diff options
Diffstat (limited to 'binfilter/bf_sw/source/filter')
97 files changed, 50384 insertions, 0 deletions
diff --git a/binfilter/bf_sw/source/filter/ascii/makefile.mk b/binfilter/bf_sw/source/filter/ascii/makefile.mk new file mode 100644 index 000000000000..d49daeefd76d --- /dev/null +++ b/binfilter/bf_sw/source/filter/ascii/makefile.mk @@ -0,0 +1,53 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_ascii + +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/sw_ascatr.obj \ + $(SLO)$/sw_wrtasc.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx b/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx new file mode 100644 index 000000000000..bf351cc9b3b9 --- /dev/null +++ b/binfilter/bf_sw/source/filter/ascii/sw_ascatr.cxx @@ -0,0 +1,228 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <tools/stream.hxx> +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_USHORTS +#endif + +#include <errhdl.hxx> + +#include <pam.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <ndtxt.hxx> +#include <wrtasc.hxx> +#include <txtfld.hxx> +#include <fmtftn.hxx> +#include <fmtfld.hxx> +#include <fldbas.hxx> +#include <ftninfo.hxx> +namespace binfilter { + +/* + * Dieses File enthaelt alle Ausgabe-Funktionen des ASCII-Writers; + * fuer alle Nodes, Attribute, Formate und Chars. + */ + +class SwASC_AttrIter +{ + SwASCWriter& rWrt; + const SwTxtNode& rNd; + xub_StrLen nAktSwPos; + + xub_StrLen SearchNext( xub_StrLen nStartPos ); + +public: + SwASC_AttrIter( SwASCWriter& rWrt, const SwTxtNode& rNd, xub_StrLen nStt ); + + void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); } + + xub_StrLen WhereNext() const { return nAktSwPos; } + BOOL OutAttr( xub_StrLen nSwPos ); +}; + + +/*N*/ SwASC_AttrIter::SwASC_AttrIter( SwASCWriter& rWr, const SwTxtNode& rTxtNd, +/*N*/ xub_StrLen nStt ) +/*N*/ : rWrt( rWr ), rNd( rTxtNd ), nAktSwPos( 0 ) +/*N*/ { +/*N*/ nAktSwPos = SearchNext( nStt + 1 ); +/*N*/ } + + +/*N*/ xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos ) +/*N*/ { +/*N*/ register xub_StrLen nMinPos = STRING_MAXLEN; +/*N*/ const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); +/*N*/ if( pTxtAttrs ) +/*N*/ { +/*?*/ 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( !pPos ) +/*?*/ { +/*?*/ if( nPos >= nStartPos && nPos <= nMinPos ) +/*?*/ nMinPos = nPos; +/*?*/ +/*?*/ if( ( ++nPos ) >= nStartPos && nPos < nMinPos ) +/*?*/ nMinPos = nPos; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ return nMinPos; +/*N*/ } + + +/*N*/ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); +/*N*/ if( pTxtAttrs ) +/*N*/ { +/*?*/ 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: + {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 /*?*/ 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() ) +/*?*/ rWrt.Strm().WriteUnicodeOrByteText( sOut ); +/*?*/ } +/*?*/ else if( nSwPos < *pHt->GetStart() ) +/*?*/ break; +/*?*/ } +/*N*/ } +/*N*/ return bRet; +/*N*/ } + + +//------------------------ +/* Ausgabe der Nodes */ +//------------------------ + +/*N*/ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) +/*N*/ { +/*N*/ const SwTxtNode& rNd = (SwTxtNode&)rNode; +/*N*/ +/*N*/ xub_StrLen nStrPos = rWrt.pCurPam->GetPoint()->nContent.GetIndex(); +/*N*/ xub_StrLen nNodeEnde = rNd.Len(), nEnde = nNodeEnde; +/*N*/ BOOL bLastNd = rWrt.pCurPam->GetPoint()->nNode == rWrt.pCurPam->GetMark()->nNode; +/*N*/ if( bLastNd ) +/*N*/ nEnde = rWrt.pCurPam->GetMark()->nContent.GetIndex(); +/*N*/ +/*N*/ SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos ); +/*N*/ +/*N*/ if( !nStrPos ) +/*N*/ rWrt.Strm().WriteUnicodeOrByteText( rNd.GetNumString() ); +/*N*/ +/*N*/ String aStr( rNd.GetTxt() ); +/*N*/ if( rWrt.bASCII_ParaAsBlanc ) +/*?*/ aStr.SearchAndReplaceAll( 0x0A, ' ' ); +/*N*/ +/*N*/ do { +/*N*/ xub_StrLen nNextAttr = aAttrIter.WhereNext(); +/*N*/ +/*N*/ if( nNextAttr > nEnde ) +/*N*/ nNextAttr = nEnde; +/*N*/ +/*N*/ if( !aAttrIter.OutAttr( nStrPos )) +/*N*/ rWrt.Strm().WriteUnicodeOrByteText( +/*N*/ aStr.Copy( nStrPos, nNextAttr - nStrPos )); +/*N*/ nStrPos = nNextAttr; +/*N*/ aAttrIter.NextPos(); +/*N*/ } while( nStrPos < nEnde ); +/*N*/ +/*N*/ if( !bLastNd || +/*N*/ ( !rWrt.bWriteClipboardDoc && !rWrt.bASCII_NoLastLineEnd ) +/*N*/ && !nStrPos && nEnde == nNodeEnde ) +/*?*/ rWrt.Strm().WriteUnicodeOrByteText( ((SwASCWriter&)rWrt).GetLineEnd()); +/*N*/ +/*N*/ return rWrt; +/*N*/ } + +/* + * 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 +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx b/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx new file mode 100644 index 000000000000..4e777638de33 --- /dev/null +++ b/binfilter/bf_sw/source/filter/ascii/sw_wrtasc.cxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#include <tools/stream.hxx> + +#include <errhdl.hxx> + +#include <pam.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <ndtxt.hxx> +#include <mdiexp.hxx> // ...Percent() +#include <docary.hxx> +#include <fmtcntnt.hxx> +#include <frmfmt.hxx> +#include <wrtasc.hxx> + +#include <statstr.hrc> // ResId fuer Statusleiste +#include <osl/endian.h> +namespace binfilter { + +//----------------------------------------------------------------- + +/*N*/ SwASCWriter::SwASCWriter( const String& rFltNm ) +/*N*/ { +/*N*/ SwAsciiOptions aNewOpts; +/*N*/ +/*N*/ switch( 5 <= rFltNm.Len() ? rFltNm.GetChar( 4 ) : 0 ) +/*N*/ { +/*?*/ case 'D': +/*?*/ #if !defined(PM2) +/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_IBM_850 ); +/*?*/ aNewOpts.SetParaFlags( LINEEND_CRLF ); +/*?*/ #endif +/*?*/ 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': +/*?*/ #if !defined(WIN) && !defined(WNT) +/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 ); +/*?*/ aNewOpts.SetParaFlags( LINEEND_CRLF ); +/*?*/ #endif +/*?*/ break; +/*?*/ +/*?*/ case 'M': +/*?*/ #if !defined(MAC) +/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_APPLE_ROMAN ); +/*?*/ aNewOpts.SetParaFlags( LINEEND_CR ); +/*?*/ #endif +/*?*/ break; +/*?*/ +/*?*/ case 'X': +/*?*/ #if !defined(UNX) +/*?*/ aNewOpts.SetCharSet( RTL_TEXTENCODING_MS_1252 ); +/*?*/ aNewOpts.SetParaFlags( LINEEND_LF ); +/*?*/ #endif +/*?*/ break; +/*?*/ +/*N*/ default: +/*N*/ if( rFltNm.Copy( 4 ).EqualsAscii( "_DLG" )) +/*N*/ { +/*N*/ // use the options +/*N*/ aNewOpts = GetAsciiOptions(); +/*N*/ } +/*N*/ } +/*N*/ SetAsciiOptions( aNewOpts ); +/*N*/ } + +/*N*/ SwASCWriter::~SwASCWriter() {} + +/*N*/ ULONG SwASCWriter::WriteStream() +/*N*/ { +/*N*/ sal_Char cLineEnd[ 3 ]; +/*N*/ sal_Char* pCEnd = cLineEnd; +/*N*/ if( bASCII_ParaAsCR ) // falls vorgegeben ist. +/*?*/ *pCEnd++ = '\015'; +/*N*/ else if( bASCII_ParaAsBlanc ) +/*?*/ *pCEnd++ = ' '; +/*N*/ else +/*N*/ switch( GetAsciiOptions().GetParaFlags() ) +/*N*/ { +/*?*/ case LINEEND_CR: *pCEnd++ = '\015'; break; +/*?*/ case LINEEND_LF: *pCEnd++ = '\012'; break; +/*N*/ case LINEEND_CRLF: *pCEnd++ = '\015', *pCEnd++ = '\012'; break; +/*N*/ } +/*N*/ *pCEnd = 0; +/*N*/ +/*N*/ sLineEnd.AssignAscii( cLineEnd ); +/*N*/ +/*N*/ long nMaxNode = pDoc->GetNodes().Count(); +/*N*/ +/*N*/ if( bShowProgress ) +/*N*/ ::binfilter::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() ); +/*N*/ +/*N*/ SwPaM* pPam = pOrigPam; +/*N*/ +/*N*/ BOOL bWriteSttTag = bUCS2_WithStartChar && +/*M*/ (RTL_TEXTENCODING_UCS2 == GetAsciiOptions().GetCharSet() || +/*M*/ RTL_TEXTENCODING_UTF8 == GetAsciiOptions().GetCharSet()); +/*N*/ +/*N*/ rtl_TextEncoding eOld = Strm().GetStreamCharSet(); +/*N*/ Strm().SetStreamCharSet( GetAsciiOptions().GetCharSet() ); +/*N*/ +/*N*/ // gebe alle Bereich des Pams in das ASC-File aus. +/*N*/ do { +/*N*/ BOOL bTstFly = TRUE; +/*N*/ while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() || +/*N*/ (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() && +/*N*/ pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) ) +/*N*/ { +/*N*/ SwTxtNode* pNd = pCurPam->GetPoint()->nNode.GetNode().GetTxtNode(); +/*N*/ if( pNd ) +/*N*/ { +/*N*/ // sollten nur Rahmen vorhanden sein? +/*N*/ // (Moeglich, wenn Rahmen-Selektion ins Clipboard +/*N*/ // gestellt wurde) +/*N*/ if( bTstFly && bWriteAll && +/*N*/ // keine Laenge +/*N*/ !pNd->GetTxt().Len() && +/*N*/ // Rahmen vorhanden +/*N*/ pDoc->GetSpzFrmFmts()->Count() && +/*N*/ // nur ein Node im Array +/*N*/ pDoc->GetNodes().GetEndOfExtras().GetIndex() + 3 == +/*N*/ pDoc->GetNodes().GetEndOfContent().GetIndex() && +/*N*/ // und genau der ist selektiert +/*N*/ pDoc->GetNodes().GetEndOfContent().GetIndex() - 1 == +/*N*/ pCurPam->GetPoint()->nNode.GetIndex() ) +/*N*/ { +/*N*/ // dann den Inhalt vom Rahmen ausgeben. +/*N*/ // dieser steht immer an Position 0 !! +/*?*/ SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[ 0 ]; +/*?*/ const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); +/*?*/ if( pIdx ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 delete pCurPam; +/*N*/ } +/*N*/ } +/*N*/ else +/*M*/ { +/*M*/ if (bWriteSttTag) +/*M*/ { +/*M*/ switch(GetAsciiOptions().GetCharSet()) +/*M*/ { +/*M*/ case RTL_TEXTENCODING_UTF8: +/*M*/ Strm() << BYTE(0xEF) << BYTE(0xBB) << +/*M*/ BYTE(0xBF); +/*M*/ break; +/*M*/ case RTL_TEXTENCODING_UCS2: +/*M*/ //Strm().StartWritingUnicodeText(); +/*M*/ Strm().SetEndianSwap(FALSE); +/*M*/ #ifdef OSL_LITENDIAN +/*M*/ Strm() << BYTE(0xFF) << BYTE(0xFE); +/*M*/ #else +/*M*/ Strm() << BYTE(0xFE) << BYTE(0xFF); +/*M*/ #endif +/*M*/ break; +/*M*/ +/*M*/ } +/*?*/ bWriteSttTag = FALSE; +/*N*/ } +/*N*/ Out( aASCNodeFnTab, *pNd, *this ); +/*N*/ } +/*N*/ bTstFly = FALSE; // eimal Testen reicht +/*N*/ } +/*N*/ +/*N*/ if( !pCurPam->Move( fnMoveForward, fnGoNode ) ) +/*N*/ break; +/*N*/ +/*N*/ if( bShowProgress ) +/*N*/ ::binfilter::SetProgressState( pCurPam->GetPoint()->nNode.GetIndex(), +/*N*/ pDoc->GetDocShell() ); // Wie weit ? +/*N*/ +/*N*/ } +/*N*/ } while( CopyNextPam( &pPam ) ); // bis alle Pam bearbeitet +/*N*/ +/*N*/ Strm().SetStreamCharSet( eOld ); +/*N*/ +/*N*/ if( bShowProgress ) +/*N*/ ::binfilter::EndProgress( pDoc->GetDocShell() ); +/*N*/ +/*N*/ return 0; +/*N*/ } + + +/*N*/ void GetASCWriter( const String& rFltNm, WriterRef& xRet ) +/*N*/ { +/*N*/ xRet = new SwASCWriter( rFltNm ); +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx b/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx new file mode 100644 index 000000000000..cd90f32eff03 --- /dev/null +++ b/binfilter/bf_sw/source/filter/ascii/wrtasc.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _WRTASC_HXX +#define _WRTASC_HXX + +#include <shellio.hxx> +#include <wrt_fn.hxx> +namespace binfilter { + +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; } +}; + + +} //namespace binfilter +#endif // _WRTASC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/basflt/makefile.mk b/binfilter/bf_sw/source/filter/basflt/makefile.mk new file mode 100644 index 000000000000..a32ee7eb3178 --- /dev/null +++ b/binfilter/bf_sw/source/filter/basflt/makefile.mk @@ -0,0 +1,64 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_basflt + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw + +.IF "$(mydebug)" != "" +CDEFS+=-Dmydebug +.ENDIF + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/sw_docfact.obj \ + $(SLO)$/sw_fltini.obj \ + $(SLO)$/sw_shellio.obj \ + $(SLO)$/sw_w4wflt.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/basflt/sw_docfact.cxx b/binfilter/bf_sw/source/filter/basflt/sw_docfact.cxx new file mode 100644 index 000000000000..164236dc884b --- /dev/null +++ b/binfilter/bf_sw/source/filter/basflt/sw_docfact.cxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#include <shellio.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include <errhdl.hxx> + + +#include <cmdid.h> +namespace binfilter { + + +/****************************************************************************** + * Methode : SwDocFac::SwDocFac( SwDoc *pDoc ) + * Beschreibung: + * Erstellt : OK 01-24-94 11:32am + * Aenderung : OK 01-24-94 11:32am + ******************************************************************************/ + + +/*N*/ SwDocFac::SwDocFac( SwDoc *pDc ) +/*N*/ : pDoc( pDc ) +/*N*/ { +/*N*/ if( pDoc ) +/*N*/ pDoc->AddLink(); +/*N*/ } + +/****************************************************************************** + * Methode : SwDocFac::~SwDocFac() + * Beschreibung: + * Erstellt : OK 01-24-94 11:33am + * Aenderung : OK 01-24-94 11:33am + ******************************************************************************/ + + +/*N*/ SwDocFac::~SwDocFac() +/*N*/ { +/*N*/ if( pDoc && !pDoc->RemoveLink() ) +/*?*/ delete pDoc; +/*N*/ } + +/****************************************************************************** + * Methode : SwDoc *SwDocFac::GetDoc() + * Beschreibung: Diese Methode legt immer einen Drucker an. + * Erstellt : OK 01-24-94 11:34am + * Aenderung : OK 01-24-94 11:34am + ******************************************************************************/ + + +/*N*/ SwDoc *SwDocFac::GetDoc() +/*N*/ { +/*N*/ if( !pDoc ) +/*N*/ { +/*N*/ pDoc = new SwDoc; +/*N*/ pDoc->AddLink(); +/*N*/ } +/*N*/ return pDoc; +/*N*/ } + + +/****************************************************************************** + * Erstellt : JP 01-27-94 11:37am + * Aenderung : JP 01-27-94 11:37am + ******************************************************************************/ + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/basflt/sw_fltini.cxx b/binfilter/bf_sw/source/filter/basflt/sw_fltini.cxx new file mode 100644 index 000000000000..7a64bb2b2f4b --- /dev/null +++ b/binfilter/bf_sw/source/filter/basflt/sw_fltini.cxx @@ -0,0 +1,1087 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define _SVSTDARR_STRINGS + +#include <string.h> +#include <stdio.h> // sscanf + +#include <hintids.hxx> + +#include <bf_sfx2/fcontnr.hxx> +#include <bf_sfx2/docfile.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/tstpitem.hxx> +#include <frmatr.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <docary.hxx> + +#include <errhdl.hxx> + +#include <pam.hxx> +#include <errhdl.hxx> +#include <wdocsh.hxx> +#include <fltini.hxx> +#include <swgpar.hxx> // fuer den SW/G Parser +#include <sw3io.hxx> +#include <w4wflt.hxx> // AutoDetect +// enable implementation and members +#define IS_SW_DLL 1 +#include <iodetect.hxx> +#include <hints.hxx> +#include <numrule.hxx> +#include <ndtxt.hxx> +#include <swfltopt.hxx> + +#include <swerror.h> + +#include <bf_svtools/moduleoptions.hxx> + +namespace binfilter { + +using namespace utl; +using namespace rtl; +using namespace ::com::sun::star::uno; + +SwRead ReadRtf = 0, ReadAscii = 0, ReadSwg = 0, ReadSw3 = 0, + ReadHTML = 0, ReadXML = 0; + +/*N*/ inline BOOL IsDocShellRegistered() { return SvtModuleOptions().IsWriter(); } + + +/*N*/ IO_DETECT_IMPL1 +/*N*/ IO_DETECT_IMPL2 +/*N*/ IO_DETECT_IMPL3 +/*N*/ IO_DETECT_IMPL4 + + +/*N*/ inline void _SetFltPtr( USHORT& rPos, SwRead pReader +/*N*/ , const sal_Char* pNm +/* pNm optimiert der Compiler weg, wird nur in der nicht PRODUCT benoetigt! */ +/*N*/ ) +/*N*/ { +/*N*/ ASSERT( !strcmp( aReaderWriter[ rPos ].pName, pNm ), "falscher Filter" ); +/*N*/ aReaderWriter[ rPos++ ].pReader = pReader; +/*N*/ } + +/*N*/ void _InitFilter() +/*N*/ { +/*N*/ SwRead pRd; +/*N*/ +/*N*/ USHORT nCnt = 0; +/*N*/ _SetFltPtr( nCnt, (ReadSw3 = new Sw3Reader), FILTER_SW5 ); +/*N*/ _SetFltPtr( nCnt, ReadSw3, FILTER_SW4 ); +/*N*/ _SetFltPtr( nCnt, ReadSw3, FILTER_SW3 ); +/*N*/ _SetFltPtr( nCnt, (ReadSwg = new SwgReader), FILTER_SWG ); +/*N*/ _SetFltPtr( nCnt, ReadSwg, FILTER_SWGV ); +/*?*/ _SetFltPtr( nCnt, new Sw6Reader, sSwDos ); +/*N*/ _SetFltPtr( nCnt, (ReadAscii = new AsciiReader), FILTER_BAS ); +/*N*/ _SetFltPtr( nCnt, new W4WReader, FILTER_W4W ); +/*N*/ _SetFltPtr( nCnt, ( pRd = new ExcelReader ), sCExcel ); +/*N*/ _SetFltPtr( nCnt, pRd, sExcel ); +/*N*/ _SetFltPtr( nCnt, new LotusReader, sLotusD ); +/*N*/ _SetFltPtr( nCnt, ReadSwg, sSwg1 ); +/*?*/ _SetFltPtr( nCnt, (ReadXML = new XMLReader), FILTER_XML ); +/*N*/ +/*N*/ +/*N*/ _SetFltPtr( nCnt, ReadAscii, FILTER_TEXT ); +/*N*/ +/*N*/ ASSERT( MAXFILTER == nCnt, "Anzahl Filter ungleich der Definierten" ); +/*N*/ } + + + + +/*N*/ void _FinitFilter() +/*N*/ { +/*N*/ // die Reader vernichten +/*N*/ for( USHORT n = 0; n < MAXFILTER; ++n ) +/*N*/ { +/*N*/ SwIoDetect& rIo = aReaderWriter[n]; +/*N*/ if( rIo.bDelReader && rIo.pReader ) +/*N*/ delete rIo.pReader; +/*N*/ } +/*N*/ } + + +/* */ + +/*N*/ void SwIoSystem::GetWriter( const String& rFltName, WriterRef& xRet ) +/*N*/ { +/*N*/ for( USHORT n = 0; n < MAXFILTER; ++n ) +/*N*/ if( aReaderWriter[n].IsFilter( rFltName ) ) +/*N*/ { +/*N*/ aReaderWriter[n].GetWriter( rFltName, xRet ); +/*N*/ break; +/*N*/ } +/*N*/ } + + + SwRead SwIoSystem::GetReader( const String& rFltName ) + { + SwRead pRead = 0; + for( USHORT n = 0; n < MAXFILTER; ++n ) + if( aReaderWriter[n].IsFilter( rFltName ) ) + { + pRead = aReaderWriter[n].GetReader(); + // fuer einige Reader noch eine Sonderbehandlung: + pRead->SetFltName( rFltName ); + break; + } + return pRead; + } + + // suche ueber den Filtertext den Filtereintrag +/*N*/ const SfxFilter* SwIoSystem::GetFilterOfFilterTxt( const String& rFilterNm, +/*N*/ const SfxFactoryFilterContainer* pCnt ) +/*N*/ { +/*N*/ const SfxFactoryFilterContainer* pFltCnt = pCnt ? pCnt : +/*N*/ ( IsDocShellRegistered() +/*N*/ ? SwDocShell::Factory().GetFilterContainer() +/*N*/ : SwWebDocShell::Factory().GetFilterContainer() ); +/*N*/ +/*N*/ do { +/*N*/ if( pFltCnt ) +/*N*/ { +/*N*/ const SfxFilter* pFilter; +/*N*/ USHORT nCount = pFltCnt->GetFilterCount(); +/*N*/ for( USHORT i = 0; i < nCount; ++i ) +/*N*/ if( ( pFilter = pFltCnt->GetFilter( i ))->GetFilterName() == rFilterNm ) +/*N*/ return pFilter; +/*N*/ } +/*?*/ if( pCnt || pFltCnt == SwWebDocShell::Factory().GetFilterContainer()) +/*?*/ break; +/*?*/ pFltCnt = SwWebDocShell::Factory().GetFilterContainer(); +/*?*/ } while( TRUE ); +/*?*/ +/*?*/ return 0; +/*N*/ } + + +/* */ + +/////////////// die Storage Reader/Writer //////////////////////////////// + + +/*N*/ void GetSw3Writer( const String&, WriterRef& xRet ) +/*N*/ { +/*N*/ xRet = new Sw3Writer; +/*N*/ } + + + ULONG StgReader::OpenMainStream( SvStorageStreamRef& rRef, USHORT& rBuffSize ) + { + ULONG nRet = ERR_SWG_READ_ERROR; + ASSERT( pStg, "wo ist mein Storage?" ); + const SfxFilter* pFltr = SwIoSystem::GetFilterOfFormat( aFltName ); + if( pFltr ) + { + rRef = pStg->OpenStream( SwIoSystem::GetSubStorageName( *pFltr ), + STREAM_READ | STREAM_SHARE_DENYALL ); + + if( rRef.Is() ) + { + if( SVSTREAM_OK == rRef->GetError() ) + { + USHORT nOld = rRef->GetBufferSize(); + rRef->SetBufferSize( rBuffSize ); + rBuffSize = nOld; + nRet = 0; + } + else + nRet = rRef->GetError(); + } + } + return nRet; + } + +/* */ + + +/*N*/ ULONG Sw3Reader::Read( SwDoc &rDoc, SwPaM &rPam, const String & ) +/*N*/ { +/*N*/ ULONG nRet; +/*N*/ if( pStg && pIO ) +/*N*/ { +/*N*/ // TRUE: Vorlagen ueberschreiben +/*N*/ pIO->SetReadOptions( aOpt,TRUE ); +/*N*/ if( !bInsertMode ) +/*N*/ { +/*N*/ // Im Laden-Modus darf der PaM-Content-Teil nicht +/*N*/ // in den Textbereich zeigen (Nodes koennen geloescht werden) +/*N*/ rPam.GetBound( TRUE ).nContent.Assign( 0, 0 ); +/*N*/ rPam.GetBound( FALSE ).nContent.Assign( 0, 0 ); +/*N*/ } +/*N*/ nRet = pIO->Load( pStg, bInsertMode ? &rPam : 0 ); +/*N*/ aOpt.ResetAllFmtsOnly(); +/*N*/ pIO->SetReadOptions( aOpt, TRUE ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ASSERT( !this, "Sw3-Read ohne Storage und/oder IO-System" ); +/*?*/ nRet = ERR_SWG_READ_ERROR; +/*N*/ } +/*N*/ return nRet; +/*N*/ } + + // read the sections of the document, which is equal to the medium. + // returns the count of it + + +/*N*/ ULONG Sw3Writer::WriteStorage() +/*N*/ { +/*N*/ ULONG nRet; +/*N*/ if( pIO ) +/*N*/ { +/*N*/ // der gleiche Storage -> Save, sonst SaveAs aufrufen +/*N*/ if( !bSaveAs ) +/*?*/ nRet = pIO->Save( pOrigPam, bWriteAll ); +/*N*/ else +/*N*/ nRet = pIO->SaveAs( pStg, pOrigPam, bWriteAll ); +/*N*/ +/*N*/ pIO = 0; // nach dem Schreiben ist der Pointer ungueltig !! +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ASSERT( !this, "Sw3-Writer ohne IO-System" ) +/*?*/ nRet = ERR_SWG_WRITE_ERROR; +/*N*/ } +/*N*/ return nRet; +/*N*/ } + + + + + + + + BOOL Writer::IsStgWriter() const { return FALSE; } + BOOL Writer::IsSw3Writer() const { return FALSE; } + + +/* */ + + +ULONG SwgReader::Read( SwDoc &rDoc, SwPaM &rPam, const String& rFileName ) +{ + if( !pStrm ) + { + ASSERT( !this, "SWG-Read ohne Stream" ); + return ERR_SWG_READ_ERROR; + } + SwSwgParser *pSwgParser = new SwSwgParser( &rDoc, &rPam, pStrm, + rFileName, !bInsertMode ); + USHORT nBits = SWGRD_NORMAL; + SwgReader* pRdr = (SwgReader*) ReadSwg; + if( pRdr->aOpt.IsFmtsOnly() ) + { + nBits = 0; + if( pRdr->aOpt.IsFrmFmts() ) nBits |= SWGRD_FRAMEFMTS; + if( pRdr->aOpt.IsTxtFmts() ) nBits |= SWGRD_CHARFMTS | SWGRD_PARAFMTS; + if( pRdr->aOpt.IsPageDescs() ) nBits |= SWGRD_PAGEFMTS; + if( !pRdr->aOpt.IsMerge() ) + nBits |= SWGRD_FORCE; + } + ULONG nRet = pSwgParser->CallParser( nBits ); + delete pSwgParser; + + // die Flags muessen natuerlich wieder geloescht werden! + pRdr->aOpt.ResetAllFmtsOnly(); + + return nRet; +} + + + BOOL SwReader::NeedsPasswd( const Reader& rOptions ) + { + BOOL bRes = FALSE; + if( &rOptions == ReadSwg ) + { + if( !pStrm && pMedium && !pMedium->IsStorage() ) + pStrm = pMedium->GetInStream(); + + ASSERT( pStrm, "Passwort-Test ohne Stream" ); + if( pStrm ) + { + SwSwgParser *pSwgParser = new SwSwgParser( pStrm ); + bRes = pSwgParser->NeedsPasswd(); + delete pSwgParser; + } + } + return bRes; + } + + + BOOL SwReader::CheckPasswd( const String& rPasswd, const Reader& rOptions ) + { + BOOL bRes = TRUE; + if( &rOptions == ReadSwg ) + { + if( !pStrm && pMedium && !pMedium->IsStorage() ) + pStrm = pMedium->GetInStream(); + + ASSERT( pStrm, "Passwort-Check ohne Stream" ); + if( pStrm ) + { + SwSwgParser *pSwgParser = new SwSwgParser( pStrm ); + bRes = pSwgParser->CheckPasswd( rPasswd ); + delete pSwgParser; + } + } + return bRes; + } + +/* */ + +//----------------------------------------------------------------------- +// Filter Flags lesen, wird von WW8 / W4W / EXCEL / LOTUS benutzt. +//----------------------------------------------------------------------- + +/* +<FilterFlags> + <Excel_Lotus> + <MinRow cfg:type="long">0</MinRow> + <MaxRow cfg:type="long">0</MaxRow> + <MinCol cfg:type="long">0</MinCol> + <MaxCol cfg:type="long">0</MaxCol> + </Excel_Lotus> + <W4W> + <W4WHD cfg:type="long">0</W4WHD> + <W4WFT cfg:type="long">0</W4WFT> + <W4W000 cfg:type="long">0</W4W000> + </W4W> + <WinWord> + <WW1F cfg:type="long">0</WW1F> + <WW cfg:type="long">0</WW> + <WW8 cfg:type="long">0</WW8> + <WWF cfg:type="long">0</WWF> + <WWFA0 cfg:type="long">0</WWFA0> + <WWFA1 cfg:type="long">0</WWFA1> + <WWFA2 cfg:type="long">0</WWFA2> + <WWFB0 cfg:type="long">0</WWFB0> + <WWFB1 cfg:type="long">0</WWFB1> + <WWFB2 cfg:type="long">0</WWFB2> + <WWFLX cfg:type="long">0</WWFLX> + <WWFLY cfg:type="long">0</WWFLY> + <WWFT cfg:type="long">0</WWFT> + <WWWR cfg:type="long">0</WWWR> + </WinWord> + <Writer> + <SW3Imp cfg:type="long">0</SW3Imp> + </Writer> +</FilterFlags> +*/ + +/*N*/ #define FILTER_OPTION_ROOT String::CreateFromAscii( \ +/*N*/ RTL_CONSTASCII_STRINGPARAM( "Office.Writer/FilterFlags" ) ) + + SwFilterOptions::SwFilterOptions() + : ConfigItem( FILTER_OPTION_ROOT ) + { + } + +/*N*/ SwFilterOptions::SwFilterOptions( sal_uInt16 nCnt, const sal_Char** ppNames, +/*N*/ sal_uInt32* pValues ) +/*N*/ : ConfigItem( FILTER_OPTION_ROOT ) +/*N*/ { +/*N*/ GetValues( nCnt, ppNames, pValues ); +/*N*/ } + +/*N*/ void SwFilterOptions::GetValues( sal_uInt16 nCnt, const sal_Char** ppNames, +/*N*/ sal_uInt32* pValues ) +/*N*/ { +/*N*/ Sequence<OUString> aNames( nCnt ); +/*N*/ OUString* pNames = aNames.getArray(); + USHORT n=0; +/*N*/ for( n = 0; n < nCnt; ++n ) +/*N*/ pNames[ n ] = OUString::createFromAscii( ppNames[ n ] ); +/*N*/ Sequence<Any> aValues = GetProperties( aNames ); +/*N*/ +/*N*/ if( nCnt == aValues.getLength() ) +/*N*/ { +/*N*/ const Any* pAnyValues = aValues.getConstArray(); +/*N*/ for( n = 0; n < nCnt; ++n ) +/*N*/ pValues[ n ] = pAnyValues[ n ].hasValue() +/*N*/ ? *(sal_uInt32*)pAnyValues[ n ].getValue() +/*N*/ : 0; +/*N*/ } +/*N*/ else +/*?*/ for( n = 0; n < nCnt; ++n ) +/*?*/ pValues[ n ] = 0; +/*N*/ } + + sal_Bool SwFilterOptions::CheckNodeContentExist( const sal_Char* pNode, + const sal_Char* pCntnt ) + { + Sequence<OUString> aNames( GetNodeNames( + OUString::createFromAscii( pNode ))); + sal_Bool bExist = sal_False; + const OUString* pNames = aNames.getConstArray(); + for( long n = 0, nEnd = aNames.getLength(); n < nEnd; ++n, ++pNames ) + if( !pNames->compareToAscii( pCntnt )) + { + bExist = sal_True; + break; + } + return bExist; + } + +/* */ + + + + + + +/* */ + +SwRelNumRuleSpaces::SwRelNumRuleSpaces( SwDoc& rDoc, BOOL bNDoc ) + : bNewDoc( bNDoc ) +{ + pNumRuleTbl = new SwNumRuleTbl( 8, 8 ); + if( !bNDoc ) + pNumRuleTbl->Insert( &rDoc.GetNumRuleTbl(), 0 ); +} + +SwRelNumRuleSpaces::~SwRelNumRuleSpaces() +{ + if( pNumRuleTbl ) + { + pNumRuleTbl->Remove( 0, pNumRuleTbl->Count() ); + delete pNumRuleTbl; + } +} + +void SwRelNumRuleSpaces::SetNumRelSpaces( SwDoc& rDoc ) +{ + SwNumRuleTbl* pRuleTbl = bNewDoc ? &rDoc.GetNumRuleTbl() : pNumRuleTbl; + if( !bNewDoc ) + { + // jetzt alle schon vorhanden NumRules aus dem Array entfernen, + // damit nur die neuen angepasst werden + SwNumRuleTbl aNumRuleTbl; + aNumRuleTbl.Insert( pRuleTbl, 0 ); + pRuleTbl->Remove( 0, pRuleTbl->Count() ); + const SwNumRuleTbl& rRuleTbl = rDoc.GetNumRuleTbl(); + SwNumRule* pRule; + + for( USHORT n = 0; n < rRuleTbl.Count(); ++n ) + if( USHRT_MAX == aNumRuleTbl.GetPos( ( pRule = rRuleTbl[ n ] ))) + // war noch nicht vorhanden, also neu + pRuleTbl->Insert( pRule, pRuleTbl->Count() ); + + aNumRuleTbl.Remove( 0, aNumRuleTbl.Count() ); + } + + if( pRuleTbl ) + { + for( USHORT n = pRuleTbl->Count(); n; ) + { + SwNumRule* pRule = (*pRuleTbl)[ --n ]; + // Rule noch gueltig und am Doc vorhanden? + if( USHRT_MAX != rDoc.GetNumRuleTbl().GetPos( pRule )) + { + SwNumRuleInfo aUpd( pRule->GetName() ); + aUpd.MakeList( rDoc ); + + // bei allen nmumerierten Absaetzen vom linken Rand + // den absoluten Wert des NumFormates abziehen + for( ULONG nUpdPos = 0; nUpdPos < aUpd.GetList().Count(); + ++nUpdPos ) + { + SwTxtNode* pNd = aUpd.GetList().GetObject( nUpdPos ); + SetNumLSpace( *pNd, *pRule ); + } + } + } + } + + if( pNumRuleTbl ) + { + pNumRuleTbl->Remove( 0, pNumRuleTbl->Count() ); + delete pNumRuleTbl, pNumRuleTbl = 0; + } + + if( bNewDoc ) + { + SetOultineRelSpaces( SwNodeIndex( rDoc.GetNodes() ), + SwNodeIndex( rDoc.GetNodes().GetEndOfContent())); + } +} + +void SwRelNumRuleSpaces::SetOultineRelSpaces( const SwNodeIndex& rStt, + const SwNodeIndex& rEnd ) +{ + SwDoc* pDoc = rStt.GetNode().GetDoc(); + const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds(); + if( rOutlNds.Count() ) + { + USHORT nPos; + rOutlNds.Seek_Entry( &rStt.GetNode(), &nPos ); + for( ; nPos < rOutlNds.Count() && + rOutlNds[ nPos ]->GetIndex() < rEnd.GetIndex(); ++nPos ) + { + SwTxtNode* pNd = rOutlNds[ nPos ]->GetTxtNode(); + if( pNd->GetOutlineNum() && !pNd->GetNumRule() ) + SetNumLSpace( *pNd, *pDoc->GetOutlineNumRule() ); + } + } +} + +void SwRelNumRuleSpaces::SetNumLSpace( SwTxtNode& rNd, const SwNumRule& rRule ) +{ + BOOL bOutlineRule = OUTLINE_RULE == rRule.GetRuleType(); + BYTE nLvl; + { + SwNodeNum aNdNum( 0 ); + const SwNodeNum* pNum; + if( bOutlineRule ) + { + if( 0 == ( pNum = rNd.GetOutlineNum() )) + pNum = rNd.UpdateOutlineNum( aNdNum ); + } + else if( 0 == ( pNum = rNd.GetNum() )) + pNum = rNd.UpdateNum( aNdNum ); + nLvl = GetRealLevel( pNum->GetLevel() ); + } + const SwNumFmt& rFmt = rRule.Get( nLvl ); + const SvxLRSpaceItem& rLR = rNd.GetSwAttrSet().GetLRSpace(); + + SvxLRSpaceItem aLR( rLR ); + aLR.SetTxtFirstLineOfst( 0 ); + + // sagt der Node, das die Numerierung den Wert vorgibt? + if( !bOutlineRule && rNd.IsSetNumLSpace() ) + aLR.SetTxtLeft( 0 ); + else + { + long nLeft = rFmt.GetAbsLSpace(), nParaLeft = rLR.GetTxtLeft(); + if( 0 < rLR.GetTxtFirstLineOfst() ) + nParaLeft += rLR.GetTxtFirstLineOfst(); + else if( nParaLeft >= nLeft ) + // #82963#/#82962#: set correct paragraph indent + nParaLeft -= nLeft; + else + //#83154#, Don't think any of the older #80856# bugfix code is + //relevent anymore. + nParaLeft = rLR.GetTxtLeft()+rLR.GetTxtFirstLineOfst(); + aLR.SetTxtLeft( nParaLeft ); + } + + if( aLR.GetTxtLeft() != rLR.GetTxtLeft() ) + { + //bevor rLR geloescht wird! + long nOffset = rLR.GetTxtLeft() - aLR.GetTxtLeft(); + rNd.SwCntntNode::SetAttr( aLR ); + + // Tabs anpassen !! + const SfxPoolItem* pItem; + if( SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState( + RES_PARATR_TABSTOP, TRUE, &pItem )) + { + SvxTabStopItem aTStop( *(SvxTabStopItem*)pItem ); + for( USHORT n = 0; n < aTStop.Count(); ++n ) + { + SvxTabStop& rTab = (SvxTabStop&)aTStop[ n ]; + if( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() ) + { + if( !rTab.GetTabPos() ) + { + aTStop.Remove( n ); + --n; + } + else + rTab.GetTabPos() += nOffset; + } + } + rNd.SwCntntNode::SetAttr( aTStop ); + } + } +} +/* */ + struct CharSetNameMap + { + rtl_TextEncoding eCode; + const sal_Char* pName; + }; + + const CharSetNameMap *GetCharSetNameMap() + { + static const CharSetNameMap aMapArr[] = + { + # define IMPLENTRY(X) { RTL_TEXTENCODING_##X, "" #X "" } + IMPLENTRY(DONTKNOW), + IMPLENTRY(MS_1252), + IMPLENTRY(APPLE_ROMAN), + IMPLENTRY(IBM_437), + IMPLENTRY(IBM_850), + IMPLENTRY(IBM_860), + IMPLENTRY(IBM_861), + IMPLENTRY(IBM_863), + IMPLENTRY(IBM_865), + IMPLENTRY(SYMBOL), + IMPLENTRY(ASCII_US), + IMPLENTRY(ISO_8859_1), + IMPLENTRY(ISO_8859_2), + IMPLENTRY(ISO_8859_3), + IMPLENTRY(ISO_8859_4), + IMPLENTRY(ISO_8859_5), + IMPLENTRY(ISO_8859_6), + IMPLENTRY(ISO_8859_7), + IMPLENTRY(ISO_8859_8), + IMPLENTRY(ISO_8859_9), + IMPLENTRY(ISO_8859_14), + IMPLENTRY(ISO_8859_15), + IMPLENTRY(IBM_737), + IMPLENTRY(IBM_775), + IMPLENTRY(IBM_852), + IMPLENTRY(IBM_855), + IMPLENTRY(IBM_857), + IMPLENTRY(IBM_862), + IMPLENTRY(IBM_864), + IMPLENTRY(IBM_866), + IMPLENTRY(IBM_869), + IMPLENTRY(MS_874), + IMPLENTRY(MS_1250), + IMPLENTRY(MS_1251), + IMPLENTRY(MS_1253), + IMPLENTRY(MS_1254), + IMPLENTRY(MS_1255), + IMPLENTRY(MS_1256), + IMPLENTRY(MS_1257), + IMPLENTRY(MS_1258), + IMPLENTRY(APPLE_ARABIC), + IMPLENTRY(APPLE_CENTEURO), + IMPLENTRY(APPLE_CROATIAN), + IMPLENTRY(APPLE_CYRILLIC), + IMPLENTRY(APPLE_DEVANAGARI), + IMPLENTRY(APPLE_FARSI), + IMPLENTRY(APPLE_GREEK), + IMPLENTRY(APPLE_GUJARATI), + IMPLENTRY(APPLE_GURMUKHI), + IMPLENTRY(APPLE_HEBREW), + IMPLENTRY(APPLE_ICELAND), + IMPLENTRY(APPLE_ROMANIAN), + IMPLENTRY(APPLE_THAI), + IMPLENTRY(APPLE_TURKISH), + IMPLENTRY(APPLE_UKRAINIAN), + IMPLENTRY(APPLE_CHINSIMP), + IMPLENTRY(APPLE_CHINTRAD), + IMPLENTRY(APPLE_JAPANESE), + IMPLENTRY(APPLE_KOREAN), + IMPLENTRY(MS_932), + IMPLENTRY(MS_936), + IMPLENTRY(MS_949), + IMPLENTRY(MS_950), + IMPLENTRY(SHIFT_JIS), + IMPLENTRY(GB_2312), + IMPLENTRY(GBT_12345), + IMPLENTRY(GBK), + IMPLENTRY(BIG5), + IMPLENTRY(EUC_JP), + IMPLENTRY(EUC_CN), + IMPLENTRY(EUC_TW), + IMPLENTRY(ISO_2022_JP), + IMPLENTRY(ISO_2022_CN), + IMPLENTRY(KOI8_R), + IMPLENTRY(KOI8_U), + IMPLENTRY(UTF7), + IMPLENTRY(UTF8), + IMPLENTRY(ISO_8859_10), + IMPLENTRY(ISO_8859_13), + IMPLENTRY(EUC_KR), + IMPLENTRY(ISO_2022_KR), + IMPLENTRY(JIS_X_0201), + IMPLENTRY(JIS_X_0208), + IMPLENTRY(JIS_X_0212), + IMPLENTRY(MS_1361), + IMPLENTRY(GB_18030), + IMPLENTRY(BIG5_HKSCS), + IMPLENTRY(TIS_620), + IMPLENTRY(UCS4), + IMPLENTRY(UCS2), + IMPLENTRY(UNICODE), + {0,0} //Last + }; + return &aMapArr[0]; + } +/* + Get a rtl_TextEncoding from its name + */ + rtl_TextEncoding CharSetFromName(const String& rChrSetStr) + { + const CharSetNameMap *pStart = GetCharSetNameMap(); + rtl_TextEncoding nRet = pStart->eCode; + + for(const CharSetNameMap *pMap = pStart; pMap->pName; ++pMap) + { + if(rChrSetStr.EqualsIgnoreCaseAscii(pMap->pName)) + { + nRet = pMap->eCode; + break; + } + } + + ASSERT(nRet != pStart->eCode, "TXT: That was an unknown language!"); + + return nRet; + } + + +/* + Get the String name of an rtl_TextEncoding + */ + + struct LangNameMap + { + LanguageType nId; + const sal_Char* pLanguageNm; + }; + + const LangNameMap *GetLangNameMap() + { + static const LangNameMap aMapArr[] = + { + {LANGUAGE_DONTKNOW, "DONTKNOW" }, + {LANGUAGE_NONE, "NONE" }, + {LANGUAGE_SYSTEM, "SYSTEM" }, + {LANGUAGE_AFRIKAANS, "AFRIKAANS" }, + {LANGUAGE_ALBANIAN, "ALBANIAN" }, + {LANGUAGE_ARABIC_PRIMARY_ONLY, "ARABIC" }, + {LANGUAGE_ARABIC_SAUDI_ARABIA, "ARABIC (SAUDI ARABIA)" }, + {LANGUAGE_ARABIC_IRAQ, "ARABIC (IRAQ)" }, + {LANGUAGE_ARABIC_EGYPT, "ARABIC (EGYPT)" }, + {LANGUAGE_ARABIC_LIBYA, "ARABIC (LIBYA)" }, + {LANGUAGE_ARABIC_ALGERIA, "ARABIC (ALGERIA)" }, + {LANGUAGE_ARABIC_MOROCCO, "ARABIC (MOROCCO)" }, + {LANGUAGE_ARABIC_TUNISIA, "ARABIC (TUNISIA)" }, + {LANGUAGE_ARABIC_OMAN, "ARABIC (OMAN)" }, + {LANGUAGE_ARABIC_YEMEN, "ARABIC (YEMEN)" }, + {LANGUAGE_ARABIC_SYRIA, "ARABIC (SYRIA)" }, + {LANGUAGE_ARABIC_JORDAN, "ARABIC (JORDAN)" }, + {LANGUAGE_ARABIC_LEBANON, "ARABIC (LEBANON)" }, + {LANGUAGE_ARABIC_KUWAIT, "ARABIC (KUWAIT)" }, + {LANGUAGE_ARABIC_UAE, "ARABIC (UAE)" }, + {LANGUAGE_ARABIC_BAHRAIN, "ARABIC (BAHRAIN)" }, + {LANGUAGE_ARABIC_QATAR, "ARABIC (QATAR)" }, + {LANGUAGE_ARMENIAN, "ARMENIAN" }, + {LANGUAGE_ASSAMESE, "ASSAMESE" }, + {LANGUAGE_AZERI, "AZERI" }, + {LANGUAGE_AZERI_LATIN, "AZERI (LATIN)" }, + {LANGUAGE_AZERI_CYRILLIC, "AZERI (CYRILLIC)" }, + {LANGUAGE_BASQUE, "BASQUE" }, + {LANGUAGE_BELARUSIAN, "BELARUSIAN" }, + {LANGUAGE_BENGALI, "BENGALI" }, + {LANGUAGE_BULGARIAN, "BULGARIAN" }, + {LANGUAGE_BURMESE, "BURMESE" }, + {LANGUAGE_CATALAN, "CATALAN" }, + {LANGUAGE_CHINESE, "CHINESE" }, + {LANGUAGE_CHINESE_TRADITIONAL, "CHINESE (TRADITIONAL)" }, + {LANGUAGE_CHINESE_SIMPLIFIED, "CHINESE (SIMPLIFIED)" }, + {LANGUAGE_CHINESE_HONGKONG, "CHINESE (HONGKONG)" }, + {LANGUAGE_CHINESE_SINGAPORE, "CHINESE (SINGAPORE)" }, + {LANGUAGE_CHINESE_MACAU, "CHINESE (MACAU)" }, + {LANGUAGE_CZECH, "CZECH" }, + {LANGUAGE_DANISH, "DANISH" }, + {LANGUAGE_DUTCH, "DUTCH" }, + {LANGUAGE_DUTCH_BELGIAN, "DUTCH_BELGIAN" }, + {LANGUAGE_ENGLISH, "ENGLISH" }, + {LANGUAGE_ENGLISH_US, "ENGLISH (US)" }, + {LANGUAGE_ENGLISH_UK, "ENGLISH (UK)" }, + {LANGUAGE_ENGLISH_AUS, "ENGLISH (AUS)" }, + {LANGUAGE_ENGLISH_CAN, "ENGLISH (CAN)" }, + {LANGUAGE_ENGLISH_NZ, "ENGLISH (NZ)" }, + {LANGUAGE_ENGLISH_EIRE, "ENGLISH (EIRE)" }, + {LANGUAGE_ENGLISH_SAFRICA, "ENGLISH (SAFRICA)" }, + {LANGUAGE_ENGLISH_JAMAICA, "ENGLISH (JAMAICA)" }, + {LANGUAGE_ENGLISH_CARRIBEAN, "ENGLISH (CARRIBEAN)" }, + {LANGUAGE_ENGLISH_BELIZE, "ENGLISH (BELIZE)" }, + {LANGUAGE_ENGLISH_TRINIDAD, "ENGLISH (TRINIDAD)" }, + {LANGUAGE_ENGLISH_ZIMBABWE, "ENGLISH (ZIMBABWE)" }, + {LANGUAGE_ENGLISH_PHILIPPINES, "ENGLISH (PHILIPPINES)" }, + {LANGUAGE_ESTONIAN, "ESTONIAN" }, + {LANGUAGE_FAEROESE, "FAEROESE" }, + {LANGUAGE_FARSI, "FARSI" }, + {LANGUAGE_FINNISH, "FINNISH" }, + {LANGUAGE_FRENCH, "FRENCH" }, + {LANGUAGE_FRENCH_BELGIAN, "FRENCH (BELGIAN)" }, + {LANGUAGE_FRENCH_CANADIAN, "FRENCH (CANADIAN)" }, + {LANGUAGE_FRENCH_SWISS, "FRENCH (SWISS)" }, + {LANGUAGE_FRENCH_LUXEMBOURG, "FRENCH (LUXEMBOURG)" }, + {LANGUAGE_FRENCH_MONACO, "FRENCH (MONACO)" }, + {LANGUAGE_FRENCH_WEST_INDIES, "FRENCH (WEST INDIES)" }, + {LANGUAGE_FRENCH_REUNION, "FRENCH (REUNION)" }, + {LANGUAGE_FRENCH_ZAIRE, "FRENCH (ZAIRE)" }, + {LANGUAGE_FRENCH_SENEGAL, "FRENCH (SENEGAL)" }, + {LANGUAGE_FRENCH_CAMEROON, "FRENCH (CAMEROON)" }, + {LANGUAGE_FRENCH_COTE_D_IVOIRE, "FRENCH (COTE D IVOIRE)"}, + {LANGUAGE_FRENCH_MALI, "FRENCH (MALI)" }, + {LANGUAGE_FRISIAN_NETHERLANDS, "FRISIAN (NETHERLANDS)" }, + {LANGUAGE_GAELIC_SCOTLAND, "GAELIC (SCOTLAND)" }, + {LANGUAGE_GAELIC_IRELAND, "GAELIC (IRELAND)" }, + {LANGUAGE_GALICIAN, "GALICIAN" }, + {LANGUAGE_GEORGIAN, "GEORGIAN" }, + {LANGUAGE_GERMAN, "GERMAN" }, + {LANGUAGE_GERMAN_SWISS, "GERMAN (SWISS)" }, + {LANGUAGE_GERMAN_AUSTRIAN, "GERMAN (AUSTRIAN)" }, + {LANGUAGE_GERMAN_LUXEMBOURG, "GERMAN (LUXEMBOURG)" }, + {LANGUAGE_GERMAN_LIECHTENSTEIN, "GERMAN (LIECHTENSTEIN)"}, + {LANGUAGE_GREEK, "GREEK" }, + {LANGUAGE_GUJARATI, "GUJARATI" }, + {LANGUAGE_HEBREW, "HEBREW" }, + {LANGUAGE_HINDI, "HINDI" }, + {LANGUAGE_HUNGARIAN, "HUNGARIAN" }, + {LANGUAGE_ICELANDIC, "ICELANDIC" }, + {LANGUAGE_INDONESIAN, "INDONESIAN" }, + {LANGUAGE_ITALIAN, "ITALIAN" }, + {LANGUAGE_ITALIAN_SWISS, "ITALIAN (SWISS)" }, + {LANGUAGE_JAPANESE, "JAPANESE" }, + {LANGUAGE_KANNADA, "KANNADA" }, + {LANGUAGE_KASHMIRI, "KASHMIRI" }, + {LANGUAGE_KASHMIRI_INDIA, "KASHMIRI (INDIA)" }, + {LANGUAGE_KAZAK, "KAZAK" }, + {LANGUAGE_KHMER, "KHMER" }, + {LANGUAGE_KIRGHIZ, "KIRGHIZ" }, + {LANGUAGE_KONKANI, "KONKANI" }, + {LANGUAGE_KOREAN, "KOREAN" }, + {LANGUAGE_KOREAN_JOHAB, "KOREAN (JOHAB)" }, + {LANGUAGE_LAO, "LAO" }, + {LANGUAGE_LATVIAN, "LATVIAN" }, + {LANGUAGE_LITHUANIAN, "LITHUANIAN" }, + {LANGUAGE_LITHUANIAN_CLASSIC, "LITHUANIAN (CLASSIC)" }, + {LANGUAGE_MACEDONIAN, "MACEDONIAN" }, + {LANGUAGE_MALAY, "MALAY" }, + {LANGUAGE_MALAY_MALAYSIA, "MALAY (MALAYSIA)" }, + {LANGUAGE_MALAY_BRUNEI_DARUSSALAM, "MALAY (BRUNEI DARUSSALAM)"}, + {LANGUAGE_MALAYALAM, "MALAYALAM" }, + {LANGUAGE_MALTESE, "MALTESE" }, + {LANGUAGE_MANIPURI, "MANIPURI" }, + {LANGUAGE_MARATHI, "MARATHI" }, + {LANGUAGE_MONGOLIAN, "MONGOLIAN" }, + {LANGUAGE_NEPALI, "NEPALI" }, + {LANGUAGE_NEPALI_INDIA, "NEPALI (INDIA)" }, + {LANGUAGE_NORWEGIAN, "NORWEGIAN" }, + {LANGUAGE_NORWEGIAN_BOKMAL, "NORWEGIAN (BOKMAL)" }, + {LANGUAGE_NORWEGIAN_NYNORSK, "NORWEGIAN (NYNORSK)" }, + {LANGUAGE_ORIYA, "ORIYA" }, + {LANGUAGE_POLISH, "POLISH" }, + {LANGUAGE_PORTUGUESE, "PORTUGUESE" }, + {LANGUAGE_PORTUGUESE_BRAZILIAN, "PORTUGUESE (BRAZILIAN)"}, + {LANGUAGE_PUNJABI, "PUNJABI" }, + {LANGUAGE_RHAETO_ROMAN, "RHAETO (ROMAN)" }, + {LANGUAGE_ROMANIAN, "ROMANIAN" }, + {LANGUAGE_ROMANIAN_MOLDOVA, "ROMANIAN (MOLDOVA)" }, + {LANGUAGE_RUSSIAN, "RUSSIAN" }, + {LANGUAGE_RUSSIAN_MOLDOVA, "RUSSIAN (MOLDOVA)" }, + {LANGUAGE_SAMI_LAPPISH, "SAMI (LAPPISH)" }, + {LANGUAGE_SANSKRIT, "SANSKRIT" }, + {LANGUAGE_SERBIAN, "SERBIAN" }, + {LANGUAGE_CROATIAN, "CROATIAN" }, + {LANGUAGE_SERBIAN_LATIN, "SERBIAN (LATIN)" }, + {LANGUAGE_SERBIAN_CYRILLIC, "SERBIAN (CYRILLIC)" }, + {LANGUAGE_SESOTHO, "SESOTHO" }, + {LANGUAGE_SINDHI, "SINDHI" }, + {LANGUAGE_SLOVAK, "SLOVAK" }, + {LANGUAGE_SLOVENIAN, "SLOVENIAN" }, + {LANGUAGE_SORBIAN, "SORBIAN" }, + {LANGUAGE_SPANISH_DATED, "SPANISH" }, + {LANGUAGE_SPANISH_MEXICAN, "SPANISH (MEXICAN)" }, + {LANGUAGE_SPANISH_MODERN, "SPANISH (MODERN)" }, + {LANGUAGE_SPANISH_GUATEMALA, "SPANISH (GUATEMALA)" }, + {LANGUAGE_SPANISH_COSTARICA, "SPANISH (COSTARICA)" }, + {LANGUAGE_SPANISH_PANAMA, "SPANISH (PANAMA)" }, + {LANGUAGE_SPANISH_DOMINICAN_REPUBLIC,"SPANISH (DOMINICAN REPUBLIC)"}, + {LANGUAGE_SPANISH_VENEZUELA, "SPANISH (VENEZUELA)" }, + {LANGUAGE_SPANISH_COLOMBIA, "SPANISH (COLOMBIA)" }, + {LANGUAGE_SPANISH_PERU, "SPANISH (PERU)" }, + {LANGUAGE_SPANISH_ARGENTINA, "SPANISH (ARGENTINA)" }, + {LANGUAGE_SPANISH_ECUADOR, "SPANISH (ECUADOR)" }, + {LANGUAGE_SPANISH_CHILE, "SPANISH (CHILE)" }, + {LANGUAGE_SPANISH_URUGUAY, "SPANISH (URUGUAY)" }, + {LANGUAGE_SPANISH_PARAGUAY, "SPANISH (PARAGUAY)" }, + {LANGUAGE_SPANISH_BOLIVIA, "SPANISH (BOLIVIA)" }, + {LANGUAGE_SPANISH_EL_SALVADOR, "SPANISH (EL SALVADOR)" }, + {LANGUAGE_SPANISH_HONDURAS, "SPANISH (HONDURAS)" }, + {LANGUAGE_SPANISH_NICARAGUA, "SPANISH (NICARAGUA)" }, + {LANGUAGE_SPANISH_PUERTO_RICO, "SPANISH (PUERTO RICO)" }, + {LANGUAGE_SWAHILI, "SWAHILI" }, + {LANGUAGE_SWEDISH, "SWEDISH" }, + {LANGUAGE_SWEDISH_FINLAND, "SWEDISH (FINLAND)" }, + {LANGUAGE_TAJIK, "TAJIK" }, + {LANGUAGE_TAMIL, "TAMIL" }, + {LANGUAGE_TATAR, "TATAR" }, + {LANGUAGE_TELUGU, "TELUGU" }, + {LANGUAGE_THAI, "THAI" }, + {LANGUAGE_TIBETAN, "TIBETAN" }, + {LANGUAGE_TSONGA, "TSONGA" }, + {LANGUAGE_TSWANA, "TSWANA" }, + {LANGUAGE_TURKISH, "TURKISH" }, + {LANGUAGE_TURKMEN, "TURKMEN" }, + {LANGUAGE_UKRAINIAN, "UKRAINIAN" }, + {LANGUAGE_URDU, "URDU" }, + {LANGUAGE_URDU_PAKISTAN, "URDU (PAKISTAN)" }, + {LANGUAGE_URDU_INDIA, "URDU (INDIA)" }, + {LANGUAGE_UZBEK_LATIN, "UZBEK (LATIN)" }, + {LANGUAGE_UZBEK_CYRILLIC, "UZBEK (CYRILLIC)" }, + {LANGUAGE_VENDA, "VENDA" }, + {LANGUAGE_VIETNAMESE, "VIETNAMESE" }, + {LANGUAGE_WELSH, "WELSH" }, + {LANGUAGE_XHOSA, "XHOSA" }, + {LANGUAGE_ZULU, "ZULU" }, + {0,0} //Last + }; + return &aMapArr[0]; + } + + static LanguageType LanguageFromName(const String& rLngStr) + { + const LangNameMap *pStart = GetLangNameMap(); + LanguageType nRet = pStart->nId; + + for (const LangNameMap *pMap = pStart; pMap->pLanguageNm; ++pMap) + { + if (rLngStr.EqualsIgnoreCaseAscii(pMap->pLanguageNm)) + { + nRet = pMap->nId; + break; + } + } + + ASSERT(nRet != pStart->nId, "TXT: That was an unknown language!"); + + return nRet; + } + + +// for the automatic conversion (mail/news/...) +// The user data contains the options for the ascii import/export filter. +// The format is: +// 1. CharSet - as ascii chars +// 2. LineEnd - as CR/LR/CRLF +// 3. Fontname +// 4. Language +// the delimetercharacter is "," +// + + void SwAsciiOptions::ReadUserData( const String& rStr ) + { + xub_StrLen nToken = 0; + USHORT nCnt = 0; + String sToken; + do { + if( 0 != (sToken = rStr.GetToken( 0, ',', nToken )).Len() ) + { + switch( nCnt ) + { + case 0: // CharSet + eCharSet = CharSetFromName(sToken); + break; + case 1: // LineEnd + if( sToken.EqualsIgnoreCaseAscii( "CRLF" )) + eCRLF_Flag = LINEEND_CRLF; + else if( sToken.EqualsIgnoreCaseAscii( "LF" )) + eCRLF_Flag = LINEEND_LF; + else + eCRLF_Flag = LINEEND_CR; + break; + case 2: // fontname + sFont = sToken; + break; + case 3: // Language + nLanguage = LanguageFromName(sToken); + break; + } + } + ++nCnt; + } while( STRING_NOTFOUND != nToken ); + } + +/* -----------------------------02.03.00 17:33-------------------------------- + + ---------------------------------------------------------------------------*/ +Color ConvertBrushStyle(const Color& rCol, const Color& rFillCol, BYTE nStyle) +{ + Color aColor = rCol; + switch ( nStyle ) + { + case SW_SV_BRUSH_25: + { + ULONG nRed = aColor.GetRed(); + ULONG nGreen = aColor.GetGreen(); + ULONG nBlue = aColor.GetBlue(); + nRed += (ULONG)(rFillCol.GetRed())*2; + nGreen += (ULONG)(rFillCol.GetGreen())*2; + nBlue += (ULONG)(rFillCol.GetBlue())*2; + aColor = Color( (BYTE)(nRed/3), (BYTE)(nGreen/3), (BYTE)(nBlue/3) ); + } + break; + + case SW_SV_BRUSH_50: + { + ULONG nRed = aColor.GetRed(); + ULONG nGreen = aColor.GetGreen(); + ULONG nBlue = aColor.GetBlue(); + nRed += (ULONG)(rFillCol.GetRed()); + nGreen += (ULONG)(rFillCol.GetGreen()); + nBlue += (ULONG)(rFillCol.GetBlue()); + aColor = Color( (BYTE)(nRed/2), (BYTE)(nGreen/2), (BYTE)(nBlue/2) ); + } + break; + + case SW_SV_BRUSH_75: + { + ULONG nRed = aColor.GetRed()*2; + ULONG nGreen = aColor.GetGreen()*2; + ULONG nBlue = aColor.GetBlue()*2; + nRed += (ULONG)(rFillCol.GetRed()); + nGreen += (ULONG)(rFillCol.GetGreen()); + nBlue += (ULONG)(rFillCol.GetBlue()); + aColor = Color( (BYTE)(nRed/3), (BYTE)(nGreen/3), (BYTE)(nBlue/3) ); + } + break; + + case SW_SV_BRUSH_NULL: + aColor = Color( COL_TRANSPARENT ); + } + + return aColor; +} + + void SwFilterOptions::Commit() {} + void SwFilterOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ) {} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx b/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx new file mode 100644 index 000000000000..ad46524700ed --- /dev/null +++ b/binfilter/bf_sw/source/filter/basflt/sw_shellio.cxx @@ -0,0 +1,730 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER +#include <hintids.hxx> + +#include <bf_svtools/urihelper.hxx> +#include <bf_svtools/fstathelper.hxx> +#include <bf_svtools/moduleoptions.hxx> +#include <bf_sfx2/docfile.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/linkmgr.hxx> +#include <bf_svx/paperinf.hxx> + +#include <errhdl.hxx> + +#include <docary.hxx> +#include <fmtanchr.hxx> +#include <fmtfsize.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <editsh.hxx> +#include <pagedesc.hxx> +#include <poolfmt.hxx> +#include <fltini.hxx> +#include <docsh.hxx> +#include <redline.hxx> +#include <linkenum.hxx> +#include <swerror.h> +#include <com/sun/star/document/UpdateDocMode.hpp> +#include "bf_so3/staticbaseurl.hxx" +namespace binfilter { + +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////////// + +/*N*/ ULONG SwReader::Read( const Reader& rOptions ) +/*N*/ { +/*N*/ // Variable uebertragen +/*N*/ Reader* po = (Reader*) &rOptions; +/*N*/ po->pStrm = pStrm; +/*N*/ po->pStg = pStg; +/*N*/ po->bInsertMode = 0 != pCrsr; +/*N*/ +/*N*/ // ist ein Medium angegeben, dann aus diesem die Streams besorgen +/*N*/ if( 0 != (po->pMedium = pMedium ) && !po->SetStrmStgPtr() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 po->SetReadUTF8( FALSE ); +/*?*/ return ERR_SWG_FILE_FORMAT_ERROR; +/*N*/ } +/*N*/ +/*N*/ ULONG nError = 0L; +/*N*/ +/*N*/ GetDoc(); +/*N*/ +/*N*/ // am Sw3-Reader noch den pIo-Pointer "loeschen" +/*N*/ if( po == ReadSw3 && pDoc->GetDocShell() && +/*N*/ ((Sw3Reader*)po)->GetSw3Io() != pDoc->GetDocShell()->GetIoSystem() ) +/*N*/ ((Sw3Reader*)po)->SetSw3Io( pDoc->GetDocShell()->GetIoSystem() ); +/*N*/ +/*N*/ // waehrend des einlesens kein OLE-Modified rufen +/*N*/ Link aOLELink( pDoc->GetOle2Link() ); +/*N*/ pDoc->SetOle2Link( Link() ); +/*N*/ +/*N*/ pDoc->bInReading = TRUE; +/*N*/ +/*N*/ SwPaM *pPam; +/*N*/ if( pCrsr ) +/*?*/ pPam = pCrsr; +/*N*/ else +/*N*/ { +/*N*/ // Wenn der Reader nicht mit einem Shell konstruiert wurde, +/*N*/ // selber einen Pam machen. +/*N*/ SwNodeIndex nNode( pDoc->GetNodes().GetEndOfContent(), -1 ); +/*N*/ pPam = new SwPaM( nNode ); +/*N*/ // Bei Web-Dokumenten wird die Default-Vorlage schon im InitNew +/*N*/ // gesetzt und braucht deshalb nicht nochmal gesetzt zu werden. +/*N*/ // Das gilt natuerlich nicht, wenn der Filter nicht der HTML-Filter +/*N*/ // ist oder im ConvertFrom zuvor ein SetTemplateName gerufen +/*N*/ // wurde. +/*N*/ if( !pDoc->IsHTMLMode() || ReadHTML != po || !po->pTemplate ) +/*N*/ po->SetTemplate( *pDoc ); +/*N*/ } +/*N*/ +/*N*/ // Pams sind ringfoermig verkettet. Aufhoeren, wenn man wieder beim +/*N*/ // ersten ist. +/*N*/ SwPaM *pEnd = pPam; +/*N*/ +/*N*/ BOOL bReadPageDescs = FALSE; +/*N*/ +/*N*/ SwNodeIndex aSplitIdx( pDoc->GetNodes() ); +/*N*/ +/*N*/ SwRedlineMode eOld = pDoc->GetRedlineMode(); +/*N*/ pDoc->SetRedlineMode_intern( REDLINE_IGNORE ); +/*N*/ +/*N*/ // Array von FlyFormaten +/*N*/ SwSpzFrmFmts aFlyFrmArr; +/*N*/ // only read templates? then ignore multi selection! +/*N*/ BOOL bFmtsOnly = po->aOpt.IsFmtsOnly(); +/*N*/ +/*N*/ while( TRUE ) +/*N*/ { +/*N*/ if( pCrsr ) +/*N*/ { +/*?*/ // Pam auf den Node davor setzen damit er nicht mit verschoben wird +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 const SwNodeIndex& rTmp = pPam->GetPoint()->nNode; +/*N*/ } +/*N*/ +/*N*/ // Speicher mal alle Fly's +/*N*/ if( pCrsr ) +/*?*/ aFlyFrmArr.Insert( pDoc->GetSpzFrmFmts(), 0L ); +/*N*/ +/*N*/ xub_StrLen nSttCntnt = pPam->GetPoint()->nContent.GetIndex(); +/*N*/ +/*N*/ // damit fuer alle Reader die Ende-Position immer stimmt, hier +/*N*/ // pflegen. +/*N*/ SwCntntNode* pCNd = pPam->GetCntntNode(); +/*N*/ xub_StrLen nEndCntnt = pCNd ? pCNd->Len() - nSttCntnt : 0; +/*N*/ SwNodeIndex aEndPos( pPam->GetPoint()->nNode, 1 ); +/*N*/ +/*N*/ nError = po->Read( *pDoc, *pPam, aFileName ); +/*N*/ +/*N*/ if( !IsError( nError )) // dann setzen wir das Ende mal richtig +/*N*/ { +/*N*/ aEndPos--; +/*N*/ pCNd = aEndPos.GetNode().GetCntntNode(); +/*N*/ if( !pCNd && 0 == ( pCNd = pDoc->GetNodes().GoPrevious( &aEndPos ) )) +/*?*/ pCNd = pDoc->GetNodes().GoNext( &aEndPos ); +/*N*/ +/*N*/ pPam->GetPoint()->nNode = aEndPos; +/*N*/ xub_StrLen nLen = pCNd->Len(); +/*N*/ if( nLen < nEndCntnt ) +/*?*/ nEndCntnt = 0; +/*N*/ else +/*N*/ nEndCntnt = nLen - nEndCntnt; +/*N*/ pPam->GetPoint()->nContent.Assign( pCNd, nEndCntnt ); +/*N*/ } +/*N*/ +/*N*/ if( pCrsr ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); +/*N*/ } +/*N*/ +/*N*/ pPam = (SwPaM *) pPam->GetNext(); +/*N*/ if( pPam == pEnd ) +/*N*/ break; +/*N*/ +/*N*/ // only read templates? then ignore multi selection! Bug 68593 +/*?*/ if( bFmtsOnly ) +/*?*/ break; +/*?*/ + /* + * !!! man muss selbst den Status vom Stream zuruecksetzen. !!! + * Beim seekg wird der akt. Status, eof- und bad-Bit + * gesetzt, warum weiss keiner + */ +/*?*/ if( pStrm ) +/*?*/ { +/*?*/ pStrm->Seek(0); +/*?*/ pStrm->ResetError(); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ pDoc->bInReading = FALSE; +/*N*/ pDoc->SetAllUniqueFlyNames(); +/*N*/ +/*N*/ +/*N*/ // Wenn der Pam nur fuers Lesen konstruiert wurde, jetzt zerstoeren. +/*N*/ if( !pCrsr ) +/*N*/ { +/*N*/ delete pPam; // ein neues aufgemacht. +/*N*/ eOld = (SwRedlineMode)(pDoc->GetRedlineMode() & ~REDLINE_IGNORE); +/*N*/ pDoc->SetFieldsDirty( FALSE ); +/*N*/ } +/*N*/ +/*N*/ pDoc->SetRedlineMode_intern( eOld ); +/*N*/ pDoc->SetOle2Link( aOLELink ); +/*N*/ +/*N*/ if( pCrsr ) // das Doc ist jetzt modifiziert +/*N*/ pDoc->SetModified(); +/*N*/ +/*N*/ if( po == ReadSw3 ) // am Sw3-Reader noch den pIo-Pointer "loeschen" +/*N*/ ((Sw3Reader*)po)->SetSw3Io( 0 ); +/*N*/ +/*N*/ po->SetReadUTF8( FALSE ); +/*N*/ po->SetBlockMode( FALSE ); +/*N*/ po->SetOrganizerMode( FALSE ); +/*N*/ po->SetIgnoreHTMLComments( FALSE ); +/*N*/ return nError; +/*N*/ } + + +/* + * Konstruktoren, Destruktor + */ + +// Initiales Einlesben + + +/*N*/ SwReader::SwReader( SvStorage& rStg, const String& rFileName, SwDoc *pDoc ) +/*N*/ : SwDocFac( pDoc ), +/*N*/ pStrm( 0 ), +/*N*/ pStg( &rStg ), +/*N*/ pMedium( 0 ), +/*N*/ aFileName( rFileName ), +/*N*/ pCrsr( 0 ) +/*N*/ { +/*N*/ } + + + SwReader::SwReader( SfxMedium& rMedium, const String& rFileName, SwDoc *pDoc ) + : SwDocFac( pDoc ), + pStrm( 0 ), + pStg( 0 ), + pMedium( &rMedium ), + aFileName( rFileName ), + pCrsr( 0 ) + { + } + +// In ein existierendes Dokument einlesen + + SwReader::SwReader( SfxMedium& rMedium, const String& rFileName, SwPaM& rPam ) + : SwDocFac( rPam.GetDoc() ), + aFileName( rFileName ), + pStg( 0 ), + pStrm( 0 ), + pMedium( &rMedium ), + pCrsr( &rPam ) + { + } +/*N*/ Reader::Reader() +/*N*/ : pStrm(0), pStg(0), pMedium(0), pTemplate(0), +/*N*/ bTmplBrowseMode( FALSE ), bInsertMode( FALSE ), +/*N*/ bReadUTF8( FALSE ), bBlockMode( FALSE ), bOrganizerMode( FALSE ), +/*N*/ bHasAskTemplateName( FALSE ), bIgnoreHTMLComments( FALSE ) +/*N*/ { +/*N*/ } + +/*N*/ Reader::~Reader() +/*N*/ { +/*N*/ delete pTemplate; +/*N*/ } + +/*N*/ String Reader::GetTemplateName() const +/*N*/ { +/*N*/ return aEmptyStr; +/*N*/ } + +// Die Filter-Vorlage laden, setzen und wieder freigeben +/*N*/ SwDoc* Reader::GetTemplateDoc() +/*N*/ { +/*N*/ if( !bHasAskTemplateName ) +/*N*/ { +/*N*/ SetTemplateName( GetTemplateName() ); +/*N*/ bHasAskTemplateName = TRUE; +/*N*/ } +/*N*/ +/*N*/ if( !aTemplateNm.Len() ) +/*N*/ ClearTemplate(); +/*N*/ else +/*N*/ { +/*?*/ INetURLObject aTDir( ::binfilter::StaticBaseUrl::SmartRelToAbs(aTemplateNm) ); +/*?*/ DateTime aCurrDateTime; +/*?*/ BOOL bLoad = FALSE; +/*?*/ +/*?*/ // Wenn das Template schon mal geladen wurde, nur einmal pro +/*?*/ // Minute nachschauen, ob es geaendert wurde. +/*?*/ if( !pTemplate || aCurrDateTime >= aChkDateTime ) +/*?*/ { +/*?*/ Date aTstDate; +/*?*/ Time aTstTime; +/*?*/ if( ::binfilter::GetModifiedDateTimeOfFile( +/*?*/ aTDir.GetMainURL( INetURLObject::NO_DECODE ), +/*?*/ &aTstDate, &aTstTime ) && +/*?*/ ( !pTemplate || aDStamp != aTstDate || aTStamp != aTstTime )) +/*?*/ { +/*?*/ bLoad = TRUE; +/*?*/ aDStamp = aTstDate; +/*?*/ aTStamp = aTstTime; +/*?*/ } +/*?*/ +/*?*/ // Erst in einer Minute wieder mal nachschauen, ob sich die +/*?*/ // Vorlage geaendert hat. +/*?*/ aChkDateTime = aCurrDateTime; +/*?*/ aChkDateTime += Time( 0L, 1L ); +/*?*/ } +/*?*/ +/*?*/ if( bLoad ) +/*?*/ { +/*?*/ ClearTemplate(); +/*?*/ ASSERT( !pTemplate, "Who holds the template doc?" ); +/*?*/ +/*?*/ SvStorageRef xStor( new SvStorage( aTDir.GetFull(), STREAM_READ )); +/*?*/ ULONG nFormat = xStor->GetFormat(); +/*?*/ long nVersion = SOFFICE_FILEFORMAT_60; +/*?*/ switch( nFormat ) +/*?*/ { +/*?*/ case SOT_FORMATSTR_ID_STARWRITER_50: +/*?*/ case SOT_FORMATSTR_ID_STARWRITERGLOB_50: +/*?*/ case SOT_FORMATSTR_ID_STARWRITERWEB_50: +/*?*/ nVersion = SOFFICE_FILEFORMAT_50; +/*?*/ break; +/*?*/ case SOT_FORMATSTR_ID_STARWRITER_40: +/*?*/ case SOT_FORMATSTR_ID_STARWRITERGLOB_40: +/*?*/ case SOT_FORMATSTR_ID_STARWRITERWEB_40: +/*?*/ nVersion = SOFFICE_FILEFORMAT_40; +/*?*/ break; +/*?*/ case SOT_FORMATSTR_ID_STARWRITER_30: +/*?*/ nVersion = SOFFICE_FILEFORMAT_31; +/*?*/ break; +/*?*/ } +/*?*/ if( nVersion >= SOFFICE_FILEFORMAT_60 ) +/*?*/ { +/*?*/ // #95605#: If the writer module is not installed, +/*?*/ // we cannot create a SwDocShell. We could create a +/*?*/ // SwWebDocShell however, because this exists always +/*?*/ // for the help. +/*?*/ SvtModuleOptions aModuleOptions; +/*?*/ if( aModuleOptions.IsWriter() ) +/*?*/ { +/*?*/ SwDocShell *pDocSh = +/*?*/ new SwDocShell ( SFX_CREATE_MODE_INTERNAL ); +/*?*/ SvEmbeddedObjectRef xDocSh = pDocSh; +/*?*/ if( pDocSh->DoInitNew( 0 ) ) +/*?*/ { +/*?*/ pTemplate = pDocSh->GetDoc(); +/*?*/ pTemplate->SetOle2Link( Link() ); +/*?*/ pTemplate->SetBrowseMode( bTmplBrowseMode ); +/*?*/ pTemplate->RemoveAllFmtLanguageDependencies(); +/*?*/ +/*?*/ ReadXML->SetOrganizerMode( TRUE ); +/*?*/ SwReader aRdr( *xStor, aEmptyStr, pTemplate ); +/*?*/ aRdr.Read( *ReadXML ); +/*?*/ ReadXML->SetOrganizerMode( FALSE ); +/*?*/ +/*?*/ pTemplate->AddLink(); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pTemplate = new SwDoc; +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ ASSERT( !pTemplate || ::binfilter::IsDocument( +/*?*/ aTDir.GetMainURL( INetURLObject::NO_DECODE ) ) || +/*?*/ aTemplateNm.EqualsAscii( "$$Dummy$$" ), +/*?*/ "TemplatePtr but no template exist!" ); +/*N*/ } +/*N*/ +/*N*/ return pTemplate; +/*N*/ } + +/*N*/ BOOL Reader::SetTemplate( SwDoc& rDoc ) +/*N*/ { +/*N*/ BOOL bRet = FALSE; +/*N*/ +/*N*/ GetTemplateDoc(); +/*N*/ if( pTemplate ) +/*N*/ { +/*?*/ rDoc.RemoveAllFmtLanguageDependencies(); +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 rDoc.ReplaceStyles( *pTemplate ); +/*N*/ } +/*N*/ +/*N*/ return bRet; +/*N*/ } + +/*N*/ void Reader::ClearTemplate() +/*N*/ { +/*N*/ if( pTemplate ) +/*N*/ { +/*?*/ if( 0 == pTemplate->RemoveLink() ) +/*?*/ delete pTemplate, +/*?*/ pTemplate = 0; +/*N*/ } +/*N*/ } + +/*N*/ void Reader::SetTemplateName( const String& rDir ) +/*N*/ { +/*N*/ if( rDir.Len() && aTemplateNm != rDir ) +/*N*/ { +/*?*/ ClearTemplate(); +/*?*/ aTemplateNm = rDir; +/*N*/ } +/*N*/ } + + +// alle die die Streams / Storages nicht geoeffnet brauchen, +// muessen die Methode ueberladen +int Reader::SetStrmStgPtr() +{ + ASSERT( pMedium, "Wo ist das Medium??" ); + + if( pMedium->IsStorage() ) + { + if( SW_STORAGE_READER & GetReaderType() ) + { + pStg = pMedium->GetStorage(); + return TRUE; + } + } + else if( SW_STREAM_READER & GetReaderType() ) + { + pStrm = pMedium->GetInStream(); + return TRUE; + } + return FALSE; +} + + + int Reader::GetReaderType() + { + return SW_STREAM_READER; + } + + + void Reader::SetFltName( const String& ) + { + } + + +void Reader::SetNoOutlineNum( SwDoc& rDoc ) +{ +} + + +void Reader::ResetFrmFmtAttrs( SfxItemSet &rFrmSet ) +{ + rFrmSet.Put( SvxLRSpaceItem() ); + rFrmSet.Put( SvxULSpaceItem() ); + rFrmSet.Put( SvxBoxItem() ); +} + + +void Reader::ResetFrmFmts( SwDoc& rDoc ) +{ + for( USHORT i=0; i<3; i++ ) + { + USHORT nPoolId; + switch( i ) + { + case 0: nPoolId = RES_POOLFRM_FRAME; break; + case 1: nPoolId = RES_POOLFRM_GRAPHIC; break; + case 2: nPoolId = RES_POOLFRM_OLE; break; + } + + SwFrmFmt *pFrmFmt = rDoc.GetFrmFmtFromPool( nPoolId ); + + pFrmFmt->ResetAttr( RES_LR_SPACE ); + pFrmFmt->ResetAttr( RES_UL_SPACE ); + pFrmFmt->ResetAttr( RES_BOX ); + } +} + + // read the sections of the document, which is equal to the medium. + // returns the count of it + +// ------------------------------------------------ + + + + +// ------------------------------------------------ + + + + + +/* + * Writer + */ + +/* + * Konstruktoren, Destruktoren sind inline (inc/shellio.hxx). + */ + + + + + + +/*N*/ SwWriter::SwWriter( SvStream& rStrm, SwPaM& rPam, BOOL bWriteAll ) +/*N*/ : pStrm( &rStrm ), +/*N*/ pStg( 0 ), +/*N*/ pMedium( 0 ), +/*N*/ pShell( 0 ), +/*N*/ pOutPam( &rPam ), +/*N*/ rDoc( *rPam.GetDoc() ), +/*N*/ bWriteAll( bWriteAll ) +/*N*/ { +/*N*/ } + +/* + +SwWriter::SwWriter( SvStorage& rStg, SwCrsrShell &rShell, BOOL bWriteAll ) + : pStrm( 0 ), + pStg( &rStg ), + pMedium( 0 ), + pShell( &rShell ), + pOutPam( 0 ), + rDoc( *rShell.GetDoc() ), + bWriteAll( bWriteAll ) +{ +} +*/ + + +/*N*/ SwWriter::SwWriter(SvStorage& rStg,SwDoc &rDoc) +/*N*/ :pStrm( 0 ), +/*N*/ pStg( &rStg ), +/*N*/ pMedium( 0 ), +/*N*/ pShell( 0 ), +/*N*/ pOutPam( 0 ), +/*N*/ rDoc( rDoc ), +/*N*/ bWriteAll( TRUE ) +/*N*/ { +/*N*/ } +/* + +SwWriter::SwWriter( SvStorage& rStg, SwPaM& rPam, BOOL bWriteAll ) + : pStrm( 0 ), + pStg( &rStg ), + pMedium( 0 ), + pShell( 0 ), + pOutPam( &rPam ), + rDoc( *rPam.GetDoc() ), + bWriteAll( bWriteAll ) +{ +} +*/ + + + + +/* + +SwWriter::SwWriter( SfxMedium& rMedium, SwPaM& rPam, BOOL bWriteAll ) + : pStrm( 0 ), + pStg( 0 ), + pShell( 0 ), + pMedium( &rMedium ), + pOutPam( &rPam ), + rDoc( *rPam.GetDoc() ), + bWriteAll( bWriteAll ) +{ +} +*/ + + +/*N*/ ULONG SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) +/*N*/ { +/*N*/ BOOL bHasMark = FALSE; +/*N*/ SwPaM * pPam; +/*N*/ +/*N*/ SwDoc *pDoc = 0L; +/*N*/ SvEmbeddedObjectRef* pRefForDocSh = 0; +/*N*/ +/*N*/ if ( pShell && !bWriteAll && pShell->IsTableMode() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 bWriteAll = TRUE; +/*N*/ } +/*N*/ +/*N*/ if( !bWriteAll && ( pShell || pOutPam )) +/*N*/ { +/*N*/ if( pShell ) +/*?*/ pPam = pShell->GetCrsr(); +/*N*/ else +/*N*/ pPam = pOutPam; +/*N*/ +/*N*/ SwPaM *pEnd = pPam; +/*N*/ +/*N*/ // Erste Runde: Nachsehen, ob eine Selektion besteht. +/*N*/ while(TRUE) +/*N*/ { +/*N*/ bHasMark = bHasMark || pPam->HasMark(); +/*N*/ pPam = (SwPaM *) pPam->GetNext(); +/*N*/ if(bHasMark || pPam == pEnd) +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ // Wenn keine Selektion besteht, eine ueber das ganze Dokument aufspannen. +/*N*/ if(!bHasMark) +/*N*/ { +/*?*/ if( pShell ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pShell->Push(); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ pPam = new SwPaM( *pPam ); +/*?*/ pPam->Move( fnMoveBackward, fnGoDoc ); +/*?*/ pPam->SetMark(); +/*?*/ pPam->Move( fnMoveForward, fnGoDoc ); +/*?*/ } +/*N*/ } +/*N*/ // pPam ist immer noch der akt. Cursor !! +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // keine Shell oder alles schreiben -> eigenen Pam erzeugen +/*N*/ SwDoc* pOutDoc = pDoc ? pDoc : &rDoc; +/*N*/ pPam = new SwPaM( pOutDoc->GetNodes().GetEndOfContent() ); +/*N*/ pPam->Move( fnMoveBackward, fnGoDoc ); +/*N*/ pPam->SetMark(); +/*N*/ pPam->Move( fnMoveForward, fnGoDoc ); +/*N*/ } +/*N*/ +/*N*/ rxWriter->bWriteAll = bWriteAll; +/*N*/ SwDoc* pOutDoc = pDoc ? pDoc : &rDoc; +/*N*/ +/*N*/ // falls der Standart PageDesc. immer noch auf initalen Werten steht +/*N*/ // (wenn z.B. kein Drucker gesetzt wurde) dann setze jetzt auf DIN A4 +/*N*/ if( !pOutDoc->GetPrt() ) +/*N*/ { +/*?*/ const SwPageDesc& rPgDsc = pOutDoc->GetPageDesc( 0L ); +/*?*/ //const SwPageDesc& rPgDsc = *pOutDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );; +/*?*/ const SwFmtFrmSize& rSz = rPgDsc.GetMaster().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() ) +/*?*/ { +/*?*/ SwPageDesc aNew( rPgDsc ); +/*?*/ SwFmtFrmSize aNewSz( rSz ); +/*?*/ aNewSz.SetHeight( lA4Height ); +/*?*/ aNewSz.SetWidth( lA4Width ); +/*?*/ aNew.GetMaster().SetAttr( aNewSz ); +/*?*/ pOutDoc->ChgPageDesc( 0, aNew ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ SwEditShell* pESh = pOutDoc->GetEditShell(); +/*N*/ if( pESh ) +/*N*/ pESh->StartAllAction(); +/*N*/ +/*N*/ BOOL bWasPurgeOle = pOutDoc->IsPurgeOLE(); +/*N*/ pOutDoc->SetPurgeOLE( FALSE ); +/*N*/ +/*N*/ ULONG nError = 0; +/*N*/ if( pMedium ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 nError = rxWriter->Write( *pPam, *pMedium, pRealFileName ); +/*N*/ else if( pStg ) +/*N*/ nError = rxWriter->Write( *pPam, *pStg, pRealFileName ); +/*N*/ else if( pStrm ) +/*N*/ nError = rxWriter->Write( *pPam, *pStrm, pRealFileName ); +/*N*/ +/*N*/ pOutDoc->SetPurgeOLE( bWasPurgeOle ); +/*N*/ if( pESh ) +/*N*/ pESh->EndAllAction(); +/*N*/ +/*N*/ // Falls nur zum Schreiben eine Selektion aufgespannt wurde, vor der +/*N*/ // Rueckkehr den alten Crsr wieder herstellen. +/*N*/ if( !bWriteAll && ( pShell || pOutPam )) +/*N*/ { +/*N*/ if(!bHasMark) +/*N*/ { +/*?*/ if( pShell ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pShell->Pop( FALSE ); +/*?*/ else +/*?*/ delete pPam; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ delete pPam; // loesche den hier erzeugten Pam +/*N*/ // Alles erfolgreich geschrieben? Sag' das dem Dokument! +/*N*/ if( !IsError( nError ) && !pDoc ) +/*N*/ rDoc.ResetModified(); +/*N*/ } +/*N*/ +/*N*/ if ( pDoc ) +/*N*/ { +/*N*/ delete pRefForDocSh; +/*?*/ if ( !pDoc->RemoveLink() ) +/*?*/ delete pDoc; +/*?*/ bWriteAll = FALSE; +/*N*/ } +/*N*/ +/*N*/ return nError; +/*N*/ } + + +/* */ + +// ---------------------------------------------------------------------- + + +/*N*/ BOOL SetHTMLTemplate( SwDoc & rDoc ) +/*N*/ { +DBG_BF_ASSERT(0, "STRIP"); return FALSE;//STRIP001 //STRIP001 // Vorlagennamen von den Sfx-HTML-Filter besorgen!!! +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/basflt/sw_w4wflt.cxx b/binfilter/bf_sw/source/filter/basflt/sw_w4wflt.cxx new file mode 100644 index 000000000000..ce89b4e8eca4 --- /dev/null +++ b/binfilter/bf_sw/source/filter/basflt/sw_w4wflt.cxx @@ -0,0 +1,342 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_svtools/pathoptions.hxx> +#include <unotools/localfilehelper.hxx> + +// ------------------------------------------------------------------- + +#ifdef MAC + +#include <mac_start.h> +#include <Resources.h> +#include <Memory.h> +#include <Signal.h> +#include <Types.h> +#include <Strings.h> +#include <mac_end.h> + +typedef int (*FNDisplay)(int); +# define FNDisp int +typedef int(**CHand)( void*, void*, void*, void*, void* ); + +#endif + +// ------------------------------------------------------------------- +#if defined( WIN ) || defined( WNT ) + +// Typen fuer die Funktion der W4W-DLL +#include <tools/svwin.h> +typedef int ( FAR PASCAL *FNDisplay)( int ); + +#ifdef WIN +#define FNDisp _loadds FAR PASCAL +#else +#define FNDisp FAR PASCAL +#endif // WIN + +typedef int (FAR PASCAL *FNautorec)( LPSTR, int, LPINT ); +typedef int (FAR PASCAL *FNw4wt)( LPSTR, LPSTR, LPSTR, LPSTR, FNDisplay ); +typedef int (FAR PASCAL *FNw4wf)( LPSTR, LPSTR, LPSTR, LPSTR, FNDisplay ); + +#endif // defined( WIN ) || defined( WNT ) + +// --------------------------------------------------------------------- + +#ifdef UNX +#include <stdlib.h> +#endif + +// ------------------------------------------------------------------- + +#ifdef PM2 +#define INCL_DOS // fuer bsedos.h <- os2.h <- svpm.h <- sysdep.hxx +#endif + +// ------------------------------------------------------------------- + +#include <bf_sfx2/app.hxx> +#include <unotools/tempfile.hxx> + +#include <swtypes.hxx> +#include <w4wflt.hxx> + +#include <swerror.h> + +namespace binfilter {//STRIP009 + +#define ERR_DLL 9999 + +/*N*/ USHORT AutoDetec( const String& rFileName, USHORT & rVersion ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return 0;//STRIP001 +/*N*/ } + +// Handler fuer die Prozentanzeige + +#if defined( WIN ) || defined( WNT ) || defined( PM2 ) + +int FNDisp W4WReadDisplayHandler( int nPercent ) +{ +// no progress display in binfilter! +// ::binfilter::SetProgressState( nPercent / 3, 0 ); + return 0; // -1 fuehrt zu Abbruch +} + +int FNDisp W4WWriteDisplayHandler( int nPercent ) +{ +// no progress display in binfilter! +// ::binfilter::SetProgressState( 67 + nPercent / 3, 0 ); + return 0; // -1 fuehrt zu Abbruch +} + + +#endif + + + +// W4W speichert beim Laden vom File rFileName die Ausgabe in aTmpFile. +// der Filter wird ueber nFilter bestimmt. + +ULONG LoadFile( const String& rFileName, USHORT nFilter, + const String& rVersion, String & rTmpFile ) +{ + rTmpFile = utl::TempFile::CreateTempName( 0 ); + String sNativeFileName(rTmpFile); + USHORT nError = 1; + + rtl_TextEncoding eEnc = ::gsl_getSystemTextEncoding(); + ByteString sFileName( rFileName, eEnc ), sVersion( rVersion, eEnc ), + sTmpFile( rTmpFile, eEnc ); + + { + String sTmp; + if( utl::LocalFileHelper::ConvertPhysicalNameToURL( rTmpFile, sTmp )) + rTmpFile = sTmp; + } + +#ifdef MAC + + nError = Call_MacRes( rFileName, nFilter, TRUE, rVersion, rTmpFile ); + +#else //MAC + + String aFormat; + +#if defined( WIN ) || defined( WNT ) + aFormat += 'w'; + if( nFilter < 10 ) + aFormat += '0'; + if( nFilter < 100 ) + aFormat += '0'; + aFormat += String::CreateFromInt32( nFilter ); + aFormat += 'f'; +#if defined( WIN ) + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "16W" )); +#else // WIN + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "32W" )); +#endif // WIN + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ".DLL" )); +#endif // defined( WIN ) || defined( WNT ) + +#ifdef PM2 + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "w4w" )); + if( nFilter < 10 ) + aFormat += '0'; + aFormat += String::CreateFromInt32( nFilter ); + aFormat += 'f'; + + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ".dll" )); +#endif // PM2 + +#ifdef UNX + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "w4w" )); + if( nFilter < 10 ) + aFormat += '0'; + aFormat += String::CreateFromInt32( nFilter ); + aFormat += 'f'; +#endif // UNX + + SvtPathOptions aOpt; + if( !aOpt.SearchFile( aFormat, SvtPathOptions::PATH_FILTER ) ) + return ERR_W4W_DLL_ERROR | ERROR_SW_READ_BASE; + + ByteString sFormat( aFormat, ::gsl_getSystemTextEncoding() ); +#if defined( WIN ) || defined( WNT ) + + ByteString aEmptyByteStr; + HANDLE hDLL = LoadLibrary( (LPSTR)sFormat.GetBuffer() ); + if( hDLL >= (HANDLE)HINSTANCE_ERROR ) + { + FNw4wf fnRead = (FNw4wf)GetProcAddress( (HINSTANCE)hDLL, (LPSTR)"w4wf" ); + if( fnRead ) + nError = (*fnRead)( (LPSTR)sFileName.GetBuffer(), + (LPSTR)sTmpFile.GetBuffer(), + (LPSTR)sVersion.GetBuffer(), + (LPSTR)aEmptyByteStr.GetBuffer(), + (FNDisplay)&W4WReadDisplayHandler + ); + + FreeLibrary( (HINSTANCE)hDLL ); + } +#ifndef WIN /* Bei Windows kommt schon eine System-Box hoch */ + else + nError = ERR_DLL; +#endif + +#endif //WIN || WNT + +#ifdef PM2 + HMODULE hDLL; + ByteString aEmptyByteStr; + CHAR sLoadError[ 100 ]; + APIRET rc = DosLoadModule( (PSZ)sLoadError, sizeof( sLoadError ), + (PSZ)sFormat.GetBuffer(), &hDLL ); + if( !rc ) + { + PFN ppFN; + ULONG nBitVers; + + if( 0 == ( rc = DosQueryProcType( hDLL, 0L, (PSZ)"w4wf", &nBitVers )) && + 1 == nBitVers && // 32 Bit DLLs + 0 == ( rc = DosQueryProcAddr( hDLL, 0L, (PSZ)"w4wf", &ppFN ))) + { + // die neuen 32 Bit DLLs + FN32w4wf fnRead = (FN32w4wf)ppFN; + nError = (*fnRead)( (PSZ)sFileName.GetBuffer(), + (PSZ)sTmpFile.GetBuffer(), + (PSZ)sVersion.GetBuffer(), + (PSZ)aEmptyByteStr.GetBuffer(), + (FN32Display)&W4WReadDisplayHandler + ); + } +//Bug 33334: Modul wird von OS/2 nie aus dem Speicher entfernt, +// W4W stoplter darueber --> also nie entfernen! +//JP 23.04.98: fuer den DCF-RFT-Filter unter OS/2 muss aber die DLL +// freigegeben werden. + if( 15 == nFilter ) + DosFreeModule( hDLL ); + } + else + nError = ERR_DLL; +#endif // PM2 + +#ifdef UNX + + String aParam( aFormat ); + aParam += ' '; + aParam += rFileName; + aParam.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " -N -t=" )); + aParam += sNativeFileName; + aParam.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " -v" )); + aParam += rVersion; + + ByteString sParam( aParam, ::gsl_getSystemTextEncoding() ); + + nError = system( sParam.GetBuffer() ); +#endif // UNX +#endif // MAC + +static const ULONG nErrors[18]={ + 0, ERR_SWG_READ_ERROR, ERR_SWG_READ_ERROR, ERR_W4W_WRITE_TMP_ERROR, + ERR_W4W_WRITE_TMP_ERROR, ERR_SWG_FILE_FORMAT_ERROR, + ERR_W4W_WRITE_TMP_ERROR, ERR_W4W_WRITE_TMP_ERROR, + ERR_W4W_MEM | ERROR_SW_READ_BASE, + ERR_SWG_FILE_FORMAT_ERROR, ERR_W4W_WRITE_FULL | ERROR_SW_READ_BASE, + 0, 0, 0, + 0, ERR_SW6_PASSWD, ERR_W4W_INTERNAL_ERROR | ERROR_SW_READ_BASE, + 0 }; + + if ( nError != 12 ) // 12 ist nur Warning + { + if ( nError == ERR_DLL ) + return ERR_W4W_DLL_ERROR | ERROR_SW_READ_BASE; + if ( nError>0 && nError<=17 ) + return nErrors[ nError ]; + } + return 0; +} + +FASTBOOL W4WDLLExist( W4WDLL_TYPE eType, USHORT nFilter ) +{ +#ifdef MAC + return TRUE; // dann beim CallMacRes feststellen +#else + + String aFormat; + switch( eType ) + { + case W4WDLL_EXPORT: + case W4WDLL_IMPORT: +#if defined( PM2 ) || defined( UNX ) + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "w4w" )); + if( nFilter < 10 ) + aFormat += '0'; + aFormat += String::CreateFromInt32( nFilter ); + aFormat += W4WDLL_IMPORT ? 'f' : 't'; +#endif // PM2 || UNX + +#if defined( WIN ) || defined( WNT ) + aFormat += 'w'; + if( nFilter < 10 ) + aFormat += '0'; + if( nFilter < 100 ) + aFormat += '0'; + aFormat += String::CreateFromInt32( nFilter ); + aFormat += W4WDLL_IMPORT ? 'f' : 't'; +#if defined( WIN ) + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "16W" )); +#else // WIN + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "32W" )); +#endif // WIN + +#endif // WIN || WNT + break; + + case W4WDLL_AUTODETEC: + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "autorec" )); + break; + } + +#ifndef UNX + aFormat.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ".dll" )); +#endif // UNX + + // Fehlerbehandlung oder fuer Systeme die keine W4W-Filter kennen + SvtPathOptions aOpt; + + return aOpt.SearchFile( aFormat, SvtPathOptions::PATH_FILTER ); +#endif // MAC +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/exccrts.hxx b/binfilter/bf_sw/source/filter/excel/exccrts.hxx new file mode 100644 index 000000000000..c95b5623f3ab --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/exccrts.hxx @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __EXCCRTS_HXX__ +#define __EXCCRTS_HXX__ + +#include "fltglbls.hxx" + +#include <tools/debug.hxx> +namespace binfilter { + +// ----------------------------------------------- class ColRowSettings -- +class ColRowSettings + { + // ACHTUNG: Col-/Row-Angaben in TWIPS + // ExcelKoordinaten -> Klasse( -> SwKoordinaten ) + private: + INT32 *pWidth; + INT32 *pHeight; + BOOL *pColHidden; + BOOL *pRowHidden; + BOOL *pColUsed; + BOOL *pRowUsed; + USHORT nDefWidth; + USHORT nDefHeight; + USHORT nAktTab; + USHORT nTabLimit, nColLimit, nRowLimit; + public: + ColRowSettings(); + ~ColRowSettings(); + void NewTab( USHORT nNew ); + void Apply(); +#ifdef USED + void HideColRange( USHORT nColFirst, USHORT nColLast ); + void HideRowRange( USHORT nRowFirst, USHORT nRowLast ); +#endif + void SetWidthRange( USHORT nColF, USHORT nColL, USHORT nNew ); + void SetDefaults( USHORT nWidth, USHORT nHeight ) + { + nDefWidth = nWidth; + nDefHeight = nHeight; + } + + void SetDefWidth( USHORT nNew ) { nDefWidth = nNew; } + + void SetDefHeight( USHORT nNew ) { nDefHeight = nNew; } + + void SetWidth( USHORT nCol, INT32 nNew ) + { + pExcGlob->NormalizeCol( nCol ); + + DBG_ASSERT( nCol < nColLimit, + "+ColRowSettings::SetWidth(): ungueltige Column" ); + if( nCol < nColLimit ) + { + pWidth[ nCol ] = nNew; + pColUsed[ nCol ] = TRUE; + } + } + + void SetHeight( USHORT nRow, INT32 nNew ) + { + pExcGlob->NormalizeRow( nRow ); + + DBG_ASSERT( nRow < nRowLimit, + "+ColRowSettings::SetHeight(): ungueltige Row" ); + if( nRow < nRowLimit ) + { + pHeight[ nRow ] = nNew; + pRowUsed[ nRow ] = TRUE; + } + } + + void Used( USHORT nCol, USHORT nRow ) + { + pExcGlob->Normalize( nCol, nRow ); + + DBG_ASSERT( nRow < nRowLimit, + "+ColRowSettings::Used(): ungueltige Row" ); + DBG_ASSERT( nCol < nColLimit, + "+ColRowSettings::Used(): ungueltige Column" ); + if( nCol < nColLimit && nRow < nRowLimit ) + { + pColUsed[ nCol ] = TRUE; + pRowUsed[ nRow ] = TRUE; + } + } + + void ColUsed( USHORT nCol ) + { + pExcGlob->NormalizeCol( nCol ); + + DBG_ASSERT( nCol < nColLimit, + "+ColRowSettings::ColUsed(): ungueltige Column" ); + if( nCol < nColLimit ) pColUsed[ nCol ] = TRUE; + } + + void RowUsed( USHORT nRow ) + { + pExcGlob->NormalizeRow( nRow ); + + DBG_ASSERT( nRow < nRowLimit, + "+ColRowSettings::RowUsed(): ungueltige Row" ); + if( nRow < nRowLimit ) pRowUsed[ nRow ] = TRUE; + } + + }; + +// ---------------------------------------------------- class FltColumn -- + +class FltColumn + { + // ACHTUNG: SwKoordinaten -> Klasse( -> SwKoordinaten ) + private: + USHORT *pData; // Daten-Array fuer XF-Indizes + USHORT nSize; // Groesse des pData-Arrays, teilbar durch 2 + USHORT nLastRow; + USHORT nCol; // Column-Nummer + static USHORT nTab; // Tabellen-Nummer + + static const USHORT nDefSize; + static const USHORT nLevelSize; + static UINT32 nDefCleared; + + void Grow( USHORT nRecIndex ); + public: + FltColumn( USHORT nNewCol ); +#ifdef USED + FltColumn( USHORT nNewCol, USHORT nNewSize ); +#endif + + ~FltColumn() { delete[] pData; } + + void SetXF( USHORT nRow, USHORT nNewXF ) + { + if( nRow < pExcGlob->AnzRows() ) + { + if( nRow >= nSize ) Grow( nRow ); + if( nRow > nLastRow ) nLastRow = nRow; + + DBG_ASSERT( nRow < nSize, + "-FltColumn::SetXF(): nSize nicht an nRow angepasst!" ); + + pData[ nRow ] = nNewXF; + } + } + + void SetTab( USHORT nNewTab ) + { + nTab = nNewTab; + } + + void Settings( USHORT nNewTab ) + { + nTab = nNewTab; + } + +#ifdef USED + void Reset( USHORT nNewTab ); +#endif + void Reset(); + void Apply(); + }; + +// --------------------------------------------------- class FltTabelle -- + +class FltTabelle + { + // ACHTUNG: ExcelKoordinaten -> Klasse( -> SwKoordinaten ) + private: + FltColumn **pData; // Array mit Column-Daten + USHORT nSize; + USHORT nLastCol; + public: + FltTabelle(); + ~FltTabelle(); + void Settings( USHORT nTab ); + void SetXF( USHORT nCol, USHORT nRow, USHORT nNewXF ); +#ifdef USED + void Reset( USHORT nTab ); +#endif + void Apply(); + }; + +// ----------------------------------------------------------------------- + +} //namespace binfilter +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/excdocum.hxx b/binfilter/bf_sw/source/filter/excel/excdocum.hxx new file mode 100644 index 000000000000..e09247bc2475 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/excdocum.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifdef USED + +#ifndef __EXCDOCUM_HXX__ +#define __EXCDOCUM_HXX__ + +// auto strip #include <tools/string.hxx> +namespace binfilter { + + +// Q&D defines statt consts +#define MAX_TABS_EXCDOK 1024 + +class ExcDokument + +// ----------------------------------------------------------------------- +// beschreibt eine Excel-Tabelle +class ExcTabelle + { + private: + friend ExcDokument; + String aName; + USHORT nCS; + USHORT nCE; + USHORT nRS; + USHORT nRE; + ULONG nStrPos; + + ExcTabelle( ULONG ); // mit Stream-Pos + ExcTabelle( const String & ); // mit Name + ExcTabelle( USHORT, USHORT, USHORT, USHORT ); // mit Range + public: + ExcTabelle(); + ~ExcTabelle(); + + void GetRange( USHORT& rCS, USHORT& rCE, USHORT& rRS, USHORT& rRE ) const + { + rCS = nCS; + rCE = nCE; + rRS = nRS; + rRE = nRE; + } + + ULONG GetStrPos( void ) const + { + return nStrPos; + } + + const String &GetName( void ) const + { + return aName; + } + }; + +// ----------------------------------------------------------------------- +// beschreibt ein Excel-Dokument +class ExcDokument + { + private: + ExcTabelle **ppTabellen; + INT32 nAktGetNext; // aktueller Index fuer GetNext + USHORT nAktTabIndex; // aktuelle Tabelle in ppTabellen + public: + ExcDokument(); + ~ExcDokument(); + +#ifdef USED + USHORT GetAnzTabs( void ) const; + ExcTabelle *operator[]( USHORT ); + void NewTab( const String &rName, + ULONG nStrPos = 0xFFFFFFFF ); + void Set( USHORT nNewCS, USHORT nNewCE, + USHORT nNewRS, USHORT nNewRE, + USHORT nIndex = 0xFFFF ); + ExcTabelle *GetNextTab( void ); + ExcTabelle *GetFirstTab( void ); + void Set( ULONG nStrPos, USHORT nIndex = 0xFFFF ); + void Set( const String &rName, + USHORT nIndex = 0xFFFF ); +#endif + }; + +#endif + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/excfntbf.hxx b/binfilter/bf_sw/source/filter/excel/excfntbf.hxx new file mode 100644 index 000000000000..8c853ab4f531 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/excfntbf.hxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _EXCFNTBF_HXX +#define _EXCFNTBF_HXX + +#include <tools/solar.h> +class String; +namespace binfilter { + +class SvxColorItem; +class SvxFontItem; +class SvxFontHeightItem; + + +//------------------------------------------------------------------------ + +enum ExcScript { + EXCSCR_None = 0x00, + EXCSCR_Super = 0x01, + EXCSCR_Sub = 0x02 }; + +enum ExcUnderline { + EXCUNDER_None = 0x00, + EXCUNDER_Single = 0x01, + EXCUNDER_Double = 0x02, + EXCUNDER_SingleAccount = 0x21, + EXCUNDER_DoubleAccount = 0x22, + EXCUNDER_Attr = 0xFF }; + +struct ExcFont{ + SvxFontItem *pFont; + SvxFontHeightItem *pHeight; + UINT16 nColor; + UINT16 nWeight; + ExcScript eScript; + ExcUnderline eUnderline; + INT16 bItalic : 1; + INT16 bStrikeout : 1; + INT16 bOutline : 1; + INT16 bShadow : 1; + }; + + +//------------------------------------------------------------------------ +class ColorBuffer + { + private: + SvxColorItem **pArray; + SvxColorItem *pDefault; + UINT16 nMax; + UINT16 nCount; + BOOL bAuto; + // ---------------------------------------------------------- + public: + ColorBuffer(); + ~ColorBuffer(); + +#ifdef USED + void Reset( void ); +#endif + BOOL NewColor( UINT16 nR, UINT16 nG, UINT16 nB ); + const SvxColorItem *GetColor( UINT16 nIndex ); + + BOOL Auto( void ) const { return bAuto; } + }; + +//------------------------------------------------------------------------ +class FontBuffer + { + private: + ExcFont **ppFonts; // Array mit Fontbeschreibungen + UINT16 nMax; // Groesse des Arrays + UINT16 nCount; // akt. Speichermarke im Array + ExcFont aDefaultFont; + public: + FontBuffer( UINT16 nNewMax = 128 ); + ~FontBuffer(); + + void NewFont( UINT16 nHeight, BYTE nAttr0, + UINT16 nIndexCol, const String &rName ); + + void NewFont( UINT16 nHeight, BYTE nAttr0, + BYTE nUnderline, UINT16 nIndexCol, + UINT16 nBoldness, BYTE nFamily, BYTE nCharset, + const String &rName ); + + const ExcFont &GetFont( UINT16 nIndex ); + +#ifdef USED + void Reset( void ); +#endif + }; + + + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/excvfbff.hxx b/binfilter/bf_sw/source/filter/excel/excvfbff.hxx new file mode 100644 index 000000000000..8b890931cee6 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/excvfbff.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _EXCVFBFF_HXX +#define _EXCVFBFF_HXX + +#include <tools/solar.h> +class String; +namespace binfilter { + + + +class ValueFormBuffer; + +#if defined(BLC) || defined(MAC) +// BLC will es auf jeden Fall hier +typedef void ( ValueFormBuffer::*Fkt_rString )( String & ); +typedef sal_uInt32 ( ValueFormBuffer::*Fkt_USHORT )( USHORT ); +#endif + +class ValueFormBuffer + { + private: +#if !defined(BLC) && !defined(MAC) +// MSC will es auf jeden Fall hier + typedef void ( ValueFormBuffer::*Fkt_rString )( String & ); + typedef sal_uInt32 ( ValueFormBuffer::*Fkt_USHORT )( USHORT ); +#endif + + sal_uInt32 *pHandles; // Array mit Handles... + USHORT nMax; // Groesse des Arrays + USHORT nCount; // Index des naechsten freien Eintrags + sal_uInt32 nDefaultHandle; + + // nur fuer Excel5 + static const USHORT nAnzBuiltin; // bekannte Formate + static const USHORT nNewFormats; // selbstdefinierte + static const sal_Char *pBuiltinFormats[]; // vordefinierte Formate + + Fkt_rString _NewValueFormat; + Fkt_USHORT _GetValueFormat; + // ---------------------------------------------------------- + void Init( void ); + // fuer 1. Nutzung + void __NewValueFormat( String &rFormString ); + sal_uInt32 __GetValueFormat( USHORT nExcIndex ); + // fuer n-te Nutzung + void _NewValueFormatX( String &rFormString ); + void _NewValueFormat5( String &rFormString ); + sal_uInt32 _GetValueFormatX5( USHORT nExcIndex ); + public: + ValueFormBuffer( const USHORT nSize = 2048 ); + ~ValueFormBuffer(); + + inline void NewValueFormat( String &rFormString ); + inline ULONG GetValueFormat( USHORT nExcIndex ); +#ifdef USED + void Reset( void ); +#endif + }; + +inline void ValueFormBuffer::NewValueFormat( String &rFormString ) + { + ( this->*_NewValueFormat )( rFormString ); + } + +inline ULONG ValueFormBuffer::GetValueFormat( USHORT nExcIndex ) + { + return ( this->*_GetValueFormat )( nExcIndex ); + } + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/excxfbuf.hxx b/binfilter/bf_sw/source/filter/excel/excxfbuf.hxx new file mode 100644 index 000000000000..929e139a65e0 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/excxfbuf.hxx @@ -0,0 +1,245 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _EXCXFBUF_HXX +#define _EXCXFBUF_HXX + +#include <tools/debug.hxx> +namespace binfilter { +class SfxItemSet; + +class SvxBorderLine; + + + +enum ExcHorizAlign { EHA_General = 0, EHA_Left = 1, EHA_Center = 2, + EHA_Right = 3, EHA_Fill = 4, EHA_Justify = 5, EHA_CentAcrSel = 6, + EHA_Parent }; + +enum ExcVertAlign { EVA_Top = 0, EVA_Center = 1, EVA_Bottom = 2, + EVA_Justify = 3, EVA_Parent }; + +enum ExcTextOrient { ETO_NoRot = 0, ETO_TopBottom = 1, ETO_90ccw = 2, + ETO_90cw = 3, ETO_Parent }; + +enum ExcWrapText { EWT_NoWrap = 0, EWT_Wrap = 1, EWT_Parent }; + +struct CellBorder + { + BYTE nTopLine; + BYTE nLeftLine; + BYTE nBottomLine; + BYTE nRightLine; + USHORT nTopColor; + USHORT nLeftColor; + USHORT nBottomColor; + USHORT nRightColor; + }; + +struct CellFill + { + BYTE nPattern; + USHORT nForeColor; + USHORT nBackColor; + }; + +// ----------------------------------------------------------------------- +class XF_Data + { + private: + USHORT nFont; // Index auf zugehoerigen Font + ULONG nValForm; // Id fuer Value-Format + ExcWrapText eWrap; + ExcHorizAlign eHoriz; + USHORT nParent; // Index zum Parent Style-XF + CellFill *pFill; + CellBorder *pBord; + BOOL bCellXF : 1; // Cell- oder Style-XF + BOOL bFontValid : 1; // nFont <> Font vom Parent? + BOOL bFormValid : 1; + public: + XF_Data(); + + ~XF_Data(); + + BOOL IsCellXF() const { return bCellXF; } + void SetCellXF() { bCellXF = TRUE; } + void SetCellXF( BOOL bNewCellXF ) { bCellXF = bNewCellXF; } + void SetStyleXF() { bCellXF = FALSE; } + + BOOL HasFont() const { return bFontValid; } + USHORT Font() const { return nFont; } + void SetFont( USHORT nNew ) + { nFont = nNew; bFontValid = TRUE; } + + BOOL HasValueFormat() const { return bFormValid; } + ULONG ValueFormat() const { return nValForm; } + void SetValueFormat( ULONG nNew ) + { nValForm=nNew; bFormValid=TRUE; } + + BOOL HasWrap() const { return ( eWrap != EWT_Parent ); } + void SetWrap() { eWrap = EWT_Wrap; } + void SetWrap( ExcWrapText eNew ) { eWrap = eNew; } + ExcWrapText Wrap() const { return eWrap; } + + BOOL HasHorizAlign() const + { return ( eHoriz != EHA_Parent ); } + void SetAlign( ExcHorizAlign eNew ) { eHoriz = eNew; } + ExcHorizAlign HorizAlign() const { return eHoriz; } + + void SetParent( USHORT nNew ) { nParent = nNew; } + USHORT Parent() const { return nParent; } + + BOOL HasFill() const { return ( pFill != NULL ); } + inline void SetFill( CellFill *pNew ); + inline void SetFill( const CellFill &rNew ); + inline void SetFill( BYTE nPattern, USHORT nForeColor, + USHORT nBackColor ); + const CellFill *Fill() const { return pFill; } + + BOOL HasBorder() const { return ( pBord != NULL ); } + + inline void SetBorder( CellBorder *pNew ); + + void SetBorder( const CellBorder &rNew ); +#if 0 + void SetBorder( BYTE nTopLine, BYTE nLeftLine, + BYTE nBottomLine, BYTE nRightLine, + USHORT nTopColor, USHORT nLeftColor, + USHORT nBottomColor, USHORT nRightColor ); +#endif + const CellBorder *Border() const { return pBord; } + }; + +inline void XF_Data::SetFill( CellFill *pNew ) + { + // PREC: Rufender newed pNew, deleted wird in XF_Data! + // !Es wird keine Kopie angelegt! + if( pFill != NULL ) delete pFill; + pFill = pNew; + } + +inline void XF_Data::SetFill( const CellFill &rNew ) + { + if( pFill == NULL ) pFill = new CellFill; + DBG_ASSERT( pFill != NULL, + "-XF_Data::SetFill(): pFill == NULL!" ); + pFill->nPattern = rNew.nPattern; + pFill->nForeColor = rNew.nForeColor; + pFill->nBackColor = rNew.nBackColor; + } + +inline void XF_Data::SetFill( BYTE nPattern, USHORT nForeColor, + USHORT nBackColor ) + { + if( pFill == NULL ) pFill = new CellFill; + DBG_ASSERT( pFill != NULL, + "-XF_Data::SetFill(): pFill == NULL!" ); + pFill->nPattern = nPattern; + pFill->nForeColor = nForeColor; + pFill->nBackColor = nBackColor; + } +inline void XF_Data::SetBorder( CellBorder *pNew ) + { + // PREC: Rufender newed pNew, deleted wird in XF_Data! + // !Es wird keine Kopie angelegt! + if( pBord != NULL ) delete pBord; + pBord = pNew; + } + + +// ----------------------------------------------------------------------- +class XF_Buffer + { + private: + SfxItemSet **ppTxtAttr; // Array mit Text-Attributes + SfxItemSet **ppBoxAttr; // Array mit Box-Attributes + XF_Data **ppData; // Array mit XF-Daten + USHORT nMax; // Groesse des Arrays + USHORT nCount; // akt. Speichermarke im pPattern-Array + SfxItemSet *pDefTxtAttr; // Array mit Text-Attributes + SfxItemSet *pDefBoxAttr; // Array mit Box-Attributes + XF_Data *pDefaultData; // im Fehlerfall als Daten + //---------------------------------------------------------------- + void ExcToSwBorderLine( BYTE nLine, USHORT nColor, + SvxBorderLine *&rpBorderLine ); + void CellXF( XF_Data &rD ); + void StyleXF( XF_Data &rD ); + void CreateItemSets( USHORT nIndex ); + public: + XF_Buffer( USHORT nNewMax = 2048 ); + ~XF_Buffer(); + + inline void NewXF( XF_Data *pD ); + + inline void GetItemSets( USHORT nIndex, const SfxItemSet *pTxtAttr, + const SfxItemSet *pBoxAttr ); + + sal_uInt32 GetNumFormat( USHORT nIndex ); + void SetItemSets( USHORT nCol, USHORT nSR, USHORT nER, + USHORT nXF ); +#ifdef USED + void Reset(); +#endif + }; + +inline void XF_Buffer::NewXF( XF_Data *pD ) + { + // PREC: pD muss in rufender Routine ge-'new'-t werden, + // delete im ~XF_Buffer + DBG_ASSERT( nCount < nMax, + "+XF_Buffer::NewXF(): Puffer fuer XFs voll!" ); + if( nCount < nMax ) + ppData[ nCount++ ] = pD; + } + +inline void XF_Buffer::GetItemSets( USHORT nIndex, const SfxItemSet *pTxtAttr, + const SfxItemSet *pBoxAttr ) + { + DBG_ASSERT( nIndex < nCount , + "+XF_Buffer::GetItemSets(): das ist zuviel des Guten!" ); + if( nIndex >= nCount ) + { + pTxtAttr = pDefTxtAttr; // nicht im Puffer + pBoxAttr = pDefBoxAttr; + } + else + { + if( ppTxtAttr[ nIndex ] == NULL ) + CreateItemSets( nIndex ); // erste Nutzung + + pTxtAttr = ppTxtAttr[ nIndex ]; + pBoxAttr = ppBoxAttr[ nIndex ]; + } + } + + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/exlpar.hxx b/binfilter/bf_sw/source/filter/excel/exlpar.hxx new file mode 100644 index 000000000000..fb4e481cd7fa --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/exlpar.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _EXLPAR_HXX +#define _EXLPAR_HXX + +#include "fltbase.hxx" + +#include "exccrts.hxx" +// auto strip #include "excdocum.hxx" +class SvStream; +class String; +namespace binfilter { + + +// einige Forward-Deklaratioen + +class SwPaM; +class SwDoc; + +class ValueFormBuffer; + + +enum StringInfoLen { + LenByte = 0,// 1 Byte lange Stringlaengeninfo + LenWord = 1 // 2 Byte " " + }; + +enum BiffTyp { + Biff2 = 0, + Biff3 = 2, + Biff3W = 3, + Biff4 = 4, + Biff4W = 5, + Biff5 = 8, + Biff5W = 9, + BiffX = -1 }; + + +class SwExcelParser : public SwFilterBase +{ + int bNewDoc : 1; + BiffTyp eDateiTyp; // aktuelles Tabellen-Format + static const double fExcToTwips; + static const sal_Char *pBuildInName[]; + + CharSet eQuellChar; // Quell-Zeichensatz (interner Zeichensatz) + CharSet eZielChar; // Ziel-Zeichensatz + + USHORT nLastCol; + USHORT nLastRow; + USHORT nLastXF; + +// ULONG nLastBof; // Stream Position NACH letzten BOF + + ColRowSettings aColRowBuff; // Col/Row-Einstellungen 1 Tabelle + FltTabelle aFltTab; // Attribute-Optimierung + +#ifdef USED + ExcDokument aExcDok; // merkt sich Tabellen-Parameter + ExcDataPool aDataPool; // merkt sich benannte Bereiche, + // Tabellenname, ... fuer'n Dialog +#endif + + ValueFormBuffer *pValueFormBuffer; // Exc->Sv-Numberformats + + USHORT nIxfeIndex; // merkt sich Angabe im IXFE-Record + + BOOL bResultString; + + // --------------------------------------------------------------- +// void NI(); // nicht implementierter Opcode + void Dimensions(); // 0x00 + void Blank25(); // 0x01 + void Number25(); // 0x03 + void Label25(); // 0x04 + void Formula25(); // 0x06 + void REC_String(); // 0x07 +// void Row25(); // 0x08 + void Bof2(); // 0x09 + void Eof(); // 0x0A +// void Externsheet(); // 0x17 +// void Name25(); // 0x18 +// void Note(); // 0x1C + void Format235(); // 0x1E +// void Formatcount(); // 0x1F +// void Columndefault(); // 0x20 +// void Array25(); // 0x21 +// void Externname25(); // 0x23 + void Colwidth(); // 0x24 +// void Defrowheight2(); // 0x25 + void Font25(); // 0x31 + void Codepage(); // 0x42 + void XF2(); // 0x43 + void Ixfe(); // 0x44 + void DefColWidth(); // 0x55 +// void Builtinfmtcnt(); // 0x56 + void Colinfo(); // 0x7D + void Rk(); // 0x7E + void Boundsheet(); // 0x85 +// void Country(); // 0x8C +// void Bundlesoffset(); // 0x8E +// void Bundleheader(); // 0x8F + void Palette(); // 0x92 + void Standardwidth(); // 0x99 +// void Shrfmla(); // 0xBC + void Mulrk(); // 0xBD + void Mulblank(); // 0xBE + void Rstring(); // 0xD6 + void XF5(); // 0xE0 + // // 0x0200 -> 0x00 + void Blank34(); // 0x0201 + void Number34(); // 0x0203 + void Label34(); // 0x0204 + void Formula3(); // 0x0206 +// void Row34(); // 0x0208 + void Bof3(); // 0x0209 +// void Name34(); // 0x0218 + void Array34(); // 0x0221 + void Externname34(); // 0x0223 + void Defrowheight345(); // 0225 + void Font34(); // 0x0231 + void XF3(); // 0x0243 + //void Rk(); // 0x027E -> 0x7E + void Formula4(); // 0x0406 + void Bof4(); // 0x0409 + void Format4(); // 0x041E + void XF4(); // 0x0443 + void Bof5(); // 0x0809 + // --------------------------------------------------------------- + double RkToDouble( const UINT32 &nRk ); + String &ReadExcString( StringInfoLen eLen, String &aString ); +#ifdef USED + void ResetBof(); +#endif + void EndSheet(); + void ReadExcString( StringInfoLen eLen ); + void PutCell( USHORT nCol, USHORT nRow, const String &rText, + USHORT nXF ); + void PutCell( USHORT nCol, USHORT nRow, double fVal, + USHORT nXF ); + void Parse(); + BOOL GetRange( USHORT nLenExpr, USHORT &rTab, USHORT &rCS, + USHORT &rCE, USHORT &rRS, USHORT &RE ); + // --------------------------------------------------------------- + void Init(); + void ScanDokuInfos(); // Info-Sammler fuer Arbeitsmappen + void ScanBiff2(); + void ScanBiff3(); + void ScanBiff4(); + void ScanBiff3W(); + void ScanBiff4W(); + void ScanBiff5W(); +#ifdef USED + void ReadTab( const ExcUiEntry &rUiEntry, ULONG nStrPos ); +#endif +public: + // Parameter bReadNewDoc gibt an, ob in ein bestehendes Dokument ein- + // gelesen wird. TRUE: in ein "neues" Dokument einfuegen. + SwExcelParser( SwDoc& rDoc, const SwPaM & rCrsr, SvStream& pIn, + int bReadNewDoc, CharSet eQ ); + ~SwExcelParser(); + + ULONG CallParser(); +}; + +} //namespace binfilter +#endif + // _EXLPAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/makefile.mk b/binfilter/bf_sw/source/filter/excel/makefile.mk new file mode 100644 index 000000000000..8676c0ca3125 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/makefile.mk @@ -0,0 +1,70 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +# makefile Verteiler + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_excel + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw + +CXXFILES = \ + sw_fltglbls.cxx \ + sw_exctools.cxx \ + sw_excread.cxx \ + sw_excimpop.cxx \ + sw_exlpar.cxx \ + + +SLOFILES = \ + $(SLO)$/sw_fltglbls.obj \ + $(SLO)$/sw_exctools.obj \ + $(SLO)$/sw_excread.obj \ + $(SLO)$/sw_excimpop.obj \ + $(SLO)$/sw_exlpar.obj + + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/excel/sw_excimpop.cxx b/binfilter/bf_sw/source/filter/excel/sw_excimpop.cxx new file mode 100644 index 000000000000..f93367d7c61f --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/sw_excimpop.cxx @@ -0,0 +1,1506 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdio.h> + +#include <tools/color.hxx> +#include <bf_svtools/zforlist.hxx> + +#include "exlpar.hxx" +#include "exccrts.hxx" +#include "excxfbuf.hxx" +#include "excfntbf.hxx" +#include "excvfbff.hxx" +#include <osl/endian.h> +namespace binfilter { + +const sal_Char *SwExcelParser::pBuildInName[] = { + "BI_Consolidate_Area","BI_Auto_Open","BI_Auto_Close", + "BI_Extract","BI_Database","BI_Criteria","BI_Print_Area", + "BI_Print_Titles","BI_Recorder","BI_Data_Form", + "BI_Auto_Activate","BI_Auto_Deactivate","BI_SheetTitle" }; + + + + +// ------------------------------------------------------------------ 0x00 +void SwExcelParser::Dimensions() + { + UINT16 nCS, nCE, nRS, nRE; + + *pIn >> nRS >> nRE >> nCS >> nCE; + nBytesLeft -= 8; + + nRE--; // ...Excel-Eigenheit + nCE--; + + pExcGlob->ColLimitter( nCS ); // Cols/Rows in ihre Schranken verweisen + pExcGlob->ColLimitter( nCE ); + + pExcGlob->RowLimitter( nRS ); + pExcGlob->RowLimitter( nRE ); + + pExcGlob->SetRange( nCS, nCE, nRS, nRE ); + } + +// ------------------------------------------------------------------ 0x01 +void SwExcelParser::Blank25() + { + UINT16 nRow, nCol, nXF; + + *pIn >> nRow >> nCol; + nBytesLeft -= 4; + if( eDateiTyp == Biff5 ) + { + *pIn >> nXF; + nBytesLeft -= 2; + } + else + { + pIn->SeekRel( 3 ); + nBytesLeft -= 3; + nXF = 0; + } + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + } + } + +// ------------------------------------------------------------------ 0x03 +void SwExcelParser::Number25() + { + UINT16 nRow, nCol, nXF; + double fValue; + + *pIn >> nRow >> nCol; + nBytesLeft -= 4; + if( eDateiTyp == Biff5 ) + { + *pIn >> nXF; + nBytesLeft -= 2; + } + else + { + pIn->SeekRel( 3 ); + nBytesLeft -= 3; + nXF = 0; + } + + *pIn >> fValue; + nBytesLeft -= 8; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, fValue, nXF ); + } + } + +// ------------------------------------------------------------------ 0x04 +void SwExcelParser::Label25() + { + UINT16 nRow, nCol, nXF; + + if( eDateiTyp == Biff5 ) + { + *pIn >> nRow >> nCol >> nXF; + nBytesLeft -= 6; + + ReadExcString( LenWord ); + } + else + {// nur fuer BIFF2 + BYTE nAttr0, nAttr1, nAttr2; + + *pIn >> nRow >> nCol >> nAttr0 >> nAttr1 >> nAttr2; + nBytesLeft -= 7; + + ReadExcString( LenByte ); + + nXF = nAttr0 & 0x3F; + if( nXF == 63 ) + // IXFE-record stand davor + nXF = nIxfeIndex; + } + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + String aSvStr( pReadBuff, eZielChar ); + PutCell( nCol, nRow, aSvStr, nXF ); + } + } + +// ------------------------------------------------------------------ 0x06 +void SwExcelParser::Formula25() + { + UINT16 nRow, nCol, nXF, nFormLen; + double fCurVal; + BYTE nAttr0, nFlag0; + + *pIn >> nRow >> nCol; + nBytesLeft -= 4; + + if( eDateiTyp == Biff2 ) + {// BIFF2 + BYTE nDummy; + *pIn >> nAttr0; + pIn->SeekRel( 2 ); + nBytesLeft -= 3; + + *pIn >> fCurVal; + pIn->SeekRel( 1 ); + *pIn >> nDummy; + nFormLen = nDummy; + nBytesLeft -= 10; + } + else + {// BIFF5 + *pIn >> nXF >> fCurVal >> nFlag0; + pIn->SeekRel( 5 ); + + *pIn >> nFormLen; + nBytesLeft -= 18; + } + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, fCurVal, nXF ); + } + } + + +// --------------------------------------------------------- 0x07 + 0x0207 +void SwExcelParser::REC_String() + { + if( pExcGlob->IsInRange( nLastCol, nLastRow ) ) + { + if( eDateiTyp == Biff2 ) + ReadExcString( LenByte ); + else + ReadExcString( LenWord ); + + String aSvStr( pReadBuff, eZielChar ); + PutCell( nLastCol, nLastRow, aSvStr, nLastXF ); + } + } +// ------------------------------------------------------------------ 0x09 +void SwExcelParser::Bof2() + { + //POST: eDateiTyp = Biff2 + UINT16 nTyp; + + pIn->SeekRel( 2 ); + *pIn >> nTyp; + nBytesLeft -= 4; + +#ifdef USED + ResetBof(); +#endif + + if( nTyp == 0x0010 ) // Worksheet? + { + //eAktZust = ImpZustTabBase; + eDateiTyp = Biff2; + } + else + { + //eAktZust = ImpZustInit; // -> ueberlesen von Nicht-Worksheets + eDateiTyp = BiffX; + } + } + +// ------------------------------------------------------------------ 0x0A +void SwExcelParser::Eof() + { + eDateiTyp = BiffX; + } + +// ------------------------------------------------------------------ 0x1E +void SwExcelParser::Format235() + { + String aFormString; + + if( eDateiTyp == Biff5 || eDateiTyp == Biff5W ) + { + pIn->SeekRel( 2 ); + nBytesLeft -= 2; + } + + ReadExcString( LenByte, aFormString ); + pValueFormBuffer->NewValueFormat( aFormString ); + } + + +// ------------------------------------------------------------------ 0x24 +void SwExcelParser::Colwidth() + {// Column Width + BYTE nColFirst, nColLast; + UINT16 nColWidth; + + *pIn >> nColFirst >> nColLast >> nColWidth; + nBytesLeft -= 4; + + nColWidth = ( UINT16 ) ( fExcToTwips * nColWidth ); + + aColRowBuff.SetWidthRange( nColFirst, nColLast, nColWidth ); + } + + +// ------------------------------------------------------------------ 0x31 +void SwExcelParser::Font25() + { + UINT16 nHeight, nIndexCol; + BYTE nAttr0; + String aName; + + if( eDateiTyp == Biff2 ) + {// Biff2 + *pIn >> nHeight >> nAttr0; + pIn->SeekRel( 1 ); + nBytesLeft -= 4; + nIndexCol = 32767; + + ReadExcString( LenByte, aName ); + + // Font in Pool batschen + pExcGlob->pFontBuff->NewFont( nHeight, nAttr0, nIndexCol, aName ); + } + else + {// Biff5 + BYTE nUnderline, nFamily, nCharSet; + UINT16 nWeight; + + *pIn >> nHeight >> nAttr0; + pIn->SeekRel( 1 ); + *pIn >> nIndexCol >> nWeight; + pIn->SeekRel( 2 ); // Super/Sub + *pIn >> nUnderline >> nFamily >> nCharSet; + pIn->SeekRel( 1 ); // Reserved + nBytesLeft -= 14; + + ReadExcString( LenByte, aName ); + + // Font in Pool batschen + pExcGlob->pFontBuff->NewFont( + nHeight, nAttr0, nUnderline, nIndexCol, nWeight, + nFamily, nCharSet, aName ); + } + } + +// ------------------------------------------------------------------ 0x42 +void SwExcelParser::Codepage() + { + UINT16 nPage; + + *pIn >> nPage; + nBytesLeft -= 2; + + switch( nPage ) + { + case 0x01B5: // IBM PC 437 (Multiplan) + eQuellChar = RTL_TEXTENCODING_IBM_437; + break; + case 0x8000: // Apple Macintosh + case 0x2710: // ??????????????????????????????????????????????? + eQuellChar = RTL_TEXTENCODING_APPLE_ROMAN; + break; + case 0x04E4: // ANSI (Windows ) Biff4+5 + case 0x8001: // ANSI (Windows ) Biff2+3 + eQuellChar = RTL_TEXTENCODING_MS_1252; + break; + } + } + +// ------------------------------------------------------------------ 0x43 +void SwExcelParser::XF2() + { + BYTE nDummyFormat, nDummyFont, nAttr; + UINT16 nIndexFormat, nIndexFont; + CellBorder aBorder; + XF_Data *pXFD = new XF_Data; + + pXFD->SetCellXF(); // keine Style-XFs in Biff2 + + *pIn >> nDummyFont; + pIn->SeekRel( 1 ); + *pIn >> nDummyFormat; + *pIn >> nAttr; + nBytesLeft -= 4; + + nIndexFormat = nDummyFormat & 0x3F; + nIndexFont = nDummyFont; + + if( nAttr & 0x08 ) + aBorder.nLeftLine = 1; // = durchgezogen, duenn + else + aBorder.nLeftLine = 0; // = keine Linie + + if( nAttr & 0x10 ) + aBorder.nRightLine = 1; + else + aBorder.nRightLine = 0; + + if( nAttr & 0x20 ) + aBorder.nTopLine = 1; + else + aBorder.nTopLine = 0; + + if( nAttr & 0x40 ) + aBorder.nBottomLine = 1; + else + aBorder.nBottomLine = 0; + + aBorder.nLeftColor = aBorder.nRightColor = aBorder.nTopColor = + aBorder.nBottomColor = 8; // = schwarz? + + pXFD->SetValueFormat( pValueFormBuffer->GetValueFormat( nIndexFormat ) ); + pXFD->SetBorder( aBorder ); + pXFD->SetFont( nIndexFont ); + pXFD->SetAlign( ( ExcHorizAlign ) ( nAttr & 0x07 ) ); + + pExcGlob->pXF_Buff->NewXF( pXFD ); +} + +// ------------------------------------------------------------------ 0x44 +void SwExcelParser::Ixfe() +{ + *pIn >> nIxfeIndex; + nBytesLeft -= 2; +} + +// ------------------------------------------------------------------ 0x55 +void SwExcelParser::DefColWidth() +{ + UINT16 nWidth; + *pIn >> nWidth; + nBytesLeft -= 2; + + //nWidth = ( UINT16 ) ( TWIPS_PER_CHAR * nWidth ); + nWidth = ( UINT16 ) ( ((20.0 * 72.27) / 13.6) * nWidth ); + + aColRowBuff.SetDefWidth( nWidth ); +} + +// ------------------------------------------------------------------ 0x7D +void SwExcelParser::Colinfo() + {// Column Formatting Information + UINT16 nColFirst, nColLast, nColWidth, nXF; + BYTE nOpt0, nOpt1; + + *pIn >> nColFirst >> nColLast >> nColWidth >> nXF >> nOpt0 >> nOpt1; + nBytesLeft -= 10; + + nColWidth = ( UINT16 ) ( fExcToTwips * nColWidth ); + + aColRowBuff.SetWidthRange( nColFirst, nColLast, nColWidth ); + } + +// ------------------------------------------------------------------ 0x7E +void SwExcelParser::Rk() + {// Cell Value, RK Number + UINT16 nRow, nCol, nXF; + UINT32 nRkNum; + + *pIn >> nRow >> nCol >> nXF >> nRkNum; + nBytesLeft -= 10; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, RkToDouble( nRkNum ), nXF ); + } + } + +/* +// ------------------------------------------------------------------ 0x85 +void SwExcelParser::Boundsheet() + { + BYTE nOpt0, nOpt1; + UINT32 nStrPos; + String aName; + + if( eDateiTyp == Biff5W ) + { + *pIn >> nStrPos; + *pIn >> nOpt0 >> nOpt1; + nBytesLeft -= 6; + + if( nOpt0 == 0x00 ) // nur Namen von Worksheets speichern + { + ReadExcString( LenByte, aName ); + aName.Convert( eQuellChar, eZielChar ); + //aTabNameBuff << aName; +// aExcDok.NewTab( aName, nStrPos ); #################################### + } + } + else + { + ReadExcString( LenByte, aName ); + + aName.Convert( eQuellChar, eZielChar ); + //aTabNameBuff << aName; +// aExcDok.Set( aName, nTab ); #################################### + nTab++; + } + +// if( nOpt0 == 0x00 ) // nur Namen von Worksheets speichern +// { +// aDataPool.InsertEntry( aAnsiName, EET_Table, aAnsiName, +// aTabNameBuff.GetLastIndex(), 0, 0xFFFF, 0, 0xFFFF ); + // zunaechst gesamte Tabelle selektieren, da Groesse noch nicht bekannt +// } + } +*/ + +// ------------------------------------------------------------------ 0x92 +void SwExcelParser::Palette() + { + UINT16 nAnz; + BYTE nRed, nGreen, nBlue, nDummy; + + *pIn >> nAnz; + nBytesLeft -= 2; + + for( UINT16 nC = 0 ; nC < nAnz ; nC++ ) + { + *pIn >> nRed >> nGreen >> nBlue >> nDummy; + pExcGlob->pColorBuff->NewColor( nRed, nGreen, nBlue ); + nBytesLeft -= 4; + } + + DBG_ASSERT( nBytesLeft >= 0, + "*SwExcelParser::Palette(): Ups, das war zuviel!" ); + DBG_ASSERT( nBytesLeft <= 0, + "*SwExcelParser::Palette(): Ups, da ha'mer jemanden vergessen!" ); + } + +// ------------------------------------------------------------------ 0x99 +void SwExcelParser::Standardwidth() + { + UINT16 nWidth; + *pIn >> nWidth; + nBytesLeft -= 2; + aColRowBuff.SetDefWidth( ( UINT16 ) fExcToTwips * nWidth ); + } + +// ------------------------------------------------------------------ 0xBD +void SwExcelParser::Mulrk() + { + UINT16 nRow, nColFirst, nXF; + UINT32 nRkNum; + + *pIn >> nRow >> nColFirst; + nBytesLeft -= 4; + + if( pExcGlob->IsInRowRange( nRow ) ) + { + for( UINT16 nCol = nColFirst ; nBytesLeft > 2 ; nCol++ ) + { + *pIn >> nXF >> nRkNum; + nBytesLeft -= 6; + + if( pExcGlob->IsInColRange( nCol ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, RkToDouble( nRkNum ), nXF ); + } + } + DBG_ASSERT( nBytesLeft == 2, + "+SwExcelParser::Mulrk(): Was'n das?!!!" ); + } + } + +// ------------------------------------------------------------------ 0xBE +void SwExcelParser::Mulblank() + { + UINT16 nRow, nCol, nColFirst, nXF; + + *pIn >> nRow >> nColFirst; + nBytesLeft -= 4; + + if( pExcGlob->IsInRowRange( nRow ) ) + { + for( nCol = nColFirst ; nBytesLeft > 2 ; nCol++ ) + { + *pIn >> nXF; + nBytesLeft -= 2; + + if( pExcGlob->IsInColRange( nCol ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + } + } + } + } + +// ------------------------------------------------------------------ 0xD6 +void SwExcelParser::Rstring() + { + UINT16 nRow, nCol, nXF; + BYTE nCount; + String aString; + + *pIn >> nRow >> nCol >> nXF; + nBytesLeft -= 6; + ReadExcString( LenWord, aString ); + *pIn >> nCount; + nBytesLeft--; + pIn->SeekRel( nCount * 2 ); // STRUN-Structures ueberspringen + nBytesLeft -= nCount * 2; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, aString, nXF ); + } + } + +// ------------------------------------------------------------------ 0xE0 +void SwExcelParser::XF5() + { + UINT16 nAttr0, nAlign, nIndexFormat, nIndexFont, nFillCol, + nFill_Bottom, nBorder0, nBorder1; + CellBorder aBorder; + CellFill aFill; + XF_Data *pXFD = new XF_Data; + + *pIn >> nIndexFont >> nIndexFormat >> nAttr0 >> nAlign >> nFillCol + >> nFill_Bottom >> nBorder0 >> nBorder1; + nBytesLeft -= 16; + + aBorder.nTopLine = ( BYTE ) nBorder0 & 0x0007; // .............210 + aBorder.nTopColor = ( nBorder0 & 0xFE00 ) >> 9; // 5432109......... + aBorder.nLeftLine = ( BYTE ) ( ( nBorder0 & 0x0038 ) >> 3 );// ..........543... + aBorder.nLeftColor = nBorder1 & 0x007F ; // .........6543210 + aBorder.nBottomLine = ( BYTE ) ((nFill_Bottom & 0x01C0)>>6);// .......876...... + aBorder.nBottomColor = ( nFill_Bottom & 0xFE00 ) >> 9; // 5432109......... + aBorder.nRightLine = ( BYTE ) ( ( nBorder0 & 0x01C0 ) >> 6);//........876..... + aBorder.nRightColor = ( nBorder1& 0x3F80 ) >> 7; // ..3210987....... + + aFill.nPattern = ( BYTE ) nFill_Bottom & 0x003F; // ..........543210 + aFill.nForeColor = nFillCol & 0x007F; // .........6543210 + aFill.nBackColor = ( nFillCol & 0x1F80 ) >> 7; // ...210987....... + + if( nAttr0 & 0x0004 ) + {// Style-XF + pXFD->SetStyleXF(); + } + else + {// Cell-XF + pXFD->SetCellXF(); + } + + pXFD->SetParent( ( nAttr0 & 0xFFF0 ) >> 4 ); + + if( nAlign & 0x0400 ) + pXFD->SetValueFormat( pValueFormBuffer->GetValueFormat( nIndexFormat ) ); + if( nAlign & 0x0800 ) + pXFD->SetFont( nIndexFont ); + if( nAlign & 0x1000 ) + pXFD->SetAlign( ( ExcHorizAlign ) ( nAlign & 0x0007 ) ); + if( nAlign & 0x2000 ) + pXFD->SetBorder( aBorder ); + if( nAlign & 0x4000 ) + pXFD->SetFill( aFill ); + + pExcGlob->pXF_Buff->NewXF( pXFD ); + } + +// ---------------------------------------------------------------- 0x0201 +void SwExcelParser::Blank34() + { + UINT16 nRow, nCol, nXF; + + *pIn >> nRow >> nCol >> nXF; + nBytesLeft -= 6; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + } + } + +// ---------------------------------------------------------------- 0x0203 +void SwExcelParser::Number34() + { + UINT16 nRow, nCol, nXF; + double fValue; + + *pIn >> nRow >> nCol >> nXF >> fValue; + nBytesLeft -= 14; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, fValue, nXF ); + } + } + +// ---------------------------------------------------------------- 0x0204 +void SwExcelParser::Label34() + { + UINT16 nRow, nCol, nXF; + + *pIn >> nRow >> nCol >> nXF; + nBytesLeft -= 6; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + ReadExcString( LenWord ); + String aSvStr( pReadBuff, eZielChar ); + + PutCell( nCol, nRow, aSvStr, nXF ); + } + } + +// ---------------------------------------------------------------- 0x0206 +void SwExcelParser::Formula3() + { + UINT16 nRow, nCol, nXF, nFormLen; + double fCurVal; + BYTE nFlag0; + + *pIn >> nRow >> nCol >> nXF >> fCurVal >> nFlag0; + pIn->SeekRel( 1 ); + *pIn >> nFormLen; + nBytesLeft -= 18; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, fCurVal, nXF ); + } + } + +// ---------------------------------------------------------------- 0x0209 +void SwExcelParser::Bof3() + { + //POST: eDateiTyp = Biff3 + UINT16 nTyp; + + pIn->SeekRel( 2 ); + *pIn >> nTyp; + nBytesLeft -= 4; + +#ifdef USED + ResetBof(); +#endif + + if( nTyp == 0x0010 ) // Worksheet + { + //eAktZust = ImpZustTabBase; + eDateiTyp = Biff3; + } + else if( nTyp == 0x0100 ) // Workbook + { + //eAktZust = ImpZustGlobals; + eDateiTyp = Biff3W; + } + else + { + //eAktZust = ImpZustInit; // -> ueberlesen von Nicht-Worksheets/-Workbooks + eDateiTyp = BiffX; + } + } + +// ---------------------------------------------------------------- 0x0218 +#ifdef USED +void SwExcelParser::Name34() + { + BYTE nLenName; + UINT16 nAttr, nLenExpr; + UINT16 nT, nCS, nCE, nRS, nRE; + String aExpr, aAnsiName; + SpString aName; + sal_Char cZ; + + *pIn >> nAttr; + pIn->SeekRel( 1 ); + *pIn >> nLenName >> nLenExpr; + nBytesLeft -= 6; + + // Namen einlesen + for( UINT16 nLauf = 0 ; nLauf < nLenName ; nLauf++ ) + { + *pIn >> cZ; + aName += cZ; + } + nBytesLeft -= nLenName; + + if( aName.Len() == 1 && ( const sal_Char ) aName < 0x0D ) + {// Build-in name (0x00 - 0x0C als erstes Zeichen) + aAnsiName = pBuildInName[ ( const sal_Char ) aName ]; + } + else + { + aAnsiName = ( const sal_Char * ) aName; + aAnsiName.Convert( eQuellChar, eZielChar ); + } + + if( GetRange( nLenExpr, nT, nCS, nCE, nRS, nRE ) ) + { + aDataPool.InsertEntry( aAnsiName, EET_NamedRange, + aTabNameBuff[ nT ], nT, nCS, nCE, nRS, nRE ); + } + } + +// ---------------------------------------------------------------- 0x0221 +void SwExcelParser::Array34() + { + } + +// ---------------------------------------------------------------- 0x0223 +void SwExcelParser::Externname34() + { + } + +// ---------------------------------------------------------------- 0x0225 +void SwExcelParser::Defrowheight345() + { + } +#endif + +// ---------------------------------------------------------------- 0x0231 +void SwExcelParser::Font34() + { + UINT16 nHeight, nIndexCol; + BYTE nAttr0; + String aName; + + *pIn >> nHeight >> nAttr0; + pIn->SeekRel( 1 ); + *pIn >> nIndexCol; + nBytesLeft -= 6; + + ReadExcString( LenByte, aName ); + // Font in Pool batschen + pExcGlob->pFontBuff->NewFont( nHeight, nAttr0, nIndexCol, aName ); + } + +// ---------------------------------------------------------------- 0x0243 +void SwExcelParser::XF3() + { + BYTE nDummyFormat, nDummyFont; + UINT16 nAttr0, nAttr1, nIndexFormat, nIndexFont, nBorder, nFill; + CellBorder aBorder; + CellFill aFill; + XF_Data *pXFD = new XF_Data; + + *pIn >> nDummyFont >> nDummyFormat >> nAttr0 >> nAttr1 >> nFill >> nBorder; + + aBorder.nTopLine = ( BYTE ) nBorder & 0x0007; // .............210 + aBorder.nTopColor = ( nBorder & 0x00F8 ) >> 3; // ........76543... + aBorder.nLeftLine = ( BYTE ) ( ( nBorder & 0x0700 ) >> 8 ); // .....098........ + aBorder.nLeftColor = ( nBorder & 0xF800 ) >> 11; // 54321........... + *pIn >> nBorder; + aBorder.nBottomLine = ( BYTE ) nBorder & 0x0007; // .............210 + aBorder.nBottomColor = ( nBorder & 0x00F8 ) >> 3; // ........76543... + aBorder.nRightLine = ( BYTE ) ( ( nBorder & 0x0700 ) >> 8 );// .....098........ + aBorder.nRightColor = ( nBorder & 0xF800 ) >> 11; // 54321........... + nBytesLeft -= 12; + + nIndexFormat = nDummyFormat; + nIndexFont = nDummyFont; + aFill.nPattern = ( BYTE ) ( nFill & 0x003F ); // ..........543210 + aFill.nForeColor = ( nFill & 0x07C0 ) >> 6; // .....09876...... + aFill.nBackColor = ( nFill & 0xF800 ) >> 11; // 54321........... + + if( nAttr0 & 0x0400 ) + pXFD->SetValueFormat( pValueFormBuffer->GetValueFormat( nIndexFormat ) ); + if( nAttr0 & 0x0004 ) + {// Style-XF + pXFD->SetStyleXF(); + } + else + {// Cell-XF + pXFD->SetCellXF(); + } + + pXFD->SetParent( ( nAttr1 & 0xFFF0 ) >> 4 ); + + if( nAttr0 & 0x0800 ) + pXFD->SetFont( nIndexFont ); + if( nAttr0 & 0x1000 ) + pXFD->SetAlign( ( ExcHorizAlign ) ( nAttr1 & 0x0007 ) ); + if( nAttr0 & 0x2000 ) + pXFD->SetBorder( aBorder ); + if( nAttr0 & 0x4000 ) + pXFD->SetFill( aFill ); + + pExcGlob->pXF_Buff->NewXF( pXFD ); + } + +// ----------------------------------------------------- 0x7E <----- 0x27E + +// ---------------------------------------------------------------- 0x0406 +void SwExcelParser::Formula4() + { + UINT16 nRow, nCol, nXF, nFormLen; + double fCurVal; + BYTE nFlag0; + + *pIn >> nRow >> nCol >> nXF >> fCurVal >> nFlag0; + pIn->SeekRel( 1 ); + *pIn >> nFormLen; + nBytesLeft -= 18; + + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + aColRowBuff.Used( nCol, nRow ); + aFltTab.SetXF( nCol, nRow, nXF ); + + PutCell( nCol, nRow, fCurVal, nXF ); + } + } + +// ---------------------------------------------------------------- 0x0409 +void SwExcelParser::Bof4() + { + //POST: eDateiTyp = Biff4 + UINT16 nTyp; + + pIn->SeekRel( 2 ); + *pIn >> nTyp; + nBytesLeft -= 4; + +#ifdef USED + ResetBof(); +#endif + + if( nTyp == 0x0010 ) // Worksheet + { + //eAktZust = ImpZustTabBase; + eDateiTyp = Biff4; + } + else if( nTyp == 0x0100 ) // Workbook + { + //eAktZust = ImpZustGlobals; + eDateiTyp = Biff4W; + } + else + { + //eAktZust = ImpZustInit; // -> ueberlesen von Nicht-Worksheets/-Workbooks + eDateiTyp = BiffX; + } + + } + +// ---------------------------------------------------------------- 0x041E +void SwExcelParser::Format4() + { + String aFormString; + + pIn->SeekRel( 2 ); + nBytesLeft -=2 ; + + ReadExcString( LenByte, aFormString ); + + pValueFormBuffer->NewValueFormat( aFormString ); + } + +// ---------------------------------------------------------------- 0x0443 +void SwExcelParser::XF4() + { + BYTE nDummyFormat, nDummyFont; + UINT16 nAttr0, nAttr1, nIndexFormat, nIndexFont, nBorder, nFill; + CellBorder aBorder; + CellFill aFill; + XF_Data *pXFD = new XF_Data; + + *pIn >> nDummyFont >> nDummyFormat >> nAttr0 >> nAttr1 >> nFill >> nBorder; + aBorder.nTopLine = ( BYTE ) nBorder & 0x0007; // .............210 + aBorder.nTopColor = ( nBorder & 0x00F8 ) >> 3; // ........76543... + aBorder.nLeftLine = ( BYTE ) ( ( nBorder & 0x0700 ) >> 8 ); // .....098........ + aBorder.nLeftColor = ( nBorder & 0xF800 ) >> 11; // 54321........... + *pIn >> nBorder; + aBorder.nBottomLine = ( BYTE ) nBorder & 0x0007; // .............210 + aBorder.nBottomColor = ( nBorder & 0x00F8 ) >> 3; // ........76543... + aBorder.nRightLine = ( BYTE ) ( ( nBorder & 0x0700 ) >> 8 );// .....098........ + aBorder.nRightColor = ( nBorder & 0xF800 ) >> 11; // 54321........... + nBytesLeft -= 12; + + nIndexFormat = nDummyFormat; + nIndexFont = nDummyFont; + aFill.nPattern = ( BYTE ) nFill & 0x003F; // ..........543210 + aFill.nForeColor = ( nFill & 0x07C0 ) >> 6; // .....09876...... + aFill.nBackColor = ( nFill & 0xF800 ) >> 11; // 54321........... + + if( nAttr1 & 0x0400 ) + pXFD->SetValueFormat( pValueFormBuffer->GetValueFormat( nIndexFormat ) ); + if( nAttr0 & 0x0004 ) + {// Style-XF + pXFD->SetStyleXF(); + } + else + {// Cell-XF + pXFD->SetCellXF(); + } + + pXFD->SetParent( ( nAttr0 & 0xFFF0 ) >> 4 ); + + if( nAttr1 & 0x0800 ) + pXFD->SetFont( nIndexFont ); + if( nAttr1 & 0x1000 ) + pXFD->SetAlign( ( ExcHorizAlign ) ( nAttr1 & 0x0007 ) ); + if( nAttr1 & 0x2000 ) + pXFD->SetBorder( aBorder ); + if( nAttr1 & 0x4000 ) + pXFD->SetFill( aFill ); + + pExcGlob->pXF_Buff->NewXF( pXFD ); + } + +// ---------------------------------------------------------------- 0x0809 +void SwExcelParser::Bof5() + { + UINT16 nSubType, nVers; + + *pIn >> nVers >> nSubType; + nBytesLeft -= 4; + +#ifdef USED + ResetBof(); +#endif + + if( nSubType == 0x0010 ) // Worksheet + { + eDateiTyp = Biff5; + } + else if( nSubType == 0x0005 ) // Workbook Globals + { + //eAktZust = ImpZustGlobals; + eDateiTyp = Biff5W; + } + else if( nSubType == 0x0100 ) // Workspace File + { + //eAktZust = ImpZustGlobals; // !!!!!!!! ACHTUNG: verifizieren !!!!!!!!1 + eDateiTyp = Biff5W; + } + else + { + //eAktZust = ImpZustInit; + eDateiTyp = BiffX; + } + } + +//-------------------------------------------- SwExcelParser::RkToDouble - +double SwExcelParser::RkToDouble( const UINT32 &nRk ) + { + //PLATTFORMABHAENGIG// + double fVal; + + // jetzt kommt Code aus'm Excel-Developer's-Kit-Buch V5 (S.223) + if( nRk & 0x02 ) + // Integer + fVal = ( double ) ( *( ( INT32 * ) &nRk ) >> 2 ); + else + {// 64-Bit IEEE-Float +#ifdef OSL_BIGENDIAN +//680xx und alle anderen vernuenftigen Prozessoren... + *( ( UINT32 * ) &fVal + 1 ) = 0; // unteren 32 Bits = 0 + *( ( UINT32 * ) &fVal ) = nRk & 0xFFFFFFFC; // Bit 0, 1 = 0 +#else +//Intel-Sch... + *( ( UINT32 * ) &fVal ) = 0; // unteren 32 Bits = 0 + *( ( UINT32 * ) &fVal + 1 ) = nRk & 0xFFFFFFFC; // Bit 0, 1 = 0 +#endif + } + + if( nRk & 0x01 ) + fVal /= 100; + + return fVal; + } + +//----------------------------------------- SwExcelParser::ReadExcString - +String &SwExcelParser::ReadExcString( StringInfoLen eLen, String &aString ) + { + // POST: ACHTUNG: Funktion setzt nBytesLeft selbstaendig!!!!! + // (geht auch nicht anders!) + // ACHTUNG: es wird an String angehaengt + UINT16 nLaenge; + BYTE nHelp; + + if( eLen == LenByte ) + { + *pIn >> nHelp; + nLaenge = nHelp; + nBytesLeft--; + } + else + { + *pIn >> nLaenge; + nBytesLeft -= 2; + } + + nBytesLeft -= nLaenge; + sal_Char* pStr = new sal_Char[ nLaenge + 2 ]; + pIn->Read( pStr, nLaenge ); + pStr[ nLaenge ] = 0; + aString = String(pStr, eZielChar); + delete[] pStr; + + return aString; + } + + +#ifdef USED +//---------------------------------------------- SwExcelParser::ResetBof - +void SwExcelParser::ResetBof() + {// setzt alle Einstellungen fuer neuen Tabellenbeginn zurueck +// pFontBuffer->Reset(); +// pXF_Buffer->Reset(); +// pColorBuffer->Reset(); +// aNameBuff.Reset(); +// aExtNameBuff.Reset(); +// aExtSheetBuff.Reset(); +// aColRowBuff.NewTab( nTab ); +// aFltTab.Reset( nTab ); + } +#endif + + +//---------------------------------------------- SwExcelParser::EndSheet - +void SwExcelParser::EndSheet() + {// mach 'Gemarmel' am Ende eines Sheets + aColRowBuff.Apply(); + aFltTab.Apply(); + } + +//----------------------------------------- SwExcelParser::ReadExcString - +void SwExcelParser::ReadExcString( StringInfoLen eLen ) + { + // POST: ACHTUNG: Funktion setzt nBytesLeft selbstaendig!!!!! + // (geht auch nicht anders!) + // Inhalt landet im pReadBuff + UINT16 nLaenge; + + if( eLen == LenByte ) + { + BYTE nHelp; + *pIn >> nHelp; + nLaenge = nHelp; + nBytesLeft--; + } + else + { + *pIn >> nLaenge; + nBytesLeft -= 2; + } + + if( nLaenge >= nReadBuffSize ) + // genug Platz fuer String UND Nullbyte? + nLaenge = nReadBuffSize - 1; + + pIn->Read( pReadBuff, nLaenge ); // String einlesen + pReadBuff[ nLaenge ] = 0; // ...und nullterminieren + + nBytesLeft -= nLaenge; + } + +//-------------------------------- SwExcelParser::PutCell( ..., String ) - +void SwExcelParser::PutCell( UINT16 nCol, UINT16 nRow, const String &rText, + UINT16 nXF ) + { + String aAusgabeString; + String aDummyEingabe = rText; + Color *pDummyColor; + + DBG_ASSERT( pExcGlob->IsInColRange( nCol ), + "-SwExcelParser::PutCell(): Col ist nicht im erlaubten Bereich!" ); + DBG_ASSERT( pExcGlob->IsInRowRange( nRow ), + "-SwExcelParser::PutCell(): Row ist nicht im erlaubten Bereich!" ); + + pExcGlob->Normalize( nCol, nRow ); + + pExcGlob->pNumFormatter->GetOutputString( + aDummyEingabe, + pExcGlob->pXF_Buff->GetNumFormat( nXF ), + aAusgabeString, + &pDummyColor); + pExcGlob->InsertText( nCol, nRow, aAusgabeString ); +} + +//-------------------------------- SwExcelParser::PutCell( ..., double ) - +void SwExcelParser::PutCell( UINT16 nCol, UINT16 nRow, double fVal, + UINT16 nXF ) +{ + String aAusgabeString; + UINT16 nUpperWord; + BYTE nType, nTypeValue; + Color *pDummyColor; + + DBG_ASSERT( pExcGlob->IsInColRange( nCol ), + "-SwExcelParser::PutCell(): Col ist nicht im erlaubten Bereich!" ); + DBG_ASSERT( pExcGlob->IsInRowRange( nRow ), + "-SwExcelParser::PutCell(): Row ist nicht im erlaubten Bereich!" ); + + pExcGlob->Normalize( nCol, nRow ); + +#ifdef OSL_BIGENDIAN +//680xx und alle anderen vernuenftigen Prozessoren... + nUpperWord = *( (UINT16*) &fVal ); // Intel-Word #3 + if( nUpperWord == 0xFFFF ) + { // Ergebnis keine Zahl! + nType = *( ( (BYTE*) &fVal ) + 7 ); // Intel-Byte #0 + nTypeValue = *( ( (BYTE*) &fVal ) + 5 ); // Intel-Byte #2 + //} +#else +//Intel-Sch... + nUpperWord = *( (UINT16*) &fVal + 3 ); // Intel-Word #3 + if( nUpperWord == 0xFFFF ) + { // Ergebnis keine Zahl! + nType = *( (BYTE*) &fVal ); // Intel-Byte #0 + nTypeValue = *( ( (BYTE*) &fVal ) + 2 ); // Intel-Byte #2 + //} +#endif + // ...gemeinsamer Code + if( nType ) + {// Ergebnis KEIN String + if( nType == 1 ) + {// Boolean + if( nTypeValue ) + aAusgabeString.AssignAscii("TRUE"); + else + aAusgabeString.AssignAscii("FALSE"); + } + else if( nType == 2 ) + {// Boolerr + switch( nTypeValue ) + { + case 0x00: aAusgabeString.AssignAscii("#NULL!"); break; + case 0x07: aAusgabeString.AssignAscii("#DIV/0"); break; + case 0x0F: aAusgabeString.AssignAscii("#VALUE!"); break; + case 0x17: aAusgabeString.AssignAscii("#REF!"); break; + case 0x1D: aAusgabeString.AssignAscii("#NAME?"); break; + case 0x24: aAusgabeString.AssignAscii("#NUM!"); break; + case 0x2A: aAusgabeString.AssignAscii("#N/A"); break; + default: aAusgabeString.AssignAscii("#UNKNOWN"); + } + } + else + { + aAusgabeString.AssignAscii("Unknown type of result"); + } + }// Ende: Ergebnis KEIN String + else + {// String folgt Formula-Record + //eAktZust = ImpZustString; + bResultString = TRUE; + nLastCol = nCol; + nLastRow = nRow; + nLastXF = nXF; + } +// dieses ifdef ist nur fuer das segprag tool, wegen paariger Klammerung +#ifdef OSL_BIGENDIAN + } // Ende: Ergebnis keine Zahl! +#else + } // Ende: Ergebnis keine Zahl! +#endif + else + {// Ergebnis: 8-Byte IEEE-Number + pExcGlob->pNumFormatter->GetOutputString( + fVal, + pExcGlob->pXF_Buff->GetNumFormat( nXF ), + aAusgabeString, + &pDummyColor); + } + + if( !bResultString ) + pExcGlob->InsertText( nCol, nRow, aAusgabeString ); + +}// Ende: PutCell() + +#ifdef USED + +//-------------------------------------------- SwExcelParser::GetRange() - +BOOL SwExcelParser::GetRange( UINT16 nLenExpr, UINT16 &rTab, UINT16 &rCS, + UINT16 &rCE, UINT16 &rRS, UINT16 &rRE ) + { + // sucht in Formelausdruck nach einer Area-Refernce + // return = TRUE -> gueltiger Bereich gefunden + // = FALSE -> nichts gefunden + BOOL bRet = TRUE; + BYTE nOpcode; + //INT32 nCount = nLenExpr; + + *pIn >> nOpcode; + nBytesLeft--; + + switch( nOpcode ) + { + case 0x3A: + case 0x5A: + case 0x7A: // 3-D Cell-Reference + { + UINT16 nRowFirst, nRowLast, nTabFirst, nTabLast; + INT16 nIndExt; + BYTE nColFirst, nColLast; + *pIn >> nIndExt; + pIn->SeekRel( 8 ); + *pIn >> nTabFirst >> nTabLast >> nRowFirst >> nRowLast + >> nColFirst >> nColLast; + nBytesLeft -= 20; + + if( ( nRowFirst & 0xC0000 ) || // First relativ + ( nRowLast & 0xC000 ) || // Last relativ + ( nIndExt >= 0 ) ) // externe Reference + bRet = FALSE; + else + {// alle Angaben OK... aber nur erste Tabelle wird genommen + rTab = nTabFirst; + rCS = nColFirst; + rCE = nColLast; + rRS = nRowFirst & 0xC000; + rRE = nRowLast & 0xC000; + } + } + break; + default: + bRet = FALSE; + } + + return bRet; + } + +/* */ + +// ----------------------------------------------------------------------- +void SwExcelParser::NI() + { + } + +// ------------------------------------------------------------------ 0x08 +void SwExcelParser::Row25() + { + } + +// ------------------------------------------------------------------ 0x17 +void SwExcelParser::Externsheet() + { + } + +// ------------------------------------------------------------------ 0x18 + +void SwExcelParser::Name25() + { + String aExpr; + UINT16 nT, nCS, nCE, nRS, nRE; + + if( eDateiTyp == Biff2 ) + {// --------------------------------------------------- Biff2 + BYTE nAttr0, nAttr1, nLenName, nLenExpr; + UINT16 nLauf; + sal_Char cZ; + SpString aName; // Bereichsname + String aAnsiName; + + *pIn >> nAttr0 >> nAttr1; + pIn->SeekRel( 1 ); + *pIn >> nLenName >> nLenExpr; + nBytesLeft -= 5; + + // Namen einlesen + for( nLauf = 0 ; nLauf < nLenName ; nLauf++ ) + { + *pIn >> cZ; + aName += cZ; + } + nBytesLeft -= nLenName; + + aAnsiName = ( const sal_Char * ) aName; + aAnsiName.Convert( eQuellChar, eZielChar ); + + if( GetRange( nLenExpr, nT, nCS, nCE, nRS, nRE ) ) + { + aDataPool.InsertEntry( aAnsiName, EET_NamedRange, + aTabNameBuff[ nT ], nT, nCS, nCE, nRS, nRE ); + } + + + pIn->SeekRel( 1 ); // cceDup ueberfluessig + nBytesLeft--; + }// ------------------------------------------Ende fuer Biff2 + else + {// --------------------------------------------------- Biff5 + sal_Char cZ; + BYTE nLenName, nLen; + UINT16 nOpt, nLenDef, nLenSeekRel = 0, nLauf; + SpString aName; // Bereichsname + String aAnsiName; + + *pIn >> nOpt; + pIn->SeekRel( 1 ); + *pIn >> nLenName >> nLenDef; + pIn->SeekRel( 4 ); + *pIn >> nLen; // length of custom menu text + nLenSeekRel += nLen; + *pIn >> nLen; // length of description text + nLenSeekRel += nLen; + *pIn >> nLen; // length of help topic text + nLenSeekRel += nLen; + *pIn >> nLen; // length of status bar text + nLenSeekRel += nLen; + nBytesLeft -= 14; + + // Namen einlesen + for( nLauf = 0 ; nLauf < nLenName ; nLauf++ ) + { + *pIn >> cZ; + aName += cZ; + } + nBytesLeft -= nLenName; + // jetzt steht Lesemarke an der Formel + + if( nOpt & 0x0020 ) + {// Build-in name + aAnsiName = pBuildInName[ ( const sal_Char* ) aName ]; + } + else + { + aAnsiName = ( const sal_Char * ) aName; + aAnsiName.Convert( eQuellChar, eZielChar ); + } + + if( GetRange( nLenDef, nT, nCS, nCE, nRS, nRE ) ) + { + aDataPool.InsertEntry( aAnsiName, EET_NamedRange, + aTabNameBuff[ nT ], nT, nCS, nCE, nRS, nRE ); + } + }// ----------------------------------------- Ende fuer Biff5 + } + +// ------------------------------------------------------------------ 0x1C +void SwExcelParser::Note() + { + } + +// ------------------------------------------------------------------ 0x1F +void SwExcelParser::Formatcount() + { + } + +// ------------------------------------------------------------------ 0x20 +void SwExcelParser::Columndefault() + {// Default Cell Attributes + } + +// ------------------------------------------------------------------ 0x21 +void SwExcelParser::Array25() + { + } + +// ------------------------------------------------------------------ 0x23 +void SwExcelParser::Externname25() + { + } +// ------------------------------------------------------------------ 0x25 +void SwExcelParser::Defrowheight2() + { + } +// ------------------------------------------------------------------ 0x56 +void SwExcelParser::Builtinfmtcnt() + { + } +// ------------------------------------------------------------------ 0x56 +void SwExcelParser::Builtinfmtcnt() + { + } + +// ------------------------------------------------------------------ 0x8C +void SwExcelParser::Country() + { + } + +// ------------------------------------------------------------------ 0x8E +void SwExcelParser::Bundlesoffset() + { + } + +// ------------------------------------------------------------------ 0x8F +void SwExcelParser::Bundleheader() + { + String aName; + + ReadExcString( LenByte, aName ); + + aName.Convert( eQuellChar, eZielChar ); + aTabNameBuff << aName; + +// aExcDok.Set( aName, nTab ); #################################### + nTab++; + } + +// ------------------------------------------------------------------ 0xBC +void SwExcelParser::Shrfmla() + { + } + +// -------------------------------------------------------- 0x0207 -> 0x07 +// ---------------------------------------------------------------- 0x0208 +void SwExcelParser::Row34() + { + } + +#endif + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/sw_excread.cxx b/binfilter/bf_sw/source/filter/excel/sw_excread.cxx new file mode 100644 index 000000000000..b0b47909d039 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/sw_excread.cxx @@ -0,0 +1,523 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#ifdef DBG_UTIL +#include <stdio.h> +#endif +#include <tools/debug.hxx> + +#include <fltglbls.hxx> +#include <exlpar.hxx> +#include <doc.hxx> +#include <docsh.hxx> + +#include <mdiexp.hxx> // ...Percent() +#include <statstr.hrc> // ResId fuer Statusleiste +namespace binfilter { + + + +// ---------------------------------------------- SwExcelParser::Parse() - +void SwExcelParser::Parse() + { + // Behelfsmaessig, nur zum Vorfuehren + // HP-Compiler kommt mit Identifier String nicht klar, + // ueberall zu ExcString geaendert. + enum Zustand { ScanType, ScanDim, Initials, GlobInitials34, + GlobInitials5, Eof5, Tab, Ende, ExcString }; + Zustand eAkt; + + USHORT nOpcode; // aktueller Opcode + USHORT nLaengeRec; // Laenge aktueller Record + ULONG nLastTab = 0; // Stream Position von letzter Tab + ULONG nLastPos = 0; // letzte Stream-Pos. vor Record + + pExcGlob->eHauptDateiTyp = ERT_Biff5; // ...wenn nicht genauer bestimmt + + // Laufbalken anzeigen + { + pIn->Seek(STREAM_SEEK_TO_END); + pIn->ResetError(); +// ::StartProgress( STR_STATSTR_W4WREAD, 0, pIn->Tell(), +// pExcGlob->pD->GetDocShell() ); + pIn->Seek(STREAM_SEEK_TO_BEGIN); + pIn->ResetError(); + } + + eAkt = ScanType; + while( eAkt != Ende ) + { + nLastPos = pIn->Tell(); +// if( eAkt != ScanDim ) +// ::binfilter::SetProgressState( pIn->Tell(), pExcGlob->pD->GetDocShell() ); + + *pIn >> nOpcode >> nLaengeRec; + nBytesLeft = nLaengeRec; + if( pIn->IsEof() ) eAkt = Ende; + + // Automat: Init -> [ Global ] -> TabBase -> Tab -> ... + switch( eAkt ) + { + // --------------------------------- ScanType ---------------- + case ScanType: + { + switch( nOpcode ) + { + case 0x09: // BOF [ 2 ] + Bof2(); + if( eDateiTyp == Biff2 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + pExcGlob->eHauptDateiTyp = ERT_Biff2; + } + else + eAkt = Ende; + break; + case 0x0209: // BOF [ 3 ] + Bof3(); + if( eDateiTyp == Biff3 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + pExcGlob->eHauptDateiTyp = ERT_Biff3; + } + else if( eDateiTyp == Biff3W ) + { + eAkt = GlobInitials34; + pExcGlob->eHauptDateiTyp = ERT_Biff3; + } + else + eAkt = Ende; + break; + case 0x0409: // BOF [ 4 ] + Bof4(); + if( eDateiTyp == Biff4 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + pExcGlob->eHauptDateiTyp = ERT_Biff4; + } + else if( eDateiTyp == Biff4W ) + { + eAkt = GlobInitials34; + pExcGlob->eHauptDateiTyp = ERT_Biff4; + } + else + eAkt = Ende; + break; + case 0x0809: // BOF [ 5] + Bof5(); + if( eDateiTyp == Biff5W ) + { + eAkt = GlobInitials5; + pExcGlob->eHauptDateiTyp = ERT_Biff5; + } + else + eAkt = Ende; + break; + case 0x0A: // EOF [ 2345] + Eof(); + eAkt = Ende; + break; + + } + } + break; + // --------------------------------- ScanDim ----------------- + case ScanDim: + { + switch( nOpcode ) + { + case 0x0A: // EOF [ 2345] + eAkt = Ende; // keine Dimension keine Kekse + break; + case 0x00: // DIMENSIONS [ 2 5] + case 0x0200: // DIMENSIONS [ 34 ] + Dimensions(); + eAkt = Initials; + pIn->Seek( nLastTab ); + nBytesLeft = 0; + break; + } + } + break; + // --------------------------------- Initials ---------------- + case Initials: + { + switch( nOpcode ) + { + case 0x01: + pExcGlob->CreateTable(); + Blank25(); + eAkt = Tab; + break; // BLANK [ 2 5] + case 0x03: + pExcGlob->CreateTable(); + Number25(); + eAkt = Tab; + break; // NUMBER [ 2 5] + case 0x04: + pExcGlob->CreateTable(); + Label25(); + eAkt = Tab; + break; // LABEL [ 2 5] + case 0x06: + pExcGlob->CreateTable(); + Formula25(); + eAkt = Tab; + break; // FORMULA [ 2 5] + case 0x0A: + Eof(); + eAkt = Ende; + break; // EOF [ 2345] + case 0x1E: Format235(); break; // FORMAT [ 23 5] +// case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ] + case 0x24: Colwidth(); break; // COLWIDTH [ 2 ] + case 0x31: Font25(); break; // FONT [ 2 5] + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x43: XF2(); break; // XF [ 2 ] + case 0x44: Ixfe(); break; // IXFE [ 2 ] + case 0x55: DefColWidth(); break; // DEFCOLWIDTH [ 2345] + case 0x7D: Colinfo(); break; // COLINFO [ 345] + case 0x7E: Rk(); eAkt = Tab; break;// RK [ 5] +// case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x92: Palette(); break; // PALETTE [ 345] + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 5] + case 0xBD: + pExcGlob->CreateTable(); + Mulrk(); + eAkt = Tab; + break; // MULRK [ 5] + case 0xBE: + pExcGlob->CreateTable(); + Mulblank(); + eAkt = Tab; + break; // MULBLANK [ 5] + case 0xD6: + pExcGlob->CreateTable(); + Rstring(); + eAkt = Tab; + break; // RSTRING [ 5] + case 0xE0: XF5(); break; // XF [ 5] + case 0x0201: + pExcGlob->CreateTable(); + Blank34(); + eAkt = Tab; + break; // BLANK [ 34 ] + case 0x0203: + pExcGlob->CreateTable(); + Number34(); + eAkt = Tab; + break; // NUMBER [ 34 ] + case 0x0204: + pExcGlob->CreateTable(); + Label34(); + eAkt = Tab; + break; // LABEL [ 34 ] + case 0x0206: + pExcGlob->CreateTable(); + Formula3(); + eAkt = Tab; + break; // FORMULA [ 3 ] + case 0x0231: Font34(); break; // FONT [ 34 ] + case 0x0243: XF3(); break; // XF [ 3 ] + case 0x027E: + pExcGlob->CreateTable(); + Rk(); + eAkt = Tab; + break; // RK [ 34 ] + case 0x0406: + pExcGlob->CreateTable(); + Formula4(); + eAkt = Tab; + break; // FORMULA [ 4 ] + case 0x041E: Format4(); break; // FORMAT [ 4 ] + case 0x0443: XF4(); break; // XF [ 4 ] + } + } + break; + // --------------------------------- GlobInitials34 ---------- + case GlobInitials34: + { + switch( nOpcode ) + { + case 0x09: // BOF [ 2 ] + Bof2(); + if( eDateiTyp == Biff2 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + } + else + eAkt = Ende; + break; + case 0x0A: // EOF [ 2345] + Eof(); + eAkt = Ende; + break; + case 0x1E: Format235(); break; // FORMAT [ 23 5] +// case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ] + case 0x24: Colwidth(); break; // COLWIDTH [ 2 ] + case 0x31: Font25(); break; // FONT [ 2 5] + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x43: XF2(); break; // XF [ 2 ] + case 0x44: Ixfe(); break; // IXFE [ 2 ] + case 0x55: DefColWidth(); break; // DEFCOLWIDTH [ 2345] + case 0x7D: Colinfo(); break; // COLINFO [ 345] +// case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x92: Palette(); break; // PALETTE [ 345] + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 5] + case 0x0209: // BOF [ 3 ] + Bof3(); + if( eDateiTyp == Biff3 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + } + else + eAkt = Ende; + break; + case 0x0231: Font34(); break; // FONT [ 34 ] + case 0x0243: XF3(); break; // XF [ 3 ] + case 0x041E: Format4(); break; // FORMAT [ 4 ] + case 0x0409: // BOF [ 4 ] + Bof4(); + if( eDateiTyp == Biff4 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + } + else + eAkt = Ende; + break; + case 0x0443: XF4(); break; // XF [ 4 ] + } + } + break; + // --------------------------------- GlobInitials5 ----------- + case GlobInitials5: + { + switch( nOpcode ) + { + case 0x0A: // EOF [ 2345] + Eof(); + eAkt = Eof5; + break; + case 0x1E: Format235(); break; // FORMAT [ 23 5] + case 0x31: Font25(); break; // FONT [ 2 5] + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x55: DefColWidth(); break; // DEFCOLWIDTH [ 2345] + case 0x7D: Colinfo(); break; // COLINFO [ 345] +// case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x92: Palette(); break; // PALETTE [ 345] + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 5] + case 0xE0: XF5(); break; // XF [ 5] + case 0x041E: Format4(); break; // FORMAT [ 4 ] + } + } + break; + // --------------------------------- Eof5 -------------------- + case Eof5: + { + switch( nOpcode ) + { + case 0x0809: // BOF [ 5] + Bof5(); + if( eDateiTyp == Biff5 ) + { + nLastTab = nLastPos; + eAkt = ScanDim; + } + break; + } + } + break; + // --------------------------------- Tab --------------------- + case Tab: + { + switch( nOpcode ) + { + case 0x01: + Blank25(); break; // BLANK [ 2 5] + case 0x03: Number25(); break; // NUMBER [ 2 5] + case 0x04: + Label25(); break; // LABEL [ 2 5] + case 0x06: // FORMULA [ 2 5] + Formula25(); + if( bResultString ) eAkt = ExcString; + break; + case 0x0A: // EOF [ 2345] + Eof(); + EndSheet(); + eAkt = Ende; + break; + case 0x7E: Rk(); break; // RK [ 5] + case 0xBD: Mulrk(); break; // MULRK [ 5] + case 0xBE: Mulblank(); break; // MULBLANK [ 5] + case 0xD6: Rstring(); break; // RSTRING [ 5] + case 0x0201: Blank34(); break; // BLANK [ 34 ] + case 0x0203: Number34(); break; // NUMBER [ 34 ] + case 0x0204: Label34(); break; // LABEL [ 34 ] + case 0x0206: // FORMULA [ 3 ] + Formula3(); + if( bResultString ) eAkt = ExcString; + break; + case 0x027E: Rk(); break; // RK [ 34 ] + case 0x0406: // FORMULA [ 4 ] + Formula4(); + if( bResultString ) eAkt = ExcString; + break; + } + } + break; + // ----------------------- Record String folgt --------------- + case ExcString: + { + DBG_ASSERT( nOpcode == 0x07 || nOpcode == 0x0207, + "+SwExcelParser::Parse(): Formatfehler: Formula ohne String" ); + + if( nOpcode == 0x07 || nOpcode == 0x0207 ) + REC_String(); + bResultString = FALSE; + eAkt = Tab; + } + break; + // ----------------------------------------------------------- + default: + DBG_ERROR( + "*SwExcelParser::Parse(): Zustand undefiniert - Trottel!" ); + } + pIn->SeekRel( nBytesLeft ); // nicht gelesene Bytes ueberlesen + } + + // Laufbalken wieder abschalten +// ::EndProgress( pExcGlob->pD->GetDocShell() ); + + } +/* +// ---------------------------------------------- SwExcelParser::Parse() - +void SwExcelParser::Parse() + { + ExcTabelle *pTab; + USHORT nOpcode; // aktueller Opcode + USHORT nLaengeRec; // Laenge aktueller Record + ULONG nLastBof = 0; // Stream Position vom letzten BOF + +// ScanDokuInfos(); + // jetzt ist aDataPool mit Daten zum importieren gefuellt + + + // BOF -> EOF => eine Tabelle + pTab = aExcDok.GetFirstTab(); + while( pTab ) + { + while( !pIn->IsEof() && eAktZust != ImpZustEnd ) + { + *pIn >> nOpcode >> nLaengeRec; + nBytesLeft = nLaengeRec; + + // Automat: Init -> [ Global ] -> TabBase -> Tab -> ... + switch( eAktZust ) + { + // ----------------------- Tabelleninhalt -------------------- + case ImpZustTab: + { + switch( nOpcode ) + { + case 0x01: Blank25(); break; // BLANK [ 2 5] + case 0x03: Number25(); break; // NUMBER [ 2 5] + case 0x04: Label25(); break; // LABEL [ 2 5] + case 0x06: Formula25(); break; // FORMULA [ 2 5] + case 0x08: Row25(); break; // ROW [ 2 5] + case 0x0A: // EOF [ 2345] + Eof(); + EndSheet(); + eAktZust = ImpZustEnd; + break; + case 0x1C: Note(); break; // NOTE [ 2345] + case 0x21: Array25(); break; // ARRAY [ 2 5] + case 0x7E: Rk(); break; // RK [ 5] + case 0xBD: Mulrk(); break; // MULRK [ 5] + case 0xBE: Mulblank(); break; // MULBLANK [ 5] + case 0xD6: Rstring(); break; // RSTRING [ 5] + case 0x0201: Blank34(); break; // BLANK [ 34 ] + case 0x0203: Number34(); break; // NUMBER [ 34 ] + case 0x0204: Label34(); break; // LABEL [ 34 ] + case 0x0206: Formula3(); break; // FORMULA [ 3 ] + case 0x0208: Row34(); break; // ROW [ 34 ] + case 0x0221: Array34(); break; // ARRAY [ 34 ] + case 0x027E: Rk(); break; // RK [ 34 ] + case 0x0406: Formula4(); break; // FORMULA [ 4 ] + case 0x04BC: Shrfmla(); break; // SHRFMLA [ 5] + } + } + break; + // ----------------------- Endzustand (nutzbar?) ------------- + case ImpZustEnd: + { + //switch( nOpcode ) + { + } + } + break; + // ----------------------- Record String folgt --------------- + case ImpZustString: + { + DBG_ASSERT( nOpcode == 0x07 || nOpcode == 0x0207, + "+SwExcelParser::Read(): Formatfehler: Formula ohne String" ); + + if( nOpcode == 0x07 || nOpcode == 0x0207 ) + REC_String(); + + eAktZust = ImpZustTab; + } + break; + // ----------------------- Tabelleninhalt Init-Phase --------- + // ----------------------------------------------------------- + default: + DBG_ERROR( + "*SwExcelParser::Read(): Zustand undefiniert - Trottel!" ); + } + pIn->SeekRel( nBytesLeft ); // nicht gelesene Bytes ueberlesen + } + pTab = aExcDok.GetNextTab(); + } + + } +*/ + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/sw_exctools.cxx b/binfilter/bf_sw/source/filter/excel/sw_exctools.cxx new file mode 100644 index 000000000000..6e85839caca4 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/sw_exctools.cxx @@ -0,0 +1,1903 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER +#include "hintids.hxx" + +#include <bf_svx/boxitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/colritem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/cntritem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/adjitem.hxx> +#include <bf_svtools/zforlist.hxx> + +#include <fmtfsize.hxx> +#include <swtblfmt.hxx> +#include <node.hxx> +#include "doc.hxx" +#include "pam.hxx" +#include "swtypes.hxx" +#include "swtable.hxx" +#include "fltglbls.hxx" +#include "exccrts.hxx" +#include "excxfbuf.hxx" +#include "excfntbf.hxx" +#include "excdocum.hxx" +#include "excvfbff.hxx" +#include "fltini.hxx" +namespace binfilter { + + +// -------------------------------------------------- FltColumn::statics - +const UINT16 FltColumn::nDefSize = 128; +//const UINT16 FltColumn::nLevelSize = ( UINT16 ) ( 0.9 * MAXROW ); +const UINT16 FltColumn::nLevelSize = ( UINT16 ) ( 0.9 * 8191 ); +UINT32 FltColumn::nDefCleared = 0xFFFFFFFFL; +UINT16 FltColumn::nTab; + + + + +#ifdef USED +// ------------------------------------------------------ class SpString - +// Kopiert aus: spstring.cxx + +// ---------------------------------------- SpString::SpString( UINT16 ) - +SpString::SpString( UINT16 nInitSize ) + { + nSize = nInitSize; + pData = new sal_Char[ nSize ]; + pLimit = pData + nSize; + Clear(); // pNullTerm auf Anfang und mit Nullbyte abschliessen + } + +// ----------------------------------------------- SpString::~SpString() - +SpString::~SpString() + { + delete[] pData; + } + +// ------------------------------- SpString::operator +=( const sal_Char * ) - +void SpString::operator +=( const sal_Char *pCString ) + { + // PREC: pCString = Pointer auf C-String + // POST: C-String wird an Inhalt in pData angehaengt + while( *pCString != 0 ) + { + if( pNullTerm < pLimit ) + *( pNullTerm++ ) = *( pCString++ ); + else + Grow(); + } + + if( pNullTerm >= pLimit ) Grow(); + + *pNullTerm = 0; + } + +// --------------------------------- SpString::operator +=( const sal_Char ) - +void SpString::operator +=( const sal_Char cChar ) + { + // POST: cChar wird an Inhalt in pData angehaengt, ausser cChar ist 0 + if( pNullTerm + 2 >= pLimit ) // noch Platz fuer Charakter + Grow(); + if( cChar != 0 ) + *( pNullTerm++ ) = cChar; + + *pNullTerm = 0; + } + +// ------------------------------------------------- SpString::ExcScName - +void SpString::MakeScName() + { + // POST: ersetzt alle Zeichen <> {[a..z],[A..Z],[0..9],ä,Ä,ö,Ö,ü,Ü,ß} + // durch '_' (kann man sicher schneller implementieren) + //PLATTFORMABHAENGIG// + sal_Char *pAkt; + register cAkt; + for( pAkt = pData ; pAkt < pNullTerm ; pAkt++ ) + { + cAkt = *pAkt; + if( ( cAkt < 'a' || cAkt > 'z' ) && + ( cAkt < 'A' || cAkt > 'Z' ) && + ( cAkt < '0' || cAkt > '9' ) && + cAkt != '\xE4' && cAkt != '\xC4' && cAkt != '\xF6' && cAkt != '\xD6' && + cAkt != '\xFC' && cAkt != '\xDC' && cAkt != '\xDF' ) + { + *pAkt = '_'; + } + } + } + +// ---------------------------------------------------- SpString::Grow() - +void SpString::Grow() + { + // PREC: Verdoppelt die Groesse des pData-Arrays + sal_Char *pNewData; + register sal_Char *pFrom, *pTo; + + nSize *= 2; + pNewData = new sal_Char[ nSize ]; + + for( pFrom = pData, pTo = pNewData ; pFrom < pLimit ; pFrom++, pTo++ ) + *pTo = *pFrom; + pNullTerm = pNullTerm - pData + pNewData; + delete[] pData; + pData = pNewData; + pLimit = pData + nSize; + } + +// -------------------------------------------- SpString::Grow( UINT16 ) - +void SpString::Grow( UINT16 nNewSize ) + { + // PREC: Verdoppelt die Groesse des pData-Arrays + sal_Char *pNewData; + register sal_Char *pFrom, *pTo; + + if( nNewSize > nSize ) + nSize = nNewSize; + + pNewData = new sal_Char[ nSize ]; + + for( pFrom = pData, pTo = pNewData ; pFrom <= pNullTerm ; pFrom++, pTo++ ) + *pTo = *pFrom; + pNullTerm = pNullTerm - pData + pNewData; + delete[] pData; + pData = pNewData; + pLimit = pData + nSize; + } + +// ------------------------------------------------- SpString::Convert() - +SpString &SpString::Convert( CharSet eSource, CharSet eTarget ) + { + register const sal_Char *pCString; + register sal_Char *pTempNullTerm; + register sal_Char cAkt; + + String aTempString( pData ); + aTempString.Convert( eSource, eTarget ); + + // String jetzt groesser? + if( ( INT32 ) ( pNullTerm - pData ) < ( INT32 ) aTempString.Len() ) + Grow( aTempString.Len() + 2 ); + + pTempNullTerm = pNullTerm = pData; // String loeschen + *pTempNullTerm = 0; + + pCString = ( const sal_Char * ) aTempString; + + do { + cAkt = *( pCString++ ); + *( pTempNullTerm++ ) = cAkt; + } + while( cAkt != 0x00 ); + pTempNullTerm--; + pNullTerm = pTempNullTerm; + + return *this; + } + +// -------------------------------------------------- SpString::Shrink() - +void SpString::Shrink() + { + } + +#endif + // used + + +#ifdef USED +// --------------------------------------------------- class ExcDataPool - + +// ------------------------------------------ ExcDataPool::ExcDataPool() - +ExcDataPool::ExcDataPool() + { + pUiBack = NULL; + } + +// ----------------------------------------- ExcDataPool::~ExcDataPool() - +ExcDataPool::~ExcDataPool() + { + if( pUiBack ) delete pUiBack; + } + +// --------------------------------------- ExcDataPool::InsertEntry(...) - +void ExcDataPool::InsertEntry( const String &rName, ExcEntryType eType, + const String &rTabName, UINT16 nTab, UINT16 nCS, UINT16 nCE, + UINT16 nRS, UINT16 nRE/*, UINT32 nStrPos*/ ) + { + ExcUiEntry aNew; + + aNew.aName = rName; + aNew.aTabName = rTabName; + aNew.nTab = nTab; + aNew.nColStart = nCS; + aNew.nColEnd = nCE; + aNew.nRowStart = nRS; + aNew.nRowEnd = nRE; + aNew.eType = eType; + //aNew.nStrPos = nStrPos; + + aInit.Insert( aNew ); + } + +// ---------------------------------- ExcDataPool::GetNextSelection(...) - +BOOL ExcDataPool::GetNextSelection( String &rName, UINT16 &rTab, + UINT16 &rCS,UINT16 &rCE, UINT16 &rRS, UINT16 &rRE/*, UINT32 &rStrPos*/ ) + { + // POST: wenn pUiBack == NULL: Dlg starten und erste Selektion + // zurueckliefern + // sonst Daten aus naechsten in UiBack-Liste + // return = TRUE, wenn Daten gefunden + // = FALSE, sonst + const ExcUiEntry *pNext; + if( pUiBack ) + {// n-ter Aufruf + pNext = pUiBack->GetNext(); + } + else + {// erster Aufruf + pUiBack = new ExcUiList; + // Dialog-Aufruf + // Dlg( const ExcUiList &rInit, ExcUiList &rUiBack ); + pNext = pUiBack->GetFirst(); + } + + if( pNext ) + { + rName = pNext->aName; + rTab = pNext->nTab; + rCS = pNext->nColStart; + rCE = pNext->nColEnd; + rRS = pNext->nRowStart; + rRE = pNext->nRowEnd; + //rStrPos = pNext->nStrPos; + } + + return ( pNext != NULL ); + } + +// ----------------------- ExcDataPool::operator<<( const ExcDokument& ) - +ExcDataPool &ExcDataPool::operator<<( ExcDokument &rExcDok ) + { + UINT16 nCS, nCE, nRS, nRE, nTab; + const ExcTabelle *pAktTab = rExcDok.GetFirstTab(); + + nTab = 0; + + while( pAktTab ) + { + pAktTab->GetRange( nCS, nCE, nRS, nRE ); + + InsertEntry( pAktTab->GetName(), EET_Table, pAktTab->GetName(), + nTab, nCS, nCE, nRS, nRE ); + + nTab++; + } + + return *this; + } + + +#endif // #ifdef USED + +// ------------------------------------------------ class ColRowSettings - +// +// Kopiert aus: colrowst.cxx + + +// -------------------------------------- ColRowSettings::ColRowSettings - +ColRowSettings::ColRowSettings() + { + nColLimit = 256; + nRowLimit = 8192; + + nDefWidth = nDefHeight = 0; + + pWidth = new INT32 [ nColLimit ]; + pHeight = new INT32 [ nRowLimit ]; + pColHidden = new BOOL [ nColLimit ]; + pRowHidden = new BOOL [ nRowLimit ]; + pColUsed = new BOOL [ nColLimit ]; + pRowUsed = new BOOL [ nRowLimit ]; + + NewTab( 0 ); + } + +// ------------------------------------- ColRowSettings::~ColRowSettings - +ColRowSettings::~ColRowSettings() + { + delete[] pWidth; + delete[] pHeight; + delete[] pColHidden; + delete[] pRowHidden; + delete[] pColUsed; + delete[] pRowUsed; + } + +// ---------------------------------------------- ColRowSettings::NewTab - +void ColRowSettings::NewTab( UINT16 nNew ) + { + UINT16 nC; + nAktTab = nNew; + + // FALSE / -1 ist Default + for( nC = 0 ; nC < nColLimit ; nC++ ) + { + pColHidden[ nC ] = pColUsed[ nC ] = FALSE; + pWidth[ nC ] = -1; + } + for( nC = 0 ; nC < nRowLimit ; nC++ ) + { + pRowHidden[ nC ] = pRowUsed[ nC ] = FALSE; + pHeight[ nC ] = -1; + } + } + +// ----------------------------------------------- ColRowSettings::Apply - +void ColRowSettings::Apply() + { + UINT16 nC, nAnzCols, nAnzRows; + UINT32 nWidthSum; + double fFaktor; + + SwFmtFrmSize aSize( ATT_FIX_SIZE, nDefWidth ); + + // Column-Bemachung + nAnzCols = pExcGlob->AnzCols(); + nAnzRows = pExcGlob->AnzRows(); + nWidthSum = 0; + for( nC = 0 ; nC < nAnzCols ; nC++ ) + { + if( pWidth[ nC ] < 0 ) + pWidth[ nC ] = nDefWidth; + else if( pWidth[ nC ] < MINLAY ) + pWidth[ nC ] = MINLAY; + + nWidthSum += pWidth[ nC ]; + } + fFaktor = 65535.0 / ( double ) nWidthSum; + + for( nC = 0 ; nC < nAnzCols ; nC++ ) + { + aSize.SetWidth( ( UINT16 ) ( fFaktor * ( double ) pWidth[ nC ] ) ); + SwTableBox *pTBox = pExcGlob->pTable->GetTabLines()[ 0 ]->GetTabBoxes()[ nC ]; + SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)pTBox->ClaimFrmFmt(); // Frm-Format eindeutig + pBoxFmt->SetAttr( aSize ); + for( UINT16 nRow = 1 ; nRow < nAnzRows ; nRow++ ) + pExcGlob->pTable->GetTabLines()[ nRow ]-> + GetTabBoxes()[ nC ]->ChgFrmFmt( pBoxFmt ); + } + } + + +#ifdef USED +// ---------------------------------------- ColRowSettings::HideColRange - +void ColRowSettings::HideColRange( UINT16 nColFirst, UINT16 nColLast ) + { + DBG_ASSERT( nColFirst <= nColLast, + "+ColRowSettings::HideColRange(): First > Last?!" ); + } + +// ---------------------------------------- ColRowSettings::HideRowRange - +void ColRowSettings::HideRowRange( UINT16 nRowFirst, UINT16 nRowLast ) + { + DBG_ASSERT( nRowFirst <= nRowLast, + "+RowRowSettings::HideRowRange(): First > Last?!" ); + } +#endif + + +// ------------------------------------ ColRowSettings::SetColWidthRange - +void ColRowSettings::SetWidthRange( UINT16 nColFirst, UINT16 nColLast, + UINT16 nNew ) + { + DBG_ASSERT( nColFirst <= nColLast, + "-ColRowSettings::SetColWidthRange(): First > Last?!" ); + + if( pExcGlob->ColRangeLimitter( nColFirst, nColLast ) ) + { + pExcGlob->NormalizeCol( nColFirst ); + pExcGlob->NormalizeCol( nColLast ); + + register BOOL *pUsed; + register INT32 *pWidthCount, *pFinish; + pWidthCount = &pWidth[ nColFirst ]; + pFinish = &pWidth[ nColLast ]; + pUsed = &pColUsed[ nColFirst ]; + while( pWidthCount <= pFinish ) + { + *( pUsed++ ) = TRUE; + *( pWidthCount++ ) = nNew; + } + } + } + +// -- class FltColumn ---------------------------------------------------- + +// ------------------------------------------------ FltColumn::FltColumn - +FltColumn::FltColumn( UINT16 nNewCol ) + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + pData = new UINT16[ nDefSize ]; + nSize = nDefSize; + nCol = nNewCol; + nLastRow = nSize - 1; // wird in Reset zurueckgesetzt + Reset(); + } + + +#ifdef USED +// ------------------------------------------------ FltColumn::FltColumn - +FltColumn::FltColumn( UINT16 nNewCol, UINT16 nNewSize ) + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + DBG_ASSERT( nNewSize > 0, + "-FltColumn::Ctor: NewSize == 0! VERBOTEN - WEIL TOEDLICH!" ); + nNewSize += 1; + nNewSize &= 0xFFFE; + // jetzt ist nNewSize' mod 2 = 0 und nNewSize' >= nNewSize + nSize = nNewSize; + pData = new UINT16[ nSize ]; + nCol = nNewCol; + nLastRow = nSize - 1; // wird in Reset zurueckgesetzt + Reset(); + } + +// ------------------------------------------ FltColumn::Reset( UINT16 ) - +void FltColumn::Reset( UINT16 nNewTab ) + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + nTab = nNewTab; + Reset(); + } +#endif + + +// -------------------------------------------------- FltColumn::Reset() - +void FltColumn::Reset() + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + UINT16 nClear = ( UINT16 ) nDefCleared; + + for( UINT16 nC = 0 ; nC <= nLastRow ; nC++ ) + pData[ nC ] = nClear; + } + +// ----------------------------------------------------- FltColumn::Grow - +void FltColumn::Grow( UINT16 nRecIndex ) + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + // PREC: nRecIndex: Index, der noch in das neue Array passen soll + + DBG_ASSERT( nRecIndex >= nSize, + "-FltColumn::Grow(): geforderte Groesse <= alte Groesse" ); + + UINT16 nNewSize; + + if( nRecIndex >= nLevelSize ) +// nNewSize = MAXROW + 1; + nNewSize = 8191 + 1; + else + { + nRecIndex++; + // ab hier ist RecIndex gleichbedeutend mit RecSize + nNewSize = nSize * 2; // neue Groesse bestimmen + // Test auf Peak + if( nRecIndex > nNewSize ) + {// grosser Index -> nicht wesentlich groesser werden als Index + nRecIndex += 5; // 4 groesser, 1 fuer gerades nSize + nNewSize = nRecIndex & 0xFFFE; + } + } + + // jetzt kommt erst das Growen + UINT16 *pNewData; + pNewData = new UINT16[ nNewSize ]; + + {// alte Daten kopieren, neue resetten ---------------- + // nSize -> nLastRow + 1 + //register UINT16 nCount = nSize / 2; + register UINT16 nCount = ( nLastRow + 1 ) / 2; + register UINT32 *pWrite = ( UINT32 * ) pNewData; + {// ----------- + register const UINT32 *pRead = ( UINT32 * ) pData; // kopieren + do { + *( pWrite++ ) = *( pRead++ ); + } + while( --nCount > 0 ); // + }// ----------- + {// ----------- + //nCount = ( nNewSize - nSize ) / 2; // resetten + nCount = ( nNewSize - nLastRow - 1 ) / 2; + register UINT32 nCleared = nDefCleared; + do { + *( pWrite++ ) = nCleared; + } + while( --nCount > 0 ); // + }// ----------- + }// ---------------- + + nSize = nNewSize; + pData = pNewData; + } + +// ------------------------------------------------ FltColumn::Apply_int - +void FltColumn::Apply() + { + // ACHTUNG: interne Nutzung von SW-KOORDINATEN + UINT16 nCount, nAnzRows; + UINT16 nLastXF, nAktXF, nLastCount; + + nLastCount = 0; + nLastXF = pData[ nLastCount ]; + + nAnzRows = pExcGlob->AnzRows(); + for( nCount = 1 ; nCount < nAnzRows ; nCount++ ) + { + nAktXF = pData[ nCount ]; + if( nAktXF != nLastXF ) + { + if( nLastXF != ( UINT16 ) nDefCleared ) + { + pExcGlob->pXF_Buff->SetItemSets( + nCol, nLastCount, nCount - 1, nLastXF ); + } + nLastCount = nCount; + nLastXF = nAktXF; + } + } + // ...und den Rest applyen + if( nLastXF != ( UINT16 ) nDefCleared ) + { +// pD->ApplyPatternAreaTab( nCol, nLastCount, nCol, nCount - 1, nTab, +// pXF_Buff->GetPattern( nLastXF ) ); + pExcGlob->pXF_Buff->SetItemSets( + nCol, nLastCount, nCount - 1, nLastXF ); + } + } + +// -- class FltTabelle --------------------------------------------------- + +// ---------------------------------------------- FltTabelle::FltTabelle - +FltTabelle::FltTabelle() + { + Settings( 0 ); + } + +// --------------------------------------------- FltTabelle::~FltTabelle - +FltTabelle::~FltTabelle() + { + FltColumn **pDel = pData; + for( UINT16 nC = 0 ; nC <= nLastCol ; nC++, pDel++ ) + if( *pDel ) delete *pDel; + } + +// ------------------------------------------------ FltTabelle::Settings - +void FltTabelle::Settings( UINT16 nTab ) + { + nSize = 8191 + 1; + nLastCol = 0; + pData = new FltColumn *[ nSize ]; + + pData[ 0 ] = new FltColumn( 0 ); // Column 0 gibt's per Default + pData[ 0 ]->Settings( nTab ); + + for( UINT16 nC = 1 ; nC < nSize ; nC++ ) pData[ nC ] = NULL; + } + +// --------------------------------------------------- FltTabelle::SetXF - +void FltTabelle::SetXF( UINT16 nCol, UINT16 nRow, UINT16 nNewXF ) + { + // nCol / nRow : Excel-Koordinaten -> SW-Koordinaten + if( pExcGlob->IsInRange( nCol, nRow ) ) + { + pExcGlob->Normalize( nCol, nRow ); + if( !pData[ nCol ] ) + { + pData[ nCol ] = new FltColumn( nCol ); + if( nCol > nLastCol ) nLastCol = nCol; + } + pData[ nCol ]->SetXF( nRow, nNewXF ); + } + } + + +#ifdef USED +// --------------------------------------------------- FltTabelle::Reset - +void FltTabelle::Reset( UINT16 nTab ) + { + for( UINT16 nC = 0 ; nC <= nLastCol ; nC++ ) + if( pData[ nC ] ) pData[ nC ]->Reset(); + pData[ 0 ]->SetTab( nTab ); + } +#endif + + +// --------------------------------------------------- FltTabelle::Apply - +void FltTabelle::Apply() + { + for( UINT16 nC = 0 ; nC < pExcGlob->AnzCols() ; nC++ ) + if( pData[ nC ] ) pData[ nC ]->Apply(); + } + + +// -- class XF_Data ------------------------------------------------------ +// +// -------------------------------------------------- XF_Data::XF_Data() - +XF_Data::XF_Data() + { + pFill = NULL; + pBord = NULL; + + bFontValid = FALSE; + bFormValid = FALSE; + + nParent = nFont = 0; + eHoriz = EHA_Parent; + } + +// ------------------------------------------------- XF_Data::~XF_Data() - +XF_Data::~XF_Data() + { + if( pFill != NULL ) delete pFill; + if( pBord != NULL ) delete pBord; + } + +// ----------------------------- XF_Data::SetBorder( const CellBorder& ) - +void XF_Data::SetBorder( const CellBorder &rNew ) + { + if( pBord == NULL ) pBord = new CellBorder; + DBG_ASSERT( pBord != NULL, + "-XF_Data::SetBorder(): pBord == NULL!" ); + pBord->nTopLine = rNew.nTopLine; + pBord->nLeftLine = rNew.nLeftLine; + pBord->nBottomLine = rNew.nBottomLine; + pBord->nRightLine = rNew.nRightLine; + pBord->nTopColor = rNew.nTopColor; + pBord->nLeftColor = rNew.nLeftColor; + pBord->nBottomColor = rNew.nBottomColor; + pBord->nRightColor = rNew.nRightColor; + } + +#if 0 +// ------------------------- XF_Data::SetBorder( BYTE, BYTE, BYTE,... ) - +void XF_Data::SetBorder( BYTE nTopLine, BYTE nLeftLine, BYTE nBottomLine, + BYTE nRightLine, UINT16 nTopColor, UINT16 nLeftColor, + UINT16 nBottomColor, UINT16 nRightColor ) + { + if( pBord == NULL ) pBord = new CellBorder; + DBG_ASSERT( pBord != NULL, + "-XF_Data::SetBorder(): pBord == NULL!" ); + pBord->nTopLine = nTopLine; + pBord->nLeftLine = nLeftLine; + pBord->nBottomLine = nBottomLine; + pBord->nRightLine = nRightLine; + pBord->nTopColor = nTopColor; + pBord->nLeftColor = nLeftColor; + pBord->nBottomColor = nBottomColor; + pBord->nRightColor = nRightColor; + } +#endif + +// -- class XF_Buffer ---------------------------------------------------- +// +// Kopiert aus: xfbuff.cxx + +// ------------------------------------------------ XF_Buffer::XF_Buffer - +XF_Buffer::XF_Buffer( UINT16 nNewMax ) + {// default: 4K Pattern + nMax = nNewMax; + nCount = 0; + + ppTxtAttr = new SfxItemSet *[ nNewMax ]; + ppBoxAttr = new SfxItemSet *[ nNewMax ]; + + ppData = new XF_Data *[ nNewMax ]; + + pDefaultData = new XF_Data; + + pDefTxtAttr = new SfxItemSet( pExcGlob->pD->GetAttrPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END - 1 ); + pDefBoxAttr = new SfxItemSet( pExcGlob->pD->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END - 1 ); + + // alle NULL + for( UINT16 nC = 0 ; nC < nMax ; nC++ ) + { + ppTxtAttr[ nC ] = NULL; + ppBoxAttr[ nC ] = NULL; + ppData[ nC ] = NULL; + } + } + +// ----------------------------------------------- XF_Buffer::~XF_Buffer - +XF_Buffer::~XF_Buffer() + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + { + if( ppTxtAttr[ nC ] != NULL ) + { + delete ppTxtAttr[ nC ]; + delete ppBoxAttr[ nC ]; + } + if( ppData[ nC ] != NULL ) delete ppData[ nC ]; + } + + delete[] ppData; + delete[] ppTxtAttr; + delete[] ppBoxAttr; + delete pDefaultData; + delete pDefTxtAttr; + delete pDefBoxAttr; + } + +// ---------------------------------------- XF_Buffer::ExcToSwBorderLine - +void XF_Buffer::ExcToSwBorderLine( BYTE nLine, UINT16 nColor, + SvxBorderLine *&rpBorderLine ) + { + // POST: rpBorderLine = NULL, wenn nLine == 0 + // eine Linie, sonst + if( nLine == 0 ) + { + rpBorderLine = NULL; + return; + } + + DBG_ASSERT( nLine < 8, + "+XF_Buffer::ExcToSwBorderLine(): Line-# groesser als 7!?" ); + + const static UINT16 nPara[ 8 ][ 3 ] = { + // OutWidth, InWidth, Distance + { 0, 0, 0 }, // (0) + { DEF_LINE_WIDTH_1, 0, 0 }, // 1, duenn + { DEF_LINE_WIDTH_2, 0, 0 }, // 2, mittel + { DEF_LINE_WIDTH_1, 0, 0 }, // 3, gestrichelt lang + { DEF_LINE_WIDTH_0, 0, 0 }, // 4, gestrichelt kurz + { DEF_LINE_WIDTH_3, 0, 0 }, // 5, dick + { DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1, + DEF_LINE_WIDTH_1 }, // 6, doppelt + { DEF_LINE_WIDTH_0, 0, 0 } }; // 7, gepunktet + + rpBorderLine = new SvxBorderLine; // ACHTUNG: delete im Caller!!!!!! + + rpBorderLine->SetColor( + ( *pExcGlob->pColorBuff->GetColor( nColor ) ).GetValue() ); + + if( nLine < 8 ) + { + rpBorderLine->SetOutWidth( nPara[ nLine ][ 0 ] ); + rpBorderLine->SetInWidth( nPara[ nLine ][ 1 ] ); + rpBorderLine->SetDistance( nPara[ nLine ][ 2 ] ); + } + } + + +#ifdef USED +// ---------------------------------------------------- XF_Buffer::Reset - +void XF_Buffer::Reset() + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + if( ppTxtAttr[ nC ] != NULL ) + { + delete ppTxtAttr[ nC ]; + delete ppBoxAttr[ nC ]; + } + + nCount = 0; + } +#endif + + +// ------------------------------------------- XF_Buffer::CreateItemSets - +void XF_Buffer::CreateItemSets( UINT16 nIndex ) + { + XF_Data *pD;//, *pP; // Pointer auf eigene und Parent-Daten + SfxItemSet *pTxtAttr, *pBoxAttr; + + DBG_ASSERT( nIndex < nCount, + "+XF_Buffer::CreatePattern(): XF nicht im Puffer!" ); + + if( nIndex >= nMax ) + { + pTxtAttr = pDefTxtAttr; // Defaults + pBoxAttr = pDefBoxAttr; + return; + } + + DBG_ASSERT( ppData[ nIndex ] != NULL, + "-XF_Buffer::CreatePattern(): Wiiiiiiiiiiiiiie bitte?!" ); + + pTxtAttr = new SfxItemSet( pExcGlob->pD->GetAttrPool(), + RES_CHRATR_BEGIN, RES_PARATR_ADJUST ); + pBoxAttr = new SfxItemSet( pExcGlob->pD->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END - 1 ); + pD = ppData[ nIndex ]; + ppTxtAttr[ nIndex ] = pTxtAttr; + ppBoxAttr[ nIndex ] = pBoxAttr; + +// DBG_ASSERT( pD->Parent() < nCount, +// "+XF_Buffer::CreatePattern(): Parent-XF nicht im Puffer!" ); +// if( pD->Parent() < nCount ) +// pP = ppData[ pD->Parent() ]; +// else +// pP = pDefaultData; + + DBG_ASSERT( pD->IsCellXF(), + "+XF_Buffer::CreatePattern(): Und was soll ich mit 'nem Style?" ); + if( !pD->IsCellXF() ) + { + pTxtAttr = pDefTxtAttr; // Defaults + pBoxAttr = pDefBoxAttr; + return; + } + + // Font --------------------------------------------------------- + const ExcFont *pFont; + +// if( pD->HasFont() ) + pFont = &pExcGlob->pFontBuff->GetFont( pD->Font() ); +// else +// pFont = &pExcGlob->pFontBuff->GetFont( pP->Font() ); + + pTxtAttr->Put( *pFont->pFont ); + pTxtAttr->Put( *pFont->pHeight ); + pTxtAttr->Put( *pExcGlob->pColorBuff->GetColor( pFont->nColor ) ); + + if( pFont->nWeight ) + {// bold + SvxWeightItem aWeightItem( WEIGHT_BOLD ); + register UINT16 nWeight = pFont->nWeight; + if( !nWeight ) + aWeightItem = WEIGHT_DONTKNOW; + else if( nWeight < 150 ) + aWeightItem = WEIGHT_THIN; + else if( nWeight < 250 ) + aWeightItem = WEIGHT_ULTRALIGHT; + else if( nWeight < 325 ) + aWeightItem = WEIGHT_LIGHT; + else if( nWeight < 375 ) + aWeightItem = WEIGHT_SEMILIGHT; + else if( nWeight < 450 ) + aWeightItem = WEIGHT_NORMAL; + else if( nWeight < 550 ) + aWeightItem = WEIGHT_MEDIUM; + else if( nWeight < 650 ) + aWeightItem = WEIGHT_SEMIBOLD; + else if( nWeight < 750 ) + aWeightItem = WEIGHT_BOLD; + else if( nWeight < 850 ) + aWeightItem = WEIGHT_ULTRABOLD; + else + aWeightItem = WEIGHT_BLACK; + pTxtAttr->Put( aWeightItem ); + } + + if( pFont->bItalic ) + {// italic + SvxPostureItem aAttr( ITALIC_NORMAL ); + pTxtAttr->Put( aAttr ); + } + + switch( pFont->eUnderline ) + { + case EXCUNDER_Single: + { + SvxUnderlineItem aAttr( UNDERLINE_SINGLE ); + pTxtAttr->Put( aAttr ); + } + break; + case EXCUNDER_Double: + { + SvxUnderlineItem aAttr( UNDERLINE_DOUBLE ); + pTxtAttr->Put( aAttr ); + } + break; + case EXCUNDER_SingleAccount: + { + SvxUnderlineItem aAttr( UNDERLINE_DOTTED ); + pTxtAttr->Put( aAttr ); + } + break; + case EXCUNDER_DoubleAccount: + { + SvxUnderlineItem aAttr( UNDERLINE_DOTTED ); + pTxtAttr->Put( aAttr ); + } + break; + } + +/* FOR FUTURE USE + switch( pFont->eScript ) + { + case EXCSCR_Super: + break; + case EXCSCR_Sub: + break; + } +*/ + if( pFont->bStrikeout ) + {// strikeout + SvxCrossedOutItem aAttr( STRIKEOUT_SINGLE ); + pTxtAttr->Put( aAttr ); + } + + if( pFont->bOutline ) + {// outline + SvxContourItem aAttr( TRUE ); + pTxtAttr->Put( aAttr ); + } + + if( pFont->bShadow ) + {// shadow + SvxShadowedItem aAttr( TRUE ); + pTxtAttr->Put( aAttr ); + } + + // Bordereinstellungen ------------------------------------------ + const CellBorder *pBorder; + +// if( pD->HasBorder() ) + pBorder = pD->Border(); +// else +// pBorder = pP->Border(); + + if( pBorder ) + { + SvxBoxItem aBox; + SvxBorderLine *pTop, *pLeft, *pBottom, *pRight; + + ExcToSwBorderLine( pBorder->nTopLine, pBorder->nTopColor, pTop ); + ExcToSwBorderLine( pBorder->nLeftLine, pBorder->nLeftColor, pLeft ); + ExcToSwBorderLine( pBorder->nBottomLine, pBorder->nBottomColor, + pBottom ); + ExcToSwBorderLine( pBorder->nRightLine, pBorder->nRightColor, pRight ); + + aBox.SetLine( pTop, BOX_LINE_TOP ); + aBox.SetLine( pLeft, BOX_LINE_LEFT ); + aBox.SetLine( pBottom, BOX_LINE_BOTTOM ); + aBox.SetLine( pRight, BOX_LINE_RIGHT ); + aBox.SetDistance( MIN_BORDER_DIST ); + + pBoxAttr->Put( aBox ); + delete pTop; + delete pLeft; + delete pBottom; + delete pRight; + } + + // Hintergrund- / Fill-Einstellungen ---------------------------- + const CellFill *pFill; + +// if( pD->HasFill() ) + pFill = pD->Fill(); +// else +// pFill = pP->Fill(); + + if( pFill ) + { + const static BYTE eStyle[ 19 ] = { // Exc-# + SW_SV_BRUSH_NULL, SW_SV_BRUSH_SOLID, SW_SV_BRUSH_50, SW_SV_BRUSH_75, // 00-03 + SW_SV_BRUSH_25, SW_SV_BRUSH_INVALID,SW_SV_BRUSH_INVALID,SW_SV_BRUSH_INVALID, // 04-07 + SW_SV_BRUSH_INVALID,SW_SV_BRUSH_50, SW_SV_BRUSH_75, SW_SV_BRUSH_INVALID, // 08-0B + SW_SV_BRUSH_INVALID,SW_SV_BRUSH_INVALID,SW_SV_BRUSH_INVALID,SW_SV_BRUSH_INVALID, // 0C-0F + SW_SV_BRUSH_50, SW_SV_BRUSH_25, SW_SV_BRUSH_25 }; // 10-12 + + // !kein Hintergrund -> set nothing! + if( pFill->nPattern != 0 ) + { + Color aBack( + ( *pExcGlob->pColorBuff->GetColor( pFill->nBackColor ) ).GetValue() ); + + if( pExcGlob->pColorBuff->Auto() ) // Auto-Color fuer Background? + aBack = COL_WHITE; + + Color aColor((*pExcGlob->pColorBuff->GetColor( pFill->nForeColor ) ).GetValue()); + + if( pFill->nPattern < 19 ) + aColor = ConvertBrushStyle(aColor, aBack, eStyle[ pFill->nPattern ] ); + + pBoxAttr->Put( SvxBrushItem( aColor ) ); + } + } + + // Ausrichtungsattribute ---------------------------------------- + ExcHorizAlign eHorizAlign; + +// if( pD->HasHorizAlign() ) + eHorizAlign = pD->HorizAlign(); +// else +// eHorizAlign = pP->HorizAlign(); + + SvxAdjust eAdjust = SVX_ADJUST_LEFT; + + switch( eHorizAlign ) + { +// case EHA_Parent: +// case EHA_General: +// eAdjust = SVX_ADJUST_LEFT; +// break; +// case EHA_Left: +// eAdjust = SVX_ADJUST_LEFT; +// break; + case EHA_Center: + eAdjust = SVX_ADJUST_CENTER; + break; + case EHA_Right: + eAdjust = SVX_ADJUST_RIGHT; + break; +// case EHA_Fill: +// eAdjust = SVX_ADJUST_LEFT; +// break; + case EHA_Justify: + eAdjust = SVX_ADJUST_BLOCK; + break; +// case EHA_CentAcrSel: +// eAdjust = SVX_ADJUST_LEFT; +// break; + } + pTxtAttr->Put( SvxAdjustItem( eAdjust ) ); + } + +// ---------------------------------------------- XF_Buffer::SetItemSets - +void XF_Buffer::SetItemSets( UINT16 nCol, UINT16 nStartRow, UINT16 nEndRow, + UINT16 nXF ) + { + const SfxItemSet *pTxtAttr, *pBoxAttr; + +// DBG_ASSERT( nXF < nCount , +// "+XF_Buffer::SetItemSets(): das ist zuviel des Guten!" ); + if( nXF >= nCount ) + { + pTxtAttr = pDefTxtAttr; // nicht im Puffer + pBoxAttr = pDefBoxAttr; + } + else + { + if( ppTxtAttr[ nXF ] == NULL ) + CreateItemSets( nXF ); // erste Nutzung + + pTxtAttr = ppTxtAttr[ nXF ]; + pBoxAttr = ppBoxAttr[ nXF ]; + } + + // Ersatz fuer ApplyPatternAreaTab() + SwTableBox* pSttBox = pExcGlob->pTable->GetTabLines()[ nStartRow ]-> + GetTabBoxes()[ nCol ]; + + // BoxAttributierung + SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)pSttBox->ClaimFrmFmt(); + pBoxFmt->SetAttr( *pBoxAttr ); + + SwTableBox* pEndBox; + if( nStartRow != nEndRow ) + { + for( UINT16 nRow = nStartRow ; nRow <= nEndRow ; nRow++ ) + { + pEndBox = pExcGlob->pTable->GetTabLines()[ nRow ]-> + GetTabBoxes()[ nCol ]; + pEndBox->ChgFrmFmt( pBoxFmt ); + } + } + else + pEndBox = pSttBox; + + // TextAttributierung: + pExcGlob->pPam->GetPoint()->nNode = *pSttBox->GetSttNd(); + pExcGlob->pPam->Move( fnMoveForward, fnGoCntnt ); + pExcGlob->pPam->SetMark(); + pExcGlob->pPam->GetPoint()->nNode = *pEndBox->GetSttNd()->EndOfSectionNode(); + pExcGlob->pPam->Move( fnMoveBackward, fnGoCntnt ); + + pExcGlob->pD->Insert( *pExcGlob->pPam, *pTxtAttr ); + + } + +// --------------------------------------------- XF_Buffer::GetNumFormat - +sal_uInt32 XF_Buffer::GetNumFormat( UINT16 nIndex ) + { +// DBG_ASSERT( nIndex < nCount , +// "+XF_Buffer::GetNumFormat(): das ist zuviel des Guten!" ); + if( nIndex < nCount ) + {// im Puffer + XF_Data *pD = ppData[ nIndex ]; + + if( pD->HasValueFormat() ) + // eigenes Format + return pD->ValueFormat(); + else + {// Format vom Parent + if( pD->Parent() < nCount ) + { + XF_Data *pP = ppData[ pD->Parent() ]; + if( pP->HasValueFormat() ) + return pP->ValueFormat(); + } + } + } + + return pExcGlob->nStandard; // nicht im Puffer oder kein Value-Format + } + + +// --------------------------------------------------- class ColorBuffer - +// Kopiert aus: fontbuff.cxx + + +const UINT16 nIndCorrect = 8; + +//------------------------------------------- ColorBuffer::ColorBuffer() - + +ColorBuffer::ColorBuffer( void ) + { + UINT16 nSize = 256; + + pArray = new SvxColorItem *[ nSize ]; + for( UINT16 nC = 0 ; nC < nSize ; nC++ ) pArray[ nC ] = NULL; + + nCount = 0; + nMax = nSize; + bAuto = FALSE; + + pDefault = new SvxColorItem( Color( COL_BLACK ) ); + } + +//------------------------------------------ ColorBuffer::~ColorBuffer() - + +ColorBuffer::~ColorBuffer() + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + if( pArray[ nC ] ) delete pArray[ nC ]; + delete[] pArray; + + delete pDefault; + } + + +#ifdef USED +//--------------------------------------------------- ColorBuffer::Reset - + +void ColorBuffer::Reset( void ) + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + if( pArray[ nC ] ) + { + delete pArray[ nC ]; + pArray[ nC ] = NULL; + } + nCount = 0; + } +#endif + + +//----------------------------------------- ColorBuffer::NewColor( ... ) - + +BOOL ColorBuffer::NewColor( UINT16 nR, UINT16 nG, UINT16 nB ) + { + if( nCount < nMax ) + { + pArray[ nCount ] = new SvxColorItem( Color( + nR, nG, nB + ) ); + nCount++; + return TRUE; + } + + return FALSE; + } + +//---------------------------------------- ColorBuffer::GetColor5( ... ) - + +#define DefColorSize 56 + +const SvxColorItem *ColorBuffer::GetColor( UINT16 nIndex ) + { + if( nIndex >= nIndCorrect ) + nIndex -= nIndCorrect; + + if( nIndex < nMax ) + { + bAuto = FALSE; + if( pArray[ nIndex ] ) + return pArray[ nIndex ]; // schon Generiert + if( nIndex >= nCount ) + { // ausserhalb der Definierten + if( nIndex < DefColorSize ) + { // ... aber innerhalb der Defaults + static BYTE __READONLY_DATA pDefArray[ DefColorSize ][ 3 ] = { + 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, + 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, + 0xff, 0xff, 0x00, + 0xff, 0x00, 0xff, + 0x00, 0xff, 0xff, + 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, + 0x80, 0x80, 0x00, + 0x80, 0x00, 0x80, + 0x00, 0x80, 0x80, + 0xc0, 0xc0, 0xc0, + 0x80, 0x80, 0x80, + 0x80, 0x80, 0xff, + 0x80, 0x20, 0x60, + 0xff, 0xff, 0xc0, + 0xa0, 0xe0, 0xe0, + 0x60, 0x00, 0x80, + 0xff, 0x80, 0x80, + 0x00, 0x80, 0xc0, + 0xc0, 0xc0, 0xff, + 0x00, 0x00, 0x80, + 0xff, 0x00, 0xff, + 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, + 0x80, 0x00, 0x80, + 0x80, 0x00, 0x00, + 0x00, 0x80, 0x80, + 0x00, 0x00, 0xff, + 0x00, 0xcf, 0xff, + 0x69, 0xff, 0xff, + 0xe0, 0xff, 0xe0, + 0xff, 0xff, 0x80, + 0xa6, 0xca, 0xf0, + 0xdd, 0x9c, 0xb3, + 0xb3, 0x8f, 0xee, + 0xe3, 0xe3, 0xe3, + 0x2a, 0x6f, 0xf9, + 0x3f, 0xb8, 0xcd, + 0x48, 0x84, 0x36, + 0x95, 0x8c, 0x41, + 0x8e, 0x5e, 0x42, + 0xa0, 0x62, 0x7a, + 0x62, 0x4f, 0xac, + 0x96, 0x96, 0x96, + 0x1d, 0x2f, 0xbe, + 0x28, 0x66, 0x76, + 0x00, 0x45, 0x00, + 0x45, 0x3e, 0x01, + 0x6a, 0x28, 0x13, + 0x85, 0x39, 0x6a, + 0x4a, 0x32, 0x85, + 0x42, 0x42, 0x42 + }; + + pArray[ nIndex ] = new SvxColorItem( Color( + pDefArray[ nIndex ][ 0 ], // R + pDefArray[ nIndex ][ 1 ], // G + pDefArray[ nIndex ][ 2 ] // B + )); + } + else + { // ... und ausserhalb der Defaults + return pDefault; + } + } + return pArray[ nIndex ]; + } + else + { // ueber Array-Kapazitaet bzw. Auto + bAuto = TRUE; + return pDefault; + } + } + +// ---------------------------------------------------- class FontBuffer - + +// ---------------------------------------------- FontBuffer::FontBuffer - +FontBuffer::FontBuffer( UINT16 nNewMax ) + {// default: 256 Fonts + DBG_ASSERT( nNewMax, "-FontBuffer::FontBuffer(): Groesse 0!" ); + + nMax = nNewMax; + nCount = 0; + + aDefaultFont.pFont = new SvxFontItem; + + aDefaultFont.pHeight = new SvxFontHeightItem; + + aDefaultFont.bItalic = aDefaultFont.bStrikeout = aDefaultFont.bOutline = + aDefaultFont.bShadow = FALSE; + aDefaultFont.eUnderline = EXCUNDER_None; + aDefaultFont.nWeight = 400; // NORMAL + aDefaultFont.nColor = 0xFFFF; + + ppFonts = new ExcFont *[ nNewMax ]; + + // alle NULL + for( UINT16 nC = 0 ; nC < nMax ; nC++ ) + ppFonts[ nC ] = NULL; + + // ...ausser No. 4 + ppFonts[ 4 ] = &aDefaultFont; + } + +// --------------------------------------------- FontBuffer::~FontBuffer - +FontBuffer::~FontBuffer() + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + if( nC != 4 ) + { + delete ppFonts[ nC ]->pFont; + delete ppFonts[ nC ]->pHeight; + } + + delete[] ppFonts; + + delete aDefaultFont.pFont; + delete aDefaultFont.pHeight; + } + +//-------------------------------------------------- FontBuffer::NewFont - +void FontBuffer::NewFont( UINT16 nHeight, BYTE nAttr0, UINT16 nIndexCol, + const String &rName ) + { + // fuer Biff2-4 + BYTE nUnderline; + UINT16 nBoldness; + + if( nAttr0 &0x04 ) + // underline + nUnderline = ( BYTE ) EXCUNDER_Single; + else + nUnderline = ( BYTE ) EXCUNDER_None; + + if( nAttr0 & 0x01 ) + // bold + //rExcFont.bWeight = TRUE; + nBoldness = 700; // BOLD + else + //rExcFont.bWeight = FALSE; + nBoldness = 400; // NORMAL + + NewFont( + nHeight, nAttr0, nUnderline, nIndexCol, nBoldness, 0x00, 0x01, rName ); + // -> nFamily = DONTKNOW, nCharSet = DONTKNOW + } + +// ------------------------------------------------- FontBuffer::NewFont - +void FontBuffer::NewFont( UINT16 nHeight, BYTE nAttr0, BYTE nUnderline, + UINT16 nIndexCol, UINT16 nBoldness, BYTE nFamily, BYTE nCharSet, + const String &rName ) + { + // fuer Biff5 + + DBG_ASSERT( nCount < nMax, + "+FontBuffer::NewFont(): Puffer fuer Fonts voll!" ); + if( nCount >= nMax ) return; + + if( nCount == 4 ) nCount++; // 4 darf nicht vorkommen + + if( !ppFonts[ nCount ] ) + ppFonts[ nCount ] = new ExcFont; // bei Bedarf neu anlegen + + + ExcFont &rExcFont = *ppFonts[ nCount ]; + + // Umwandlung Windows-Font in SV-Font + CharSet eCharSet; + switch ( nCharSet ) + { + case 0: // ANSI_CHARSET + eCharSet = RTL_TEXTENCODING_MS_1252; + break; + case 255: // OEM_CHARSET + eCharSet = RTL_TEXTENCODING_IBM_850; + break; + case 2: // SYMBOL_CHARSET + eCharSet = RTL_TEXTENCODING_SYMBOL; + break; + default: + eCharSet = RTL_TEXTENCODING_DONTKNOW; + } + + FontFamily eFamily; + // !ACHTUNG!: anders als in Windows-Doku scheint der Font im unteren + // Nible des Bytes zu stehen -> Pitch unbekannt! + switch( nFamily & 0x0F ) // ...eben nicht! + { + case 0x01: // FF_ROMAN + eFamily = FAMILY_ROMAN; + break; + case 0x02: // FF_SWISS + eFamily = FAMILY_SWISS; + break; + case 0x03: // FF_MODERN + eFamily = FAMILY_MODERN; + break; + case 0x04: // FF_SCRIPT + eFamily = FAMILY_SCRIPT; + break; + case 0x05: // FF_DECORATIVE + eFamily = FAMILY_DECORATIVE; + break; + default: + eFamily = FAMILY_DONTKNOW; + } + + rExcFont.pFont = new SvxFontItem( eFamily, rName, + aEmptyStr, PITCH_DONTKNOW, eCharSet ); + + DBG_ASSERT( nHeight < 32767, + "+FontList::NewFont(): Height > 32767 - Pech..." ); + + rExcFont.pHeight = new SvxFontHeightItem( ( UINT32 ) nHeight ); + + rExcFont.nColor = nIndexCol; + + // Aufdroeseln der Fontattribute + rExcFont.nWeight = nBoldness; + + if( nAttr0 & 0x02 ) + // italic + rExcFont.bItalic = TRUE; + else + rExcFont.bItalic = FALSE; + + rExcFont.eUnderline = ( ExcUnderline ) nUnderline; + + if( nAttr0 &0x08 ) + // strikeout + rExcFont.bStrikeout = TRUE; + else + rExcFont.bStrikeout = FALSE; + + if( nAttr0 &0x10 ) + // outline + rExcFont.bOutline = TRUE; + else + rExcFont.bOutline = FALSE; + + if( nAttr0 &0x20 ) + // shadow + rExcFont.bShadow = TRUE; + else + rExcFont.bShadow = FALSE; + + nCount++; + //...und schon fertig... + } + +// ------------------------------------------------- FontBuffer::GetFont - +const ExcFont &FontBuffer::GetFont( UINT16 nIndex ) + { + // Index 4 ist per Definition nicht vorhanden! + DBG_ASSERT( nIndex != 4, + "+FontBuffer::GetFont(): Nr. 4 gibt's nicht!"); + + DBG_ASSERT( nIndex < nCount , + "+FontBuffer::GetPattern(): Hab'n mer nich' und krieg'n mer nich'" ); + if( nIndex >= nCount ) return aDefaultFont; + + return *ppFonts[ nIndex ]; + } + + +#ifdef USED +// --------------------------------------------------- FontBuffer::Reset - +void FontBuffer::Reset( void ) + { + for( UINT16 nC = 0 ; nC < nCount ; nC++ ) + { + if( nC != 4 ) + { + delete ppFonts[ nC ]->pFont; + delete ppFonts[ nC ]->pHeight; + ppFonts[ nC ]->pFont = NULL; + ppFonts[ nC ]->pHeight = NULL; + } + } + + nCount = 0; + } +#endif + + +#ifdef USED +// ---------------------------------------------------- class ExcTabelle - + +// -------------------------------------------- ExcTabelle::ExcTabelle() - +ExcTabelle::ExcTabelle() + { + nStrPos = 0xFFFFFFFF; + nCS = nRS = 1; + nCE = nRE = 0; + } + +// ------------------------------------- ExcTabelle::ExcTabelle( UINT32 ) - +ExcTabelle::ExcTabelle( UINT32 nNewStrPos ) + { + nStrPos = nNewStrPos; + nCS = nRS = 1; + nCE = nRE = 0; + } + +// ----------------------------- ExcTabelle::ExcTabelle( const String& ) - +ExcTabelle::ExcTabelle( const String &rName ) + { + aName = rName; + nCS = nRS = 1; + nCE = nRE = 0; + } + +// ------------ ExcTabelle::ExcTabelle( UINT16, UINT16, UINT16, UINT16 ) - +ExcTabelle::ExcTabelle( UINT16 nNewCS, UINT16 nNewCE, UINT16 nNewRS, + UINT16 nNewRE ) + { + nCS = nNewCS; + nRS = nNewRS; + nCE = nNewCE; + nRE = nNewRE; + } + +// ------------------------------------------- ExcTabelle::~ExcTabelle() - +ExcTabelle::~ExcTabelle() + { + } + + +// --------------------------------------------------- class ExcDokument - + +// ------------------------------------------ ExcDokument::ExcDokument() - +ExcDokument::ExcDokument() + { + ppTabellen = new ExcTabelle *[ MAX_TABS_EXCDOK ]; + + for( UINT16 nC = 0 ; nC < MAX_TABS_EXCDOK ; nC++ ) + ppTabellen[ nC ] = NULL; + + nAktTabIndex = 0; + nAktGetNext = -1; // -> GetNext enzspricht GetFirst + } + +// ----------------------------------------- ExcDokument::~ExcDokument() - +ExcDokument::~ExcDokument() + { + for( UINT16 nC = 0 ; nC < MAX_TABS_EXCDOK ; nC++ ) + if( ppTabellen[ nC ] ) delete ppTabellen[ nC ]; + delete[] ppTabellen; + } + + +// ----------------------------------------- ExcDokument::GetLastTabNr() - +UINT16 ExcDokument::GetAnzTabs( void ) const + { + if( ppTabellen[ nAktTabIndex ] ) + return nAktTabIndex + 1; + else + return nAktTabIndex; + } + +// ----------------------------------- ExcDokument::operator[]( UINT16 ) - +ExcTabelle *ExcDokument::operator[]( UINT16 nIndex ) + { + if( nIndex < MAX_TABS_EXCDOK ) + return ppTabellen[ nIndex ]; + else + return NULL; + } + +// ------------------------- ExcDokument::NewTab( const String&, UINT32 ) - +void ExcDokument::NewTab( const String &rName, UINT32 nStrPos ) + { + if( ppTabellen[ nAktTabIndex ] ) + nAktTabIndex++; + + if( nAktTabIndex < MAX_TABS_EXCDOK ) + { + ExcTabelle *pAkt = ppTabellen[ nAktTabIndex ] = new ExcTabelle; + + pAkt->aName = rName; + pAkt->nStrPos = nStrPos; + } + } + +// --------------------------------------- ExcDokument::Set( UINT16,...) - +void ExcDokument::Set( UINT16 nCS, UINT16 nCE, UINT16 nRS, + UINT16 nRE, UINT16 nIndex ) + { + if( nIndex == 0xFFFF ) + nIndex = nAktTabIndex; + + if( nIndex >= MAX_TABS_EXCDOK ) return; + + ExcTabelle *pAkt = ppTabellen[ nIndex ]; + + if( !pAkt ) + pAkt = ppTabellen[ nIndex ] = new ExcTabelle( nCS, nCE, nRS, nRE ); + } + + +// ----------------------------------- ExcDokument::Set( UINT32, UINT16 ) - +void ExcDokument::Set( UINT32 nStrPos, UINT16 nIndex ) + { + if( nIndex == 0xFFFF ) + nIndex = nAktTabIndex; + + if( nIndex >= MAX_TABS_EXCDOK ) return; + + ExcTabelle *pAkt = ppTabellen[ nIndex ]; + + if( !pAkt ) + pAkt = ppTabellen[ nIndex ] = new ExcTabelle( nStrPos ); + } + +// ----------------------------------- ExcDokument::Set( UINT32, UINT16 ) - +void ExcDokument::Set( const String &rName, UINT16 nIndex ) + { + if( nIndex == 0xFFFF ) + nIndex = nAktTabIndex; + + if( nIndex >= MAX_TABS_EXCDOK ) return; + + ExcTabelle *pAkt = ppTabellen[ nIndex ]; + + if( !pAkt ) + pAkt = ppTabellen[ nIndex ] = new ExcTabelle( rName ); + } + +// ------------------------------------------- ExcDokument::GetNextTab() - +ExcTabelle *ExcDokument::GetNextTab( void ) + { + nAktGetNext++; + DBG_ASSERT( nAktGetNext >= 0, + "-ExcDokument::GetNextTab(): nAktGetNext totaler Murks!" ); + while( nAktGetNext < MAX_TABS_EXCDOK && !ppTabellen[ nAktGetNext ] ) + nAktGetNext++; // solange, bis eine Tabelle gefunden + + if( nAktGetNext >= MAX_TABS_EXCDOK ) + return NULL; + else + return ppTabellen[ nAktGetNext ]; + } + +// ------------------------------------------ ExcDokument::GetFirstTab() - +ExcTabelle *ExcDokument::GetFirstTab( void ) + { + nAktGetNext = 0; + return ppTabellen[ nAktGetNext ]; + } +#endif + +// ----------------------------------------------- class ValueFormBuffer - + +const sal_Char *ValueFormBuffer::pBuiltinFormats[] = { + "General", // 0 + "0", // 1 + "0.00", // 2 + "#,##0", // 3 + "#,##0.00", // 4 + "", // 5 -> Defined 0 + "", // 6 -> Defined 1 + "", // 7 -> Defined 2 + "", // 8 -> Defined 3 + "0%", // 9 + "0.00%", // 10 + "0.00E+00", // 11 + "# ?/?", // 12 + "# ?""?/??", // 13 + "DD.MM.YYYY", // 14 + "DD. MMM YY", // 15 + "DD. MMM", // 16 + "MMM YY", // 17 + "h:mm AM/PM", // 18 + "h:mm:ss AM/PM", // 19 + "hh:mm", // 20 + "hh:mm:ss", // 21 + "DD.MM.YYYY hh:mm", // 22 + "", // 23 ? + "", // 24 ? + "", // 25 ? + "", // 26 ? + "", // 27 ? + "", // 28 ? + "", // 29 ? + "", // 30 ? + "", // 31 ? + "", // 32 ? + "", // 33 ? + "", // 34 ? + "", // 35 ? + "", // 36 ? + "#,##0 _$;-#,##0 _$", // 37 + "#,##0 _$;[Red]-#,##0 _$", // 38 + "#,##0.00 _$;-#,##0.00 _$", // 39 + "#,##0.00 _$;[Red]-#,##0.00 _$", // 40 + "", // 41 -> Defined 5 + "", // 42 -> Defined 4 + "", // 43 -> Defined 7 + "", // 44 -> Defined 6 + "mm:ss", // 45 + "[h]:mm:ss", // 46 + "mm:ss,0", // 47 + "##0.0E+0", // 48 + "@" // 49 + }; + +const UINT16 ValueFormBuffer::nAnzBuiltin = 50; +const UINT16 ValueFormBuffer::nNewFormats = 164; + +//------------------------------------------------------------------------ +ValueFormBuffer::ValueFormBuffer( const UINT16 nSize ) + { + nMax = nSize; + + pHandles = new UINT32[ nSize ]; + + // ACHTUNG: nCount wird in Init() sinnvoll gesetzt! + + _NewValueFormat = &ValueFormBuffer::__NewValueFormat; + _GetValueFormat = &ValueFormBuffer::__GetValueFormat; + } + +//------------------------------------------------------------------------ +ValueFormBuffer::~ValueFormBuffer() + { + delete[] pHandles; + } + +//------------------------------------------------------------------------ +void ValueFormBuffer::__NewValueFormat( String &rFormString ) + { + Init(); + ( this->*_NewValueFormat )( rFormString ); + } + +//------------------------------------------------------------------------ +void ValueFormBuffer::_NewValueFormatX( String &rFormString ) + { + DBG_ASSERT( nCount < nMax, + "+ValueFormBuffer::NewValueFormat(): Value-Form-Puffer voll!" ); + if( nCount >= nMax ) return; + + xub_StrLen nDummy; + INT16 nTyp = NUMBERFORMAT_DEFINED; + + if( rFormString == pExcGlob->aStandard ) + pHandles[ nCount ] = pExcGlob->pNumFormatter->GetStandardIndex + ( pExcGlob->eDefLanguage ); + else + pExcGlob->pNumFormatter->PutandConvertEntry( rFormString, nDummy, nTyp, + pHandles[ nCount ], LANGUAGE_ENGLISH_US, pExcGlob->eDefLanguage ); + + nCount++; + } + +//------------------------------------------------------------------------ +void ValueFormBuffer::_NewValueFormat5( String &rFormString ) + { + DBG_ASSERT( nCount < nMax, + "+ValueFormBuffer::NewValueFormat(): Value-Form-Puffer voll!" ); + if( nCount >= nMax ) return; + + xub_StrLen nDummy; + INT16 nTyp = NUMBERFORMAT_DEFINED; + + pExcGlob->pNumFormatter->PutandConvertEntry( rFormString, nDummy, nTyp, + pHandles[ nCount ], LANGUAGE_ENGLISH_US, pExcGlob->eDefLanguage ); + + // jetzt wird's merkwuerdig! + switch( nCount ) + { + case 5: nCount++; break; // 0 | + case 6: nCount++; break; // 1 |--| + case 7: nCount++; break; // 2 |--| + case 8: nCount = 42; break; // 3 |--| + case 41: nCount = 44; break; // 5 | |--| + case 42: nCount = 41; break; // 4 |--| | + case 43: nCount = nNewFormats; break; // 7 | |--| + case 44: nCount = 43; break; // 6 |--| | + default: nCount++; // |-... + } + } + +//------------------------------------------------------------------------ +UINT32 ValueFormBuffer::__GetValueFormat( UINT16 nExcIndex ) + { + Init(); + return ( this->*_GetValueFormat )( nExcIndex ); + } + +//------------------------------------------------------------------------ +UINT32 ValueFormBuffer::_GetValueFormatX5( UINT16 nExcIndex ) + { + DBG_ASSERT( nExcIndex < nCount, + "+ValueFormBuffer::GetValueFormat(): Da kann ich auch nichts fuer!" ); + if( nExcIndex >= nCount ) + return nDefaultHandle; + + return pHandles[ nExcIndex ]; + } + + +#ifdef USED +//------------------------------------------------------------------------ +void ValueFormBuffer::Reset( void ) + { + nCount = 0; + _NewValueFormat = &ValueFormBuffer::__NewValueFormat; + _GetValueFormat = &ValueFormBuffer::__GetValueFormat; + } +#endif + + +//------------------------------------------------------------------------ +void ValueFormBuffer::Init( void ) + { + if( pExcGlob->eHauptDateiTyp == ERT_Biff5 ) + {// Excel5 kriegt 'ne Sonderwurst! + UINT16 nC; + xub_StrLen nDummy; + INT16 nTyp = NUMBERFORMAT_DEFINED; + pExcGlob->pNumFormatter->PutEntry( aEmptyStr, nDummy, nTyp, + nDefaultHandle, pExcGlob->eDefLanguage ); + + // Builtin belegen + pHandles[ 0 ] = pExcGlob->pNumFormatter-> + GetStandardIndex( pExcGlob->eDefLanguage ); + + for( nC = 1 ; nC < nAnzBuiltin ; nC++ ) + { + String aString( String::CreateFromAscii(pBuiltinFormats[ nC ]) ); + pExcGlob->pNumFormatter->PutandConvertEntry( + aString, nDummy, nTyp, + pHandles[ nC ], LANGUAGE_ENGLISH_US, pExcGlob->eDefLanguage ); + } + + // Rest defaulten + for( nC = nAnzBuiltin ; nC < nMax ; nC++ ) + pHandles[ nC ] = nDefaultHandle; + + _NewValueFormat = &ValueFormBuffer::_NewValueFormat5; + nCount = 5; // !!!ACHTUNG!!! erster aus Format-Record! + } + else + { + _NewValueFormat = &ValueFormBuffer::_NewValueFormatX; + nCount = 0; + } + + _GetValueFormat = &ValueFormBuffer::_GetValueFormatX5; + } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/sw_exlpar.cxx b/binfilter/bf_sw/source/filter/excel/sw_exlpar.cxx new file mode 100644 index 000000000000..69f56266f88a --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/sw_exlpar.cxx @@ -0,0 +1,229 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_svtools/zforlist.hxx> +#include <bf_so3/svstor.hxx> + + +#include <node.hxx> +#include <doc.hxx> +#include <pam.hxx> +#include <swerror.h> +#include <fltini.hxx> +#include <exlpar.hxx> +#include <fltglbls.hxx> +#include <excxfbuf.hxx> +#include <excvfbff.hxx> +#include <excfntbf.hxx> +#include <swfltopt.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + +ExcGlob *pExcGlob = NULL; +//const double SwExcelParser::fExcToTwips = ( double ) TWIPS_PER_CHAR / 256; +const double SwExcelParser::fExcToTwips = + ( double ) ((20.0 * 72.27) / 13.6) / 256; + + + + +//Diese Methode hier weil sie natuerlich nicht inline sein darf. +void SwFilterBase::Read( String &rS ) + {// liest 0-terminierten C-String! + DBG_ASSERT( nReadBuffSize > 242, + "-SwFilterBase::Read( String& ): Read-Buffer zu klein!!!!!!!!!" ); + + sal_Char *pC = pReadBuff; + register USHORT nCount = 0; // Einer wird mindestens gelesen + + // String wird komplett mit 0-Terminator eingelesen + do { + *pIn >> *pC; + nCount++; + } + while( *(pC++) != 0 ); + + nBytesLeft -= nCount; + rS = String(pReadBuff, eQuellChar); + } + + + +ExcGlob::ExcGlob( SwDoc& rDoc, const SwPaM& rPam ) + : FilterGlobals( rDoc, rPam ) +{ + pExcGlob = this; // die Buffer greifen schon auf den Pointer zu + pXF_Buff = new XF_Buffer; + pFontBuff = new FontBuffer(); + pColorBuff = new ColorBuffer(); + + Reference< XMultiServiceFactory > xMSF = ::legacy_binfilters::getLegacyProcessServiceFactory(); + pNumFormatter = new SvNumberFormatter( xMSF, LANGUAGE_SYSTEM ); +} + +ExcGlob::~ExcGlob() +{ + delete pXF_Buff; + delete pFontBuff; + delete pColorBuff; + delete pNumFormatter; +} + + +SwExcelParser::SwExcelParser( SwDoc &rDoc, const SwPaM & rCrsr, + SvStream& rInInit, int bReadNewDoc, + CharSet eQ ) + : bNewDoc( bReadNewDoc ) +{ + pIn = &rInInit; + eQuellChar = eQ; + pExcGlob = new ExcGlob( rDoc, rCrsr ); + + pValueFormBuffer = new ValueFormBuffer; + + nReadBuffSize = 2048; + pReadBuff = new sal_Char[ nReadBuffSize ]; + + eDateiTyp = BiffX; + nLastCol = nLastRow = 0; + aColRowBuff.SetDefWidth( ( USHORT ) ( fExcToTwips * 1024 ) ); // 4 Zeichen Standardbreite + + bResultString = FALSE; +} + +SwExcelParser::~SwExcelParser() +{ + delete pExcGlob; + delete pValueFormBuffer; + delete[] pReadBuff; + pExcGlob = NULL; +} + + +ULONG SwExcelParser::CallParser() +{ + static const sal_Char* aNames[4] = { + "Excel_Lotus/MinRow", "Excel_Lotus/MaxRow", + "Excel_Lotus/MinCol", "Excel_Lotus/MaxCol" + }; + sal_uInt32 aVal[4]; + SwFilterOptions aOpt( 4, aNames, aVal ); + + USHORT nMinRow = ( USHORT ) aVal[ 0 ]; + USHORT nMaxRow = ( USHORT ) aVal[ 1 ]; + USHORT nMinCol = ( USHORT ) aVal[ 2 ]; + USHORT nMaxCol = ( USHORT ) aVal[ 3 ]; + + USHORT nAnzNodes = 65000U - pExcGlob->pD->GetNodes().Count(); + + if( nMaxRow < nMinRow ) + { + USHORT nTemp = nMinRow; + nMinRow = nMaxRow; + nMaxRow = nTemp; + } + + if( nMaxCol < nMinCol ) + { + USHORT nTemp = nMinCol; + nMinCol = nMaxCol; + nMaxCol = nTemp; + } + + if( nMaxRow - nMinRow == 0 ) + nMaxRow = nMinRow + 30; // Default bei 0 Rows + + if( nMaxCol - nMinCol == 0 ) + nMaxCol = nMinCol + 15; // Default bei 0 Cols + + if( nAnzNodes < ( nMaxRow - nMinRow ) * ( nMaxCol - nMinCol ) * 3 ) + return ERR_EXCLOT_WRONG_RANGE; + + pExcGlob->SetRange( nMinCol, nMaxCol, nMinRow, nMaxRow ); // Default-Einstellung + Parse(); + return 0; +} + + + +ULONG ExcelReader::Read( SwDoc &rDoc, SwPaM &rPam, + const String & /* FileName, falls benoetigt wird */ ) +{ + if( rPam.GetNode()->FindTableNode() ) + return ERR_SWG_READ_ERROR; + + USHORT nOldBuffSize = 32768; + + ULONG nRet = 0; + SvStorageStreamRef refStrm; // damit uns keiner den Stream klaut + SvStream* pIn = pStrm; + if( pStg ) + { + nRet = OpenMainStream( refStrm, nOldBuffSize ); + pIn = &refStrm; + } + else if( !pStrm ) + { + ASSERT( FALSE, "ExcelReader-Read ohne Stream/Storage" ); + nRet = ERR_SWG_READ_ERROR; + } + + if( !nRet ) + { + SwExcelParser* pParser = new SwExcelParser( rDoc, rPam, *pIn, !bInsertMode, gsl_getSystemTextEncoding() ); + nRet = pParser->CallParser(); // 0 == kein Fehler aufgetreten + + delete pParser; + + if( refStrm.Is() ) + refStrm->SetBufferSize( nOldBuffSize ); + } + + return nRet; +} + +int ExcelReader::GetReaderType() +{ + return SW_STORAGE_READER | SW_STREAM_READER; +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/excel/sw_fltglbls.cxx b/binfilter/bf_sw/source/filter/excel/sw_fltglbls.cxx new file mode 100644 index 000000000000..9251249f69b3 --- /dev/null +++ b/binfilter/bf_sw/source/filter/excel/sw_fltglbls.cxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "doc.hxx" +#include "pam.hxx" +#include "swtable.hxx" +#include "fltglbls.hxx" +namespace binfilter { + + + + +//------------------------------------------------------------------------ +FilterGlobals::FilterGlobals( SwDoc& rDoc, const SwPaM& rPam ) + : aStandard( String::CreateFromAscii("General") ), + aTblFmts( 0, 10 ) +{ + pD = &rDoc; // "globaler" Dokument-Pointer + pPam = new SwPaM( *rPam.GetPoint() ); + pTable = 0; + pNumFormatter = 0; + + eDefLanguage = LANGUAGE_SYSTEM; + nDefFormat = 0xFFFFFFFF; + + nColStart = nRowStart = 1; + nColEnd = nRowEnd = 0; + nAnzCols = nAnzRows = 0; +} + +FilterGlobals::~FilterGlobals() +{ + // 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(); + } + + delete pPam; +} + +//------------------------------------------------------------------------ +void FilterGlobals::SetRange( USHORT nCS, USHORT nCE, USHORT nRS, USHORT nRE ) +{ + if( nCE < nCS ) + { + if( nCS == 0 ) + nCE = 0; + else + nCE = nCS - 1; + } + + if( nRE < nRS ) + { + if( nRS == 0 ) + nRE = 0; + else + nRE = nRS - 1; + } + + nColStart = nCS; + nColEnd = nCE; + nRowStart = nRS; + nRowEnd = nRE; + nAnzCols = 1 + nCE - nCS; + nAnzRows = 1 + nRE - nRS; +} + + + +BOOL FilterGlobals::ColRangeLimitter( USHORT &rCS, USHORT &rCE ) +{ + // PREC: rCS <= rCE + // POST: wenn [rCS, rCE] und [nColStart,nColEnd] disjunkte Intervalle, + // return = FALSE; + // sonst + // return = TRUE + // rCS = MAX(rCS,nColStart) + // rCE = MIN(rCE,nColEnd) + BOOL bRet; + DBG_ASSERT( rCS <= rCE, + "-FilterGlobals::ColRangeLimitter(): Startspalte > Endspalte!" ); + if( rCS > nColEnd || rCE < nColStart ) + bRet = FALSE; + else + { + bRet = TRUE; + if( rCS < nColStart ) rCS = nColStart; + if( rCE > nColEnd ) rCE = nColEnd; + } + return bRet; +} + +void FilterGlobals::InsertText( USHORT nCol, USHORT nRow, const String& rStr ) +{ + pPam->GetPoint()->nNode = *pTable->GetTabLines()[ nRow ]-> + GetTabBoxes()[ nCol ]->GetSttNd(); + pPam->Move( fnMoveForward, fnGoCntnt ); + + pD->Insert( *pPam, rStr ); +} + +void FilterGlobals::CreateTable() +{ + pTable = pD->InsertTable( *pPam->GetPoint(), + AnzRows(), // nRows + AnzCols(), // nCols + HORI_LEFT ); // SwHoriOrient + + // JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525 + void* p = pTable->GetFrmFmt(); + aTblFmts.Insert( p, aTblFmts.Count() ); +} + +void FilterGlobals::InsertAttr( const SfxPoolItem& rItem ) +{ + SfxItemSet aTxtAttr( pD->GetAttrPool(), rItem.Which(), rItem.Which() ); + aTxtAttr.Put( rItem ); + pD->Insert( *pLotGlob->pPam, aTxtAttr ); +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/SwAppletImpl.hxx b/binfilter/bf_sw/source/filter/inc/SwAppletImpl.hxx new file mode 100644 index 000000000000..aa48e212df16 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/SwAppletImpl.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SW_APPLET_IMPL_HXX +#define _SW_APPLET_IMPL_HXX + +#define SWHTML_OPTTYPE_IGNORE 0 +#define SWHTML_OPTTYPE_TAG 1 +#define SWHTML_OPTTYPE_PARAM 2 +#define SWHTML_OPTTYPE_SIZE 3 + +#include <tools/string.hxx> + +#include <bf_svtools/htmlkywd.hxx> +#include <bf_sfx2/frameobj.hxx> +#include <vcl/wrkwin.hxx> +#include <bf_so3/svstor.hxx> +#include <bf_so3/applet.hxx> +#include <bf_so3/plugin.hxx> +#include <bf_svtools/itemset.hxx> +namespace binfilter { + +class SfxItemSet; + +class SwApplet_Impl +{ + SvAppletObjectRef xApplet; // das aktuelle Applet + SfxItemSet aItemSet; + +public: + static USHORT GetOptionType( const String& rName, BOOL bApplet ){DBG_BF_ASSERT(0, "STRIP"); return 0;} //STRIP001 static USHORT GetOptionType( const String& rName, BOOL bApplet ); + SwApplet_Impl( SfxItemSet& rSet ): aItemSet ( rSet) {} + ~SwApplet_Impl(){DBG_BF_ASSERT(0, "STRIP");}; //STRIP001 ~SwApplet_Impl(); + + void CreateApplet( const String& rCode, const String& rName,//STRIP001 void CreateApplet( const String& rCode, const String& rName, + BOOL bMayScript, const String& rCodeBase ){DBG_BF_ASSERT(0, "STRIP");}; //STRIP001 //STRIP001 BOOL bMayScript, const String& rCodeBase ); + sal_Bool CreateApplet(); + SvAppletObject* GetApplet() { return &xApplet; } + SfxItemSet& GetItemSet() { return aItemSet; } +}; +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/fltbase.hxx b/binfilter/bf_sw/source/filter/inc/fltbase.hxx new file mode 100644 index 000000000000..f64df5098825 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/fltbase.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __FLTBASE_HXX__ +#define __FLTBASE_HXX__ + +#include <tools/stream.hxx> + +namespace binfilter { + +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; + } + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/fltglbls.hxx b/binfilter/bf_sw/source/filter/inc/fltglbls.hxx new file mode 100644 index 000000000000..75f3f65658f6 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/fltglbls.hxx @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _FLTGLBS_HXX +#define _FLTGLBS_HXX + +#include <tools/string.hxx> +#include <i18npool/lang.h> +#include <bf_svtools/svarray.hxx> +namespace binfilter { +class SfxPoolItem; +class SvNumberFormatter; + +class SwDoc; +class SwPaM; +class SwTable; + +class XF_Buffer; +class ColorBuffer; +class FontBuffer; + + + +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 + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/fltini.hxx b/binfilter/bf_sw/source/filter/inc/fltini.hxx new file mode 100644 index 000000000000..21ac005d21de --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/fltini.hxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _FLTINI_HXX +#define _FLTINI_HXX + + +#include <shellio.hxx> +#include <tools/color.hxx> +namespace binfilter { + +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: +}; + + + + +class XMLReader : public Reader +{ + virtual ULONG Read(SwDoc &,SwPaM &,const String &); +public: + virtual int GetReaderType(); + + XMLReader(); + + // read the sections of the document, which is equal to the medium. + // returns the count of it + virtual USHORT GetSectionList( SfxMedium& rMedium, + SvStrings& rStrings ) const; +}; + +// die speziellen Writer + +#if 0 +/*?*/ WriterRef GetW4WWriter( const String& ); +WriterRef GetStgWriter( const String& ); +WriterRef GetWWWriter( const String& ); +/*?*/ WriterRef GetWW8Writer( const String& ); +#if !( !defined(DBG_UTIL) || 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& ); +#if !( !defined(DBG_UTIL) || defined(MAC) || defined(PM2) ) +#endif +#endif + + +// 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 ); + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/w4wflt.hxx b/binfilter/bf_sw/source/filter/inc/w4wflt.hxx new file mode 100644 index 000000000000..9e998662c5e5 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/w4wflt.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _W4WFLT_HXX +#define _W4WFLT_HXX + +#include <tools/solar.h> +class String; +namespace binfilter { + + + +// suche fuer das File den enstsprechenden Filter Typ +// und die Version +USHORT AutoDetec( const String& rFileName, USHORT & rVersion ); + +// W4W speichert beim Laden vom File pFileName die Ausgabe in pTmpFile. +// (das Tempfile wird hier anleget!) +// der Filter wird ueber nFilter bestimmt. +ULONG LoadFile( const String& rFileName, USHORT nFilter, + const String& rVersion, String & rTmpFile ); + +enum W4WDLL_TYPE { W4WDLL_EXPORT, W4WDLL_IMPORT, W4WDLL_AUTODETEC }; +FASTBOOL W4WDLLExist( W4WDLL_TYPE eType, USHORT nFilter = 0 ); + + +} //namespace binfilter +#endif // _W4WFLT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/w4wpar.hxx b/binfilter/bf_sw/source/filter/inc/w4wpar.hxx new file mode 100644 index 000000000000..02432a463fb3 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/w4wpar.hxx @@ -0,0 +1,861 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _W4WPAR_HXX +#define _W4WPAR_HXX + +#include <tools/string.hxx> +#include <tools/table.hxx> +#include <tools/stream.hxx> + +#include <swtypes.hxx> +#include <hintids.hxx> + +#include <swrect.hxx> +#include <tblsel.hxx> // SwSelBoxes +#include <numrule.hxx> // numerierte Listen + +class String; +class Graphic; +namespace binfilter { + +class SfxPoolItem; +class SfxItemSet; + +// Konstanten fuer die internen Fehler-Codes beim Einlesen +#define ERR_NOERROR 0 +#define ERR_CHAR 1 +#define ERR_RECORD 2 +#define ERR_NAMETOLONG 3 + +// Konstanten fuer den Anfang und Ende der Records +#define W4WR_BEGICF 0x1B +#define W4WR_LED 0x1D +#define W4WR_TXTERM 0x1F +#define W4WR_RED 0x1E + +#define W4W_INVALID (USHORT)-1 + +#define W4WFL_NO_FLY_IN_CNTNT 0x01 +#define W4WFL_NO_GRAF_IN_CNTNT 0x02 +#define W4WFL_EXACT_TABLES 0x04 +#define W4WFL_NO_DBL_TBL_BORDER_REMOVE 0x08 +#define W4WFL_NO_WW_SPECCHAR 0x10 +#define W4WFL_NO_APO_HNL_REMOVE 0x20 +#define W4WFL_NO_DBL_APO_BORDER_REMOVE 0x40 +#define W4WFL_NO_HDFT_DIST 0x80 +#define W4WFL_ALL_HDFT_DIST 0x100 +#define W4WFL_NO_PCTEXT4_124 0x200 +#define W4WFL_NO_PCTEXT4_INDENT 0x400 +#define W4WFL_ALL_HDFT_MAINATTR 0x800 +#define W4WFL_NO_PCTEXT4_HDFT_MAINATTR 0x1000 +#define W4WFL_NO_PCTEXT4_STP_DEC2 0x2000 + +// ( Standardverhalten: analysieren, was Standard sein duerfte ) +// W4WFL_FrameMaker_cleverFrames 0x00000000; + +// ( keine Frames: blind einlesen ) +#define W4WFL_FM_neverFrames 0x00000001 + +// ( ALLES als Frames einlesen: +// kein Content fuer Header/Body/Footer ) +#define W4WFL_FM_onlyFrames 0x00000002 + + + + +typedef USHORT* UShortPtr; + +class SwDoc; +class SwPaM; + +class SwTxtFmtColl; +class SwPageDesc; +class SvxBoxItem; + +class W4WTabBorders; + +class W4WMergeGroups; // enthaelt Sw_SelBoxes_SAR + +class W4WStyleIdTab; +class W4WCtrlStack; +class SwTable; +class SwTableNode; +class SwTableLines; +class SwTableLine; +class SwTableBoxes; +class SwTableBox; + +class SwW4WGraf; +class SvxLRSpaceItem; +class SvxULSpaceItem; +class swistream; +class SwFlyFrmFmt; +struct W4WRecord; + + +struct W4WRecType +{ + sal_Char c0, c1, c2; + void Reset() + { + c0 = 0; + c1 = 0; + c2 = 0; + } + BOOL IsEqual(const W4WRecType& rRec) const + { + return (rRec.c0 == c0) && (rRec.c1 == c1) && (rRec.c2 == c2); + } + BOOL IsEqual( const sal_Char* pRec, int nLen ) const + { + return (3 == nLen ) + && (*(pRec+0) == c0) + && (*(pRec+1) == c1) + && (*(pRec+2) == c2); + } +}; + + +struct W4W_ColdT // ColumnsDefinitionTyp, nur in W4WPar2.cxx benutzt +{ + long nLeft; //!!! kann eigentlich nach w4wpar2.cxx + long nRight; + long nNC; + long nLeftTw; + long nRightTw; + long nNC2; + long nWidthFrac; + USHORT nMergeGroupIdx; // falls groesser -1 ist Merge-Gruppe offen + long nRemainingMergeRows; // wieweit nach unten mergen wir noch dazu +}; + + +struct W4WRectInfo +{ + SwRect aRect; + int nPDTId; // Nummer der Seite im PDT array + int nFLOId; // Nummer des FLO, in dem das Rect enthalten ist + + int nFMId; // urspruengliche FrameMaker-Id aus dem W4W-Code + int nSWId; // Id des W4WRectInfo, den wir im SW dafuer nehmen + // ( z.B. bei Spaltigkeit: alle Spalten weisen + // auf den linken Rahmen ) + + BOOL bInside: 1; // Frame liegt in einem anderen drinnen + BOOL bColXYZ: 1; // Folge-Spalten eines spalt. Bereichs + BOOL bBody: 1; // Body-Bereich, also KEIN Fly + BOOL bHeader: 1; // Header " " + BOOL bFooter: 1; // Footer " " + + W4WRectInfo(const SwRect& rRect_, int nId_, int nPDTId_ = -1): + aRect( rRect_ ), + nPDTId( nPDTId_), + nFMId( nId_ ), + nSWId( nId_ ) + { + bInside = FALSE; + bColXYZ = FALSE; + bBody = FALSE; + bHeader = FALSE; + bFooter = FALSE; + } + /* + void StoreRect(SwRect* pRect_, int nId_, int nPDTId_) + { + aRect = pRect_; + nPDTId = nPDTId_; + nFMId = nId_; + nSWId = nId_; + bInside = FALSE; + bColXYZ = FALSE; + bBody = FALSE; + bHeader = FALSE; + bFooter = FALSE; + } + void StoreRect(W4WRectInfo& rInfo) + { + pRect = rInfo.pRect; + nPDTId = rInfo.nPDTId; + nFMId = rInfo.nFMId; + nSWId = rInfo.nSWId; + bInside = rInfo.bInside; + bColXYZ = rInfo.bColXYZ; + bBody = rInfo.bBody; + bHeader = rInfo.bHeader; + bFooter = rInfo.bFooter; + } + */ + BOOL IsActive(){ return !(bColXYZ || bInside); } + BYTE BodyHdFtMode(){ return bBody ? 1 : (bHeader ? 2 : 3); } +}; + + +struct W4WPDTInfo +{ + String sPageName; + long* pIds; + long nPageType; // 1 == Body Page, 2 == Master Page, 3 == Reference Page + long nPageSubType; // 1 == Left Page, 2 == Right Page, 3 == First Page ??? + long nRects; + USHORT nSwPdId; + USHORT nBodyRectId; + USHORT nHdRectId; + USHORT nFtRectId; + BOOL bSwPdUsed :1; + BOOL bPageWidthUnknown :1;// Page Margin rechts noch nicht eingestellt + BOOL bPageHeightUnknown :1;// unten + W4WPDTInfo() + :nPageType( 1 ), + nPageSubType( 0 ), + nRects( 0 ), + pIds( 0 ), + nBodyRectId( USHRT_MAX ), + nHdRectId( USHRT_MAX ), + nFtRectId( USHRT_MAX ), + nSwPdId( USHRT_MAX ) + { + bSwPdUsed = FALSE; + bPageWidthUnknown = TRUE; + bPageHeightUnknown = TRUE; + } + ~W4WPDTInfo(){ delete pIds; } + BOOL PageSizeKnown(){ return 0 == ( bPageWidthUnknown + | bPageHeightUnknown ); } +}; +typedef W4WPDTInfo* W4WPDTInfo_Ptr; +SV_DECL_PTRARR_DEL(W4WPDTInfos, W4WPDTInfo_Ptr, 16, 16) + + +struct W4WFLOInfo +{ + long* pIds; + long nFlowId; + long nRects; + BOOL bFlowUsed:1; + W4WFLOInfo() + :nFlowId( 0 ), + nRects( 0 ), + pIds( 0 ) + { bFlowUsed = FALSE; } + ~W4WFLOInfo(){ delete pIds; } +}; +typedef W4WFLOInfo* W4WFLOInfo_Ptr; +SV_DECL_PTRARR_DEL(W4WFLOInfos, W4WFLOInfo_Ptr, 16, 16) + + +DECLARE_TABLE(W4WRDTInfos, W4WRectInfo*) + + +class SwW4WParser +{ + // Zum Unterscheiden, von wo die Methode + // SwW4WParser::UpdatePageMarginSettings() aufgerufen wurde + enum W4W_UpdtPgMrgSet + { + CALLED_BY_HF2, // Methode wurde aufgerufen wegen HF2-Flag, + CALLED_BY_HF1, // wegen HF1-Flag, + CALLED_BY_FLUSH_OR_HNL // aus SwW4WParser::Flush() oder nach .<HNL> + }; + + // Zur Parametrisierung von SwW4WParser::CreatePageDesc() + enum W4W_CreatePgDescSet + { + CRPGD_AS_FOLLOW = 0x01, // es soll ein Follow-PageDesc werden + CRPGD_AND_INSERT= 0x02, // PageDesc wird ins pDoc inserted + CRPGD_REMOVE_HD = 0x04, // Header des Vorgaengers NICHT uebernehmen + CRPGD_REMOVE_FT = 0x08, // Footer des Vorgaengers NICHT uebernehmen + CRPGD_UPDT_MRGN = 0x10 // ggfs. SwW4WParser::SetPageMgn() aufrufen + }; + + // zum Erkennen des unbekannten Zustands einer booleschen Variablen + enum W4W_THREE_STATE + { + VALUE_FALSE = 0x00, // wahr + VALUE_UNKNOWN = 0x01, // (noch) unbekannter Wert + VALUE_TRUE = 0x02 // unwahr + }; + + + sal_Unicode aCharBuffer[ 512 ]; // Puffer fuer die Zeichen + + const String& rVersion; // Unterversion des Filteraufrufs + //; Bit 0: Rahmen werden niemals an Zeichen gebunden + //; Bit 1: Bilder werden niemals an Zeichen gebunden + //; Bit 2: Tabelle punktgenau positionieren ( nicht so robust ) + //; Bit 3: Umrandungen von Tabellenzellen nicht ausduennen + //; Bit 4: bei WinWord2 Umlauten nicht mogeln ( ab Version 94c ) + //; Bit 5: bei WinWord2 ueberfluessige Leerzeilen nicht ignorieren ( ab Version 102 ) + //; Bit 6: Bei Frames doppelte Umrandungen nicht unterdruecken + + //; Bit 16: ASCII-Export darf ^L enthalten + //; Bit 17: Grafiken nicht exportieren + + /* + Pointer + */ + W4WCtrlStack* pCtrlStck; // Stack fuer die Attribute + + SwW4WGraf* pGraf; // Pointer auf W4W-Grafik-Klasse + Graphic* pGraphic; // Hier ist die Grafik + + SwTableNode* pTblNd; // Tabellen-Node + SwTableLine* pTabLine; // akt. Zeile + SwTableBoxes* pTabBoxes; // Boxen-Array in akt. Zeile + SwTableBox* pTabBox; // akt. Zelle + + W4W_ColdT* pTabDefs; // ColumnsDefinition + + W4WTabBorders* pTabBorders; // .<BRO>-Raender einer ganzen Tabelle + + W4WMergeGroups* pMergeGroups; // Listen aller zu verknuepfenden Zellen + + SwNodeIndex* pBehindSection; // Node-Index zum Zuruecksetzen des PaM nach einem Bereich + + W4WPDTInfos* pPDTInfos; // array von PageDefinitionTable + W4WRDTInfos* pRDTInfos; // array von RectangleDefinitionTable + W4WFLOInfos* pFLOInfos; // array von Text Folow + + W4WPDTInfo* pPDTInfo; // Id der derzeit aktuellen PDT (FrameMaker) + W4WRectInfo* pActRectInfo; // Rect-1 des derzeitigen TextFlow (FrameMaker) + + // aktuelles Seitenlayout, oder das bei naechstem + // Seitenumbruch automatisch zu nehmende Layout + SwPageDesc* pPageDesc; + + // letztes per PageAttr gesetztes Seitenlayout + SwPageDesc* pLastActPageDesc; + + // aktuelles Seitenlayout, falls bereits ein Folge-Layout definiert wurde, + // das in pPageDesc gespeichert ist, sonst 0 + SwPageDesc* pOpen1stPgPageDesc; + + // kommendes Seitenlayout ab naechstem .<HNP> fuer den Fall, + // dass wir den Follow des in pPageDesc gespeicherten Layouts + // nicht aendern wollen/duerfen, sonst 0 + SwPageDesc* pPageDescForNextHNP; + + SwPaM *pCurPaM; // Writer-Einfuegepos + SwFlyFrmFmt* pActFlySection; + SwDoc *pDoc; // aktuelles Dokument + + SvStream& rInp; // gepufferter swistream dazu + + W4WStyleIdTab* pStyleTab; // Tabelle fuers Mappen von Id auf Style + W4WStyleIdTab* pStyleBaseTab; // Tabelle fuer "Style based on" + + SwNumRule* pActNumRule; // derzeitige num. Liste laut letztem .<PND> + + W4WRecord *pActW4WRecord; // letzte, passende Methode aus ::GetNextRecord() + W4WRecType aLastRecType; // in Main Loop: last Token that has been processed + + String* pReadTxtString; // zum Einlesen in :Flush(), + // falls bReadTxtIntoString gesetzt ist + + /* + long und ULONG + */ + long nGrafPDSType; // Typ der Graphik aus PDS-Befehl + long nGrWidthTw; // Groesse der Grafik + long nGrHeightTw; + long nParaLen; // zum Zaehlen gegen UEberschreitung d. max. Absatzlaenge + long nRecNo; // Befehlszaehler zum besseren Debuggen + long nRSMLeft; // Merke RSM-Werte bis zum naechsten Seitenwechsel + long nRSMRight; + long nRSMwpwParaLeft; // Merke RSM-Werte fr WPWin - Absatz-Raender + long nRSMwpwParaRight; + + // Hilfs-Varis zur Umrechnung + // von W4W-Randangaben + // zu denen im Writer + long nLastValueSTP; // zuletzt wegen STP gesetzter Wert + long nLastValueSBP; // zuletzt wegen SBP gesetzter Wert + long nLastValueHTM; // zuletzt wegen HTM gesetzter Wert + long nLastValueHM; // zuletzt wegen HM gesetzter Wert + long nLastValueFBM; // zuletzt wegen FBM gesetzter Wert + long nLastValueFM; // zuletzt wegen FM gesetzter Wert + long nNewValueSTP; // jetzt neu von STP angegebener Wert + long nNewValueSBP; // jetzt neu von SBP angegebener Wert + long nNewValueHTM; // jetzt neu von HTM angegebener Wert + long nNewValueHM; // jetzt neu von HM angegebener Wert + long nNewValueFBM; // jetzt neu von FBM angegebener Wert + long nNewValueFM; // jetzt neu von FM angegebener Wert + + long nW4WFileSize; // fuer Prozentskala + + long nTabDeltaSpace; // durchschnittl. Zellen-Zwischenraum + long nTabWidthTw; // GesamtBreite ALLER Spalten in Twips + + long nLastProcessedCol; // zuletzt per .<BC0_> definierte Zelle + + long nStartOfActRecord; + long nStreamPosInRec; + + ULONG nIniFlags; // Flags aus der writer.ini + // untere 16 Bits fuer den W4W-Reader + ULONG nIniHdSiz; // Flags fuer Default-Size Header + ULONG nIniFtSiz; // dito fuer Footer + ULONG nIniFMFlags; // Flags fuer Import von FrameMaker Dokumenten + + W4W_THREE_STATE eFootNotePageRestart; // neu zaehlen ab jeder Seite + + /* + USHORT und short + */ + USHORT nDefLanguage; // diese Sprache statt Ausschalter + + USHORT nDocType; // Quellformat + USHORT nAktPgDesc; // momentan gueltiges Seitenlayout + USHORT nApoBorderCode; // Diese APO hat folgenden BorderCode + // gegen doppelte Border in WW2-Apos + + USHORT nColSize; // wenn keine Angaben in Twips existieren + USHORT nTablInTablDepth; // Ebenen-Tiefe von Tabelle IN Tabelle + + USHORT nHdFtType; // Typ des letzten Kopf/Fusstextes + USHORT nPDType; // Typ des zuletzt angelegten Seitenlayouts + USHORT nTabRows; // V-SSize der Tabelle + USHORT nTabCols; // H-SSize + USHORT nTabCol; // aktuelle H-Pos + + short nTabRow; // V-Pos in Tabelle + + USHORT nTabDefBorder; // Was fuer einen Standard-Rahmen ist gewaehlt + + // gecachete Raender des SeitenLayouts + USHORT nPgLeft; // SLay L.Rand + // = pPageDesc->GetMaster()->GetLRSpace()->GetTxtLeft() + + USHORT nLeftMgnCorr; + + USHORT nPgRightDelta; // dito ...->GetRight() + + USHORT nPgRight; // dito ...->GetWidth() - ->GetRight() + + USHORT nPgWidth; // dito ...->GetFrmSize().GetFixSize() + + USHORT nAktStyleId; // Id vom aktuellen StyleSheet (W4W-Nummerierung) + USHORT nTabStyleId; // Id des Style vor Tabellen-Anfang (W4W-Nummerierung) + USHORT nNoNameStylesCount; // Anzahl der Styles mit ungueltigem oder fehlendem W4W-Namen + + USHORT nChrCnt; // Counter fuer aCharBuffer + + USHORT nLastReadFootNo; // zuletzt eingelesene Fussnoten-Nr. + USHORT nLastReadEndNo; // zuletzt eingelesene Endnoten-Nr. + + /* + char und BYTE + */ + char nFtnType; // Fuss- oder EndNote, -1 fuer noch nicht bekannt + + BYTE nError; // igendwelche Fehler ?? + + BYTE nTabCode; // Tabellen-Definitions-Byte + + BYTE nUnderlineMode; // alles oder nur Worte unterstreichen + + BYTE nActNumLevel; // Nummerierungs-Tiefe des akt. Absatz + + BYTE nFootNoOverflow; // Ueberlaufzaehler fuer Fussnoten-Nummern + // beim FNI-Typ Gross- oder Kleinbuchstaben + BYTE nEndNoOverflow; // Ueberlaufzaehler fuer Endnoten-Nummern + // beim FNI-Typ Gross- oder Kleinbuchstaben + /* + BOOL mit 1 Bit + */ + BOOL bPDTanalyzed : 1; // FrameMaker-Flag, ob Page Definition Table + // bereits ausgewertet wurde + // und die entrsprechenden PgDesc erzeugt sind + + BOOL bStyleDef : 1; // Flag, ob gerade Style definitiniert wird + BOOL bHeadFootDef : 1; // Flag, ob gerade Header oder Footer definiert werden + BOOL bFootnoteDef : 1; // Flag, ob gerade Fussnote definiert wird + + BOOL bStyleEndRec : 1; // StyleEndRec erkannt + BOOL bStyleOnOff : 1; // im StyleSheet On oder Off Record + BOOL bStyleOn : 1; // im StyleSheet On Record + BOOL bTxtInDoc : 1; // setze den akt. CharBuffer ins Dokument + BOOL bPageDefRdy : 1; // Flag, ob Page-Definition abgescholssen ist + BOOL bIsTxtInDoc : 1; // Flag, ob im Doc schon Text steht + // (leeren Absatz vor Tabelle erzeugen?) + BOOL bIsTxtInFNote : 1; // Kam schon Text (oder ein TAB) in dieser + // Fussnote? (der erste TAB in e. Fussnote + // wird naemlich jeweils uebersprungen) + BOOL bIsTxtInPara : 1; // Ist der Absatz nicht mehr leer ? + // Mogelei gegen leere Absaetze WW2 + // + Sicherheit, dass PageDesc nicht in leeren Abs. + BOOL bIsTxtInPgDesc : 1; // Flag, ob dieser PageDescriptor schon Text beinhaltet + // (ist die Erzeugung eines neuen Seitenlayouts noetig?) + BOOL bWasTxtSinceLastHF2 : 1; // Flag, ob Text seit HF2 bzw. Textbeginn + BOOL bWasTxtSinceLastHF1 : 1; // Flag, ob Text seit HF1 bzw. Textbeginn + BOOL bWasTxtSince_BREAK_PAGE : 1; // ob seit letztem HNP schon Text kam + // (Ist Pagebreak bei folgendem Pagedesc ueberfluessig?) + BOOL bWasHNPInPgDesc : 1; // Gab es in diesem PgDesc bereits .<HNP>-Kodes ? + // (wir verschlucken erstes .<HNP> in leerem PgDesc) + + BOOL bStyleOff : 1; // Flag, ob am Absatzende Default-Layout gesetzt werden muss + BOOL bBCMStep1 : 1; // Flag, ob .<BCM> die Tabelle zum 1. Mal liest + BOOL bBCMStep2 : 1; // Flag, ob .<BCM> die Tabelle zum 2. Mal liest + BOOL bNoExec : 1; // Flag, ob gerade Kommandos ausser "HFX" (Ende Kopf/Fusstext) + // ignoriert werden sollen + BOOL bSepar : 1; // nach (SEP) in der Style-Definition gesetzt + BOOL bPDFirstOnly : 1; // zuletzt angelegtes Seitenlayout gilt nur fuer 1. Seite + BOOL bIsNLN : 1; // ist nach (NLN) bis ca. Anfang des naechsten Textes gesetzt + BOOL bDefFontSet : 1; // ist bereits Default-Font gesetzt ? + BOOL bIsColMode : 1; // ist Column-Mode (z.B. eine Tabelle am entstehen) ? + BOOL bWasCellAfterCBreak:1; // FALSE, wenn 2 HCB nacheinander (ohne BCO ) + BOOL bWasPGNAfterPND : 1; + BOOL bTabBorder : 1; // Umrandung der Zellen in Tabelle + BOOL bTabSpezBorder : 1; // andere als Standart-Umrandung der Zellen in Tabelle + BOOL bCheckTabAppendMode:1; // Pruef-Flag fuer .<CDS> + BOOL bIsTabAppendMode : 1; // aktuelle Tabelle und vorher definierte Tabelle + // gehoeren zusammen und werden in EINE eingelesen + BOOL bIsSTYInTab : 1; // um Style glaubwuerdig zu simulieren + BOOL bIsColDefTab : 1; // Tabelle statt Mehrspaltigkeit + BOOL bPicPossible : 1; // hier kann eine Grafik stehen + BOOL bPic : 1; // Ein Bild ist erfolgreich eingelesen worden + BOOL bIsIpsInPara : 1; // beinhaltet dieser Absatz einen IPS-Befehl ? + // -> STM ignorieren + BOOL bToxOpen : 1; // in Tox + BOOL bPersAlign : 1; // persistent Alignment (BRJ) + BOOL bPgMgnChanged : 1; // Page Margin has changed + BOOL bWasXCS : 1; // Um nach XCS-Records 1 Zeichen zu ueberlesen + BOOL bWasSLG : 1; // 1. Laguage Group ist Default + BOOL bIgnoreNTB : 1; // nach Auftreten von RUL wird NTB ignoriert + + BOOL bWWWasRSM : 1; // 1. RSM wg. WW-Bug bescheissen + BOOL bIsTab : 1; // fuer AmiPro StyleDef virt. Tabs + + BOOL bWPWWasRSM : 1; // fuer WPWin-Import RSM-Sonderbehandlung + BOOL bSingleParaMgn : 1; // fuer WPWin-Import STM/IPS-Behandlung + + BOOL bIsSTMInPara : 1; // fuer WPWin-Import STM-Sonderbehandlung + BOOL bIsNumListPara : 1; // Absatz einer nummerierten Liste + + BOOL bSetPgWidth : 1; + BOOL bSetPgHeight : 1; + + BOOL bTabOwnFrm : 1; // Flag : eigenes FraneFmt fuer alle Zellen + + BOOL bNew : 1; // neues Dokument oder zufuegen + + BOOL bEndNoteInfoAlreadySet :1; + BOOL bFtnInfoAlreadySet :1; + BOOL bFootNoteNumberAutomatic:1; + BOOL bEndNoteNumberAutomatic :1; + BOOL bWasFootNoteOnW4WPage :1; + + BOOL bReadTxtIntoString :1; // :Flush() speichert dann *nicht* ins pDoc + + BOOL bNixNoughtNothingExec :1; // keinerlei Methoden werden ausgefuehrt + + + /* + Methoden + */ + BOOL ContinueHdFtDefinition( BOOL bFollow, long nLMarg, long nRMarg ); + void Read_HdFtDefinition( BOOL bHeader ); +// void Read_ColBrk(); + + void SetPamInCell( USHORT nRow, USHORT nCol, BOOL bSetPaM = TRUE ); + SwTableBox* UpdateTableMergeGroup( SwSelBoxes_SAR* pActGroup, + SwTableBox* pActBox, + USHORT nCol ); + + void Flush(); // speichert Buffer im Document + void FlushChar( sal_Unicode c ); + + // lese und bearbeiten den naechsten Record + int GetNextRecord(); + + // returnt W4WR_RED/W4WR_TXTERM wenn einstellige HexZahl, sonst 0 + // in rHexVal steht der gewandelte Hex-Wert + BYTE GetChar( BYTE& rHexVal ); + BYTE GetDeciByte( BYTE& rByteVal ); + BYTE GetHexByte( BYTE& rHexVal ); + BYTE GetHexUShort( USHORT& rHexVal ); + // returnt W4WR_RED/W4WR_TXTERM + // in rDecVal steht der gewandelte Decimal-Wert + BYTE GetDecimal( long& rDecVal ); + // ueberliest alles bis zum W4WR_TXTERM oder W4WR_RED (wird returnt) + + BOOL GetString( String& rString, const int nEndCode1, const int nEndCode2 ); + + BOOL GetNextName(); // liest Namen (inc. Sonderzchn.) in aCharBuffer ein + + SwPageDesc* CreatePageDesc( USHORT eCreateMode ); +// SwPageDesc& GetAktPgDsc(); + + BYTE SkipPara(); + BYTE SkipParaX(); + BYTE SkipEndRecord(); + + void StyleAnfang(); // liest StyleName und Id + + const SfxPoolItem* GetFmtAttr( USHORT nWhich ); + void SetAttr( const SfxPoolItem& rHint ); + void SetAttrOff( const SfxPoolItem& rHint ); + + // returnt den abs. Rand der Seite (SeitenRand+NodeRand) + long GetLeftMargin() const; + void Read_FootNoteStart(char Type, BYTE nNoLow, + BYTE nNoHigh, + USHORT FootNo); + void DeleteZStk( W4WCtrlStack*& rpStk ); + USHORT Read_SetBorder( USHORT nBor, SvxBoxItem& rFmtBox ); + USHORT Read_SetTabBorder( USHORT nW4WRow , USHORT nW4WCol , SvxBoxItem& rFmtBox ); + void Adjust_pTabDefs(); + BOOL GetULSpace( SvxULSpaceItem*& rpUL ); + BOOL GetLRULHint( const SfxPoolItem*& rpH, RES_FRMATR eTyp ); + void SetPageMgn(); + void DoSplit(); + void UpdateCacheVars(); + void SetPageDescVSpaces( SwPageDesc& rPageDesc, + W4W_UpdtPgMrgSet eCalledByWhom); + void UpdateHdFtMarginSettings( SwFrmFmt *pHdFmt, + long nHeight, + long nDelta, + BOOL bDoTheHeader ); + void AdjustTempVar1( long& rHeight, long& rPgDelta, + long& rHdFtDelta, long nIniHdFtSiz ); + void UpdatePageMarginSettings( W4W_UpdtPgMrgSet eCalledByWhom ); + void Read_IndentPara1(long nLeft, long n1st, long nRight); + + void FlySecur( BOOL bAlignCol, + long& rXPos, long& rYPos, long& rWidthTw, long& rHeightTw, + RndStdIds& rAnchor, long* pTop = 0, long* pLeft = 0, + long* pBot = 0, long* pRight = 0, USHORT nBorderCode = 0 ); + + void Read_HardAttrOff( USHORT nResId ); + + void ReadTabDefs( BYTE nCode, long nCols, W4W_ColdT* pActTabDefs ); + + SwFlyFrmFmt* MakeTxtFly( RndStdIds eAnchor, const SfxItemSet& ); + + void UpdatePercent( ULONG nPos, ULONG nFileSize ); + + void ActivateTxtFlags(); + + void SetFtnInfoIntoDoc( BOOL bEndNote, BYTE nRestart, BYTE nStyle, + String& rPrefixTxt, + String& rSuffixTxt ); + + void Read_ProcessHiddenText( BOOL bInline ); + void ProcessRecordInHiddenText(); + +public: + SwW4WParser( const SwPaM &, SvStream& rIstream, BOOL bNewDoc, //$ istream + USHORT nFilterNo, const String& rVersion ); + + BOOL CallParser(); + + BOOL IsNewDocument() { return bNew; } + SwDoc& GetDoc() const { return *pDoc; } // aktuelles Dokument + sal_Char ReadChar() { sal_Char c = 0; rInp.Read( &c, 1 ); return c; } + + USHORT GetAktCollId() { return nAktStyleId; } + void SetAktCollId( USHORT nId ) { nAktStyleId = nId; } + SwTxtFmtColl* GetAktColl( BOOL* pSetAttrFlag = 0 ) const; // hole die durch nAktStyleId angegebe Style + + void MakeUniqueStyleName( String& rName ); + + // die Read-Methoden fuer die verschiedenen Records + void Read_DefineDocumentType(); // zur Zeit Dummies + + void Read_UpperCharSet(); + void Read_ExtendCharSet(); + void Read_HardNewLine(); + void Read_SoftNewLine(); + void Read_SoftNewPage(); + void Read_HardNewPage(); + void Read_HardSpace(); + void Read_NewLineInPara(); + void Read_Tab(); + void Read_StyleTable(); + void Read_StyleEnd(); + void Read_StyleOn(); + void Read_StyleOff(); + void Read_DateTime(); + + // Read-Methoden fuer die Attribute + void Read_BeginBold(); + void Read_EndBold(); + void Read_BeginUnderline(); + void Read_EndUnderline(); + void Read_BeginItalic(); + void Read_EndItalic(); + void Read_BeginDoubleUnderline(); + void Read_EndDoubleUnderline(); + void Read_BeginSuperScript(); + void Read_EndSuperScript(); + void Read_BeginSubScript(); + void Read_EndSubScript(); + void Read_BeginColoredText(); + void Read_EndColoredText(); + void Read_NewTabTable(); + void Read_BeginFlushRight(); + void Read_EndFlushRight(); + void Read_BeginCenterText(); + void Read_EndCenterText(); + void Read_BeginRightJustify(); + void Read_EndRightJustify(); + void Read_IndentPara(); + void Read_BeginStrikeOut(); + void Read_EndStrikeOut(); + void Read_BeginShadow(); + void Read_EndShadow(); + + // Read-Methoden fuer die Fonts + void Read_SetPitchAndOrFont(); + void Read_FontDefTable(); + + // Read-Formatierungs Methoden + void Read_SetFormLenght(); + void Read_SetPageNumber(); + void Read_PageWidth(); + void Read_ReSetLeftRightMargin(); + void Read_SetTopMarginOfPage(); // STP + void Read_SetBottomMarginOfPage(); // SBP + void Read_HeaderTopMargin(); // HTM + void Read_HeadingMargin(); // HM + void Read_FooterBottomMargin(); // FBM + void Read_FooterMargin(); // FM + void Read_SetTempLeftRightMargin(); + void Read_FooterStart(); + void Read_HeaderStart(); + void Read_HeadFootEnd(); + void Read_PrintPageNo(); + void Read_PrintLastPageNo(); + void Read_Separator(); + void Read_SetLeftMarginRelease(); + void Read_FootNoteStart1(); + void Read_FootNoteStart2(); + void Read_FootNoteEnd(); + void Read_FootNoteInfo(); + void Read_EndSection(); + void Read_ColumnsDefinition(); + void Read_BeginColumnMode(); + void Read_EndColumnMode(); + void Read_BeginTabCell(); + void Read_BeginTabRow(); + void Read_ColumnBreak(); + void Read_ParaBorder(); + void Read_BeginAbsPosObj(); + void Read_EndAbsPosObj(); + void Read_Picture(); + void Read_PictureDef(); + void Read_IncludeGraphic(); + void Read_SetSpaceAfter(); + void Read_SetSpaceBefore(); + void Read_BeginMarkedText(); + void Read_EndMarkedText(); + void Read_HardHyphen(); + void Read_SoftHyphen(); + void Read_PageOrient(); + void Read_SetTray(); + void Read_Hex(); + void Read_BeginSmallCaps(); + void Read_EndSmallCaps(); + void Read_BeginUpperCaps(); + void Read_EndUpperCaps(); + void Read_SetRightMarginIndent(); + void Read_ReSetLineSpacing(); + void Read_StyleBasedOn(); + void Read_Split(); + void Read_NonBreakSpace(); + void Read_WidowOrphOn(); + void Read_WidowOrphOff(); + void Read_BeginKerning(); + void Read_EndKerning(); + void Read_BeginHyphen(); + void Read_EndHyphen(); + void Read_LangGroup(); + void Read_SysInfo(); + void Read_Ruler(); + void Read_SetUnderlineMode(); + + void Read_BeginHiddenText(); + void Read_EndHiddenText(); + void Read_CommentLine(); + + // Read-Methoden fuer nummerierte Listen + void Read_ParagraphNumber(); + void Read_EndOfParaNum(); + void Read_ParaNumberDef(); + + // besondere Methoden fuer FrameMaker - Dokumente !! + BOOL Read_Analyze_FLO_PDT(); + void Read_PageDefinitionTable(); + void Read_RectangleDefinitionTable(); + void Read_Flow(); + void Read_BeginTextFlow(); + void Read_EndTextFlow(); + void Read_TextRectangelId(); +}; + +typedef void (SwW4WParser:: *FNReadRecord)(); + +struct W4WRecord +{ + W4WRecType aRecType; // der ID-String fuer den Record + FNReadRecord fnReadRec; // Methode fuer diesen spez. Record +}; + + +ULONG GetW4WIniFlags( USHORT nFilterNo ); // auch fuer Writer + +struct W4WStyleIdTabEntry +{ + SwTxtFmtColl* pColl; // Pointer auf Writer-Collection, sobald + // angelegt. Beim Suchen 0, bis gefunden. + USHORT nStyleId; // W4W-Style-Id, nicht Writer-Id + BOOL bSetAttributes; // erlaubt, dass Attribute gesetzt werden duerfen + + // Bei Base-Tab (Style based on) ist alles etwas anders: + // pColl ist die Vorlage (Collection), die noch einen + // Verweis (SBO) nachgereicht bekommen muss. + // nStyleId ist die W4W-Style-Id, auf die verwiesen werden + // muss, sobald es diese gibt. + + + W4WStyleIdTabEntry( SwW4WParser& rParser, USHORT nId, + const sal_Unicode* pName ); + // ctor fuers suchen !! + W4WStyleIdTabEntry( USHORT nSeekId ) : nStyleId( nSeekId ), pColl(0), + bSetAttributes( TRUE ) {} + + inline BOOL operator==( const W4WStyleIdTabEntry&) const; + inline BOOL operator<( const W4WStyleIdTabEntry&) const; +}; +typedef W4WStyleIdTabEntry* W4WStyleIdTabEntryPtr; + + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/w4wstk.hxx b/binfilter/bf_sw/source/filter/inc/w4wstk.hxx new file mode 100644 index 000000000000..4ddef268dcf6 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/w4wstk.hxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _W4WSTK_HXX +#define _W4WSTK_HXX + +#include <bf_svtools/svarray.hxx> + +#include <bf_svtools/poolitem.hxx> + +#include <ndindex.hxx> +namespace binfilter { + +class SwW4WParser; +class SwDoc; +struct SwPosition; +class SwPaM; +class SwFlyFrmFmt; + +/* ------ Stack-Eintrag fuer die Attribute ----------- + * Es werden immer Pointer auf neue Attribute uebergeben. + */ + +struct W4WStkEntry +{ + SfxPoolItem * pAttr; // Format Attribute + SwNodeIndex nMkNode; + SwNodeIndex nPtNode; + xub_StrLen nMkCntnt; // Nachbildung von Mark() + xub_StrLen nPtCntnt; // Nachbildung von GetPoint() + BOOL bLocked : 1; + BOOL bCopied : 1; + BOOL bClosed : 1; // Zeigt ueber Child geschlossenes Attr. an. + BOOL bNeverIntoDoc : 1; // Dieser Entry soll nichts ins Doc sondern, + // nach dem Schliessen geloescht werden. + + W4WStkEntry( const SwPosition & rStartPos, + SfxPoolItem* pHt, + BOOL bInitCopied = FALSE, + BOOL bInitNID = FALSE ); + + ~W4WStkEntry(); + + void SetEndPos( const SwPosition & rEndPos ); + BOOL MakeRegion( SwPaM & rRegion ) const; + +private: + W4WStkEntry( const W4WStkEntry& rEntry ); // niemals aufrufen, nur Complier-Test +}; + +// ein Stack fuer die gesamten Text-Attribute +typedef W4WStkEntry* W4WStkEntryPtr; +SV_DECL_PTRARR(W4WCtrlStkEntries,W4WStkEntryPtr,5,10) + +class W4WCtrlStack : public W4WCtrlStkEntries +{ + SwW4WParser* pParser; + W4WCtrlStack* pParentStack; + +public: + W4WCtrlStack( SwW4WParser& rParser ); + W4WCtrlStack( W4WCtrlStack& rCpy, const SwPosition& rPos ); + ~W4WCtrlStack(); + + void NewAttr( const SwPosition& rPos, const SfxPoolItem & rAttr ); + + BOOL SetAttr( const SwPosition& rPos, USHORT nAttrId=0, + BOOL bTstEnde = TRUE, + BOOL bDoNotSetInDoc = FALSE ); + void SetAttrInDoc( SwPaM& rRegion, const W4WStkEntry& rEntry ); + void SetLockedAttrClosed( USHORT nAttrId ); + void SetEndForClosedEntries( const SwPosition& rPos ); + void StealAttr( const SwPosition& rPos, USHORT nAttrId = 0 ); + void StealWWTabAttr( const SwPosition& rPos ); + + SfxPoolItem* GetFmtStkAttr( USHORT nWhich, USHORT * pPos = 0 ); + const SfxPoolItem* GetFmtAttr( const SwPaM& rPaM, USHORT nWhich ); + BOOL IsAttrOpen( USHORT nAttrId ); +}; + + +// weitere Teile aus ehemaligem swrtf.hxx +class SwW4WStyle : public SfxPoolItem +{ +public: + USHORT nStyleId; + SwW4WStyle( USHORT nId ); + SwW4WStyle( const SwW4WStyle & rRTFFld ); + + // "pure virtual Methoden" vom SfxPoolItem + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const; + + USHORT GetStyleId() const { return nStyleId; } +}; + +class SwW4WAnchor : public SfxPoolItem +{ + SwFlyFrmFmt* pFlyFmt; +public: + SwW4WAnchor( SwFlyFrmFmt* pFlyFmt ); + SwW4WAnchor( const SwW4WAnchor& ); + + // "pure virtual Methoden" vom SfxPoolItem + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const; + + const SwFlyFrmFmt* GetFlyFmt() const { return pFlyFmt; } + SwFlyFrmFmt* GetFlyFmt() { return pFlyFmt; } +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx b/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx new file mode 100644 index 000000000000..ee0125a3b888 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/wrt_fn.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _WRT_FN_HXX +#define _WRT_FN_HXX + +#include "hintids.hxx" // fuer die Konstanten + +namespace binfilter { + +class SfxPoolItem; +class SfxItemSet; + +// einige Forward-Deklarationen +class SwFmt; +class SwNode; +class SwCntntNode; +class Writer; + + +/* 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 ); + + + + +} //namespace binfilter +#endif // _WRT_FN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/inc/wrtswtbl.hxx b/binfilter/bf_sw/source/filter/inc/wrtswtbl.hxx new file mode 100644 index 000000000000..1398bd6d2936 --- /dev/null +++ b/binfilter/bf_sw/source/filter/inc/wrtswtbl.hxx @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _WRTSWTBL_HXX +#define _WRTSWTBL_HXX + +#include <tools/solar.h> +#include <tools/color.hxx> +#include <bf_svtools/svarray.hxx> + +#include <orntenum.hxx> +#include <horiornt.hxx> +class Color; +namespace binfilter { + + +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 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 +{ + + + + + + + + +public: + static long GetBoxWidth( const SwTableBox *pBox ); + + + + + + +}; + + + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/lotus/lotpar.hxx b/binfilter/bf_sw/source/filter/lotus/lotpar.hxx new file mode 100644 index 000000000000..ac0c66ea39d2 --- /dev/null +++ b/binfilter/bf_sw/source/filter/lotus/lotpar.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __LOTPAR_HXX__ +#define __LOTPAR_HXX__ + +#include "fltbase.hxx" +class SvStream; +class String; +namespace binfilter { + +// einige Forward-Deklaratioen + +class SwPaM; +class SwDoc; + + +enum WKTyp { + WKUnknown = 0, // = unbekanntes Format + WKS, // = 1-2-3/1, 1-2-3/1A + WK1, // = 1-2-3/2 + WK3, // = 1-2-3/3 + WK4 // = 1-2-3/4 + }; + + +class SwLotusParser : public SwFilterBase +{ + int bNewDoc : 1; + + WKTyp eDateiTyp; + + // --------------------------------------------------------------- + void Bof(); // 0x00 + void Dimensions(); // 0x06 + void Blank1(); // 0x0C + void Integer1(); // 0x0D + void Number1(); // 0x0E + void Label1(); // 0x0F + void Formula1(); // 0x10 + // --------------------------------------------------------------- + void PutCell( USHORT nCol, USHORT nRow, short nVal ); + void PutCell( USHORT nCol, USHORT nRow, double fVal ); + void PutCell( USHORT nCol, USHORT nRow, const String &rText, + char cJusty ); + // --------------------------------------------------------------- + void Parse( void ); + void Init( void ); +public: + // Parameter bReadNewDoc gibt an, ob in ein bestehendes Dokument ein- + // gelesen wird. TRUE: in ein "neues" Dokument einfuegen. + SwLotusParser( SwDoc& rDoc, const SwPaM & rCrsr, SvStream& pIn, + int bReadNewDoc /*= TRUE*/, CharSet eQ ); + + ~SwLotusParser(); + + ULONG CallParser(); +}; + + + +} //namespace binfilter +#endif + // _EXLPAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/lotus/makefile.mk b/binfilter/bf_sw/source/filter/lotus/makefile.mk new file mode 100644 index 000000000000..a23e98b26412 --- /dev/null +++ b/binfilter/bf_sw/source/filter/lotus/makefile.mk @@ -0,0 +1,66 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +# makefile Verteiler + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_lotus + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw + +CXXFILES = \ + sw_lotpar.cxx \ + sw_lotimpop.cxx \ + sw_lotread.cxx + + +SLOFILES = \ + $(SLO)$/sw_lotpar.obj \ + $(SLO)$/sw_lotimpop.obj \ + $(SLO)$/sw_lotread.obj + + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/lotus/sw_lotimpop.cxx b/binfilter/bf_sw/source/filter/lotus/sw_lotimpop.cxx new file mode 100644 index 000000000000..1f9117b1024d --- /dev/null +++ b/binfilter/bf_sw/source/filter/lotus/sw_lotimpop.cxx @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdio.h> + +#include "hintids.hxx" + + +#include <bf_svx/adjitem.hxx> + +#include "doc.hxx" +#include "pam.hxx" +#include "swtable.hxx" +#include "lotpar.hxx" +#include "fltglbls.hxx" +namespace binfilter { + + + +// ----------------------------------------- SwLotusParser::Bof() - 0x00 - +void SwLotusParser::Bof() + { + USHORT nRev; + + Read( nRev ); + + if( nRev == 0x0404 ) + { + eDateiTyp = WKS; + eQuellChar = RTL_TEXTENCODING_IBM_437; + } + else if( nRev == 0x0406 ) + { + eDateiTyp = WK1; + eQuellChar = RTL_TEXTENCODING_IBM_437; + } + else + eDateiTyp = WKUnknown; + + } + +// ---------------------------------- SwLotusParser::Dimensions() - 0x06 - +void SwLotusParser::Dimensions() +{ + USHORT nCS, nCE, nRS, nRE; + + Read( nCS, nRS, nCE, nRE ); + + pLotGlob->ColLimitter( nCS ); // Cols/Rows in ihre Schranken verweisen + pLotGlob->ColLimitter( nCE ); + + pLotGlob->RowLimitter( nRS ); + pLotGlob->RowLimitter( nRE ); + + pLotGlob->SetRange( nCS, nCE, nRS, nRE ); +} + + +// --------------------------------------- SwLotusParser::Blank() - 0x0C - +void SwLotusParser::Blank1() +{ + BYTE nFormat; + USHORT nCol, nRow; + + Read( nFormat, nCol, nRow ); + +} + +// ------------------------------------ SwLotusParser::Integer1() - 0x0D - +void SwLotusParser::Integer1() +{ + BYTE nFormat; + USHORT nCol, nRow; + + Read( nFormat, nCol, nRow ); + + if( pLotGlob->IsInRange( nCol, nRow ) ) + { + short nValue; + + Read( nValue ); + + PutCell( nCol, nRow, nValue ); + //SetFormat( nCol, nRow, nTab, nFormat, 0 ); + } +} + +// ------------------------------------- SwLotusParser::Number1() - 0x0E - +void SwLotusParser::Number1() +{ + BYTE nFormat; + USHORT nCol, nRow; + + Read( nFormat, nCol, nRow ); + + if( pLotGlob->IsInRange( nCol, nRow ) ) + { + double fValue; + + Read( fValue ); + + PutCell( nCol, nRow, fValue ); + } +} + +// -------------------------------------- SwLotusParser::Label1() - 0x0F - +void SwLotusParser::Label1() +{ + BYTE nFormat; + USHORT nCol, nRow; + + Read( nFormat, nCol, nRow ); + + if( pLotGlob->IsInRange( nCol, nRow ) ) + { + sal_Char cPrefix; + String aLabel; + + ReadChar( cPrefix ); + Read( aLabel ); + + PutCell( nCol, nRow, aLabel, cPrefix ); + } +} + +// ------------------------------------ SwLotusParser::Formula1() - 0x10 - +void SwLotusParser::Formula1() + { + BYTE nFormat; + USHORT nCol, nRow; + + Read( nFormat, nCol, nRow ); + + + if( pLotGlob->IsInRange( nCol, nRow ) ) + { + double fValue; + + Read( fValue ); + + PutCell( nCol, nRow, fValue ); + // nFormat = Standard -> Nachkommastellen wie Float + //SetFormat( nCol, nRow, nTab, nFormat, nDezFloat ); + } + } + +//--------------------------------- SwLotusParser::PutCell( ..., short ) - +void SwLotusParser::PutCell( USHORT nCol, USHORT nRow, short nVal ) +{ + PutCell( nCol, nRow, String::CreateFromInt32( nVal ), '"' ); +} + +//-------------------------------- SwLotusParser::PutCell( ..., double ) - +void SwLotusParser::PutCell( USHORT nCol, USHORT nRow, double fVal ) +{ + + String sText(String::CreateFromFloat(fVal)); + xub_StrLen nLen = sText.Len(); + for (xub_StrLen nI = 0; nI < nLen; ++nI) + { + // Q&D tauschen ',' <-> '.' -> nur + // fuer deutsche Version brauchbar! + if( sText.GetChar(nI) == '.' ) + sText.SetChar(nI, ','); + else if( sText.GetChar(nI) == ',' ) + sText.SetChar(nI, '.'); + } + + PutCell( nCol, nRow, sText, '"' ); +} + +//-------------------------- SwLotusParser::PutCell( ..., String, char ) - +void SwLotusParser::PutCell( USHORT nCol, USHORT nRow, + const String &rText, sal_Char cJusty ) +{ + pLotGlob->Normalize( nCol, nRow ); + pLotGlob->InsertText( nCol, nRow, rText ); + + SvxAdjust eAdjust = SVX_ADJUST_LEFT; + switch( cJusty ) + { + case '"': // rechtsbuendig + eAdjust = SVX_ADJUST_RIGHT; + break; + case '^': // zentriert + eAdjust = SVX_ADJUST_CENTER; + break; + } + + pLotGlob->InsertAttr( SvxAdjustItem( eAdjust ) ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/lotus/sw_lotpar.cxx b/binfilter/bf_sw/source/filter/lotus/sw_lotpar.cxx new file mode 100644 index 000000000000..65ccc30e36f7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/lotus/sw_lotpar.cxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <errhdl.hxx> +#include <doc.hxx> +#include <swerror.h> +#include <fltglbls.hxx> +#include <fltini.hxx> +#include <lotpar.hxx> +#include <swfltopt.hxx> +namespace binfilter { + +LotGlob *pLotGlob = NULL; + + + + + +SwLotusParser::SwLotusParser( SwDoc &rD, const SwPaM & rCrsr, + SvStream& rInInit, int bReadNewDoc, + CharSet eQ ) + : bNewDoc( bReadNewDoc ) +{ + eQuellChar = eQ; + pIn = &rInInit; + pLotGlob = new LotGlob( rD, rCrsr ); + + nReadBuffSize = 2048; + pReadBuff = new char[ nReadBuffSize ]; + +// aColRowBuff.SetDefWidth( ( USHORT ) ( 9192 ) ); // 4 Zeichen Standardbreite +} + +SwLotusParser::~SwLotusParser() +{ + delete[] pReadBuff; + delete pLotGlob; + pLotGlob = NULL; +} + + +ULONG SwLotusParser::CallParser() +{ + static const sal_Char* aNames[4] = { + "Excel_Lotus/MinRow", "Excel_Lotus/MaxRow", + "Excel_Lotus/MinCol", "Excel_Lotus/MaxCol" + }; + sal_uInt32 aVal[4]; + SwFilterOptions aOpt( 4, aNames, aVal ); + + USHORT nMinRow = ( USHORT ) aVal[ 0 ]; + USHORT nMaxRow = ( USHORT ) aVal[ 1 ]; + USHORT nMinCol = ( USHORT ) aVal[ 2 ]; + USHORT nMaxCol = ( USHORT ) aVal[ 3 ]; + + USHORT nAnzNodes = 65000U - pLotGlob->pD->GetNodes().Count(); + + if( nMaxRow < nMinRow ) + { + USHORT nTemp = nMinRow; + nMinRow = nMaxRow; + nMaxRow = nTemp; + } + + if( nMaxCol < nMinCol ) + { + USHORT nTemp = nMinCol; + nMinCol = nMaxCol; + nMaxCol = nTemp; + } + + if( nMaxRow - nMinRow == 0 ) + nMaxRow = nMinRow + 30; // Default bei 0 Rows + + if( nMaxCol - nMinCol == 0 ) + nMaxCol = nMinCol + 15; // Default bei 0 Cols + + if( nAnzNodes < ( nMaxRow - nMinRow ) * ( nMaxCol - nMinCol ) * 3 ) + return ERR_EXCLOT_WRONG_RANGE; + + pLotGlob->SetRange( nMinCol, nMaxCol, nMinRow, nMaxRow ); // Default-Einstellung + + Parse(); + + return 0; // kein Fehler +} + + +ULONG LotusReader::Read( SwDoc &rDoc, SwPaM &rPam, + const String & /* FileName, falls benoetigt wird */ ) +{ + ULONG nRet; + if( !pStrm ) + { + ASSERT( FALSE, "Lotus-Read ohne Stream" ); + nRet = ERR_SWG_READ_ERROR; + } + else + { + SwLotusParser* pParser = new SwLotusParser( rDoc, rPam, *pStrm, + !bInsertMode, eCodeSet ); + nRet = pParser->CallParser(); // 0 == kein Fehler aufgetreten + delete pParser; + } + + return nRet; +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/lotus/sw_lotread.cxx b/binfilter/bf_sw/source/filter/lotus/sw_lotread.cxx new file mode 100644 index 000000000000..3fc7e8599f99 --- /dev/null +++ b/binfilter/bf_sw/source/filter/lotus/sw_lotread.cxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <tools/debug.hxx> + +#include "fltglbls.hxx" +#include "lotpar.hxx" +namespace binfilter { + + + +// ---------------------------------------------- SwLotusParser::Parse() - +void SwLotusParser::Parse( void ) +{ + USHORT nOpcode, nLen; + enum { SearchBof, SearchDim, InWKS, InWK1, Ende } eAkt; + BOOL bInTab = TRUE; + + eAkt = SearchBof; + while( eAkt != Ende ) + { + *pIn >> nOpcode >> nLen; + if( pIn->IsEof() ) + eAkt = Ende; + + nBytesLeft = nLen; + switch( eAkt ) + { + case SearchBof: // ---------------------------- + if( 0x00 == nOpcode ) + { + Bof(); + eAkt = SearchDim; + } + break; + case SearchDim: // ---------------------------- + if( 0x06 == nOpcode ) // DIMENSIONS [S1 ] + { + Dimensions(); + switch( eDateiTyp ) + { + case WKS: + eAkt = InWKS; + pLotGlob->CreateTable(); + break; + case WK1: + eAkt = InWK1; + pLotGlob->CreateTable(); + break; + case WKUnknown: + case WK3: + case WK4: + eAkt = Ende; break; + } + } + break; + case InWKS: // ---------------------------- + case InWK1: + { + switch( nOpcode ) + { + case 0x01: // EOF [S1 ] +//Leere Methode!! Eof(); + eAkt = Ende; + break; + case 0x0C: Blank1(); break; // BLANK [S1 ] + case 0x0D: Integer1(); break; // INTEGER [S1 ] + case 0x0E: Number1(); break; // NUMBER [S1 ] + case 0x0F: Label1(); break; // LABEL [S1 ] + case 0x10: Formula1(); break; // FORMULA [S1 ] + } + } + break; + + + case Ende: // --------------------------------- + break; + + default: + DBG_ERROR( "-SwLotusParser::Read(): Unbekannter Zustand!" ); + } + ClearBytesLeft(); + } +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/makefile.mk b/binfilter/bf_sw/source/filter/makefile.mk new file mode 100644 index 000000000000..971f02d4afac --- /dev/null +++ b/binfilter/bf_sw/source/filter/makefile.mk @@ -0,0 +1,71 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/.. +BFPRJ=..$/.. + +PRJNAME=binfilter +TARGET=sw_filter + +NO_HIDS=TRUE + +.IF "$(CALLTARGETS)"=="filter" +RC_SUBDIRS= +.ENDIF + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw +# --- Files -------------------------------------------------------- + + +SUBLIBS= \ + $(SLB)$/sw_ascii.lib \ + $(SLB)$/sw_basflt.lib \ + $(SLB)$/sw_writer.lib \ + $(SLB)$/sw_excel.lib \ + $(SLB)$/sw_lotus.lib \ + $(SLB)$/sw_w4w.lib \ + $(SLB)$/sw_xml.lib \ + $(SLB)$/sw_sw6.lib + +################################################################ + +LIB1TARGET=$(SLB)$/sw_filter.lib +LIB1FILES= \ + $(SUBLIBS) + +.INCLUDE : target.mk + +################################################################ + + diff --git a/binfilter/bf_sw/source/filter/sw6/makefile.mk b/binfilter/bf_sw/source/filter/sw6/makefile.mk new file mode 100644 index 000000000000..cce08fa7e1e5 --- /dev/null +++ b/binfilter/bf_sw/source/filter/sw6/makefile.mk @@ -0,0 +1,63 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_sw6 + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk + +INC+= -I$(PRJ)$/inc$/bf_sw +# --- Files -------------------------------------------------------- + +CXXFILES = \ + sw_sw6file.cxx \ + sw_sw6par.cxx + + +SLOFILES = \ + $(SLO)$/sw_sw6file.obj \ + $(SLO)$/sw_sw6par.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/sw6/sw6file.hxx b/binfilter/bf_sw/source/filter/sw6/sw6file.hxx new file mode 100644 index 000000000000..70523ce7105d --- /dev/null +++ b/binfilter/bf_sw/source/filter/sw6/sw6file.hxx @@ -0,0 +1,451 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SW6FILE_HXX +#define _SW6FILE_HXX + +#include <stdlib.h> + +#include <tools/string.hxx> + +#include <tools/stream.hxx> + +#include "swtypes.hxx" +#include "swerror.h" +namespace binfilter { + +class SwCharFmt; +class SwTxtFmtColl; + + +#define TWIPINCH 1440 // Wieviele Twips per Inch + +#define NVERSION '6' // Neue Versionsnummer +#define AVERSION '5' // Alte Versionsnummer + +#define KFEND "\7" +#define NOTENEND "\14" +#define MLDBOOJAJA "JA" +#define MLDBOONEIN "NEIN" +#define DOKUKENN ".\\\\\\ WRITER # \\\\\\" +#define DOKUKENNE ".\\\\\\ WRITER #E \\\\\\" +#define LAYOUTKENN ".\\\\\\ LAYOUT # \\\\\\" +#define LAYOUTKENNE ".\\\\\\ LAYOUT #E \\\\\\" + +#define MAXALAY 64 // Maximalanzahl Absatzlays +#define MAXSLAY 32 // Maximalanzahl Seitenlays +#define MAXBLAY 16 // Maximalanzahl Fontuebersetzungen +#define MAXTAB 32 // Maximale Anzahl Tabulatoren +#define MAXGLIED 5 // Wieviele Gliederungsebenen + +// Art der Nummerierung einer automatisch zu erzeugenden +// Zahl wie z.B. Seitenummer, Gliedernummer etc. + +enum NUMMERIERNG { + Arabisch,Roemisch,Grossbuch,Kleinbuch,Bullets +}; + +// Alle Steuerzeichen die vorkommen + +enum CTRLS { + PrGraf, // ^@ Praefix fuer Grafiksteuerzeichen + InhKenn, // ^A Zeichen fuer Inhaltsvz.-Kennzeichnung, ingnore + IdxKenn, // ^B Zeichen fuer Indexvz.-Kennzeichnung, ignore + PrtPause, // ^C Zeichen fuer Druckunterbrechung, ignore + PrSoftSp, // ^D Zeichen Praefix Softspace + SoftSp, // ^E Soft-Leerzeichen, ' ' + HardSp, // ^F Hartspace (wird nicht umbrochen) ,' ' + NewCol, // ^G Neue Spalte, ignore + BackSpc, // ^H Backspace-Steuerzeichen + TabZch, // ^I Tabulatorzeichen, Pfeil + NewLine, // ^J Neue Zeile + SoftK, // ^K Zeichen fuer k-c-Austausch bei Trennung, 'k' + NewPage, // ^L Neue Seite, ignore + NewPara, // ^M Neuer Absatz + PrSForm, // ^N Praefix harte Formatierung Seite + PrAForm, // ^O Praefix harte Formatierung Absatz + HTrenn, // ^P Hartes Trennzeichen (wird nicht umbrochen), '-' + PrMerker, // ^Q Versteckter Text fuer Merker + PrPrFix, // ^R Praefix-Praefix fuer spaetere Erweiterungen + SoftAdd, // ^S Zusatz-Zeichen Trennung von "Schiff-fahrt" + PrKomm, // ^T Praefix Textkommando + ParaGraf, // ^U Zeichen welches fuer Paragraf-Zeichen + PrGlied, // ^V Praefix fuer Gliederungsnummer + PrHidd, // ^W Praefix fuer Hidden Text + PrAttr, // ^X Praefix Attribut + PrSize, // ^Y Praefix Fontsize + NewText, // ^Z Textende + PrUser, // ^[ Praefix fuer User-Controlzeichen + PrFnote, // ^\ Praefix fuer Fussnotenkennzeichnung + PrEnote, // ^] Praefix fuer Endnotenkennzeichnung + PrFont, // ^^ Praefix Font + STrenn // ^_ Weiches Trennzeichen, '-' nur Zeilenende +}; + +// Fuers harte Seitenformat, 2. Steuerzeichen nach PrSForm + +enum AFORMTYP { + AF_Res, // Nichts + AF_Ein, // Einrueckung Twips + AF_Lks, // Linker Rand Twips + AF_Rts, // Rechter Rand Twips + AF_AbAb, // Absatzabstand Twips + AF_Form, // Absatzformat Enum + AF_SpAb, // Spaltenabstand Twips + AF_SpAn, // Spaltenanzahl Byte + AF_SAbs, // Spaltenabsatz Bool + AF_Auto, // Durchschuss Bool + AF_ZlAb, // Zeilenabstand Twips + AF_Glied, // Gliederungslay Enum + AF_Tab, // Tabulator alt Struct + AF_TabN, // Tabulator neu Struct + AF_Zus // Zusammenhalten +}; + +// Fuers harte Absatzformat, 2. Steuerzeichen nach PrAForm + +enum SFORMTYP { + SF_Res,SF_KoAb,SF_FuAb,SF_Lks,SF_Rts,SF_Obn,SF_Unt, + SF_SpAb,SF_Guel,SF_SpAn,SF_KoTx,SF_FuTx +}; + +// Art den Rahmen in Layouts oder harter Formatierung +// Dies sind eigentlich Bitflags mit (1 << Frm_xxx) + +enum FRMARTEN { + Frm_Lks,Frm_Rts,Frm_Obn,Frm_Unt,Frm_Frm,MaxFRMARTEN +}; + +// Bitflags Grafikrand + +struct GRAFFRAM { + int NoFrame:1; // Kein Rahmen + int Einfach:1; // Einfacher Rahmen + int Doppelt:1; // Doppelter Rahmen +}; + +// Bitflags Grafik + +struct GRAFFLAG { + int DoppelDruck:1; // Doppelt drucken + int InversDruck:1; // Invers drucken + int KeineGraust:1; // Keine Graustufen + int Kompatibel :1; // Kompatibel (siehe GRAFDESC) + int SGFHeller :1; // Grafik aufhellen (f. Laserdrucker) + int SGFBlkWhite:1; // Schwarz/Weiss erzwingen + int SGFRawform :1; // Wenn Grafik mit 256 Farben + int SGFFormel :1; // Wenn es eine Formel ist +}; + +// Ausrichtung einer Grafik + +enum GBUNDTYP { + G_Nicht,G_Links,G_Rechts,G_Zent +}; + +// Format einer Grafik (Je nach Treiber) + +enum GRAFSTAT { + NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf +}; + +// Writer Grafikdescribtor, steht direkt in der Textzeile +// Aus Kompatibilitaetsgruenden wird die Liniendicke nicht im GrafDesc +// aufgefuehrt. Wenn Bit3(Flags)=1 dann steht die Liniendicke hinter +// Name/UsrT als Wort im Grafdesc drin. LPos enthaelt evt. auch LWdt. + +struct GRAFDESC { + SwTwips Hoch; // Hoehe Grafik in Twips + SwTwips Breit; // Breite Grafik in Twips + SwTwips Rand; // Breite/Hoehe des Randes (zusaetzlich) + BYTE Rahm; // 1=Kein Rahmen, 2=Einfach, 3=Doppelt + GBUNDTYP Bund; // Nichtbuendig, Links, Rechts, Zent + GRAFSTAT Form; // Datenformat, welcher Treiber + BYTE Flag; // Bits:0=Dopp, 1=Invs, 2=NoGrau, Bit3=Kompatibel + String Name; // Enthaelt den Grafiknamen +}; + +// Ein Bitarray fuer Attribute, von denen die wichtigsten +// mal festgelegt wurden. Sonstige Attributte gibts nicht + +enum ATTRBITS { + Nix0,Fett,Kursiv,Unter,DUnter,Durch,DDurch, + Hoch,Tief,Nix1,Outl,Shad,OutShad,Invs,Hoch2, + Hoch4,Gross2,Gross4,Nix2,Nix3,Nix4,FRot, + FBlau,FMag,FGelb,FOrange,FGruen,FCyan, + ATTRBITS_END +}; + +typedef long ATTRS; + +// Schluesselbuchstaben und Anmerkung fuer Layouts + +struct RKEY { + String Key; // Tastenschluessel zum rufen + String Remark; // Anmerkungen des Benutzers +}; + +// Art der Tabs in Layouts oder harter Formatierung + +enum TABARTEN { + Tab_L,Tab_R,Tab_Z,Tab_D,Tab_LF,Tab_RF +}; + +// Ein Tabulator + +struct TABU { + TABARTEN TabArt; // Art des Tabulators + SwTwips TabPos; // Position Tab + sal_Char TabZch; // Fuellzeichen, #0 oder Spc fuer nix +}; + +// Ein Bereichslayout + +struct BLAY:RKEY { + SwCharFmt *pCharFmt; // Zeiger auf Fertige FmtColl zum Uebergeben + + short BFNum; // Nummer des Fonts + short BFSiz; // Hoehe des Fonts in Halbpunkt + BOOL bTran; // Sollen Zeichen uebersetzt werden? + ATTRS BAttr; // Welches Attribut anschalten +}; + +// Art der Formatierung in Layouts oder harter Formatierung. Tab- +// satz ist eine Satzform die nie in einer Datei stehen sollte. + +enum SATZTYP { + BlockSatz,LinksSatz,RechtsSatz,ZentrSatz, + AustrSatz,UnformSatz,SperrSatz,TabSatz +}; + +// Ein Absatzlayout + +struct ALAY:RKEY { + SwTxtFmtColl *pFmtColl; // Zeiger auf Fertige FmtColl zum Uebergeben + + short ABlay; // Welche Fontuebersetz, 0=Hart + short AFNum; // Nummer des Fonts + short AFSiz; // Hoehe des Fonts in Halbpunkt + BOOL bTran; // Sollen Zeichen uebersetzt werden? + ATTRS AAttr; // Welches Attribut anschalten + SwTwips Einzug; // Absatzeinzug in Spalten + SwTwips LRand; // Einrueckung lks in Spalten + SwTwips RRand; // Einrueckung rts in Spalten + SwTwips ORand; // Abstand vom Vorherg. Abs. + SwTwips SpaltAbst; // Abstand zw. den Spalten + BOOL SpTrenn; // Spaltentrenn + short SpAnzahl; // Wenn SpAbsatz>Spaltenzahl + BOOL SpAbsatz; // Ist Spaltenabsatz? + BOOL AutoZlAb; // Durchschuss oder Zlabstand + short ZlAbstand; // Zeilenabstand in Pt + short GliedLay; // 0=Nein, sonst Gliederebene + SATZTYP FormatFlg; // Format: Block,Rts/Lks,Zen,Unf. + SwTwips FrmAbst; // Abstand der Linien vom Absatz + SwTwips FrmWdth; // Strichstaerke Linien vom Absatz + short FrmArt; // Was fuer Linien, BitArray + short LinLTyp; // Gpm-Linienart + short LinRTyp; // Gpm-Rasterart + BOOL Zusammen; // Absatz zusammenhalten + short MaxTabs; // Wieviel gueltige Tabs + TABU Tabs[MAXTAB]; // Tabulatoren in Spalten +}; + +// Ein Seitenlayout + +struct SLAY:RKEY { + short Follow; // Merker fuer Follow-Layout + short Gueltig; // 0=alle,1=ung.,2=gerade S.,3=1.Seite + SwTwips KopfHoch; // Wieviel Zeilenhoehe Kopftext + SwTwips FussHoch; // Wieviel Zeilenhoehe Fusstext + SwTwips KopfAbst; // Abstand Kopftext + SwTwips FussAbst; // Abstand Fusstext + SwTwips LRand; // Textrand links + SwTwips RRand; // Textrand rechts + SwTwips ORand; // Textrand oben + SwTwips URand; // Textrand unten + SwTwips SpaltAbst; // Abstand zw. den Spalten + BOOL SpTrenn; // Spaltentrenner + short SpAnzahl; // Spaltenzahl Slayout + short KopfTNum; // Nummer harter KopfText, 0=Weicher + short FussTNum; // Nummer harter Fusstext, 0=Weicher + long FussText; // Weicher Kopftext + long KopfText; // Weicher Kopftext +}; + +struct KOFU:RKEY { + long KFText; // Dateipos fuer Kopf oder Fusstexte +}; + +// Describtor eines Gesamt Layouts des Writers V5.0-V6.0 + +struct LAYDESC { + BOOL FNotenFlg; // True=Dokumentweise + BOOL FNotenLin; // Soll Fussnotenstrich? + BOOL ANotenFlg; // Sollen Anmerkungen gedruckt? + SATZTYP FNotSForm; // Notenstrich (1=Lks,2=Rts,3=Zent) + short FNotSPerc; // Notenstrich-Prozente + SwTwips FNotURand; // Unterer Rand Fussnoten + short NumAlay; // Wieviele Alays? + short NumSlay; // Wieviele Slays? + short NumBlay; // Wieviele Fontuebersetzungen + short NumKopf; // Wieviele Kopftexte + short NumFuss; // Wieviele Fusstexte + long LastLayTm; // Vergleichsdatum Lay-Datei, 0=Kein Datum + long FNotenLink; // Zeiger auf Fussnotenzeilen + long ANotenLink; // Zeiger auf Anmerkungen + long ENotenLink; // Zeiger auf Endnotenzeilen + SwTwips SpTrennWd; // Strichstaerke Spaltentrenner Twips + SwTwips PapierLen; // . Papierlaenge + SwTwips PapierBrt; // . Papierbreite + NUMMERIERNG FNotenForm; // Wie FNotennummern? + NUMMERIERNG ENotenForm; // Wie ENotennummern? + NUMMERIERNG SeitenForm; // Wie Seitennummern? + NUMMERIERNG GliedForm[MAXGLIED]; // Wie Gliedernummern? + ALAY *FileAlay[MAXALAY]; // Alle Alays eines Textes + SLAY *FileSlay[MAXSLAY]; // Alle Slays eines Textes + BLAY *FileBlay[MAXBLAY]; // Alle Fontuebersetzungen + KOFU *HartKopf[MAXSLAY]; // Halter fuer den Kopftext + KOFU *HartFuss[MAXSLAY]; // Halter fuer den Fusstext + + void DelLayout(BOOL GLay,BOOL Kopf,BOOL Fuss); + + LAYDESC(void):NumAlay(0),NumSlay(0), + NumBlay(0),NumKopf(0),NumFuss(0) {} + ~LAYDESC(void) {DelLayout(TRUE,TRUE,TRUE);} +}; + +class Sw6Stack +{ + +private: + + struct DATA { + DATA *pNext; + size_t nSize; + } *pData; + void Clr(void); + +public: + + Sw6Stack(void):pData(NULL){}; + ~Sw6Stack(void){Clear();}; + BOOL Push(void *pSrce,size_t nMaxSize); + BOOL Get(void *pDest,size_t nMaxSize,size_t *pnSize=NULL); + BOOL Pop(void *pDest,size_t nMaxSize,size_t *pnSize=NULL); + void Clear(void); +}; + +class Sw6File +{ + +private: + + struct STAT + { + BOOL bEof; // TRUE wenn CtrlZ gelesen... + BOOL bErr; // Errorstatus ausgegeben? + BOOL bTrs; // Soll OEM->eDfltCharSet? + } aSta; + + struct BUFFR + { + size_t nMax; // Wieviele Byte im Puffer gltig + size_t nSiz; // Gr”áe des Puffers in pBuf + size_t nIdx; // Leseindex, wandert bis nMax + sal_Char *pBuf; // Zeiger auf Eingabepuffer + BUFFR(void):nMax(0),nSiz(0),nIdx(0),pBuf(NULL){}; + ~BUFFR(void){DELETEZ(pBuf);}; + }; + + BUFFR aBuf; // Buffer fuer Eingabe + BUFFR aPwd; // 2. Buffer wenn Passwort aktiv + + size_t nCtr; // Bei Ctrls: Max Anzahl der Zchn + SvStream *pInp; // Eingabesteam schon geoeffnet //$ istream + Sw6Stack aStk; // Fuer PushStat und PopStat + + short nLev; // Zur Begrenzung des Stacks + BYTE nBit; // 8 Bits fuer ReadBit + BYTE nOvl; // Overflow des Stacks? + + struct NODE + { + NODE *pLks; // Linker Zweig + NODE *pRts; // Rechter Zweig + BOOL bAst; // Ast oder Blatt? + BYTE cZch; // Falls !bAst dann Zeicheninhalt + } aNode; + + BOOL FlushPhys(short nAnz,BUFFR &rBuf); + BOOL Flush(short nAnz); // Sorgt f. nAnz chars bei pBuf[nIdx] + + BYTE ReadBit(BUFFR &rBuf); // Lese ein Bit ein + void ReadTree(NODE *pNode); // Lese den Huffman-Baum + void DelTree(NODE **ppNode); // L”schen des Baums + +protected: + + BOOL ActivatePass(void); + + ULONG *pErr; // Zeiger auf Errornummer + // virtual muss nicht mehr sein, es gibt nur noch den Parser! + virtual size_t PutRest(String &rStr,sal_Char *pCtrl) = 0; + /*virtual*/ void PushStat(long nFPos); // Merke des Status + /*virtual*/ void PopStat(void); // Wiederherstellen Status + +public: + + void SetTrans(BOOL bOn){aSta.bTrs=bOn;} // OEM-Translation Ein/Aus + BOOL IsTrans() const { return aSta.bTrs;} // OEM-Translation Ein/Aus + BOOL Eof(void) const; // Gibt TRUE zurck wenn End of File + long Tell(void) const; // Gibt die Fileposition zurck + void Seek(const long lWhere); // Sucht zu einer Fileposition + BOOL TestCtrl(sal_Char cZch); // Spezial:Test auf Ende Extratext + BOOL FileOk(void) // FALSE und 1*Error() wenn Fehler + { + if (!aSta.bErr && pInp->GetError() != SVSTREAM_OK) + { + *pErr = ERR_SW6_INPUT_FILE; + aSta.bErr=TRUE; + } + return !aSta.bErr; + } + BOOL ReadLn(String &rStr); // Lese eine PC-Zeile ein (CR/LF) + + Sw6File( // ctor + SvStream &rInp, // Input-Stream, mu?offen sein //$ istream + size_t nBufSize, // Lesepuffer-Groesse, mu?>0 sein + size_t nCtrSize, // Maximale L„nge Ctrl-Zeichenkette + ULONG *pErrno ); // Optionale Fehlernummer + ~Sw6File(void); // dtor +}; + + +} //namespace binfilter +#endif // _SW6FILE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/sw6/sw6par.hxx b/binfilter/bf_sw/source/filter/sw6/sw6par.hxx new file mode 100644 index 000000000000..2530af17d6b6 --- /dev/null +++ b/binfilter/bf_sw/source/filter/sw6/sw6par.hxx @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SW6PAR_HXX +#define _SW6PAR_HXX + + +#include <tools/string.hxx> +#include <vcl/vclenum.hxx> +#include <bf_svx/svxenum.hxx> + + +#include <toxe.hxx> +#include <sw6file.hxx> +namespace binfilter { + +class SfxPoolItem; + +class SwDoc; +class SwPaM; +class SwNodeIndex; +class SvxTabStopItem; + +class SwFmt; + +// Enthaelt die Dokument-Info. Groesse des Structs muss genau +// stimmen, wird beim Einlesen als Record verwendet... + +struct DOCINFOTYPE { + String Autor; // String fuer Autorennamen + String Kateg; // Kategorie zum Suchen + String Thema[4]; // Thematik-String + String Keys[4]; // Allerlei Schluesselworte +}; + +// Die Funktion ReadLn filtert alle harten Formatsteuerzeichen +// raus und legt sie in einer Verketteten Liste ab. Diese Liste +// kann man nach ReadLn dann durchgehen und bearbeiten. + +struct HFORM { + HFORM *pNxt; // Naechste Info + USHORT nOfs; // Offset des Textes wo Info gueltig + USHORT nXtd; // Gemerkter Addierer bei Druckzchn + BYTE cDat[256]; // Daten fuer diese Info +}; + + +class Sw6Layout:public Sw6File +{ + +private: + const String *pMyName; // Mein Filename fuer Dateirefs + + struct MYSTAT + { + BYTE cFrst; // Falls nur CtrlL oder CtrlG + short nAlay; // Status der Layouts bei ReadLn + BOOL bSlay; // Soll neues Slay gesetzt werden? + short nSLft; // Nummern fr linke Seitenlayouts + short nSRgt; // dto. fr rechtes Seiten + short nSFst; // Erstseitenlayout + short nBlay; + short nKopf; + short nFuss; + USHORT nPage; // Pagenummer fuer Gerade/Ungerade + short nAddo; // Adder fuer HFORM-nOfs + HFORM *pFrmt; // Fuer harte Forminfo aus ReadLn + MYSTAT (void): + cFrst('\0'),nAlay(0),bSlay(FALSE), + nSLft(0),nSRgt(0),nSFst(0), + nBlay(0),nKopf(0),nFuss(0), + nPage(0),nAddo(0),pFrmt(NULL){} + } aSta; + + BOOL Glieder[5]; // Welche Giederebenen genutzt + + Sw6Stack aStk; // Stack fuer Push/Popstat + LAYDESC *pLay; // Halter fuer Gesamtlayout + DOCINFOTYPE *pDocInfo; // Allgemeine Dokument-Info + USHORT nLastFontMatch; + + + BOOL ReadBool(void); + void DelHForm(void); + void AddHForm(const sal_Char *pCtrl,short nPos,short nAnz,short nAdd=0); + short ZchnZahl(sal_Char Ch1,sal_Char Ch2) const; + + sal_Char UpCaseOEM(sal_Char c) const; + void AddXForm(sal_Char cLead,ByteString &rTmp,String &rStr); + + void ScanLayoutB(short &rnLay,BLAY *pKey[],const sal_Char c1, + const sal_Char c2,const short nAnz) const; + void ScanLayoutA(short &rnLay,ALAY *pKey[],const sal_Char c1, + const sal_Char c2,const short nAnz) const; + void ScanLayoutS(short &rnLay,SLAY *pKey[],const sal_Char c1, + const sal_Char c2,const short nAnz) const; + void ScanLayoutKF(short &rnLay,KOFU *pKey[],const sal_Char c1, + const sal_Char c2,const short nAnz) const; + BOOL ScanKreuz(const sal_Char *pPatt,const sal_Char *pOrig,size_t &rIgnr,sal_Char *pPara=NULL); + BOOL TextBefehl(const sal_Char *pPatt,const sal_Char *pOrig); + + SvxAdjust TransAdj(SATZTYP eForm); + SfxPoolItem *TransAtt(ATTRBITS eAttr,BOOL bEin,SwTwips nSiz); + void TransFnt(short nFnt,FontFamily &rFam,FontPitch &rPit,CharSet &rSet,String &rNam); + BOOL TransFSA(SwFmt &rFmt, short nFnt, short nSiz, ATTRS nAtt); + + void InsertTOX(SwDoc &rDoc,SwPaM &rPaM,USHORT nLen,HFORM *pTmp,TOXTypes eTyp); + void InsertTab(USHORT nTab,TABU &rTab,SvxTabStopItem &rTabs,SwTwips nKor); + void InsertExtra(SwDoc &rDoc,SwPaM &rPaM,const SwNodeIndex &rWohin,long lFPos,sal_Char *pcAKey=NULL); + BOOL InsertNote(SwDoc &rDoc,SwPaM &rPaM,USHORT nNote,BOOL bFuss); + void InsertAttr(SwDoc &rDoc,SwPaM &rPaM,ATTRBITS eAttr,BOOL bEin,SwTwips nSiz); + void InsertAForm(SwDoc &rDoc,SwPaM &rPaM,BYTE *pCtrl); + void SetFollow(short nVon,short nNach,SwDoc &rDoc); + + // virtual muss nicht mehr sein, es gibt nur noch den Parser! + virtual size_t PutRest(String &rStr,sal_Char *pCtrl); + /*virtual*/ void PushStat(long nFPos); + /*virtual*/ void PopStat(void); + +protected: + + long lLin; // Mitlaufende Zeilenzahl (in ReadLn++) + + void SetSlay(SwDoc &rDoc,SwPaM &rPaM); + BOOL TstSlay(void) {return aSta.bSlay;} + +public: + + /*virtual*/ BOOL ReadLn(String &rStr); + + enum Bereich {Kopf,Fuss,FNot,ENot,ANot,Text}; + + void MerkeNoten(Bereich eNot); + void SetGpmFile(const String& rGpm); + void SetAlayTrans(void); + void ResetLay(SwDoc &rDoc); + void SetDocInfo(DOCINFOTYPE *pInfo) {pDocInfo=pInfo;} + BOOL IgnExtra(BOOL bNote,short nAnzl=0,SwTwips *plHoch=NULL); + BOOL LeseKoFu(BOOL Kopf); + BOOL LeseLayInfo(BOOL Konv); + + SwTxtFmtColl *GetAlay(void); // Holt die gerade gueltige FmtColl + void InsertLayouts(SwDoc &rDoc,SwPaM*); + BOOL InsertLine(SwDoc &rDoc,SwPaM &rPam,String &rStg,BOOL bLast=FALSE); + + BOOL Sw6LayoutOk(void) + { + return (pLay!=NULL); + } + Sw6Layout(SvStream &rInp, ULONG *pErrno, const String *pFileName=NULL); //$ istream + ~Sw6Layout(void); +}; + +// Gesamter Describtor einer Datei + +struct DATEIDESC { + String LayName; // Layoutdateiname + String PassWord; // Passwort fuer Datei + DOCINFOTYPE DocInfo; // Allgemeine Dokument-Info +}; + +// einige Forward-Deklaratioen +class SwPaM; +class SwDoc; +class SwSw6Parser:private Sw6Layout +{ + +private: + DATEIDESC *pDat; // Dateidescribtor + SwPaM *pPaM; // WriterG-Einfuegepos + SwDoc *pDoc; // WriterG-Dokumentzugriff + BOOL bNew; // Darf es was neues sein? + + BOOL Ueberlese(const long Blk); + BOOL ReadDocInfo(void); + +public: + BOOL CallParser(void); + + SwSw6Parser(SwDoc *pSwDoc,const SwPaM &rSwPaM,SvStream *pIstream, + BOOL bNewDoc, ULONG * pErrno, const String *pFileName ); + ~SwSw6Parser(void); +}; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/sw6/sw_sw6file.cxx b/binfilter/bf_sw/source/filter/sw6/sw_sw6file.cxx new file mode 100644 index 000000000000..a48807fd58f7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/sw6/sw_sw6file.cxx @@ -0,0 +1,442 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <string.h> +#include "errhdl.hxx" + +#include "sw6file.hxx" +namespace binfilter { + + +// --- LAYDESC --- + +void LAYDESC::DelLayout(BOOL GLay,BOOL Kopf,BOOL Fuss) +{ + short Idx; + + if (GLay) + { + for (Idx=0; Idx<NumAlay; Idx++) + if (FileAlay[Idx]) + DELETEZ(FileAlay[Idx]); + NumAlay=0; + for (Idx=0; Idx<NumSlay; Idx++) + if (FileSlay[Idx]) + DELETEZ(FileSlay[Idx]); + NumSlay=0; + for (Idx=0; Idx<NumBlay; Idx++) + if (FileBlay[Idx]) + DELETEZ(FileBlay[Idx]); + NumBlay=0; + } + if (Kopf) + { + for (Idx=0; Idx<NumKopf; Idx++) + if (HartKopf[Idx]) + DELETEZ(HartKopf[Idx]); + NumKopf=0; + } + if (Fuss) + { + for (Idx=0; Idx<NumFuss; Idx++) + if (HartFuss[Idx]) + DELETEZ(HartFuss[Idx]); + NumFuss=0; + } +} + +// --- Sw6Stack --- + +void Sw6Stack::Clr(void) +// loescht oberstes Element +{ + DATA *pOld=pData; + pData=pData->pNext; + delete (sal_Char *)pOld; +} + +BOOL Sw6Stack::Push(void *pSrce,size_t nMaxSize) +// Kopiert ein Element auf den Stack drauf +{ + if (pSrce && nMaxSize) + { + DATA *pOld=pData; + if ((pData=(DATA *)new // Hole neues Element und falls + sal_Char[sizeof(*pData)+ // dies ok war, stelle auf Stack + nMaxSize])!=NULL) + { + pData->pNext=pOld; + pData->nSize=nMaxSize; + register sal_Char *q=(sal_Char *)pSrce; + register sal_Char *p=(sal_Char *)pData+sizeof(*pData); + while (nMaxSize--) *p++=*q++; + return TRUE; + } + else pData=pOld; + } + return FALSE; +} + +BOOL Sw6Stack::Get(void *pDest,size_t nMaxSize,size_t *pnSize) +// Kopiert Element nach *pDest mit maximal nMaxSize +// Bytes. *pnSize enthaelt dann tatsaechliche Anzahl +{ + if (pDest && nMaxSize && pData) + { + if (pnSize) *pnSize=pData->nSize; + if (nMaxSize>pData->nSize) nMaxSize=pData->nSize; + register sal_Char *p=(sal_Char *)pDest; + register sal_Char *q=(sal_Char *)pData+sizeof(*pData); + while (nMaxSize--) *p++=*q++; + return TRUE; + } + return FALSE; +} + +BOOL Sw6Stack::Pop(void *pDest,size_t nMaxSize,size_t *pnSize) +// Holt Element nach *pDest und loescht es vom Stack +{ + if (Get(pDest,nMaxSize,pnSize)) + { + Clr(); + return TRUE; + } + return FALSE; +} + +void Sw6Stack::Clear(void) +// Loescht den Stack komplett +{ + while (pData) Clr(); +} + +// --- Sw6File --- + +void Sw6File::PushStat(long nFPos) +// Merke des Status +{ + long nPos=nFPos; + + if (nPos>=0) + { + nPos=Tell(); + Seek(nFPos); + } + aStk.Push(&nPos,sizeof(nPos)); + aStk.Push(&aSta,sizeof(aSta)); +} + +void Sw6File::PopStat(void) +// Wiederherstellen Status +{ + long nPos; + aStk.Pop(&aSta,sizeof(aSta)); + aStk.Pop(&nPos,sizeof(nPos)); + + if (nPos>=0) Seek(nPos); +} + +BOOL Sw6File::FlushPhys(short nAnz, BUFFR &rBuf) +// Holt immer nAnz Zeichen nach pStr[nIdx], egal wie der Puf- +// ferstand aus ist. Aufruf mit nAnz==0 dient zum Input-Flush +{ + if (rBuf.nIdx+nAnz>=rBuf.nMax) + { + ASSERT(rBuf.nIdx<=rBuf.nMax,"Sw6-Datei ist wohl defekt"); + + if (rBuf.nMax<rBuf.nIdx) + { + rBuf.nMax=rBuf.nIdx; // Datei war Schrott... + } + memmove(rBuf.pBuf, + &rBuf.pBuf[rBuf.nIdx], // Gewnschte Zeichen runter- + nAnz=rBuf.nMax-rBuf.nIdx); // schieben und Rest dazulesen + rBuf.nIdx=0; // Leseindex im Puffer auf 0 + + //$ pInp->clear(pInp->rdstate()&~ios::eofbit); // Kein EOF + pInp->ResetError(); + ULONG lGCount = pInp->Read(&rBuf.pBuf[nAnz],rBuf.nSiz-nAnz); + rBuf.pBuf[rBuf.nMax=nAnz+lGCount]='\x1A'; + if (!FileOk()) return FALSE; + if (rBuf.nMax<rBuf.nSiz-nAnz) // Nicht alles gelesen? + { + //$ pInp->clear(pInp->rdstate() & ~ios::failbit); // Kein Fail-Bit + pInp->ResetError(); + } + } + return TRUE; +} + +BOOL Sw6File::Flush(short nAnz) +{ + if (aPwd.pBuf) + { + if (aBuf.nIdx+nAnz>=aBuf.nMax) + { + memmove(aBuf.pBuf, + &aBuf.pBuf[aBuf.nIdx], + nAnz=aBuf.nMax-aBuf.nIdx); + aBuf.nIdx=0; + for (aBuf.nMax=0; aBuf.nMax< + aBuf.nSiz-nAnz; aBuf.nMax++) + { + NODE *pNode=&aNode; + while (pNode->bAst) + { + pNode=(ReadBit(aPwd)==0)? + pNode->pLks:pNode->pRts; + } + aBuf.pBuf[nAnz+aBuf.nMax]=pNode->cZch; + if (aPwd.nMax==0) + { + break; // Nothalt fuer EOF + } + } + } + return TRUE; + } + else return FlushPhys(nAnz,aBuf); +} + +BOOL Sw6File::Eof(void) const +// Gibt TRUE zurck wenn End of File erreicht +{ + return aBuf.pBuf?aBuf.pBuf[aBuf.nIdx]=='\x1A':pInp->IsEof(); +} + +long Sw6File::Tell(void) const +// Gibt die Fileposition zurck +{ + return pInp->Tell()+aBuf.nIdx-aBuf.nMax; +} + +void Sw6File::Seek(const long lWhere) +// Sucht zu einer Fileposition +{ + pInp->Seek(lWhere); + aBuf.nIdx=aBuf.nMax=0; + Flush(0); +} + + +BYTE Sw6File::ReadBit(BUFFR &rBuf) +// Lese genau 1 Bit ein +{ + BYTE nRet = (nBit&0x80) !=0 ; + nBit=(nBit&0x7f)<<1; + + if (nBit==0) + { + FlushPhys(1,rBuf); + nBit=rBuf.pBuf[rBuf.nIdx]; + nRet=(nBit&0x80)!=0; + nBit=((nBit&0x7f)<<1)+1; + rBuf.nIdx++; + } + return nRet; +} + +void Sw6File::DelTree(NODE **ppNode) +{ + if (*ppNode) + { + DelTree(&(*ppNode)->pLks); + DelTree(&(*ppNode)->pRts); + delete *ppNode; + } +} + +void Sw6File::ReadTree(NODE *pNode) +{ + if (nLev<256 && nOvl==0) + { + nLev++; + if (ReadBit(aBuf)==0) + { + pNode->pLks=new NODE; + pNode->pRts=new NODE; + pNode->bAst=TRUE; + if (pNode->pLks && pNode->pRts) + { + ReadTree(pNode->pLks); + ReadTree(pNode->pRts); + } + else nOvl=2; + } + else + { + pNode->pLks=NULL; + pNode->pRts=NULL; + pNode->bAst=FALSE; + pNode->cZch=0; + for (USHORT n=0; n<8; n++) + { + pNode->cZch=(pNode-> + cZch<<1)+ReadBit(aBuf); + } + } + nLev--; + } + else nOvl=1; +} + +BOOL Sw6File::ActivatePass(void) +// Lese Codebaum und setze ReadLn um +{ + Flush(3); + if (aBuf.pBuf[aBuf.nIdx+0]==NewPara && + aBuf.pBuf[aBuf.nIdx+1]==NewLine && + aBuf.pBuf[aBuf.nIdx+2]==NewText) + { // Es werden CR/LF/EOF erwartet + aBuf.nIdx+=3; + nBit=0; + nLev=0; + nOvl=0; + ReadTree(&aNode); + nBit=0; // Fuers Lesen nochmal Reset Bitlesen + if (nOvl==0) + { + aPwd.nMax=aBuf.nMax; + aPwd.nSiz=aBuf.nSiz; + aPwd.nIdx=aBuf.nIdx; + aPwd.pBuf=aBuf.pBuf; + aBuf.nMax=0; + aBuf.nIdx=0; + if ((aBuf.pBuf=new sal_Char[aBuf.nSiz+1])==NULL) + { + aBuf.nMax=aPwd.nMax; + aBuf.nSiz=aPwd.nSiz; + aBuf.nIdx=aPwd.nIdx; + aBuf.pBuf=aPwd.pBuf; + aPwd.pBuf=NULL; + } + else return Flush(0); + } + } + return FALSE; +} + +BOOL Sw6File::TestCtrl(sal_Char cZch) +// Spezial:Test auf Ende Extratext +// ob cZch und ^M^J gleich kommen! +{ + Flush(3); // Teste die naechsten 3 Zchn + return aBuf.pBuf[aBuf.nIdx+0]==cZch && + aBuf.pBuf[aBuf.nIdx+1]==NewPara && + aBuf.pBuf[aBuf.nIdx+2]==NewLine; +} + + +BOOL Sw6File::ReadLn(String &rStr) +// Lese eine PC-Zeile ein (CR/LF) +{ + rStr.Erase(); // String ist leer + while (FileOk()) // Solange kein Fehler auftrat + { + register BYTE *p = (BYTE *)&aBuf.pBuf[aBuf.nIdx], *pStt = p; + while (*p>'#' || *p>=' ' && *p<'#') + p++; + + xub_StrLen nAsc = p - pStt; + if( nAsc ) + { + rtl_TextEncoding eEnc = aSta.bTrs ? RTL_TEXTENCODING_IBM_850 + : gsl_getSystemTextEncoding(); + rStr += String( (sal_Char*)pStt, nAsc, eEnc ); + + aBuf.nIdx += nAsc; + } + switch (aBuf.pBuf[aBuf.nIdx]) + { + case NewPara: + aBuf.nIdx++; // NewPara annehmen + Flush(1); // Sicherstellen das 1 Zchn da ist + if (aBuf.pBuf[aBuf.nIdx]==NewLine) + { + aBuf.nIdx++; + return TRUE; + } + break; + case NewLine: + aBuf.nIdx++; // Zeichen annehmen + Flush(0); // Einfach ignorieren + break; + case NewText: + if (aBuf.nIdx<aBuf.nMax) + { // Eof bleibt im Puffer + return TRUE; // erhalten und liefert + } // ab hier Leerzeilen + Flush(0); + break; + default: + Flush(nCtr); // Test ob es nCtr Zeichen gibt + aBuf.nIdx+=PutRest( // Zchn annehmen, Ignore Anzahl Zchn + rStr,&aBuf.pBuf[aBuf.nIdx]); + } // switch + } // while + return FALSE; +} + + +Sw6File::Sw6File( SvStream &rInp, size_t nBufSize, size_t nCtrSize, + ULONG *pErrno ) +// ctor, allokiert Puffer und merkt sich den +// offenen Stream, von dem der Input kommt. +{ + pInp=&rInp; + pErr = pErrno; + nCtr=nCtrSize; + aSta.bErr=FALSE; + aSta.bTrs=FALSE; + aSta.bEof=pInp->IsEof(); + aBuf.nSiz=nBufSize; + if (aBuf.nSiz && aBuf.nSiz> // Puffergr”áe==0 unzul„ssig + nCtr && (aBuf.pBuf=new // nSiz<Ctrl-SSize ebenfalls + sal_Char[aBuf.nSiz+1])!=NULL) + { + Flush(0); // Lese nun den Puffer voll + } + aNode.bAst=TRUE; + aNode.pLks=NULL; + aNode.pRts=NULL; +} + +Sw6File::~Sw6File(void) +// dtor, gibt den Filepuffer wieder frei +{ + DelTree(&aNode.pLks); + DelTree(&aNode.pRts); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/sw6/sw_sw6par.cxx b/binfilter/bf_sw/source/filter/sw6/sw_sw6par.cxx new file mode 100644 index 000000000000..47d7ed7fc0d8 --- /dev/null +++ b/binfilter/bf_sw/source/filter/sw6/sw_sw6par.cxx @@ -0,0 +1,5596 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER +#include <hintids.hxx> + +#include <bf_svtools/pathoptions.hxx> +#include <bf_svtools/fstathelper.hxx> +#include <bf_svtools/urihelper.hxx> +#include <bf_sfx2/docinf.hxx> +#include <bf_sfx2/app.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/brkitem.hxx> +#include <bf_svx/lspcitem.hxx> +#include <bf_svx/adjitem.hxx> +#include <bf_svx/spltitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/tstpitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/escpitem.hxx> +#include <bf_svx/cntritem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/colritem.hxx> + + +#include <fmtpdsc.hxx> +#include <fmtftn.hxx> +#include <txtftn.hxx> +#include <fmtfld.hxx> +#include <fmtfsize.hxx> +#include <fmthdft.hxx> +#include <fmtcntnt.hxx> +#include <fmtcntnt.hxx> +#include <fmtfsize.hxx> +#include <fmtornt.hxx> +#include <fmthbsh.hxx> +#include <fchrfmt.hxx> +#include <frmatr.hxx> +#include <charatr.hxx> +#include <ftninfo.hxx> +#include <charfmt.hxx> +#include <pam.hxx> +#include <doc.hxx> +#include <ndtxt.hxx> +#include <fldbas.hxx> +#include <paratr.hxx> +#include <docufld.hxx> +#include <flddat.hxx> +#include <dbfld.hxx> +#include <fmtcol.hxx> +#include <linetype.hxx> +#include <pagedesc.hxx> +#include <fltini.hxx> +#include <poolfmt.hxx> + +#ifdef __BORLANDC__ + #pragma warn -lvc +#endif + +#include <sw6par.hxx> +#include <tox.hxx> +#include <SwStyleNameMapper.hxx> +#include "bf_so3/staticbaseurl.hxx" +#include "linetype.hxx" +namespace binfilter { + +#ifdef __BORLANDC__ + #pragma warn +lvc +#endif + + + +// Globals ****************************************************************** + + static const SwLineType __FAR_DATA aLineTypeArr[] = + { + // In Out Dist + LIN_0, LIN_1, LIN_0, // Einfache Linien + LIN_0, LIN_2, LIN_0, + LIN_0, LIN_3, LIN_0, + LIN_0, LIN_5, LIN_0, + LIN_1, LIN_1, LIN_2, // Doppelte Linien + LIN_2, LIN_2, LIN_2, // Doppelte Linien + LIN_3, LIN_3, LIN_3, + LIN_3, LIN_2, LIN_2, + LIN_2, LIN_3, LIN_2, + LIN_4, LIN_3, LIN_3, + LIN_3, LIN_4, LIN_3 + }; + + +// ************************************************************************** + + + + const SwLineType& GetLineType(USHORT nIdx) + { + return aLineTypeArr[nIdx]; + } + + + +#define SW6_MATCH_FONTNAMES_CNT 558 +static const sal_Char* aFontNames[ SW6_MATCH_FONTNAMES_CNT ] = { + /* 0 */ "Draft", + /* 1 */ "Courier", + /* 2 */ "Courier PS", + /* 3 */ "LinePrtR8", + /* 4 */ "CourierR8", + /* 5 */ "Pica", + /* 6 */ "OCR-B", + /* 7 */ "OCR-A", + /* 8 */ "Emphasis", + /* 9 */ "Kana", + /* 10 */ "Hebrew", + /* 11 */ "Elite", + /* 12 */ "Prestige", + /* 13 */ "Script", + /* 14 */ "Letter_Gothic", + /* 15 */ "Narrator", + /* 16 */ "Titan", + /* 17 */ "Bold_PS", + /* 18 */ "Cubic_PS", + /* 19 */ "Trend_PS", + /* 20 */ "Roman_PS", + /* 21 */ "Script_PS", + /* 22 */ "Gothic_PS", + /* 23 */ "Gothic", + /* 24 */ "Gothic PS", + /* 25 */ "Prestige PS", + /* 26 */ "Prestige_NLQ", + /* 27 */ "Quadro", + /* 28 */ "Gothik", + /* 29 */ "Prestige_PS", + /* 30 */ "Sans Serif", + /* 31 */ "Symbol", + /* 32 */ "Roman", + /* 33 */ "Super Grande", + /* 34 */ "Brougham", + /* 35 */ "Sans Serif PS", + /* 36 */ "Script PS", + /* 37 */ "Quadro PS", + /* 38 */ "Roman PS", + /* 39 */ "Super Grande PS", + /* 40 */ "Brougham PS", + /* 41 */ "Quadro_NLQ", + /* 42 */ "Gothik_NLQ", + /* 43 */ "Anelia_PS", + /* 44 */ "Quadro_PS", + /* 45 */ "Brougham_PS", + /* 46 */ "Letter Gothik", + /* 47 */ "Bother Helvetica PS", + /* 48 */ "PS Schrift", + /* 49 */ "Brother Times Roman PS", + /* 50 */ "Brougham12", + /* 51 */ "PS LQ", + /* 52 */ "OCR-B_LQ401", + /* 53 */ "Gothik_LQ401", + /* 54 */ "Gothik_LQ400", + /* 55 */ "Brougham_LQ400", + /* 56 */ "Anelia_PS_LQ400/401", + /* 57 */ "OCR-B_LQ_401", + /* 58 */ "Gothik_LQ_400", + /* 59 */ "Gothik_LQ_401", + /* 60 */ "Brougham_LQ_400", + /* 61 */ "Letter Gothic", + /* 62 */ "Sans Serif II", + /* 63 */ "BR-02H", + /* 64 */ "Roman II", + /* 65 */ "BR-01T", + /* 66 */ "BR-03B", + /* 67 */ "Br-01T", + /* 68 */ "Br-02H", + /* 69 */ "Line Printer", + /* 70 */ "Lori PS", + /* 71 */ "Br-01T bold", + /* 72 */ "Br-01T italic", + /* 73 */ "Br-02H bold", + /* 74 */ "Br-02H italic", + /* 75 */ "BR-01H", + /* 76 */ "Letter GothicIBM", + /* 77 */ "BroughamIBM", + /* 78 */ "Mars8", + /* 79 */ "BR-11U (Univers)", + /* 80 */ "BR01-T (CG Times)", + /* 81 */ "LetterGothicIBM", + /* 82 */ "LetterGothic", + /* 83 */ "PrestigeElite", + /* 84 */ "HELVETICA", + /* 85 */ "Helvetica", + /* 86 */ "BrotherHelv", + /* 87 */ "TimesRoman", + /* 88 */ "BrotherTimes", + /* 89 */ "AneliaPSIBM", + /* 90 */ "LoriPSIBM", + /* 91 */ "LineDrawU", + /* 92 */ "Anelia PS", + /* 93 */ "Orator", + /* 94 */ "OratorS", + /* 95 */ "Typenrad", + /* 96 */ "Pica_NLQ", + /* 97 */ "Pica_PS", + /* 98 */ "Pica_NLQ_PS", + /* 99 */ "OCR", + /* 100 */ "Italic", + /* 101 */ "Courier_PS", + /* 102 */ "Kassettenschrift", + /* 103 */ "Letter Gothic PS", + /* 104 */ "Courier_LQ", + /* 105 */ "Prestige_Elite", + /* 106 */ "LQ", + /* 107 */ "NLQ_PS", + /* 108 */ "LQ Display", + /* 109 */ "Display PS", + /* 110 */ "Times Roman", + /* 111 */ "Times Roman PS", + /* 112 */ "CourierIBM", + /* 113 */ "LetterGothik", + /* 114 */ "Quality", + /* 115 */ "NLQ", + /* 116 */ "Pica10", + /* 117 */ "High-SpeedDraft", + /* 118 */ "Scientific DQ Cart", + /* 119 */ "Scientific LQ Cart", + /* 120 */ "Scientific CQ Cart", + /* 121 */ "Compression", + /* 122 */ "Courier10", + /* 123 */ "PrestigeElite12", + /* 124 */ "Correspondence", + /* 125 */ "Letter Gothic LQ Cart", + /* 126 */ "Draft PS", + /* 127 */ "Pica10 PS", + /* 128 */ "High-SpeedDraft PS", + /* 129 */ "Compression PS", + /* 130 */ "Boldface PS", + /* 131 */ "Courier10 PS", + /* 132 */ "PrestigeElite12 PS", + /* 133 */ "Correspondence PS", + /* 134 */ "Proportional", + /* 135 */ "SansSerif", + /* 136 */ "SansSerif PS", + /* 137 */ "Roman NLQ PS", + /* 138 */ "Draft_NLQ", + /* 139 */ "Draft_PS", + /* 140 */ "Script LQ", + /* 141 */ "OCR B", + /* 142 */ "Script C PS", + /* 143 */ " OratorS", + /* 144 */ "Sans Serif H", + /* 145 */ "Roman T", + /* 146 */ "High-Speed Draft", + /* 147 */ "Scientific DQ", + /* 148 */ "Scientific LQ", + /* 149 */ "Scientific CQ", + /* 150 */ "Prestige Elite", + /* 151 */ "Old English", + /* 152 */ "Humanist", + /* 153 */ "Dutch", + /* 154 */ "High-Speed Draft PS", + /* 155 */ "Prestige Elite PS", + /* 156 */ "Humanist PS", + /* 157 */ "Dutch PS", + /* 158 */ "Tile", + /* 159 */ "Primus", + /* 160 */ "Title PS", + /* 161 */ "Fontkassette", + /* 162 */ "EDP_Resident", + /* 163 */ "Courier_Resident", + /* 164 */ "Courier_Download", + /* 165 */ "LegalCourier_Download", + /* 166 */ "LetterGothic_Download", + /* 167 */ "Prestige_Download", + /* 168 */ "LegalPrestige_Download", + /* 169 */ "HelvPS_Download", + /* 170 */ "CourierPS_Resident", + /* 171 */ "TMS_RomanPS_Download", + /* 172 */ "Legal EDP 13", + /* 173 */ "Courier_Outline", + /* 174 */ "SansSerif_Outline", + /* 175 */ "Roman_Outline", + /* 176 */ "Symbol_Outline", + /* 177 */ "Univers", + /* 178 */ "Atlantic", + /* 179 */ "Sans", + /* 180 */ "Challenge", + /* 181 */ "Sans Condensed", + /* 182 */ "Classico", + /* 183 */ "Milano", + /* 184 */ "Office", + /* 185 */ "Pentagon", + /* 186 */ "Avanti", + /* 187 */ "Classic", + /* 188 */ "Finish", + /* 189 */ "Hilton", + /* 190 */ "Ovetti", + /* 191 */ "Progress", + /* 192 */ "Westcoast", + /* 193 */ "Calculator", + /* 194 */ "Cescendo", + /* 195 */ "Console", + /* 196 */ "Funky", + /* 197 */ "NEWYORK", + /* 198 */ "Nova", + /* 199 */ "Paisley", + /* 200 */ "Shanghai", + /* 201 */ "Skyline", + /* 202 */ "Speed", + /* 203 */ "XPRESS", + /* 204 */ "CG Times", + /* 205 */ "PS Roman", + /* 206 */ "Booklet", + /* 207 */ "Centuri", + /* 208 */ "Paltus", + /* 209 */ "Tapir", + /* 210 */ "Greek", + /* 211 */ "Cyrillian", + /* 212 */ "WingDings", + /* 213 */ "LinePrtIBM", + /* 214 */ "Univers Condensed", + /* 215 */ "Arial", + /* 216 */ "Antique Olive", + /* 217 */ "Times New", + /* 218 */ "Garamond", + /* 219 */ "CG Omega", + /* 220 */ "Coronet", + /* 221 */ "Marigold", + /* 222 */ "Clarendon Condensed", + /* 223 */ "Albertus", + /* 224 */ "Wingdings", + /* 225 */ "SansCondensed", + /* 226 */ "PS-Roman", + /* 227 */ "Courier 6", + /* 228 */ "Courier 12", + /* 229 */ "Presentation 7 Cart_M", + /* 230 */ "Presentation 8 Cart_M", + /* 231 */ "Presentation 9 Cart_M", + /* 232 */ "Presentation 14 Cart_M", + /* 233 */ "Presentation 16 Cart_M", + /* 234 */ "Presentation 18 Cart_M", + /* 235 */ "CG Triumvirate Cart_CB", + /* 236 */ "CG Triumvirate Bold Cart_CB", + /* 237 */ "Prestige 5 Cart_B", + /* 238 */ "Prestige 7 Cart_B", + /* 239 */ "Prestige 10 Cart_B", + /* 240 */ "Letter Gothic 6", + /* 241 */ "Letter Gothic 12", + /* 242 */ "Letter Gothic 12 Cart_C", + /* 243 */ "Courier 24 Cart_L", + /* 244 */ "Letter Gothic 6 Cart_L", + /* 245 */ "Letter Gothic 7 Cart_M", + /* 246 */ "Letter Gothic 9.5 Cart_C", + /* 247 */ "Letter Gothic 12 Cart_L", + /* 248 */ "Letter Gothic 14 Cart_M", + /* 249 */ "Letter Gothic 19 Cart_L", + /* 250 */ "Letter Gothic 24 Cart_L", + /* 251 */ "CG Century Cart_CB", + /* 252 */ "Helvetica Cart_G", + /* 253 */ "Helvetica Cart_H", + /* 254 */ "Helvetica Cart_J", + /* 255 */ "Helvetica Cart_T", + /* 256 */ "Helvetica Cart_V", + /* 257 */ "Brush Cart_CE", + /* 258 */ "Dom Casual Cart_CD", + /* 259 */ "Times Roman Cart_R", + /* 260 */ "Garamond Antiqua Cart_CC", + /* 261 */ "Garamond Halbfett Cart_CC", + /* 262 */ "Times Roman Cart_U", + /* 263 */ "Letter2 Gothic 14 Cart_M", + /* 264 */ "Helvetica Softfont", + /* 265 */ "Times Roman Softfont", + /* 266 */ "Helv_AD/AF", + /* 267 */ "TmsRmn_AD/AF", + /* 268 */ "TimesNewRoman", + /* 269 */ "PS", + /* 270 */ "Font", + /* 271 */ "Pica_D", + /* 272 */ "Proportional_LQ", + /* 273 */ "HelveticaBold", + /* 274 */ "Times", + /* 275 */ "LinePrinter", + /* 276 */ "Courier_Footnote", + /* 277 */ "Courier Footnote", + /* 278 */ "ARIAL", + /* 279 */ "ARIAL Narrow", + /* 280 */ "ITC Avant Garde", + /* 281 */ "ITC Bookman", + /* 282 */ "Century Schoolbook", + /* 283 */ "Zapf Calligraphic", + /* 284 */ "ITC Zapf Chancery", + /* 285 */ "Sans Serif LQ", + /* 286 */ "Orator gro\xE1", + /* 287 */ "Orator klein", + /* 288 */ "Courier LQ", + /* 289 */ "Sans Serif NLQ PS", + /* 290 */ "Courier NLQ PS", + /* 291 */ "Sans_Serif_LQ", + /* 292 */ "San_Serif_NLQ_PS", + /* 293 */ "Courier_NLQ_PS", + /* 294 */ "LQ San Serif", + /* 295 */ "Optimo", + /* 296 */ "LQ Helvetica", + /* 297 */ "LQ Orator I", + /* 298 */ "Code 39", + /* 299 */ "LQ Orator II", + /* 300 */ "LQ OCR-B", + /* 301 */ "LQ OCR-A", + /* 302 */ "LQ Script", + /* 303 */ "LQ Courier", + /* 304 */ "LQ Prestige", + /* 305 */ "LQ Letter Gothic", + /* 306 */ "LQ Times Roman", + /* 307 */ "LQ TW Light", + /* 308 */ "Cinema", + /* 309 */ "LQ Blippo", + /* 310 */ "PS San Serif", + /* 311 */ "PS Helvetica", + /* 312 */ "PS Orator I", + /* 313 */ "PS Orator II", + /* 314 */ "PS Courier", + /* 315 */ "PS Prestige", + /* 316 */ "PS Letter Gothic", + /* 317 */ "PS Times Roman", + /* 318 */ "PS TW Light", + /* 319 */ "PS Blippo", + /* 320 */ "S.Bern", + /* 321 */ "S.Roman", + /* 322 */ "S.Bern PS", + /* 323 */ "Orator PS", + /* 324 */ "S.Roman PS", + /* 325 */ "HQ", + /* 326 */ "Elite_D", + /* 327 */ "Schrift-Art 1", + /* 328 */ "Schrift-Art 2", + /* 329 */ "Schrift-Art 3", + /* 330 */ "Schrift-Art 4", + /* 331 */ "Schrift-Art 5", + /* 332 */ "Draft Gothik", + /* 333 */ "Quick Gothik", + /* 334 */ "Prestige Elite WP", + /* 335 */ "Helvette PS", + /* 336 */ "Bold PS", + /* 337 */ "Times PS", + /* 338 */ "Souvenier", + /* 339 */ "Superfocus", + /* 340 */ "LQ PS", + /* 341 */ "Ext.Font", + /* 342 */ "Pica LQ", + /* 343 */ "Pica HD", + /* 344 */ "Elite LQ", + /* 345 */ "Elite HD", + /* 346 */ "PS HD", + /* 347 */ "Draft_Gothik", + /* 348 */ "Fast Focus 10", + /* 349 */ "Fast Focus 12", + /* 350 */ "Pr._Elite", + /* 351 */ "ITC_Souvenir", + /* 352 */ "LQ Font Cartridges", + /* 353 */ "Pica/Draft", + /* 354 */ "Pica_HS", + /* 355 */ "PS_LQ", + /* 356 */ "PS_LQ(hoch/tief)", + /* 357 */ "OCR B 702", + /* 358 */ "OCR A 702", + /* 359 */ "Bar Code 39 702", + /* 360 */ "UPC / EAN 702", + /* 361 */ "Super Focus 707", + /* 362 */ "Helvette ASCII 701", + /* 363 */ "Helvette Greek-Math 701", + /* 364 */ "Prestige Pica 708", + /* 365 */ "Letter Gothic 703", + /* 366 */ "Letter Gothic 707", + /* 367 */ "Letter Gothic 14 P. 703", + /* 368 */ "ITC Souvenir", + /* 369 */ "Times ASCII 701", + /* 370 */ "Times Greek-Math 701", + /* 371 */ "Helvette PS 18 P. 705", + /* 372 */ "Helvette PS 24 P. 705", + /* 373 */ "Bold Italic PS 708", + /* 374 */ "Times PS 18 P. 704", + /* 375 */ "Times PS 24 P. 704", + /* 376 */ "ITC Bookman 10 P. 706", + /* 377 */ "ITC Bookman 18 P. 706", + /* 378 */ "ITC Bookman 24 P. 706", + /* 379 */ "Helvetica PS", + /* 380 */ "Helvetica PS Scale", + /* 381 */ "Times PS Scale", + /* 382 */ "Helvette_PS", + /* 383 */ "Times_PS", + /* 384 */ "NLQ##", + /* 385 */ "HS_Draft", + /* 386 */ "Helvette", + /* 387 */ "Prestige Cart", + /* 388 */ "Letter Gothic Cart", + /* 389 */ "Schrift Cart", + /* 390 */ "Hevette PS", + /* 391 */ "Fontkassette LQ", + /* 392 */ "Courier_LQ_PS", + /* 393 */ "Utility", + /* 394 */ "Gothik_LQ", + /* 395 */ "Helvette_LQ", + /* 396 */ "Bold_LQ", + /* 397 */ "Prestige_LQ", + /* 398 */ "Roman_LQ", + /* 399 */ "Gothik_PS", + /* 400 */ "Draft HS", + /* 401 */ "Helvette LQ", + /* 402 */ "OCR-B Cassette", + /* 403 */ "OCR-A Cassette", + /* 404 */ "Roman LQ", + /* 405 */ "Prestige LQ", + /* 406 */ "Letter Gothic LQ", + /* 407 */ "Helvette LQ PS", + /* 408 */ "Courier LQ PS", + /* 409 */ "Roman LQ PS", + /* 410 */ "Prestige LQ PS", + /* 411 */ "Letter Gothic LQ PS", + /* 412 */ "Cassettenschrift", + /* 413 */ "Draft_HS", + /* 414 */ "Fontkassette_LQ", + /* 415 */ "HelveticaBold_S2", + /* 416 */ "TimesRoman_S2", + /* 417 */ "LinePrinterIBM", + /* 418 */ "Helvetic", + /* 419 */ "TimesRomanCompr.", + /* 420 */ "LinePrinterR8", + /* 421 */ "Pica NLQ", + /* 422 */ "Proportional LQ", + /* 423 */ "Letter Gothic 6", + /* 424 */ "Letter Gothic 12", + /* 425 */ "Letter Gothic 4\xAC", + /* 426 */ "Letter Gothic 9\xAB", + /* 427 */ "Times Nordic Cart E", + /* 428 */ "Courier Cart 1", + /* 429 */ "Prestige Elite Cart 1", + /* 430 */ "Letter Gothic Cart 6", + /* 431 */ "Prestige Elite Cart 7", + /* 432 */ "ARIAL R8 Cart 2", + /* 433 */ "ARIAL R8 Cart 5", + /* 434 */ "ARIAL R8 Cart 8", + /* 435 */ "ARIAL R8", + /* 436 */ "Dutch R8 Cart 3", + /* 437 */ "Dutch R8 Cart 5", + /* 438 */ "Dutch R8 Cart 8", + /* 439 */ "Dutch R8", + /* 440 */ "Century 702", + /* 441 */ "NLQ PS", + /* 442 */ "Elite NLQ", + /* 443 */ "Pica PS", + /* 444 */ "Pica PS NLQ", + /* 445 */ "Datenschrift", + /* 446 */ "Font Card", + /* 447 */ "BOLD", + /* 448 */ "BOLD PS", + /* 449 */ "Outline", + /* 450 */ "Century", + /* 451 */ "Letter_Gothic_PS", + /* 452 */ "Typenrad PS", + /* 453 */ "IC-Font", + /* 454 */ "Hoch-Tief-Schrift", + /* 455 */ "Roman Script", + /* 456 */ "Roman Script PS", + /* 457 */ "Font 3", + /* 458 */ "Font 1", + /* 459 */ "Font 2", + /* 460 */ "Font 3 PS", + /* 461 */ "Font 1 PS", + /* 462 */ "Font 2 PS", + /* 463 */ "Helvetica-Narrow", + /* 464 */ "AvantGarde-Book", + /* 465 */ "Times-Roman", + /* 466 */ "Bookman-Light", + /* 467 */ "NewCentury-SchlbkRoman", + /* 468 */ "Palatino-Roman", + /* 469 */ "ZapfChancery-MediumItalic", + /* 470 */ "P_LQ", + /* 471 */ "P_NLQ", + /* 472 */ "Elite_LQ", + /* 473 */ "Elite_NLQ", + /* 474 */ "Corpora_LQ", + /* 475 */ "Corpora_NLQ", + /* 476 */ "Cubic_PS_LQ", + /* 477 */ "Cubic_PS_NLQ", + /* 478 */ "Cubic_Mini_PS_LQ", + /* 479 */ "Cubic_Mini_PS_NLQ", + /* 480 */ "S.Helv", + /* 481 */ "S.Helvetica", + /* 482 */ "S.Helvetica PS", + /* 483 */ "Gothic 12", + /* 484 */ "TW-Light", + /* 485 */ "San Serif PS", + /* 486 */ "TW-Light PS", + /* 487 */ "Cinema PS", + /* 488 */ "Orator_gro\xE1", + /* 489 */ "Orator_klein", + /* 490 */ "Orator_LQ", + /* 491 */ "Script_LQ", + /* 492 */ "OPTIONAL_LQ *", + /* 493 */ "Orator_PS", + /* 494 */ "OPTIONAL_PS *", + /* 495 */ "GothicR8", + /* 496 */ "Helvet", + /* 497 */ "TimesIBM", + /* 498 */ "PS_NLQ", + /* 499 */ "Draft Hoch", + /* 500 */ "LQ Roman", + /* 501 */ "LQ H-GOTHIC", + /* 502 */ "LQ Roman PS", + /* 503 */ "LQ Orator", + /* 504 */ "LQ Optimo", + /* 505 */ "LQ Courier Hoch", + /* 506 */ "SLQ Times Roman", + /* 507 */ "LQ TW-Light", + /* 508 */ "SLQ TW-Light", + /* 509 */ "Cassetten-Schrift", + /* 510 */ "LQ Greek", + /* 511 */ "LQ Cinema", + /* 512 */ "LQ Helvetica PS", + /* 513 */ "LQ Orator PS", + /* 514 */ "LQ Optimo PS", + /* 515 */ "LQ Courier PS", + /* 516 */ "LQ Pestige PS", + /* 517 */ "LQ Letter Gothic PS", + /* 518 */ "LQ Times Roman PS", + /* 519 */ "SLQ Times Roman PS", + /* 520 */ "LQ TW-Light PS", + /* 521 */ "SLQ TW-Light PS", + /* 522 */ "LQ Cinema PS", + /* 523 */ "LQ Blippo PS", + /* 524 */ "LQ Bar Code 39", + /* 525 */ "SLQ Script", + /* 526 */ "LQ Orane (Optimo)", + /* 527 */ "SLQ Roman", + /* 528 */ "LQ H-Gothic (Helvet)", + /* 529 */ "LQ Sanserif", + /* 530 */ "LQ H-Gothic (Helvet) PS", + /* 531 */ "LQ Orane (Optimo) PS", + /* 532 */ "LQ Prestige PS", + /* 533 */ "SLQ Roman PS", + /* 534 */ "LQ Sanserif PS", + /* 535 */ "LQ Times-Roman", + /* 536 */ "SLQ Times-Roman", + /* 537 */ "PS Sanserif", + /* 538 */ "PS Script", + /* 539 */ "PS Times-Roman", + /* 540 */ "PS TW-Light", + /* 541 */ "Optionaler Font", + /* 542 */ "PrestigeElite PS", + /* 543 */ "Kleinschrift", + /* 544 */ "Schnellschrift", + /* 545 */ "Font_4", + /* 546 */ "Font_5", + /* 547 */ "Font_6", + /* 548 */ "Font_7", + /* 549 */ "Deutsch mit Serifen", + /* 550 */ "IBM mit Serifen", + /* 551 */ "German Courier 10 (B8156-01)", + /* 552 */ "Deutsch ohne Serifen", + /* 553 */ "IBM ohne Serifen", + /* 554 */ "Deutsch mit Serifen PS", + /* 555 */ "IBM mit Serifen PS", + /* 556 */ "Deutsch ohne Serifen PS", + /* 557 */ "IBM ohne Serifen PS" +}; + +static const struct Sw6PrinterFont +{ + USHORT nFontNo, nFontNmNo; + FontFamily eFamily; + sal_Bool bPCFont, bFixPitch; +} + a5000DI[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aACERLP75[] = { + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aAEG200I[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBJ10E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBJ130E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBJ300[] = { + { 2, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 24, FAMILY_SWISS, sal_True, sal_False }, + { 98, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1109[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 26, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1209[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 28, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1224L[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 99, 29, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1324[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 6, 31, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 33, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 77, 36, FAMILY_SWISS, sal_True, sal_False }, + { 80, 37, FAMILY_SWISS, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_True }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 24, FAMILY_ROMAN, sal_True, sal_False }, + { 108, 39, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 40, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1409[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 41, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 26, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 42, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1509[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 41, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 26, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 42, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1709[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 41, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 26, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 42, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1724L[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 80, 44, FAMILY_SWISS, sal_True, sal_False }, + { 99, 29, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 45, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR1824L[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 6, 31, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 46, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 33, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 47, FAMILY_SWISS, sal_True, sal_False }, + { 77, 36, FAMILY_SWISS, sal_True, sal_False }, + { 99, 48, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 49, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR2024[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 58, 50, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 51, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR2518[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 52, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 53, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 54, FAMILY_ROMAN, sal_True, sal_True }, + { 58, 55, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 56, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR3524L[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 28, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBR4018[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 57, FAMILY_ROMAN, sal_True, sal_True }, + { 31, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 58, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 59, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 60, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 43, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBRHJ770[] = { + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 33, FAMILY_ROMAN, sal_True, sal_True }, + { 58, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 62, FAMILY_SWISS, sal_True, sal_False }, + { 66, 63, FAMILY_SWISS, sal_True, sal_False }, + { 97, 64, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 65, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 66, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBRHL4[] = { + { 1, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 67, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 68, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 46, FAMILY_ROMAN, sal_True, sal_True }, + { 6, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 7, 69, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 70, FAMILY_ROMAN, sal_True, sal_True }, + { 9, 67, FAMILY_ROMAN, sal_True, sal_True }, + { 10, 71, FAMILY_ROMAN, sal_True, sal_True }, + { 11, 72, FAMILY_ROMAN, sal_True, sal_True }, + { 12, 68, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 73, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 69, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 67, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 71, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 72, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 68, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 73, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 74, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 65, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 75, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBRHL48V[] = { + { 1, 76, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 77, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 65, 79, FAMILY_SWISS, sal_True, sal_False }, + { 97, 80, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBRHL8DB[] = { + { 1, 77, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 81, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 84, FAMILY_SWISS, sal_True, sal_False }, + { 66, 85, FAMILY_SWISS, sal_True, sal_False }, + { 67, 86, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 88, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 89, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 90, FAMILY_ROMAN, sal_True, sal_False }, + { 128, 91, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBRHR[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aBROTHER[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 27, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 58, 34, FAMILY_ROMAN, sal_True, sal_True }, + { 80, 37, FAMILY_SWISS, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 24, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 40, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 92, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCANONBJX[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 94, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 36, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCE500[] = { + { 1, 95, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCE700[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIE_210E[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 96, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 97, FAMILY_SWISS, sal_True, sal_False }, + { 66, 98, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIE_310E[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 96, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 99, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 100, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 97, FAMILY_SWISS, sal_True, sal_False }, + { 66, 98, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIE_610E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 101, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIE_610P[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 102, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 35, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 103, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIE_715E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 105, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 101, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIT120D[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 106, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 107, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIT120DP[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 106, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 108, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 107, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 109, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCIT124D[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 110, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 111, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aCITOH52[] = { + { 1, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 66, 85, FAMILY_SWISS, sal_True, sal_False }, + { 67, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aD_630[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aD_630E[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aD_630HZ[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aDICO150[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 114, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aDICO300I[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 25, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 114, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aDLP[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 116, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 117, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 118, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 119, FAMILY_ROMAN, sal_True, sal_True }, + { 24, 120, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 121, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 122, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 123, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 124, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 125, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 66, 127, FAMILY_SWISS, sal_True, sal_False }, + { 67, 128, FAMILY_SWISS, sal_True, sal_False }, + { 78, 129, FAMILY_SWISS, sal_True, sal_False }, + { 80, 130, FAMILY_SWISS, sal_True, sal_False }, + { 97, 131, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 132, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 133, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aDLQ[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 106, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aDMP[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 134, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPLQ800[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPLX800[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPSFX[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 135, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 66, 136, FAMILY_SWISS, sal_True, sal_False }, + { 98, 137, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPSFX100[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 138, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPSFX80[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 138, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPSLQ[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 94, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 140, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 36, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aEPSRX[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 138, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aESCP2[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 141, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 142, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 143, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 144, FAMILY_SWISS, sal_True, sal_False }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 145, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aFUJIDL24[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 146, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 147, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 148, FAMILY_ROMAN, sal_True, sal_True }, + { 24, 149, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 121, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 150, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 124, FAMILY_ROMAN, sal_True, sal_True }, + { 42, 151, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 152, FAMILY_ROMAN, sal_True, sal_True }, + { 60, 153, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 67, 154, FAMILY_SWISS, sal_True, sal_False }, + { 78, 129, FAMILY_SWISS, sal_True, sal_False }, + { 80, 130, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 155, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 133, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 103, FAMILY_ROMAN, sal_True, sal_False }, + { 108, 156, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 157, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aGABRIELE[] = { + { 1, 158, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 159, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 160, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aGENICOM[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 161, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aGQ3500SF[] = { + { 1, 162, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 163, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 164, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 165, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 166, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 167, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 168, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 169, FAMILY_SWISS, sal_True, sal_False }, + { 70, 170, FAMILY_SWISS, sal_True, sal_False }, + { 97, 171, FAMILY_ROMAN, sal_True, sal_False }, + { 164, 172, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aGQ5000[] = { + { 33, 173, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 174, FAMILY_SWISS, sal_True, sal_False }, + { 97, 175, FAMILY_ROMAN, sal_True, sal_False }, + { 128, 176, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aGRAPHICS[] = { + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_True }, + { 66, 178, FAMILY_SWISS, sal_True, sal_True }, + { 67, 179, FAMILY_SWISS, sal_True, sal_True }, + { 68, 180, FAMILY_SWISS, sal_True, sal_True }, + { 69, 181, FAMILY_SWISS, sal_True, sal_True }, + { 70, 182, FAMILY_SWISS, sal_True, sal_True }, + { 71, 183, FAMILY_SWISS, sal_True, sal_True }, + { 72, 184, FAMILY_SWISS, sal_True, sal_True }, + { 73, 185, FAMILY_SWISS, sal_True, sal_True }, + { 74, 186, FAMILY_SWISS, sal_True, sal_True }, + { 75, 187, FAMILY_SWISS, sal_True, sal_True }, + { 76, 188, FAMILY_SWISS, sal_True, sal_True }, + { 77, 189, FAMILY_SWISS, sal_True, sal_True }, + { 78, 190, FAMILY_SWISS, sal_True, sal_True }, + { 79, 150, FAMILY_SWISS, sal_True, sal_True }, + { 80, 191, FAMILY_SWISS, sal_True, sal_True }, + { 81, 192, FAMILY_SWISS, sal_True, sal_True }, + { 82, 193, FAMILY_SWISS, sal_True, sal_True }, + { 83, 194, FAMILY_SWISS, sal_True, sal_True }, + { 84, 195, FAMILY_SWISS, sal_True, sal_True }, + { 85, 196, FAMILY_SWISS, sal_True, sal_True }, + { 86, 197, FAMILY_SWISS, sal_True, sal_True }, + { 87, 198, FAMILY_SWISS, sal_True, sal_True }, + { 88, 199, FAMILY_SWISS, sal_True, sal_True }, + { 89, 200, FAMILY_SWISS, sal_True, sal_True }, + { 90, 201, FAMILY_SWISS, sal_True, sal_True }, + { 91, 202, FAMILY_SWISS, sal_True, sal_True }, + { 92, 203, FAMILY_SWISS, sal_True, sal_True }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 205, FAMILY_ROMAN, sal_True, sal_True }, + { 103, 206, FAMILY_ROMAN, sal_True, sal_True }, + { 105, 207, FAMILY_ROMAN, sal_True, sal_True }, + { 109, 208, FAMILY_ROMAN, sal_True, sal_True }, + { 130, 209, FAMILY_DECORATIVE, sal_True, sal_True }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 136, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 137, 210, FAMILY_DONTKNOW, sal_False, sal_True }, + { 138, 211, FAMILY_DONTKNOW, sal_False, sal_True }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHP4[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 66, 214, FAMILY_SWISS, sal_True, sal_False }, + { 67, 215, FAMILY_SWISS, sal_True, sal_False }, + { 68, 216, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 217, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 218, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 219, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 131, 220, FAMILY_DECORATIVE, sal_True, sal_False }, + { 132, 221, FAMILY_DECORATIVE, sal_True, sal_False }, + { 133, 222, FAMILY_DECORATIVE, sal_True, sal_False }, + { 134, 223, FAMILY_DECORATIVE, sal_True, sal_False }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 136, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 137, 210, FAMILY_DONTKNOW, sal_False, sal_False }, + { 138, 211, FAMILY_DONTKNOW, sal_False, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 141, 224, FAMILY_DECORATIVE, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHP4SFS[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 66, 214, FAMILY_SWISS, sal_True, sal_False }, + { 67, 215, FAMILY_SWISS, sal_True, sal_False }, + { 68, 216, FAMILY_SWISS, sal_True, sal_False }, + { 69, 225, FAMILY_SWISS, sal_True, sal_False }, + { 74, 186, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 226, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 218, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 219, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 206, FAMILY_ROMAN, sal_True, sal_True }, + { 105, 207, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 208, FAMILY_ROMAN, sal_True, sal_False }, + { 130, 209, FAMILY_DECORATIVE, sal_True, sal_False }, + { 131, 220, FAMILY_DECORATIVE, sal_True, sal_False }, + { 132, 221, FAMILY_DECORATIVE, sal_True, sal_False }, + { 133, 222, FAMILY_DECORATIVE, sal_True, sal_False }, + { 134, 223, FAMILY_DECORATIVE, sal_True, sal_False }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 137, 210, FAMILY_DONTKNOW, sal_False, sal_False }, + { 138, 211, FAMILY_DONTKNOW, sal_False, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 141, 224, FAMILY_DECORATIVE, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPDJ[] = { + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPDJ500C[] = { + { 17, 229, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 230, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 231, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 232, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 233, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 234, FAMILY_ROMAN, sal_True, sal_True }, + { 28, 235, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 236, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 237, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 238, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 239, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 240, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 241, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 242, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 243, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 244, FAMILY_ROMAN, sal_True, sal_True }, + { 52, 245, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 246, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 247, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 248, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 249, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 250, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 251, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 252, FAMILY_SWISS, sal_True, sal_False }, + { 69, 253, FAMILY_SWISS, sal_True, sal_False }, + { 70, 254, FAMILY_SWISS, sal_True, sal_False }, + { 71, 255, FAMILY_SWISS, sal_True, sal_False }, + { 72, 256, FAMILY_SWISS, sal_True, sal_False }, + { 77, 257, FAMILY_SWISS, sal_True, sal_False }, + { 78, 258, FAMILY_SWISS, sal_True, sal_False }, + { 101, 218, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 259, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 260, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 261, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 107, 262, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPDJ550[] = { + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 240, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 241, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPDJCAR[] = { + { 17, 229, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 230, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 231, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 232, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 233, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 234, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 237, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 238, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 239, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 242, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 243, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 244, FAMILY_ROMAN, sal_True, sal_True }, + { 52, 245, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 246, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 247, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 263, FAMILY_ROMAN, sal_True, sal_True }, + { 56, 249, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 250, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 252, FAMILY_SWISS, sal_True, sal_False }, + { 69, 253, FAMILY_SWISS, sal_True, sal_False }, + { 70, 254, FAMILY_SWISS, sal_True, sal_False }, + { 71, 255, FAMILY_SWISS, sal_True, sal_False }, + { 72, 256, FAMILY_SWISS, sal_True, sal_False }, + { 102, 259, FAMILY_ROMAN, sal_True, sal_False }, + { 107, 262, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPDJSF[] = { + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 264, FAMILY_SWISS, sal_True, sal_False }, + { 97, 265, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPIII[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 66, 214, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPIIISFS[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 66, 178, FAMILY_SWISS, sal_True, sal_False }, + { 67, 179, FAMILY_SWISS, sal_True, sal_False }, + { 68, 180, FAMILY_SWISS, sal_True, sal_False }, + { 69, 225, FAMILY_SWISS, sal_True, sal_False }, + { 70, 182, FAMILY_SWISS, sal_True, sal_False }, + { 71, 183, FAMILY_SWISS, sal_True, sal_False }, + { 72, 184, FAMILY_SWISS, sal_True, sal_False }, + { 73, 185, FAMILY_SWISS, sal_True, sal_False }, + { 74, 186, FAMILY_SWISS, sal_True, sal_False }, + { 75, 187, FAMILY_SWISS, sal_True, sal_False }, + { 76, 188, FAMILY_SWISS, sal_True, sal_False }, + { 77, 189, FAMILY_SWISS, sal_True, sal_False }, + { 78, 190, FAMILY_SWISS, sal_True, sal_False }, + { 79, 150, FAMILY_SWISS, sal_True, sal_False }, + { 80, 191, FAMILY_SWISS, sal_True, sal_False }, + { 81, 192, FAMILY_SWISS, sal_True, sal_False }, + { 82, 193, FAMILY_SWISS, sal_True, sal_False }, + { 83, 194, FAMILY_SWISS, sal_True, sal_False }, + { 85, 196, FAMILY_SWISS, sal_True, sal_False }, + { 86, 197, FAMILY_SWISS, sal_True, sal_False }, + { 87, 198, FAMILY_SWISS, sal_True, sal_False }, + { 88, 199, FAMILY_SWISS, sal_True, sal_False }, + { 89, 200, FAMILY_SWISS, sal_True, sal_False }, + { 90, 201, FAMILY_SWISS, sal_True, sal_False }, + { 91, 202, FAMILY_SWISS, sal_True, sal_False }, + { 92, 203, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 226, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 206, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 207, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 208, FAMILY_ROMAN, sal_True, sal_False }, + { 130, 209, FAMILY_DECORATIVE, sal_True, sal_False }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 136, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 137, 210, FAMILY_DONTKNOW, sal_False, sal_False }, + { 138, 211, FAMILY_DONTKNOW, sal_False, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPIIP[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 66, 85, FAMILY_SWISS, sal_True, sal_False }, + { 67, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPQJ[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHPXL300[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_False }, + { 66, 214, FAMILY_SWISS, sal_True, sal_False }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_False }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aHP_ADAF[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 266, FAMILY_SWISS, sal_True, sal_False }, + { 97, 267, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBM_PPDS[] = { + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 268, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBM4019I[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 269, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBM4072[] = { + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 126, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 107, 24, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBM5202[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 130, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBM6750[] = { + { 1, 270, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBMGR[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 271, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBMPRO[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 96, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aIBMPRO24[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 96, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 105, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 272, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aJUKI6500[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 19, 8, FAMILY_ROMAN, sal_True, sal_True }, + { 21, 9, FAMILY_ROMAN, sal_True, sal_True }, + { 23, 10, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 15, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 16, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 17, FAMILY_SWISS, sal_True, sal_False }, + { 76, 18, FAMILY_SWISS, sal_True, sal_False }, + { 77, 19, FAMILY_SWISS, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 22, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aKONICA[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 273, FAMILY_SWISS, sal_True, sal_False }, + { 97, 274, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aKYOCERA[] = { + { 1, 275, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aKYOF1010[] = { + { 1, 275, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLBP8II[] = { + { 33, 276, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 110, 153, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLBP8III[] = { + { 33, 277, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 278, FAMILY_SWISS, sal_True, sal_False }, + { 69, 279, FAMILY_SWISS, sal_True, sal_False }, + { 74, 280, FAMILY_SWISS, sal_True, sal_False }, + { 97, 153, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 281, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 282, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 283, FAMILY_ROMAN, sal_True, sal_False }, + { 130, 284, FAMILY_DECORATIVE, sal_True, sal_False }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLC_20[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 285, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 286, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 287, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 288, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 289, FAMILY_SWISS, sal_True, sal_False }, + { 97, 290, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLC_200[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 291, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 66, 292, FAMILY_SWISS, sal_True, sal_False }, + { 97, 293, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLC24_200[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 294, FAMILY_ROMAN, sal_True, sal_True }, + { 6, 295, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 296, FAMILY_ROMAN, sal_True, sal_True }, + { 10, 297, FAMILY_ROMAN, sal_True, sal_True }, + { 12, 298, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 299, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 300, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 301, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 302, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 303, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 304, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 305, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 306, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 307, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 308, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 309, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 310, FAMILY_SWISS, sal_True, sal_False }, + { 68, 311, FAMILY_SWISS, sal_True, sal_False }, + { 69, 312, FAMILY_SWISS, sal_True, sal_False }, + { 71, 313, FAMILY_SWISS, sal_True, sal_False }, + { 97, 314, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 315, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 316, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 317, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 318, FAMILY_ROMAN, sal_True, sal_False }, + { 112, 319, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLC866[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLC866SF[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 266, FAMILY_SWISS, sal_True, sal_False }, + { 97, 267, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aLT20[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 320, FAMILY_ROMAN, sal_True, sal_True }, + { 10, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 321, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 150, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 322, FAMILY_SWISS, sal_True, sal_False }, + { 69, 323, FAMILY_SWISS, sal_True, sal_False }, + { 77, 36, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 324, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 155, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aMA_MT81[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aMA_MT91[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 325, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 269, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aMP1300[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 271, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 326, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aMT222[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 327, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 328, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 329, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 330, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 331, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aMT910[] = { + { 1, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 113, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_False }, + { 66, 85, FAMILY_SWISS, sal_True, sal_False }, + { 67, 85, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP2030[] = { + { 1, 332, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 333, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 334, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 335, FAMILY_SWISS, sal_True, sal_False }, + { 70, 336, FAMILY_SWISS, sal_True, sal_False }, + { 103, 337, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP2200[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 52, 338, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 339, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 340, FAMILY_ROMAN, sal_True, sal_False }, + { 128, 341, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP23[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 342, FAMILY_ROMAN, sal_True, sal_True }, + { 7, 343, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 344, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 345, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 51, FAMILY_SWISS, sal_True, sal_False }, + { 66, 346, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP2P[] = { + { 1, 347, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 348, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 349, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 350, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 351, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 335, FAMILY_SWISS, sal_True, sal_False }, + { 70, 336, FAMILY_SWISS, sal_True, sal_False }, + { 103, 337, FAMILY_ROMAN, sal_True, sal_False }, + { 133, 352, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP567[] = { + { 1, 353, FAMILY_ROMAN, sal_True, sal_True }, + { 7, 354, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 355, FAMILY_SWISS, sal_True, sal_False }, + { 128, 356, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP6070[] = { + { 1, 332, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 333, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 357, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 358, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 359, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 360, FAMILY_ROMAN, sal_True, sal_True }, + { 24, 361, FAMILY_ROMAN, sal_True, sal_True }, + { 28, 362, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 363, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 334, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 364, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 365, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 366, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 367, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 368, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 369, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 370, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 335, FAMILY_SWISS, sal_True, sal_False }, + { 69, 371, FAMILY_SWISS, sal_True, sal_False }, + { 70, 372, FAMILY_SWISS, sal_True, sal_False }, + { 71, 336, FAMILY_SWISS, sal_True, sal_False }, + { 72, 373, FAMILY_SWISS, sal_True, sal_False }, + { 103, 337, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 374, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 375, FAMILY_ROMAN, sal_True, sal_False }, + { 108, 376, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 377, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 378, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECP6272[] = { + { 1, 332, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 333, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 357, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 358, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 359, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 360, FAMILY_ROMAN, sal_True, sal_True }, + { 24, 361, FAMILY_ROMAN, sal_True, sal_True }, + { 28, 362, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 363, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 334, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 364, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 365, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 366, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 367, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 368, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 369, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 370, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 379, FAMILY_SWISS, sal_True, sal_False }, + { 69, 371, FAMILY_SWISS, sal_True, sal_False }, + { 70, 372, FAMILY_SWISS, sal_True, sal_False }, + { 71, 336, FAMILY_SWISS, sal_True, sal_False }, + { 72, 373, FAMILY_SWISS, sal_True, sal_False }, + { 96, 380, FAMILY_SWISS, sal_True, sal_False }, + { 103, 337, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 374, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 375, FAMILY_ROMAN, sal_True, sal_False }, + { 108, 376, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 377, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 378, FAMILY_ROMAN, sal_True, sal_False }, + { 111, 381, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECPLUS[] = { + { 1, 347, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 357, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 358, FAMILY_ROMAN, sal_True, sal_True }, + { 20, 359, FAMILY_ROMAN, sal_True, sal_True }, + { 22, 360, FAMILY_ROMAN, sal_True, sal_True }, + { 28, 362, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 363, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 350, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 364, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 365, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 366, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 367, FAMILY_ROMAN, sal_True, sal_True }, + { 51, 351, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 369, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 370, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 382, FAMILY_SWISS, sal_True, sal_False }, + { 69, 371, FAMILY_SWISS, sal_True, sal_False }, + { 70, 372, FAMILY_SWISS, sal_True, sal_False }, + { 72, 373, FAMILY_SWISS, sal_True, sal_False }, + { 103, 383, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 374, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 375, FAMILY_ROMAN, sal_True, sal_False }, + { 108, 376, FAMILY_ROMAN, sal_True, sal_False }, + { 109, 377, FAMILY_ROMAN, sal_True, sal_False }, + { 110, 378, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aNECS60[] = { + { 2, 275, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI192[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 107, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI192OR[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 384, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI193[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 107, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI292F[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI293F[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI320[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 385, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 66, 107, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI380E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 386, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 387, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 388, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 389, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 390, FAMILY_SWISS, sal_True, sal_False }, + { 71, 323, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI390E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 391, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI390EL[] = { + { 1, 393, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 394, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 395, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 396, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 397, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 398, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 382, FAMILY_SWISS, sal_True, sal_False }, + { 66, 17, FAMILY_SWISS, sal_True, sal_False }, + { 67, 399, FAMILY_SWISS, sal_True, sal_False }, + { 97, 101, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 29, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI393EL[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 400, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 401, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 402, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 403, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 288, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 404, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 405, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 406, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 407, FAMILY_SWISS, sal_True, sal_False }, + { 97, 408, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 409, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 410, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 411, FAMILY_ROMAN, sal_True, sal_False }, + { 128, 412, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI393F[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 413, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 414, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI400[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 273, FAMILY_SWISS, sal_True, sal_False }, + { 66, 415, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 416, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKI800[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 273, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKILL6[] = { + { 1, 417, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 418, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 419, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOKILL6R8[] = { + { 1, 420, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 53, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 54, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 418, FAMILY_SWISS, sal_True, sal_False }, + { 97, 87, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 419, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOLI324L[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 421, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 150, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 422, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOLIDM109[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 96, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOLIJP350[] = { + { 33, 227, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 228, FAMILY_ROMAN, sal_True, sal_True }, + { 45, 423, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 424, FAMILY_ROMAN, sal_True, sal_True }, + { 47, 425, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 426, FAMILY_ROMAN, sal_True, sal_True }, + { 102, 427, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aOLIPG306[] = { + { 2, 275, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 428, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 429, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 430, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 431, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 432, FAMILY_SWISS, sal_True, sal_False }, + { 66, 433, FAMILY_SWISS, sal_True, sal_False }, + { 67, 434, FAMILY_SWISS, sal_True, sal_False }, + { 68, 435, FAMILY_DONTKNOW, sal_False, sal_False }, + { 102, 436, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 437, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 438, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 439, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPAINT[] = { + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPAN4450I[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 440, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1080[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 106, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 67, 340, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1081[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 441, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1090[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1091[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1092[] = { + { 1, 5, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 442, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 443, FAMILY_SWISS, sal_True, sal_False }, + { 67, 444, FAMILY_SWISS, sal_True, sal_False }, + { 132, 444, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1124[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 32, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 70, 336, FAMILY_SWISS, sal_True, sal_False }, + { 71, 323, FAMILY_SWISS, sal_True, sal_False }, + { 77, 36, FAMILY_SWISS, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1180[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 35, FAMILY_SWISS, sal_True, sal_False }, + { 70, 336, FAMILY_SWISS, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1540[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 445, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 288, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 129, 446, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1592[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 97, 441, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPANA1595[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 11, 447, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 70, 448, FAMILY_SWISS, sal_True, sal_False }, + { 97, 441, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPR241[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 15, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 17, 449, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 105, FAMILY_ROMAN, sal_True, sal_True }, + { 41, 14, FAMILY_ROMAN, sal_True, sal_True }, + { 57, 450, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 101, FAMILY_ROMAN, sal_True, sal_False }, + { 101, 451, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPR5200[] = { + { 1, 95, FAMILY_ROMAN, sal_True, sal_True }, + { 70, 452, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPRODOT24[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 453, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 454, FAMILY_ROMAN, sal_True, sal_True }, + { 7, 85, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 455, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 110, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 379, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 456, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 111, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPRODOT9[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 453, FAMILY_ROMAN, sal_True, sal_True }, + { 7, 457, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 458, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 459, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 460, FAMILY_SWISS, sal_True, sal_False }, + { 97, 461, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 462, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPS[] = { + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 85, FAMILY_SWISS, sal_True, sal_True }, + { 69, 463, FAMILY_SWISS, sal_True, sal_True }, + { 74, 464, FAMILY_SWISS, sal_True, sal_True }, + { 97, 465, FAMILY_ROMAN, sal_True, sal_True }, + { 103, 466, FAMILY_ROMAN, sal_True, sal_True }, + { 105, 467, FAMILY_ROMAN, sal_True, sal_True }, + { 109, 468, FAMILY_ROMAN, sal_True, sal_True }, + { 130, 469, FAMILY_DECORATIVE, sal_True, sal_True }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aPT90[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 470, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 471, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 472, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 473, FAMILY_ROMAN, sal_True, sal_True }, + { 61, 474, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 475, FAMILY_ROMAN, sal_True, sal_True }, + { 76, 476, FAMILY_SWISS, sal_True, sal_False }, + { 77, 477, FAMILY_SWISS, sal_True, sal_False }, + { 78, 478, FAMILY_SWISS, sal_True, sal_False }, + { 79, 479, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aRASTER[] = { + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 177, FAMILY_SWISS, sal_True, sal_True }, + { 66, 178, FAMILY_SWISS, sal_True, sal_True }, + { 67, 179, FAMILY_SWISS, sal_True, sal_True }, + { 68, 180, FAMILY_SWISS, sal_True, sal_True }, + { 69, 181, FAMILY_SWISS, sal_True, sal_True }, + { 70, 182, FAMILY_SWISS, sal_True, sal_True }, + { 71, 183, FAMILY_SWISS, sal_True, sal_True }, + { 72, 184, FAMILY_SWISS, sal_True, sal_True }, + { 73, 185, FAMILY_SWISS, sal_True, sal_True }, + { 74, 186, FAMILY_SWISS, sal_True, sal_True }, + { 75, 187, FAMILY_SWISS, sal_True, sal_True }, + { 76, 188, FAMILY_SWISS, sal_True, sal_True }, + { 77, 189, FAMILY_SWISS, sal_True, sal_True }, + { 78, 190, FAMILY_SWISS, sal_True, sal_True }, + { 79, 150, FAMILY_SWISS, sal_True, sal_True }, + { 80, 191, FAMILY_SWISS, sal_True, sal_True }, + { 81, 192, FAMILY_SWISS, sal_True, sal_True }, + { 82, 193, FAMILY_SWISS, sal_True, sal_True }, + { 83, 194, FAMILY_SWISS, sal_True, sal_True }, + { 84, 195, FAMILY_SWISS, sal_True, sal_True }, + { 85, 196, FAMILY_SWISS, sal_True, sal_True }, + { 86, 197, FAMILY_SWISS, sal_True, sal_True }, + { 87, 198, FAMILY_SWISS, sal_True, sal_True }, + { 88, 199, FAMILY_SWISS, sal_True, sal_True }, + { 89, 200, FAMILY_SWISS, sal_True, sal_True }, + { 90, 201, FAMILY_SWISS, sal_True, sal_True }, + { 91, 202, FAMILY_SWISS, sal_True, sal_True }, + { 92, 203, FAMILY_SWISS, sal_True, sal_True }, + { 97, 204, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 205, FAMILY_ROMAN, sal_True, sal_True }, + { 103, 206, FAMILY_ROMAN, sal_True, sal_True }, + { 105, 207, FAMILY_ROMAN, sal_True, sal_True }, + { 109, 208, FAMILY_ROMAN, sal_True, sal_True }, + { 130, 209, FAMILY_DECORATIVE, sal_True, sal_True }, + { 135, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 136, 78, FAMILY_DONTKNOW, sal_False, sal_True }, + { 137, 210, FAMILY_DONTKNOW, sal_False, sal_True }, + { 138, 211, FAMILY_DONTKNOW, sal_False, sal_True }, + { 140, 212, FAMILY_DONTKNOW, sal_False, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSD15[] = { + { 1, 95, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSD24[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 107, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSEIKO[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 480, FAMILY_SWISS, sal_True, sal_False }, + { 97, 321, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIHP4100[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 391, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIHP4200[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 55, 391, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIHP4400[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 413, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 414, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIHP440F[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 5, 413, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 414, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 392, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIPT18[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIPT18F[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSIPT19[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSL230AI[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 481, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 321, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 23, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 482, FAMILY_SWISS, sal_True, sal_False }, + { 71, 323, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 38, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 36, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 24, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSL80AI[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 398, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSL80IP[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 398, FAMILY_ROMAN, sal_True, sal_True }, + { 98, 20, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSL92[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 481, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 7, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 321, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 483, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 482, FAMILY_SWISS, sal_True, sal_False }, + { 71, 323, FAMILY_SWISS, sal_True, sal_False }, + { 77, 36, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 324, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 25, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSP1600AI[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSP264[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 327, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 328, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 329, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 330, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 331, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARFR10[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 30, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 93, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 6, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 13, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 61, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 484, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 308, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 126, FAMILY_SWISS, sal_True, sal_False }, + { 66, 485, FAMILY_SWISS, sal_True, sal_False }, + { 71, 323, FAMILY_SWISS, sal_True, sal_False }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 103, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 486, FAMILY_ROMAN, sal_True, sal_False }, + { 111, 487, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARLC[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 291, FAMILY_ROMAN, sal_True, sal_True }, + { 13, 488, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 489, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 139, FAMILY_SWISS, sal_True, sal_False }, + { 66, 292, FAMILY_SWISS, sal_True, sal_False }, + { 97, 293, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARLC24[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 490, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 104, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 397, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 491, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 492, FAMILY_ROMAN, sal_True, sal_True }, + { 71, 493, FAMILY_SWISS, sal_True, sal_False }, + { 97, 101, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 29, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 21, FAMILY_ROMAN, sal_True, sal_False }, + { 112, 494, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARLP8[] = { + { 1, 213, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 3, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 112, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 495, FAMILY_ROMAN, sal_True, sal_True }, + { 36, 82, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 4, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 496, FAMILY_SWISS, sal_True, sal_False }, + { 97, 274, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 497, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARNB[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 441, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARNL_I[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 115, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 498, FAMILY_SWISS, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARSJ48[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 499, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 500, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 501, FAMILY_ROMAN, sal_True, sal_True }, + { 102, 502, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTARXB24[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 499, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 296, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 503, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 300, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 301, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 302, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 504, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 303, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 505, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 304, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 305, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 306, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 506, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 507, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 508, FAMILY_ROMAN, sal_True, sal_True }, + { 58, 509, FAMILY_ROMAN, sal_True, sal_True }, + { 60, 510, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 511, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 309, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 512, FAMILY_SWISS, sal_True, sal_False }, + { 71, 513, FAMILY_SWISS, sal_True, sal_False }, + { 80, 514, FAMILY_SWISS, sal_True, sal_False }, + { 97, 515, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 516, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 517, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 518, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 519, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 520, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 521, FAMILY_ROMAN, sal_True, sal_False }, + { 111, 522, FAMILY_ROMAN, sal_True, sal_False }, + { 112, 523, FAMILY_ROMAN, sal_True, sal_False }, + { 129, 524, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTLC2420[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 499, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 503, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 300, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 301, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 302, FAMILY_ROMAN, sal_True, sal_True }, + { 27, 525, FAMILY_ROMAN, sal_True, sal_True }, + { 32, 526, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 303, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 304, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 305, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 500, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 527, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 507, FAMILY_ROMAN, sal_True, sal_True }, + { 49, 508, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 528, FAMILY_ROMAN, sal_True, sal_True }, + { 60, 529, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 511, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 309, FAMILY_ROMAN, sal_True, sal_True }, + { 68, 530, FAMILY_SWISS, sal_True, sal_False }, + { 71, 513, FAMILY_SWISS, sal_True, sal_False }, + { 80, 531, FAMILY_SWISS, sal_True, sal_False }, + { 97, 515, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 532, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 517, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 502, FAMILY_ROMAN, sal_True, sal_False }, + { 103, 533, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 520, FAMILY_ROMAN, sal_True, sal_False }, + { 105, 521, FAMILY_ROMAN, sal_True, sal_False }, + { 106, 534, FAMILY_ROMAN, sal_True, sal_False }, + { 111, 522, FAMILY_ROMAN, sal_True, sal_False }, + { 112, 523, FAMILY_ROMAN, sal_True, sal_False }, + { 129, 524, FAMILY_DECORATIVE, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSTXB2420[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 529, FAMILY_ROMAN, sal_True, sal_True }, + { 6, 504, FAMILY_ROMAN, sal_True, sal_True }, + { 8, 296, FAMILY_ROMAN, sal_True, sal_True }, + { 10, 297, FAMILY_ROMAN, sal_True, sal_True }, + { 12, 298, FAMILY_ROMAN, sal_True, sal_True }, + { 14, 299, FAMILY_ROMAN, sal_True, sal_True }, + { 16, 300, FAMILY_ROMAN, sal_True, sal_True }, + { 18, 301, FAMILY_ROMAN, sal_True, sal_True }, + { 26, 302, FAMILY_ROMAN, sal_True, sal_True }, + { 28, 525, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 303, FAMILY_ROMAN, sal_True, sal_True }, + { 38, 304, FAMILY_ROMAN, sal_True, sal_True }, + { 40, 305, FAMILY_ROMAN, sal_True, sal_True }, + { 44, 535, FAMILY_ROMAN, sal_True, sal_True }, + { 46, 536, FAMILY_ROMAN, sal_True, sal_True }, + { 48, 507, FAMILY_ROMAN, sal_True, sal_True }, + { 50, 508, FAMILY_ROMAN, sal_True, sal_True }, + { 62, 511, FAMILY_ROMAN, sal_True, sal_True }, + { 64, 309, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 537, FAMILY_SWISS, sal_True, sal_False }, + { 68, 311, FAMILY_SWISS, sal_True, sal_False }, + { 69, 312, FAMILY_SWISS, sal_True, sal_False }, + { 71, 313, FAMILY_SWISS, sal_True, sal_False }, + { 77, 538, FAMILY_SWISS, sal_True, sal_False }, + { 97, 314, FAMILY_ROMAN, sal_True, sal_False }, + { 99, 315, FAMILY_ROMAN, sal_True, sal_False }, + { 100, 316, FAMILY_ROMAN, sal_True, sal_False }, + { 102, 539, FAMILY_ROMAN, sal_True, sal_False }, + { 104, 540, FAMILY_ROMAN, sal_True, sal_False }, + { 112, 319, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aSWIFT24E[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 541, FAMILY_ROMAN, sal_True, sal_True }, + { 4, 85, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 110, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 12, FAMILY_ROMAN, sal_True, sal_True }, + { 66, 379, FAMILY_SWISS, sal_True, sal_False }, + { 98, 111, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTOSH301[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 83, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 2, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 542, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTOSH321[] = { + { 1, 0, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 543, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 105, FAMILY_ROMAN, sal_True, sal_True }, + { 43, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 97, 134, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTOSH351[] = { + { 1, 544, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 11, FAMILY_ROMAN, sal_True, sal_True }, + { 35, 1, FAMILY_ROMAN, sal_True, sal_True }, + { 37, 105, FAMILY_ROMAN, sal_True, sal_True }, + { 39, 543, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 134, FAMILY_SWISS, sal_True, sal_False }, + { 129, 545, FAMILY_DECORATIVE, sal_True, sal_False }, + { 130, 546, FAMILY_DECORATIVE, sal_True, sal_False }, + { 131, 547, FAMILY_DECORATIVE, sal_True, sal_False }, + { 132, 548, FAMILY_DECORATIVE, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTTY[] = { + { 1, 270, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTTYDEU[] = { + { 1, 270, FAMILY_ROMAN, sal_True, sal_True }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }, + aTYPENRAD[] = { + { 1, 549, FAMILY_ROMAN, sal_True, sal_True }, + { 2, 550, FAMILY_ROMAN, sal_True, sal_True }, + { 3, 551, FAMILY_ROMAN, sal_True, sal_True }, + { 33, 552, FAMILY_ROMAN, sal_True, sal_True }, + { 34, 553, FAMILY_ROMAN, sal_True, sal_True }, + { 65, 554, FAMILY_SWISS, sal_True, sal_False }, + { 66, 555, FAMILY_SWISS, sal_True, sal_False }, + { 97, 556, FAMILY_ROMAN, sal_True, sal_False }, + { 98, 557, FAMILY_ROMAN, sal_True, sal_False }, + { 0, 0, FAMILY_ROMAN, sal_False, sal_False } + }; + + +static const struct Sw6FontMatch +{ + const sal_Char* pPrtName; + const Sw6PrinterFont* pFonts; +} aFntMatch[] = { + { "5000DI", a5000DI }, + { "ACERLP75", aACERLP75 }, + { "AEG200I", aAEG200I }, + { "BJ10E", aBJ10E }, + { "BJ130E", aBJ130E }, + { "BJ300", aBJ300 }, + { "BR1109", aBR1109 }, + { "BR1209", aBR1209 }, + { "BR1224L", aBR1224L }, + { "BR1324", aBR1324 }, + { "BR1409", aBR1409 }, + { "BR1509", aBR1509 }, + { "BR1709", aBR1709 }, + { "BR1724L", aBR1724L }, + { "BR1824L", aBR1824L }, + { "BR2024", aBR2024 }, + { "BR2518", aBR2518 }, + { "BR3524L", aBR3524L }, + { "BR4018", aBR4018 }, + { "BRHJ770", aBRHJ770 }, + { "BRHL4", aBRHL4 }, + { "BRHL48V", aBRHL48V }, + { "BRHL8DB", aBRHL8DB }, + { "BRHR", aBRHR }, + { "BROTHER", aBROTHER }, + { "CANONBJX", aCANONBJX }, + { "CE500", aCE500 }, + { "CE700", aCE700 }, + { "CIE_210E", aCIE_210E }, + { "CIE_310E", aCIE_310E }, + { "CIE_610E", aCIE_610E }, + { "CIE_610P", aCIE_610P }, + { "CIE_715E", aCIE_715E }, + { "CIT120D", aCIT120D }, + { "CIT120DP", aCIT120DP }, + { "CIT124D", aCIT124D }, + { "CITOH52", aCITOH52 }, + { "D-630", aD_630 }, + { "D-630E", aD_630E }, + { "D-630HZ", aD_630HZ }, + { "DICO150", aDICO150 }, + { "DICO300I", aDICO300I }, + { "DLP", aDLP }, + { "DLQ", aDLQ }, + { "DMP", aDMP }, + { "EPLQ800", aEPLQ800 }, + { "EPLX800", aEPLX800 }, + { "EPSFX", aEPSFX }, + { "EPSFX100", aEPSFX100 }, + { "EPSFX80", aEPSFX80 }, + { "EPSLQ", aEPSLQ }, + { "EPSRX", aEPSRX }, + { "ESCP2", aESCP2 }, + { "FUJIDL24", aFUJIDL24 }, + { "GABRIELE", aGABRIELE }, + { "GENICOM", aGENICOM }, + { "GQ3500SF", aGQ3500SF }, + { "GQ5000", aGQ5000 }, + { "GRAPHICS", aGRAPHICS }, + { "HP4", aHP4 }, + { "HP4SFS", aHP4SFS }, + { "HPDJ", aHPDJ }, + { "HPDJ500C", aHPDJ500C }, + { "HPDJ550", aHPDJ550 }, + { "HPDJCAR", aHPDJCAR }, + { "HPDJSF", aHPDJSF }, + { "HPIII", aHPIII }, + { "HPIIISFS", aHPIIISFS }, + { "HPIIP", aHPIIP }, + { "HPQJ", aHPQJ }, + { "HPXL300", aHPXL300 }, + { "HP_ADAF", aHP_ADAF }, + { "IBM-PPDS", aIBM_PPDS }, + { "IBM4019I", aIBM4019I }, + { "IBM4072", aIBM4072 }, + { "IBM5202", aIBM5202 }, + { "IBM6750", aIBM6750 }, + { "IBMGR", aIBMGR }, + { "IBMPRO", aIBMPRO }, + { "IBMPRO24", aIBMPRO24 }, + { "JUKI6500", aJUKI6500 }, + { "KONICA", aKONICA }, + { "KYOCERA", aKYOCERA }, + { "KYOF1010", aKYOF1010 }, + { "LBP8II", aLBP8II }, + { "LBP8III", aLBP8III }, + { "LC-20", aLC_20 }, + { "LC-200", aLC_200 }, + { "LC24-200", aLC24_200 }, + { "LC866", aLC866 }, + { "LC866SF", aLC866SF }, + { "LT20", aLT20 }, + { "MA-MT81", aMA_MT81 }, + { "MA-MT91", aMA_MT91 }, + { "MP1300", aMP1300 }, + { "MT222", aMT222 }, + { "MT910", aMT910 }, + { "NECP2030", aNECP2030 }, + { "NECP2200", aNECP2200 }, + { "NECP23", aNECP23 }, + { "NECP2P", aNECP2P }, + { "NECP567", aNECP567 }, + { "NECP6070", aNECP6070 }, + { "NECP6272", aNECP6272 }, + { "NECPLUS", aNECPLUS }, + { "NECS60", aNECS60 }, + { "OKI192", aOKI192 }, + { "OKI192OR", aOKI192OR }, + { "OKI193", aOKI193 }, + { "OKI292F", aOKI292F }, + { "OKI293F", aOKI293F }, + { "OKI320", aOKI320 }, + { "OKI380E", aOKI380E }, + { "OKI390E", aOKI390E }, + { "OKI390EL", aOKI390EL }, + { "OKI393EL", aOKI393EL }, + { "OKI393F", aOKI393F }, + { "OKI400", aOKI400 }, + { "OKI800", aOKI800 }, + { "OKILL6", aOKILL6 }, + { "OKILL6R8", aOKILL6R8 }, + { "OLI324L", aOLI324L }, + { "OLIDM109", aOLIDM109 }, + { "OLIJP350", aOLIJP350 }, + { "OLIPG306", aOLIPG306 }, + { "PAINT", aPAINT }, + { "PAN4450I", aPAN4450I }, + { "PANA1080", aPANA1080 }, + { "PANA1081", aPANA1081 }, + { "PANA1090", aPANA1090 }, + { "PANA1091", aPANA1091 }, + { "PANA1092", aPANA1092 }, + { "PANA1124", aPANA1124 }, + { "PANA1180", aPANA1180 }, + { "PANA1540", aPANA1540 }, + { "PANA1592", aPANA1592 }, + { "PANA1595", aPANA1595 }, + { "PR241", aPR241 }, + { "PR5200", aPR5200 }, + { "PRODOT24", aPRODOT24 }, + { "PRODOT9", aPRODOT9 }, + { "PS", aPS }, + { "PT90", aPT90 }, + { "RASTER", aRASTER }, + { "SD15", aSD15 }, + { "SD24", aSD24 }, + { "SEIKO", aSEIKO }, + { "SIHP4100", aSIHP4100 }, + { "SIHP4200", aSIHP4200 }, + { "SIHP4400", aSIHP4400 }, + { "SIHP440F", aSIHP440F }, + { "SIPT18", aSIPT18 }, + { "SIPT18F", aSIPT18F }, + { "SIPT19", aSIPT19 }, + { "SL230AI", aSL230AI }, + { "SL80AI", aSL80AI }, + { "SL80IP", aSL80IP }, + { "SL92", aSL92 }, + { "SP1600AI", aSP1600AI }, + { "SP264", aSP264 }, + { "STARFR10", aSTARFR10 }, + { "STARLC", aSTARLC }, + { "STARLC24", aSTARLC24 }, + { "STARLP8", aSTARLP8 }, + { "STARNB", aSTARNB }, + { "STARNL-I", aSTARNL_I }, + { "STARSJ48", aSTARSJ48 }, + { "STARXB24", aSTARXB24 }, + { "STLC2420", aSTLC2420 }, + { "STXB2420", aSTXB2420 }, + { "SWIFT24E", aSWIFT24E }, + { "TOSH301", aTOSH301 }, + { "TOSH321", aTOSH321 }, + { "TOSH351", aTOSH351 }, + { "TTY", aTTY }, + { "TTYDEU", aTTYDEU }, + { "TYPENRAD", aTYPENRAD }, + { "", 0 } +}; + + + +//using namespace ::com::sun::star; +//using namespace ::com::sun::star::ucb; +//using namespace ::com::sun::star::uno; +//using namespace ::ucb; +//using namespace ::rtl; + +// --- Sw6Layout --- + +short Sw6Layout::ZchnZahl(sal_Char Ch1,sal_Char Ch2) const +// Ermittelt die tatsaechliche Zeichenzahl-1 eines kompletten SW6-Zchns +// Oftmals ist Ch1 ein Steuerzeichen und Ch2 ist dann ein Laengenbyte, +// so dass die Zeichenzahl erst mit Ch2 zu ermitteln ist. Wenn man wissen +// will, ob Ch1 ein nachfolgezeichen Ch2 hat, dann mit Ch2==1 aufrufen +// und auf == 0 abfragen. +{ + short nRet; + + switch (Ch1) + { + case PrSoftSp: + case PrPrFix: + case PrAttr: + case PrSize: + case PrUser: + case PrFont: + nRet=1; // 2 Char/Zchn + break; + case PrFnote: + case PrEnote: + nRet=2; // 3 Char/Zchn + break; + case PrGraf: + case PrMerker: + case PrKomm: + case PrGlied: + case PrHidd: // Ch2 ist Laengenbyte + nRet=((short)(BYTE)Ch2)+1; + break; + case PrSForm: // Harte Seitenformatierung nie implementiert + switch (Ch2) + { + case SF_Guel: // Wie Layout gueltig + case SF_SpAn: // Anzahl Spalten + case SF_KoTx: // Nummer Kopftext + case SF_FuTx: // Nummer Fusstext + nRet=2; + break; + case SF_KoAb: // Kopfabstand in Twips + case SF_FuAb: // Fussabstand + case SF_Lks: // Linker Rand + case SF_Rts: // Rechter Rand + case SF_Obn: // Oberer Rand + case SF_Unt: // Unterer Rand + case SF_SpAb: // Spaltenabstand + nRet=3; + break; + default: + nRet=1; // Default aus dem Writer + break; + } // switch + break; + case PrAForm: + switch (Ch2) + { + case AF_Form: // Formatierart, Aufzaehltyp + case AF_SpAn: // Spaltenanzahl im Absatz + case AF_SAbs: // Bool, ist dies ein Spaltenabsatz + case AF_Auto: // Autom. Zeilenabstand (Durchschuss) + case AF_Glied: // War mal fuer Gliederung vorgesehen + case AF_Zus: // Absatz zusammenhalten + nRet=2; + break; + case AF_Ein: // Einzug in Twips + case AF_Lks: // Linker Rand + case AF_Rts: // Rechter Rand + case AF_AbAb: // Absatzabstand + case AF_SpAb: // Spaltenabstand + case AF_ZlAb: // Zeilenabstand + nRet=3; + break; + case AF_Tab: // Harter Tab mit Tabart, Position (alt, SW5) + nRet=4; + break; + case AF_TabN: // Harter Tab plus Fuellzeichen, (neu, SW6) + nRet=5; + break; + default: + nRet=1; // Default aus dem Writer + break; + } // switch + break; + default: + nRet=0; // Default 1 Char/Zchn + break; + } // switch + return nRet; +} + +sal_Char Sw6Layout::UpCaseOEM(sal_Char c) const +// Upcase fuer OEM-Zeichensatz +{ + if (c<'a' || c>'z') + { + switch (c) + { + case '\x84': + c='\x8E'; + break; + case '\x94': + c='\x99'; + break; + case '\x81': + c='\x9A'; + break; + } // switch + } + else c-='\040'; + return c; +} + +// Sucht eine Buchstabenkennung raus... +// Uebergabe abgeleiteter Strcts ist leider +// nicht als Pointer Pointer moeglich. +// Templates darf ich auch nicht also! + +#define SCANLAYOUT() \ +{ \ + short nIdx=0; \ + while (nIdx<nAnz) \ + { \ + if (UpCaseOEM(rKey[(USHORT)nIdx]->Key.GetChar(0))==UpCaseOEM(c1) && \ + UpCaseOEM(rKey[(USHORT)nIdx]->Key.GetChar(1))==UpCaseOEM(c2)) \ + { \ + rnLay=nIdx; \ + break; \ + } \ + nIdx++; \ + } \ +} + +void Sw6Layout::ScanLayoutB(short &rnLay, BLAY *rKey[], + const sal_Char c1,const sal_Char c2,const short nAnz) const +{ + SCANLAYOUT(); +} + +void Sw6Layout::ScanLayoutA(short &rnLay, ALAY *rKey[], + const sal_Char c1,const sal_Char c2,const short nAnz) const +{ + SCANLAYOUT(); +} + +void Sw6Layout::ScanLayoutS(short &rnLay, SLAY *rKey[], + const sal_Char c1,const sal_Char c2,const short nAnz) const +{ + SCANLAYOUT(); +} + +void Sw6Layout::ScanLayoutKF(short &rnLay, KOFU *rKey[], + const sal_Char c1,const sal_Char c2,const short nAnz) const +{ + SCANLAYOUT(); +} + +void Sw6Layout::MerkeNoten(Bereich eNot) +// Merkt sich die jeweilige Notenposition +{ + if (pLay) + { + switch (eNot) + { + case FNot: + pLay->FNotenLink=Tell(); + break; + case ENot: + pLay->ENotenLink=Tell(); + break; + case ANot: + pLay->ANotenLink=Tell(); + break; + } + } +} + +void Sw6Layout::SetGpmFile( const String &rGpm ) +// Meldet GPM-Datei fuer Fontuebersetzung an +{ + // is the last printer the wanted printer? + String sGpm( rGpm ); + sGpm.SearchAndReplaceAscii( ".GPM", aEmptyStr ); + if( USHRT_MAX == nLastFontMatch || + !sGpm.EqualsAscii( aFntMatch[ nLastFontMatch ].pPrtName )) + { + // search the wanted printer + for( nLastFontMatch = 0; aFntMatch[ nLastFontMatch ].pFonts; + ++nLastFontMatch ) + if( sGpm.EqualsAscii( aFntMatch[ nLastFontMatch ].pPrtName )) + break; + + if( !aFntMatch[ nLastFontMatch ].pFonts ) + nLastFontMatch = USHRT_MAX; + } +} + +void Sw6Layout::SetAlayTrans(void) +// Uebersetzen OEM->SYSSET je nach Alay ein/aus +{ + if (pLay!=NULL && aSta.nAlay<pLay->NumAlay) + { + SetTrans(pLay->FileAlay[aSta.nAlay]->ABlay==0 + ?pLay->FileAlay[aSta.nAlay]->bTran // Setze das Uebersetzflag + :pLay->FileBlay[pLay->FileAlay[ // OEM->eDfltSet entweder + aSta.nAlay]->ABlay-1]->bTran); // aus ALAY oder aus BLAY + } +} + +void Sw6Layout::SetFollow(short nVon,short nNach,SwDoc &rDoc) +// Setzt die Folge-Seitenlayouts +{ + if (pLay->FileSlay[nVon]->Follow==nVon) + { + SwPageDesc &rPg=(SwPageDesc &)rDoc.GetPageDesc(nVon); + rPg.SetFollow(&rDoc.GetPageDesc(nNach)); + rDoc.ChgPageDesc(nVon,rPg); + pLay->FileSlay[nVon]->Follow=nNach; + } +} + +void Sw6Layout::ResetLay(SwDoc &rDoc) +// Wird aufgerufen wenn Haupttextbereich gelesen werden soll +{ + aSta.nAlay=0; aSta.nBlay=-1; // Status der Layouts bei ReadLn + aSta.nKopf=-1; aSta.nFuss=-1; // Dann suche nach Sonder-Alays + aSta.nSFst=-1; aSta.nSLft=-1; // der verschiedenen Bereiche + aSta.nSRgt=-1; aSta.bSlay=TRUE; + aSta.nPage=1; + + short n=-1; + + while (++n<pLay->NumSlay) // Suche nun das erste guel- + { // tige Seitenlayout heraus. + switch (pLay->FileSlay[n]->Gueltig) + { + case 1: + if (aSta.nSRgt<0) aSta.nSRgt=n; + break; + case 2: + if (aSta.nSLft<0) aSta.nSLft=n; + break; + case 3: + if (aSta.nSFst<0) aSta.nSFst=n; + break; + default: + if (aSta.nSRgt<0) aSta.nSRgt=n; + if (aSta.nSLft<0) aSta.nSLft=n; + break; + } // switch + } // while + if (aSta.nSRgt<0) aSta.nSRgt=0; + if (aSta.nSLft<0) aSta.nSLft=0; + if (aSta.nSFst>=0) SetFollow(aSta.nSFst,aSta.nSRgt,rDoc); +} + +void Sw6Layout::PushStat(long nFPos) +{ + Sw6File::PushStat(nFPos); // Merke Zustand Sw6File & Seek(Pos) + aStk.Push(&aSta,sizeof(aSta)); // Dann merke aSta mit harte Formatinfo + aSta.pFrmt=NULL; // Einen neuen Absatz mit pFrm=NULL + aSta.nAddo=0; +} + +void Sw6Layout::PopStat(void) +{ + DelHForm(); // Harte Formatierinfo weg, dann + aStk.Pop(&aSta,sizeof(aSta)); // hole auch den alten Status + Sw6File::PopStat(); // Ein Seek(Zurueck) in Sw6File +} + +void Sw6Layout::SetSlay(SwDoc &rDoc,SwPaM &rPaM) +// Setze am Pam eine neues Seitenlayout +{ + if (aSta.bSlay) + { + if (aSta.nSFst<0) + { + aSta.nSFst=(aSta.nPage&1?aSta.nSRgt:aSta.nSLft); + if (aSta.nSLft!=aSta.nSRgt) + { + SetFollow(aSta.nSRgt,aSta.nSLft,rDoc); + SetFollow(aSta.nSLft,aSta.nSRgt,rDoc); + } + } + rDoc.Insert(rPaM,SwFmtPageDesc( + &rDoc.GetPageDesc(aSta.nSFst))); + aSta.bSlay=FALSE; + aSta.nSFst=-1; + } +} + +BOOL Sw6Layout::ScanKreuz(const sal_Char *pPatt,const sal_Char *pOrig,size_t &rIgnr,sal_Char *pPara) +// Sucht aus rOrig Kreuzbefehl pPatt raus +// und gibt TRUE zurueck wenn was gefunden, +// Ignr gibt an, wieviele Zeichen #-Befehl +{ + size_t n; + for (n =0;*pPatt && *pOrig;pPatt++,pOrig++,n++) + { + switch (*pPatt) + { + case '?': + if (UpCaseOEM(*pOrig)>='A' && + UpCaseOEM(*pOrig)>='Z') + { + if (pPara) *pPara=UpCaseOEM(*pOrig); + } + else return FALSE; + break; + case '\xA8': + if (*pOrig>='0' && *pOrig<='9') + { + if (pPara) *pPara=*pOrig; + } + else return FALSE; + break; + default: + if (UpCaseOEM(*pOrig)!=*pPatt) + { + return FALSE; + } + break; + } // switch + } // for + if (!*pPatt) + { + while (*pOrig>'#' && ( + *pOrig=='*' || *pOrig=='+' || + *pOrig=='-' || *pOrig=='^')) + { + pOrig++; n++; + } + if (*pOrig=='#') + { + rIgnr=n+2; + return TRUE; + } + } + return FALSE; +} + +BOOL Sw6Layout::TextBefehl(const sal_Char *pPatt,const sal_Char *pOrig) +// Ermittelt, ob es einen Textbefehl pPatt gibt +// Achtung: pOrig zeigt auf Pascal-String! +{ + sal_Char cLen=*pOrig++; + while (cLen && *pPatt && UpCaseOEM(*pOrig)==*pPatt) + { + pPatt++; + pOrig++; + cLen--; + } + return !*pPatt && (!cLen || *pOrig<'A' || *pOrig>'Z'); +} + +void Sw6Layout::AddXForm(sal_Char cLead,ByteString &rTmp,String &rStr) +// Kurzform, wird oefter benoetigt +{ + rTmp.EraseLeadingChars(); + rTmp.EraseTrailingChars(); + rTmp.Insert((sal_Char)rTmp.Len(),0); + rTmp.Insert(cLead,0); + AddHForm(rTmp.GetBuffer(),rStr.Len(),rTmp.Len(),1); +} + +size_t Sw6Layout::PutRest(String &rStr,sal_Char *pCtrl) +// Holt aus ReadLn die Info. Behandelt versteckte Zchn +// Wird immer nach ReadLn() aufgerufen (virtuell) +{ + size_t nRet=1; + + aSta.cFrst|='\x80'; // Merker fuer Zeile nicht leer + switch (pCtrl[0]) + { + case SoftSp: + break; + case PrSoftSp: + nRet++; + break; + case NewPage: + aSta.nPage++; + case NewCol: + if ((aSta.cFrst & '\x7F')==0 && rStr.Len()==0) + { + aSta.cFrst=(BYTE)pCtrl[0]; + } + break; + case PrKomm: + if ((nRet=pCtrl[1]+2)==5) + { + switch (UpCaseOEM(pCtrl[2])) + { + case 'A': + ScanLayoutA(aSta.nAlay,pLay->FileAlay, + pCtrl[3],pCtrl[4],pLay->NumAlay); + SetAlayTrans(); + break; + case 'B': + { + short nOldL=aSta.nBlay; + aSta.nBlay=-1; + ScanLayoutB(aSta.nBlay,pLay->FileBlay, + pCtrl[3],pCtrl[4],pLay->NumBlay); + if (!(++aSta.nBlay)) + { + aSta.nBlay=pLay->FileAlay[ + aSta.nAlay]->ABlay; + } + if (aSta.nBlay) + { + SetTrans(pLay->FileBlay[ + aSta.nBlay-1]->bTran); + } + else + { + SetTrans(pLay->FileAlay[ + aSta.nAlay]->bTran); + } + if (nOldL!=aSta.nBlay) + { // Blay evt. schon gueltig? + sal_Char cTmp[2]; + + cTmp[0]='B'; + cTmp[1]=(sal_Char)aSta.nBlay; + AddHForm(cTmp,rStr.Len(),2); + } + } + break; + case 'S': + { + short nNewL=-1; + ScanLayoutS(nNewL,pLay->FileSlay, + pCtrl[3],pCtrl[4],pLay->NumSlay); + if (nNewL>=0) { + switch (pLay->FileSlay[nNewL]->Gueltig) + { + case 1: + aSta.nSRgt=nNewL; + break; + case 2: + aSta.nSLft=nNewL; + break; + case 3: + break; + default: + aSta.nSRgt=nNewL; + aSta.nSLft=nNewL; + break; + } // switch + aSta.bSlay=TRUE; + aSta.nSFst=-1; + } + } + break; + case 'K': + ScanLayoutKF(aSta.nKopf,pLay->HartKopf, + pCtrl[3],pCtrl[4],pLay->NumKopf); + break; + case 'F': + ScanLayoutKF(aSta.nFuss,pLay->HartFuss, + pCtrl[3],pCtrl[4],pLay->NumFuss); + break; + } // switch + } + else + { + if (TextBefehl("PA",&pCtrl[1]) || + TextBefehl("CP",&pCtrl[1])) + { + static sal_Char __READONLY_DATA p[2]={NewPage,'\0'}; + AddHForm(p,rStr.Len(),1); + } + else + if (TextBefehl("INDEX",&pCtrl[1])) + { + ByteString aString(&pCtrl[8],(BYTE)pCtrl[1]-6); + AddXForm('X',aString,rStr); + } + else + if (TextBefehl("INHALT",&pCtrl[1])) + { + ByteString aString(&pCtrl[9],(BYTE)pCtrl[1]-7); + AddXForm('V',aString,rStr); + } + else + { + ByteString aTmp( &pCtrl[2], pCtrl[1] ); + aTmp.Convert( RTL_TEXTENCODING_IBM_850, + gsl_getSystemTextEncoding() ); + aTmp.EraseLeadingChars(); + aTmp.EraseTrailingChars(); + aTmp.Insert('}'); // Mache versteckten Text + aTmp.Insert('{',0); + AddXForm('-',aTmp,rStr); + } + } + break; + case HardSp: // HardSpace + AddHForm(pCtrl,rStr.Len(),1,1); + break; + case HTrenn: // HTrenn nach Minus + rStr+='-'; + break; + case SoftK: // Softk nach 'C' + rStr+='c'; + break; + case PrGlied: // PrGlied: Gliedernummer + { // einfach rauswerfen... + nRet=pCtrl[1]+2; + if (rStr.Len() && rStr.GetChar( rStr.Len()-1 )=='#') + { + rStr.Erase(rStr.Len()-1); + } + } + break; + case '#': + { + sal_Char *p=++pCtrl; + + while (p-pCtrl<32 && (BYTE)*p>'#') p++; + if (p!=pCtrl && *p=='#') + { + if (ScanKreuz("_S",pCtrl,nRet)) + AddHForm("S",rStr.Len(),1,1); + else if (ScanKreuz("_UHR",pCtrl,nRet)) + AddHForm("U",rStr.Len(),1,1); + else if (ScanKreuz("_PFAD",pCtrl,nRet)) + AddHForm("P",rStr.Len(),1,1); + else if (ScanKreuz("_AUTOR",pCtrl,nRet)) + AddHForm("A",rStr.Len(),1,1); + else if (ScanKreuz("_WORTE",pCtrl,nRet)) + AddHForm("sW",rStr.Len(),2,1); + else if (ScanKreuz("_ZEILEN",pCtrl,nRet)) + AddHForm("sZ",rStr.Len(),2,1); + else if (ScanKreuz("_SEITEN",pCtrl,nRet)) + AddHForm("sS",rStr.Len(),2,1); + else if (ScanKreuz("_DATUM",pCtrl,nRet)) + AddHForm("dT",rStr.Len(),2,1); + else if (ScanKreuz("_DATUMZ",pCtrl,nRet)) + AddHForm("dZ",rStr.Len(),2,1); + else if (ScanKreuz("_DATUMBU",pCtrl,nRet)) + AddHForm("dB",rStr.Len(),2,1); + else if (ScanKreuz("_DATUMMON",pCtrl,nRet)) + AddHForm("dM",rStr.Len(),2,1); + else if (ScanKreuz("_TEXTNAME",pCtrl,nRet)) + AddHForm("N",rStr.Len(),1,1); + else if (ScanKreuz("_KATEGORIE",pCtrl,nRet)) + AddHForm("iK",rStr.Len(),2,1); + else if (ScanKreuz("_THEMA\xA8",pCtrl,nRet)) + AddHForm("iT",rStr.Len(),2,1); + else if (ScanKreuz("_SCHL\x9A" "SSELWORT\xA8",pCtrl,nRet)) + AddHForm("iS",rStr.Len(),2,1); + else if (ScanKreuz("_N",pCtrl,nRet)){} + else if (ScanKreuz("_FN",pCtrl,nRet)){} + else if (ScanKreuz("_EN",pCtrl,nRet)){} + else if (*pCtrl>='A' && *pCtrl<='Z' || + *pCtrl>='a' && *pCtrl<='z') + { + ByteString aFld(pCtrl,p-pCtrl); + aFld.Convert( RTL_TEXTENCODING_IBM_850, + gsl_getSystemTextEncoding() ); + nRet=(size_t)(p-pCtrl)+2; + aFld.Insert((sal_Char)(p-pCtrl),0); + aFld.Insert('+',0); + AddHForm(aFld.GetBuffer(),rStr.Len(),aFld.Len(),1); + } + } + if (nRet<=1) rStr+='#'; + } + break; + case ParaGraf: // Achtung: mit IBM_PC geht + rStr+=ByteString::ConvertToUnicode( '\xA7', RTL_TEXTENCODING_MS_1252 );// nix: Zchn>=128 dann Conv + break; + case TabZch: // Tab erst spaeter einfg. + case InhKenn: // Dies Steuerzeichen werden + case IdxKenn: // erst ausgewertet, wenn + case PrGraf: // der komplette String ein- + case PrFnote: // gelesen worden ist. + case PrEnote: + case PrAttr: + case PrFont: + case PrSize: + case PrAForm: + AddHForm(pCtrl,rStr.Len(), // Attributumschaltung merken + ZchnZahl(pCtrl[0],pCtrl[1])+1); + default: + nRet=ZchnZahl(pCtrl[0],pCtrl[1])+1; + } // switch + return nRet; +} + +BOOL Sw6Layout::ReadLn(String &rStr) +// Liesst eine Writerzeile mit Steuerzeichen in rStr ein. +// Gibt FALSE zurueck, wenn ein Fehler auftrat... +// Einlesen eines Strings, Incrementiert lLin +{ + aSta.nAddo=0; // Kein Adder fuer HFORM->nOfs + aSta.cFrst='\0'; // cFrst nicht gesetzt + DelHForm(); // Falls in pFrm noch was ist + lLin++; + return Sw6File::ReadLn(rStr); // Kein Fehler aufgetreten +} + +BOOL Sw6Layout::IgnExtra(BOOL bNote,short nAnzl,SwTwips *plHoch) +// Liesst und ignoriert Texte bis eine Sonderzeile +// entdeckt wird. Bei Noten==FALSE bis Zeile==^G +// und bei Noten==TRUE bis Zeile==^L, dann Ende... +{ + String aStg; + + if (plHoch) *plHoch=0; + do { + if (Eof()) // Unexpc'd Eof? + { + *pErr=ERR_SW6_UNEXPECTED_EOF; + return FALSE; + } + SetAlayTrans(); // Setze Translate je nach + if (!ReadLn(aStg)) return FALSE; // Alay und lesen Absatz + if (aStg.Len()) aSta.cFrst='\0'; // Ignore ^L/^G if aStg!="" + if ((bNote || aSta.cFrst!=NewCol) && + (!bNote || aSta.cFrst!=NewPage) && + (plHoch)) *plHoch+=TWIPINCH/6; // Ja, Text gefunden... + if (nAnzl && aSta.cFrst==NewCol) + { + if (!--nAnzl) return TRUE; // Nte Note gefunden... + } + } while ((bNote || aSta.cFrst!=NewCol) && // Lese bis zum Ende des + (!bNote || aSta.cFrst!=NewPage)); // Textes (Zeile mit ^L/^G) + return TRUE; // Keine Fehler aufgetreten +} + +BOOL Sw6Layout::ReadBool(void) +{ + String aStg; + + ReadLn(aStg); + return aStg.EqualsAscii(MLDBOOJAJA); +} + +void Sw6Layout::DelHForm(void) +{ + HFORM *pTmp; // Hangelzeiger fuer delete + + aSta.nAddo=0; // Adder fuer HFORM->nOfs auch 0 + while (aSta.pFrmt) + { // Falls noch harte Formatinfo + pTmp=aSta.pFrmt; // gespeichert ist wech damit + aSta.pFrmt=aSta.pFrmt->pNxt; + delete (sal_Char *)pTmp; // HFORM ist flexibler struct... + } +} + +void Sw6Layout::AddHForm(const sal_Char *pCtrl,short nPos,short nAnz,short nAdd) +{ + HFORM *pTmp=(HFORM *)&aSta.pFrmt; + + while (pTmp->pNxt) + { // Suche letztes Element + pTmp=pTmp->pNxt; // Aus der vorhandenen Liste + } + if (NULL!=(pTmp->pNxt=(HFORM *)new sal_Char[ + sizeof(*pTmp)-sizeof(pTmp->cDat)+nAnz])) + { + pTmp=pTmp->pNxt; // Fuelle Stackelement aus + pTmp->pNxt=NULL; // Next ist natuerlich NULL + pTmp->nOfs=nPos+aSta.nAddo; // Merke Pos im String + pTmp->nXtd=nAdd; // Merke fuers Attribut-Kramen + for (short n=0; n<nAnz; n++) + { + pTmp->cDat[n]=*pCtrl++; // Kopiere die Formatdaten + } + aSta.nAddo+=nAdd; // Evt. mehr addieren! + } +} + +BOOL Sw6Layout::LeseLayInfo(BOOL Konv) +{ + BOOL bIsTrans = IsTrans(); + + String aStg; // Einlese-String + + short Idx; // Indexe + short Idy; + short NumB; // Anzahl Blays + short NumA; // Anzahl Alays + short NumS; // Anzahl Slays + + ALAY *LocA; // WITH Ersatz... + BLAY *LocB; + SLAY *LocS; + TABU *LocT; + + pLay->DelLayout(TRUE,FALSE,FALSE); // Layout-Info loeschen + pLay->LastLayTm=0; // Keine Verbindung zum Layout + if (!Konv) + { // Zeitangabe Verbundenes Lay + ReadLn(aStg); // Steht hier damit die Text- + pLay->LastLayTm=aStg.ToInt32(); // blockangaben ab Zeile 4... + } + ReadLn(aStg); + pLay->PapierLen=aStg.ToInt32(); // Laenge des Papiers + ReadLn(aStg); + pLay->PapierBrt=aStg.ToInt32(); // Breite des Papiers + ReadLn(aStg); + + pLay->FNotenFlg=(0!=aStg.ToInt32()); // Fussnotennummerierung + ReadLn(aStg); + pLay->FNotenForm=(NUMMERIERNG)aStg.ToInt32(); // Fussnotenformat + pLay->FNotenLin=ReadBool(); // Fussnotenstrich + if (Konv) + { + pLay->FNotSForm=ZentrSatz; // Writer 5.x kennt das nicht + pLay->FNotSPerc=75; + pLay->FNotURand=0; + pLay->SpTrennWd=20; + } + else + { + ReadLn(aStg); + pLay->FNotSForm=(SATZTYP)aStg.ToInt32(); + ReadLn(aStg); + pLay->FNotSPerc=aStg.ToInt32(); + ReadLn(aStg); + pLay->FNotURand=aStg.ToInt32(); + ReadLn(aStg); + pLay->SpTrennWd=aStg.ToInt32(); // Twips Spaltentrennstrich + } + ReadLn(aStg); + pLay->ENotenForm=(NUMMERIERNG)aStg.ToInt32(); // Enotenformat + ReadLn(aStg); + pLay->SeitenForm=(NUMMERIERNG)aStg.ToInt32(); // Seitennummernformat + if (Konv) + { + ReadLn(aStg); // Erweitere Formatierung + pLay->GliedForm[0]=(NUMMERIERNG)aStg.ToInt32(); + for (Idx=1; Idx<MAXGLIED; Idx++) + { + pLay->GliedForm[Idx]= + pLay->GliedForm[0]; + } // fuer Gleiderungsebenen + } + else + { + for (Idx=0; Idx<MAXGLIED; Idx++) + { + ReadLn(aStg); + pLay->GliedForm[Idx]=(NUMMERIERNG)aStg.ToInt32(); + } + } + pLay->ANotenFlg=ReadBool(); + ReadLn(aStg); // 3 Zeilen Reserve + ReadLn(aStg); + ReadLn(aStg); + ReadLn(aStg); + NumB=aStg.ToInt32(); // Anzahl Fontuebersetz + ReadLn(aStg); + NumA=aStg.ToInt32(); // Anzahl Alays + ReadLn(aStg); + NumS=aStg.ToInt32(); // Anzahl Slays + if (!FileOk()) return FALSE; + if ((NumA==0) || (NumS==0)) + { + *pErr = ERR_SWG_FILE_FORMAT_ERROR; + return FALSE; // Mind. 1 Alay und 1 Slay + } + for (Idx=0; Idx<NumB; Idx++) // Fontuebersetzungen lesen } + { + if ((LocB=pLay->FileBlay[Idx]= + new(BLAY))==NULL) return FALSE; + pLay->NumBlay++; + SetTrans( TRUE ); + ReadLn(LocB->Remark); // Anmerkung + ReadLn(LocB->Key); // Tastenschluessel + SetTrans( bIsTrans ); + ReadLn(aStg); + LocB->BFNum=aStg.ToInt32(); // Fontnummer + LocB->bTran=TRUE; // Font OEM->ANSI + ReadLn(aStg); + LocB->BFSiz=aStg.ToInt32(); // FontSize + ReadLn(aStg); + LocB->BAttr=aStg.ToInt32(); // Fontattribute + if (!Konv) ReadLn(aStg); // 1 * Reserve + } + for (Idx=0; Idx<NumA; Idx++) // Alays lesen + { + if ((LocA=pLay->FileAlay[Idx]= + new(ALAY))==NULL) return FALSE; + pLay->NumAlay++; + SetTrans( TRUE ); + ReadLn(LocA->Remark); // Anmerkung + ReadLn(LocA->Key); // Tastenschluessel + SetTrans( bIsTrans ); + ReadLn(aStg); + LocA->Einzug=aStg.ToInt32(); // Linke Einrueckung 1. Zeile + ReadLn(aStg); + LocA->LRand=aStg.ToInt32(); // Linke Einrueckung + ReadLn(aStg); + LocA->RRand=aStg.ToInt32(); // Rechte Einrueckung + ReadLn(aStg); + LocA->ORand=aStg.ToInt32(); // Absatzabstand + ReadLn(aStg); + LocA->ABlay=aStg.ToInt32(); // Fontuebersetz + if (LocA->ABlay>NumB) // Falls Fontuebersetzung + { // eigentlich gar nicht vor + LocA->ABlay=0; // handen sein sollte... + } + ReadLn(aStg); + LocA->AFNum=aStg.ToInt32(); // Fontnummer + LocA->bTran=TRUE; // Font OEM->ANSI + ReadLn(aStg); + LocA->AFSiz=aStg.ToInt32(); // FontSize + ReadLn(aStg); + LocA->AAttr=aStg.ToInt32(); // Wegen Runtime-Lib-Err + ReadLn(aStg); + LocA->FormatFlg=(SATZTYP)aStg.ToInt32(); // Formatierart + ReadLn(aStg); + LocA->SpaltAbst=aStg.ToInt32(); // Abstand der Spalten + ReadLn(aStg); + LocA->SpAnzahl=aStg.ToInt32(); // Spaltenanzahl-Flag + if (LocA->SpAnzahl==0 || + LocA->SpAnzahl>5) + { + LocA->SpAnzahl=1; + } + if (Konv) + { + ReadLn(aStg); // SpaltenTrennzeichen + LocA->SpTrenn=(aStg.ToInt32()>0); + } + else LocA->SpTrenn=ReadBool(); + LocA->SpAbsatz=ReadBool(); // Spaltenabsatz-Flag + LocA->AutoZlAb=ReadBool(); // Durchschussflag + ReadLn(aStg); + LocA->ZlAbstand=aStg.ToInt32(); // Zeilenabstand + ReadLn(aStg); + LocA->GliedLay=aStg.ToInt32(); // Gliederungsebene + if (LocA->GliedLay!=0 && LocA-> + GliedLay<=sizeof(Glieder) && + !Glieder[LocA->GliedLay-1]) // Gliederebene schon + { // mal genutzt worden? + Glieder[LocA->GliedLay-1]=TRUE; + } + else LocA->GliedLay=0; + if (Konv) + { + LocA->FrmAbst=0; + LocA->FrmWdth=16; + LocA->FrmArt=0; + LocA->LinLTyp=0; + LocA->LinRTyp=0; + LocA->Zusammen=FALSE; + } + else + { + ReadLn(aStg); + LocA->FrmAbst=aStg.ToInt32(); // Rahmenabstand + ReadLn(aStg); + LocA->FrmWdth=aStg.ToInt32(); // Liniendicke + LocA->FrmArt=0; // Vorinitialisierung + for (Idy=0; Idy<MaxFRMARTEN; Idy++) + { // 5 * Rahmenflag: O,U,L,R,Box + ReadLn(aStg); + LocA->FrmArt+=aStg.ToInt32()<<Idy; + } + ReadLn(aStg); + LocA->LinLTyp=aStg.ToInt32(); // Gpm-LinienArt + ReadLn(aStg); + LocA->LinRTyp=aStg.ToInt32(); // Gpm-RasterArt + LocA->Zusammen=ReadBool(); // Absatz zusammenhalten? + ReadLn(aStg); // 1 * Reserve + } + ReadLn(aStg); + LocA->MaxTabs=aStg.ToInt32(); // Anzahl Tabulatoren + for (Idy=0; Idy<LocA->MaxTabs; Idy++) + { + LocT=&LocA->Tabs[Idy]; + ReadLn(aStg); + LocT->TabPos=aStg.ToInt32(); // Tabulator-Position + ReadLn(aStg); // Tabulator-Art + LocT->TabArt=(TABARTEN)aStg.ToInt32(); + if (!Konv) + { + ReadLn(aStg); + LocT->TabZch=(sal_Char)aStg.ToInt32(); // Tabulator-Zeichen + } + else LocT->TabZch='\0'; + if (LocT->TabArt>Tab_D) + { + LocT->TabZch='.'; // Frueher auffuellende Tabs + LocT->TabArt=(TABARTEN) // Begenze Tabart auf Normal + ((short)LocT->TabArt & 3); + } + } // for Idy + + } // for Idx + for (Idx=0; Idx<NumS; Idx++) // Alle Seitenlayouts lesen + { + if ((LocS=pLay->FileSlay[Idx]= + new(SLAY))==NULL) return FALSE; + pLay->NumSlay++; + LocS->Follow=Idx; // Merke Folgelayout + LocS->KopfText=0; // Kein K/F-Text gelesen + LocS->KopfHoch=0; + LocS->FussText=0; + LocS->FussHoch=0; + SetTrans( TRUE ); + ReadLn(LocS->Remark); // Anmerkung + ReadLn(LocS->Key); // Tastenschluessel + SetTrans( bIsTrans ); + ReadLn(aStg); + LocS->KopfAbst=aStg.ToInt32(); // Kopfabstand + ReadLn(aStg); + LocS->FussAbst=aStg.ToInt32(); // Fussabstand + if (Konv) + { + if (LocS->FussAbst>(TWIPINCH/6)) + { // Frueher war das anders + LocS->FussAbst-=(TWIPINCH/6); + } + else LocS->FussAbst=0; + } + ReadLn(aStg); + LocS->LRand=aStg.ToInt32(); // Linker Rand + ReadLn(aStg); + LocS->RRand=aStg.ToInt32(); // Rechter Rand + ReadLn(aStg); + LocS->ORand=aStg.ToInt32(); // Oberer Rand + ReadLn(aStg); + LocS->URand=aStg.ToInt32(); // Unterer Rand + ReadLn(aStg); + LocS->SpaltAbst=aStg.ToInt32(); // Spaltenabstand + ReadLn(aStg); + LocS->Gueltig=aStg.ToInt32(); // Gueltigkeit + ReadLn(aStg); + LocS->SpAnzahl=aStg.ToInt32(); // Anzahl der Spalten + if (LocS->SpAnzahl==0 || + LocS->SpAnzahl>5) + { + LocS->SpAnzahl=1; + } + if (Konv) + { + ReadLn(aStg); // SpaltenTrennzeichen + LocS->SpTrenn=(aStg.ToInt32()>0); + } + else LocS->SpTrenn=ReadBool(); + ReadLn(aStg); + LocS->KopfTNum=aStg.ToInt32(); // Nummer Kopftext + ReadLn(aStg); + LocS->FussTNum=aStg.ToInt32(); // Nummer Fusstext + if (!Konv) ReadLn(aStg); // 1 * Reserve + + LocS->KopfText=Tell(); + if (!IgnExtra(FALSE,0,&LocS-> // Kopftext ueberlesen + KopfHoch)) return FALSE; + LocS->FussText=Tell(); + if (!IgnExtra(FALSE,0,&LocS-> // Fusstext ueberlesen + FussHoch)) return FALSE; + } + return TRUE; +} + +BOOL Sw6Layout::LeseKoFu(BOOL Kopf) +// Liesst harte Kopf- oder Fusstexte ein +{ + short Idx; + short Anz; + String Stg; + KOFU *LocF; + + pLay->DelLayout(FALSE,Kopf,!Kopf); // Kopf oder Fusslayout loeschen + ReadLn(Stg); + Anz=Stg.ToInt32(); + if (!FileOk()) return FALSE; + for (Idx=0; Idx<Anz; Idx++) + { + if (Kopf) + { + if ((LocF=pLay->HartKopf[Idx]= + new(KOFU))==NULL) return FALSE; + pLay->NumKopf++; + } + else + { + if ((LocF=pLay->HartFuss[Idx]= + new(KOFU))==NULL) return FALSE; + pLay->NumFuss++; + } + ReadLn(LocF->Remark); + ReadLn(LocF->Key); + LocF->KFText=Tell(); + if (!FileOk() || !IgnExtra(FALSE)) + { + return FALSE; + } + } + return IgnExtra(TRUE); +} + +SwTxtFmtColl *Sw6Layout::GetAlay(void) +// Holt die gerade gueltige FmtColl +{ + ASSERT(aSta.nAlay>=0 && aSta.nAlay<pLay->NumAlay,"Ungueltiges Alay"); + return pLay->FileAlay[aSta.nAlay]->pFmtColl; +} + +SvxAdjust Sw6Layout::TransAdj(SATZTYP eForm) +// Uebersetzt Formatierart +{ + SvxAdjust eAdj=SVX_ADJUST_LEFT; // Default immer links + switch (eForm) // Satztyp uebergeben + { + case AustrSatz: // Unbekannt in SWG! + case SperrSatz: // Gibt es auch nicht + case BlockSatz: + eAdj=SVX_ADJUST_BLOCK; + break; + case RechtsSatz: + eAdj=SVX_ADJUST_RIGHT; + break; + case ZentrSatz: + eAdj=SVX_ADJUST_CENTER; + break; + case UnformSatz: // Behandle wie linksbuendig + break; + } // switch + return eAdj; +} + +SfxPoolItem *Sw6Layout::TransAtt(ATTRBITS eAttr,BOOL bEin,SwTwips nSiz) +// Uebersetzt Fontattribut SW5->SWG +{ + switch (eAttr) + { + case Gross2 :return new SvxFontHeightItem( (ULONG)nSiz*(bEin?2:1)); + case Gross4 :return new SvxFontHeightItem( (ULONG)nSiz*(bEin?4:1)); + case Fett :return new SvxWeightItem(bEin?WEIGHT_BOLD:WEIGHT_NORMAL); + case Kursiv :return new SvxPostureItem(bEin?ITALIC_NORMAL:ITALIC_NONE); + case Unter :return new SvxUnderlineItem(bEin?UNDERLINE_SINGLE:UNDERLINE_NONE); + case DUnter :return new SvxUnderlineItem(bEin?UNDERLINE_DOUBLE:UNDERLINE_NONE); + case Durch :return new SvxCrossedOutItem(bEin?STRIKEOUT_DOUBLE:STRIKEOUT_NONE); + case DDurch :return new SvxCrossedOutItem(bEin?STRIKEOUT_SINGLE:STRIKEOUT_NONE); + case Hoch :return new SvxEscapementItem(bEin?SVX_ESCAPEMENT_SUPERSCRIPT:SVX_ESCAPEMENT_OFF); + case Tief :return new SvxEscapementItem(bEin?SVX_ESCAPEMENT_SUBSCRIPT:SVX_ESCAPEMENT_OFF); + case Outl :return new SvxContourItem(bEin); + case OutShad:return new SvxContourItem(bEin); + case Shad :return new SvxShadowedItem(bEin); + case FRot :return new SvxColorItem( Color( bEin?COL_RED:COL_BLACK)); + case FBlau :return new SvxColorItem( Color( bEin?COL_BLUE:COL_BLACK)); + case FMag :return new SvxColorItem( Color( bEin?COL_MAGENTA:COL_BLACK)); + case FGelb :return new SvxColorItem( Color( bEin?COL_YELLOW:COL_BLACK)); + case FOrange:return new SvxColorItem( Color( bEin?COL_LIGHTRED:COL_BLACK)); + case FGruen :return new SvxColorItem( Color( bEin?COL_GREEN:COL_BLACK)); + case FCyan :return new SvxColorItem( Color( bEin?COL_CYAN:COL_BLACK)); + default: return NULL; + } // switch +} + +void Sw6Layout::TransFnt( short nFnt, FontFamily &rFam, + FontPitch &rPit, CharSet &rSet, String &rNam ) +// Uebersetzt Fontnummer nFnt nach Family und Pitch +{ + Sw6PrinterFont aFontDef; + aFontDef.nFontNo = 0; + if( USHRT_MAX != nLastFontMatch ) + { + const Sw6PrinterFont* pFonts = aFntMatch[ nLastFontMatch ].pFonts; + for( ; pFonts->nFontNo; ++pFonts ) + if( pFonts->nFontNo == nFnt ) + { + aFontDef = *pFonts; + break; + } + } + + if( !aFontDef.nFontNo ) + { + // Je nach Fontnummer einen Default zusammenstellen, wie er im Config + // stehen koennte ... + aFontDef.bPCFont = sal_True; + aFontDef.bFixPitch = sal_True; + if( nFnt < 33 ) + { + aFontDef.nFontNo = 33; + aFontDef.nFontNmNo = 69; + aFontDef.eFamily = FAMILY_SYSTEM; + } + else if( nFnt < 65 ) + { + aFontDef.nFontNo = 65; + aFontDef.nFontNmNo = 1; + aFontDef.eFamily = FAMILY_MODERN; + } + else if( nFnt < 97 ) + { + aFontDef.nFontNo = 97; + aFontDef.nFontNmNo = 215; + aFontDef.eFamily = FAMILY_SWISS; + aFontDef.bFixPitch = sal_False; + } + else if( nFnt < 129 ) + { + aFontDef.nFontNo = 129; + aFontDef.nFontNmNo = 274; + aFontDef.eFamily = FAMILY_ROMAN; + aFontDef.bFixPitch = sal_False; + } + else + { + rFam = FAMILY_DONTKNOW; + rSet = RTL_TEXTENCODING_IBM_850; + rPit = PITCH_VARIABLE; + } + } + + if( aFontDef.nFontNo ) + { + rNam.AssignAscii( aFontNames[ aFontDef.nFontNmNo ] ); + rFam = aFontDef.eFamily; + if( aFontDef.bPCFont ) + rSet = RTL_TEXTENCODING_IBM_850; + rPit = aFontDef.bFixPitch ? PITCH_FIXED : PITCH_VARIABLE; + } +} + +BOOL Sw6Layout::TransFSA(SwFmt &rFmt, short nFnt, short nSiz, ATTRS nAtt) +// Uebersetzt Font/SSize/Attribut aus den DOS-SW in ein SwCharFmt +// Dabei wird TRUE zurueckgegeben, wenn so ausgezeichnete Zeichen +// von IBM-PC Zeichensatz nach OEM umgesetzt werden sollten. +{ + const SvxFontItem& rFont = rFmt.GetFont(); + FontFamily eFam=rFont.GetFamily(); + FontPitch ePit=rFont.GetPitch(); + CharSet eSet=rFont.GetCharSet(); + String aNam=rFont.GetFamilyName(); + String aSty=rFont.GetStyleName(); + + SfxItemSet aSet( *rFmt.GetAttrSet().GetPool(), + rFmt.GetAttrSet().GetRanges() ); + TransFnt(nFnt,eFam,ePit,eSet,aNam); // Matsche SW6->SWG + aSet.Put( SvxFontItem(eFam,aNam,aSty,ePit, + RTL_TEXTENCODING_DONTKNOW ) ); // Neuen Font anmelden + aSet.Put( SvxFontHeightItem(nSiz*10) ); // Neue SSize anmelden + + for (short nIdx=0; nIdx<ATTRBITS_END; nIdx++) + { + if (nAtt & ((ATTRS)1<<nIdx)) + { + SfxPoolItem *pTmp=TransAtt( + (ATTRBITS)nIdx,TRUE,nSiz*10); + if (pTmp) + { + aSet.Put( *pTmp ); + delete pTmp; + } + } + } + rFmt.SetAttr( aSet ); + return eSet==RTL_TEXTENCODING_IBM_850; // Merke ob Uebersetzen +} + +void Sw6Layout::InsertTab(USHORT nTab,TABU &rTab,SvxTabStopItem &rTabs,SwTwips nKor) +// Packt einen Writer-TABU in ein SvxTabStop +// nTab ist die Nummer des Tabs aus FmtTabStops +// nKor ist ein Korrekturwert wegen linker Rand++ +{ + sal_Unicode eFill=cDfltFillChar; + if ((BYTE)rTab.TabZch>' ') + { + eFill= ByteString::ConvertToUnicode( rTab.TabZch, RTL_TEXTENCODING_IBM_850 ); + } + + SvxTabAdjust eAdjust=SVX_TAB_ADJUST_LEFT; + switch (rTab.TabArt) + { + case Tab_R:eAdjust=SVX_TAB_ADJUST_RIGHT; + break; + case Tab_Z:eAdjust=SVX_TAB_ADJUST_CENTER; + break; + case Tab_D:eAdjust=SVX_TAB_ADJUST_DECIMAL; + break; + } // switch + + SvxTabStop aTab(rTab.TabPos-nKor,eAdjust,cDfltDecimalChar,eFill); + if(nTab<rTabs.Count()) + { + rTabs.Remove(nTab); + } + rTabs.Insert(aTab); +} + +void Sw6Layout::InsertExtra(SwDoc &rDoc,SwPaM &rPaM, + const SwNodeIndex &rWohin,long lFPos,sal_Char *pcAKey) +// Fuege einen Sondertext an die Stelle rDoc/rPaM ein. +// Dazu suche mittels Seek den Text, lese die Absaetze +// ein und seeke wieder zurueck an die Ausgangsposition +{ + String aStg; + short nOldA=aSta.nAlay; // Gemerkte Alaynummer + BOOL bErrs=FALSE; // Fehler aufgetreten? + SwPosition aMerk(*rPaM.GetPoint()); // Merke alte Einfgposition + + aSta.nAlay=0; + if (pcAKey) // Vorgabe eines Layout- + { // kennzeichners vorhanden? + ScanLayoutA(aSta.nAlay,pLay->FileAlay, // z.B. Standard KO fuer + pcAKey[0],pcAKey[1],pLay->NumAlay); // Kopftexte hier suchen + } + PushStat(lFPos); // Springe zum Extratext + rPaM.GetPoint()->nNode=rWohin; // Setze den PaM auf den in + rPaM.GetPoint()->nContent. // rWohin angegebenen Node + Assign(rPaM.GetCntntNode(),0); + aSta.nBlay=0; // Kein BLay gueltig + + do { + SetAlayTrans(); // Setze Translate je nach + if (ReadLn(aStg)) // Alay und lesen Absatz + { + if (aStg.Len()) aSta.cFrst='\0'; // Ignore ^L/^G if Stg!="" + if ((aSta.cFrst!=NewCol) && + (aSta.cFrst!=NewPage)) + { + rDoc.SetTxtFmtColl(rPaM,GetAlay()); + if (!InsertLine(rDoc,rPaM,aStg,TestCtrl( + NewPage) || TestCtrl(NewCol))) + { + bErrs=TRUE; + } + } + } + else bErrs=TRUE; + } while (!bErrs && // Lese bis zum Ende des + (aSta.cFrst!=NewCol) && // Textes (Zeile mit ^L/^G) + (aSta.cFrst!=NewPage)); + + *rPaM.GetPoint()=aMerk; // PaM wieder zuruecksetzen + aSta.nAlay=nOldA; // Altes Layout zurueck + PopStat(); // Wieder zur Ausgangspos +} + +BOOL Sw6Layout::InsertNote(SwDoc &rDoc,SwPaM &rPaM,USHORT nNote, BOOL bFuss) +// Fuege eine Fuss/Endnote in den Text ein. +// Gibt TRUE zurueck wenn tatsaechlich eine +// Fuss- oder Endnote eingefuegt wurde. +// Wenn nNote<0 dann Anmerkung->PostIt +{ + BOOL bRet=FALSE; + + if (bFuss) + { + BOOL bErrs=FALSE; + + PushStat(nNote&0x8000? // Suchen entweder Anmer- + pLay->ANotenLink: // kung oder FussNote raus + pLay->FNotenLink); + if (nNote&0x7FFF) + { // Suche Anfang dieser Note + bErrs=!IgnExtra(TRUE,nNote&0x7FFF); // Wenn das noetig ist. + } + if (!bErrs) + { + if (!(nNote&0x8000)) + { + SwFmtFtn aFtn; // Ein Fussnotennode in + rDoc.Insert(rPaM,aFtn); // den Text einfuegen und + SwPaM aPaM(rPaM); // dann den Text dazu holen + aPaM.Move(fnMoveBackward,fnGoCntnt); + // Auf's Fussnotenzeichen + SwNodeIndex aSttIdx(*(((SwTxtFtn*)aPaM.GetNode()-> + GetTxtNode()->GetTxtAttr(aPaM.GetPoint()-> + nContent,RES_TXTATR_FTN))->GetStartNode()),1); + InsertExtra(rDoc,rPaM,aSttIdx,-1,"FN"); + bRet=TRUE; // Hier alles Fehlerfrei... + } + else + { + String aStg,aNot; // Liess Anmerkung nach aNot + do // und verknuepfe mehrere + { // Absaetze zu einem String + if (ReadLn(aStg)) + { + if (aStg.Len()) aSta.cFrst='\0'; + if ((aSta.cFrst!=NewCol) && + (aSta.cFrst!=NewPage)) + { +#ifdef WIN + if (aNot.Len()) aNot+="\r\n"; +#else + if (aNot.Len()) aNot+='\n'; +#endif + aNot+=aStg; + } + } + else bErrs=TRUE; + } while (!bErrs && // Lese bis zum Ende des + (aSta.cFrst!=NewCol) && // Textes (Zeile mit ^L/^G) + (aSta.cFrst!=NewPage)); + if (!bErrs && aNot.Len()) + { + Date aDate; + String aLeer; + + SwPostItField aFld((SwPostItFieldType*) + rDoc.GetSysFldType(RES_POSTITFLD), + pDocInfo?pDocInfo->Autor:aLeer,aNot,aDate); + rDoc.Insert(rPaM,SwFmtFld(aFld)); + bRet=TRUE; + } + } + } + PopStat(); // Wieder zur Ausgangspos + } + return bRet; +} + +static SwTxtFmtColl* _GetTxtColl( SwDoc* pDoc, const String& rName, + const String& rKey ) +{ + USHORT n; + + // 1. Runde: ist der Name ein Poolformatname? + if( rName.Len() && + USHRT_MAX != (n = SwStyleNameMapper::GetPoolIdFromUIName( rName, GET_POOLID_TXTCOLL )) ) + return pDoc->GetTxtCollFromPoolSimple( n, FALSE ); + + // 2. Runde: ueber den Namen suchen; ueber den vollstaendigen ! + String sNm( rKey ); + if( rName.Len() ) + { + sNm += ' '; + sNm += rName; + } + + SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( sNm ); + if( !pColl ) + pColl = pDoc->MakeTxtFmtColl( sNm, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); + return pColl; +} + +static SwCharFmt* _GetCharFmt( SwDoc* pDoc, const String& rName, + const String& rKey ) +{ + USHORT n; + + // 1. Runde: ist der Name ein Poolformatname? + if( rName.Len() && + USHRT_MAX != (n = SwStyleNameMapper::GetPoolIdFromUIName( rName, GET_POOLID_CHRFMT )) ) + return pDoc->GetCharFmtFromPool( n ); + + // 2. Runde: ueber den Namen suchen + String sNm( rKey ); + if( rName.Len() ) + { + sNm += ' '; + sNm += rName; + } + + SwCharFmt* pFmt = pDoc->FindCharFmtByName( sNm ); + if( !pFmt ) + pFmt = pDoc->MakeCharFmt( sNm, pDoc->GetDfltCharFmt() ); + return pFmt; +} + +void Sw6Layout::InsertLayouts(SwDoc &rDoc, SwPaM *pPaM) +// Schiesst alle Layouts in das Dokument +{ + short Idx; // Index fuer Layouts + + SwFtnInfo aInfo; + aInfo=rDoc.GetFtnInfo(); // Wow: was 'ne Aktion...! + aInfo.ePos=FTNPOS_PAGE; // GetFntInfo ist const & + rDoc.SetFtnInfo(aInfo); + + for (Idx=pLay->NumBlay-1; Idx>=0; Idx--) + { + BLAY *pBly=pLay->FileBlay[Idx]; // Zeiger auf aktuelles Blay + // Erzeuge neues SwCharFmt + pBly->pCharFmt = _GetCharFmt( &rDoc, pBly->Remark, pBly->Key ); + + pBly->bTran=TransFSA(*pBly-> // Uebertrage die Fontnummer + pCharFmt,pBly->BFNum, // und die Attribute aus SW + pBly->BFSiz,pBly->BAttr); // in die SWG-Umgebung + } // for pLay->NumBlay + + for (Idx=0; Idx<pLay->NumAlay; Idx++) + { + ALAY *pAly=pLay->FileAlay[Idx]; // Zeiger auf aktuelles Alay + // Suche/Erzeuge SwTxtFmtColl + pAly->pFmtColl = _GetTxtColl( &rDoc, pAly->Remark, pAly->Key ); + + SfxItemSet aSet( *pAly->pFmtColl->GetAttrSet().GetPool(), + pAly->pFmtColl->GetAttrSet().GetRanges() ); + // Gliederebene setzen + pAly->pFmtColl->SetOutlineLevel( pAly->GliedLay>0 + ? pAly->GliedLay-1 + : NO_NUMBERING ); + + if (pAly->ABlay!=0) // BLay-Nummer ist gueltig? + { + BLAY *pBly=pLay->FileBlay[pAly->ABlay-1]; + + pAly->bTran=pBly->bTran; // Merke auch Uebersetzung +#ifdef JP_NEWCORE +JP 29.09.94: zur Zeit keine Zeichen-Vorlage an der Format-Vorlage + pAly->pFmtColl->SetCharFmt( // Trage das Blay am Alay ein + pBly->pCharFmt); +#endif + } + else + { // Harter Font/SSize/Attr + pAly->bTran=TransFSA( // Merke ob Trans OEM->Dflt + *pAly->pFmtColl, // Aendere SwCharFmt Alay + pAly->AFNum,pAly->AFSiz,pAly->AAttr); + } + SvxLRSpaceItem aLR; // Linken und rechten + aLR.SetLeft(USHORT(pAly->LRand)); // Absatzeinzug bestimmen + aLR.SetRight(USHORT(pAly->RRand)); + aLR.SetTxtFirstLineOfst( // Einzug erste Zeile + USHORT(pAly->Einzug-pAly->LRand)); + aSet.Put( aLR ); + + SvxULSpaceItem aUL; // Absatzabstand setzen + aUL.SetUpper(USHORT(pAly->ORand)); + aSet.Put( aUL ); + + SvxLineSpacingItem aLSpc; // Height=0, Methode MIN, INTER_OFF + aLSpc.SetLineHeight(pAly->ZlAbstand); + + if (pAly->AutoZlAb) // ZlAbstand Durchschuss? + { + aLSpc.SetLineHeight(0); + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.SetInterLineSpace(pAly->ZlAbstand); + } + aSet.Put( aLSpc ); // Abstand uebergeben + + aSet.Put( SvxAdjustItem(TransAdj(pAly->FormatFlg) )); + aSet.Put( SvxFmtSplitItem(!pAly->Zusammen) ); // Absatz zusammenhalten? + + if (pAly->FrmArt&0x1F && pAly->LinLTyp>1) + { + if (pAly->FrmArt&0x10) // Falls Rahmen drumherum + pAly->FrmArt|=0x0F; + ColorData eColor=COL_BLACK; // Zu verwendende Farbe + switch (pAly->LinLTyp) + { + case 2: + case 3: + eColor=COL_WHITE; + break; + case 4: + case 5: + case 6: + eColor=COL_LIGHTGRAY; + break; + case 7: + case 8: + eColor=COL_GRAY; + } // switch + SvxBoxItem aFBox; + Color aColor(eColor); + SwLineType aLTyp=GetLineType((USHORT)(pAly-> + FrmWdth>10*20?10:pAly->FrmWdth/20)); + SvxBorderLine aBord(&aColor,aLTyp. + nOut,aLTyp.nIn,aLTyp.nDist); + + aFBox.SetDistance((USHORT)pAly->FrmAbst); + if (pAly->FrmArt&0x2) + aFBox.SetLine (&aBord, BOX_LINE_RIGHT); + if (pAly->FrmArt&0x8) + aFBox.SetLine (&aBord, BOX_LINE_BOTTOM); + if (pAly->FrmArt&0x1) + aFBox.SetLine (&aBord, BOX_LINE_LEFT); + if (pAly->FrmArt&0x4) + aFBox.SetLine (&aBord, BOX_LINE_TOP); + aSet.Put( aFBox ); + } + if (pAly->LinRTyp>1) + { + ColorData eColor=COL_BLACK; +// BrushStyle eBrush=BRUSH_SOLID; + switch (pAly->LinRTyp) + { + case 2:eColor=COL_WHITE; break; +// case 3:eBrush=BRUSH_UPDIAG; break; +// case 4:eBrush=BRUSH_DOWNDIAG; break; +// case 5:eBrush=BRUSH_CROSS; break; +// case 6:eBrush=BRUSH_DIAGCROSS; break; +// case 7:eBrush=BRUSH_25; break; +// case 8:eBrush=BRUSH_50; break; +// case 9:eBrush=BRUSH_75; break; + } // switch +// Brush aBrush=Brush(Color(eColor),eBrush); +// aBrush.SetTransparent(FALSE); + Color aTmpColor(eColor); + SvxBrushItem aBack( aTmpColor, RES_BACKGROUND); + aSet.Put( aBack ); + } + + SvxTabStopItem aTabs(0,0); // Erzeuge Tab-Tabelle + for (short n=0; n<pAly->MaxTabs; n++) // muss sein, falls LRand & + { // und Einzug ungleich sind + InsertTab(n,pAly->Tabs[n], + aTabs,pAly->LRand); + } + aSet.Put( aTabs ); // Alle Tabs ins Format + pAly->pFmtColl->SetAttr( aSet ); + } // for pLay->NumAlay + + for (Idx=0; Idx<pLay->NumSlay; Idx++) + { + USHORT nPageDesc=0; + SLAY *pSly=pLay->FileSlay[Idx]; // Zeiger auf aktuelles Slay + String aNam=pSly->Key; + if (pSly->Remark.Len()) + aNam+=' '; + aNam += pSly->Remark; + + if (Idx!=0) // Default Pagedesc ein- + { // fach ueberschreiben oder + nPageDesc=rDoc.MakePageDesc(aNam, 0, FALSE); + // sonst einen neuen machen + } + + SwPageDesc &rPg=(SwPageDesc &)rDoc. + GetPageDesc(nPageDesc); + + if (Idx==0) rPg.SetName(aNam); // setze den Follow-PageDesc + rPg.SetFollow(&rPg); // erstmal auf sich selbst + rPg.SetUseOn((UseOnPage)(PD_ALL|PD_HEADERSHARE|PD_FOOTERSHARE)); + + if (Idx==0) + { // 1.Slay auch gueltig machen + rDoc.Insert(*pPaM,SwFmtPageDesc( + &rDoc.GetPageDesc(nPageDesc))); + } + // Seitenhoehe einstellen + SwFrmFmt &rFmt=rPg.GetMaster(); + SwFmtFrmSize aSiz(rFmt.GetFrmSize()); + aSiz.SetWidth(pLay->PapierBrt); // Setze Papierbreite + aSiz.SetHeight(pLay->PapierLen); // Setze Papierlaenge + rFmt.SetAttr(aSiz); // Melde Dokumentformat an + + { // Seitenformat setzen + SvxLRSpaceItem aLR(rFmt.GetLRSpace()); + aLR.SetLeft(USHORT(pSly->LRand)); + aLR.SetRight(USHORT(pSly->RRand)); + rFmt.SetAttr(aLR); + + SvxULSpaceItem aUL(rFmt.GetULSpace()); + + if (pSly->KopfHoch>pSly->ORand) // Begrenze Kopftexthoehe + pSly->KopfHoch=pSly->ORand; // und den Kopftextabstand + if (pSly->KopfAbst>pSly->ORand-pSly->KopfHoch) + pSly->KopfAbst=pSly->ORand-pSly->KopfHoch; + if (pSly->KopfHoch) // Kopftext ueberhaupt da? + { + aUL.SetUpper(USHORT(pSly->KopfAbst)); + } + else aUL.SetUpper(USHORT(pSly->ORand)); + + if (pSly->FussAbst>pSly->URand) // Begrenze Fusstextabstand + pSly->FussAbst=pSly->URand; // und die Fusstexthoehe + if (pSly->FussHoch>pSly->FussAbst) + pSly->FussHoch=pSly->FussAbst; + if (pSly->FussHoch) // Fusstext ueberhaupt da? + { + aUL.SetLower((USHORT(pSly->FussAbst- // UL.Lower auf den + pSly->FussHoch))); // Fusstextabstand + } + else aUL.SetLower(USHORT(pSly->URand)); + + rFmt.SetAttr(aUL); + } + { // Abst and Kopftext setzen + + rFmt.SetAttr(SwFmtHeader( // Evt. kein Kopftext... + pSly->KopfHoch!=0)); + if (pSly->KopfHoch!=0) + { + SwFrmFmt *pFmt=(SwFrmFmt*)rFmt. + GetHeader().GetHeaderFmt(); + SvxULSpaceItem aUL(pFmt->GetULSpace()); + aUL.SetUpper(0); + aUL.SetLower(USHORT(pSly->ORand-pSly-> + KopfAbst-pSly->KopfHoch)); + pFmt->SetAttr(aUL); // Attribute Kopftext setzen + SwNodeIndex aIdx( *pFmt->GetCntnt().GetCntntIdx(), 1 ); + InsertExtra(rDoc,*pPaM,aIdx, // Eigentlichen Text einlesen + pSly->KopfText,"KO"); + } + } + { // Abstand Fusstext setzen + rFmt.SetAttr(SwFmtFooter( // Evt. kein Fusstext... + pSly->FussHoch!=0)); + if (pSly->FussHoch!=0) + { + SwFrmFmt *pFmt=(SwFrmFmt*)rFmt. + GetFooter().GetFooterFmt(); + SvxULSpaceItem aUL(pFmt->GetULSpace()); + aUL.SetUpper(USHORT(pSly-> + URand-pSly->FussAbst)); + aUL.SetLower(0); + pFmt->SetAttr(aUL); // Attribute Fusstext setzen + SwNodeIndex aIdx( *pFmt->GetCntnt().GetCntntIdx(), 1 ); + InsertExtra(rDoc,*pPaM,aIdx, // Eigentlichen Text einlesen + pSly->FussText,"FU"); + } + } + { // Fussnoteninfo setzen + SwPageFtnInfo aInfo(rPg.GetFtnInfo()); + +// Pen aPen(aInfo.GetPen()); +// aPen.SetStyle(pLay->FNotenLin?PEN_SOLID:PEN_NULL); + if(!pLay->FNotenLin) + aInfo.SetLineColor(Color(COL_TRANSPARENT)); + + switch (pLay->FNotSForm) + { + case RechtsSatz: + aInfo.SetAdj(FTNADJ_RIGHT); + break; + case ZentrSatz: + aInfo.SetAdj(FTNADJ_CENTER); + break; + default: + aInfo.SetAdj(FTNADJ_LEFT); + break; + } // switch + aInfo.SetWidth(Fraction(pLay->FNotSPerc,100)); + if (pLay->FNotURand>aInfo.GetTopDist()) + { + aInfo.SetTopDist(pLay->FNotURand); + } + rPg.SetFtnInfo(aInfo); + } + rDoc.ChgPageDesc(nPageDesc,rPg); + } // for pLay->NumSlay +} + +void Sw6Layout::InsertAForm(SwDoc &rDoc,SwPaM &rPaM,BYTE *pCtrl) +// Gibt einem Absatz die spezielle Form, die der wohl +// soll; mittels harter Formatierung ist dies moeglich +{ + SvxLineSpacingItem aLSpc; // Zum Zeilenabstand setzen + SvxLRSpaceItem aLR; // Zum link/rechten Rand setzen + SvxULSpaceItem aUL; // Zum Absatztabstand setzen + SwTxtNode *pTxt; // Aktueller Absatz + SwAttrSet* pSet; // aktuelle Format-Attribute + short nWert; // Wert Zeilenabstand/Raender + + if (NULL!=(pTxt=rDoc.GetNodes()[rPaM. + GetPoint()->nNode]->GetTxtNode()) && + NULL!=(pSet=&pTxt->GetSwAttrSet()) ) + { + // Hole Wert in Twips und evt. drehen + nWert=SVBT16ToShort(&pCtrl[2]); + switch (pCtrl[1]) // Je nach Absatzformataenderung + { + case AF_Ein: // Einrueckung Twips + case AF_Lks: // Linker Rand Twips + { + SwTwips nLRnd; // Linker Rand Absatz (absolut) + SwTwips nEinz; // Einzug Absatz (absolut) + SwTwips nTemp; // Temporaerwert + + const SvxLRSpaceItem& rLR = pSet->GetLRSpace(); + nLRnd=rLR.GetLeft(); + if ((nTemp=nEinz=rLR.GetTxtFirstLineOfst())<0) + { + nEinz=nLRnd; // Der einfachheit halber Einzug + nLRnd-=nTemp; // und LRand als Absolutwerte + } + else nEinz+=nLRnd; + // Raender neu setzen + if (pCtrl[1]==AF_Ein) + nEinz=nWert; + else + nLRnd=nWert; + + aLR.SetLeft((USHORT)(nEinz<nLRnd?nEinz:nLRnd)); + aLR.SetRight(rLR.GetRight()); + aLR.SetTxtFirstLineOfst((USHORT)(nEinz-nLRnd)); + + rDoc.Insert(rPaM,aLR); // Und dann Raender hart rein... + } + break; + case AF_Rts: // Rechter Rand Twips + aLR.SetLeft(pSet->GetLRSpace().GetLeft()); + aLR.SetRight(nWert); + rDoc.Insert(rPaM,aLR); + break; + case AF_AbAb: // Absatzabstand Twips + aUL.SetUpper(nWert); + aUL.SetLower(pSet->GetULSpace().GetLower()); + rDoc.Insert(rPaM,aUL); + break; + case AF_Form: // Absatzformat Enum + rDoc.Insert(rPaM,SvxAdjustItem( + TransAdj((SATZTYP)pCtrl[2]))); + break; + case AF_SpAb: // Spaltenabstand Twips + break; + case AF_SpAn: // Spaltenanzahl Byte + break; + case AF_SAbs: // Spaltenabsatz Bool + break; + case AF_Auto: // Durchschuss Bool + nWert=(pSet->GetLineSpacing().GetInterLineSpaceRule() + ==SVX_INTER_LINE_SPACE_OFF) ? + pSet->GetLineSpacing().GetInterLineSpace(): + pSet->GetLineSpacing().GetLineHeight(); + + aLSpc.SetLineHeight(nWert); + if (pCtrl[2]!='\0') + { + aLSpc.SetLineHeight(0); + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.SetInterLineSpace(nWert); + } + rDoc.Insert(rPaM,aLSpc); + break; + case AF_ZlAb: // Zeilenabstand Twips + aLSpc.SetLineHeight(nWert); + if (pSet->GetLineSpacing().GetInterLineSpaceRule() + !=SVX_INTER_LINE_SPACE_OFF) + { + aLSpc.SetLineHeight(0); + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.SetInterLineSpace(nWert); + } + rDoc.Insert(rPaM,aLSpc); + break; + case AF_Glied: // Gliederungslay Enum + break; + case AF_Tab: // Tabulator alt Struct + case AF_TabN: // Tabulator neu Struct + { + TABU aTab; // Ein SW6-Tab + SvxTabStopItem aTabs(0,0); // Eine neue Tab-Tabelle + + aTab.TabArt=(TABARTEN)(pCtrl[2]); + aTab.TabPos=SVBT16ToShort(&pCtrl[3]); + aTab.TabZch=(pCtrl[1]==AF_TabN)?pCtrl[5]:'\0'; + if (aTab.TabArt>Tab_D) + { + aTab.TabZch='.'; + aTab.TabArt=(TABARTEN)(aTab.TabArt & 3); + } + for (USHORT n=0; n<pSet->GetTabStops().Count(); n++) + { + aTabs.Insert(pSet->GetTabStops()[n]); + } + InsertTab(pSet->GetTabStops().Count(),aTab, + aTabs,pSet->GetLRSpace().GetTxtLeft()); + rDoc.Insert(rPaM,aTabs); + break; + } + case AF_Zus: // Zusammenhalten + rDoc.Insert(rPaM,SvxFmtSplitItem(pCtrl[2])); + break; + } // switch + } +} + +void Sw6Layout::InsertTOX(SwDoc &rDoc,SwPaM &rPaM, + USHORT nLen,HFORM *pTmp,TOXTypes eTyp) +// Kramt vom HFORM Stack den Rest eines +// Inhalts bzw. Indexeintrages zusammen +{ + const USHORT nToxID=0; // Leider nur ToxID==0 + + if (!rDoc.GetTOXTypeCount(eTyp)) // Noch keine TOX + { // da: mache neue + rDoc.InsertTOXType(SwTOXType( // Die Namen sind leider + eTyp, + String::CreateFromAscii( + eTyp==TOX_INDEX? // hart Kodiert, weil der + "Stichwortverzeichnis": // ctor zu bloed ist... + "Inhaltsverzeichnis"))); + } + + String aEntry; // TOX Entrystring + USHORT nMzAnz=0; // Anzahl markiert Zeichen + + if (pTmp->cDat[0]<' ') // Kein Textbefehl? + { // Suche das Ende + HFORM *pScd=pTmp->pNxt; // der Markierung + USHORT nKor=0; // Korrektur fuer Felder + + while (pScd && !nMzAnz) // oder evt. auch + { // {INDEX-Befehle} + nKor+=pScd->nXtd; + if (pScd->cDat[0]<' ') + { + if (pTmp->cDat[0]==pScd->cDat[0]) + { + nMzAnz=pScd->nOfs-pTmp->nOfs-nKor; + pScd->cDat[0]='@'; // HForm ungueltig + } + } + else + { if ((pScd->cDat[0]=='V' || + pScd->cDat[0]=='W') && + ((pTmp->cDat[0]==InhKenn) // Wenn Addon mittels Text- + ==(pScd->cDat[0]=='V'))) // befehl addiere aEntry+Bef + { + aEntry+=String((sal_Char *)&pScd-> + cDat[2],pScd->cDat[1]); + pScd->cDat[0]='@'; // HForm ungueltig + } + } + pScd=pScd->pNxt; // Naechsten HFORM + } // while + if (!nMzAnz) + { + nMzAnz+=nLen-pTmp->nOfs; // Default bis EndOfLine + } + } + else + { + aEntry=String((sal_Char *)&pTmp-> // Einfach nur einen + cDat[2],pTmp->cDat[1]); // neuen Eintrag schreiben + } + SwTOXMark aMark(rDoc. // Mache eine neue TOX-Marke + GetTOXType(eTyp,nToxID)); // und lasse sie von der + if (aEntry.Len()) // derzeitigen Position aus + { // nMzAnz Zeichen markieren + aMark.SetAlternativeText(aEntry); + } + if (eTyp==TOX_CONTENT) aMark.SetLevel(1); // Level muss man setzen! + + if( !aEntry.Len() ) + { + rPaM.SetMark(); + rPaM.GetMark()->nContent += nMzAnz; + } + rDoc.Insert( rPaM, aMark ); + if( !aEntry.Len() ) + rPaM.DeleteMark(); +} + +extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich, + USHORT& rSubType, UINT32 &rFmt, + USHORT nVersion ); + +BOOL Sw6Layout::InsertLine(SwDoc &rDoc,SwPaM &rPaM,String &rStg,BOOL bLast) +// Fuege eine neuen Zeile bei rPam ein +{ + if ((rStg.Len()==0 || + rDoc.Insert(rPaM, rStg)) && + (bLast || rDoc.SplitNode(*rPaM.GetPoint()))) + { + if (aSta.pFrmt) // Gibt es harte Forminfo? + { + HFORM *pTmp=aSta.pFrmt; // Klapper HForm-Stack durch + + SwPaM aPaM(rPaM); // NeuPaM, zeigt auf AbsAnf + aPaM.DeleteMark(); // Falls Mark noch gesetzt + if (!bLast) aPaM.Move( // Absatz zurueck falls ein + fnMoveBackward,fnGoNode); // Splitnode war + + while (pTmp) + { + USHORT nEnd=rDoc.GetNodes()[ // Merke jetzige Absatzlaenge + aPaM.GetPoint()->nNode]-> + GetTxtNode()->GetTxt().Len(); + aPaM.GetPoint()->nContent=pTmp->nOfs; + switch (pTmp->cDat[0]) + { + case TabZch: + { + ALAY *pTmpLay=pLay->FileAlay[aSta.nAlay]; + if (pTmp->nOfs!=0 || // Autotab hier unnoetig + pTmpLay->GliedLay==0 || + pTmpLay->LRand==pTmpLay->Einzug) + { + rDoc.Insert(aPaM,'\t'); + HFORM *pScd=pTmp->pNxt; + + while (pScd) // Alle Zeichen verschieben + { // sich weil ContentNode + if (pScd->nOfs>pTmp->nOfs) + { + pScd->nOfs++; + } + pScd=pScd->pNxt; + } + } + } + break; + case PrGraf: + { + String aTrb; // Treibername + String aNam; // Gemerkte Name falls Fehler + // Attribute fuer FlyFrames + SfxItemSet aFAtt(rDoc.GetAttrPool(), + RES_FRMATR_BEGIN, + RES_FRMATR_END-1 ); + GRAFDESC aGrf; + + aGrf.Hoch =SVBT16ToShort(&pTmp->cDat[2]); + aGrf.Breit=SVBT16ToShort(&pTmp->cDat[4]); + aGrf.Rand =SVBT16ToShort(&pTmp->cDat[6]); + aGrf.Rahm =SVBT8ToByte(&pTmp->cDat[8]); + aGrf.Bund =(GBUNDTYP)SVBT8ToByte(&pTmp->cDat[9]); + aGrf.Form =(GRAFSTAT)SVBT8ToByte(&pTmp->cDat[12]); + aGrf.Flag =SVBT8ToByte(&pTmp->cDat[14]); + for (USHORT n=0;n<pTmp->cDat[15];n++) + { + aNam+=(sal_Char)pTmp->cDat[n+16]; + } + + // search the correct path of the graphic + aNam = ::binfilter::StaticBaseUrl::SmartRelToAbs( aNam ); + if( !::binfilter::IsDocument( aNam ) ) + { + String sFNm( INetURLObject( aNam ).getName() ); + INetURLObject aURL( *pMyName ); + aURL.setName( sFNm ); + String sSrchGrf( aURL.GetMainURL( + INetURLObject::NO_DECODE )); + if( ::binfilter::IsDocument( sSrchGrf ) ) + aNam = sSrchGrf; + else + { + SvtPathOptions aPathOpt; + if( aPathOpt.SearchFile( sFNm, + SvtPathOptions::PATH_MODULE )) + aNam = sFNm; + } + } + +#define MAX_BORDER_SIZE 210 // So Breit ist max. der Border +#define MAX_EMPTY_BORDER 1 // So Breit wenn kein Rahmen drum + + SwTwips nMaxi=MAX_EMPTY_BORDER; + if ((aGrf.Rahm&0xf)>1) + { + SvxBoxItem aFBox; + SwLineType aLTyp=GetLineType( + (aGrf.Rahm&0xf)==3?5:1); + Color aColor(COL_BLACK); + SvxBorderLine aBord(&aColor,aLTyp. + nOut,aLTyp.nIn,aLTyp.nDist); + + aFBox.SetLine (&aBord, BOX_LINE_RIGHT); + aFBox.SetLine (&aBord, BOX_LINE_BOTTOM); + aFBox.SetLine (&aBord, BOX_LINE_LEFT); + aFBox.SetLine (&aBord, BOX_LINE_TOP); + aFAtt.Put(aFBox); + nMaxi=MAX_BORDER_SIZE; + } + SvxULSpaceItem aUL; + SvxLRSpaceItem aLR; + + aUL.SetUpper(USHORT(aGrf.Rand)); + aUL.SetLower(USHORT(aGrf.Rand)); + aLR.SetLeft (USHORT(aGrf.Rand)); + aLR.SetRight(USHORT(aGrf.Rand)); + aFAtt.Put(aUL); + aFAtt.Put(aLR); + + if (aGrf.Breit<MINFLY+2*aGrf.Rand+nMaxi) + aGrf.Breit=MINFLY+2*aGrf.Rand+nMaxi; + if (aGrf.Hoch<MINFLY+2*aGrf.Rand+nMaxi) + aGrf.Hoch=MINFLY+2*aGrf.Rand+nMaxi; + + aFAtt.Put(SwFmtFrmSize(ATT_FIX_SIZE, + aGrf.Breit+2*aGrf.Rand, + aGrf.Hoch+2*aGrf.Rand)); + + switch (aGrf.Bund) + { + case G_Nicht: + aFAtt.Put(SwFmtHoriOrient( + 0,HORI_NONE)); + break; + case G_Rechts: + aFAtt.Put(SwFmtHoriOrient( + 0,HORI_RIGHT)); + break; + case G_Zent: + aFAtt.Put(SwFmtHoriOrient( + 0,HORI_CENTER)); + break; + default: + aFAtt.Put(SwFmtHoriOrient( + 0,HORI_LEFT)); + break; + } + + rDoc.Insert( aPaM, aNam, aTrb,NULL, &aFAtt, 0 ); + } + break; + case PrFnote: + case PrEnote: + { + InsertNote(rDoc,aPaM, + SVBT16ToShort(&pTmp->cDat[1]), + pTmp->cDat[0]==PrFnote); + + HFORM *pScd=pTmp->pNxt; // Fnote ist Ctent + while (pScd) // Daher verschiebt + { // sich alle HForm + if (pScd->nOfs>pTmp->nOfs) + { + pScd->nOfs++; + } + pScd=pScd->pNxt; + } + } + break; + case PrAttr: + { + + HFORM *pScd=pTmp->pNxt; // Suche dann das Pedant + USHORT nKor=0; // Korrigiere nAdd zurueck + + while (pScd && (pScd->cDat[0]!=PrAttr || + pScd->cDat[1]!=pTmp->cDat[1])) + { + nKor+=pScd->nXtd; + pScd=pScd->pNxt; + } + if (pScd) + { + pScd->cDat[0]='@'; // Pedant ungueltig machen + nEnd=pScd->nOfs-nKor; // Merken neuen Ende-Offs im Absatz +// Falls ueber AddHForm eine Korrektur (nAdd) fuer druckbare Zeichen an- +// gegeben wurde, muss diese Korrektur hier rueckgaengig gemacht werden, +// weil dieses "druckbare" Zeichen nun erst spaeter eingefuegt wird. + } + if (pTmp->nOfs<nEnd && pTmp->cDat[1]>0 && + pTmp->cDat[1]<ATTRBITS_END) + { // Lohnt sonst nicht + SwPaM aTmpPaM(aPaM); // Noch'n PaM + aTmpPaM.SetMark(); + aTmpPaM.GetPoint()-> // Zum Ende Attribut + nContent+=(nEnd-pTmp->nOfs); + SfxPoolItem *pFmt=TransAtt( + (ATTRBITS)pTmp->cDat[1], + (pLay->FileAlay[aSta.nAlay]-> + AAttr & (1<<pTmp->cDat[1]))==0, + pLay->FileAlay[aSta.nAlay]->AFSiz*10); + if (pFmt) + { + rDoc.Insert(aTmpPaM,*pFmt); + delete pFmt; + } + } + break; + } + case PrFont: + { + SvxFontItem &rTmpFnt=(SvxFontItem &)pLay-> + FileAlay[aSta.nAlay]->pFmtColl->GetFont(); + + FontFamily eFam=rTmpFnt.GetFamily(); + FontPitch ePit=rTmpFnt.GetPitch(); + CharSet eSet=rTmpFnt.GetCharSet(); + String aNam=rTmpFnt.GetFamilyName(); + String aSty=rTmpFnt.GetStyleName(); + + short nFnt=pTmp->cDat[1]; + + if (nFnt==0) + { + nFnt=pLay->FileAlay[aSta.nAlay]->AFNum; + } + + SwPaM aTmpPaM(aPaM); // Noch'n PaM + aTmpPaM.SetMark(); // Setze Markanf + aTmpPaM.GetPoint()-> // Zum Ende des + nContent+=(nEnd- // Attributs + pTmp->nOfs); // setzen. + TransFnt(nFnt,eFam, // Font uebersetzen + ePit,eSet,aNam); + SetTrans(eSet==RTL_TEXTENCODING_IBM_850); // Evt. nicht trans + rDoc.Insert(aTmpPaM,SvxFontItem( // Nun Font ins Doc + eFam,aNam,aSty,ePit,RTL_TEXTENCODING_DONTKNOW)); + } + break; + case PrSize: + { + short nSiz=pTmp->cDat[1]; + if (nSiz==0) + { + nSiz=pLay->FileAlay[ + aSta.nAlay]->AFSiz; + } + + SwPaM aTmpPaM(aPaM); // Noch'n PaM + aTmpPaM.SetMark(); // Setze Markanf + aTmpPaM.GetPoint()-> // Zum Ende des + nContent+=(nEnd- // Attributs + pTmp->nOfs); // setzen. + rDoc.Insert(aTmpPaM, // Dann Fontsize + SvxFontHeightItem(nSiz*10)); // am Doc einfgen + } + break; + case PrAForm: + InsertAForm(rDoc,aPaM,pTmp->cDat); + break; + case HardSp: // HardSpace + rDoc.Insert(aPaM, CHAR_HARDBLANK); + break; + case STrenn: // Weicher Trenner + rDoc.Insert(aPaM,CHAR_SOFTHYPHEN); + break; + case 'B': + if (pTmp->cDat[1]!='\0') // Nur wenn Blay + { // neu gueltig ist + HFORM *pScd=pTmp->pNxt; // Suche immer das + USHORT nKor=0; // Gueltigkeitsende + + while (pScd && pScd->cDat[0]!='B') + { + nKor+=pScd->nXtd; + pScd=pScd->pNxt; + } + if (pScd) // Sonst bis Absend + { + nEnd=pScd->nOfs-nKor; + } + + SwPaM aTmpPaM(aPaM); // Noch'n PaM + aTmpPaM.SetMark(); // Setze Markanf + aTmpPaM.GetPoint()-> // Zum Ende Blay + nContent+=(nEnd-pTmp->nOfs); + BYTE nTmp=pTmp->cDat[1]; + rDoc.Insert(aTmpPaM, + SwFmtCharFmt((pLay->FileBlay[ + nTmp-1]->pCharFmt))); + } + break; + case NewPage: + rDoc.Insert(aPaM,SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE)); + break; + case 'V': + case InhKenn: + InsertTOX(rDoc,aPaM,nEnd,pTmp,TOX_CONTENT); + break; + case 'X': + case IdxKenn: + InsertTOX(rDoc,aPaM,nEnd,pTmp,TOX_INDEX); + break; + +#define InsField(TypeName,ResName,FieldSet) \ +{ \ + TypeName aFld((TypeName##Type*) \ + rDoc.GetSysFldType(ResName)); \ + aFld.ChangeFormat(FieldSet); \ + rDoc.Insert(aPaM,SwFmtFld(aFld)); \ +} + case 'A': + InsField(SwAuthorField,RES_AUTHORFLD,AF_NAME); + break; + case 'P': + InsField(SwFileNameField,RES_FILENAMEFLD,FF_PATH); + break; + case 'S': + { + SwPageNumberField aFld((SwPageNumberFieldType*) + rDoc.GetSysFldType(RES_PAGENUMBERFLD),PG_RANDOM,SVX_NUM_ARABIC); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + break; + } + case 'U': + { + USHORT nSubType = TIMEFLD, nWhich = RES_DATETIMEFLD; + UINT32 nFormat = (UINT32)TF_SSMM_24; + sw3io_ConvertFromOldField( rDoc, nWhich, nSubType, + nFormat, 0x0110 ); + + SwDateTimeField aFld((SwDateTimeFieldType*)rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + //InsField(SwTimeField,RES_TIMEFLD,TF_SSMM_24); + break; + } + case 'N': + InsField(SwFileNameField,RES_FILENAMEFLD,FF_NAME); + break; + case 'd': + { + SwDateFormat eDat=DF_SSYS; + switch (pTmp->cDat[1]) + { + case 'Z':eDat=DF_LSYS; break; + case 'B':eDat=DF_LMON; break; + case 'M':eDat=DF_LMONTH; break; + } + USHORT nSubType = DATEFLD, nWhich = RES_DATETIMEFLD; + UINT32 nFormat = (UINT32)eDat; + + sw3io_ConvertFromOldField( rDoc, nWhich, nSubType, + nFormat, 0x0110 ); + + SwDateTimeField aFld((SwDateTimeFieldType*)rDoc.GetSysFldType(RES_DATETIMEFLD), DATEFLD, nFormat); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + //InsField(SwDateField,RES_DATEFLD,eDat); + } + break; + case 'i': + { + SwDocInfoSubType eTyp=DI_TITEL; + switch (pTmp->cDat[1]) + { + case 'T':eTyp=DI_THEMA; break; + case 'S':eTyp=DI_KEYS; break; + } + SwDocInfoField aFld((SwDocInfoFieldType*) + rDoc.GetSysFldType(RES_DOCINFOFLD),eTyp); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + } + break; + case 's': + { + SwDocStatSubType eSta=DS_PARA; + switch (pTmp->cDat[1]) + { + case 'W':eSta=DS_WORD; break; + case 'S':eSta=DS_PAGE; break; + } + InsField(SwDocStatField,RES_DOCSTATFLD,eSta); + } + break; + case '-': + case '+': + if (pTmp->cDat[0]=='-' || pTmp->cDat[2]=='_') + { + SwHiddenTxtField aFld((SwHiddenTxtFieldType*) + rDoc.GetSysFldType(RES_HIDDENTXTFLD), + FALSE,aEmptyStr,String((sal_Char *)( + pTmp->cDat+2),pTmp->cDat[1])); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + } + else + { + SwDBField aFld((SwDBFieldType*)rDoc. + InsertFldType(SwDBFieldType(&rDoc, String( + (sal_Char *)(pTmp->cDat+2),pTmp->cDat[1]), SwDBData()))); + aFld.ChangeFormat(UF_STRING); + rDoc.Insert(aPaM,SwFmtFld(aFld)); + } + break; + } // switch + pTmp=pTmp->pNxt; + } // while(pTmp) + } // if(pFrm) + } + else return FALSE; // Insert oder SplitNode ging nicht + return TRUE; // Ok. +} + +Sw6Layout::Sw6Layout(SvStream &rInp,ULONG *pErrno,const String *pFileName): //$ istream + Sw6File(rInp,2048,258,pErrno),pMyName(pFileName), + pDocInfo(NULL), nLastFontMatch( USHRT_MAX ), + lLin(0) +// Konstruktor der Klasse Sw6Layout +{ + pLay=new LAYDESC; // Neuer LAYDESC noetig + Glieder[0]=FALSE; // Noch keine Gliederungen + Glieder[1]=FALSE; + Glieder[2]=FALSE; + Glieder[3]=FALSE; + Glieder[4]=FALSE; +} + +Sw6Layout::~Sw6Layout(void) +// Destruktor Sw6Layout +{ + if (pLay) DELETEZ(pLay); // LAYDESC wech + DelHForm(); // Loesche noch pFrm +} + +// --- SwSw6Parser --- + +BOOL SwSw6Parser::Ueberlese(const long Blk) +// Ueberlesen eines Writer-Dateiblocks +{ + long Nxt; + String Stg; + + Nxt=lLin+Blk; + while (lLin<Nxt) + { + if (!ReadLn(Stg)) return FALSE; + if (Eof()) + { + *pErr=ERR_SW6_UNEXPECTED_EOF; + return FALSE; + } + } + return TRUE; +} + +BOOL SwSw6Parser::ReadDocInfo(void) +// Einlesen des DocInfo-Blocks +// Wird auch gleich ins Doc gegeben +{ + BOOL bRet = FALSE, bIsTrans = IsTrans(); + SetTrans( TRUE ); + + short Idx; + if (ReadLn(pDat->DocInfo.Autor) && + ReadLn(pDat->DocInfo.Kateg)) + { + bRet = TRUE; + pDat->DocInfo.Autor=pDat->DocInfo.Autor; + pDat->DocInfo.Kateg=pDat->DocInfo.Kateg; + + for (Idx=0;Idx<4;Idx++) + { + String &rTmp=pDat->DocInfo.Thema[Idx]; + if (ReadLn(rTmp)) + { + rTmp.EraseLeadingChars(); + rTmp.EraseTrailingChars(); + } + else + { + bRet = FALSE; + break; + } + } + for (Idx=0;Idx<4;Idx++) + { + String &rTmp=pDat->DocInfo.Keys[Idx]; + if (ReadLn(rTmp)) + { + rTmp.EraseLeadingChars(); + rTmp.EraseTrailingChars(); + } + else + { + bRet = FALSE; + break; + } + } + } + SetTrans( bIsTrans ); + return TRUE; +} + +BOOL SwSw6Parser::CallParser() +// Wird von ReadDoc aufgerufen. Gibt FALSE zurueck wenn es +// einen Fehler gab. Ungeklaert ob Stream noch geschlossen +// werden muss, und wer wie die Fehlermeldungen ausgibt... +{ + short Idx; // Index + short Anz; // Anzahl der Bloecke + long Blk[20]; // Zeilenzahl je Block + sal_Char Ver; // Versionskennung Datei + String Stg; // Zum Einlesen + + + if (Sw6LayoutOk() && pDat!=NULL) // Sonst gibt Aerger!!! + { + lLin=0; // Wieder von vorne + Seek(0); + if (!ReadLn(Stg)) + return FALSE; // Lese Dateikennung + Ver = Stg.GetChar( ByteString(DOKUKENN).Search('#') ); + Stg.SetChar((ByteString(DOKUKENN).Search('#')), '#'); + if( Stg.EqualsAscii(DOKUKENN) ) + { + if (!ReadLn(pDat->LayName)) // Name Layoutdatei + return FALSE; + if (!ReadLn(Stg)) // Druckerkennung + return FALSE; + while (Stg.Search('\\')!=STRING_NOTFOUND) + { + Stg.Erase(0,Stg.Search('\\')+1); + } // Nur den GPM-Dateinamen bitte + SetGpmFile(Stg); // Melde richtige Gpmdatei an + + if (!ReadLn(Stg)) // Anzahl Bloecke + return FALSE; + if (0==(Anz=Stg.ToInt32())) + { + *pErr = ERR_SWG_FILE_FORMAT_ERROR; + return FALSE; // Es muessen mehrere Bloecke da sein + } + for (Idx=0; Idx<Anz; Idx++) + { // Lese Zeilen ein + if (!ReadLn(Stg)) + return FALSE; + Blk[Idx]=Stg.ToInt32(); + } + if (Anz>11 && Blk[11]!=0) + { + *pErr=ERR_SW6_PASSWD; + return FALSE; // Passwort-Dateien kann ich nicht + } + if (Anz>0) // LeseHistInfo + { + if (!Ueberlese(Blk[0])) return FALSE; + } + if (Anz>1) // LeseDocInfo + { + if (ReadDocInfo()) + { + SfxDocumentInfo aInfo(*pDoc->GetInfo()); + SfxStamp aTmp; + if (pDat->DocInfo.Autor.Len()) + { + aTmp=aInfo.GetCreated(); + aTmp.SetName(pDat->DocInfo.Autor); + aInfo.SetCreated(aTmp); + } + if (pDat->DocInfo.Kateg.Len()) + { + aInfo.SetTitle(pDat->DocInfo.Kateg); + } + short n; + for (n=0; n<4; n++) + { + if (pDat->DocInfo.Thema[n].Len()) + { + String s(aInfo.GetTheme()); + if (s.Len() && + s.GetChar( s.Len() ) !=' ' && + s.GetChar( s.Len() ) !='-') + { + s.Insert(' '); + } + s+=pDat->DocInfo.Thema[n]; + aInfo.SetTheme(s); + } + } // for n + for (n=0; n<4; n++) + { + if (pDat->DocInfo.Keys[n].Len()) + { + String s(aInfo.GetKeywords()); + if (s.Len() && + s.GetChar( s.Len() )!=' ' && + s.GetChar( s.Len() )!='-') + { + s.Insert(' '); + } + s+=pDat->DocInfo.Keys[n]; + aInfo.SetKeywords(s); + } + } // for n + pDoc->SetInfo(aInfo); + } + else return FALSE; + } + if (Anz>2) // LeseLayInfo + { + if (!LeseLayInfo(Ver==AVERSION)) return FALSE; + } + if (Anz>3) // ReadExtra(FNotenlink) + { + MerkeNoten(FNot); + if (!IgnExtra(TRUE)) return FALSE; + } + if (Anz>4) // ReadExtra(ENotenLink) + { + MerkeNoten(ENot); + if (!IgnExtra(TRUE)) return FALSE; + } + if (Anz>5) // ReadExtra(ANotenLink) + { + MerkeNoten(ANot); + if (!IgnExtra(TRUE)) return FALSE; + } + if (Anz>6 && Blk[6]) // ReadHartKopf + { + if (!LeseKoFu(TRUE)) return FALSE; + } + if (Anz>7 && Blk[7]) // ReadHartFuss + { + if (!LeseKoFu(FALSE)) return FALSE; + } + for (Idx=8; Idx<Anz; Idx++) + { // Sonstige Bloecke ueberlesen + if (!Ueberlese(Blk[Idx])) return FALSE; + } + InsertLayouts(*pDoc,pPaM); // Layouts in das Dokument schieaen + ResetLay(*pDoc); // Ab hier wird Haupttext gelesen + if (Anz>11 && Blk[11]!=0) + { + if (!ActivatePass() || + !ReadLn(Stg) || !Stg.EqualsAscii("PASS")) + { + *pErr=ERR_SW6_PASSWD; + return FALSE; + } + } + do { // Zeile Haupttext lesen + SetAlayTrans(); + if (!ReadLn(Stg)) return FALSE; + pDoc->SetTxtFmtColl(*pPaM,GetAlay()); + if (TstSlay()) SetSlay(*pDoc,*pPaM); + if (!InsertLine(*pDoc,*pPaM,Stg,Eof())) + { + return FALSE; + } + } while (!Eof()); // Rest der Datei bis eof() + *pErr = 0; + return TRUE; + } + else + { + *pErr=ERR_SW6_NOWRITER_FILE; + } + } + return FALSE; +} + +SwSw6Parser::SwSw6Parser(SwDoc *pSwDoc,const SwPaM &rSwPaM, + SvStream *pIstream,BOOL bNewDoc, + ULONG *pErrno,const String *pFileName): + pDoc(pSwDoc),bNew(bNewDoc), + Sw6Layout(*pIstream,pErrno,pFileName) + +// Konstruktor wie ihn der SWG benoetigt +{ + pDat=new DATEIDESC; + pPaM=new SwPaM( *(rSwPaM.GetPoint() ) ); + SetDocInfo(&pDat->DocInfo); + + SwTxtNode *pTxtNode=0; + + // Ist das ein SwPaM auf einen TextNode? + if (0==(pTxtNode=pDoc->GetNodes()[pPaM->GetPoint()->nNode]->GetTxtNode())) + { + // Ist keiner, dann machen wir uns einen + pDoc->GetNodes().MakeTxtNode( + pPaM->GetPoint()->nNode, + (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl(), 0 ); + // Da zeigt jetzt auch der StartIdx hin + pPaM->GetPoint()->nNode-=1; + } +} + +SwSw6Parser::~SwSw6Parser(void) +// Destructor von SwSw6Parser +{ + if (pDat) delete pDat; + if (pPaM) delete pPaM; +} + +ULONG Sw6Reader::Read( SwDoc &rDoc,SwPaM &rPam,const String &rFileName) +{ + ULONG nRet = ERR_SWG_READ_ERROR; +#ifndef COMPACT + + if( pStrm ) + { + //JP 18.01.96: Alle Ueberschriften sind normalerweise ohne + // Kapitelnummer. Darum hier explizit abschalten + // weil das Default jetzt wieder auf AN ist. + if( !bInsertMode ) + SetNoOutlineNum( rDoc ); + + SwSw6Parser *pSw6Parser = new SwSw6Parser( &rDoc, rPam, pStrm, + !bInsertMode, &nRet, &rFileName ); + pSw6Parser->CallParser(); + delete pSw6Parser; + } + else + ASSERT( !this, "SW6-Read ohne Stream" ); +#endif + return nRet; +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/makefile.mk b/binfilter/bf_sw/source/filter/w4w/makefile.mk new file mode 100644 index 000000000000..2cefd94b0ac7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/makefile.mk @@ -0,0 +1,80 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_w4w + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk + +INC+= -I$(PRJ)$/inc$/bf_sw +.IF "$(mydebug)" != "" +CDEFS=$(CDEFS) -Dmydebug +.ENDIF + +# --- Files -------------------------------------------------------- + +CXXFILES = \ + sw_w4watr.cxx \ + sw_w4wgraf.cxx \ + sw_w4wpar1.cxx \ + sw_w4wpar2.cxx \ + sw_w4wpar3.cxx \ + sw_w4wstk.cxx \ + sw_wrtgraf.cxx \ + sw_wrtw4w.cxx + + + +SLOFILES = \ + $(SLO)$/sw_w4watr.obj \ + $(SLO)$/sw_w4wgraf.obj \ + $(SLO)$/sw_w4wpar1.obj \ + $(SLO)$/sw_w4wpar2.obj \ + $(SLO)$/sw_w4wpar3.obj \ + $(SLO)$/sw_w4wstk.obj \ + $(SLO)$/sw_wrtgraf.obj \ + $(SLO)$/sw_wrtw4w.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4watr.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4watr.cxx new file mode 100644 index 000000000000..4026ec910b33 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4watr.cxx @@ -0,0 +1,1728 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +/* + * Dieses File enthaelt alle Ausgabe-Funktionen des W4W-Writers; + * fuer alle Nodes, Attribute, Formate und Chars. + */ +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <bf_svtools/whiter.hxx> +#include <bf_svx/hyznitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/orphitem.hxx> +#include <bf_svx/tstpitem.hxx> +#include <bf_svx/spltitem.hxx> +#include <bf_svx/widwitem.hxx> +#include <bf_svx/adjitem.hxx> +#include <bf_svx/cmapitem.hxx> +#include <bf_svx/lspcitem.hxx> +#include <bf_svx/kernitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/escpitem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/colritem.hxx> +#include <bf_svx/brkitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/fhgtitem.hxx> + + +#include <fmtftn.hxx> +#include <txtftn.hxx> +#include <fmtpdsc.hxx> +#include <fmthdft.hxx> +#include <fmtcntnt.hxx> +#include <fmtfsize.hxx> +#include <fmtfld.hxx> +#include <frmatr.hxx> +#include <charatr.hxx> +#include <ftninfo.hxx> +#include <ndtxt.hxx> +#include <doc.hxx> +#include <pam.hxx> +#include <paratr.hxx> +#include <fldbas.hxx> // fuer SwField ... +#include <ndgrf.hxx> +#include <grfatr.hxx> +#include <fmtcol.hxx> +#include <bookmrk.hxx> // fuer SwBookmark ... +#include <pagedesc.hxx> // fuer SwPageDesc... +#include <pageiter.hxx> +#include <wrtw4w.hxx> +namespace binfilter { + + +/* + * 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(WTC) && !defined(__MINGW32__) && !defined(OS2) + +#define ATTRFNTAB_SIZE 130 +#if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN +#error "Attribut-Tabelle ist ungueltigt. Wurden neue Hint-ID's 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-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 + + + +//----------------------------------------------------------------------- + +// einige Forward Deklarationen + +#define OUTRECORD(rStrm,pStr) rStrm << sW4W_RECBEGIN << pStr << cW4W_RED + +inline int HI_BYTE( USHORT n ) { return (int)( ( n >> 8 ) & 0xff ); } +inline int LO_BYTE( USHORT n ) { return (int)( n & 0xff ); } + + +//----------------------------------------------------------------------- +// Footnotes +// + +static Writer& OutW4W_SwFtn( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SwFmtFtn& rFtnFmt = (const SwFmtFtn&)rHt; + const SwTxtFtn& rFtn = *rFtnFmt.GetTxtFtn(); + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + do { // middle-check-loop + if( !rFtn.GetStartNode() ) + break; // es gibt keine Kopf-/Fusszeile/Fussnote + + // Hole vom Node und vom letzten Node die Position in der Section + SwNode* pSttNd = rWrt.pDoc->GetNodes()[ *rFtn.GetStartNode() ]; + ULONG nEnd = pSttNd->EndOfSectionIndex(), + nStart = rFtn.GetStartNode()->GetIndex()+1; + + // kein Bereich also kein gueltiger Node + if( nStart >= nEnd ) + break; + + static sal_Char __FAR_DATA cFNT[] = "FNT00\x1f"; // FootNote + if ( rW4WWrt.pDoc->GetFtnInfo().ePos != FTNPOS_PAGE ) + cFNT[ 4 ] = '2'; // EndNote + + rWrt.Strm() << sW4W_RECBEGIN << cFNT; + + rWrt.OutHex( HI_BYTE(rFtn.GetFtn().GetNumber()) ) << cW4W_TXTERM; + rWrt.OutHex( LO_BYTE(rFtn.GetFtn().GetNumber()) ) << cW4W_TXTERM; + rWrt.Strm() << "00" << cW4W_TXTERM << "01" << cW4W_TXTERM << // gemogelt: # of lines + "00" << cW4W_TXTERM << "01" << cW4W_TXTERM << // Old lines / lines in page + "01" << cW4W_TXTERM << "FF" << cW4W_TXTERM << // const ( muss so sein ) + "13" << cW4W_TXTERM << "104" << cW4W_TXTERM << // gemogelte Raender + "8D" << sW4W_TERMEND; // const + + W4WSaveData aSaveData( rW4WWrt, nStart, nEnd ); + rW4WWrt.pCurPam->GetMark()->nNode++; + rW4WWrt.Out_SwDoc( rW4WWrt.pCurPam, FALSE ); + + rWrt.Strm() << sW4W_RECBEGIN << "EFN" << cW4W_RED; + + } while( FALSE ); + return rWrt; +} + + +//----------------------------------------------------------------------- +// PageDescs +// + +void OutW4W_SwFmtPageDesc1( SwW4WWriter& rW4WWrt, const SwPageDesc* pPg ) +{ + if ( rW4WWrt.bStyleDef // Was soll denn dieser Schwachsinn ??? + // Ignorieren, sonst verschluckt sich W4W + || rW4WWrt.bHdFt ) // hier ignorieren ( mag WW2 nicht ) + return; + + if ( ( ( rW4WWrt.GetFilter() != 1 ) // Keiner (?) will ^L im Ascii-Text + || ( rW4WWrt.GetIniFlags() & 0x10000 ) + ) + && rW4WWrt.bIsTxtInPgDesc + ) + rW4WWrt.Strm() << sW4W_RECBEGIN << "HNP" << cW4W_RED; + + rW4WWrt.pPgDsc2 = pPg; + const SwFrmFmt *pFrm = &(pPg->GetMaster()); //!!! GetLeft() +#if OSL_DEBUG_LEVEL > 1 + rW4WWrt.Strm() << sW4W_RECBEGIN << "NOP_Pagedesc_Inhalt" << sW4W_TERMEND; +#endif + BOOL bOldPg = rW4WWrt.bPageDesc; + rW4WWrt.bPageDesc = TRUE; + + OutW4W_SwFmt( rW4WWrt, *pFrm ); + + rW4WWrt.bPageDesc = bOldPg; +#if OSL_DEBUG_LEVEL > 1 + rW4WWrt.Strm() << sW4W_RECBEGIN << "NOP_Pagedesc_Inhalt_Ende" << sW4W_TERMEND ;//!!! +#endif + rW4WWrt.bIsTxtInPgDesc = FALSE; + return; +} + +static Writer& OutW4W_SwFmtPageDesc( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SwPageDesc* pPg = ((SwFmtPageDesc&)rHt).GetPageDesc(); + + if( pPg ) // pPg == 0 : So was kommt vor + OutW4W_SwFmtPageDesc1( (SwW4WWriter&)rWrt, pPg ); + + return rWrt; +} + + +static BOOL OutW4W_SwFmtHeader1( SwW4WWriter& rWrt, const SwFmtHeader& rHd, + const SwPageDesc * pPg, BOOL bFollow ) +{ + BOOL bHasFollow = FALSE; + + if( !rHd.IsActive() ) // nicht aktiv, dann nichts weiter ausgeben + return FALSE; + + // hole einen Node zu dem Request + SwCntntNode *pNode = 0; + const SwFmtCntnt& rCntnt = rHd.GetHeaderFmt()->GetCntnt(); + if( rCntnt.GetCntntIdx() ) + pNode = rWrt.pDoc->GetNodes()[ rCntnt.GetCntntIdx()->GetIndex()+ 1 ] + ->GetCntntNode(); + + do { // middle-check-loop + if( !pNode ) + break; // es gibt keine Kopf-/Fusszeile/Fussnote + + // Hole vom Node und vom letzten Node die Position in der Section + ULONG nStart = pNode->StartOfSectionIndex()+1, + nEnd = pNode->EndOfSectionIndex(); + + // kein Bereich also kein gueltiger Node + if( nStart >= nEnd ) + break; + ASSERT( pPg, "Header-Attribut ohne PageDesc" ); + + BYTE nFirst = 3; // Default: First and all Pages + BYTE nDef = 0; + // wird nicht die PageDesc-Tabelle ausgegeben und gibt es einen + // Nachfolger, dann handelt es sich um die "1.Seite". + + if( !bFollow && pPg->GetFollow() && pPg->GetFollow() != pPg ){ + bHasFollow = TRUE; + nFirst = 1; + } + else if( !pPg->IsHeaderShared() ) + { + if( pPg->GetLeftFmt() && + rHd.GetHeaderFmt() == pPg->GetLeftFmt() ) + nDef |= 0x10; // Even Pages + else if( pPg->GetRightFmt() && + rHd.GetHeaderFmt() == pPg->GetRightFmt() ) + nDef |= 0x8; // Odd Pages (Header1/Header2 ???) + } + else + nDef |= 0x4; // All Pages + + if ( nDef == 0 ) nDef |= 0x4; // Default: odd + even pages + if ( bHasFollow ) nDef |= 1; // 1. Seite -> "Header 2" + if ( bFollow ) nFirst = 2; // 2 = Non-first page + + // hole erstmal die Ober-/Unterkanten vom Header/Footer + const SvxULSpaceItem& rUL = rHd.GetHeaderFmt()->GetULSpace(); + const SvxLRSpaceItem& rLR = rHd.GetHeaderFmt()->GetLRSpace(); + const SvxLRSpaceItem& rPgLR = pPg->GetMaster().GetLRSpace(); + + USHORT nNewLeft = rPgLR.GetLeft() + rLR.GetLeft(); + USHORT nNewRight = USHORT(pPg->GetMaster().GetFrmSize().GetWidth() + - rPgLR.GetRight() - rLR.GetRight()); + if ( nNewRight - nNewLeft < 288 ) + nNewRight = nNewLeft + 288 ; + + rWrt.Strm() << sW4W_RECBEGIN << "HF200" << cW4W_TXTERM + << '0' << cW4W_TXTERM; + rWrt.OutULong( nNewLeft / 144 ) << cW4W_TXTERM; + rWrt.OutULong( nNewRight / 144 ) + << cW4W_TXTERM << '1', cW4W_TXTERM; + rWrt.OutULong( rUL.GetUpper() / 240 ) << sW4W_TERMEND; + + BOOL bOldHdFt = rWrt.bHdFt; + rWrt.bHdFt = TRUE; + { + W4WSaveData aSaveData( rWrt, nStart, nEnd ); + rWrt.Out_SwDoc( rWrt.pCurPam, FALSE ); + } + rWrt.bHdFt = bOldHdFt; + rWrt.Strm() << sW4W_RECBEGIN << "HFX2" << cW4W_TXTERM; // # of Lines (hoffentlich egal) + rWrt.OutHex( nDef ) + << cW4W_TXTERM // Definition Byte + << '0' << cW4W_TXTERM; // Auto Height + rWrt.OutULong( nFirst ) << sW4W_TERMEND; // First/NonFirst/All + + } while( FALSE ); + return bHasFollow; +} + +// Header-Footer werden auch vom -Writer direkt gerufen, also kein static! + +Writer& OutW4W_SwFmtHeader( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + BOOL bFollow = OutW4W_SwFmtHeader1( rW4WWrt, (const SwFmtHeader&) rHt, + rW4WWrt.pPgDsc2, FALSE ); + if ( bFollow ) + OutW4W_SwFmtHeader1( rW4WWrt, + rW4WWrt.pPgDsc2->GetFollow()->GetMaster().GetHeader(), //!!! GetLeft() + rW4WWrt.pPgDsc2->GetFollow(), TRUE ); + return rWrt; +} + +static BOOL OutW4W_SwFmtFooter1( SwW4WWriter& rWrt, const SwFmtFooter& rHd, + const SwPageDesc * pPg, BOOL bFollow ) +{ + BOOL bHasFollow = FALSE; + + if( !rHd.IsActive() ) // nicht aktiv, dann nichts weiter ausgeben + return FALSE; + + // hole einen Node zu dem Request + SwCntntNode *pNode = 0; + const SwFmtCntnt& rCntnt = rHd.GetFooterFmt()->GetCntnt(); + if( rCntnt.GetCntntIdx() ) + pNode = rWrt.pDoc->GetNodes()[ rCntnt.GetCntntIdx()->GetIndex()+ 1 ]-> + GetCntntNode(); + do { // middle-check-loop + if( !pNode ) + break; // es gibt keine Kopf-/Fusszeile/Fussnote + + // Hole vom Node und vom letzten Node die Position in der Section + ULONG nStart = pNode->StartOfSectionIndex()+1, + nEnd = pNode->EndOfSectionIndex(); + + // kein Bereich also kein gueltiger Node + if( nStart >= nEnd ) + break; + ASSERT( pPg, "Footer-Attribut ohne PageDesc" ); + + BYTE nFirst = 3; // Default: First and all Pages + BYTE nDef = 2; // Default: Footer + // wird nicht die PageDesc-Tabelle ausgegeben und gibt es einen + // Nachfolger, dann handelt es sich um die "1.Seite" nach RTF. + + if( !bFollow && pPg->GetFollow() && pPg->GetFollow() != pPg ){ + bHasFollow = TRUE; + nFirst = 1; + } + else if( !pPg->IsFooterShared() ) + { + if( pPg->GetLeftFmt() && + rHd.GetFooterFmt() == pPg->GetLeftFmt() ) + nDef |= 0x10; // Even Pages + else if( pPg->GetRightFmt() && + rHd.GetFooterFmt() == pPg->GetRightFmt() ) + nDef |= 0x8; // Odd Pages (Footer1/Footer2 ???) + } + else + nDef |= 0x4; // All Pages + + if ( nDef == 2 ) nDef |= 0x4; // Default: odd + even pages + if ( bHasFollow ) nDef |= 1; // 1. Seite -> "Footer 2" + if ( bFollow ) nFirst = 2; // 2 = Non-first page + + // hole erstmal die Ober-/Unterkanten vom Header/Footer + const SvxULSpaceItem& rUL = rHd.GetFooterFmt()->GetULSpace(); + const SvxLRSpaceItem& rLR = rHd.GetFooterFmt()->GetLRSpace(); + const SvxLRSpaceItem& rPgLR = pPg->GetMaster().GetLRSpace(); + + USHORT nNewLeft = rPgLR.GetLeft() + rLR.GetLeft(); + USHORT nNewRight = USHORT(pPg->GetMaster().GetFrmSize().GetWidth() + - rPgLR.GetRight() - rLR.GetRight()); + if ( nNewRight - nNewLeft < 288 ) + nNewRight = nNewLeft + 288 ; + + rWrt.Strm() << sW4W_RECBEGIN << "HF100" << cW4W_TXTERM + << '0', cW4W_TXTERM; + rWrt.OutULong( nNewLeft / 144 ) << cW4W_TXTERM; + rWrt.OutULong( nNewRight / 144 ) + << cW4W_TXTERM << '1' << cW4W_TXTERM; + rWrt.OutULong( 55 - rUL.GetUpper() / 240 ) << sW4W_TERMEND; + + BOOL bOldHdFt = rWrt.bHdFt; + rWrt.bHdFt = TRUE; + { + W4WSaveData aSaveData( rWrt, nStart, nEnd ); + rWrt.Out_SwDoc( rWrt.pCurPam, FALSE ); + } + rWrt.bHdFt = bOldHdFt; + rWrt.Strm() << sW4W_RECBEGIN << "HFX2" << cW4W_TXTERM; // # of Lines (hoffentlich egal) + rWrt.OutHex( nDef ) + << cW4W_TXTERM // Definition Byte + << '0' << cW4W_TXTERM; // Auto Height + rWrt.OutULong( nFirst ) << sW4W_TERMEND; // First/NonFirst/All + + } while( FALSE ); + return bHasFollow; +} + +// Header-Footer werden auch vom -Writer direkt gerufen, also kein static! + +Writer& OutW4W_SwFmtFooter( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + BOOL bFollow = OutW4W_SwFmtFooter1( rW4WWrt, (const SwFmtFooter&) rHt, + rW4WWrt.pPgDsc2, FALSE ); + if ( bFollow ) + OutW4W_SwFmtFooter1( rW4WWrt, + rW4WWrt.pPgDsc2->GetFollow()->GetMaster().GetFooter(), //!!! GetLeft() + rW4WWrt.pPgDsc2->GetFollow(), TRUE ); + return rWrt; +} + +//-------------------------------------------------------------------- + + + +static Writer& OutW4W_SwFmtBox( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + const SvxBoxItem& rBox = (const SvxBoxItem&)rHt; + USHORT nBorder; + + rW4WWrt.OutW4W_GetBorder( &rBox, nBorder ); + + rWrt.Strm() << sW4W_RECBEGIN << "PBC"; + rWrt.OutHex4( nBorder ) << sW4W_TERMEND; + + if ( rW4WWrt.bStyleDef || rW4WWrt.bStyleOnOff ) + rW4WWrt.GetStrm() << sW4W_RECBEGIN << "PBC0000" << sW4W_TERMEND; + else + rW4WWrt.GetNlStrm() << sW4W_RECBEGIN << "PBC0000" << sW4W_TERMEND; + + return rWrt; +} + + + +Writer& OutW4W_SwChar( Writer& rWrt, sal_Unicode c, BOOL bRaw ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if ( bRaw ) + { + sal_Char cOut = ByteString::ConvertFromUnicode( c, rW4WWrt.eTargCharSet ); + if( !cOut ) + cOut = c; + rWrt.Strm() << cOut; + return rWrt; + } + + do { // block, damit aus diesem gesprungen werden kann ! + if( '\t' == c ) + rWrt.Strm() << sW4W_RECBEGIN << "TAB0" << sW4W_TERMEND; + else if( '\n' == c ) + rWrt.Strm() << sW4W_RECBEGIN << "SNL" << cW4W_RED; + else if( ' ' <= c && '~' >= c ) + rWrt.Strm() << (sal_Char)c; + else if( CH_TXTATR_BREAKWORD == c || CH_TXTATR_INWORD == c ) + return rWrt; + else + break; + return rWrt; + } while( FALSE ); + + rtl_TextEncoding eTargCSet = rW4WWrt.eTargCharSet; + + // der CodeSet fuer HEX / UCS + sal_Char cPcCode = ByteString::ConvertFromUnicode( c, RTL_TEXTENCODING_IBM_850 ); + if( !cPcCode ) + cPcCode = '@'; /***** ?????? *******/ + + sal_Char cTargCode = cPcCode; + if( RTL_TEXTENCODING_IBM_850 != eTargCSet ) + { + cTargCode = ByteString::ConvertFromUnicode( c, eTargCSet ); + if( !cTargCode ) + cTargCode = '@'; /***** ?????? *******/ + } + + if( '~' < cTargCode ) + { + if( RTL_TEXTENCODING_MS_1252 == eTargCSet ) + { + rWrt.Strm() << sW4W_RECBEGIN << "XCS819" << cW4W_TXTERM; // ANSI + rWrt.OutHex( cTargCode & 0xff ) << cW4W_RED; + } + else + { + rWrt.Strm() << sW4W_RECBEGIN << "XCS850" << cW4W_TXTERM; // IBMPC850 + rWrt.OutHex( cPcCode & 0xff ) << cW4W_RED; + } + rWrt.Strm() << sW4W_RECBEGIN << "UCS"; + rWrt.OutHex( cPcCode & 0xff ) << sW4W_TERMEND; + } + else if( ' ' > cPcCode ) + { + rWrt.Strm() << sW4W_RECBEGIN << "HEX"; + rWrt.OutHex( cPcCode & 0xff ) << cW4W_RED; + } + else + rWrt.Strm() << (sal_Char)cTargCode; + + return rWrt; +} + + +Writer& OutW4W_String( Writer& rWrt, const String& rStr ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + BOOL bRaw = 0x40000 & rW4WWrt.GetIniFlags(); // 1: no XCS in struct names + for( xub_StrLen n = 0; n < rStr.Len(); ++n ) + OutW4W_SwChar( rWrt, rStr.GetChar( n ), bRaw ); + return rWrt; +} + +static void CalcFontSize( SwW4WWriter & rW4WWrt, const SwFmt& rFmt, + USHORT& rFontId, USHORT& rFontHeight ) +{ + UINT32 nFontHeight = rFmt.GetSize().GetHeight(); + rFontHeight = ( nFontHeight > USHRT_MAX ) ? USHRT_MAX : (USHORT)nFontHeight; + rFontId = rW4WWrt.GetId( rFmt.GetFont() ); +} + +/* + * Format wie folgt ausgeben: + * - gebe die Attribute aus; ohne Parents! + */ + +Writer& OutW4W_SwFmt( Writer& rWrt, const SwFmt& rFmt ) +{ + SwW4WWriter & rW4WWrt = (SwW4WWriter&)rWrt; + + switch( rFmt.Which() ) + { + case RES_CONDTXTFMTCOLL: + case RES_TXTFMTCOLL: + { + USHORT nFontHeight, nFontId; + CalcFontSize( rW4WWrt, rFmt, nFontId, nFontHeight ); + + // dann gebe mal das "W4W"-FontAttribut aus + rW4WWrt.Strm() << sW4W_RECBEGIN << "SPF10" << cW4W_TXTERM + << '0' << cW4W_TXTERM << "10" << cW4W_TXTERM; + rWrt.OutULong( nFontId ) << cW4W_TXTERM; + rWrt.OutULong( nFontHeight ) << cW4W_TXTERM; + OutW4W_String( rWrt, rW4WWrt.GetFont( nFontId ).GetFamilyName() ).Strm() + << sW4W_TERMEND; + + // akt. Collection-Pointer am Writer setzen + rW4WWrt.pNdFmt = &rFmt; + + const SfxItemSet& rSet = rFmt.GetAttrSet(); + if( rSet.Count() ) + { + const SfxItemPool& rPool = *rSet.GetPool(); + const SfxPoolItem* pItem; + SfxWhichIter aIter( rSet ); + register USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + switch( nWhich ) + { + case RES_CHRATR_FONT: + case RES_CHRATR_PROPORTIONALFONTSIZE: + case RES_CHRATR_FONTSIZE: + break; + default: + if( SFX_ITEM_SET == rSet.GetItemState( nWhich, + TRUE, &pItem ) && + *pItem != rPool.GetDefaultItem( nWhich ) ) + Out( aW4WAttrFnTab, *pItem, rWrt ); + } + nWhich = aIter.NextWhich(); + } + } + } + break; + + default: + Out_SfxItemSet( aW4WAttrFnTab, rWrt, rFmt.GetAttrSet(), TRUE ); + break; + } + + return rWrt; +} + + + +/* Ausgabe der Nodes */ + +/* + * Ausgabe der Texte-Attribute: + * Die Text-Attribute sind in einem VarArray nach ihren Start-Positionen + * sortiert. Fuer den W4W-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. + */ + +struct W4WSttEndPos +{ + USHORT nFontSize, nFontId; + const SwTxtAttr* pTxtAttr; + W4WSttEndPos( const SwTxtAttr* pTxtAt, USHORT nFSize, USHORT nFId ); + W4WSttEndPos( const W4WSttEndPos & rSEPos ); + BOOL operator<( const W4WSttEndPos & rSEPos ); +}; + +W4WSttEndPos::W4WSttEndPos( const SwTxtAttr* pTxtAt, USHORT nFSize, USHORT nFId ) + : pTxtAttr(pTxtAt), nFontSize(nFSize), nFontId( nFId ) +{} + +W4WSttEndPos::W4WSttEndPos( const W4WSttEndPos & rSEPos ) + : pTxtAttr( rSEPos.pTxtAttr), nFontSize( rSEPos.nFontSize ), + nFontId( rSEPos.nFontId ) +{} + +BOOL W4WSttEndPos::operator<( const W4WSttEndPos & rSEPos ) +{ + USHORT nEnd1, nEnd2; + if( ( nEnd1 = *pTxtAttr->GetEnd() ) < ( nEnd2 = *rSEPos.pTxtAttr->GetEnd() ) ) + return TRUE; + if( nEnd1 == nEnd2 ) + return *pTxtAttr->GetStart() > *rSEPos.pTxtAttr->GetStart(); + return FALSE; +} + +SV_DECL_VARARR( _W4WEndPosLst, W4WSttEndPos, 5, 5 ) +SV_IMPL_VARARR( _W4WEndPosLst, W4WSttEndPos ) + +class W4WEndPosLst : private _W4WEndPosLst +{ +public: + W4WEndPosLst() : _W4WEndPosLst( 5 ) {} + + BOOL Insert( W4WSttEndPos & aNew ); + void Delete( USHORT n = 1 ) + { _W4WEndPosLst::Remove( 0, n ); } + W4WSttEndPos operator[]( USHORT nPos ) + { return _W4WEndPosLst::operator[]( nPos ); } + USHORT Count() + { return _W4WEndPosLst::Count(); } + void OutAttr( SwW4WWriter & rWrt, USHORT nStrPos, USHORT nEnde ); +}; + +BOOL W4WEndPosLst::Insert( W4WSttEndPos & aNew ) +{ + USHORT nPos; + for( nPos = 0; nPos < Count(); nPos++ ) + { + W4WSttEndPos aTmp = _W4WEndPosLst::operator[]( nPos ); + if( aNew < aTmp ) + { + _W4WEndPosLst::Insert( aNew, nPos ); + return TRUE; + } + } + _W4WEndPosLst::Insert( aNew, nPos ); + return TRUE; +} + +void W4WEndPosLst::OutAttr( SwW4WWriter & rWrt, USHORT nStrPos, USHORT nEnde ) +{ + rWrt.bAttrOnOff = FALSE; + USHORT nWhch; + while( 0 != Count() && ( nStrPos >= nEnde || + *operator[]( 0 ).pTxtAttr->GetEnd() == nStrPos )) + { + // das setzen der alten Attribut-Werte erfolgt nur durch die + // entsprechenden Attribute !! + const W4WSttEndPos& rSTPos = *GetData(); + if( ( nWhch = rSTPos.pTxtAttr->Which()) == RES_CHRATR_FONTSIZE || + nWhch == RES_CHRATR_PROPORTIONALFONTSIZE ) + rWrt.nFontHeight = rSTPos.nFontSize; + else if( nWhch == RES_CHRATR_FONT ) + rWrt.nFontId = rSTPos.nFontId; + Out( aW4WAttrFnTab, rSTPos.pTxtAttr->GetAttr(), rWrt ); + Delete(); + } +} + + +static Writer& OutW4W_SwTxtNode( Writer& rWrt, SwCntntNode & rNode ) +{ + SwTxtNode * pNd = &((SwTxtNode&)rNode); + SwW4WWriter & rW4WWrt = (SwW4WWriter&)rWrt; + W4WEndPosLst aW4WEndPosLst; + xub_StrLen nAttrPos = 0; + xub_StrLen nStrPos = rW4WWrt.pCurPam->GetPoint()->nContent.GetIndex(); + + const String& rStr = pNd->GetTxt(); + xub_StrLen nEnde = rStr.Len(); + if( rW4WWrt.pCurPam->GetPoint()->nNode == rW4WWrt.pCurPam->GetMark()->nNode ) + nEnde = rW4WWrt.pCurPam->GetMark()->nContent.GetIndex(); + + BOOL bLastPara = ( !rW4WWrt.bLastPg + && ( rW4WWrt.pCurPam->GetPoint()->nNode >= rW4WWrt.pNxtPg->nNode ) ); + + // akt. Collection-Pointer am Writer setzen + rW4WWrt.pNdFmt = &pNd->GetAnyFmtColl(); + + // bestimme die aktuelle FontSize aus der Collection + CalcFontSize( rW4WWrt, *rW4WWrt.pNdFmt, rW4WWrt.nFontId, rW4WWrt.nFontHeight ); + + if( rW4WWrt.bWriteAll || rW4WWrt.bTable ) + rW4WWrt.Out_SwTxtColl_OnOff( (SwTxtFmtColl&)*rW4WWrt.pNdFmt, + pNd->GetpSwAttrSet(), TRUE ); + // erste Zeile und nur Teilweise ausgeben + + // ist der aktuelle Absatz in einem freifliegenden Rahmen ? Dann + // muessen noch die Attribute dafuer ausgegeben werden. + if( rW4WWrt.pFlyFmt ) + Out_SfxItemSet( aW4WAttrFnTab, rW4WWrt, rW4WWrt.pFlyFmt->GetAttrSet(), TRUE ); + + // 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() ) + { + // Ok, es gibt vorher Attribute, die ausgegeben werden muessen + rW4WWrt.bTxtAttr = rW4WWrt.bAttrOnOff = TRUE; + do { + nAttrPos++; + if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht + continue; // ausgeben + + if( pHt->GetEnd() ) + if( *pHt->GetEnd() != *pHt->GetStart() ) + { + W4WSttEndPos aW4WSttEndPos( pHt,rW4WWrt.nFontHeight, + rW4WWrt.nFontId ); + aW4WEndPosLst.Insert( aW4WSttEndPos ); + } + Out( aW4WAttrFnTab, pHt->GetAttr(), rW4WWrt ); + } while( nAttrPos < nCntAttr && nStrPos > + *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() ); + rW4WWrt.bTxtAttr = FALSE; + } + + if( !rW4WWrt.bWriteAll && rW4WWrt.bFirstLine ) + { + ASSERT( !&rWrt, "Teilausgabe der Dokuments nicht implementiert" ); + } + + + for( ; nStrPos <= nEnde; nStrPos++ ) + { + rW4WWrt.bTxtAttr = TRUE; + aW4WEndPosLst.OutAttr( rW4WWrt, nStrPos, nEnde ); + rW4WWrt.bAttrOnOff = TRUE; + if( nAttrPos < nCntAttr && *pHt->GetStart() == nStrPos + && nStrPos != nEnde ) + { + do { + if( pHt->GetEnd() ) + { + if( *pHt->GetEnd() != nStrPos ) + { + W4WSttEndPos aW4WSttEndPos( pHt, rW4WWrt.nFontHeight, + rW4WWrt.nFontId ); + aW4WEndPosLst.Insert( aW4WSttEndPos ); + Out( aW4WAttrFnTab, pHt->GetAttr(), rW4WWrt ); + } + } + else + Out( aW4WAttrFnTab, pHt->GetAttr(), rW4WWrt ); + nAttrPos++; + } while( nAttrPos < nCntAttr && nStrPos == + *( pHt = pNd->GetSwpHints()[ nAttrPos ] )->GetStart() ); + } + + if ( bLastPara + && ( nStrPos >= rW4WWrt.pNxtPg->nContent.GetIndex() )) + { + rW4WWrt.Strm() << sW4W_RECBEGIN << "SNP" << cW4W_RED; + + ASSERT( rW4WWrt.pIter->GetPageDesc(), "PageDesc weg"); + rW4WWrt.pPageDesc = rW4WWrt.pIter->GetPageDesc(); + rW4WWrt.pPgFrm = (SwFrmFmt*)&(rW4WWrt.pPgDsc2->GetMaster()); //!!! GetLeft() + rW4WWrt.bEvenPage = !rW4WWrt.bEvenPage; + + rW4WWrt.pIter->NextPage(); + rW4WWrt.bLastPg = !(rW4WWrt.pIter->GetPosition( *rW4WWrt.pNxtPg )); + + bLastPara = ( !rW4WWrt.bLastPg && + (rW4WWrt.pCurPam->GetPoint()->nNode >= rW4WWrt.pNxtPg->nNode )); + } + if( nStrPos != nEnde ) // eigentliche Buchstaben ausgeben + OutW4W_SwChar( rW4WWrt, rStr.GetChar( nStrPos ), FALSE ); + rW4WWrt.bTxtAttr = FALSE; + } + // wenn bis zum Ende vom Node, dann auch das AbsatzEnde ausgeben + + if( rW4WWrt.pCurPam->GetMark()->nNode.GetIndex() != + rW4WWrt.pCurPam->GetPoint()->nNode.GetIndex() + || pNd->Len() == rW4WWrt.pCurPam->GetMark()->nContent.GetIndex() + && !rW4WWrt.bTable ){ + + rW4WWrt.Out_SwTxtColl_OnOff( (SwTxtFmtColl&)pNd->GetAnyFmtColl(), + 0, FALSE ); // STF + + rW4WWrt.Strm() << sW4W_RECBEGIN << "HNL" << cW4W_RED; + + if ( rW4WWrt.pPostNlStrm) + { + // gebe die Sachen aus, die hinter HNL + // kommen muessen (RSP, SAF, SBF) + rW4WWrt.pPostNlStrm->Seek( 0L ); + rW4WWrt.Strm() << *rW4WWrt.pPostNlStrm; + DELETEZ( rW4WWrt.pPostNlStrm ); + } + } + else if( rW4WWrt.bTable ) + rW4WWrt.Out_SwTxtColl_OnOff( (SwTxtFmtColl&)pNd->GetAnyFmtColl(), 0, FALSE ); + + rW4WWrt.bIsTxtInPgDesc = TRUE; + return rW4WWrt; +} + + +static Writer& OutW4W_SwGrfNode( Writer& rWrt, SwCntntNode & rNode ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + rW4WWrt.OutW4W_Grf( rNode.GetGrfNode() ); + return rWrt; +} + +static Writer& OutW4W_SwOLENode( Writer& rWrt, SwCntntNode& /*rNode*/ ) +{ + rWrt.Strm() << sW4W_RECBEGIN << "HNL" << cW4W_RED; + return rWrt; +} + + +/* File CHRATR.HXX: */ + +static Writer& OutW4W_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 W4W-Dokument referenziert. + */ + const SvxFontItem& rFont = (const SvxFontItem&)rHt; + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( rW4WWrt.bAttrOnOff ) + rW4WWrt.nFontId = rW4WWrt.GetId( rFont ); + + rWrt.Strm() << sW4W_RECBEGIN << "SPF10" << cW4W_TXTERM << '0' << cW4W_TXTERM + << "10" << cW4W_TXTERM; + rWrt.OutULong( rW4WWrt.nFontId ) << cW4W_TXTERM; + rWrt.OutULong( rW4WWrt.nFontHeight ) << cW4W_TXTERM; + OutW4W_String( rWrt, rW4WWrt.GetFont( rW4WWrt.nFontId ).GetFamilyName()) + .Strm() << sW4W_TERMEND; + return rWrt; +} + +static Writer& OutW4W_SwPosture( Writer& rWrt, const SfxPoolItem& rHt ) +{ + if( ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() ) + { + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), "ITO" ); + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr), "ITF" ); + } + return rWrt; +} + + +static Writer& OutW4W_SwWeight( Writer& rWrt, const SfxPoolItem& rHt ) +{ + if( WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight() ) + { + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), "BBT" ); + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr), "EBT" ); + } + return rWrt; +} + + +static Writer& OutW4W_SwShadowed( Writer& rWrt, const SfxPoolItem& rHt ) +{ + if( ((const SvxShadowedItem&)rHt).GetValue() ) + { + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), "BSP" ); + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "ESP" ); + } + return rWrt; +} + + +static Writer& OutW4W_SwContour( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +static Writer& OutW4W_SwKerning( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxKerningItem& rKern = (const SvxKerningItem&)rHt; + + long nDist = 0; + long nPos = 1; + + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rKern.GetValue() ) + { + OUTRECORD( ((SwW4WWriter&)rWrt).Strm(), "EKR" ); + return rWrt; + } + +#ifdef JP_NEWCORE + // JP 23.09.94, wie nun ????? + Fraction aTmp( 20, 1 ); + aTmp += rKern.frKern; + nDist = (long)aTmp; // in Twips umrechnen + if( nDist < 0 ) + { + nDist = -nDist; + nPos = 0; + } +#endif + + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + { + rWrt.Strm() << sW4W_RECBEGIN << "KER"; + rWrt.OutLong( nPos ) << cW4W_TXTERM; + rWrt.OutLong( nDist ) << sW4W_TERMEND; + } + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "EKR" ); + + return rWrt; +} + + +static Writer& OutW4W_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxCrossedOutItem& rCrossOut = (const SvxCrossedOutItem&)rHt; + if( STRIKEOUT_SINGLE == rCrossOut.GetStrikeout() ) + { + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + { + rWrt.Strm() << sW4W_RECBEGIN << "BSO"; + OutW4W_SwChar( rWrt, rCrossOut.GetStrikeout(), TRUE ).Strm() + << sW4W_TERMEND; + } + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "ESO" ); + } + return rWrt; +} + + +static Writer& OutW4W_SwCaseMap( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( SVX_CASEMAP_KAPITAELCHEN == ((const SvxCaseMapItem&)rHt).GetValue() ) + { + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), "BCS" ); + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "ECS" ); + } + else if( SVX_CASEMAP_VERSALIEN == ((const SvxCaseMapItem&)rHt).GetValue() ) + { + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), "BCU" ); + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "ECU" ); + } + return rWrt; +} + + +static Writer& OutW4W_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxUnderlineItem & rULine = (const SvxUnderlineItem&)rHt; + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + const sal_Char *pSttStr, *pEndStr; + if( UNDERLINE_SINGLE == rULine.GetUnderline() ) + { + pSttStr = "BUL"; + pEndStr = "EUL"; + + } + else if( UNDERLINE_DOUBLE == rULine.GetUnderline() ) + { + pSttStr = "BDU"; + pEndStr = "EDU"; + } + else if( UNDERLINE_NONE == rULine.GetUnderline() ) + { + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "EUL" ); + return rWrt; + } + else + return rWrt; + + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), pSttStr ); + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), pEndStr ); + + return rWrt; +} + + +static Writer& OutW4W_SwLanguage( Writer& rWrt, const SfxPoolItem& rHt ) +{ + // die Werte des Enums sind mit den Werten fuer W4W identisch + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + { + USHORT nLang = ((const SvxLanguageItem&)rHt).GetValue(); + if( LANGUAGE_DONTKNOW == nLang ) + nLang = 0; + rWrt.Strm() << sW4W_RECBEGIN << "SLG"; + rWrt.OutULong( nLang ) << sW4W_TERMEND; + } + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + { + rWrt.Strm() << sW4W_RECBEGIN << "SLG"; + rWrt.OutULong( LANGUAGE_DONTKNOW == rW4WWrt.nDefLanguage + ? 0 : rW4WWrt.nDefLanguage ) << sW4W_TERMEND; + } + return rWrt; +} + + +static Writer& OutW4W_SwEscapement( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxEscapementItem & rEsc = (const SvxEscapementItem&)rHt; + const sal_Char *pSttStr, *pEndStr; + + if( 0 < rEsc.GetEsc() ) + { + pSttStr = "SPS"; + pEndStr = "EPS"; + } + else if( 0 > rEsc.GetEsc() ) + { + pSttStr = "SBS"; + pEndStr = "EBS"; + } + else + return rWrt; + + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff ) + OUTRECORD( rWrt.Strm(), pSttStr ); + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), pEndStr ); + + return rWrt; +} + + +static Writer& OutW4W_SwSize( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxFontHeightItem& rSize = (const SvxFontHeightItem&)rHt; + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + if( rW4WWrt.bAttrOnOff ) + rW4WWrt.nFontHeight = (USHORT)rSize.GetHeight(); + + rWrt.Strm() << sW4W_RECBEGIN << "SPF10" << cW4W_TXTERM << '0' << cW4W_TXTERM + << "10" << cW4W_TXTERM; + rWrt.OutULong( rW4WWrt.nFontId ) << cW4W_TXTERM; + rWrt.OutULong( rW4WWrt.nFontHeight) << cW4W_TXTERM; + OutW4W_String( rWrt, rW4WWrt.GetFont( rW4WWrt.nFontId ).GetFamilyName() ) + .Strm() << sW4W_TERMEND; + return rWrt; +} + + +static Writer& OutW4W_SwColor( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( rW4WWrt.bStyleDef && ( rW4WWrt.GetFilter() == 44 || rW4WWrt.GetFilter() == 49 ) ) + return rWrt; //!! umpopel W4W-Bug: Farbe in Style -> Farbe immer + + + if( !rW4WWrt.bTxtAttr || !rW4WWrt.bAttrOnOff ) + OUTRECORD( rW4WWrt.GetStrm( !rW4WWrt.bTxtAttr ), "ECL" ); + + if( !(!rW4WWrt.bTxtAttr || rW4WWrt.bAttrOnOff )) + return rWrt; + + const SvxColorItem& rCol = (const SvxColorItem&)rHt; + USHORT nCol = 0; + if( rCol.GetValue().GetRed() ) + nCol |= rCol.GetValue().GetRed() & 0x80 ? 0x0C : 0x04; + if( rCol.GetValue().GetGreen()) + nCol |= rCol.GetValue().GetGreen() & 0x80 ? 0x0A : 0x02; + if( rCol.GetValue().GetBlue() ) + nCol |= rCol.GetValue().GetBlue() & 0x80 ? 0x09 : 0x01; + +// laut Spec hex, laut output dec ?? rWrt.OutHex( nCol ) + rWrt.Strm() << sW4W_RECBEGIN << "BCL"; + rWrt.OutULong( nCol) << cW4W_TXTERM; + rWrt.OutULong( rCol.GetValue().GetRed() ) << cW4W_TXTERM; + rWrt.OutULong( rCol.GetValue().GetGreen() ) << cW4W_TXTERM; + rWrt.OutULong( rCol.GetValue().GetBlue() ) << sW4W_TERMEND; + + return rWrt; +} + + +static Writer& OutW4W_SwField( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SwField* pFld = ((SwFmtFld&)rHt).GetFld(); + + switch( pFld->GetTyp()->Which() ) + { + case RES_PAGENUMBERFLD: rWrt.Strm() << sW4W_RECBEGIN << "PPN"; + break; + case RES_DOCSTATFLD: rWrt.Strm() << sW4W_RECBEGIN << "PLN"; + break; + default: // nicht unterstuetztes Feld +#if OSL_DEBUG_LEVEL > 1 + rWrt.Strm() << sW4W_RECBEGIN + << "NOP_Unsupported_Field" << cW4W_RED; + break; +#else + return rWrt; // Nix ausgeben +#endif + } + rWrt.Strm() << cW4W_RED; + return rWrt; +} + + + +/* File FRMATR.HXX */ + +static Writer& OutW4W_SwFrmSize( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +static Writer& OutW4W_SwFillOrder( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +static Writer& OutW4W_SwBreak( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter & rW4WWrt = (SwW4WWriter&)rWrt; + + if ( rW4WWrt.bHdFt ) // hier ignorieren ( mag WW2 nicht ) + return rWrt; + const SvxFmtBreakItem &rBreak = (const SvxFmtBreakItem&)rHt; + +#ifdef JP_NEWCORE + was ist mit Column-Break ??? + - ist das 1. If ohne Block so richtig ??? + der String No_PageBreak wird immer ausgegeben !!!! +#endif + + if( SVX_BREAK_NONE != rBreak.GetBreak() ) + + if ( ( rW4WWrt.GetFilter() != 1 ) // Keiner (?) will ^L im Ascii-Text + || ( rW4WWrt.GetIniFlags() & 0x10000) + ) + OUTRECORD( rWrt.Strm(), "HNP" ); + + rWrt.Strm() << sW4W_RECBEGIN << "NOP_PageBreak" << sW4W_TERMEND;//!!! + //!!! PAGEBREAK_AFTER stimmt nicht + + return rWrt; +} + +static Writer& OutW4W_SwPaperBin( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +static Writer& OutW4W_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter & rW4WWrt = (SwW4WWriter&)rWrt; + + // hole erstmal die Seitenangaben + const SwFrmFmt* pFmtPage = rW4WWrt.pPgFrm; + const SvxLRSpaceItem& rPageLR = pFmtPage->GetLRSpace(); + const SwFmtFrmSize& rSz = pFmtPage->GetFrmSize(); + const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rHt; + + USHORT nLeft = (USHORT)rLR.GetTxtLeft(); + USHORT n1st = nLeft + (USHORT)rLR.GetTxtFirstLineOfst(); + USHORT nRight = (USHORT)(rSz.GetWidth() - rLR.GetRight() ); + if ( !rW4WWrt.bPageDesc ) + { + nLeft += (USHORT)rPageLR.GetLeft(); + n1st += (USHORT)rPageLR.GetLeft(); + nRight -= (USHORT)rPageLR.GetRight(); + } +#ifdef NIE // Besser ist IPS statt RSM/STM + rWrt.Strm() << W4W_RECBEGIN << "RSM0" << W4W_TXTERM + << '0' << W4W_TXTERM + << String((long)Fraction( nLeft, 144 )).GetStr() << W4W_TXTERM + << String((long)Fraction( nRight, 144 )).GetStr() + << W4W_TXTERM + << String(nLeft).GetStr() << W4W_TXTERM + << String(nRight).GetStr() << W4W_TXTERM + << W4W_RED; +#endif //NIE + // Benutze IPS fuer links, 1.Zeile, rechts + + rWrt.Strm() << sW4W_RECBEGIN << "IPS"; + rWrt.OutLong( nLeft / 144 ) << cW4W_TXTERM; + rWrt.OutLong( n1st / 144 ) << cW4W_TXTERM; + rWrt.OutLong( nLeft ) << cW4W_TXTERM; + rWrt.OutLong( n1st ) << cW4W_TXTERM; + rWrt.OutLong( nRight ) << sW4W_TERMEND; + + return rWrt; +} + +static Writer& OutW4W_SwFmtULSpace( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if ( rW4WWrt.bPageDesc ) // SBF/SAF geht nur fuer Absaetze, fuer + return rWrt; // Pagedesc sollte STP/SBP sein oder ignorieren + + const SvxULSpaceItem & rUL = (const SvxULSpaceItem&)rHt; + + if( 0 != rUL.GetUpper() ) + { + rWrt.Strm() << sW4W_RECBEGIN << "SBF"; + rWrt.OutLong( rUL.GetUpper() ) << cW4W_TXTERM + << '0' << sW4W_TERMEND; // WW2-Hack: Wenn nLines != 0 ist, + // muessen nLines HNL1 folgen, sonst + // wird HNL ignoriert. Es duerfen aber auch + // nicht zu viele HNL1 da sein, da sie sonst + // als HNL interpretiert werden. Deshalb behaupte + // ich, dass nLines = 0 statt nLines = GetUpper()/240. + // Das SBF duerfte daher bei zeilenorientierten + // Formaten verloren gehen. + + if ( rW4WWrt.bStyleDef || rW4WWrt.bStyleOnOff ) + rW4WWrt.GetStrm() << sW4W_RECBEGIN << "SBF" << '0' << cW4W_TXTERM + << '0' << sW4W_TERMEND; + else + rW4WWrt.GetNlStrm() << sW4W_RECBEGIN << "SBF" << '0' << cW4W_TXTERM + << '0' << sW4W_TERMEND; // Wieder zurueckstellen ?? + } + if( 0 != rUL.GetLower() ) + { + rWrt.Strm() << sW4W_RECBEGIN << "SAF"; + rWrt.OutLong( rUL.GetLower() ) << cW4W_TXTERM + << '0' << sW4W_TERMEND; // WW2-Hack, siehe oben. Erschwerend + // kommt hinzu, dass hier die HNL1 *vor* + // dem HNL stehen muessen.... + + if ( rW4WWrt.bStyleDef || rW4WWrt.bStyleOnOff ) + rW4WWrt.GetStrm() << sW4W_RECBEGIN << "SAF" << '0' << cW4W_TXTERM + << '0' << sW4W_TERMEND; // Wieder zurueckstellen ?? + else + rW4WWrt.GetNlStrm() << sW4W_RECBEGIN << "SAF" << '0' << cW4W_TXTERM + << '0' << sW4W_TERMEND; + } + return rWrt; +} + +static Writer& OutW4W_SwFmtPrint( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwFmtOpaque( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwFmtProtect( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwFmtSurround( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +/* File GRFATR.HXX */ + +static Writer& OutW4W_SwMirrorGrf( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + +static Writer& OutW4W_SwCropGrf( Writer& rWrt, const SfxPoolItem& /*rHt*/ ) +{ + return rWrt; +} + + +/* File PARATR.HXX */ + +static Writer& OutW4W_SwLineSpacing( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxLineSpacingItem &rLs = (const SvxLineSpacingItem&)rHt; + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + switch( rLs.GetLineSpaceRule() ) + { + case SVX_LINE_SPACE_AUTO: + case SVX_LINE_SPACE_FIX: + case SVX_LINE_SPACE_MIN: + { + + short nLsp = 0; + + switch( rLs.GetInterLineSpaceRule() ) + { + case SVX_INTER_LINE_SPACE_FIX: // Durchschuss + nLsp = 240 + rLs.GetInterLineSpace(); + break; + case SVX_INTER_LINE_SPACE_PROP: // 1.5, 2-zeilig, Prop + { + long nTmp = 240; + nTmp *= rLs.GetPropLineSpace(); + nLsp = (short)nTmp; + } + break; + default: // z.B. Minimum + nLsp = rLs.GetLineHeight(); + break; + } + if ( nLsp < 60 ) nLsp = 60; // keine sinnlosen Werte + rW4WWrt.Strm() << sW4W_RECBEGIN + << "RSP2" << cW4W_TXTERM; // old Spacing 1-zeilig + rWrt.OutLong( ( nLsp + 60 ) / 120 ) << cW4W_TXTERM; // new in 1/2 zeilen + rWrt.OutLong( nLsp ) << sW4W_TERMEND; // dito in Twips + + if ( rW4WWrt.bStyleDef || rW4WWrt.bStyleOnOff ) + rW4WWrt.GetStrm() << sW4W_RECBEGIN // RSP per StylePostNlStrm + << "RSP2" << cW4W_TXTERM // wieder ausschalten + << '2' << cW4W_TXTERM + << "240" << sW4W_TERMEND; + else + rW4WWrt.GetNlStrm() << sW4W_RECBEGIN // RSP per StylePostNlStrm + << "RSP2" << cW4W_TXTERM // wieder ausschalten + << '2' << cW4W_TXTERM + << "240" << sW4W_TERMEND; + } + break; + } + return rWrt; +} + +static Writer& OutW4W_SwAdjust( Writer& rWrt, const SfxPoolItem& rHt ) +{ + const SvxAdjustItem & rAdjust = ((const SvxAdjustItem&)rHt); + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + switch( rAdjust.GetAdjust() ) + { + case SVX_ADJUST_RIGHT: + { + rW4WWrt.Strm() << sW4W_RECBEGIN << "AFR10" << cW4W_TXTERM + << "10" << cW4W_TXTERM + << '0' << sW4W_TERMEND; + OUTRECORD( rW4WWrt.GetStrm(), "EAT" ); + } + break; + case SVX_ADJUST_BLOCK: + case SVX_ADJUST_BLOCKLINE: + { + OUTRECORD( rW4WWrt.Strm(), "BRJ" ); + OUTRECORD( rW4WWrt.GetStrm(), "ERJ" ); + } + break; + + case SVX_ADJUST_CENTER: + { + rW4WWrt.Strm() << sW4W_RECBEGIN << "CTX0" << cW4W_TXTERM + << '0' << cW4W_TXTERM + << '0' << sW4W_TERMEND; + OUTRECORD( rW4WWrt.GetStrm(), "ECT" ); + } + break; + } + return rWrt; +} + + +static Writer& OutW4W_SwSplit( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + if( !((SvxFmtSplitItem&)rHt).GetValue() ) + OUTRECORD( rW4WWrt.GetStrm(), "KEP" ); + return rWrt; +} + +static Writer& OutW4W_SwWidows( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + const SvxWidowsItem& rWid = (const SvxWidowsItem&)rHt; + + rW4WWrt.Strm() << sW4W_RECBEGIN << "WON"; + rWrt.OutLong( rWid.GetValue() ) << sW4W_TERMEND; + OUTRECORD( rW4WWrt.GetStrm(), "WOY" ); + + return rWrt; +} + +static Writer& OutW4W_SwOrphans( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + const SvxOrphansItem& rOr = (const SvxOrphansItem&)rHt; + + rW4WWrt.Strm() << sW4W_RECBEGIN << "WON"; + rWrt.OutLong( rOr.GetValue() ) << sW4W_TERMEND; + OUTRECORD( rW4WWrt.GetStrm(), "WOY" ); + return rWrt; +} + + +#define MAX_TAB_OVER 1000 // soviel twips ueberhaengen ist ok + +// Wenn beim SWG Tabe bis zu 2 cm ueberhaengen, gelten sie trotzdem noch. +// Wenn bei WW2-Export die Tabs nur 1 Twip ueberhaengen, werden sie +// ignoriert. Das passiert innerhalb von Frames leicht. Deshalb wird hier +// gemogelt. Dass bei Flys die Page-Grenzen statt der Fly-Grenzen genommen +// werden, ist ok, da WW2 dann die Tabs immer noch anerkennt + + +static Writer& OutW4W_SwTabStop( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + + const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt; + SwTwips nLeftMargin, nWidth; + rW4WWrt.GetMargins( nLeftMargin, nWidth ); + + BYTE aTabPosArr[ 32 ]; + BYTE aTabTypesArr[ 20 ]; + BYTE aTabLeadingArr[ 40 ]; + + memset( aTabPosArr, 0, 32 ); + memset( aTabTypesArr, 0, 20 ); + memset( aTabLeadingArr, 0, 40 ); + // Umsetzungtabelle fuer das Adjustment + static BYTE __READONLY_DATA aAdjustArr[ SVX_TAB_ADJUST_DEFAULT - SVX_TAB_ADJUST_LEFT +1 ] = { + /* SVX_TAB_ADJUST_LEFT */ 0, + /* SVX_TAB_ADJUST_RIGHT */ 2, + /* SVX_TAB_ADJUST_DECIMAL */ 3, + /* SVX_TAB_ADJUST_CENTER */ 1, + /* SVX_TAB_ADJUST_DEFAULT */ 0 + }; + + USHORT n; + for( n = 0; n < rTStops.Count() && n < 40; n++ ) + { + const SvxTabStop & rTS = rTStops[ n ]; // in 1/10 Inch + SwTwips nTabRel = rTS.GetTabPos(); + if ( nTabRel > nWidth + MAX_TAB_OVER ) // teste auf Sinn der Positionen + continue; // Tab out of SRange + if ( nTabRel > nWidth ) + nTabRel = nWidth; // Tab nur wenig out of SRange + + USHORT nSize = (USHORT)( ((long)(nLeftMargin + nTabRel)) / 144 ); + if ( /*nSize < 0 ||*/ nSize / 8 >= 32 ) // Stuss-Werte -> ignorieren + continue; + aTabPosArr[ nSize / 8 ] |= ( 0x80 >> ( nSize % 8 )); + aTabTypesArr[ n / 2 ] |= ( n & 1 ? aAdjustArr[ rTS.GetAdjustment() ] : + aAdjustArr[ rTS.GetAdjustment() ] << 4 ); + if( cDfltFillChar != rTS.GetFill() ) + aTabLeadingArr[ n ] = rTS.GetFill(); + } + + rWrt.Strm() << sW4W_RECBEGIN << "NTB"; + for( n = 0; n < 32; ++n ) + rWrt.OutHex( aTabPosArr[ n ] ) << cW4W_TXTERM; + for( n = 0; n < 20; ++n ) + rWrt.OutHex( aTabTypesArr[ n ] ) << cW4W_TXTERM; + for( n = 0; n < 40; ++n ) + rWrt.OutHex( aTabLeadingArr[ n ] ) << cW4W_TXTERM; + + rWrt.OutLong( rTStops.Count() ) << cW4W_TXTERM; + + for( n = 0; n < rTStops.Count() && n < 40; n++ ) + { + SwTwips nTabRel = rTStops[ n ].GetTabPos(); + if ( nTabRel > nWidth + MAX_TAB_OVER ) // teste auf Sinn der Positionen + continue; // Tab out of SRange + if ( nTabRel > nWidth ) + nTabRel = nWidth; // Tab nur wenig out of SRange + rWrt.OutLong( nLeftMargin + nTabRel ) << cW4W_TXTERM; + } + + rWrt.Strm() << cW4W_RED; + return rWrt; +} + +static Writer& OutW4W_SwHyphenZone( Writer& rWrt, const SfxPoolItem& rHt ) +{ + SwW4WWriter& rW4WWrt = (SwW4WWriter&)rWrt; + const SvxHyphenZoneItem& rAttr = (const SvxHyphenZoneItem&)rHt; + + if ( rW4WWrt.GetFilter() == 48 ) //!!! Bug WP6.0-Filter + return rWrt; // fuehrt zu Absturz WP6 + + if ( !rAttr.IsHyphen() ) + { + OUTRECORD( rW4WWrt.Strm(), "EHP" ); + return rWrt; + } + OUTRECORD( rW4WWrt.Strm(), "BHP" ); + OUTRECORD( rW4WWrt.GetStrm(), "EHP" ); + + // Nach Angabe der W4W-Doku gibt es auch den + // RHZ-Befehl, der sagt, wie getrennt werden soll. + // Bei WP6 scheint er aber zumindest + // beim Import nicht zu funktionieren. + // In WW2 gibt es diese Einstellmoeglichkeit + // anscheinend nicht. + return rWrt; +} + +/* + * lege hier die Tabellen fuer die W4W-Funktions-Pointer auf + * die Ausgabe-Funktionen an. + * Es sind lokale Strukturen, die nur innerhalb der W4W-DLL + * bekannt sein muessen. + */ + +SwAttrFnTab aW4WAttrFnTab = { +/* RES_CHRATR_CASEMAP */ OutW4W_SwCaseMap, +/* RES_CHRATR_CHARSETCOLOR */ 0, +/* RES_CHRATR_COLOR */ OutW4W_SwColor, +/* RES_CHRATR_CONTOUR */ OutW4W_SwContour, +/* RES_CHRATR_CROSSEDOUT */ OutW4W_SwCrossedOut, +/* RES_CHRATR_ESCAPEMENT */ OutW4W_SwEscapement, +/* RES_CHRATR_FONT */ OutW4W_SwFont, +/* RES_CHRATR_FONTSIZE */ OutW4W_SwSize, +/* RES_CHRATR_KERNING */ OutW4W_SwKerning, +/* RES_CHRATR_LANGUAGE */ OutW4W_SwLanguage, +/* RES_CHRATR_POSTURE */ OutW4W_SwPosture, +/* RES_CHRATR_PROPORTIONALFONTSIZE*/0, +/* RES_CHRATR_SHADOWED */ OutW4W_SwShadowed, +/* RES_CHRATR_UNDERLINE */ OutW4W_SwUnderline, +/* RES_CHRATR_WEIGHT */ OutW4W_SwWeight, +/* RES_CHRATR_WORDLINEMODE */ 0, // AMA 14.10.94: NEU +/* RES_CHRATR_AUTOKERN */ 0, // AMA 27.01.95: NEU +/* RES_CHRATR_BLINK */ 0, +/* 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_NOLINEBREAK */ 0, +/* RES_TXTATR_NOHYPHEN */ 0, +/* RES_TXTATR_REFMARK */ 0, /* OutW4W_RefMark */ +/* RES_TXTATR_TOXMARK */ 0, /* OutW4W_SwTxtTOXMark */ +/* 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 */ OutW4W_SwField, +/* RES_TXTATR_FLYCNT */ 0, /* OutW4W_SwFlyCntnt */ +/* RES_TXTATR_FTN */ OutW4W_SwFtn, +/* RES_TXTATR_SOFTHYPH */ 0, /* OutW4W_SwSoftHyph */ +/* RES_TXTATR_HARDBLANK */ 0, /* OutW4W_HardBlank */ +/* RES_TXTATR_DUMMY1 */ 0, // Dummy: +/* RES_TXTATR_DUMMY2 */ 0, // Dummy: + +/* RES_PARATR_LINESPACING */ OutW4W_SwLineSpacing, +/* RES_PARATR_ADJUST */ OutW4W_SwAdjust, +/* RES_PARATR_SPLIT */ OutW4W_SwSplit, +/* RES_PARATR_WIDOWS */ OutW4W_SwWidows, +/* RES_PARATR_ORPHANS */ OutW4W_SwOrphans, +/* RES_PARATR_TABSTOP */ OutW4W_SwTabStop, +/* RES_PARATR_HYPHENZONE*/ OutW4W_SwHyphenZone, +/* RES_PARATR_DROP */ 0, +/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit +/* RES_PARATR_NUMRULE */ 0, // NumRule +/* RES_PARATR_SCRIPTSPACE */ 0, // Dummy: +/* RES_PARATR_HANGINGPUNCTUATION */ 0, // Dummy: +/* RES_PARATR_DUMMY1 */ 0, // Dummy: +/* RES_PARATR_DUMMY2 */ 0, // Dummy: +/* RES_PARATR_DUMMY3 */ 0, // Dummy: +/* RES_PARATR_DUMMY4 */ 0, // Dummy: +/* RES_PARATR_DUMMY5 */ 0, // Dummy: +/* RES_PARATR_DUMMY6 */ 0, // Dummy: +/* RES_PARATR_DUMMY7 */ 0, // Dummy: +/* RES_PARATR_DUMMY8 */ 0, // Dummy: + +/* RES_FILL_ORDER */ OutW4W_SwFillOrder, +/* RES_FRM_SIZE */ OutW4W_SwFrmSize, +/* RES_PAPER_BIN */ OutW4W_SwPaperBin, +/* RES_LR_SPACE */ OutW4W_SwFmtLRSpace, +/* RES_UL_SPACE */ OutW4W_SwFmtULSpace, +/* RES_PAGEDESC */ OutW4W_SwFmtPageDesc, +/* RES_BREAK */ OutW4W_SwBreak, +/* RES_CNTNT */ 0, /* OutW4W_??? */ +/* RES_HEADER */ OutW4W_SwFmtHeader, +/* RES_FOOTER */ OutW4W_SwFmtFooter, +/* RES_PRINT */ OutW4W_SwFmtPrint, +/* RES_OPAQUE */ OutW4W_SwFmtOpaque, +/* RES_PROTECT */ OutW4W_SwFmtProtect, +/* RES_SURROUND */ OutW4W_SwFmtSurround, +/* RES_VERT_ORIENT */ OutW4W_SwFmtVertOrient, +/* RES_HORI_ORIENT */ OutW4W_SwFmtHoriOrient, +/* RES_ANCHOR */ 0, /* OutW4W_??? */ +/* RES_BACKGROUND */ 0, /* OutW4W_??? */ +/* RES_BOX */ OutW4W_SwFmtBox, +/* RES_SHADOW */ 0, /* OutW4W_??? */ +/* RES_FRMMACRO */ 0, /* OutW4W_??? */ +/* RES_COL */ 0, /* OutW4W_??? */ +/* RES_KEEP */ 0, /* OutW4W_??? */ +/* 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 */ OutW4W_SwMirrorGrf, +/* RES_GRFATR_CROPGRF */ 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 +}; + +SwNodeFnTab aW4WNodeFnTab = { +/* RES_TXTNODE */ OutW4W_SwTxtNode, +/* RES_GRFNODE */ OutW4W_SwGrfNode, +/* RES_OLENODE */ OutW4W_SwOLENode +}; + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4wgraf.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4wgraf.cxx new file mode 100644 index 000000000000..2caabc6348ba --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4wgraf.cxx @@ -0,0 +1,1081 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdlib.h> +#ifdef UNX + #include <unistd.h> +#endif + +#include <unotools/tempfile.hxx> +#include <vcl/graph.hxx> +#include <tools/poly.hxx> +#include <bf_svtools/filter.hxx> +#include <vcl/virdev.hxx> +#include <tools/cachestr.hxx> +#include <bf_svx/impgrf.hxx> + +#include <shellio.hxx> +#include <w4wstk.hxx> // fuer den Attribut Stack +#include <w4wpar.hxx> // ERR_CHAR +#include <w4wgraf.hxx> // eigenes +#include <osl/endian.h> +namespace binfilter { + +#define MAX_MEM_GRAF 300000 // ab 300K im File statt im Speicher + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Windows BMP ///////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +class BmpFileHd +{ // Vorsicht: Struktur ist nicht aligned +public: + USHORT Typ; // = "BM" + ULONG Size; // Filesize in Bytes + USHORT Reserve1; // Reserviert + USHORT Reserve2; // Reserviert + ULONG Offset; // Offset? + + friend SvStream& operator << ( SvStream& rOStream, BmpFileHd& rHead ); //$ ostream +}; + +#define BMP_FILE_HD_SIZ 14 // Groesse der Struktur BmpFileHd + + +class BmpInfoHd +{ // Dieser Header ist aligned +public: + ULONG Size; // Gr”áe des BmpInfoHeaders + long Width; // Breite in Pixel + long Height; // H”he in Pixel + USHORT Planes; // Anzahl der Planes (immer 1) + + USHORT PixBits; // Anzahl der Bit je Pixel (1,4,8,oder 24) + ULONG Compress; // Datenkompression + ULONG ImgSize; // Gr”áe der Images in Bytes. Ohne Kompression ist auch 0 erlaubt. + long xDpmm; // Dot per Meter (0 ist erlaubt) + long yDpmm; // Dot per Meter (0 ist erlaubt) + ULONG ColUsed; // Anzahl der verwendeten Farben (0=alle) + ULONG ColMust; // Anzahl der wichtigen Farben (0=alle) + + friend SvStream& operator << ( SvStream& rOStream, BmpInfoHd& rHead ); //$ ostream +}; + +class RGBQuad { +private: + unsigned char Red; + unsigned char Grn; + unsigned char Blu; + unsigned char Fil; +public: + RGBQuad( unsigned char R, unsigned char G, unsigned char B ) + { Red=R; Grn=G; Blu=B; Fil=0; } +}; + + +SvStream& operator << ( SvStream& rOStream, BmpFileHd& rHead ) //$ ostream +{ + BmpFileHd aHd = rHead; + +#ifndef OSL_LITENDIAN + aHd.Typ =SWAPSHORT( aHd.Typ ); + aHd.Size =SWAPLONG ( aHd.Size ); + aHd.Reserve1=SWAPSHORT( aHd.Reserve1 ); + aHd.Reserve2=SWAPSHORT( aHd.Reserve2 ); + aHd.Offset =SWAPLONG ( aHd.Offset ); +#endif // !OSL_LITENDIAN + + // Da MS die BmpFileHd-Struktur nicht aligned hat, + // muessen die Member einzeln 'rausgeschrieben werden, + // da die Groesse der Sruktur von Compiler zu Compiler + // unterschiedlich ist. + + rOStream.Write( (char*)&aHd.Typ, sizeof( aHd.Typ ) ); + rOStream.Write( (char*)&aHd.Size, sizeof( aHd.Size ) ); + rOStream.Write( (char*)&aHd.Reserve1, sizeof( aHd.Reserve1 ) ); + rOStream.Write( (char*)&aHd.Reserve2, sizeof( aHd.Reserve2 ) ); + rOStream.Write( (char*)&aHd.Offset, sizeof( aHd.Offset ) ); + + return rOStream; +} + + +SvStream& operator << ( SvStream& rOStream, BmpInfoHd& rInfo) //$ ostream +{ +#ifndef OSL_LITENDIAN + BmpInfoHd aInfo = rInfo; + + aInfo.Size =SWAPLONG ( aInfo.Size ); + aInfo.Width =SWAPLONG ( aInfo.Width ); + aInfo.Height =SWAPLONG ( aInfo.Height ); + aInfo.Planes =SWAPSHORT( aInfo.Planes ); + aInfo.PixBits =SWAPSHORT( aInfo.PixBits ); + aInfo.Compress=SWAPLONG ( aInfo.Compress ); + aInfo.ImgSize =SWAPLONG ( aInfo.ImgSize ); + aInfo.xDpmm =SWAPLONG ( aInfo.xDpmm ); + aInfo.yDpmm =SWAPLONG ( aInfo.yDpmm ); + aInfo.ColUsed =SWAPLONG ( aInfo.ColUsed ); + aInfo.ColMust =SWAPLONG ( aInfo.ColMust ); + + rOStream.Write( (char*)&aInfo, sizeof(aInfo) ); +#else // !OSL_LITENDIAN + rOStream.Write( (char*)&rInfo, sizeof(rInfo) ); +#endif // !OSL_LITENDIAN + return rOStream; +} + + +SwW4WGraf::SwW4WGraf( SvStream& rIstream ) + : rInp( rIstream ) +{ + pBmp = 0; + pGraph = 0; + nError = 0; + nStat = 0; + pPal = 0; + nPalColors = 0; + pBmpHead = 0; + pBmpInfo = 0; + nVectMinX = nVectMinY = USHRT_MAX; + nVectMaxX = nVectMaxY = 0; +} + + +SwW4WGraf::~SwW4WGraf() +{ + if( pGraph ) + delete pGraph; + if( pBmp ) + delete pBmp; +} + + +short SwW4WGraf::GetHexByte() // Ret: -1 fuer W4W_TXT_TERM, W4W_RED +{ + register unsigned int c; + register unsigned int nHexVal = 0; // Default fuer Error + + for ( int i = 0; i < 2; ++i ) + { + c = ReadChar(); + if( c == 0 ) + { // eof oder Stuss + nError = ERR_CHAR; + return -1; + } + if( c >= '0' && c <= '9' ) (nHexVal <<= 4 )+= (c - '0'); + else if( c >= 'A' && c <= 'F' ) (nHexVal <<= 4 )+= (c - 'A' + 10); + else if( c >= 'a' && c <= 'f' ) (nHexVal <<= 4 )+= (c - 'a' + 10); + else + { + nError = ERR_CHAR; + return 0; + } + } + + return (short)nHexVal; +} + + +USHORT SwW4WGraf::GetHexUShort() +{ + int c = (int)GetHexByte(); + return( (BYTE)c | ( (USHORT)GetHexByte() << 8 ) ); +} + + +ULONG SwW4WGraf::GetHexULong() +{ + register ULONG c = 0; + register int i; + for ( i=0; i<32; i+=8 ) + c |= ((ULONG)GetHexByte()) << i; + return c; +} + + +long SwW4WGraf::GetVarSize() // Zum Lesen der Recordlaenge (in 1..5 Byte codiert) +{ + BYTE c0, c1, c2, c3, c4; + + if ( ( c0 = (BYTE)GetHexByte() ) != 0xff ) // 1-Byte-Darstellung : Wert + return c0; + + c1 = (BYTE)GetHexByte(); + c2 = (BYTE)GetHexByte(); + if ( ( c2 & 0x80 ) == 0 ) // 3-Byte-Darstellung : + return ( (USHORT)c2 << 8 ) | c1; // 0xff LowByte HiByte + + c3 = (BYTE)GetHexByte(); // 5-Byte-Darstellung: + c4 = (BYTE)GetHexByte(); // 0xff Byte2 (Byte3 | 0x80) Byte0 Byte1 + return( ( ( (long) c2 & 0x7f ) << 24 ) + | ( (long) c1 << 16 ) + | ( (USHORT)c4 << 8 ) + | c3 ); +} + + +short SwW4WGraf::DefaultPalette( USHORT nColors ) +{ + pPal = (RGBQuad*)new char[ nColors*sizeof(RGBQuad) ]; + if ( !pPal ) return -1; + nPalColors = nColors; + register RGBQuad* pP = pPal; + + if (nColors==2) { + *pP++ = RGBQuad(0x00,0x00,0x00); // Schwarz + *pP++ = RGBQuad(0xFF,0xFF,0xFF); // Weiss + } + else if (nColors==16) + { + *pP++ = RGBQuad(0x00,0x00,0x00); // Schwarz + *pP++ = RGBQuad(0x24,0x24,0x24); // Grau 80% + *pP++ = RGBQuad(0x49,0x49,0x49); // Grau 60% + *pP++ = RGBQuad(0x92,0x92,0x92); // Grau 40% + *pP++ = RGBQuad(0x6D,0x6D,0x6D); // Grau 30% + *pP++ = RGBQuad(0xB6,0xB6,0xB6); // Grau 20% + *pP++ = RGBQuad(0xDA,0xDA,0xDA); // Grau 10% + *pP++ = RGBQuad(0xFF,0xFF,0xFF); // Weiss + *pP++ = RGBQuad(0x00,0x00,0x00); // Schwarz + *pP++ = RGBQuad(0xFF,0x00,0x00); // Rot + *pP++ = RGBQuad(0x00,0x00,0xFF); // Blau + *pP++ = RGBQuad(0xFF,0x00,0xFF); // Magenta + *pP++ = RGBQuad(0x00,0xFF,0x00); // Gruen + *pP++ = RGBQuad(0xFF,0xFF,0x00); // Gelb + *pP++ = RGBQuad(0x00,0xFF,0xFF); // Cyan + *pP++ = RGBQuad(0xFF,0xFF,0xFF); // Weiss + } else + return -1; + return 0; +} + + + +short SwW4WGraf::ReadPalette( long nVarSize ) +{ + nPalColors = (USHORT)(nVarSize / 3); + pPal = (RGBQuad*)new char[ nPalColors*sizeof(RGBQuad) ]; + if ( !pPal ){ nPalColors = 0; return -1; }; + register RGBQuad* pP = pPal; + USHORT i; + + for (i=0; i<nPalColors; i++) + *pP++ = RGBQuad( (BYTE)GetHexByte(), (BYTE)GetHexByte(), (BYTE)GetHexByte() ); + return 0; +} + + + +short SwW4WGraf::ReadBitmap( long ) // Mastersoft internal Format Bitmap +{ + ULONG n4Width = GetHexULong(); // Lies Header ein + ULONG n4Height = GetHexULong(); + USHORT n4ResWidth = GetHexUShort(); + USHORT n4ResHeight = GetHexUShort(); + USHORT n4ColBits = GetHexUShort(); + + USHORT nColors = (1 << n4ColBits); // Anzahl der Farben (1,16,256) + USHORT nWdtIn = (USHORT)((n4Width*n4ColBits+7)/8); + USHORT nWdtOut = (USHORT)(((n4Width*n4ColBits+31)/32)*4); + +if( 24 > n4ColBits ) +{ + + + if ( !pPal || ( nColors != nPalColors ) ){ // keine oder falsche Palette + if ( pPal ) DELETEZ( pPal ); + if ( DefaultPalette( nColors ) < 0 ) // mach selbst + return -1; + } + + +} + + + pBmpHead = new BmpFileHd; // erzeuge BMP-Header + if ( !pBmpHead ) return -1; + pBmpInfo = new BmpInfoHd; + if ( !pBmpInfo ) return -1; + + pBmpHead->Typ='B'+'M'*256; + pBmpHead->Offset=BMP_FILE_HD_SIZ+sizeof(*pBmpInfo); + if( pPal ) pBmpHead->Offset += nColors*4; + pBmpHead->Size=pBmpHead->Offset+nWdtOut*n4Height; // Reihenfolge wichtig + pBmpHead->Reserve1=0; + pBmpHead->Reserve2=0; + + pBmpInfo->Size=sizeof(*pBmpInfo); + pBmpInfo->Width=n4Width; + pBmpInfo->Height=n4Height; + pBmpInfo->Planes=1; + pBmpInfo->PixBits=n4ColBits; + pBmpInfo->Compress=0; + pBmpInfo->ImgSize=0; + pBmpInfo->xDpmm=n4ResWidth*1000L/254L; // DPI in Pixel per Meter + pBmpInfo->yDpmm=n4ResHeight*1000L/254; // dito + pBmpInfo->ColUsed=0; + pBmpInfo->ColMust=0; + + if ( nWdtOut != (size_t)nWdtOut ) return -1; // Zeile nicht allozierbar + BYTE* pBuf = new BYTE[nWdtOut]; + if ( !pBuf ) return -1; // Fehler: kein Speicher da + + String sExt(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( ".bmp" ))); + ::utl::TempFile aTempFile(aEmptyStr, &sExt, 0); + aTempFile.EnableKillingFile(); + + SvStream* pOut = aTempFile.GetStream( STREAM_READ | STREAM_WRITE | + STREAM_TRUNC ); + + *pOut << *pBmpHead<<*pBmpInfo; + if ( pPal ) + pOut->Write( (char*)pPal, nPalColors*sizeof(*pPal) ); // hier kein ByteSwap noetig + // da nur Bytes enthalten + USHORT x, y; + short nLeft; + BYTE c, nRun; + BYTE* pB; + + for( y=0; y<n4Height; y++) + { + nLeft = nWdtIn; + pB = pBuf; + while ( nLeft > 0 ){ + nRun = (BYTE)GetHexByte(); + if ( ( nRun & 0x80 ) != 0 ){ // komprimiert + nRun &= 0x7f; + c = (BYTE)GetHexByte(); + for ( x=0; x<nRun; x++){ + *pB++ = c; + } + }else{ // unkomprimiert + for ( x=0; x<nRun; x++){ + *pB++ = (BYTE)GetHexByte(); + } + } + nLeft -= nRun; + } + for ( x=nWdtIn; x<nWdtOut; x++ ) + *pB++ = 0x00; // 0..3 Bytes Luecke + pOut->Write( (char*)pBuf, (size_t)nWdtOut ); + } + pOut->Seek(0); + GraphicFilter& rGF = *GetGrfFilter(); // lese ueber Filter ein + pGraph = new Graphic; + BOOL bOk = ( rGF.ImportGraphic( *pGraph, aEmptyStr, *pOut, + GRFILTER_FORMAT_DONTKNOW ) + == 0 ); + + if( !bOk ) + DELETEZ( pGraph ); + + return ( bOk ) ? 0 : -1; // OK / Error +} + + +void SwW4WGraf::SkipBytes( register long nBytes ) +{ + nBytes *= 2; // 1 Byte = 2 Chars im File + rInp.SeekRel( nBytes ); +} + +#define W4WRG_Ignore 0x0000 /* Dummy */ +#define W4WRG_RecdID 0x0001 /* orginal file type, etc. */ +#define W4WRG_DefPal 0x0002 /* Define Palette */ +#define W4WRG_DefPen 0x0003 /* Define Pen */ +#define W4WRG_DefBrs 0x0004 /* Define Brush */ +#define W4WRG_DefMrk 0x0005 /* Define Marker */ +#define W4WRG_MoveTo 0x0008 /* Move To */ +#define W4WRG_LineTo 0x0009 /* Line To */ +#define W4WRG_FloodF 0x000A /* Floodfill Area */ +#define W4WRG_SetFil 0x000B /* Set Fillmode */ +#define W4WRG_DrMark 0x000C /* Draw Marker */ +#define W4WRG_DrMrkP 0x000D /* Draw an Array of Markers */ +#define W4WRG_DrRect 0x000E /* Draw a SRectangle */ +#define W4WRG_DrPLin 0x000F /* Draw a Polyline */ +#define W4WRG_DrPoly 0x0010 /* Draw a Polygon */ +#define W4WRG_DrwArc 0x0011 /* Draw an Arc */ +#define W4WRG_DrwPie 0x0012 /* Draw a Pie */ +#define W4WRG_DrCirc 0x0013 /* Draw a Circle or an Ellipse */ +#define W4WRG_DrBMap 0x0014 /* Draw a Bitmap */ +#define W4WRG_Scalng 0x0015 /* Set Scaling Mode */ +#define W4WRG_Rotate 0x0016 /* Set Rotation Value */ +#define W4WRG_DefFnt 0x0017 /* Define Font */ +#define W4WRG_DrText 0x0018 /* Draw Text */ +#define W4WRG_BckCol 0x0019 /* Set Backgroundcolor */ +#define W4WRG_StGrup 0x001A /* Start grouped Objects */ +#define W4WRG_EoGrup 0x001B /* End grouped Objects */ +#define W4WRG_DrChrd 0x001C /* Draw a Chord */ +#define W4WRG_DefP16 0x001D /* Define 16 Bit Palette */ +#define W4WRG_DefGCv 0x001E /* Define Gray Curve */ +#define W4WRG_DefFHd 0x001F /* Define File Header */ + +#define W4WRG_TextBox 0x0020 /* Text box */ +#define W4WRG_StClPath 0x0021 /* Start enclosed path */ +#define W4WRG_EoClPath 0x0022 /* End enclosed path */ +#define W4WRG_Bezier 0x0023 /* Draw a bezier curve */ +#define W4WRG_Dr24bitBMap 0x0024 /* Draw a 24bit Bitmap */ +#define W4WRG_Comment 0x0025 /* intermal MSG comment */ +#define W4WRG_Spline 0x0026 /* to be defined */ +#define W4WRG_Transform 0x0027 /* to be defined */ +#define W4WRG_LineHead 0x0028 /* to be defined */ +#define W4WRG_LineTail 0x0029 /* to be defined */ +#define W4WRG_CanvasCol 0x002A /* canvas color of image */ +#define W4WRG_BmpPos 0x002B /* x,y and scaling of bitmap */ + +#define W4WRG_EoFile 0xFFFF /* End of File */ + + + +int SwW4WGraf::GetNextRecord() +{ + USHORT nRecId; + long nVarSize; + short nRet=0; + + nRecId=GetHexUShort(); + nVarSize=GetVarSize(); + + switch( nRecId ) + { + case W4WRG_DefPal: nRet = ReadPalette( nVarSize ); break; + case W4WRG_DrBMap: nRet = ReadBitmap( nVarSize ); break; + case W4WRG_Dr24bitBMap: nRet = ReadBitmap( nVarSize ); break; + default: SkipBytes( nVarSize ); + } + if( nRet < 0 ) nStat = nRet; + return (nRet) ? nRet : nRecId; +} + + +short SwW4WGraf::ReadW4WGrafBMap( long, long, long ) // Mastersoft internal Format Bitmap +{ + int nRet; + do { + nRet=GetNextRecord(); + } while (nError==0 && nRet!=(int)W4WRG_EoFile && nRet!=-1 && nRet!=-1); //$ EOF + return nStat; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// W4W Vectorimport von Joe (BEGIN) /////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef JOEDEBUG + + +void ShowW4WGrafRec(USHORT nRecID) +{ + static USHORT nLnCnt=0; + switch (nRecID) { + case W4WRG_Ignore: ShowMsg("Dummy "); break; + case W4WRG_RecdID: ShowMsg("OrgFileTp "); break; + case W4WRG_DefPal: ShowMsg("Def_Pal Û"); break; + case W4WRG_DefPen: ShowMsg("Def_Pen "); break; + case W4WRG_DefBrs: ShowMsg("Def_Brs "); break; + case W4WRG_DefMrk: ShowMsg("Def_Mark Û"); break; + case W4WRG_MoveTo: ShowMsg("Move_To "); break; + case W4WRG_LineTo: ShowMsg("Line_To "); break; + case W4WRG_FloodF: ShowMsg("FloodfillÛ"); break; + case W4WRG_SetFil: ShowMsg("Set_Fill Û"); break; + case W4WRG_DrMark: ShowMsg("Drw_Mark Û"); break; + case W4WRG_DrMrkP: ShowMsg("Drw_MarkAÛ"); break; + case W4WRG_DrRect: ShowMsg("Drw_Rect "); break; + case W4WRG_DrPLin: ShowMsg("Drw_PLine "); break; + case W4WRG_DrPoly: ShowMsg("Drw_Poly "); break; + case W4WRG_DrwArc: ShowMsg("Drw_Arc Û"); break; + case W4WRG_DrwPie: ShowMsg("Drw_Pie Û"); break; + case W4WRG_DrCirc: ShowMsg("Drw_Circ Û"); break; + case W4WRG_DrBMap: ShowMsg("Drw_BMap Û"); break; + case W4WRG_Scalng: ShowMsg("Set_ScaleÛ"); break; + case W4WRG_Rotate: ShowMsg("Set_Rota Û"); break; + case W4WRG_DefFnt: ShowMsg("Def_Font Û"); break; + case W4WRG_DrText: ShowMsg("Drw_Text Û"); break; + case W4WRG_BckCol: ShowMsg("Set_BCol Û"); break; + case W4WRG_StGrup: ShowMsg("Start_Grp "); break; + case W4WRG_EoGrup: ShowMsg("End_Grp "); break; + case W4WRG_DrChrd: ShowMsg("Drw_ChordÛ"); break; + case W4WRG_DefP16: ShowMsg("Def_Pal16Û"); break; + case W4WRG_DefGCv: ShowMsg("Def_PalGrÛ"); break; + case W4WRG_DefFHd: ShowMsg("Def_FHeadÛ"); break; + case W4WRG_EoFile: ShowMsg("EOFÞÜÝÞßÝ \n"); break; + } + nLnCnt++; + if (nLnCnt>=23*8) { + nLnCnt=0; + WaitKey(); + } +} + +#endif + + +BOOL SwW4WGraf::CheckW4WVector() // enth„lt die W4W-Grafik Vektordaten ? (Joe) +{ + long nFPosMerk = rInp.Tell(); + long nVarSize; + USHORT nRecID; + BOOL bRet = FALSE; + + do { + nRecID = GetHexUShort(); + nVarSize = GetVarSize(); + + // Bitmap ? + if( ( nRecID == W4WRG_DefPal ) + || ( nRecID == W4WRG_DrBMap ) + || ( nRecID == W4WRG_Dr24bitBMap ) ) break; + + // Vektor ? + if( ( nRecID == W4WRG_LineTo ) + || ( nRecID == W4WRG_FloodF ) + || ( nRecID == W4WRG_DrMark ) + || ( nRecID == W4WRG_DrMrkP ) + || ( nRecID == W4WRG_DrRect ) + || ( nRecID == W4WRG_DrPLin ) + || ( nRecID == W4WRG_DrPoly ) + || ( nRecID == W4WRG_DrwArc ) + || ( nRecID == W4WRG_DrwPie ) + || ( nRecID == W4WRG_DrCirc ) + || ( nRecID == W4WRG_DrText ) + || ( nRecID == W4WRG_DrChrd ) ) + { + bRet = TRUE; break; + } + SkipBytes( nVarSize ); + } + while( ( !nError ) && ( W4WRG_EoFile != nRecID ) ); + + rInp.Seek( nFPosMerk ); // FilePos restaurieren + return bRet; +} + + +void SwW4WGraf::ReadHexPoint(Point& aPnt) +{ + USHORT xu=GetHexUShort(); + USHORT yu=GetHexUShort(); + if( xu < nVectMinX ) + nVectMinX = xu; + if( xu > nVectMaxX ) + nVectMaxX = xu; + if( yu < nVectMinY ) + nVectMinY = yu; + if( yu > nVectMaxY ) + nVectMaxY = yu; + long x=xu; + long y=yu; + Point a(x,y); + aPnt=a; +} + + +void DrehePoint(Point& P, long cx, long cy, double sn, double cs) +{ + long dx,dy; + double x1,y1; + dx=P.X()-cx; + dy=P.Y()-cy; + x1=dx*cs-dy*sn; + y1=dy*cs+dx*sn; + P=Point(cx+long(x1),cy+long(y1)); +} + + +int SwW4WGraf::GetNextVectRec(OutputDevice& rOut) +{ + USHORT nRecID; + long nVarSize; + + nRecID = GetHexUShort(); + nVarSize = GetVarSize(); + +#ifdef JOEDEBUG +// ShowW4WGrafRec(nRecID); +#endif + + switch (nRecID) { +// case W4WRG_DefPal: nRet=ReadPalette(nVarSize); break; +// case W4WRG_DrBMap: nRet=ReadBitmap(nVarSize); break; + case W4WRG_RecdID: { + /* INT16 nId= */ GetHexUShort(); + /* INT16 nRes= */GetHexUShort(); + /* INT16 nX0= */ GetHexUShort(); + /* INT16 nY0= */ GetHexUShort(); + /* INT16 nX1= */ GetHexUShort(); + /* INT16 nY1= */ GetHexUShort(); + } break; + case W4WRG_Scalng: { + SkipBytes(nVarSize); // Dummy fuer Breakpoint + } break; + case W4WRG_MoveTo: { + ReadHexPoint(aVectPos); + } break; + case W4WRG_LineTo: { + Point aP; + ReadHexPoint(aP); + rOut.DrawLine(aVectPos,aP); + aVectPos=aP; + } break; + case W4WRG_DrPLin: case W4WRG_DrPoly: { + INT16 nPts=GetHexUShort(); + INT16 i; + Polygon aPoly(nPts); + Point P1; + for (i=0;i<nPts;i++) { + ReadHexPoint(P1); + aPoly.SetPoint(P1,i); + } + if (nRecID==W4WRG_DrPLin) rOut.DrawPolyLine(aPoly); + else rOut.DrawPolygon(aPoly); + } break; + case W4WRG_DrRect: { + Point P1,P2; + ReadHexPoint(P1); + ReadHexPoint(P2); + rOut.DrawRect(Rectangle(P1,P2)); + } break; + case W4WRG_DrCirc: { + short xc=(short)GetHexUShort(); + short yc=(short)GetHexUShort(); + short xr=(short)GetHexUShort(); + short yr=(short)GetHexUShort(); + rOut.DrawEllipse(Rectangle(Point(xc-xr,yc-yr),Point(xc+xr,yc+yr))); + } break; + case W4WRG_DrwPie: case W4WRG_DrwArc: { + long xc=(short)GetHexUShort(), + yc=(short)GetHexUShort(), + xr=(short)GetHexUShort(), + yr=(short)GetHexUShort(), + nAnf=(short)GetHexUShort(), + nEnd=(short)GetHexUShort(); + double sn,cs; + Point aAnf(xc+xr,yc); + Point aEnd=aAnf; + sn=sin(double(nAnf)*3.14159265359/18000); + cs=cos(double(nAnf)*3.14159265359/18000); + DrehePoint(aAnf,xc,yc,sn,cs); + sn=sin(double(nEnd)*3.14159265359/18000); + cs=cos(double(nEnd)*3.14159265359/18000); + DrehePoint(aEnd,xc,yc,sn,cs); + if (nRecID==W4WRG_DrwPie) + rOut.DrawPie(Rectangle(Point(xc-xr,yc-yr),Point(xc+xr,yc+yr)),aAnf,aEnd); + else rOut.DrawArc(Rectangle(Point(xc-xr,yc-yr),Point(xc+xr,yc+yr)),aAnf,aEnd); + } break; + case W4WRG_DefBrs: { + USHORT nPat=GetHexUShort(); + USHORT nBlu=GetHexByte(); + USHORT nGrn=GetHexByte(); + USHORT nRed=GetHexByte(); + Color aCol(nRed*0x0100,nGrn*0x0100,nBlu*0x0100); +// Brush aBrs(aCol); + switch (nPat) { + //case 0: Bitmap +// case 1: aBrs.SetStyle(BRUSH_SOLID); break; +// case 2: aBrs.SetStyle(BRUSH_VERT); break; +// case 3: aBrs.SetStyle(BRUSH_UPDIAG); break; // +45deg +// case 4: aBrs.SetStyle(BRUSH_HORZ); break; +// case 5: aBrs.SetStyle(BRUSH_DOWNDIAG); break; // -45deg +// case 6: aBrs.SetStyle(BRUSH_50); break; // Dots +// case 7: aBrs.SetStyle(BRUSH_CROSS); break; +// case 8: aBrs.SetStyle(BRUSH_DIAGCROSS); break; + case 9: aCol.SetTransparency(0xff); break; // BRUSH_NULL Hollow + } + rOut.SetFillColor(aCol); + } break; + case W4WRG_DefPen: { + USHORT nPat=GetHexUShort(); + USHORT nBlu=GetHexByte(); + USHORT nGrn=GetHexByte(); + USHORT nRed=GetHexByte(); + /* USHORT nWdt= */ GetHexUShort(); + /* USHORT nHgt= */ GetHexUShort(); + Color aCol(nRed*0x0100,nGrn*0x0100,nBlu*0x0100); +// Pen aPen(aCol); + switch (nPat) { + case 0: aCol.SetTransparency(0xff);/*aPen.SetStyle(PEN_NULL);*/ break; +// case 1: aPen.SetStyle(PEN_SOLID); break; +// case 2: aPen.SetStyle(PEN_DASH); break; +// case 3: aPen.SetStyle(PEN_DOT); break; +// case 4: aPen.SetStyle(PEN_DASHDOT); break; +// case 5: aPen.SetStyle(PEN_DASHDOT); break; + } + rOut.SetLineColor(aCol); + } break; + case W4WRG_BckCol: { + USHORT nBlu=GetHexByte(); + USHORT nGrn=GetHexByte(); + USHORT nRed=GetHexByte(); + Color aCol(nRed*0x0100,nGrn*0x0100,nBlu*0x0100); + rOut.SetBackground(Wallpaper(aCol)); + } break; + case W4WRG_DefFnt: + { + USHORT i; + USHORT Grad=GetHexByte(); + USHORT nLen=USHORT(nVarSize)-2; // L„nge des Fontnamen inkl. #0 + sal_Char* pC = new sal_Char[ nLen ]; + for (i=0;i<nLen;i++) + pC[i]=(char)GetHexByte(); + String aStr( pC, RTL_TEXTENCODING_IBM_850 ); + Color aColor=rOut.GetLineColor(); + Font aFont(aStr,Size(0,Grad)); + aFont.SetColor(aColor); + rOut.SetFont(aFont); + delete[] pC; + } break; + case W4WRG_DrText: { + USHORT i; + Point P1; + ReadHexPoint(P1); + USHORT nLen=USHORT(nVarSize)-4; // Textl„nge inkl. #0 + char* pC=new char[nLen]; + for (i=0;i<nLen;i++) + pC[i]=(char)GetHexByte(); + String aStr( pC, RTL_TEXTENCODING_IBM_850 ); + rOut.DrawText(P1,aStr); + delete[] pC; + } break; + + /* + folgende Dummys sind ggfs. noch zu implementieren + */ + case W4WRG_TextBox: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_StClPath: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_EoClPath: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_Bezier: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + /* + case W4WRG_Dr24bitBMap: { + ; + } break; + */ + case W4WRG_Comment: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_Spline: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_Transform: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_LineHead: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_LineTail: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_CanvasCol: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + case W4WRG_BmpPos: { + // Dummy-Implementation + short nDummy; + for( USHORT i=0; i < nVarSize; i++) nDummy = GetHexByte(); + } break; + +// Bitmap und Vektoren gemischt geht nicht, denn im W4W-BitmapRec steht +// nichts ber die Position der Bitmap in der Grafik drin. Die Gr”áe der +// Bitmap k”nnte man sich mittels Pixelsize und DPI ausrechnen. Joe M. +// case W4WRG_DefPal: { +// ReadPalette(nVarSize); +// } break; +// case W4WRG_DrBMap: { +// ReadBitmap(nVarSize); +// if (rFileName!=aEmptyStr) { // BMap im File +// rFileName=aEmptystr; +// } else { +// if ... +// } +// } break; + default: SkipBytes(nVarSize); + } + return nRecID; +} + + +short SwW4WGraf::ReadW4WGrafVect( long, long, long ) // Mastersoft internal Format Vector (Joe) +{ + int nRet; + GDIMetaFile aMtf; // fr Vektorimport des internen W4W-Formats (Joe) + VirtualDevice aOut; + aMtf.Record(&aOut); // aOut ans Metafile binden + do { + nRet=GetNextVectRec(aOut); + } while (nError==0 && nRet!=(int)W4WRG_EoFile && nRet!=-1 && nRet!=-1); //$ EOF + aMtf.Stop(); + aMtf.WindStart(); + aMtf.SetPrefMapMode( MAP_10TH_MM ); + long nSizX = (long)nVectMaxX - (long)nVectMinX; // Groesse + long nRandX = nSizX / 50 + 1; // Zugabe + long nSizY = (long)nVectMaxY - (long)nVectMinY; + long nRandY = nSizY / 50 + 1; // Zugabe + aMtf.SetPrefSize( Size( nSizX + 2 * nRandX, nSizY + 2 * nRandY ) ); + + // Das Obere zuunterst kehren + aMtf.Scale( Fraction( 1, 1 ), Fraction( -1, 1 ) ); + aMtf.Move( (long)nVectMinX + nRandX, (long)nVectMaxY + nRandY ); + pGraph=new Graphic(aMtf); + + return nStat; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// W4W Vectorimport von Joe (ENDE) //////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + + + +struct WmfFileHd +{ // Vorsicht: Struktur ist nicht aligned + USHORT nTyp; // 0 = Mem, 1 = File + USHORT nHdSiz; // 0x009 + USHORT nVersion; // 0x300 + ULONG nSize; // filesize in bytes + USHORT nNoObj; // Number of Objects that exist at same time + ULONG nMaxRecLen; // largest record + USHORT nNoParas; // not used +}; + +//#define WMF_FILE_HD_SIZ 18 // Groesse der Struktur WmfFileHd + + +ULONG SwW4WGraf::ReadWmfHeader( WmfFileHd& rHd ) +{ + long nPos = rInp.Tell(); + + rHd.nTyp = GetHexUShort(); + rHd.nHdSiz = GetHexUShort(); + rHd.nVersion = GetHexUShort(); + rHd.nSize = GetHexULong(); + rHd.nNoObj = GetHexUShort(); + rHd.nMaxRecLen = GetHexULong(); + rHd.nNoParas = GetHexUShort(); + + rInp.Seek( nPos ); + return rHd.nSize * 2; // FileSize in Bytes +} + +struct METAFILEHEADER +{ + UINT32 key; + UINT16 hmf; + UINT16 left; + UINT16 top; + UINT16 right; + UINT16 bottom; + UINT16 inch; + UINT32 reserved; + UINT16 checksum; +}; + +#define METAFILEHEADER_SIZE 22 + + +void WriteWmfPreHd( long nWidth, long nHeight, SvStream& rOStream ) //$ ostream +{ + METAFILEHEADER aHeader; + + aHeader.key = 0x9AC6CDD7L; + aHeader.hmf = 0; + aHeader.left = 0; + aHeader.top = 0; + aHeader.right = (USHORT)( nWidth * 100 / 144 ); + aHeader.bottom = (USHORT)( nHeight * 100 / 144 ); + aHeader.inch= 1000; + aHeader.reserved = 0; + aHeader.checksum = 0; + for( USHORT n=0; n < 10; n++ ) + aHeader.checksum ^= *(((UINT16*)&aHeader)+n); + +#ifndef OSL_LITENDIAN + 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 // !OSL_LITENDIAN + + rOStream.Write( (char*)&aHeader, METAFILEHEADER_SIZE ); +} + + +static BYTE WpgFileHd[]={ 0xFF, 0x57, 0x50, 0x43, 0x10, 0x00, 0x00, 0x00, + 0x01, 0x16, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + +short SwW4WGraf::ReadGrafFile( long nTyp, long nWidth, long nHeight ) // Grafik in File schreiben +{ + SvCacheStream aOut; + BOOL bWriteToOut = TRUE; + switch ( nTyp ) + { + /* + Anmerkungen zu den Datei-Formaten, die als + Hex-Dump im Zwischenkode stehen: + + 503 = encapsulated Postscript + mit Vorschau-Header --> alles dumpen + Wir haben hierfuer leider + noch keinen Import-Filter. + + 513 = Bitmap incl. Header --> alles dumpen + + 614 = in AmiPro importierte WPG- + Files, die fuer uns leider + unlesbar sind: unbekanntes + Format --> dennoch alles dumpen + + 615 = WPG ( WordPerfect ) --> alles dumpen + Wir haben hierfuer leider + noch keinen Import-Filter. + + */ + case 1: { // WMF ( z.B. WinWord ) + WmfFileHd aHd; // lies Header + ULONG nSiz = ReadWmfHeader( aHd ); // FileSize in Bytes + + WriteWmfPreHd( nWidth, nHeight, aOut ); // Placeable WMF-Header + + register ULONG i; + for ( i = 0; i < nSiz && !nError; i++ ) // Schreibe Daten + aOut << (BYTE)GetHexByte(); + bWriteToOut = FALSE; + } + break; + + case 606:{ // WPG ( WordPerfect ) + // Es fehlt der File-Header, es gibt auch keine + // Info ueber ihn. Ich nehme mal an, dass er immer + // gleich ist wie in den Beispiel-Dateien von WpWin52 + + for ( int i = 0; i < sizeof( WpgFileHd ); i++ ) // Schreibe Header + aOut << WpgFileHd[ i ]; + } + break; + + case 610:{ // Metafile + // diese Metafile-Dateien sind in + // WinWord eingebunden und + // haben einen verstuemmelten Header + // sowie eine andere Dateilaenge als + // die Original-Dateien + short s = ReadChar(); // ueberlies " 0 | " + s = ReadChar(); + } + break; + + } + + if( bWriteToOut ) + { + register long i = 0; + register short s; // evtl. mit Header + while( !nError ) + { + s = GetHexByte(); // Kopiere Daten + if ( s < 0 ) break; // fertig + aOut << (BYTE)s; + i++; + } + } + + GraphicFilter& rGF = *GetGrfFilter(); // lies ueber UNSERE Filter ein + pGraph = new Graphic(); + + aOut.Seek( STREAM_SEEK_TO_BEGIN ); + + if( 0 != rGF.ImportGraphic( *pGraph, aEmptyStr, aOut )) + DELETEZ( pGraph ); + +// aOut.SwapOut(); + + return 0; +} + + +short SwW4WGraf::Read( long nTyp, long nWidth, long nHeight ) +{ + if( pGraph ) DELETEZ( pGraph ); + nStat = 0; + switch( nTyp ) { + case 0: { + if( CheckW4WVector() ) + { + return ReadW4WGrafVect( nTyp, nWidth, nHeight ); // Mastersoft internal Format Vector + } else + { + return ReadW4WGrafBMap( nTyp, nWidth, nHeight ); // Mastersoft internal Format Bitmap + } + } + default: + { + // erweitert um viele Formate (khz, April 1998) + return ReadGrafFile( nTyp, nWidth, nHeight ); + } + } +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4wpar1.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar1.cxx new file mode 100644 index 000000000000..9c6ccf75caf0 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar1.cxx @@ -0,0 +1,3760 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#include <hintids.hxx> + +#include <bf_svtools/zforlist.hxx> + +#include <bf_svx/paperinf.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_sfx2/docfile.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/shdditem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/pbinitem.hxx> +#include <bf_svx/brkitem.hxx> +#include <bf_svx/wghtitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/wrlmitem.hxx> +#include <bf_svx/udlnitem.hxx> +#include <bf_svx/postitem.hxx> +#include <bf_svx/escpitem.hxx> +#include <bf_svx/colritem.hxx> +#include <bf_svx/crsditem.hxx> +#include <bf_svx/lspcitem.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/cmapitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/cscoitem.hxx> +#include <bf_svx/tstpitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/fhgtitem.hxx> +#include <bf_svx/adjitem.hxx> +#include <unotools/charclass.hxx> +#include <unotools/localedatawrapper.hxx> +#include <bf_svx/unolingu.hxx> + +#include <fmthbsh.hxx> +#include <fmthdft.hxx> +#include <fmtfld.hxx> +#include <fmtfsize.hxx> +#include <fmtpdsc.hxx> +#include <frmatr.hxx> +#include <ftnidx.hxx> +#include <ftninfo.hxx> +#include <fmtftn.hxx> +#include <txtftn.hxx> +#include <pam.hxx> // fuer SwPam +#include <doc.hxx> +#include <shellio.hxx> // MAX_ASCII_PARA +#include <ndtxt.hxx> +#include <fldbas.hxx> +#include <paratr.hxx> +#include <fmtcol.hxx> +#include <pagedesc.hxx> +#include <docufld.hxx> +#include <poolfmt.hxx> // RES_POOLCOLL_STANDARD +#include <ndgrf.hxx> +#include <w4wstk.hxx> // fuer den Attribut Stack +#include <w4wpar.hxx> +#include <w4wflt.hxx> // fuer den W4W Parser +#include <fltini.hxx> +#include <swfltopt.hxx> +#include <flddat.hxx> // class SwDateTimeField +#include <swunohelper.hxx> + +#include <sal/macros.h> + +#include <swerror.h> +#include <mdiexp.hxx> // ...SetPercent() +#include <statstr.hrc> // ResId fuer Statusleiste +namespace binfilter { + +#define HOR_SICHER 100 // Horizontale Bereiche werden mindestens so + // gross gemacht ( z.B. Tab-Boxengroesse - LRSpace ) + +#define MOGEL_WW6 // Bei WW6 werden PGW und SFL ignoriert, da falsch + + +#define CHARBUF_SIZE (SAL_N_ELEMENTS( aCharBuffer )) + +// #define bInsertMode FALSE + + +inline const SwNodeIndex & PtNd( const SwPaM * pPam ) + { return pPam->GetPoint()->nNode; } +inline SwNodeIndex & PtNd( SwPaM* pPam ) + { return pPam->GetPoint()->nNode; } +inline const SwIndex & PtCnt( const SwPaM * pPam ) + { return pPam->GetPoint()->nContent; } +inline SwIndex & PtCnt( SwPaM* pPam ) + { return pPam->GetPoint()->nContent; } + +// ------------- allg. Funktionen -------------------- + +// Ermittle die Anzahl der Bits der Varaiablen "n". +// (Algorithmus kommt aus einer MAIL) + +static USHORT GetBitCnt( register ULONG n ) +{ + n = (n & 0x55555555) + ((n >> 1) & 0x55555555); + n = (n & 0x33333333) + ((n >> 2) & 0x33333333); + n = (n + (n >> 4)) & 0x0f0f0f0f; + n += n >> 8; + n += n >> 16; + return ( (USHORT)n & 0xff); +} + + +/*************************************************************************** +#* Prototypes +#**************************************************************************/ + +extern "C" { +#if defined(PM2) && defined(ZTC) + #define COMPRECORD_MODIFIER __CLIB +#elif defined( WNT ) && defined( _CRTAPI1 ) +// nur beim MSC von den NT Disks ist _CRTAPI1 definiert, nicht bei VC++ + #define COMPRECORD_MODIFIER _CRTAPI1 +#elif defined( WNT ) + #define COMPRECORD_MODIFIER __cdecl +#else + #define COMPRECORD_MODIFIER +#endif + + + int COMPRECORD_MODIFIER CompRecord( const void *pFirst, const void *pSecond) + { + return strncmp( (char*) &(((W4WRecord*)pSecond)->aRecType.c0) , + (char*) &(((W4WRecord*)pFirst)->aRecType.c0), 3 ); + } + // die Routine ist absichtlich "falsch" herum ( 'A' > 'Z' ) definiert, + // da sonst wg. Vorordnung der Quicksort laenger braucht + + #undef COMPRECORD_MODIFIER +} + +static BOOL bSortRecordTab = FALSE; +static W4WRecord aRecordTab[] = { + 'A', 'F', 'R', &SwW4WParser::Read_BeginFlushRight, + 'A', 'P', 'F', &SwW4WParser::Read_EndAbsPosObj, + 'A', 'P', 'O', &SwW4WParser::Read_BeginAbsPosObj, + 'B', 'B', 'T', &SwW4WParser::Read_BeginBold, + 'B', 'C', 'L', &SwW4WParser::Read_BeginColoredText, + 'B', 'C', 'M', &SwW4WParser::Read_BeginColumnMode, + 'B', 'C', 'O', &SwW4WParser::Read_BeginTabCell, + 'B', 'C', 'S', &SwW4WParser::Read_BeginSmallCaps, + 'B', 'C', 'U', &SwW4WParser::Read_BeginUpperCaps, + 'B', 'D', 'U', &SwW4WParser::Read_BeginDoubleUnderline, + 'B', 'H', 'P', &SwW4WParser::Read_BeginHyphen, + 'B', 'H', 'T', &SwW4WParser::Read_BeginHiddenText, + 'B', 'M', 'T', &SwW4WParser::Read_BeginMarkedText, + 'B', 'R', 'J', &SwW4WParser::Read_BeginRightJustify, + 'B', 'R', 'O', &SwW4WParser::Read_BeginTabRow, + 'B', 'S', 'O', &SwW4WParser::Read_BeginStrikeOut, + 'B', 'S', 'P', &SwW4WParser::Read_BeginShadow, + + 'B', 'T', 'F', &SwW4WParser::Read_BeginTextFlow, // FrameMaker + + 'B', 'U', 'L', &SwW4WParser::Read_BeginUnderline, + 'C', 'D', 'S', &SwW4WParser::Read_ColumnsDefinition, + 'C', 'M', 'T', &SwW4WParser::Read_CommentLine, + 'C', 'T', 'X', &SwW4WParser::Read_BeginCenterText, + 'D', 'I', 'D', &SwW4WParser::Read_DefineDocumentType, + 'D', 'T', 'B', &SwW4WParser::Read_Tab, + 'D', 'T', 'F', &SwW4WParser::Read_DateTime, + 'E', 'A', 'T', &SwW4WParser::Read_EndFlushRight, + 'E', 'B', 'S', &SwW4WParser::Read_EndSubScript, + 'E', 'B', 'T', &SwW4WParser::Read_EndBold, + 'E', 'C', 'L', &SwW4WParser::Read_EndColoredText, + 'E', 'C', 'M', &SwW4WParser::Read_EndColumnMode, + 'E', 'C', 'S', &SwW4WParser::Read_EndSmallCaps, + 'E', 'C', 'T', &SwW4WParser::Read_EndCenterText, + 'E', 'C', 'U', &SwW4WParser::Read_EndUpperCaps, + 'E', 'D', 'U', &SwW4WParser::Read_EndDoubleUnderline, + 'E', 'F', 'N', &SwW4WParser::Read_FootNoteEnd, + 'E', 'F', 'T', &SwW4WParser::Read_FootNoteEnd, + 'E', 'H', 'P', &SwW4WParser::Read_EndHyphen, + 'E', 'H', 'T', &SwW4WParser::Read_EndHiddenText, + 'E', 'K', 'R', &SwW4WParser::Read_EndKerning, + 'E', 'M', 'T', &SwW4WParser::Read_EndMarkedText, + 'E', 'P', 'N', &SwW4WParser::Read_EndOfParaNum, + 'E', 'P', 'S', &SwW4WParser::Read_EndSuperScript, + 'E', 'R', 'J', &SwW4WParser::Read_EndRightJustify, + 'E', 'S', 'O', &SwW4WParser::Read_EndStrikeOut, + 'E', 'S', 'P', &SwW4WParser::Read_EndShadow, + + 'E', 'T', 'F', &SwW4WParser::Read_EndTextFlow, // FrameMaker + + 'E', 'U', 'L', &SwW4WParser::Read_EndUnderline, + 'F', 'B', 'M', &SwW4WParser::Read_FooterBottomMargin, +// 'F', 'D', 'T', &SwW4WParser::Read_FontDefTable, // ueberfluessig + + 'F', 'L', 'O', &SwW4WParser::Read_Flow, // FrameMaker + + 'F', 'M', ' ', &SwW4WParser::Read_FooterMargin, + 'F', 'N', 'I', &SwW4WParser::Read_FootNoteInfo, + 'F', 'N', 'T', &SwW4WParser::Read_FootNoteStart1, + 'F', 'T', 'N', &SwW4WParser::Read_FootNoteStart2, + 'H', 'C', 'B', &SwW4WParser::Read_ColumnBreak, + 'H', 'E', 'X', &SwW4WParser::Read_Hex, + 'H', 'H', 'C', &SwW4WParser::Read_HardHyphen, + 'H', 'H', 'L', &SwW4WParser::Read_HardHyphen, + 'H', 'H', 'P', &SwW4WParser::Read_HardHyphen, + 'H', 'F', '1', &SwW4WParser::Read_FooterStart, + 'H', 'F', '2', &SwW4WParser::Read_HeaderStart, + 'H', 'F', 'X', &SwW4WParser::Read_HeadFootEnd, + + 'H', 'M', ' ', &SwW4WParser::Read_HeadingMargin, + 'H', 'T', 'M', &SwW4WParser::Read_HeaderTopMargin, + 'H', 'N', 'L', &SwW4WParser::Read_HardNewLine, + 'H', 'N', 'P', &SwW4WParser::Read_HardNewPage, + 'H', 'S', 'P', &SwW4WParser::Read_HardSpace, + + 'I', 'G', 'R', &SwW4WParser::Read_IncludeGraphic, + 'I', 'P', 'S', &SwW4WParser::Read_IndentPara, + 'I', 'T', 'F', &SwW4WParser::Read_EndItalic, + 'I', 'T', 'O', &SwW4WParser::Read_BeginItalic, + 'K', 'E', 'P', &SwW4WParser::Read_Split, + 'K', 'E', 'R', &SwW4WParser::Read_BeginKerning, + 'L', 'M', 'R', &SwW4WParser::Read_SetLeftMarginRelease, + 'N', 'B', 'R', &SwW4WParser::Read_NonBreakSpace, + 'N', 'L', 'N', &SwW4WParser::Read_NewLineInPara, + 'N', 'T', 'B', &SwW4WParser::Read_NewTabTable, + 'P', 'B', 'C', &SwW4WParser::Read_ParaBorder, + 'P', 'C', 'T', &SwW4WParser::Read_Picture, + 'P', 'D', 'S', &SwW4WParser::Read_PictureDef, + + 'P', 'D', 'T', &SwW4WParser::Read_PageDefinitionTable, // FrameMaker + + 'P', 'G', 'N', &SwW4WParser::Read_ParagraphNumber, + 'P', 'G', 'W', &SwW4WParser::Read_PageWidth, + 'P', 'L', 'N', &SwW4WParser::Read_PrintLastPageNo, + 'P', 'N', 'D', &SwW4WParser::Read_ParaNumberDef, + 'P', 'O', 'R', &SwW4WParser::Read_PageOrient, + 'P', 'P', 'N', &SwW4WParser::Read_PrintPageNo, + + 'R', 'D', 'T', &SwW4WParser::Read_RectangleDefinitionTable,// FrameMaker + + 'R', 'M', 'I', &SwW4WParser::Read_SetRightMarginIndent, + 'R', 'S', 'M', &SwW4WParser::Read_ReSetLeftRightMargin, + 'R', 'S', 'P', &SwW4WParser::Read_ReSetLineSpacing, + 'R', 'U', 'L', &SwW4WParser::Read_Ruler, + 'S', 'A', 'F', &SwW4WParser::Read_SetSpaceAfter, + 'S', 'B', 'O', &SwW4WParser::Read_StyleBasedOn, + 'S', 'B', 'F', &SwW4WParser::Read_SetSpaceBefore, + 'S', 'B', 'P', &SwW4WParser::Read_SetBottomMarginOfPage, + 'S', 'B', 'S', &SwW4WParser::Read_BeginSubScript, + 'S', 'C', 'B', &SwW4WParser::Read_ColumnBreak, + 'S', 'E', 'P', &SwW4WParser::Read_Separator, + 'S', 'F', 'B', &SwW4WParser::Read_SetTray, //!!! konnte noch nicht getestet + // werden, da W4W den Befehl anscheinend + // vergisst. + 'S', 'F', 'L', &SwW4WParser::Read_SetFormLenght, + 'S', 'H', 'C', &SwW4WParser::Read_SoftHyphen, + 'S', 'H', 'L', &SwW4WParser::Read_SoftHyphen, + 'S', 'H', 'P', &SwW4WParser::Read_SoftHyphen, + 'S', 'L', 'G', &SwW4WParser::Read_LangGroup, + 'S', 'N', 'L', &SwW4WParser::Read_SoftNewLine, + 'S', 'N', 'P', &SwW4WParser::Read_SoftNewPage, + 'S', 'P', 'F', &SwW4WParser::Read_SetPitchAndOrFont, + 'S', 'P', 'N', &SwW4WParser::Read_SetPageNumber, + 'S', 'P', 'S', &SwW4WParser::Read_BeginSuperScript, + 'S', 'T', 'E', &SwW4WParser::Read_StyleEnd, + 'S', 'T', 'F', &SwW4WParser::Read_StyleOff, + 'S', 'T', 'M', &SwW4WParser::Read_SetTempLeftRightMargin, + 'S', 'T', 'P', &SwW4WParser::Read_SetTopMarginOfPage, + 'S', 'U', 'M', &SwW4WParser::Read_SetUnderlineMode, + 'S', 'T', 'Y', &SwW4WParser::Read_StyleOn, + 'S', 'Y', 'T', &SwW4WParser::Read_StyleTable, + 'T', 'A', 'B', &SwW4WParser::Read_Tab, + + 'T', 'R', 'I', &SwW4WParser::Read_TextRectangelId, // FrameMaker + + 'U', 'C', 'S', &SwW4WParser::Read_UpperCharSet, + 'W', 'O', 'N', &SwW4WParser::Read_WidowOrphOn, + 'W', 'O', 'Y', &SwW4WParser::Read_WidowOrphOff, + 'X', 'C', 'S', &SwW4WParser::Read_ExtendCharSet +}; + + +void SwW4WParser::FlushChar( sal_Unicode c ) +{ + if( bReadTxtIntoString ) + *pReadTxtString += c; + else + { + aCharBuffer[ nChrCnt++ ] = c; + if( nChrCnt >= CHARBUF_SIZE ) + Flush(); + } +} + + +void SwW4WParser::ActivateTxtFlags() +{ + if( !bHeadFootDef && !bStyleDef ) + bPageDefRdy + = bIsTxtInDoc + = bIsTxtInFNote + = bIsTxtInPgDesc + = bWasTxtSinceLastHF2 + = bWasTxtSinceLastHF1 + = bWasTxtSince_BREAK_PAGE + = TRUE; +} + + +void SwW4WParser::DoSplit() +{ + /* + Beachten: die Nummerierung des alten Absatzes + muss erhalten bleiben... + */ + SwTxtNode* pTxtNd = pCurPaM->GetNode()->GetTxtNode(); + pDoc->SplitNode( *pCurPaM->GetPoint() ); + + if( pTxtNd->GetNum() ) + { + SwNodeIndex aIdx( *pTxtNd, -1 ); + if( aIdx.GetNode().IsTxtNode() ) + aIdx.GetNode().GetTxtNode()->UpdateNum( *pTxtNd->GetNum() ); + pTxtNd->ResetAttr( RES_PARATR_NUMRULE ); + pTxtNd->UpdateNum( SwNodeNum( NO_NUMBERING )); + } + + nParaLen = 0; + bIsIpsInPara = FALSE; // Neuer Absatz -> neue Zaehlung + bIsTxtInPara = FALSE; + bIsSTMInPara = FALSE; + bIsNumListPara = FALSE; +} + +// Funktion fuer Vorgangs-Anzeige: Hier und in shellio.cxx das Verhaeltnis der +// Wandeldauer MASO zu uns justieren + +void SwW4WParser::UpdatePercent( ULONG nPos, ULONG nFileSize ) +{ + ::binfilter::SetProgressState( 38 + nPos * 62 / nFileSize, pDoc->GetDocShell() ); +} + + + // RSP wird bei vorherigem IPS nicht gebraucht, da redundant + // bei WP ist es aber noetig + +void SwW4WParser::Read_ReSetLineSpacing() // (RSP) +{ + long nOld, nNew, nOptNewTw; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_LINESPACING ); + return; + } + + if( GetDecimal( nOld ) && !nError && GetDecimal( nNew ) && !nError ){ + if( W4WR_TXTERM != GetDecimal( nOptNewTw ) || nError ) + nOptNewTw = nNew * 120; // in half Lines + + BOOL bStd = FALSE; + SvxLineSpacingItem aLSpc; + + if ( nOptNewTw % 120 == 0 ){ + bStd = TRUE; + switch ( nOptNewTw ){ + case 240: // 1-Zeilig + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; + break; + + case 360: // 1.5-Zeilig + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.SetPropLineSpace( 150 ); + break; + case 480: // 2-Zeilig + aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; + aLSpc.SetPropLineSpace( 200 ); + break; + default: // Krumme Werte + bStd = FALSE; + break; + } + } + if ( !bStd ){ // krumme Werte als Minimum uebernehmen + aLSpc.SetLineHeight( (USHORT)nOptNewTw ); + aLSpc.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; + } + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_LINESPACING ); + if ( nOptNewTw != 240 ) // Wert 240 wird zu Ausschalten benutzt + SetAttr( aLSpc ); + } +} + + +void SwW4WParser::Read_SetRightMarginIndent() // (RMI) +{ + if( bStyleOnOff ) + { // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_LR_SPACE ); + } + else + if( !bIsIpsInPara ) + { + + long nSpaces, nOptRelRightTw; + short nRight; + + if( W4WR_TXTERM != GetDecimal( nSpaces ) || nError ) + return; + + // gibt es die optionale Angabe ? + if( W4WR_TXTERM == GetDecimal( nOptRelRightTw ) && !nError ) + nRight = (USHORT) nOptRelRightTw; // evtl. UEberlauf ist beabsichtigt, + // da bei W4W neg. Zahlen um 65536 + // erhoeht dargestellt werden + else + nRight = (USHORT)nSpaces*nColSize; // in 1/10 Inch + + if( 0 <= nRight ) + { + if( bIsColMode && pTabDefs ) + { // Tabelle + long nBoxSize = pTabDefs[nTabCol].nRightTw + - pTabDefs[nTabCol].nLeftTw; + if( nRight + HOR_SICHER > nBoxSize / 2 ) + nRight = 0; // Stuss-Werte -> keine Einrueckung + } + SvxLRSpaceItem aLR( *(SvxLRSpaceItem*) + pCtrlStck->GetFmtAttr( *pCurPaM, RES_LR_SPACE )); + + aLR.SetRight( nRight ); + SetAttr( aLR ); + } + } + /* + Achtung: nach RMI sollte immer RSM folgen; ist zu ueberspringen + */ + BOOL bOldNoExec = bNoExec; + BOOL bOldTxtInDoc = bTxtInDoc; + bNoExec = TRUE; + bTxtInDoc = FALSE; + ULONG nOldPos = rInp.Tell(); // FilePos merken + SkipEndRecord(); + GetNextRecord(); + if( pActW4WRecord + && ( pActW4WRecord->fnReadRec + != &SwW4WParser::Read_ReSetLeftRightMargin ) ) + { + rInp.Seek( nOldPos ); // FilePos restaurieren + } + bNoExec = bOldNoExec; + bTxtInDoc = bOldTxtInDoc; + nChrCnt = 0; + aCharBuffer[ nChrCnt ] = 0; +} + + +void SwW4WParser::Read_BeginSmallCaps() // (BCS) +{ + if( !bStyleOnOff ) + SetAttr( SvxCaseMapItem( SVX_CASEMAP_KAPITAELCHEN ) ); +} + + +void SwW4WParser::Read_EndSmallCaps() // (ECS) +{ + if( !bStyleOnOff ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_CASEMAP ); +} + + +void SwW4WParser::Read_BeginUpperCaps() // (BCU) +{ + if( !bStyleOnOff ) + SetAttr( SvxCaseMapItem( SVX_CASEMAP_VERSALIEN ) ); +} + + +void SwW4WParser::Read_EndUpperCaps() // (ECU) +{ + if( !bStyleOnOff ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_CASEMAP ); +} + + +void SwW4WParser::Read_PageOrient() // (POR) +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + long nOrient; + + if( W4WR_TXTERM != GetDecimal( nOrient ) || nError ) + return; + + if( bIsTxtInPgDesc && nDocType != 15 ) // -> neues SLay mit SeitenEnde falls noetig + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + pPageDesc->SetLandscape( nOrient != 0 ); +} + + //!!! noch nicht getestet (W4W-Fehler) + + +void SwW4WParser::Read_SetTray() // (SFB) +{ + long nOldTray, nTray; // evtl noch neuen PageDesc anlegen + + if( bStyleDef ) return; + + if( GetDecimal( nOldTray ) && !nError + && W4WR_TXTERM != GetDecimal( nTray ) || nError ) + return; + + pPageDesc->GetMaster().SetAttr( SvxPaperBinItem( RES_PAPER_BIN, (BYTE)nTray)); +} + + +void SwW4WParser::Read_SoftHyphen() // (SHC, SHL, SHP) +{ + pDoc->Insert( *pCurPaM, CHAR_SOFTHYPHEN ); +} + + +void SwW4WParser::Read_HardHyphen() // (HHC, HHL, HHP) +{ + FlushChar('-'); // Bitte _so_ stehen lassen, + // Zeichen wird in Read_SoftNewLine() abgefragt! +} + + +// ----------------------------- +SV_DECL_PTRARR_SORT( W4WStyleIdTab, W4WStyleIdTabEntryPtr, 0, 4 ) + +SwW4WParser::SwW4WParser( const SwPaM & rPaM, SvStream& rIstream, + BOOL bNewDoc, USHORT nFilterNo, const String& rVers ) + : pCurPaM( (SwPaM*)&rPaM ), bNew( bNewDoc ), rVersion( rVers ), + rInp( rIstream ) +{ + pDoc = rPaM.GetDoc(); + rInp.Seek( STREAM_SEEK_TO_END ); + rInp.ResetError(); // Sehe nach, wie gross die + nW4WFileSize = rInp.Tell(); // W4W-Datei ist + if( !nW4WFileSize ) + { + ASSERT( !this, "SvStream::seek doesn't work correct" ); + nW4WFileSize = 1; + } + rInp.Seek( STREAM_SEEK_TO_BEGIN ); + rInp.ResetError(); + + if( !bSortRecordTab ) + { + qsort( (void*)aRecordTab, + sizeof( aRecordTab ) / sizeof (W4WRecord), + sizeof( W4WRecord ), + CompRecord ); + bSortRecordTab = TRUE; + } + nError = 0; // kein Fehler + pStyleTab = pStyleBaseTab = 0; + + { + USHORT nFltNo = nFilterNo; + const sal_Char* aNames[ 4 ] = { + 0, "W4W/W4W000", "W4W/W4WHD", "W4W/W4WFT" }; + sal_uInt32 aVal[ 4 ]; + + SwFilterOptions aOpt; + + sal_Char aFirst[]="W4W/W4W000"; + aNames[0]=aFirst; + + // set into the first name the filter number + sal_Char* pStr = aFirst; + pStr += 7; + *pStr++ = '0' + ( nFltNo / 100 ); nFltNo %= 100; + *pStr++ = '0' + ( nFltNo / 10 ); nFltNo %= 10; + *pStr++ = '0' + nFltNo; + + // first test if the node & content exist. If not, then we may not + // ask the configuration (produce assertions!) + pStr = aFirst; + pStr[ 3 ] = 0; + + if( aOpt.CheckNodeContentExist( pStr, pStr + 4 )) + { + pStr[ 3 ] = '/'; + aOpt.GetValues( 4, aNames, aVal ); + } + else + { + aOpt.GetValues( 3, aNames+1, aVal+1 ); + aVal[0] = 0; + } + + nIniFlags = aVal[ 0 ]; + if( !nIniFlags ) + nIniFlags = aVal[ 1 ]; + nIniHdSiz = aVal[ 2 ]; + nIniFtSiz = aVal[ 3 ]; + } + + // Frame-Erkennung und -Umwandlung vorlaeufig deaktiviert + // wegen Zeitueberschreitung. + // + // noch bestehende Probleme: + // + // - Content im W4W Zwischencode erscheint in Reihelfonge der FLOws, + // nicht in Reihenfolge der Seiten, d.h. Inhalt eines Frame auf S.1 + // kommt womoeglich erst nach Inhalt der Seite 7 usw... + // + // - ... ? + // + nIniFMFlags = W4WFL_FM_neverFrames; +} + + +BOOL SwW4WParser::CallParser() +{ + pCtrlStck = new W4WCtrlStack( *this ); + pActFlySection = 0; + + nError = 0; // kein Fehler + nChrCnt = 0; // Counter fuer den Buffer + nTabCols = nTabRows = nTabRow = nTabCol = 0; + nTabDeltaSpace = 0; + nAktPgDesc = W4W_INVALID; // kein gueltiges Seitenlayout + nAktStyleId = nTabStyleId = nNoNameStylesCount = 0; + nApoBorderCode = 0; + nDocType = 0; + nParaLen = 0; + nGrafPDSType = 0; + nRecNo = 0; + nGrWidthTw = 0; + nGrHeightTw = 0; + nRSMLeft = 0; + nRSMRight = lA4Width; + nRSMwpwParaLeft = 0; + nRSMwpwParaRight = 0; + nLeftMgnCorr = 0; + nLastValueSTP = nLastValueSBP = nLastValueHTM = + nLastValueHM = nLastValueFBM = nLastValueFM = 0; + nNewValueSTP = nNewValueSBP = nNewValueHTM = + nNewValueHM = nNewValueFBM = nNewValueFM = 0; + nPDType = nHdFtType = 0; + nTablInTablDepth = 0; + nStartOfActRecord = 0; + + bSetPgWidth = bSetPgHeight = bPDTanalyzed + = bStyleDef = bStyleEndRec = bStyleOn = bStyleOnOff + = bPageDefRdy = bStyleOff = bHeadFootDef = bFootnoteDef = bNoExec + = bBCMStep1 = bBCMStep2 = FALSE; + + bSepar = bIsTxtInPgDesc = bIsTxtInFNote + = bWasTxtSinceLastHF2 = bWasTxtSinceLastHF1 + = bIsTxtInDoc = bIsTxtInPara = bIsSTMInPara = bIsNumListPara + = bWasTxtSince_BREAK_PAGE + = bWasHNPInPgDesc = bEndNoteInfoAlreadySet + = bFtnInfoAlreadySet = FALSE; + + bIsNLN = bDefFontSet = bIsColMode = bWasCellAfterCBreak = + bIsSTYInTab = bIsColDefTab = bPic = bPicPossible = + bIsIpsInPara = bToxOpen = bPersAlign = FALSE; + + bPgMgnChanged = bWasXCS = bWasSLG = bIgnoreNTB = + bWWWasRSM = bIsTab = bWPWWasRSM = bSingleParaMgn = + bCheckTabAppendMode = bIsTabAppendMode = + bWasPGNAfterPND = FALSE; + + bFootNoteNumberAutomatic = bEndNoteNumberAutomatic = TRUE; + bWasFootNoteOnW4WPage = bReadTxtIntoString + = bNixNoughtNothingExec = FALSE; + eFootNotePageRestart = VALUE_UNKNOWN; + + bTxtInDoc = TRUE; + + pPageDesc = pLastActPageDesc = + pOpen1stPgPageDesc = pPageDescForNextHNP = 0; + + nLastReadFootNo = nLastReadEndNo = USHRT_MAX; + + nFootNoOverflow = nEndNoOverflow = 0; + + pTabDefs = 0; + pTabBorders = 0; + pMergeGroups = 0; + + pPDTInfos = 0; + pRDTInfos = 0; + pFLOInfos = 0; + pActRectInfo = 0; + pPDTInfo = 0; + + pBehindSection=0; + + pActNumRule = 0; + pActW4WRecord = 0; + aLastRecType.Reset(); + + nUnderlineMode = 2; + + pGraf = 0; + pGraphic = 0; + nFtnType = -1; + nPgLeft = 0; + nPgRightDelta = 0; + nPgRight = 10440; + nPgWidth = lA4Width; + nColSize = 144; + nDefLanguage = 1031; // besser: Default-Language + +// ((const SwFmtLanguage&)pDoc->GetDefault( RES_CHRATR_LANGUAGE )).nLanguage; + + USHORT nPageDescOffset = pDoc->GetPageDescCnt(); + + SwNodeIndex aSttNdIdx( pDoc->GetNodes() ); + SwRelNumRuleSpaces aRelNumRule( *pDoc, bNew ); + + // eigener Page-Descriptor + CreatePageDesc( (bNew ? CRPGD_AND_INSERT : 0) + | CRPGD_REMOVE_HD + | CRPGD_REMOVE_FT ); + + /* + Hauptschleife des Parser + ************************ + ************************ + */ + int nRet = 0; + + while( ( EOF != nRet ) && !nError ) + nRet = GetNextRecord(); + + + + if( pCtrlStck ) + DeleteZStk( pCtrlStck ); + + if( pStyleTab ) + { + pStyleTab->DeleteAndDestroy( 0, pStyleTab->Count() ); + DELETEZ( pStyleTab ); + } + + if( pStyleBaseTab ) + pStyleBaseTab->DeleteAndDestroy( 0, pStyleBaseTab->Count() ); + + // Pagedescriptoren am Dokument updaten (nur so werden auch die + // linken Seiten usw. eingestellt). + + for (USHORT i=nPageDescOffset; i < pDoc->GetPageDescCnt(); i++ ) + { + //!!!! +// const SwFmtFooter &rBla = pDoc->GetPageDesc( i ).GetLeft().GetFooter(); +// const SwFmtFooter &rBla2 = pDoc->GetPageDesc( i ).GetMaster().GetFooter(); + pDoc->ChgPageDesc( i, pDoc->GetPageDesc( i ) ); + } + + + DELETEZ( pTabDefs ); // nur noetig, wenn ECM fehlt + DELETEZ( pBehindSection ); // dito. + + + // ggfs. FrameMaker Daten abraeumen + if( pPDTInfos ) + { + if( pPDTInfos->Count() ) + { + for( USHORT n = pPDTInfos->Count(); 0 < n; ) + { + --n; // Decrement IN der Schleife !! + + W4WPDTInfo& rInfo = *pPDTInfos->GetObject( n ); + + if((USHRT_MAX != rInfo.nSwPdId) && !rInfo.bSwPdUsed ) + {// ^^^^^^^^^^^^^ NIE PageDesc NULL loeschen! + pDoc->DelPageDesc( rInfo.nSwPdId ); + } + } + } + DELETEZ( pPDTInfos ); + } + if( pRDTInfos ) + { + for(W4WRectInfo* p = pRDTInfos->First(); p; p = pRDTInfos->Next()) + delete p; + DELETEZ( pRDTInfos ); + } + if( pFLOInfos ) + { + /* + for( USHORT n = 0; n < pFLOInfos->Count(); ++n ) + { + W4WFLOInfo& rInfo = *pFLOInfos->GetObject( n ); + if( !rInfo.bFlowUsed ) + { + // was machen wir im Falle eines unbenutzten Flow ?? + } + } + */ + DELETEZ( pFLOInfos ); + } + + + /* + ggfs. Fuss- und/oder Endnoten auf automatische Zaehlung schalten + */ + if( ( (USHRT_MAX != nLastReadFootNo) && bFootNoteNumberAutomatic ) + || ( (USHRT_MAX != nLastReadEndNo ) && bEndNoteNumberAutomatic ) ) + { + SwFtnIdxs& rFtnIdxs = pDoc->GetFtnIdxs(); + for( USHORT n = 0; n < rFtnIdxs.Count(); ++n ) + { + SwTxtFtn& rFtn = *rFtnIdxs[ n ]; + if( rFtn.GetFtn().IsEndNote() ? bEndNoteNumberAutomatic + : bFootNoteNumberAutomatic ) + { + rFtn.SetNumber( 0, 0 ); + } + } + + /* + ggfs. noch die Fuss-Noten auf Neuanfang je Seite schalten + */ + if( VALUE_TRUE == eFootNotePageRestart ) + { + SwFtnInfo aInfo( pDoc->GetFtnInfo() ); + aInfo.eNum = FTNNUM_PAGE; + pDoc->SetFtnInfo( aInfo ); + } + + rFtnIdxs.UpdateAllFtn(); + } + + // NumRules koennen erst nach dem setzen aller Attribute korrgiert werden + aRelNumRule.SetNumRelSpaces( *pDoc ); + if( !bNew && aSttNdIdx.GetIndex() ) + { + aSttNdIdx++; + aRelNumRule.SetOultineRelSpaces( aSttNdIdx, + pCurPaM->GetPoint()->nNode ); + } + +// return EOF == nRet && !nError; + + + return 1; // lese ein, auch wenn Error +} + + +void SwW4WParser::DeleteZStk( W4WCtrlStack*& rpStk ) +{ + Flush(); + ASSERT(rpStk, "W4W-ControlStack bereits geloescht"); + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->SetAttr( rPos, 0, FALSE ); + pCtrlStck->SetAttr( rPos, 0, FALSE ); + delete rpStk; + rpStk = 0; +} + + +int SwW4WParser::GetNextRecord() // Typ muss int sein, damit Vergleich mit EOF geht +{ + register unsigned int c; + BOOL bBegIcf = FALSE; + +#if OSL_DEBUG_LEVEL > 1 + if( bTxtInDoc && !bNoExec || bStyleDef ) + nRecNo++; +#endif + + while( !nError ) + { + if( 0 == ( c = ReadChar()) ) + break; + + if( W4WR_BEGICF == c ) + { + if( bBegIcf ) + { + nError = ERR_RECORD; // 2 mal BEGICF ?? + return nError; + } + bBegIcf = TRUE; + continue; + } + + if( W4WR_LED == c ) // Record-Anfang + { + if( !bBegIcf ) + { + nError = ERR_RECORD; // LED ohne vorheriges BEGICF ?? + return nError; + } + + // ok, es wurde ein Record Anfang erkannt + nStartOfActRecord = rInp.Tell() - 1; + + // speicher erstmal den Puffer im Dokument + if( bTxtInDoc ) + Flush(); + + // lies die Record-Kennung + W4WRecord aTmpRec; + rInp.Read( (sal_Char*) &(aTmpRec.aRecType.c0), 3 ); + + if( rInp.IsEof() ) + { + nError = ERR_RECORD; + return EOF; + } + +// NOTE4( "<<%c%c%c>>", aTmpRec.aRecType.c0, aTmpRec.aRecType.c1, +// aTmpRec.aRecType.c2 ); + + // dann suche nach der Methode fuer den Record + pActW4WRecord = 0; + if( 0 != ( pActW4WRecord = (W4WRecord*)bsearch( (char *) &aTmpRec, + (char *) aRecordTab, + sizeof( aRecordTab ) / sizeof( W4WRecord ), + sizeof( W4WRecord ), + CompRecord ) )) + { + if( bNixNoughtNothingExec ) + { + nStreamPosInRec = rInp.Tell(); + } + else + { + if( bNoExec ) + { + // Modus: Suche nach Ende des Headers/Footers/Tabelle + if ( ((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_HeadFootEnd) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_FootNoteEnd) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_BeginTabRow) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_BeginTabCell) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_EndColumnMode) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_ColumnsDefinition) + ||((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_BeginColumnMode ) + ) + { + (this->*pActW4WRecord->fnReadRec)(); // Ignoriere alles Andere + } + } + else if (bStyleDef && bSepar) + { // Modus: Styledef. Aussschaltsequenz + if ((pActW4WRecord->fnReadRec)==&SwW4WParser::Read_Separator) + Read_HeadFootEnd(); // Ignoriere alles Andere + } + else + { // normaler Modus + (this->*pActW4WRecord->fnReadRec)(); + } + } + // im Stream 1 Position zurueck und dann alles ueberlies + // bis zum Ende des Records + + rInp.SeekRel( -1 ); + } + SkipEndRecord(); + if( !aTmpRec.aRecType.IsEqual( RTL_CONSTASCII_STRINGPARAM("BCM" )) + || !aLastRecType.IsEqual( RTL_CONSTASCII_STRINGPARAM("ECM" ))) + aLastRecType = aTmpRec.aRecType; + } + bBegIcf = FALSE; + if ( c >= 32 && bWasXCS ){ // naechsten Buchstaben / UCF / HEX + bWasXCS = FALSE; // nach einem XCS ueberlesen + continue; + } + if( c >= 0x20 && c < 0xff ) // Zeichen ueber 0x7f kommen in Namen + // innerhalb von Befehlen (z.B. BMT) vor + // 0xff bringt Bernd ins Schleudern + FlushChar( c ); + else + return (BYTE)c; // ein unbekanntes Zeichen + // nError = ERR_CHAR; // was soll damit geschehen ?? + } + return rInp.IsEof() ? EOF : nError; +} + + +// SkipParaX ueberliest einen Parameter. Der Stream darf hinter dem BEGICF +// stehen. SkipParaX aehnelt SkipPara, laesst sich aber durch geschachtelte +// ICFs nicht verarschen. + +BYTE SwW4WParser::SkipParaX() +{ + register unsigned int c; + register unsigned int nRecurs = 0; + + while( TRUE ) + { + if ( ( c = ReadChar() ) == 0 ) // eof ergibt 0-Wert als Rueckgabe + { // eof oder ungueltigiges Zeichen + nError = ERR_CHAR; + return 0; + } + if ( W4WR_TXTERM == c && !nRecurs ) + break; // fertig + + if ( W4WR_RED == c ) // z.B. fuer codierte Umlaute (XCS/UCS) + nRecurs--; + else if( W4WR_LED == c ) + nRecurs++; + } + return (BYTE)c; +} + +BYTE SwW4WParser::GetChar( BYTE& rHexVal ) +{ + register unsigned int c; + register unsigned int c2; + rHexVal = 0; // Default fuer Error + + if( ( c = ReadChar() ) == 0 ){ // eof oder Mist im File + nError = ERR_CHAR; + return 0; + } + if( W4WR_RED == c || W4WR_TXTERM == c ){ + return (BYTE)c; + } + if( W4WR_BEGICF == c ) + SkipParaX(); // ignoriere mit XCS/UCS codierte Zeichen + //!! nicht ganz schoen + + if( ( c2 = ReadChar() ) == 0 ) // lese schon naechstes Zeichen + nError = ERR_CHAR; // sollte nur TXTERM / RED sein ! + rHexVal = (BYTE)c; + return (BYTE)c2; +} + + +BOOL SwW4WParser::GetString( String& rString, const int nEndCode1, const int nEndCode2 ) +{ + nChrCnt = 0; + int nGetCode = GetNextRecord(); + BOOL bOk = ( !nError ) + && ( ( nEndCode1 == nGetCode ) + || ( nEndCode2 == nGetCode ) ); + if( bOk && nChrCnt ) + { + aCharBuffer[ nChrCnt ] = 0; + rString = aCharBuffer; + } + else + rString = aEmptyStr; + nChrCnt = 0; + aCharBuffer[ nChrCnt ] = 0; + return bOk; +} + + + // returnt W4WR_RED/W4WR_TXTERM + // in rByteVal steht der als erste Ziffer gelesene BYTE-Wert + +BYTE SwW4WParser::GetDeciByte( BYTE& rByteVal ) +{ + register BYTE n; + register BOOL Ok = FALSE; + BYTE nCode; + + while( this ) + { + n = ReadChar(); + if ( '0' > n || '9' < n ) // eof durch 0 abgedeckt + break; + if( !Ok ) + { + nCode = (n - '0'); + Ok = TRUE; + } + } + if( n == 0 ) + nError = ERR_CHAR; + + if( Ok && ( n == W4WR_TXTERM ) ) + { // ordentlich abgeschlossene Eingabe, + // dann abspeichern, sonst rByteVal unveraendert + rByteVal = nCode; + } + return n; +} + + + // GetHexByte returnt W4WR_RED/W4WR_TXTERM wenn einstellige HexZahl, sonst 0 + // in rHexVal steht gewandelter HexCharakter + +BYTE SwW4WParser::GetHexByte( BYTE& rHexVal ) +{ + register unsigned int c1 = 0; // shorts sind schneller als char (WIN) + register unsigned int c2 = 0; + register unsigned int nRet; + + rHexVal = 0; + + c1 = ReadChar(); // eof liefert 0 zurueck + if ( c1 == 0 ){ // falsches Zeichen oder eof + nError = ERR_CHAR; + return 0; + } + if( W4WR_RED == c1 || W4WR_TXTERM == c1 ){ + return (BYTE)c1; + } + c2 = ReadChar(); + if ( c2 == 0 ){ // falsches Zeichen oder eof + nError = ERR_CHAR; + return (BYTE)c2; + } + + // Hi-Byte + if( c1 >= '0' && c1 <= '9' ) nRet = (c1 - '0'); + else if( c1 >= 'A' && c1 <= 'F' ) nRet = (c1 - 'A' + 10); + else if( c1 >= 'a' && c1 <= 'f' ) nRet = (c1 - 'a' + 10); + + if( W4WR_RED == c2 || W4WR_TXTERM == c2 ){ + rHexVal = (BYTE)nRet; + return (BYTE)c2; + } + + nRet <<= 4; // *16 + + // Lo-Byte + if( c2 >= '0' && c2 <= '9' ) nRet |= (c2 - '0'); + else if( c2 >= 'A' && c2 <= 'F' ) nRet |= (c2 - 'A' + 10); + else if( c2 >= 'a' && c2 <= 'f' ) nRet |= (c2 - 'a' + 10); + + c2 = ReadChar(); // lese schon naechstes Zeichen + if( c2 == 0 ) // pInp->eof() + nError = ERR_CHAR; // sollte nur TXTERM / RED sein ! + + rHexVal = (BYTE)nRet; + return (BYTE)c2; +} + + // returnt W4WR_RED/W4WR_TXTERM wenn ordentliche HexZahl, sonst 0 + // in rHexVal steht gewandelter HexUShort + +BYTE SwW4WParser::GetHexUShort( USHORT& rHexVal ) +{ + register unsigned int c; + register unsigned int nVal = 0; + rHexVal = 0; // Default fuer Error + + for (int i=0; i<4; i++){ + + c = ReadChar(); + if( c == 0 ){ // eof oder Mist im File + nError = ERR_CHAR; + return 0; + } + if( W4WR_RED == c || W4WR_TXTERM == c ){ + return (BYTE)c; + } + + nVal <<= 4; + + if( c >= 'a' && c <= 'f' ) nVal += (c - 'a' + 10); + else if( c >= 'A' && c <= 'F' ) nVal += (c - 'A' + 10); + else if( c >= '0' && c <= '9' ) nVal += (c - '0'); + else { nError = ERR_CHAR; return (BYTE)c; } + } + c = ReadChar(); // lese schon naechstes Zeichen + if( c == 0 ) + nError = ERR_CHAR; // sollte nur TXTERM / RED sein ! + rHexVal = (USHORT)nVal; + return (BYTE)c; +} + + // returnt W4WR_RED/W4WR_TXTERM + // in rDecVal steht der gewandelte Decimal-Wert + +BYTE SwW4WParser::GetDecimal( long& rDecVal ) +{ + register unsigned int c; // schneller als BYTE (win) + register UINT16 uVal = 0; + + while( TRUE ){ + c = ReadChar(); + if ( '0' > c || '9' < c ) // eof durch 0 abgedeckt + break; + uVal = ( uVal * 10 ) + c - '0'; + } + if( c == 0 ) + nError = ERR_CHAR; + + if( c == W4WR_TXTERM ){ // ordentlich abgeschlossene Eingabe + // dann abspeichern + // sonst rDecVal unveraendert + + register INT16 iVal = uVal; // Werte > 32767 -> negativ + // ( wird in W4W so codiert ) + rDecVal = iVal; + } + return (BYTE)c; +} + + + // ueberliest alles bis zum W4WR_TXTERM oder W4WR_RED (wird returnt) + +BYTE SwW4WParser::SkipPara() +{ + register unsigned int c; + while( TRUE ){ + c = ReadChar(); + if ( W4WR_TXTERM == c || W4WR_RED == c || 0 == c ) // 0 == eof + break; + } + + if( c == 0 ) nError = ERR_CHAR; + return (BYTE)c; +} + // ueberliest alles bis zum W4WR_TXTERM oder W4WR_RED (wird returnt) + +BYTE SwW4WParser::SkipEndRecord() +{ + register unsigned int c; + register unsigned int nRecurs = 1; + + while( nRecurs ){ + c = ReadChar(); // eof ergibt 0-Wert als Rueckgabe + if ( c == 0 ){ // eof oder ungueltigiges Zeichen + nError = ERR_CHAR; + return 0; + } + if ( W4WR_RED == c ){ // z.B. fuer codierte Umlaute (XCS/UCS) + nRecurs--; + }else if( W4WR_LED == c ) { + nRecurs++; + } + } + return (BYTE)c; +} + +void SwW4WParser::Flush() +{ + nParaLen += nChrCnt; + aCharBuffer[ nChrCnt ] = 0; + + if( !nChrCnt ) + return; + + if( bTxtInDoc ) + { + bIsTxtInPara = TRUE; + ActivateTxtFlags(); + +// bIsNLN = FALSE; + if( bIsTxtInPgDesc ) + { + UpdatePageMarginSettings( CALLED_BY_FLUSH_OR_HNL ); + } + if ( nParaLen >= MAX_ASCII_PARA - CHARBUF_SIZE - 100 ) + { + sal_Unicode* pBuf = aCharBuffer; + for( ; 0 != *pBuf; ++pBuf ) + if( ' ' == *pBuf ) // suche ' ' + break; + sal_Unicode c = *pBuf; + *pBuf = 0; + if( bReadTxtIntoString ) + { + *pReadTxtString += aCharBuffer; + *pReadTxtString += '\n'; + } + else + { + pDoc->Insert( *pCurPaM, aCharBuffer, FALSE ); + pDoc->SplitNode( *pCurPaM->GetPoint() ); + } + nParaLen = 0; + *pBuf = c; + if( pBuf != aCharBuffer ) + { + if( bReadTxtIntoString ) + *pReadTxtString += pBuf; + else + pDoc->Insert( *pCurPaM, pBuf, FALSE ); + } + } + else + { + if( bReadTxtIntoString ) + *pReadTxtString += aCharBuffer; + else + pDoc->Insert( *pCurPaM, aCharBuffer, FALSE ); + } + } + else if( nChrCnt > CHARBUF_SIZE) + { + // das ist normalerweise ein Fehler !!! + nError = ERR_NAMETOLONG; + } + nChrCnt = 0; +} + + +void SwW4WParser::Read_UpperCharSet() // (UCS) +{ + // nach einem XCS folge meistens ein UCS / HEX oder ein normaler + // Buchstabe, der benutzt werden soll, wenn das XCS ignoriert wird. + // Deshalb muss das naechste USC / HEX / Buchstabe nach XCS + // ignoriert werden. ( Gespraech Karl Forster ) + if ( bWasXCS ) // naechsten Bucchstaben / UCF / HEX + { + bWasXCS = FALSE; // nach einem XCS ueberlesen + return; + } + BYTE c, cRet; + while( !nError && W4WR_RED != ( cRet = GetHexByte( c )) ) + if( cRet == W4WR_TXTERM ) + { + sal_Unicode cC = ByteString::ConvertToUnicode( c, + RTL_TEXTENCODING_IBM_437 ); + + FlushChar( cC ); // z.B. Umlaute + } + if( W4WR_RED != cRet ) + nError = ERR_CHAR; +} + + +void SwW4WParser::Read_ExtendCharSet() // (XCS) +{ + BYTE c; + long nValue; + if( W4WR_TXTERM == GetDecimal( nValue ) && !nError && + GetHexByte( c ) && !nError ) + { + rtl_TextEncoding eCodeSet = RTL_TEXTENCODING_MS_1252; + + if( nValue == 850 && c == 0xef ) //! Sonderbehandlung fuer Haeckchen + { // von WordPerfect + nValue = 819; + c = 180; // Macke W4W ?? + } + if ( !( nIniFlags & W4WFL_NO_WW_SPECCHAR ) + && ( nDocType == 44 || nDocType == 49 ) //! WW2: Hier stimmen die + && nValue == 9998 // Umlaute "A, "U, "s nicht + && ( c == 0xc4 || c == 0xdc || c == 0xdf )) + nValue = 819; // mache dann Umlaute aus Symbolen + + switch( nValue ) + { + case 9999: // Complete Mactintosh Char Set + eCodeSet = RTL_TEXTENCODING_APPLE_ROMAN; +#ifdef MAC + if ( nDocType == 1 && rVersion == "0" ) // Dos-Ascii + eCodeSet = RTL_TEXTENCODING_IBM_850; // Fehler im Dos-Filter + // umpopeln +#endif + break; + case 437: // Standard US PC code page + eCodeSet = RTL_TEXTENCODING_IBM_437; + break; + case 850: // Standard international PC code page + eCodeSet = RTL_TEXTENCODING_IBM_850; + break; + case 819: // ANSI code page + eCodeSet = ( 39 == nDocType && + rVersion.EqualsAscii( "0" )) // MS Works f. DOS + ? RTL_TEXTENCODING_IBM_850 + : RTL_TEXTENCODING_MS_1252; + break; + case 8591: // ISO 8859-1 + eCodeSet = RTL_TEXTENCODING_ISO_8859_1; + break; + case 8592: // ISO 8859-2 + eCodeSet = RTL_TEXTENCODING_ISO_8859_2; + break; + case 9998: // Windows Standard-Symbol-Charset + { + SvxFontItem aFont( FAMILY_DONTKNOW, String::CreateFromAscii( + RTL_CONSTASCII_STRINGPARAM( "Symbol" )), + aEmptyStr, PITCH_DONTKNOW, + RTL_TEXTENCODING_SYMBOL ); + Flush(); + SetAttr( aFont ); // neuer Font + FlushChar( c ); + Flush(); // Sonderzeichen + // Font wieder zurueck + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_FONT ); + bWasXCS = TRUE; + return; + } + } + + sal_Unicode cC = ByteString::ConvertToUnicode( c, eCodeSet ); + FlushChar( cC ); + + // folgt ein UCS-Record oder ein HEX-Record hinter einem XCS-Rec., + // dann ueberlies diesen. + // folgt ein Zeichen, dann ueberlese dieses + bWasXCS = TRUE; + } + else if( !nError ) + nError = ERR_CHAR; +} + + +void SwW4WParser::Read_Hex() // (HEX) +{ + if( !bWasXCS || nDocType == 15 ) + { + BYTE c; + if( !nError && GetHexByte( c ) && + 0x15 == c ) // Juristenparagraph + { + sal_Unicode cC = ByteString::ConvertToUnicode( '\xa7', + RTL_TEXTENCODING_MS_1252 ); + if( bReadTxtIntoString ) + *pReadTxtString += cC; + else + pDoc->Insert( *pCurPaM, cC ); + } + } + bWasXCS = FALSE; // HEX nach einem XCS ist hiermit ueberlesen +} + + +void SwW4WParser::Read_DefineDocumentType() // (DID) +{ + long nType; + + if( GetDecimal( nType ) && !nError ) + { + nDocType = (USHORT)nType; + if( nDocType == 15 && !( nIniFlags & W4WFL_NO_PCTEXT4_124 ) ) + nColSize = 124; + } +} + + +void SwW4WParser::Read_SoftNewLine() // (SNL) +{ + /* + was macht Read_SoftNewLine() ? + + Pruefen, ob links davon mindestens ein Dutzend Zeichen stehen + und das .<SNL> nach direkt hinter der Kombination + BUCHSTABE + KLEINBUCHSTABE + MINUS steht + und nach dem SNL mindestens zwei Kleinbuchstaben kommen. + + Ist dies der Fall, wird das Minus entfernt und das SNL durch + ein .<SHC> ersetzt, da wir annehmen, dass es sich um einen + weichen Trenner handelt, der von W4W bloss nicht gemeldet wurde. + + Ansonsten darf das SNL-Flag dennoch nicht ignoriert werden, da + sonst das vorige und das folgende Wort verschmelzen. + Stattdessen ist (lt. W4W-Handbuch) immer dann ein Space + einzufuegen, wenn vorher weder ein Space, noch ein Tab noch + ein Hyphen kam. + */ + xub_StrLen nDocPos = PtCnt( pCurPaM ).GetIndex(); + + if( nDocPos ) + { + BOOL bAllDone = FALSE; + const String& rTxt = pCurPaM->GetPoint()->nNode.GetNode(). + GetTxtNode()->GetTxt(); + sal_Unicode cLastChar = rTxt.GetChar( nDocPos-1 ); + + if( 11 < nDocPos ) + { + const CharClass& rCC = GetAppCharClass(); + sal_Int32 nChrType; + + if( '-' == cLastChar && + CharClass::isLetterType( + rCC.getCharacterType( rTxt, nDocPos-3 ) ) && + CharClass::isLetterType( nChrType = + rCC.getCharacterType( rTxt, nDocPos-2 ) ) && + 0 == ( ::com::sun::star::i18n::KCharacterType::UPPER & + nChrType )) + { + SwNodeIndex aNdIdx( PtNd( pCurPaM ), -1 ); + + SkipEndRecord(); + GetNextRecord(); + rInp.SeekRel( -1 ); // ein Zeichen zurueck + + if( aNdIdx.GetIndex()+1 == PtNd( pCurPaM ).GetIndex() ) + { + if( nChrCnt ) + nChrType = rCC.getCharacterType( + String( aCharBuffer ), 0 ); + else + nChrType = rCC.getCharacterType( rTxt, nDocPos ); + if( CharClass::isLetterType( nChrType ) && + 0 == ( ::com::sun::star::i18n::KCharacterType::UPPER & + nChrType )) + { + SwTxtNode* pNd = PtNd( pCurPaM ).GetNode().GetTxtNode(); + xub_StrLen nCnt = PtCnt( pCurPaM ).GetIndex(); + PtNd( pCurPaM ) = aNdIdx.GetIndex()+1; + PtCnt( pCurPaM ).Assign( + pCurPaM->GetCntntNode(), nDocPos-1 ); + + SvxFontItem* pFont = (SvxFontItem*)GetFmtAttr( RES_CHRATR_FONT ); + + if( ( !pFont ) + || ( RTL_TEXTENCODING_SYMBOL != pFont->GetCharSet() ) ) + { + /* + bereits eingefuegten Trennstrich loeschen und + weichen Trenner einfuegen + */ + pNd->Erase( PtCnt( pCurPaM ), 1 ); + pDoc->Insert( *pCurPaM, CHAR_SOFTHYPHEN ); + bAllDone = TRUE; + } + PtNd( pCurPaM ) = *pNd; + PtCnt( pCurPaM ).Assign( pCurPaM->GetCntntNode(), nCnt ); + } + } + } + } + if( ( !bAllDone ) + && ( ' ' != cLastChar ) + && ( '\t' != cLastChar ) + && ( '-' != cLastChar ) ) FlushChar( ' ' ); + } +} + + + +void SwW4WParser::Read_NonBreakSpace() // (NBR) +{ + pDoc->Insert( *pCurPaM, CHAR_HARDBLANK ); +} + + + +void SwW4WParser::Read_HardNewLine() // (HNL) +{ + UpdatePercent( rInp.Tell(), nW4WFileSize ); + + if( bCheckTabAppendMode ) + { + return; + } + + if( bIsNLN ) + { + bIsNLN = FALSE; + return; // Nach NLN folgt zu ignorierendes HNL + } + + BYTE c = ReadChar(); + + if( (0 == c) + || (EOF == c) ) + { + nError = ERR_CHAR; // falsches Zeichen oder EOF + return; + } + if( '1' == c ) // ignorieren, da Absatzabstaende interpretiert werden + return; + + bIsTxtInPara = FALSE; + + // Abfrage vorsichtshalber + if( ( bStyleOff || bTxtInDoc ) && !bStyleDef ) + { + /* nach Handbuch W4W schaltet HNL + * CTX - Centered Text mit aus + * BRJ - Blockfatz bleibt an !!! + */ + const SwPosition& rPos = *pCurPaM->GetPoint(); + if ( !bPersAlign ) + pCtrlStck->SetAttr( rPos, RES_PARATR_ADJUST ); + + pCtrlStck->SetAttr( rPos, RES_UL_SPACE ); //??? Temp. Margins auch ? + pCtrlStck->SetAttr( rPos, RES_PARATR_SPLIT ); +// pCtrlStck->SetAttr( pCurPaM, RES_PARATR_TABSTOP ); //??? Temp. Margins auch ? + // nicht ganz schoen, aber ich weiss nichts besseres +// pCtrlStck->SetAttr( pCurPaM, RES_CHRATR_FONT ); //??? Temp. Margins auch ? +// pCtrlStck->SetAttr( pCurPaM, RES_CHRATR_FONTSIZE ); //??? Temp. Margins auch ? + + + // ggfs. obere/unterer Raender setzen + UpdatePageMarginSettings( CALLED_BY_FLUSH_OR_HNL ); + + // Beende Definition von nur fuer diesen Node gueltigem Rand + if( bSingleParaMgn ) + pCtrlStck->SetAttr( rPos, RES_LR_SPACE ); + + /* + Jetzt neuen Node erzeugen: + */ + DoSplit(); + + // wenn RSM offen, setze Rand fuer neuen Absatz wieder genauso + if( bSingleParaMgn + && ( nRSMwpwParaLeft + || ( nRSMwpwParaRight + && ( nRSMwpwParaRight != nPgRight ) ) ) ) + { + Read_IndentPara1( nRSMwpwParaLeft, nRSMwpwParaLeft, + nRSMwpwParaRight ); + bSingleParaMgn = FALSE; + } + + if( bIsColMode && !bIsSTYInTab ) + { + // wenn kein Style hart gesetzt ist + // Override Style "Tabellenkopf", "Tabelleninhalt" + // mit vorher gueltigem Style + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->NewAttr( rPos, SwW4WStyle( nTabStyleId ) ); + pCtrlStck->SetAttr( rPos, RES_FLTR_STYLESHEET ); + } + ActivateTxtFlags(); + +// return; + + // zusaetzliche Massnahmen beim Style-Ausschalten + if( bStyleOff ) + { + SwCntntNode* pCNd = pCurPaM->GetCntntNode(); + nAktStyleId = 0; + if( pCNd->IsTxtNode() ) + { + SwTxtFmtColl* pAktColl = GetAktColl(); + if( !pAktColl ) + { +// pAktColl = (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl(); + pAktColl = pDoc->GetTxtCollFromPoolSimple + ( RES_POOLCOLL_STANDARD, FALSE ); + } + pDoc->SetTxtFmtColl( *pCurPaM, pAktColl, FALSE ); + } + else + { + // in den anderen Content-Nodes nur das Frame-Format setzen. + pCNd->ChgFmtColl( (SwGrfFmtColl*)pDoc->GetDfltGrfFmtColl() ); + } + bStyleOff = FALSE; + } + } +} + + +void SwW4WParser::Read_HardNewPage() // (HNP) +{ + if( bHeadFootDef // it's Nonsense to embedd PageBreaks into Header/Footer + || bFootnoteDef // (smart Winword *does* such nonsense) + || bCheckTabAppendMode ) + { + return; + } + + if( bStyleDef ) + { + pDoc->Insert( *pCurPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) ); + } + else + { + if( bIsTxtInPara ) // Pagebreak / PgDesc needs an *new* node + DoSplit(); + + if( pPageDescForNextHNP ) + { +// pDoc->Insert( *pCurPaM, SwFmtPageDesc( &pDoc->GetPageDesc( 3 ))); + pDoc->Insert( *pCurPaM, +// SwFmtPageDesc( &pDoc->GetPageDesc( nAktPgDesc ))); + SwFmtPageDesc( pPageDescForNextHNP )); + pPageDescForNextHNP = 0; + if ( bPgMgnChanged ) SetPageMgn(); + } + else + { + if ( bPgMgnChanged ) // Raender wurden geaendert + { // ( beim letzten RSM ) + if( bIsTxtInPgDesc ) + CreatePageDesc( CRPGD_AND_INSERT ); + SetPageMgn(); + } + if( bIsTxtInPgDesc + || bWasHNPInPgDesc ) + { // alter PgDesc mit Text oder mindestens 1 .<HNP> -> PageBreak + pDoc->Insert( *pCurPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) ); + bWasTxtSince_BREAK_PAGE = FALSE; + } + } + bWasHNPInPgDesc = TRUE; + bWasFootNoteOnW4WPage = FALSE; + } +} + + + + +void SwW4WParser::Read_SoftNewPage() // (SNP) +{ + if( !bStyleDef ) + { + bWasFootNoteOnW4WPage = FALSE; + } +} + + + +void SwW4WParser::Read_NewLineInPara() // (NLN) +{ + FlushChar( '\x0a' ); + bIsNLN = TRUE; +} + + +void SwW4WParser::Read_DateTime() // (DTF) +{ + BYTE nSep, nFormat; + String sDate, sTime, *pFirst = 0, *pLast = 0; + for( int n = 0; + n < 15 && + W4WR_TXTERM == GetHexByte( nFormat ) && !nError && nFormat && + W4WR_TXTERM == GetHexByte( nSep ) && !nError; ++n ) + { + const char* pDAdd = 0, *pTAdd = 0, *pAdd; + String* pStr; + switch( nFormat ) + { + case 0x30: pTAdd = "AM/PM"; break; + case 0x31: pDAdd = "TT"; break; + case 0x32: pDAdd = "MM"; break; + case 0x33: pDAdd = "MMMM"; break; + case 0x34: pDAdd = "JJJJ"; break; + case 0x35: pDAdd = "JJ"; break; + case 0x36: pDAdd = "NNNN"; break; + case 0x37: pTAdd = "HH"; break; + case 0x38: pTAdd = "HH"; break; + case 0x39: pTAdd = "MM"; break; + } + + if( 0 != ( pAdd = pTAdd )) + pStr = &sTime; + else if( 0 != ( pAdd = pDAdd )) + pStr = &sDate; + else + continue; + + if( !pFirst ) + pFirst = pStr; + else if( !pLast && pFirst != pStr ) + pLast = pStr; + pStr->AppendAscii( pAdd ); + if( nSep ) + *pStr += static_cast< char >(nSep); + } + + if( pFirst ) + { + // get Doc Numberformatter + SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter(); + +// ULONG nLang = ((SvxLanguageItem&)(pDoc->GetAttrPool(). +// GetDefaultItem( RES_CHRATR_LANGUAGE ))).GetValue(); + + // tell the Formatter about the new entry + UINT16 nCheckPos = 0; + INT16 nType = NUMBERFORMAT_DEFINED; + sal_uInt32 nKey; + + pFormatter->PutandConvertEntry( *pFirst, nCheckPos, nType, nKey, + LANGUAGE_GERMAN, + /*nLang*/LANGUAGE_SYSTEM ); + SwDateTimeField aFld( (SwDateTimeFieldType*) + pDoc->GetSysFldType( RES_DATETIMEFLD ), + &sTime == pFirst ? TIMEFLD : DATEFLD, nKey ); + pDoc->Insert( *pCurPaM, SwFmtFld( aFld ) ); + + if( pLast ) + { + nCheckPos = 0; + nType = NUMBERFORMAT_DEFINED; + + pFormatter->PutandConvertEntry( *pLast, nCheckPos, nType, nKey, + LANGUAGE_GERMAN, + /*nLang*/LANGUAGE_SYSTEM ); + SwDateTimeField aFld( (SwDateTimeFieldType*) + pDoc->GetSysFldType( RES_DATETIMEFLD ), + &sTime == pLast ? TIMEFLD : DATEFLD, nKey ); + pDoc->Insert( *pCurPaM, SwFmtFld( aFld ) ); + } + } +} + + +void SwW4WParser::Read_Tab() // (TAB), (DTB) +{ + if( bStyleOnOff ) + return; + + /* + ersten, fuehrenden TAB innerhalb einer Fussnote uebergehen + */ + if( bFootnoteDef && !bIsTxtInFNote ) + { + bIsTxtInFNote = TRUE; + return; + } + + long nValue; + + if( W4WR_TXTERM != GetDecimal( nValue ) || nError + || nValue == 0 ) // real Tab (no Filler) + { + FlushChar( '\t' ); + } +} + + + +void SwW4WParser::Read_HardSpace() // (HSP) +{ + // erstmal so, spaeter das entsprechende Attribute setzen + FlushChar( ' ' ); +} + + + +// -------- Methoden fuer die Attribut-Verarbeitung: ------------ + +// SwW4WParser::GetFmtAttr ist +// statt pCtrlStck->GetFmtAttr( *pCurPaM, RES_LR_SPACE )); zu benutzen, wenn +// das Attribut auch waehrend der Styledefinition wiedergefunden werden soll + +const SfxPoolItem* SwW4WParser::GetFmtAttr( USHORT nWhich ) +{ + if( bStyleDef ) + { + SwTxtFmtColl* pAktColl = GetAktColl(); + ASSERT( pAktColl, "StyleId ungueltig" ); + + return &pAktColl->GetAttr( nWhich ); + } + else + return pCtrlStck->GetFmtAttr( *pCurPaM, nWhich ); +} + +void SwW4WParser::SetAttr( const SfxPoolItem& rAttr ) +{ + if( bStyleDef ) + { + BOOL bSetAttr; + SwTxtFmtColl* pAktColl = GetAktColl( &bSetAttr ); + ASSERT( pAktColl, "StyleId ungueltig" ); + if( bSetAttr ) + pAktColl->SetAttr( rAttr ); + } + else + pCtrlStck->NewAttr( *pCurPaM->GetPoint(), rAttr ); +} + +// SetAttrOff setzt ein Attribut in den Attributstack. Ob ein Anfang oder +// ein Ende gemeint ist ( z.B. ITF ), wird daran zu erkennen versucht, +// ob noch ein angefangenes Attribut auf dem Stack haengt. +// +// Wenn Styledefinitionen passieren, ist diese Mimik ausgeschaltet: +// wenn bStyleOnOff TRUE ist, wird ein Attributende angenommen, +// d.h. das Attribut wird nicht gesetzt, da der Style das schon erledigt, +// es werden aber etwaige gleichartige harte Attribute beendet, um die +// Einstellungen im Style nicht gleich wieder per harter Attributierung +// ueberzumangeln. + +void SwW4WParser::SetAttrOff( const SfxPoolItem& rAttr ) +{ + if( bStyleOnOff ) + { + Read_HardAttrOff( rAttr.Which() ); + } + else if( bStyleDef ) + { + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), rAttr.Which() ); + } + else + { + const SwPosition& rPos = *pCurPaM->GetPoint(); + if( !pCtrlStck->SetAttr( rPos, rAttr.Which() ) ) + pCtrlStck->NewAttr( rPos, rAttr ); // Das Attribut gab's noch + // nicht auf den Stack, es muss wohl + // ein aktives Ausschalten gemeint sein + } +} + + +void SwW4WParser::Read_BeginBold() // (BBT) +{ + if( !bStyleOnOff ) + SetAttr( SvxWeightItem( WEIGHT_BOLD )); +} + + +void SwW4WParser::Read_EndBold() // (EBT) +{ + SetAttrOff( SvxWeightItem( WEIGHT_NORMAL )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_WEIGHT ); +} + + +void SwW4WParser::Read_SetUnderlineMode() // (SUM) +{ + long nOldSUM, nSUM; + + if( W4WR_TXTERM != GetDecimal( nOldSUM ) || + W4WR_TXTERM != GetDecimal( nSUM ) || + nError ) + return; + + nUnderlineMode = (BYTE)nSUM; // 0 = single Word + // 1 = double Word + // 2,3 = Continuous ( default ) +} + +void SwW4WParser::Read_BeginUnderline() // (BUL) +{ + if( !bStyleOnOff ) + { + SetAttr( SvxUnderlineItem( UNDERLINE_SINGLE )); + if ( nUnderlineMode < 2 ) + SetAttr( SvxWordLineModeItem( TRUE )); + } +} + + +void SwW4WParser::Read_EndUnderline() // (EUL) +{ + SetAttrOff( SvxUnderlineItem( UNDERLINE_NONE )); + SetAttrOff( SvxWordLineModeItem( FALSE )); +} + + +void SwW4WParser::Read_BeginDoubleUnderline() // (BDU) +{ + if( !bStyleOnOff ){ + SetAttr( SvxUnderlineItem( UNDERLINE_DOUBLE )); + if ( nUnderlineMode < 2 ) + SetAttr( SvxWordLineModeItem( TRUE )); + } +} + + +void SwW4WParser::Read_EndDoubleUnderline() // (EDU) +{ + SetAttrOff( SvxUnderlineItem( UNDERLINE_NONE )); + SetAttrOff( SvxWordLineModeItem( FALSE )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_UNDERLINE ); +} + + +void SwW4WParser::Read_BeginItalic() // (ITO) +{ + if( !bStyleOnOff ) + SetAttr( SvxPostureItem( ITALIC_NORMAL )); +} + + +void SwW4WParser::Read_EndItalic() // (ITF) +{ + SetAttrOff( SvxPostureItem( ITALIC_NONE )); +} + + +void SwW4WParser::Read_BeginSuperScript() // (SPS) +{ + if( !bStyleOnOff ) + SetAttr( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT )); +} + + +void SwW4WParser::Read_EndSuperScript() // (EPS) +{ + SetAttrOff( SvxEscapementItem( SVX_ESCAPEMENT_OFF )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_ESCAPEMENT ); +} + + +void SwW4WParser::Read_BeginSubScript() // (SBS) +{ + if( !bStyleOnOff ) + SetAttr( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT )); +} + + +void SwW4WParser::Read_EndSubScript() // (EBS) +{ + SetAttrOff( SvxEscapementItem( SVX_ESCAPEMENT_OFF )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_ESCAPEMENT ); +} + + +void SwW4WParser::Read_BeginColoredText() // (BCL) +{ + if( !bStyleOnOff ) // evtl muessen noch die Bits in + // nCol abgefragt werden + { + long nCol, nRed, nGreen, nBlue; + if( GetDecimal( nCol ) && !nError && GetDecimal( nRed ) && !nError + && GetDecimal( nGreen ) && !nError && GetDecimal( nBlue ) + && !nError ) + SetAttr( SvxColorItem( + Color( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ))); + } +} + +void SwW4WParser::Read_EndColoredText() // (ECL) +{ + SetAttrOff( SvxColorItem( Color( 0, 0, 0 ) ) ); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_COLOR ); +} + + +void SwW4WParser::Read_BeginStrikeOut() // (BSO) +{ + if( !bStyleOnOff ) + { + BYTE c; + c = ReadChar(); + if( rInp.IsEof() ) + { + nError = ERR_RECORD; + return; + } + FontStrikeout eStrike = STRIKEOUT_SINGLE; + if( c > ' ' && c < '~' ){ + switch( c ){ + case ' ': eStrike = STRIKEOUT_NONE; break; + case '-': + case '_': eStrike = STRIKEOUT_SINGLE; break; + default: eStrike = STRIKEOUT_DOUBLE; break; + } + } + SetAttr( SvxCrossedOutItem( eStrike ) ); + } +} + + +void SwW4WParser::Read_EndStrikeOut() // (ESO) +{ + SetAttrOff( SvxCrossedOutItem( STRIKEOUT_NONE )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_CROSSEDOUT ); +} + + +void SwW4WParser::Read_BeginShadow() // (BSP) +{ + if( !bStyleOnOff ) + SetAttr( SvxShadowedItem( TRUE )); +} + + +void SwW4WParser::Read_EndShadow() // (ESP) +{ + SetAttrOff( SvxShadowedItem( FALSE )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_SHADOWED ); +} + + +// Read_HardAttrOff beendet die harten Attribute. +// muss fuer jedes Attribut gerufen werden, das beim Style-einschalten +// oder Style-ausschalten enthalten ist. +// Wenn beim Einschalten der Pam am Anfang einer Zeile steht ( trifft +// meistens beim Einschalten des Styles zu ) und es kein Charformat ist, +// wird das Attributende am Ende des letzten Absatzes gesetzt, +// da sonst das harte Attribut eine Zeile zuweit gueltig waere. + +void SwW4WParser::Read_HardAttrOff( USHORT nResId ) +{ + + BOOL bForward = FALSE; + BOOL bBack = bStyleOn && pCtrlStck->IsAttrOpen( nResId ) + && (RES_CHRATR_BEGIN > nResId || nResId >= RES_CHRATR_END ) + && pCurPaM->GetPoint()->nContent.GetIndex() == 0; + + if( bBack ) + bForward = pCurPaM->Move( fnMoveBackward, fnGoCntnt ); + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), nResId, TRUE, bForward ); + + if( bForward ) + pCurPaM->Move( fnMoveForward, fnGoCntnt ); +} + + +void SwW4WParser::Read_SetPageNumber() // (SPN) +{ // Der Befehl wird nicht ausgewertet. Stattdessen + if ( nDocType == 44 ) // wird er bei WW2 dafuer benutzt, das Ende der + bPageDefRdy = TRUE; // Seitenbeschreibung zu erkennen. +} + + +struct TabT{ + long nPos; + BYTE cType; + BYTE cLead; +}; + + +void SwW4WParser::Read_Ruler() // (RUL) +{ + long nDefByte, nNumTabs; + long i; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_TABSTOP ); + return; + } + + if ( !bPageDefRdy ) return; // auch nicht global setzen + + if( W4WR_TXTERM != GetDecimal( nDefByte ) || nError + || W4WR_TXTERM != GetDecimal( nNumTabs ) || nError + || nNumTabs > 100 ) + return; + + TabT *pTab = new TabT[nNumTabs]; + + for (i=0; i<nNumTabs; i++){ // lies Positionen + if( W4WR_TXTERM != GetDecimal( pTab[i].nPos ) || nError ){ + DELETEZ( pTab ); + return; + } + } + + BOOL bOpt = TRUE; + + for (i=0; i<nNumTabs; i++) // lies optionale Typen + { + if ( bOpt ) + { + if( W4WR_TXTERM != GetChar( pTab[i].cType ) || nError ) + { + pTab[i].cType = 'L'; // Opt. Parameter fehlen + bOpt = FALSE; + } + } + else + { // Opt. Parameter nicht da -> Default links + pTab[i].cType = 'L'; + } + } + + for (i=0; i<nNumTabs; i++){ // lies optionale Leadings + if ( bOpt ){ + if( W4WR_TXTERM != GetChar( pTab[i].cLead ) || nError ){ + pTab[i].cLead = cDfltFillChar; // Opt. Parameter fehlen + bOpt = FALSE; + } + }else{ // Opt. Parameter nicht da -> Default kein Leading + pTab[i].cLead = cDfltFillChar; + } + } + + if ( nDocType == 44 || nDocType == 49 ) + { // Default-Tabs von WinWord erkennen + for (i=nNumTabs-1; i>=0; i--) // von hinten nach vorne durchsuchen + { + if ( pTab[i].cType == 'L' ) // nur L kann Default sein + { + USHORT nPos = (USHORT)(pTab[i].nPos); + if ( nDefByte & 1 ) // Abstand zum l. Seiterand + nPos -= nPgLeft; + if ((nPos % 708 == 0)||(nPos % 709 == 0)){ // std-Einstellung + pTab[i].cType = 'l'; // Default-Tab + if ( i>0 && pTab[i].nPos - pTab[i-1].nPos < 50 ) + pTab[i].cType = 'V'; // falscher Default-Tab + } + else break; // kein Def-Tab -> alle davor auch nicht + } + else break; // dito + } + } + + SvxTabStopItem aTabStops( 0, 0 ); + SvxTabStop aTabStop; +// BOOL bZeroTab = FALSE; + long nLeftMargin = GetLeftMargin(); //!! geht anders schneller + + for (i=0; i<nNumTabs; i++) // Erzeuge Attribut + { + // SeitenRand abziehen ? + if ( nDefByte & 1 ) + aTabStop.GetTabPos() = pTab[i].nPos - nLeftMargin; + else + aTabStop.GetTabPos() = pTab[i].nPos; + + // Bestimme die Art des Tabulators + switch( pTab[ i ].cType ) + { + case 'l': aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DEFAULT; break; // eigene Codierung + case 'L': aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break; + case 'R': aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break; + case 'C': aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break; + case 'D': aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break; + case 'V': + { + continue; // Ignoriere virtuelle Tabs + } + default: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break; + } + + aTabStop.GetFill() = pTab[i].cLead; + +// if ( aTabStop.GetTabPos() < 10 && aTabStop.GetTabPos() > -10 ) +// bZeroTab = TRUE; + + aTabStops.Insert( aTabStop ); + } + +//!!! nicht mehr noetig ??? anscheinend doch ! +// if ( !bZeroTab ) // wenn neg. Erstzeeileneinzug benutzt wird, +// aTabStops.Insert( SvxTabStop( 0, SVX_TAB_ADJUST_DEFAULT ) ); // muss bei Null ein Tab gesetzt werden, wenn + + // keine doppelten Tabs + if( !bStyleDef ) + pCtrlStck->StealAttr( *pCurPaM->GetPoint(), RES_PARATR_TABSTOP ); + // jetzt noch das Attribut setzen (ueber Stack) + SetAttr( aTabStops ); + + DELETEZ( pTab ); + + bIgnoreNTB = TRUE; // wenn einmal RUL auftaucht, werden alle + // kommenden NTBs des Dokumentes ignoriert + bIsTab = TRUE; +} + + +void SwW4WParser::Read_NewTabTable() // (NTB) +{ + if ( bIgnoreNTB ) return; + + register BYTE c; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_TABSTOP ); + return; + } + + + if ( !bPageDefRdy ) return; // auch nicht global setzen + + BYTE aTabPosArr[ 32 ]; + BYTE nCnt; + for( nCnt = 0; nCnt < 32; ++nCnt ) + if( W4WR_TXTERM != GetHexByte( aTabPosArr[ nCnt ] )) + { + nError = ERR_RECORD; + return; + } + BYTE aTabTypesArr[ 20 ]; + for( nCnt = 0; nCnt < 20; ++nCnt ) + if( W4WR_TXTERM != GetHexByte( aTabTypesArr[ nCnt ] )) + { + nError = ERR_RECORD; + return; + } + + BOOL bTabLeadings = FALSE; + BYTE aTabLeadingArr[ 40 ]; + long nTabTwipCnt = 0; + BOOL bTabTwips = FALSE; + + // TabLeadings sind optional !! + c = ReadChar(); + if( !rInp.IsEof() && c != W4WR_RED ) + { + bTabLeadings = TRUE; + rInp.SeekRel( - 1 ); +// pInput->putback( c ); + + for( nCnt = 0; nCnt < 40; ++nCnt ) + if( W4WR_TXTERM != (c = GetHexByte( aTabLeadingArr[ nCnt ] ))) + { + nError = ERR_RECORD; + return; + } + + // Tab-Twips-Positions sind optional !! + // sind sie in Twips angegeben, lese sie erst beim Erzeugen der Tabs + bTabTwips = W4WR_RED != (c = GetDecimal( nTabTwipCnt )) && !nError; + } + + + // ok, jetzt sind alle Daten vorhanden, also erzeuge sie: + // 1. stelle fest, wieviele es ueberhaupt gibt: + if( !bTabTwips ) + { + nTabTwipCnt = 0; + for( nCnt = 0; nCnt < 32; nCnt += 4 ) + nTabTwipCnt += GetBitCnt( (ULONG) aTabPosArr + nCnt ); + } + + long nLeftMargin = GetLeftMargin(); + + + SvxTabStopItem aTabStops( 0, 0 ); + USHORT nTabPos = 0; + static SvxTabAdjust __READONLY_DATA aAdjustArr[ 4 ] = + { SVX_TAB_ADJUST_LEFT, SVX_TAB_ADJUST_CENTER, + SVX_TAB_ADJUST_RIGHT, SVX_TAB_ADJUST_DECIMAL }; + USHORT nTmp; + long nTabTwipPos = 0; +// BOOL bZeroTab = FALSE; + + for( nCnt = 0; nCnt < 32; ++nCnt ) + { + if( !aTabPosArr[ nCnt ] ) + continue; + + for( BYTE nMaske = 0x80, i = 0; nMaske; nMaske >>= 1, ++i ) + if( aTabPosArr[ nCnt ] & nMaske ) + { + SvxTabStop aTabStop; + if( bTabTwips ) + { + if( W4WR_TXTERM != (c = GetDecimal( nTabTwipPos )) || nError ) + { + nError = ERR_RECORD; + return; + } + aTabStop.GetTabPos() = nTabTwipPos; + } + else + aTabStop.GetTabPos() = nColSize * ( nCnt * 8 + i ); + aTabStop.GetTabPos() -= nLeftMargin; // SeitenRand abziehen + + BYTE nType = aTabTypesArr[ nTabPos / 2 ]; + + nTmp = nTabPos & 1 ? nType & 0x0f : (nType & 0xf0) >> 4; + if (nTmp <= 4){ // no virtual Tab + aTabStop.GetAdjustment() = aAdjustArr[nTmp]; + + if( bTabLeadings && aTabLeadingArr[ nTabPos ] ) + aTabStop.GetFill() = aTabLeadingArr[ nTabPos ]; + + aTabStops.Insert( aTabStop ); +// if( aTabStop.GetTabPos() < 10 && +// aTabStop.GetTabPos() > -10 ) +// bZeroTab = TRUE; + } + ++nTabPos; + } + } +// if ( !bZeroTab ) // wenn neg. Erstzeeileneinzug benutzt wird, +// aTabStops.Insert( SvxTabStop( 0 ) ); // muss bei Null ein Tab gesetzt werden, wenn + // sich hier noch keiner befindet. + + const SwPosition& rPos = *pCurPaM->GetPoint(); + if ( !bStyleDef ) // keine doppelten Tabs + pCtrlStck->StealAttr( rPos, RES_PARATR_TABSTOP ); + pCtrlStck->SetAttr( rPos, RES_PARATR_TABSTOP ); // erst alte Tabs setzen + SetAttr( aTabStops ); // jetzt noch das Attribut setzen (ueber Stack) +// pCtrlStck->SetAttr( rPos, RES_PARATR_TABSTOP ); +} + + +void SwW4WParser::Read_BeginFlushRight() // (AFR) +{ + long nAlign; + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_ADJUST ); + return; + } + if( GetDecimal( nAlign ) && !nError ) + { + if( 10 == nAlign ) + SetAttr( SvxAdjustItem( SVX_ADJUST_RIGHT )); + else if( 44 == nAlign || 46 == nAlign ) + FlushChar( '\t' ); //!!! Was machen RechtsTabs ? + } +} + + +void SwW4WParser::Read_EndFlushRight() // (EAT) +{ + SetAttrOff( SvxAdjustItem( SVX_ADJUST_LEFT )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_ADJUST ); +} + + +void SwW4WParser::Read_BeginCenterText() // (CTX) +{ + if( bStyleOnOff ) + // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_ADJUST ); + else + { + long nAlign; + if( GetDecimal( nAlign ) && !nError ) + { + if( 0 == nAlign ) + SetAttr( SvxAdjustItem( SVX_ADJUST_CENTER )); + else + if( 1 == nAlign ) + FlushChar( '\t' ); + } + } +} + + +void SwW4WParser::Read_EndCenterText() // (ECT) +{ + SetAttrOff( SvxAdjustItem( SVX_ADJUST_LEFT )); +// if( !bStyleOnOff ) +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_ADJUST ); +} + + +void SwW4WParser::Read_BeginRightJustify() // (BRJ) +{ + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_PARATR_ADJUST ); + return; + } + bPersAlign = TRUE; + SetAttr( SvxAdjustItem( SVX_ADJUST_BLOCK )); +} + + +void SwW4WParser::Read_EndRightJustify() // (ERJ) +{ + SetAttrOff( SvxAdjustItem( SVX_ADJUST_LEFT )); + bPersAlign = FALSE; +// if( !bStyleOnOff ){ +// bPersAlign = FALSE; +// pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_ADJUST ); +// } +} + + +void SwW4WParser::Read_PrintPageNo() // (PPN) +{ + // Seitennummernfeld einsetzen: + SwPageNumberField aPageFld( (SwPageNumberFieldType*) + pDoc->GetSysFldType( RES_PAGENUMBERFLD ) ); + aPageFld.ChangeFormat( SVX_NUM_ARABIC ); + pDoc->Insert( *pCurPaM, SwFmtFld( aPageFld ) ); +} + + +void SwW4WParser::Read_PrintLastPageNo() // (PLN) +{ + // SeitenZahl - Feld + SwDocStatField aPageFld( (SwDocStatFieldType*) + pDoc->GetSysFldType( RES_DOCSTATFLD ), + DS_PAGE, SVX_NUM_ARABIC ); + pDoc->Insert( *pCurPaM, SwFmtFld( aPageFld )); +} + +// -------- Methoden fuer die Font-Verarbeitung: ------------ + + +void SwW4WParser::Read_SetPitchAndOrFont() // (SPF) +{ + if ( bStyleOnOff ){ // Style On /Off -> Harte Attributierung zuende + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->SetAttr( rPos, RES_CHRATR_FONT ); + pCtrlStck->SetAttr( rPos, RES_CHRATR_FONTSIZE ); + return; + } + + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + + long nOldPitch, nOldFont, nNewPitch, nNewFont, nSize; + long nOptProp, nOptSerif; + + // die von W4W angegeben alten Werte nOld... + // stimmen nicht immer, d.h., + // man darf sich zur Optimierung der Aufrufe nicht + // darauf verlassen + + // Im Moment werden die Aufrufe nicht optimiert, d.h bei + // jedem SetText-Record werden Pitch, SSize und Name neu + // gesetzt + + Flush(); // Vor GetNextRecord() Puffer leeren + if( GetDecimal( nOldPitch ) && !nError && + GetDecimal( nOldFont ) && !nError && + GetDecimal( nNewPitch ) && !nError && + GetDecimal( nNewFont ) && !nError && + GetDecimal( nSize ) && !nError && + EOF != GetNextRecord() ) + { + if( W4WR_TXTERM != GetDecimal( nOptProp ) || // weitere Info zum Font ?? + W4WR_TXTERM != GetDecimal( nOptSerif ) || nError ){ + nOptProp = -1; // keine weitere Info + nOptSerif = -1; + } + + Flush(); // '\0' hinter Fontnamen setzen +// NOTE7( "[Font: (Old: %ld|%ld)(New: %ld|%ld) SSize: %ld, Name: (%s)", +// nOldPitch, nOldFont, nNewPitch, nNewFont, nSize, aCharBuffer ); + +/* Nach ST den Pitch besser ignorieren, da er im SW immer fest mit der Fontgroesse + verknuepft ist (und damit keine schmaleren Buchstaben moeglich sind) + + // erstmal das alte zuruecksetzen + if( !bStyleDef ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_CHARWIDTH ); + + SetAttr( SwFmtCharWidth( Fraction( nNewPitch, 1 ))); +*/ + + if ( bNew ) + { + + // loesche alle fuehrende Blanks vom Namen + String sFntNm( aCharBuffer ); + sFntNm.EraseLeadingChars().EraseTrailingChars(); + + SvxFontItem aFont( ((SvxFontItem&)pDoc->GetAttrPool().GetDefaultItem( + RES_CHRATR_FONT ) )); + + FontFamily eFamily = FAMILY_DONTKNOW; + + if( sFntNm.Len() ) + { +#if defined( WIN ) || defined ( WNT ) + // ersetze alte Fonts durch neue AEquivalente + if ( sFntNm.EqualsAscii( "Helv" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Arial" )); + else if ( sFntNm.EqualsAscii( "Tms Rmn" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Times New Roman" )); + else if ( sFntNm.EqualsAscii( "Courier" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Courier New" )); +#endif // WIN +#if defined( OS2 ) + if ( sFntNm.EqualsAscii( "Helv" ) || + sFntNm.EqualsAscii( "Arial" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" )); + else if( sFntNm.EqualsAscii( "Tms Rmn" ) + || sFntNm.EqualsAscii( "Times New Roman" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Times New Roman" )); + else if ( sFntNm.EqualsAscii( "Courier New" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Courier" )); +#endif // OS2 +#if defined( MAC ) + if ( sFntNm.EqualsAscii( "Helv" ) || + sFntNm.EqualsAscii( "Arial" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" )); + else if( sFntNm.EqualsAscii( "Tms Rmn" ) + || sFntNm.EqualsAscii( "Times New Roman" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Times" )); + else if ( sFntNm.EqualsAscii( "Courier New" )) + sFntNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Courier" )); +#endif // MAC + + if ( sFntNm.EqualsAscii( "Script" )) + eFamily = FAMILY_SCRIPT; + } + + switch( nOptProp ) + { + case 0: + aFont.GetPitch() = PITCH_FIXED; + aFont.GetFamily() = FAMILY_MODERN; + break; + + case 1: + aFont.GetPitch() = PITCH_VARIABLE; + if( !nOptSerif ) + aFont.GetFamily() = FAMILY_SWISS; + else if( 1 == nOptSerif ) + aFont.GetFamily() = FAMILY_ROMAN; + break; + } + + SvxFontHeightItem aSz( (const ULONG)nSize ); + if ( !bPageDefRdy ) // Setze Defaults fuer ganzes Dokument + { + pDoc->SetDefault( aFont ); // Font ignorieren, da W4W WW2-Filter + // faelschlicherweise am Anfang + // immer Courier setzt ?? + + pDoc->SetDefault( aSz ); // Groesse setzen + + } + else + { + SetAttr( aFont ); // neuer Font + SetAttr( aSz ); // in Twips + } + } + bDefFontSet = TRUE; + } + bTxtInDoc = bOldTxtInDoc; +} + +#ifdef NIE + + +void SwW4WParser::Read_FontDefTable() // (FDT) +{ //!!! Ist m.E. ueberfluessig, SPF tut's besser + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + + long nCntFnts, nFntFlds; + BYTE nDummy; + int cRet; + if( GetDecimal( nCntFnts ) && !nError && + GetDecimal( nFntFlds ) && !nError && + nCntFnts ) + { + if( W4WR_TXTERM != SkipPara() ) // Dummy Feld einlesen + { // am Ende vom Record ? + nError = ERR_RECORD; // darf nicht sein ! + return; + } + +// NOTE3( "[ FontTab: (Sz: %ld, FldSz: %ld )", nCntFnts, nFntFlds ); + + long nFntId; + for( USHORT n = 0; n < nCntFnts; ++n ) + { + // lese jetzt die Fontdefinitionen: + if( GetDecimal( nFntId ) && !nError && + EOF != ( cRet = GetNextRecord()) && !nError && + W4WR_TXTERM == cRet ) + { + for( USHORT nCnt = 2; nCnt < nFntFlds && !nError; ++nCnt ) + if( W4WR_TXTERM != SkipPara() ) // am Ende vom Record ? + { + nError = ERR_RECORD; // darf nicht sein ! + return; + } + Flush(); +// NOTE3( "(Id: %ld, (%s) )", nFntId, aCharBuffer ); + } + } +// NOTE1( "]" ); + } + bTxtInDoc = bOldTxtInDoc; +} + +#endif // NIE + + +/*********************************************************** +************ Methoden fuer die Formatierung: *************** +***********************************************************/ + +void SwW4WParser::Read_SetFormLenght() // (SFL) +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + long nNewHeight; + +#ifdef MOGEL_WW6 + if ( nDocType == 49 ) return; // WW6 : PGW, SFL macht Mist +#endif + + // FrameMaker: Seitengroesse ist oft erst nach FLO, PDT und RDT definiert. + if( pPDTInfo ) + { + if( pPDTInfo->PageSizeKnown() ) + { + // PgDesc ist bereits aktiv, aber noch nicht vollstaendig bemasst + + } + } + + + if ( bIsTxtInPgDesc && nDocType != 15 ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + if( nError || + W4WR_TXTERM != SkipPara() || W4WR_TXTERM != SkipPara() || + W4WR_TXTERM != GetDecimal( nNewHeight ) || nError ) + return; + + // Seitenhoehe einstellen + SwFrmFmt &rFmt = pPageDesc->GetMaster(); + SwFmtFrmSize aSz( rFmt.GetFrmSize() ); + + long nOptNew; // gibt es die optionale Angabe ? + + if ( nDocType == 1 ) // Ascii -> zwangsweise A4 ( statt letter ) + return; + + if( W4WR_TXTERM != SkipPara() || + //!! unterer Rand wird bislang ignoriert + W4WR_TXTERM != GetDecimal( nOptNew ) || nError ) + nOptNew = nNewHeight * 240; // Angabe nur in 1/6 Inch + + if (( nOptNew < lA4Height + 240 ) && ( nOptNew > lA4Height - 240 )) + nOptNew = lA4Height; // fast A4 -> genau A4 + + aSz.SetHeight( nOptNew ); + rFmt.SetAttr( aSz ); + bSetPgHeight = TRUE; +} + + +void SwW4WParser::Read_PageWidth() // (PGW) +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + long nNewWidth; + +#ifdef MOGEL_WW6 + if ( nDocType == 49 ) return; // WW6 : PGW, SFL macht Mist +#endif + + // nicht bei PC Text 4 und nicht bei FrameMaker + if ( bIsTxtInPgDesc && (nDocType != 15) && !pPDTInfos ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + if( nError || W4WR_TXTERM != GetDecimal( nNewWidth ) || nError ) + return; + + // Seitenbreite einstellen + SwFrmFmt &rFmt = pPageDesc->GetMaster(); + SwFmtFrmSize aSz( rFmt.GetFrmSize() ); + + long nOptNew; // gibt es die optionale Angabe ? + if( W4WR_TXTERM != GetDecimal( nOptNew ) || nError ) + nOptNew = nNewWidth * 144; // in 1/10 Inch statt in twips + + if (( nOptNew < lA4Width + 240 ) && ( nOptNew > lA4Width - 240 )) + nOptNew = lA4Width; // fast A4 -> genau A4 + + aSz.SetWidth( nOptNew ); // in Twip + rFmt.SetAttr( aSz ); + nPgWidth = USHORT(nOptNew); + + if( pPDTInfos ) + { + if( pActRectInfo ) + { + const SvxLRSpaceItem& rPageLR = rFmt.GetLRSpace(); + const SwRect& rRect = pActRectInfo->aRect; + USHORT nMyLeft = rPageLR.GetLeft(); + USHORT nMyRight = abs( nOptNew - rRect.Width() - nMyLeft ); + + rFmt.SetAttr( SvxLRSpaceItem( nMyLeft, nMyRight ) ); + + } + } + else + { + UpdateCacheVars(); // neuer rechter Rand + + bSetPgWidth = TRUE; + if ( nDocType != 44 ) // WinWord: alle Attribute vor + bPageDefRdy = TRUE; // Styledefinitionen vergessen + } +} + + +void SwW4WParser::SetPageMgn() // Seitenraender einstellen nach nRSM... +{ + SwFrmFmt &rFmt = pPageDesc->GetMaster(); + long nNewRight = rFmt.GetFrmSize().GetWidth() - nRSMRight; + if ( nNewRight < 0 ) + nNewRight = 0; + SvxLRSpaceItem aLR; + aLR.SetTxtLeft( USHORT(nRSMLeft) ); + aLR.SetRight( USHORT(nNewRight) ); + rFmt.SetAttr( aLR ); + + UpdateCacheVars(); + + bPgMgnChanged = FALSE; +} + + + // bei WPWin 6,7,8 setzt W4W ein RSM, um einen Absatz(!) links + // einzuruecken - aehnlich <IPS> behandeln! ( Karl-Heinz Zimmer ) + +void SwW4WParser::Read_ReSetLeftRightMargin() // (RSM) +{ + long nNewLeft, nNewRight; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_LR_SPACE ); + return; + } + if ( bIsColMode ) // ignoriere RSM in Tabelle ( W4W-WW2-Bug ) + return; + + if( nError || W4WR_TXTERM != SkipPara() || W4WR_TXTERM != SkipPara() || + W4WR_TXTERM != GetDecimal( nNewLeft ) || + W4WR_TXTERM != GetDecimal( nNewRight ) || + nError ) + return; + + long nOptNew; // gibt es die optionale Angabe ? + BOOL bOption = W4WR_TXTERM == GetDecimal( nOptNew ); + if( bOption && !nError ) + nNewLeft = nOptNew; // in Twip + else + nNewLeft *= 144; // in 1/10 Inch, *nicht* nColSize; + + // gibt es die optionale Angabe ? + if( bOption && W4WR_TXTERM == GetDecimal( nOptNew ) && !nError ) + nNewRight = nOptNew; // in Twip + else + nNewRight *= 144; // in 1/10 Inch, *nicht* nColSize; + + if( !bStyleDef ) + { + if( (1800 == nNewLeft) && (44 == nDocType) // Mogelei gegen WinWord-Bug + && ( !bWWWasRSM ) + && ( SvxLocaleToLanguage( GetAppLocaleData().getLocale() ) // Der Mac, + == LANGUAGE_GERMAN ) // der spinnt + ) + { + nNewLeft = 1417; + nLeftMgnCorr = 1800 - (USHORT)nNewLeft; + nNewRight = 10823; + bWWWasRSM = TRUE; + } + else + { + nLeftMgnCorr = 0; + } + } + + // Zahlenueberlauf oder andere W4W-Fehler + if ( ( nNewLeft < 0 ) + || ( nNewLeft >= (long)nPgWidth - nColSize ) + || ( ( nNewLeft < nRSMLeft ) + // Sonderbehandlung fuer WordPerfekt f. Win 6,7,8 + && ( 48 == nDocType ) + && ( pCurPaM->GetPoint()->nNode.GetIndex() + >= pDoc->GetNodes().GetEndOfContent(). + StartOfSectionIndex()+2 + ) + ) + ) + { + nNewLeft = 0; + } + if( nNewLeft >= nNewRight - nColSize ) { // Zahlenueberlauf oder andere W4W-Fehler + nNewLeft = 0; + } + if( nNewLeft >= nNewRight - nColSize ) // dito + nNewRight = (long)nPgWidth - nColSize; + if( nNewRight > (long)nPgWidth ) + nNewRight = nPgWidth; + + if( 1 == nDocType && nNewLeft < 850 ) // ASCII-Reader mit falschem LRand + return; + + if( bStyleDef // behandle RSM in StyleDef wie IPS/STM + // WordPerfekt f. Win 6,7,8 + || ( ( 48 == nDocType ) + && ( bWPWWasRSM ) + && ( ( 0 == nNewLeft ) + || ( nNewLeft >= nRSMLeft ) + || ( pCurPaM->GetPoint()->nNode.GetIndex() + >= pDoc->GetNodes().GetEndOfContent(). + StartOfSectionIndex()+2 + ) + ) + ) ) + { + if( bStyleDef ) + Read_IndentPara1( nNewLeft, nNewLeft, nNewRight); + else + { + nRSMwpwParaLeft = nNewLeft; + nRSMwpwParaRight = nNewRight; + } + } + else + { + if( !bStyleDef ) + bWPWWasRSM = TRUE; // fuer WPWin - Sonderbehandlung + + nRSMLeft = nNewLeft; + nRSMRight = nNewRight; + bPgMgnChanged = TRUE; + + if( !bIsTxtInPgDesc ) + SetPageMgn(); + } +} + // kam im selben Absatz bereits ein IPS, dann sollte ein // + // folgendes STM ignoriert werden, da STM den + // Erstzeileneinzug zuruecksetzt. ( Karl Forster ) + // + // aber: bei WPWin 6,7,8 setzt W4W ein STM, um einen + // TAB anzuzeigen, der nicht als erstes Zeichen in der Zeile + // steht. dann wie .<TAB> behandeln! ( Karl-Heinz Zimmer ) + +void SwW4WParser::Read_SetTempLeftRightMargin() // (STM) +{ + long nCurrPos, nFinalPos; + + + /* + erstmal alle Parameter lesen, aber noch nicht setzen... + */ + if( W4WR_TXTERM != GetDecimal( nCurrPos ) || + W4WR_TXTERM != GetDecimal( nFinalPos ) || nError ) return; + + // ggfs. die optionalen Angaben lesen + long nOptCurr, nOptFinal; + if( W4WR_TXTERM == GetDecimal( nOptCurr ) && + W4WR_TXTERM == GetDecimal( nOptFinal ) && !nError ) + { + nCurrPos = nOptCurr; // in Twip + nFinalPos = nOptFinal; // in Twip + } + else + { + nCurrPos *= nColSize; // in 1/10 Inch / ?? + nFinalPos *= nColSize; // in 1/10 Inch / ?? + } + + // Parameter korrigieren + if( ( 33 != nDocType ) || !bStyleDef ) + { + nCurrPos -= nPgLeft; + nFinalPos -= nPgLeft; + } + // die Angaben gelten ab Seitenrand !! + // ausser bei Ami in der StyleDef + // Bei AmiPro kommt vor der Styledefinition kein RSM vor, + // in den Style beziehen sich Einrueckungen auf einen + // linken Seitenrand von 0 + + if( nCurrPos < 0 ) nCurrPos = 0; + if( nFinalPos < 0 ) nFinalPos = 0; + + + /* + eigentliche Aktionen, je nach Situation... + */ + if( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_LR_SPACE ); + return; + } + + // Sonderbehandlung fuer WordPerfekt f. Win 6,7,8 + if( ( 48 == nDocType ) && !bStyleDef ) + { + if( bIsNumListPara ) + { /* + Bei num. Listen in WP folgt auf .<PGN> - .<EPN> ein + .<STM> welches die Einrueckung des Listenabsatzes regelt. + Hier gelten nCurrPos als linker Absatz-Einzug + und nFinalPos als Erstzeileneinzug. + */ + + // loesche ggfs. altes Attr. vom Stack + pCtrlStck->StealAttr( *pCurPaM->GetPoint(), RES_LR_SPACE ); + + SwNumFmt aMyNumFmt( pActNumRule->Get( nActNumLevel ) ); + + aMyNumFmt.SetAbsLSpace( (USHORT)nFinalPos ); + aMyNumFmt.SetFirstLineOffset( (short)(nCurrPos - nFinalPos) ); + + pActNumRule->Set( nActNumLevel, aMyNumFmt ); + + return; + } + else + if( pCurPaM->GetPoint()->nContent.GetIndex() ) + { + FlushChar( '\t' ); + return; + } + } + + if( bIsIpsInPara ) return; + + if( bIsColMode && pTabDefs ) + { // Tabelle + long nBoxSize = pTabDefs[nTabCol].nRightTw + - pTabDefs[nTabCol].nLeftTw; + if( nFinalPos + HOR_SICHER > nBoxSize / 2 ) //!!! RMargin ?? + nFinalPos = 0; // Stuss-Werte -> keine Einrueckung + } + /* + else + if( pCurPaM->GetPoint()->nContent.GetIndex() ) + { + FlushChar( '\t' ); + return; + } + */ + + /* + Hier nun tatsaechlich die harte Einrueckung... + */ + SvxLRSpaceItem aLR( *(SvxLRSpaceItem*) GetFmtAttr( RES_LR_SPACE )); + + // Sonderbehandlung bei PC-Text-4 + if( ( nDocType == 15 ) + && ( nChrCnt + || PtNd( pCurPaM ).GetNode().GetTxtNode()->GetTxt().Len() + ) + && !( nIniFlags & W4WFL_NO_PCTEXT4_INDENT ) ) + { + aLR.SetTxtFirstLineOfst( -(short)nFinalPos ); + aLR.SetTxtLeft( (short)nFinalPos ); + } + else + aLR.SetTxtLeft( (short)nFinalPos ); + SetAttr( aLR ); + + // Flag setzen, damit Einrueckung bei num. Listen ggfs. wieder + // entfernt werden kann... + bIsSTMInPara = TRUE; + + // Flag setzen, damit bei HLN alter Wert restauriert wird. + bSingleParaMgn = TRUE; +} + + + // .<LMR> wird leider nicht ueberfluessig, da WP kein IPS liefert. + // Wenn vorher ein IPS aufgetreten ist, wird dieses jedoch + // ignoriert, da IPS eine weitergehende Aussage macht + +void SwW4WParser::Read_SetLeftMarginRelease() // (LMR) +{ + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_LR_SPACE ); + return; + } + if( bIsIpsInPara ) return; + + long nSpaces, nOptRelLeftTw, nOptAbsLeftTw; + short nFirstLeft; + BOOL bAbs = FALSE; + + if( W4WR_TXTERM != GetDecimal( nSpaces ) || nError ) + return; + + // gibt es die optionale Angabe ? + if( W4WR_TXTERM == GetDecimal( nOptRelLeftTw ) && !nError ) + { + nFirstLeft = *((short*)&nOptRelLeftTw); // evtl. UEberlauf ist beabsichtigt, + // da bei W4W neg. Zahlen um 65536 + // erhoeht werden + if( W4WR_TXTERM == GetDecimal( nOptAbsLeftTw ) && !nError ) + { + nFirstLeft = (short)(nOptAbsLeftTw - GetLeftMargin()); + bAbs = TRUE; + } + } + else + nFirstLeft = (short)nSpaces * nColSize; // in 1/10 Inch / ?? + +/* + // erstmal das alte zuruecksetzen + if( !bStyleDef ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_LR_SPACE ); +*/ +/* + SwFmtLRSpace aLR( *(SwFmtLRSpace*) + pCtrlStck->GetFmtAttr( *pCurPaM, RES_LR_SPACE )); +*/ + SvxLRSpaceItem aLR( *(SvxLRSpaceItem*) GetFmtAttr( RES_LR_SPACE ) ); + + + + if( bAbs ) + aLR.SetTxtFirstLineOfst( nFirstLeft ); + else // relative Angaben sind leider kumulativ + { + short nIndent = GetLeftMargin() - nFirstLeft; + short nAbsIndent = aLR.GetTxtLeft(); + if( nIndent > ( nAbsIndent * -1 ) ) + nIndent = nAbsIndent; + + aLR.SetTxtFirstLineOfst( nIndent * -1 ); + } + SetAttr( aLR ); + +#if 0 + // MIB 16.5.2001: A default tab at pos 0 isn't required since 1996. + if( nDocType == 33 && bStyleDef && !bIsTab ) + { + // AmiPro hat nicht so irrsinnig viele Tabs im Metafile, + // so dass die dort eingebaute Mimik zum Setzen eines + // Default-Tabs an die Pos 0 ( fuer 1.Zeile < LRand ) + // nicht ausreicht. + + SvxTabStopItem aTabStops( 0, 0 ); + aTabStops.Insert( SvxTabStop( 0, SVX_TAB_ADJUST_DEFAULT ) ); + SetAttr( aTabStops ); + bIsTab = TRUE; + } +#endif +} + // fuer IPS und RSM waehrend StyleDefinition + // und fuer RSM bei WordPerfekt f. Win 6,7,8 + +void SwW4WParser::Read_IndentPara1(long nLeft, long n1st, long nRight) +{ + n1st -= nLeft; // 1st rel. zu left + nLeft -= nPgLeft; // left rel. zu Page + if( nLeft < 0) nLeft = 0; + if( n1st < -nLeft ) n1st = -nLeft; + nRight -= nPgRight; // right rel. zu Page + if( nRight < 0 ) nRight = 0; + + //!!! FlyFrames auch testen ?? + if( bIsColMode && pTabDefs ){ // Tabelle + long nBoxSize = pTabDefs[nTabCol].nRightTw + - pTabDefs[nTabCol].nLeftTw; + if( nLeft + nRight + HOR_SICHER > nBoxSize + || n1st + nRight + HOR_SICHER > nBoxSize ) + nRight = nLeft = n1st = 0; // Stuss-Werte -> keine Einrueckung + } +/* + // erstmal das alte zuruecksetzen + if( !bStyleDef ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_LR_SPACE ); +*/ + SvxLRSpaceItem aLR; + aLR.SetTxtLeft( USHORT(nLeft) ); + aLR.SetRight( USHORT(nRight) ); + aLR.SetTxtFirstLineOfst( (short)n1st ); + + SetAttr( aLR ); +} + + +void SwW4WParser::Read_IndentPara() // (IPS) +{ + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_LR_SPACE ); + return; + } + + long nLCol, n1Col; + // Die folgenden Parameter sind entgegen der + // Dokumentation optional, bei DosWord fehlen sie + + long nOptLeft, nOpt1st, nOptRight; + + if( GetDecimal( nLCol ) && !nError && GetDecimal( n1Col ) && !nError ) + { + + if ( W4WR_TXTERM != GetDecimal( nOptLeft ) || nError + || W4WR_TXTERM != GetDecimal( nOpt1st ) || nError + || W4WR_TXTERM != GetDecimal( nOptRight ) || nError ) + { + nOptLeft = nLCol * nColSize; + nOpt1st = n1Col * nColSize; + nOptRight = nPgRight; + } + Read_IndentPara1( nOptLeft, nOpt1st, nOptRight); + bIsIpsInPara = TRUE; // -> ignoriere STM, LMR, RMI + // Flag setzen, damit bei HLN alter Wert restauriert wird. + bSingleParaMgn = TRUE; + } +} + + +/* + * Es folgen die Methoden fuer vertikale Abstaende. + * + * zur Erinnerung hier nochmal die unterschiedlichen Randschemata (k.h.z.) + * + * + * W4W: Beachte: Bei WinWord 2 + * +--------------------------- und bei AmiPro + * | - HTM \ liefert das miese + * | +----------------- \ W4W uns lediglich + * | | \ + * | | Kopf \ STP und SBP + * | | - STP + * | +----------------- / die uebrigen Daten + * | - HM / fehlen, so dass + * | +------------------------ / mit moeglichst + * | | plausiblen Hilfs- + * | | werten gearbeitet + * | | Rumpf werden muss . . . + * | | + * | | Bei WordPerfekt + * | +------------------------ f. Win. stehen + * | - FM \ uns dann alle + * | +----------------- \ moeglichen Werte + * | | \ zur Verfuegung + * | | Fuss \ und wir koennen + * | | - SBP die Raender + * | +----------------- / richtig genau + * | - FBM / austuefteln. + * +--------------------------- / + * + * + * + * Writer: + * +--------------------------- + * | - Seitenrand oben nPgUpper + * | +--------------------- + * | | \ + * | | Kopf - Kopf-Hoehe nHdHeight + * | | / + * | +---------------- / + * | - Kopf-Margin / nHdLower + * | +------------------/ + * | | + * | | + * | | Rumpf + * | | + * | | + * | +------------------\ + * | - Fuss-Margin \ nFtUpper + * | +---------------- \ + * | | \ + * | | Fuss - Fuss-Hoehe nFtHeight + * | | / + * | +--------------------- + * | - Seitenrand unten nPgLower + * +--------------------------- + */ + + +void SwW4WParser::UpdateHdFtMarginSettings( SwFrmFmt *pHdFtFmt, + long nHeight, + long nDelta, + BOOL bDoTheHeader ) +{ + // aktuelle Werte ermitteln + SwFmtFrmSize aSz( pHdFtFmt->GetFrmSize() ); // Height / Width + SvxULSpaceItem aUL( pHdFtFmt->GetULSpace() ); // Upper / Lower + + // sicherstellen, dass MIN-Size eingestellt ist, + // (sonst gilt naemlich VAR-Size) + // und die Werte aendern + aSz.SetSizeType( ATT_MIN_SIZE ); + aSz.SetHeight( nHeight ); + if( bDoTheHeader ) + aUL.SetLower( USHORT( nDelta ) ); // nDelta = nHdLower + else + aUL.SetUpper( USHORT( nDelta ) ); // nDelta = nFtLower + + // geaenderte Werte eintragen + pHdFtFmt->SetAttr( aSz ); + pHdFtFmt->SetAttr( aUL ); +} + + +void SwW4WParser::AdjustTempVar1( long& rHeight, + long& rPgDelta, + long& rHdFtDelta, + long nIniHdFtSiz ) +{ + /* + * mindest. Kopf-/Fussbereich-Hoehe steht in der Ini-Datei + * oder wird mit 0,50 cm angesetzt + */ + long nMin = (nIniHdFtSiz ? nIniHdFtSiz : MM50) * 3 / 2; + if( rHeight < nMin ) + rHeight = nMin; +#if 0 +// why get the page upper / lower the half of the header/footer height? + rPgDelta = rHeight / 2; + rHdFtDelta = rPgDelta / 2; +#else + // then the half height for the header/footer and the other half + // height get half the page and the header/footer distance + rHdFtDelta = rPgDelta = rHeight / 4; + rHeight -= rPgDelta; +#endif +} + + + +void SwW4WParser::SetPageDescVSpaces( SwPageDesc& rPageDesc, + W4W_UpdtPgMrgSet eCalledByWhom ) +{ + // Variablen fuer Writer + long nPgUpper, + nHdHeight, nHdLower, + nFtUpper, nFtHeight, + nPgLower; + BOOL bHasHeader, + bHasFooter; + + // Umrechnen vom W4W-Schema zum Writer-Schema (s.oben) + nPgUpper = nNewValueHTM; + nPgLower = nNewValueFBM; + + nHdHeight = nNewValueSTP - nPgUpper; + nFtHeight = nNewValueSBP - nPgLower; + + nHdLower = nNewValueHM; + nFtUpper = nNewValueFM; + + // weitere Plausibilitaetskontrolle, ggfs. Anpassung an Minimalwert + bHasHeader = (nHdHeight > 0); + if( bHasHeader + && (nHdHeight - nHdLower < MM50) ) // siehe SWTYPES.HXX + { + nHdHeight = nHdLower + MM50; + nNewValueSTP = nHdHeight + nPgUpper; + } + bHasFooter = (nFtHeight > 0); + if( bHasFooter + && (nFtHeight - nFtUpper < MM50) ) + { + nFtHeight = nFtUpper + MM50; + nNewValueSBP = nFtHeight + nPgLower; + } + + // passende Werte-Initialisierungen, falls Aufruf aus HF2 bzw. HF1 + if( CALLED_BY_HF2 == eCalledByWhom && + ( !bHasHeader || ( !nPgUpper && !nHdLower ) ) ) + { + bHasHeader = TRUE; + AdjustTempVar1( nHdHeight, nPgUpper, nHdLower, nIniHdSiz ); + } + else if( CALLED_BY_HF1 == eCalledByWhom && + ( !bHasFooter || ( !nPgLower && !nFtUpper ) ) ) + { + bHasFooter = TRUE; + AdjustTempVar1( nFtHeight, nPgLower, nFtUpper, nIniFtSiz ); + } + + /* + Setzen der neuen Werte + bzw. Loeschen des Kopf- oder Fuss-Bereichs + */ + SwFrmFmt &rPageFmt = rPageDesc.GetMaster(); + + // Kopfbereich + if( eCalledByWhom != CALLED_BY_HF1 ) + { + SwFrmFmt *pHdFmt; + pHdFmt = (SwFrmFmt*)rPageFmt.GetHeader().GetHeaderFmt(); + if( pHdFmt ) + { + if( bHasHeader ) + { + if( !nPgUpper && !nHdLower ) + AdjustTempVar1( nHdHeight, nPgUpper, nHdLower, nIniHdSiz ); + UpdateHdFtMarginSettings( pHdFmt, nHdHeight, nHdLower, TRUE); + } + else + rPageFmt.SetAttr(SwFmtHeader(BOOL( FALSE ))); + } + } + // Fussbereich + if( eCalledByWhom != CALLED_BY_HF2 ) + { + SwFrmFmt *pFtFmt; + pFtFmt = (SwFrmFmt*)rPageFmt.GetFooter().GetFooterFmt(); + if( pFtFmt ) + { + if( bHasFooter ) + { + if( !nPgLower && !nFtUpper ) + AdjustTempVar1( nFtHeight, nPgLower, nFtUpper, nIniFtSiz ); + UpdateHdFtMarginSettings(pFtFmt, nFtHeight, nFtUpper, FALSE); + } + else + rPageFmt.SetAttr(SwFmtFooter(BOOL( FALSE ))); + } + } + + // eine letzte Korrektur: falls keine Hd(bzw. Ft)-Abstaende definiert, + // setze den gesamten oberen (unteren) Abstand als Seitenrand ein + if( nHdHeight && (!nPgUpper) && (!nHdLower) ) nPgUpper = nHdHeight; + if( nFtHeight && (!nPgLower) && (!nFtUpper) ) nPgLower = nFtHeight; + + // Seitenrand oben/unten + if( eCalledByWhom == CALLED_BY_FLUSH_OR_HNL ) + { + SvxULSpaceItem aUL( (const USHORT) nPgUpper, (const USHORT) nPgLower ); + rPageFmt.SetAttr( aUL ); + } + else + { + SvxULSpaceItem aUL( rPageFmt.GetULSpace() ); // Upper / Lower + switch ( eCalledByWhom ){ + case CALLED_BY_HF2: // oberer Seitenrand + aUL.SetUpper( USHORT( nPgUpper ) ); + if( nNewValueSBP != nLastValueSBP ) + aUL.SetLower( USHORT( nPgLower ) ); + break; + case CALLED_BY_HF1: // unterer Seitenrand + aUL.SetLower( USHORT( nPgLower ) ); + if( nNewValueSTP != nLastValueSTP ) + aUL.SetUpper( USHORT( nPgUpper ) ); + break; + default: // was wollen wir denn hier ??? + ASSERT( !this, "eCalledByWhom has undefined value" ); + break; + } + rPageFmt.SetAttr( aUL ); + } +} + +void SwW4WParser::UpdatePageMarginSettings( W4W_UpdtPgMrgSet eCalledByWhom ) +{ + BOOL bValueChanged = ( (nNewValueSTP != nLastValueSTP) + || (nNewValueSBP != nLastValueSBP) + || (nNewValueHTM != nLastValueHTM) + || (nNewValueHM != nLastValueHM ) + || (nNewValueFBM != nLastValueFBM) + || (nNewValueFM != nLastValueFM ) ); + if( ( !bValueChanged ) + && ( eCalledByWhom != CALLED_BY_HF2 ) + && ( eCalledByWhom != CALLED_BY_HF1 ) ) + { + return; + } + if( bValueChanged ) + { + /* Plausibilitaetspruefung, ggfs. Korrektur der W4W-Variablen: + + Wir pruefen, ob STP oder SBP etwa zu KLEIN werden, + wenn NUR die Werte HTM, HM, FBM oder FM geaendert wurden + und korrigieren dann ggfs. STP oder SBP, + da wir in diesem Fall von einem W4W-Fehler ausgehen. + + Wir pruefen NICHT, ob HTM, HM, FBM oder FM zu gross sind, + ===== + nachdem STP bzw. SBP veraendert wurden, + sondern lassen die Variablen in diesen Faellen unveraendert, + schalten aber dann im Writer den Header- bzw. Footer-Bereich aus. + Grund: so bleiben die Header-/Footer-Raender erhalten und + koennen bei spaeterer Reaktivierung des Header-/Footer-Bereichs + sofort wieder in die Berechnung einfliessen. + */ + + if( ( (nNewValueHTM != nLastValueHTM) + || (nNewValueHM != nLastValueHM ) + ) + && (nNewValueSTP == nLastValueSTP) ) + { + /* + Wenn HTM oder HM geaendert wurden, STP unveraendert blieb + und STP hierdurch zu klein wird, + wird STP um die Aenderungs-Differenz von HTM und HM + erhoeht. + Grund: die HOEHE des Kopfes veraendert sich, + wenn HTM oder HM veraendert werden, darf aber natuerlich + nicht negativ werden. Wir vermuten dann einen W4W-Fehler: + es wurde wohl vergessen STP anzupassen ! + */ + if( nNewValueSTP < nNewValueHTM + nNewValueHM ) + { + nNewValueSTP = + nLastValueSTP + ( nNewValueHTM + nNewValueHM) + - (nLastValueHTM + nLastValueHM); + } + } + // Fuss-Bereich + if( ( (nNewValueFBM != nLastValueFBM) + || (nNewValueFM != nLastValueFM ) + ) + && (nNewValueSBP == nLastValueSBP) ) + { + // ( Vorgehensweise analog zum Kopfbereich - s.o. ) + if( nNewValueSBP < nNewValueFBM + nNewValueFM ) + { + nNewValueSBP = + nLastValueSBP + ( nNewValueFBM + nNewValueFM) + - (nLastValueFBM + nLastValueFM); + } + } + } + + // Jetzt Abstaende tatsaechlich einstellen + if( pOpen1stPgPageDesc ) + SetPageDescVSpaces( *pOpen1stPgPageDesc, eCalledByWhom ); + SetPageDescVSpaces( *pPageDesc, eCalledByWhom ); + + // Aktualisieren der W4W-Variablen + nLastValueSTP = nNewValueSTP; + nLastValueSBP = nNewValueSBP; + nLastValueHTM = nNewValueHTM; + nLastValueHM = nNewValueHM ; + nLastValueFBM = nNewValueFBM; + nLastValueFM = nNewValueFM ; +} + + +void SwW4WParser::Read_SetTopMarginOfPage() // (STP) +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF2 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + // skip "Old top margin" and read "New Top margin" + long nNew; + if( nError + || W4WR_TXTERM != SkipPara() + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + { + nNewValueSTP = nOptNew; // in Twip + } + else + { + if( nDocType == 15 && !( nIniFlags & W4WFL_NO_PCTEXT4_STP_DEC2 ) ) + { + long nTw = ( nNew - 2 ) * 240; + if( nTw < 100 ) + nTw = 100; + nNewValueSTP = nTw; // PCText4 Korektur-Raten + } + else + { + nNewValueSTP = nNew * 240; // in 1/6 Inch + } + } +} + + +void SwW4WParser::Read_SetBottomMarginOfPage() // (SBP) +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF1 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + long nNew; + if( nError + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + nNewValueSBP = nOptNew; // in Twip + else + nNewValueSBP = nNew * 240; // in 1/6 Inch +} + + +void SwW4WParser::Read_HeaderTopMargin() // HTM +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF2 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + long nNew; + if( nError + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + nNewValueHTM = nOptNew; // in Twip + else + nNewValueHTM = nNew * 240; // in 1/6 Inch +} + + +void SwW4WParser::Read_HeadingMargin() // HM +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF2 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + long nNew; + if( nError + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + nNewValueHM = nOptNew; // in Twip + else + nNewValueHM = nNew * 240; // in 1/6 Inch +} + + +void SwW4WParser::Read_FooterBottomMargin() // FBM +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF1 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + long nNew; + if( nError + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + nNewValueFBM = nOptNew; // in Twip + else + nNewValueFBM = nNew * 240; // in 1/6 Inch +} + + +void SwW4WParser::Read_FooterMargin() // FM +{ + if( bStyleDef || bHeadFootDef || bFootnoteDef ) return; + + if ( bIsTxtInPgDesc && bWasTxtSinceLastHF1 && (nDocType != 15) ) + CreatePageDesc(CRPGD_AND_INSERT | CRPGD_UPDT_MRGN); + + long nNew; + if( nError + || W4WR_TXTERM != GetDecimal( nNew ) + || nError ) + return; + + long nOptNew; + // gibt es die optionale Angabe ? + if( ( W4WR_TXTERM == GetDecimal( nOptNew ) ) + && !nError ) + nNewValueFM = nOptNew; // in Twip + else + nNewValueFM = nNew * 240; // in 1/6 Inch +} + + +ULONG W4WReader::Read( SwDoc &rDoc, SwPaM &rPam, const String & ) +{ + if( pStrm || pStg ) + { + ASSERT( !this, + "W4W-Reader darf nur mit einem Medium aufgerufen werden" ); + return ERR_SWG_READ_ERROR; + } + else + // Stream darf auf gar keinen fall won irgend jemanden geoeffnet sein!!! + pMedium->CloseInStream(); + + // ist die DLL ueberhaupt vorhanden? + if( !W4WDLLExist( W4WDLL_IMPORT, GetFilter() ) ) + return ERR_W4W_DLL_ERROR | ERROR_SW_READ_BASE; + + String aTmpFile; + String sFileName( pMedium->GetPhysicalName() ); + ASSERT( sFileName.Len(), + "W4W-Reader hat keinen Dateinamen uebergeben bekommen" ); + if( !GetFilter() || !sFileName.Len() ) + return ERR_SWG_READ_ERROR; + +// ::StartProgress( STR_STATSTR_W4WREAD, 0, 100, rDoc.GetDocShell() ); + + ULONG nError = LoadFile( sFileName, GetFilter(), GetVersion(), aTmpFile ); + + if( !nError ) + { // dieser Block muss sein, damit das File geschlossen ist, + // wenn es nach Benutzung geloescht werden soll + + // den Stream kommt mit dem internen Format oeffnen + SfxMedium aMedium( aTmpFile, STREAM_READ, TRUE ); + SvStream* pStrm = aMedium.GetInStream(); + if( pStrm && SVSTREAM_OK == pStrm->GetError() ) + { + if( !bInsertMode ) + { + // MIB 27.09.96: Umrandung uns Abstaende aus Frm-Vorlagen entf. + Reader::ResetFrmFmts( rDoc ); + } + + SwW4WParser *pParser = new SwW4WParser( rPam, *pStrm, + !bInsertMode, GetFilter(), GetVersion() ); + if( !pParser->CallParser() ) +// !! hier muss der interne Fehler noch auf den SWG-Fehler gemappt werden !! + nError = ERR_SWG_READ_ERROR; + + delete pParser; // Fehlermeldungen werden immer + } // vom Parser selber ausgegeben + } + +// ::EndProgress( rDoc.GetDocShell() ); + + SWUnoHelper::UCB_DeleteFile( aTmpFile ); + + return nError; +} + +int W4WReader::GetReaderType() +{ + return bStorageFlag ? SW_STORAGE_READER : SW_STREAM_READER; +} + +// wir wollen die Streams / Storages nicht geoeffnet haben +int W4WReader::SetStrmStgPtr() +{ + return TRUE; +} + + +void W4WReader::SetFltName( const String& rFltName ) +{ + String sFilter( rFltName.Copy( 3 )); + xub_StrLen nPos = sFilter.Search( '_' ); + sVersion = sFilter.Copy( nPos + 1 ); + sFilter.Erase( nPos + 1 ); + if( 0 != ( bStorageFlag = 'C' == sFilter.GetChar( 0 ))) + sFilter.Erase( 0, 1 ); + + nFilter = sFilter.ToInt32(); +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4wpar2.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar2.cxx new file mode 100644 index 000000000000..4519aedf9ef3 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar2.cxx @@ -0,0 +1,3982 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdio.h> //dort ist EOF (-1) definiert + +#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER + +#include <hintids.hxx> + +#include <bf_svx/paperinf.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/shaditem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/adjitem.hxx> +#include <bf_svx/brkitem.hxx> +#include <bf_svtools/svarray.hxx> +#include <tools/urlobj.hxx> +#include <bf_svx/unolingu.hxx> +#include <unotools/localedatawrapper.hxx> + +#include <fmtclds.hxx> +#include <fmtornt.hxx> +#include <fmtfsize.hxx> +#include <fmtornt.hxx> +#include <fmtanchr.hxx> +#include <fmtflcnt.hxx> +#include <fmtcntnt.hxx> +#include <fmthdft.hxx> +#include <txtftn.hxx> +#include <fmtpdsc.hxx> +#include <fmtftn.hxx> +#include <fmtsrnd.hxx> +#include <frmatr.hxx> +#include <docary.hxx> +#include <numrule.hxx> +#include <paratr.hxx> +#include <section.hxx> +#include <pam.hxx> // fuer SwPam +#include <doc.hxx> +#include <ndtxt.hxx> +#include <node.hxx> // SwTableNode +#include <shellio.hxx> +#include <fmtcol.hxx> +#include <pagedesc.hxx> +#include <ftninfo.hxx> // SwFtnInfo +#include <swtable.hxx> // GetTabLines(), ... +#include <grfatr.hxx> +#include <tox.hxx> +#include <ndgrf.hxx> +#include <w4wstk.hxx> // fuer den Attribut Stack +#include <w4wpar.hxx> +#include <w4wgraf.hxx> +#include <tblsel.hxx> // SwSelBoxes +#include <viewsh.hxx> +#include <shellres.hxx> +#include "bf_so3/staticbaseurl.hxx" +namespace binfilter { + + +// Aktivierung der LR-Rand-Einstellungen fuer Kopf-/Fusszeilen +#define HDFT_MARGIN + + + +#define MOGEL_WW2 + + // 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 + +#define DEFAULT_TAB_CELL_DISTANCE 42 // Default: 0.7 mm Abstand + + +SV_DECL_PTRARR_DEL(W4WTabBorders, UShortPtr, 64, 64)//STRIP008 ; +SV_IMPL_PTRARR( W4WTabBorders, UShortPtr ); + +typedef SwSelBoxes_SAR* SwSelBoxes_SARPtr; + +SV_DECL_PTRARR_DEL(W4WMergeGroups, SwSelBoxes_SARPtr, 16,16)//STRIP008 ; +SV_IMPL_PTRARR( W4WMergeGroups, SwSelBoxes_SARPtr ); + +inline const SwNodeIndex & PtNd( const SwPaM * pPam ) + { return pPam->GetPoint()->nNode; } +inline SwNodeIndex & PtNd( SwPaM* pPam ) + { return pPam->GetPoint()->nNode; } +inline const SwIndex & PtCnt( const SwPaM * pPam ) + { return pPam->GetPoint()->nContent; } +inline SwIndex & PtCnt( SwPaM* pPam ) + { return pPam->GetPoint()->nContent; } + + +static BOOL JoinNode( SwPaM* pPam ) +{ + pPam->GetPoint()->nContent = 0; + // an den Anfang der Zeile gehen + if ( !pPam->Move( fnMoveBackward, fnGoCntnt ) ) + { + return FALSE; // Cursor geht nicht zurueck + } + + SwNode* pNd = pPam->GetDoc()->GetNodes()[ PtNd(pPam) ]; + + if( pNd->FindTableNode() || !pNd->IsCntntNode() ) + { + return FALSE; // hier wuerde JoinNext abstuerzen + } + + ((SwCntntNode*)pNd)->JoinNext(); + + return TRUE; +} + + +/**************************************************************************** +Indicex: Gliederung, Stichwortverzeichnis ... +*****************************************************************************/ + +void SwW4WParser::Read_BeginMarkedText() // (BMT) +{ + BYTE nType; + USHORT nStrLen = 0; + bToxOpen = TRUE; + + if ( bStyleDef || bStyleOnOff ) return; + + if( GetHexByte( nType ) && !nError ) + { + BOOL bOldTxtInDoc = bTxtInDoc; bTxtInDoc = FALSE; + + if( W4WR_TXTERM == GetNextRecord() && !nError ){ // lese opt. Namen + nStrLen = nChrCnt; // Stringlaenge merken + Flush(); // '\0' hinter Namen setzen + } + bTxtInDoc = bOldTxtInDoc; + + TOXTypes eTox; + if ( nType <= 0x1f ) eTox = TOX_CONTENT; + else if ( nType <= 0x3f ) eTox = TOX_INDEX; + else eTox = TOX_USER; // TOX_USER eigentlich + + + BYTE nNum = 0; + + if( 33 == nDocType ) // W4W ist bei anderen Doc-Typen + { // noch nicht konsistent + nNum = (nType & 0x1f); + + const USHORT nMaxLevel = SwForm::GetFormMaxLevel( eTox ); + + if( nNum >= nMaxLevel ) + nNum = nMaxLevel-1; + + /* + * Achtung - AmiPro-Hack: + * + * wenn ein .<BMT> in einem Bereich auftaucht, der ueber + * einen Style formatiert ist, werten wir eTox aus: + * Falls es ein Gliederungs-Eintrag sein soll, weisen + * wir dem Style die entsprechende Gliederungs-Stufe zu. + * + */ + if( (USHRT_MAX != nAktStyleId) && (TOX_CONTENT == eTox) ) + { + SwTxtFmtColl* pAktColl = GetAktColl(); + ASSERT( pAktColl, "StyleId ungueltig" ); + + const SwTxtFmtColls* pDocTxtFmtColls = pDoc->GetTxtFmtColls(); + + BOOL bSchonDa = FALSE; + for(USHORT i = 0; i < pDocTxtFmtColls->Count(); i++ ) + { + if( nNum == pDocTxtFmtColls->GetObject( i )->GetOutlineLevel() ) + { + if( pAktColl == pDocTxtFmtColls->GetObject( i ) ) + { + return; // Style hat schon diese Gliederungstiefe + } + bSchonDa = TRUE; + break; + } + } + if( !bSchonDa ) + { + pAktColl->SetOutlineLevel( nNum ); + return; + // untenstehende 'harte' Verz.-Markierung nicht noetig + } + } + } + + USHORT nTOXCount = pDoc->GetTOXTypeCount( eTox ); + if( !nTOXCount ) + pDoc->InsertTOXType( + SwTOXType( eTox, SwTOXBase::GetTOXName( eTox ) ) ); + + const SwTOXType* pT = pDoc->GetTOXType( eTox, 0 ); + + SwTOXMark aM( pT ); + + if( TOX_INDEX != eTox ) // SetLevel geht nicht bei Stichwortverz. + { + aM.SetLevel( nNum ); + } + + if ( nStrLen != 0 ) // Text mit angegeben + { + aM.SetAlternativeText( String( aCharBuffer ) ); + pDoc->Insert( *pCurPaM, aM ); + }else + { + pCtrlStck->NewAttr( *pCurPaM->GetPoint(), aM ); + bToxOpen = TRUE; + } + } +} + + +void SwW4WParser::Read_EndMarkedText() //(EMT) +{ + BYTE nType; + + if( bToxOpen && GetHexByte( nType ) && !nError ) + { + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_TXTATR_TOXMARK ); + bToxOpen = FALSE; + } +} + + +// returnt den abs. Rand der Seite (SeitenRand+NodeRand) ( fuer Tabs ) + + +long SwW4WParser::GetLeftMargin() const +{ + // gebe die Groesse und die Raender der Seite aus + const SvxLRSpaceItem * pNdLR; + if ( bStyleDef ) + pNdLR = &GetAktColl()->GetLRSpace(); + else + pNdLR = (const SvxLRSpaceItem*)pCtrlStck->GetFmtAttr( *pCurPaM, + RES_LR_SPACE ); + //!!! findet manchmal nicht das richtige LRSpace + // anscheinend dann, wenn das Attr nicht direkt am Absatz klebt, + // sondern ueber ein Style gueltig ist. + return nPgLeft + pNdLR->GetTxtLeft(); +} + + + +/*************************************************************************************** +nummerierte Listen +***************************************************************************************/ + +void SwW4WParser::Read_ParagraphNumber() // (PGN) +{ + if( !bFootnoteDef ) + { + if( ( 44 != nDocType ) // nur WinWord 2 + && ( 48 != nDocType ) ) return; // und WordPerfekt 6-8 + + // ACHTUNG: in Style-Definitionen alles ignorieren und bis + // zum .<EPN> ueberlesen, denn der Kode wird von W4W in den + // ueber diesen Style definierten Absaetzen wiederholt... + if( !bStyleDef ) + { + // falls kein .<PND>-Kode , alles ignorieren !!! + if( pActNumRule ) + { + BYTE nLevel; + if( GetDeciByte( nLevel ) && !nError ) + { + if( MAXLEVEL < nLevel ) + nActNumLevel = MAXLEVEL-1; + else + nActNumLevel = nLevel -1; + + SwTxtNode* pTxtNode = pCurPaM->GetNode()->GetTxtNode(); + ASSERT( pTxtNode, "Kein Text-Node an PaM-Position" ); + + pTxtNode->SwCntntNode::SetAttr( + SwNumRuleItem( pActNumRule->GetName() ) ); + + pTxtNode->UpdateNum( SwNodeNum( nActNumLevel ) ); + + if( 44 == nDocType ) + pTxtNode->SetNumLSpace( FALSE ); // TRUE ist Defaultwert + + bWasPGNAfterPND = TRUE; + bIsNumListPara = TRUE; + } + } + } + } + /* + Das wars: nun alles bis zum naechsten .<EPN> ueberspringen + */ + BOOL bOldNoExec = bNoExec; + BOOL bOldTxtInDoc = bTxtInDoc; + bNoExec = TRUE; + bTxtInDoc = FALSE; + while( ( !nError ) + && ( EOF != GetNextRecord() ) + && !( pActW4WRecord + && ( pActW4WRecord->fnReadRec + == &SwW4WParser::Read_EndOfParaNum ))) + { + /*NOP*/; + } + /* + In Fussnoten wird ein evtl. unmittelbar + nach der Nummerierung folgender TAB ignoriert + */ + if( bFootnoteDef && !nError ) + { + ULONG nOldPos = rInp.Tell(); // FilePos merken + GetNextRecord(); + if( pActW4WRecord + && ( pActW4WRecord->fnReadRec != &SwW4WParser::Read_Tab ) ) + { + rInp.Seek( nOldPos ); // FilePos restaurieren + } + } + bNoExec = bOldNoExec; + bTxtInDoc = bOldTxtInDoc; + nChrCnt = 0; + aCharBuffer[ nChrCnt ] = 0; +} + + +void SwW4WParser::Read_EndOfParaNum() // (EPN) +{ + /*NOP*/; +} + + +void SwW4WParser::Read_ParaNumberDef() // (PND) +{ + if( bFootnoteDef || bStyleDef ) return; + + if( ( 44 != nDocType ) // nur WinWord 2 + && ( 48 != nDocType ) ) return; // und WordPerfekt 6-8 funktionieren + + BYTE nLevels = 0; + + // Lies die Anzahl der Nummerierungs-Stufen + if( ( !GetDeciByte( nLevels ) ) + || nError + || !nLevels ) + { + return; + } + + if( MAXLEVEL < nLevels ) nLevels = MAXLEVEL; + + /* + Pruefe, ob nach dem vorigen .<PND> ueberhaupt ein .<PGN> kam. + */ + SwNumRule* pMyNumRule; + if( pActNumRule && !bWasPGNAfterPND ) + { + // alte Liste muss geloescht werden + // ( geht nur, weil die Rule noch von niemand benutzt wird! ) + pDoc->DelNumRule( pActNumRule->GetName() ); + pActNumRule = 0; + } + + // neue NumRule anlegen + String aPrefix( String::CreateFromAscii( + RTL_CONSTASCII_STRINGPARAM( "W4WNum" ))); + USHORT nPos = pDoc->MakeNumRule( pDoc->GetUniqueNumRuleName( &aPrefix ) ); + pMyNumRule = pDoc->GetNumRuleTbl()[ nPos ]; + + /* + Lies die Parameter fuer alle Nummerierungs-Stufen + und setze sie in pMyNumRule ein + */ + long nW4WStartNo; // b + String aPrefixTxt; // c + BYTE nW4WType; // d + long nNoWidth; // e + String aSuffixTxt; // f + BYTE nW4WAttachPrev; // g + + USHORT nStartNo; // Start-Nr. fuer den Writer + BYTE nUpperLevel; // aktuelle Anzeigetiefe fuer den Writer + SvxExtNumType eType; // Writer-Num-Typ + + BOOL bError = TRUE; + for( USHORT nActLevel = 0; nActLevel < nLevels; nActLevel++ ) + { + bError = TRUE; + + // Parameter lesen + if( ( !GetDecimal( nW4WStartNo ) ) || nError ) break; + if( ( !GetString( aPrefixTxt, + W4WR_TXTERM, W4WR_TXTERM ) ) ) break; + if( ( !GetDeciByte( nW4WType ) ) || nError ) break; + if( ( !GetDecimal( nNoWidth ) ) || nError ) break; + if( ( !GetString( aSuffixTxt, + W4WR_TXTERM, W4WR_TXTERM ) ) ) break; + if( ( !GetDeciByte( nW4WAttachPrev ) ) || nError ) break; + + // Parameter auswerten + if( 0 > nW4WStartNo ) + nStartNo = 0; + else + nStartNo = (USHORT)nW4WStartNo; + if( nW4WAttachPrev ) + { + // Achtung: sind auch vorige Numm.-Zeichen anzuzeigen, + // so darf das Prefix-Zeichen NICHT gezeigt werden, + // da der Writer es sonst vor die GESAMTE Zeichenkette malt. + aPrefixTxt = aEmptyStr; + nUpperLevel++ ; + } + else + nUpperLevel = 1; + switch( nW4WType ) + { + case 1: eType = SVX_NUM_NUMBER_NONE; break; + case 2: eType = SVX_NUM_CHARS_LOWER_LETTER; break; + case 3: eType = SVX_NUM_CHARS_UPPER_LETTER; break; + case 4: eType = SVX_NUM_ROMAN_LOWER; break; + case 5: eType = SVX_NUM_ROMAN_UPPER; break; + default: + // pruefen auf Werte groesser 5 + ASSERT( !nW4WType, "Value of nW4WType is not supported" ); + // sonst default-Wert + eType = SVX_NUM_ARABIC; + break; + } + + // aNumFmt erzeugen, + SwNumFmt aNumFmt( pMyNumRule->Get( nActLevel ) ); + // konfigurieren + aNumFmt.SetStart( nStartNo ); + aNumFmt.SetPrefix( aPrefixTxt ); + aNumFmt.SetNumberingType(eType ); + aNumFmt.SetSuffix( aSuffixTxt ); + aNumFmt.SetIncludeUpperLevels( nUpperLevel ); + // und in die pMyNumRule aufnehmen + pMyNumRule->Set( nActLevel, aNumFmt ); + + bError = FALSE; + } + + // Dumm: bei WinWord 2 wird vor jedem .<PGN> nochmals + // die komplette .<PND>-Geschichte wiederholt. + // Wir duerfen dann natuerlich nicht jedesmal eine neue Liste + // aufmachen, sondern muessen die alte Liste weiterfuehren. + if( ( 44 == nDocType ) && pActNumRule && !bError ) + { + BOOL bIdentical = TRUE; + for( USHORT nLev = 0; nLev < nLevels; nLev++ ) + { + if( pActNumRule->Get( nLev ) != pMyNumRule-> Get( nLev ) ) + { + bIdentical = FALSE; + break; + } + } + if( bIdentical ) bError = TRUE; + } + + if( bError ) + { + // bearbeitete Liste loeschen + // ( geht nur, weil die Rule noch von niemand benutzt wird! ) + pDoc->DelNumRule( pMyNumRule->GetName() ); + } + else + { + // bearbeitete Liste erhalten und zur aktuellen Liste erklaeren + pActNumRule = pMyNumRule; + pActNumRule->SetInvalidRule( TRUE ); + bWasPGNAfterPND = FALSE; + } +} + + + + +/*************************************************************************************** + +***************************************************************************************/ + + + +BOOL SwW4WParser::GetLRULHint( const SfxPoolItem*& rpH, RES_FRMATR eTyp ) +{ + if ( bStyleDef ) + { + rpH = &GetAktColl()->GetAttr( eTyp ); + } + else + { + USHORT nIdx; + SfxPoolItem* pH = pCtrlStck->GetFmtStkAttr( eTyp, &nIdx ); + + if (pH && (*pCtrlStck)[nIdx]->nPtNode.GetIndex()+1 + == pCurPaM->GetPoint()->nNode.GetIndex()) + { + // LRUL-Space zu diesem Absatz bereits auf Stack + // -> modifizieren + rpH = pH; + return FALSE; // new( rpLR ) nicht noetig + } + else + { + // LRUL-Space zu diesem Absatz nicht auf Stack + // -> neuen Copy-Konstruieren + rpH = (SfxPoolItem*)pCtrlStck->GetFmtAttr( *pCurPaM, eTyp ); + } + } + return TRUE; // new( rpH ) noetig +} + + +BOOL SwW4WParser::GetULSpace( SvxULSpaceItem*& rpUL ) +{ + const SfxPoolItem* pH = 0; + BOOL bRet = GetLRULHint( pH, RES_UL_SPACE ); + if ( bRet ) rpUL = new SvxULSpaceItem( *((SvxULSpaceItem*)pH) ); + else rpUL = (SvxULSpaceItem*)pH; + return bRet; // TRUE -> delete( rpUL ) noetig +} + + +void SwW4WParser::Read_SetSpaceBefore() // (SBF) +{ + long nSpaceTw; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_UL_SPACE ); + return; + } + if ( !bPageDefRdy ) return; + + if( GetDecimal( nSpaceTw ) && !nError ){ + SvxULSpaceItem* pUL = 0; + BOOL bRet = GetULSpace( pUL ); + pUL->SetUpper( USHORT(nSpaceTw) ); + if ( bRet ){ + SetAttr( *pUL ); + DELETEZ( pUL ); + } + } +} + + +void SwW4WParser::Read_SetSpaceAfter() // (SAF) +{ + long nSpaceTw; + + if ( bStyleOnOff ){ // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_UL_SPACE ); + return; + } + if ( !bPageDefRdy ) return; + + if( GetDecimal( nSpaceTw ) && !nError ){ + SvxULSpaceItem* pUL = 0; + BOOL bRet = GetULSpace( pUL ); + pUL->SetLower( USHORT(nSpaceTw) ); + if ( bRet ){ + SetAttr( *pUL ); + DELETEZ( pUL ); + } + } +} + +/*************************************************************************************** +Absolute Positioned Objects und Graphiken +***************************************************************************************/ + + +void lcl_SetFlyAttr( SfxItemSet& rSet, + SwHoriOrient eHAlign, + SwVertOrient eVAlign, + long nWidthTw, long nHeightTw, long nULHCx, long nULHCy, + BOOL bAuto = FALSE, + SwRelationOrient eHRel = PRTAREA, + SwRelationOrient eVRel = PRTAREA ) +{ + if ( nHeightTw <= MINFLY ) bAuto = TRUE; + + // Groesse einstellen + rSet.Put( SwFmtFrmSize( ( bAuto ) ? ATT_MIN_SIZE : ATT_FIX_SIZE, + nWidthTw, nHeightTw )); + + rSet.Put( SwFmtVertOrient( nULHCy, eVAlign, eVRel ) ); + rSet.Put( SwFmtHoriOrient( nULHCx, eHAlign, eHRel ) ); +} + + + +SwFmtFrmSize& lcl_AdjustFlySize( Size& rSize, + SwFmtFrmSize& rFlySize, + BOOL bSetGrfTwipWidth, + BOOL bSetGrfTwipHeight, + long nGrWidthTw, + long nGrHeightTw, + USHORT nHoriDelta = 0, + USHORT nVertiDelta = 0 ) +{ + if( !rSize.Width() ) + rSize = Size( 567*2, 567/2 ); + if( bSetGrfTwipWidth && bSetGrfTwipHeight ) + { + // Breite *und* Hoehe anpassen... + rFlySize.SetWidth( rSize.Width() +nHoriDelta ); + rFlySize.SetHeight(rSize.Height()+nVertiDelta); + } + else + { + // Breite anpassen und Proportionen erhalten... + if( bSetGrfTwipWidth ) + { + long nSzH = rSize.Height(); + rFlySize.SetWidth( + rSize.Width() * nGrHeightTw + / (nSzH ? nSzH : nGrHeightTw) + +nHoriDelta ); + } + // Hoehe anpassen und Proportionen erhalten... + else + { + long nSzW = rSize.Width(); + rFlySize.SetHeight( + rSize.Height() * nGrWidthTw + / (nSzW ? nSzW : nGrWidthTw) + +nVertiDelta ); + } + } + return rFlySize; +} + + + +void SwW4WParser::Read_Picture() // (PCT) +{ + UpdatePercent( rInp.Tell(), nW4WFileSize ); + + long nBadLen; + + bPic = TRUE; // PCT-Komando angekommen + if ( !bPicPossible ) return; + if ( !pGraf) + pGraf = new SwW4WGraf( rInp ); + + // Wenn Type != 0 dann ueberlies falsche Laengenangabe + if( ( nGrafPDSType == 1 ) + && ( !GetDecimal( nBadLen ) || nError ) ) + return; + pGraf->Read( nGrafPDSType, nGrWidthTw, nGrHeightTw ); + pGraphic = pGraf->GetGraphic(); +} + + + +SwFlyFrmFmt* SwW4WParser::MakeTxtFly( RndStdIds eAnchor, + const SfxItemSet& rSet ) +{ + SwFlyFrmFmt* pFlyFmt = pDoc->MakeFlySection( eAnchor, + pCurPaM->GetPoint(), &rSet ); + + // der Anker ist der SPoint vom Pam. Dieser wird beim Einfugen + // von Text usw. veraendert, darum speicher ihn auf dem Attribut + // Stack. Das Attribut muss vom Format erfragt werden, + // damit das Format auch spaeter bekannt ist !!! + if( FLY_IN_CNTNT != eAnchor ) + pCtrlStck->NewAttr( *pCurPaM->GetPoint(), SwW4WAnchor( pFlyFmt ) ); + return pFlyFmt; +} + +void SwW4WParser::FlySecur( BOOL bAlignCol, + long& rXPos, long& rYPos, + long& rWidthTw, long& rHeightTw, + RndStdIds& rAnchor, + long* pTop, long* pLeft, long* pBot, + long* pRight, USHORT nBorderCode ) +{ + if ( rYPos < 0 ) + rYPos = 0; + if ( rXPos < 0 ) + { + switch ( rAnchor ) + { + case FLY_IN_CNTNT: rAnchor = FLY_AT_CNTNT; break; + case FLY_PAGE: rXPos = 0; break; + } + } + + if ( nBorderCode ) // mit Umrandung + { + if( rWidthTw < MINFLY + 2 * MAX_BORDER_SIZE ) + { + if( !rWidthTw ) // 0 == volle Breite (z.B. WW2) + rWidthTw = (long)(nPgRight - rXPos) - 2 * MAX_BORDER_SIZE; + else + rWidthTw = MINFLY + 2 * MAX_BORDER_SIZE; + } + + if ( rHeightTw < MINFLY + MAX_BORDER_SIZE ) + rHeightTw = MINFLY + MAX_BORDER_SIZE; + } + else // ohne Umrandung + { + if ( rWidthTw < MINFLY + MAX_EMPTY_BORDER ) + { + if( !rWidthTw ) // 0 == volle Breite (z.B. WW2) + rWidthTw = (long)(nPgRight - rXPos) - 2 * MAX_EMPTY_BORDER; + else + rWidthTw = MINFLY + 2 * MAX_EMPTY_BORDER; + } + if ( rHeightTw < MINFLY + MAX_EMPTY_BORDER ) + rHeightTw = MINFLY + MAX_EMPTY_BORDER; + } +} + + +void SwW4WParser::Read_IncludeGraphic() // (IGR) +{ + String aPath; + BYTE nType; + + long nWidthTw = 0; + long nHeightTw = 0; + + if( GetString( aPath, W4WR_TXTERM, W4WR_TXTERM ) && !nError + && GetChar( nType ) && !nError ) + { + // versuchen, ebenfalls die Breite und Hoehe zu lesen + BOOL bSetGrfTwipWidth + = ( ( W4WR_TXTERM != GetDecimal( nWidthTw ) ) || !nError ); + + BOOL bSetGrfTwipHeight = FALSE; + + if( !bSetGrfTwipWidth ) + { + bSetGrfTwipHeight + = ( ( W4WR_TXTERM != GetDecimal( nHeightTw ) ) || !nError ); + } + bSetGrfTwipWidth |= ( !nWidthTw ); + bSetGrfTwipHeight |= ( !nHeightTw ); + + // wichtig: eins zurueck gehen + rInp.SeekRel( - 1 ); + + // ggfs fuehrende und anhaengende Blanks entfernen + aPath.EraseAllChars(); + // ggfs. Anfuehrungszeichen entfernen + if( '"' == aPath.GetChar( 0 ) ) + aPath.Erase( 0, 1 ); + if( '"' == aPath.GetChar(aPath.Len()-1) ) + aPath.Erase( aPath.Len()-1 ); + + // Stil der uebergebenen Zeichenkette beruecksichtigen + INetURLObject::FSysStyle eParser = INetURLObject::FSYS_DETECT; + switch( nType ) + { + case 1: eParser = INetURLObject::FSYS_DOS; break; + case 2: eParser = INetURLObject::FSYS_MAC; break; + case 3: eParser = INetURLObject::FSYS_UNX; break; + } + INetURLObject aEntry( aPath, eParser ); + aPath = ::binfilter::StaticBaseUrl::RelToAbs( aEntry.GetFull() ); + + SfxItemSet aFlySet( pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1); + + // Art der Bindung einstellen + SwFmtAnchor aAnchor( FLY_IN_CNTNT ); // als Buchstaben + aAnchor.SetAnchor( pCurPaM->GetPoint() ); + aFlySet.Put( aAnchor ); + + // Groesse einstellen + if( bSetGrfTwipWidth ) nWidthTw = 567*2; + if( bSetGrfTwipHeight ) nHeightTw = 567/2; + aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidthTw, nHeightTw ) ); + + // Link auf die Grafik einsetzen + SwFlyFrmFmt* pFlyFmt + = pDoc->Insert( *pCurPaM, + aPath, aEmptyStr, // Name der Grafik !! + 0, // Zeiger auf die Grafik + &aFlySet, // Attr. fuer FlyFrm + 0 ); // Attr. fuer die Grafik + + // ggfs Laenge und/oder Breite korrigieren + if( bSetGrfTwipWidth || bSetGrfTwipHeight ) + { + SwGrfNode *pGrfNd + = pDoc->GetNodes()[ pFlyFmt->GetCntnt(). + GetCntntIdx()->GetIndex()+1 ] + ->GetGrfNode(); + if( pGrfNd->IsGrafikArrived() ) + { + Size aSize( pGrfNd->GetTwipSize() ); + SwFmtFrmSize aFlySize( pFlyFmt->GetFrmSize() ); + pFlyFmt->SetAttr( + lcl_AdjustFlySize( aSize, aFlySize, + bSetGrfTwipWidth, bSetGrfTwipHeight, + nWidthTw, nHeightTw ) ); + } + else + pGrfNd->SetChgTwipSize( TRUE ); + } + } +} + +void SwW4WParser::Read_PictureDef() // (PDS) +{ + long nType, nFixFloat, nXPos, nYPos, nOptWidthOrig = 0, nOptHeightOrig = 0; + + long nOldW = nGrWidthTw; + long nOldH = nGrHeightTw; + + if( GetDecimal( nType ) && !nError && GetDecimal( nFixFloat ) && !nError + && GetDecimal( nXPos ) && !nError && GetDecimal( nYPos ) && !nError + && GetDecimal( nGrWidthTw ) && !nError && GetDecimal( nGrHeightTw ) + && !nError ) + { + if( W4WR_TXTERM != GetDecimal( nOptWidthOrig ) || nError // Fehlen Opt. Parameter ? + || W4WR_TXTERM != GetDecimal( nOptHeightOrig ) || nError) + {}// do nothing + nGrafPDSType = nType; + + if ( bPicPossible ) // APO mit genaueren Angaben bereits vorhanden + return; + + BOOL bOldPoss = bPicPossible; bPicPossible = TRUE; + BOOL bOldTxtInDoc = bTxtInDoc; bTxtInDoc = FALSE; + bPic = FALSE; + + while (!nError && !bPic // lies Grafik ein + && (EOF != GetNextRecord())) // bis PCT //$ EOF + ; + + bPicPossible = bOldPoss; + bPic = FALSE; + + RndStdIds eAnchor = ( nFixFloat ) ? FLY_PAGE : FLY_IN_CNTNT; + + if ( ( nIniFlags & W4WFL_NO_GRAF_IN_CNTNT ) + && ( eAnchor == FLY_IN_CNTNT ) ) + eAnchor = FLY_AT_CNTNT; //!!! Workaround fuer u.a. Panne + + + FlySecur( FALSE, nXPos, nYPos, nGrWidthTw, nGrHeightTw, eAnchor ); + + SfxItemSet aFlySet( pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1); + if( !bNew ) + Reader::ResetFrmFmtAttrs( aFlySet ); + SwFmtAnchor aAnchor( eAnchor ); + aAnchor.SetAnchor( pCurPaM->GetPoint() ); + aFlySet.Put( aAnchor ); + lcl_SetFlyAttr( aFlySet, HORI_LEFT, VERT_TOP, + nGrWidthTw, nGrHeightTw, nXPos, nYPos, FALSE, + PRTAREA, + FRAME ); + + if( pGraphic ) // Grafik korrekt eingelesen + pDoc->Insert( *pCurPaM, + aEmptyStr, aEmptyStr, // Name der Grafik !! + pGraphic, + &aFlySet, // Attribute fuer den FlyFrm + 0 ); // Attribute fuer die Grafik + + else // Keine Grafik -> Text-FlyFrame + MakeTxtFly( eAnchor, aFlySet ); + + if ( pGraf ) DELETEZ( pGraf ); + + if ( nOldW < nGrWidthTw ) nOldW = nGrWidthTw; // umgebenden Rahmen evtl. + if ( nOldH < nGrHeightTw ) nOldH = nGrHeightTw; // vergroessern bis er + // passt + bTxtInDoc = bOldTxtInDoc; + } + nGrWidthTw = nOldW; + nGrHeightTw = nOldH; +} + + +void SwW4WParser::Read_BeginAbsPosObj() // (APO) +{ + long nAnchor, nVAlign, nHAlign, nAlignType, nWrap, + nULHCx, nULHCy, nTop, nLeft, nBot, nRight, + nOptShade = 0, nOptVPos, nOptPathFormat = 1; + BYTE nType; + + if ( bStyleDef || bStyleOnOff ) return; + + long nOldW = nGrWidthTw; + long nOldH = nGrHeightTw; + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + + if( GetHexByte( nType ) && !nError // a + && GetDecimal( nAnchor ) && !nError // b + && GetDecimal( nVAlign ) && !nError // c + && GetDecimal( nHAlign ) && !nError // d + && GetDecimal( nAlignType ) && !nError // e + && GetDecimal( nWrap ) && !nError // f + && GetDecimal( nGrWidthTw ) && !nError // g + && GetDecimal( nGrHeightTw) && !nError // h + && GetDecimal( nULHCx ) && !nError // i + && GetDecimal( nULHCy ) && !nError // j + && GetDecimal( nTop ) && !nError // k + && GetDecimal( nLeft ) && !nError // l + && GetDecimal( nBot ) && !nError // m + && GetDecimal( nRight ) && !nError // n + && GetHexUShort( nApoBorderCode ) && !nError ) // o + { + if ( W4WR_TXTERM == GetDecimal( nOptShade ) && !nError // p + && W4WR_TXTERM == GetDecimal( nOptVPos ) && !nError // q + && W4WR_TXTERM == GetNextRecord() && !nError // r + && W4WR_TXTERM != GetDecimal( nOptPathFormat ) ) // s + {}// do nothing + + + // '\0x00' hinter Dateinamen setzen + Flush(); + + // eventuell noch folgende Parameter ueberlesen + rInp.SeekRel( - 1 ); + SkipEndRecord(); + + + BOOL bSetGrfTwipWidth = !nGrWidthTw; + BOOL bSetGrfTwipHeight = !nGrHeightTw; + + static const RndStdIds nAnchorTab[]={ FLY_AT_CNTNT, // Absatz + FLY_PAGE, // Seite + FLY_IN_CNTNT }; // Buchstabe + if ( nAnchor >= sizeof(nAnchorTab)/sizeof(RndStdIds)) nAnchor = 0; + + RndStdIds eAnchor = nAnchorTab[ nAnchor ]; + + if ( ( nIniFlags & W4WFL_NO_FLY_IN_CNTNT ) + && ( eAnchor == FLY_IN_CNTNT ) ) + eAnchor = FLY_AT_CNTNT; // Workaround fuer u.a. Panne + + // anchor "at page" in header / footer must change to "at Content" + if( FLY_PAGE == eAnchor && + pDoc->IsInHeaderFooter( pCurPaM->GetPoint()->nNode )) + { + eAnchor = FLY_AT_CNTNT; + nULHCy = 0; + } + + FlySecur( (1 == nAlignType), nULHCx, nULHCy, nGrWidthTw, nGrHeightTw, eAnchor, + &nTop, &nLeft, &nBot, &nRight, nApoBorderCode ); + + nGrafPDSType = 0; + + static const SwVertOrient nVAlignTab[]={ VERT_NONE, VERT_TOP, + VERT_CENTER, VERT_BOTTOM, + VERT_NONE }; + if ( nVAlign >= sizeof(nVAlignTab)/sizeof(SwVertOrient)) nVAlign = 0; + SwVertOrient eVAlign = nVAlignTab[ nVAlign ]; + + static const SwHoriOrient nHAlignTab[]={ HORI_LEFT, HORI_RIGHT, + HORI_CENTER, HORI_NONE}; + if ( nHAlign >= sizeof(nHAlignTab)/sizeof(SwHoriOrient)) + nHAlign = 3; + SwHoriOrient eHAlign = nHAlignTab[ nHAlign ]; + + SwRelationOrient eHRel = ( 2 == nAlignType ) ? FRAME : PRTAREA; + SwRelationOrient eVRel = eHRel; + + if( ( eHRel == FRAME ) && ( eAnchor == FLY_AT_CNTNT ) ) + nULHCx -= nPgLeft; + + if( ( ( nULHCx > 50 ) + || ( nULHCx < -50 ) ) + && ( eHAlign == HORI_LEFT ) ) + { + eHAlign = HORI_NONE; // linksbuendig mit Offset + } + + if( ( ( nULHCy > 50 ) + || ( nULHCy < -50 ) ) + && ( eVAlign == VERT_TOP ) ) + { + eVAlign = VERT_NONE; // obenbuendig mit Offset + } + + if( HORI_NONE == eHAlign ) + eHRel = FRAME; + + if( VERT_NONE == eVAlign ) + eVRel = FRAME; + + SfxItemSet aFlySet( pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1); + lcl_SetFlyAttr( aFlySet, eHAlign, eVAlign, nGrWidthTw, nGrHeightTw, + nULHCx, nULHCy, + ( bSetGrfTwipWidth || bSetGrfTwipHeight ), + eHRel, + eVRel ); + + aFlySet.Put( SwFmtSurround( (nWrap) ? SURROUND_PARALLEL + : SURROUND_NONE ) ); + + USHORT nHoriDelta = 0; + USHORT nVertiDelta = 0; + { + SvxBoxItem aBox; + + // Raender nach *innen* + aBox.SetDistance( (USHORT)nLeft, BOX_LINE_LEFT ); + aBox.SetDistance( (USHORT)nTop, BOX_LINE_TOP ); + aBox.SetDistance( (USHORT)nRight, BOX_LINE_RIGHT ); + aBox.SetDistance( (USHORT)nBot, BOX_LINE_BOTTOM ); + + USHORT nRet = Read_SetBorder( nApoBorderCode, aBox ); + if( nRet ) + { + // evtl Umrandung setzen + if( 0 != ( 0x1 & nRet )) + aFlySet.Put( aBox ); + // evtl Hintergrund setzen + if( 0 != ( 0x2 & nRet )) + { + const Color aCol( COL_LIGHTGRAY ); + aFlySet.Put( SvxBrushItem( aCol, RES_BACKGROUND )); + } + + // ggfs. Schatten setzen + if( nOptShade ) + { // fShadow + SvxShadowItem aS; + aS.SetColor( Color( COL_GRAY )); + aS.SetWidth( (USHORT)nOptShade*3 ); + aS.SetLocation( SVX_SHADOW_BOTTOMRIGHT ); + aFlySet.Put( aS ); + } + + /* + horizontale Randbreite errechnen + */ + nHoriDelta += ( 2 * aBox.GetDistance() ); + const SvxBorderLine* pBoxLn = aBox.GetLeft(); + if( pBoxLn ) + { + nHoriDelta += pBoxLn->GetOutWidth() + + pBoxLn->GetInWidth() + + pBoxLn->GetDistance(); + } + pBoxLn = aBox.GetRight(); + if( pBoxLn ) + { + nHoriDelta += pBoxLn->GetOutWidth() + + pBoxLn->GetInWidth() + + pBoxLn->GetDistance(); + } + /* + vertikale Randbreite errechnen + */ + nVertiDelta += ( 2 * aBox.GetDistance() ); + pBoxLn = aBox.GetTop(); + if( pBoxLn ) + { + nVertiDelta += pBoxLn->GetOutWidth() + + pBoxLn->GetInWidth() + + pBoxLn->GetDistance(); + } + nVertiDelta += aBox.GetDistance(); + pBoxLn = aBox.GetBottom(); + if( pBoxLn ) + { + nVertiDelta += pBoxLn->GetOutWidth() + + pBoxLn->GetInWidth() + + pBoxLn->GetDistance(); + } + } + } + + SwFlyFrmFmt* pFlyFmt; + if ( nType == 2 ) + { // Graphik verknuepfen/einlesen + // Raender nach *innen* + if ( nTop || nBot ) + { + SvxULSpaceItem aUL; + aUL.SetUpper( USHORT(nTop) ); + aUL.SetLower( USHORT(nBot) ); + aFlySet.Put( aUL ); + } + if ( nLeft || nRight ) + { + SvxLRSpaceItem aLR; + aLR.SetTxtLeft( USHORT(nLeft) ); + aLR.SetRight( USHORT(nRight) ); + aFlySet.Put( aLR ); + } + + BOOL bOldPoss = bPicPossible; + bPicPossible = TRUE; + + String aGrfFileName( aCharBuffer ); + aGrfFileName.EraseLeadingChars(); + + /* + Wir lesen den *Inhalt* des Bildes nur dann, + wenn wir keinen Namen angegeben bekamen. + Haben wir einen Namen, so setzen wir + statt dem Bild einen Link ein. + */ + BOOL bOldNix = bNixNoughtNothingExec; + bNixNoughtNothingExec = ( 0 < aGrfFileName.Len() ); + pGraphic = 0; + + while( ( !nError ) + && ( EOF != GetNextRecord() ) + && !( pActW4WRecord + && ( pActW4WRecord->fnReadRec + == &SwW4WParser::Read_EndAbsPosObj ))) + { + /*NOP*/; + } + + bNixNoughtNothingExec = bOldNix; + bPicPossible = bOldPoss; + bTxtInDoc = bOldTxtInDoc; + + if( pGraphic || aGrfFileName.Len() ){ + + if( pGraphic && ( bSetGrfTwipWidth || bSetGrfTwipHeight ) ) + { + Size aSize( GetGraphicSizeTwip( *pGraphic, 0 )); + SwFmtFrmSize aFlySize( (SwFmtFrmSize&)aFlySet.Get( RES_FRM_SIZE )); + aFlySet.Put( + lcl_AdjustFlySize( aSize, aFlySize, + bSetGrfTwipWidth, bSetGrfTwipHeight, + nGrWidthTw, nGrHeightTw, + nHoriDelta, nVertiDelta ) ); + } + + SwFmtAnchor aAnchor( eAnchor ); + aAnchor.SetAnchor( pCurPaM->GetPoint() ); + aFlySet.Put( aAnchor ); + + pFlyFmt = pDoc->Insert( *pCurPaM, + aGrfFileName, aEmptyStr,// Name der Grafik !! + pGraphic, + &aFlySet, // Attr. fuer FlyFrm + 0 ); // Attr. fuer die Grafik + if( !pGraphic && ( bSetGrfTwipWidth || bSetGrfTwipHeight ) ) + { + SwGrfNode *pGrfNd + = pDoc->GetNodes()[ pFlyFmt->GetCntnt(). + GetCntntIdx()->GetIndex()+1 ] + ->GetGrfNode(); + + if( pGrfNd->IsGrafikArrived() ) + { + Size aSize( pGrfNd->GetTwipSize() ); + SwFmtFrmSize aFlySize( pFlyFmt->GetFrmSize() ); + pFlyFmt->SetAttr( + lcl_AdjustFlySize( aSize, aFlySize, + bSetGrfTwipWidth, + bSetGrfTwipHeight, + nGrWidthTw, nGrHeightTw, + nHoriDelta, nVertiDelta ) ); + } + else + pGrfNd->SetChgTwipSize( TRUE ); + } + + } + else + MakeTxtFly( eAnchor, aFlySet ); + + if ( pGraf ) DELETEZ( pGraf ); + + } + else + { // Text-FlyFrame oder Formel oder leer + + bTxtInDoc = bOldTxtInDoc; + pFlyFmt = MakeTxtFly( eAnchor, aFlySet ); + + Flush(); + + SwPosition aTmpPos( *pCurPaM->GetPoint() ); + + const SwFmtCntnt& rCntnt = pFlyFmt->GetCntnt(); + ASSERT( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." ); + PtNd( pCurPaM ) = rCntnt.GetCntntIdx()->GetIndex() + 1; + SwCntntNode *pNode = pCurPaM->GetCntntNode(); + PtCnt( pCurPaM ).Assign( pNode, 0 ); + + USHORT nOldStyleId = nAktStyleId; + W4WCtrlStack* pOldStack = pCtrlStck; + pCtrlStck = new W4WCtrlStack( *pOldStack, *pCurPaM->GetPoint() ); + + SetAttr( SwW4WStyle( nAktStyleId )); // Override implizites + // Style in Frames + pActFlySection = pFlyFmt; + while( ( !nError ) + && ( EOF != GetNextRecord() ) + && !( pActW4WRecord + && ( pActW4WRecord->fnReadRec + == &SwW4WParser::Read_EndAbsPosObj ))) + { + /*NOP*/; + } + pActFlySection = 0; + +#ifdef MOGEL_WW2 + if ( !( nIniFlags & W4WFL_NO_APO_HNL_REMOVE ) + && nDocType == 44 // Bit 4 : HNL nicht klauen + && !bIsTxtInPara ) // bevor die Attribute + JoinNode( pCurPaM ); // gesetzt sind +#endif + + DeleteZStk( pCtrlStck ); + pCtrlStck = pOldStack; + nAktStyleId = nOldStyleId; + pCtrlStck->SetEndForClosedEntries( aTmpPos ); + *pCurPaM->GetPoint() = aTmpPos; + } + } + bTxtInDoc = bOldTxtInDoc; + nGrWidthTw = nOldW; + nGrHeightTw = nOldH; + nApoBorderCode = 0; +} + + +void SwW4WParser::Read_EndAbsPosObj() // (APF) +{ +} + + +/*************************************************************************************** +Umrandungen +***************************************************************************************/ + +// Setze Umrandung, nach SetPamInCell() aufrufen +// Ret: Bit 0: Umrandung setzen +// Bit 1: Schatten setzen + +USHORT SwW4WParser::Read_SetBorder( USHORT nBor, SvxBoxItem& rFmtBox ) +{ +// W4W nuetzt ihren ohnehin schon mageren Bereich der Breiten nicht aus, +// zumindest bei WP und WW2 nicht, d.h. "extra thick" und "hairline" +// wird nie benutzt. Ich habe die Tabelle jetzt auf WW2 optimiert. + + static USHORT __READONLY_DATA nOutTab[] = { // Aussenlinie : + DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_1, // none, single + DEF_DOUBLE_LINE1_OUT, DEF_LINE_WIDTH_0, // double, dashed + DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_3, // dotted, sick + DEF_LINE_WIDTH_4, DEF_LINE_WIDTH_0 }; // extra thick, hairline + + static USHORT __READONLY_DATA nInTab[] = { // Innenlinie, + 0, 0, DEF_DOUBLE_LINE1_IN, 0, 0, 0, 0, 0 }; // Index siehe nOutTab + + static USHORT __READONLY_DATA nDistTab[] = { // Abstand der Linien + 0, 0, DEF_DOUBLE_LINE1_DIST, 0, 0, 0, 0, 0 }; // Index siehe nOutTab + + static USHORT __READONLY_DATA nLinePlace[] = { // Art der Linien + BOX_LINE_RIGHT, + BOX_LINE_BOTTOM, + BOX_LINE_LEFT, + BOX_LINE_TOP }; + + if ( nBor == 0 ) + return 0; // nix zu tun + + USHORT nRet = 0; + USHORT i; + Color aCol( COL_BLACK ); + SvxBorderLine aBrd( &aCol ); + + for ( i = 0; i < 4; i++ ){ + BYTE nW4WTyp = (BYTE)(nBor & 0xf); + // ist diese Linie vorhanden ? + if( nW4WTyp ) + { + + nRet |= 1; // mindestens 1 Linie ist vorhanden + if ( nW4WTyp & 0x8 ) // oder == 8 ?? + nRet |= 2; // Shadow + if( nW4WTyp > 7 ) // unbekannt + nW4WTyp = 7; // ->hairline + + aBrd.SetOutWidth( nOutTab[nW4WTyp] ); + aBrd.SetInWidth( nInTab[nW4WTyp] ); + aBrd.SetDistance( nDistTab[nW4WTyp] ); + rFmtBox.SetLine( &aBrd, nLinePlace[ i ] ); + } + nBor >>= 4; + } + return nRet; +} + +void SwW4WParser::Read_ParaBorder() // (PBC) +{ + USHORT nBorder; + + if ( bStyleOnOff ) + { + // in Style An / Aus -> Ende des Attributes + Read_HardAttrOff( RES_BOX ); + return; + } + if ( GetHexUShort( nBorder ) && !nError ) + { + if ( nBorder && nBorder == nApoBorderCode + && !( nIniFlags & W4WFL_NO_DBL_APO_BORDER_REMOVE ) ) + return; // Vermeide doppelte Umrandungen um APOs + + SvxBoxItem aBox; + USHORT nRet = Read_SetBorder( nBorder, aBox ); + + // einschalten ? + if( nRet ) + { + // Umrandung setzen ? + if( 0x1 & nRet ) + SetAttr( aBox ); + + // Hintergrund setzen ? + if( 0x2 & nRet ) + { + const Color aCol( COL_LIGHTGRAY ); + const SvxBrushItem aBack( aCol, RES_BACKGROUND ); + SetAttr( aBack ); + } + } + else + // ausschalten + { + // Umpopele W4W-Fehler: + // Ausschalten erfolgt oft erst am Anfang des folgenden Absatzes + // dies geschieht in normalen UND in Tabellen-Absaetzen... + if( bIsTxtInDoc && !bIsTxtInPara ) + { + // gehe 1 Char zurueck + BOOL bForward = pCurPaM->Move( fnMoveBackward, fnGoCntnt ); + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_BOX, TRUE, bForward ); + + if( bForward ) + pCurPaM->Move( fnMoveForward, fnGoCntnt ); + } + else + { + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_BOX ); + } + } + } +} + + +/*************************************************************************************** +Tabellen und mehrspaltiges +***************************************************************************************/ + +#define TAB_KULANZ 72 // so viele Twips Kulanz ( 1/20 " ) +#define TAB_KULANZ2 350 // so viele Twips Kulanz, wenn Bit2=0 + + + +void SwW4WParser::Adjust_pTabDefs() // Aufrufe siehe .<CDS> und .<BRO> +{ + int i; + + // Spalten mit Breite kleinergleich NULL werden auf Kosten der + // vorangegangenen Spalte(n) auf 144 Twips verbreitert. + // Tabelle muss hier von rechts nach links durchlaufen werden. + for(i=nTabCols-1; i>0; i--) + { + if( pTabDefs[ i ].nRightTw - pTabDefs[ i ].nLeftTw < 1 ) + { + pTabDefs[ i ].nLeftTw = pTabDefs[ i ].nRightTw-144; + if( pTabDefs[ i-1 ].nRightTw + > pTabDefs[ i ].nLeftTw - nTabDeltaSpace ) + { + pTabDefs[ i-1 ].nRightTw = + pTabDefs[ i ].nLeftTw - nTabDeltaSpace; + } + } + } + + // And now what we all like so much: File Format depending hacks ;-) + switch( nDocType ) + { + case 33: + { // AmiPro: + // Alle Parameter ab 2. Spalte korrigieren. + // Linker Zwischenraum muss der Spaltenbreite hinzugerechnet + // werden, dadurch verschieben sich alle weiteren Raender. + // Beruecksichtige hierbei aber auch die Distanz zwischen + // dem Inhalt und dem Rand einer jeden Zelle. + // Regel: Versuche, die gesamte TABELLEN-Breite moeglichst + // nicht groesser als im Original werden zu lassen ! + long nMinPlus = 2 * DEFAULT_TAB_CELL_DISTANCE; + + // Die 1. Spalte wird um genau 2 Distanzen verbreitert + long nDelta = nMinPlus; + pTabDefs[0].nRightTw += nDelta; + + // Da Verbreiterung speziell der 1. Spalte ist zwar wichtig, + // sollte aber moeglichst nicht die Gesamtbreite der + // Tabelle erhoehen, daher VERSUCHEN wir, die zusaetzliche + // Breite bei den folgenden Spalten wieder abzuknapsen... + long nToWide = nDelta; + + for (i=1; i<(int)nTabCols; i++) + { + pTabDefs[i].nLeftTw += nDelta; + + long nAktPlus = ( pTabDefs[ i ].nLeftTw + - pTabDefs[ i-1 ].nRightTw ); + + // alle uebrigen Spalten werden um ihren Zwischenraum + // mindestens jedoch um 2 Distanzen verbreitert + if( nAktPlus > nMinPlus ) + { + if( nToWide ) // noch Korrektur wg. 1. Spalte noetig? + { + if( nAktPlus - nToWide >= nMinPlus ) + { + nAktPlus -= nToWide; + nToWide = 0; + } + else + { + nToWide -= (nAktPlus - nMinPlus); + nAktPlus = nMinPlus; + } + } + } + else + { + // wir verbreitern die Spalte um MEHR als ihren + // Zwischenraum, merken uns diese Tat jedoch, + // indem wir nToWide entsprechend vergroessern, + // damit Wiedergutmachung bei der Bearbeitung + // der Folgespalten erfolgen kann... + nToWide += (nMinPlus - nAktPlus); + nAktPlus = nMinPlus; + } + nDelta += nAktPlus; + pTabDefs[i].nRightTw += nDelta; + } + // linke Raender nach links ziehen: Luecken verschwinden + for (i=1; i<(int)nTabCols; i++) + { + pTabDefs[i].nLeftTw = pTabDefs[i-1].nRightTw; + } + } + break; + case 44: + { // WW2: + // Die rechten Raender aller Spalten korrigieren. + // Rechter Zwischenraum muss der Spaltenbreite hinzugerechnet + // werden. An letzte Spalte muss dementsprechend der + // durchschnittliche Zwischenraum angehaengt werden. + for(i=0; i<(int)nTabCols-1; i++) + { + pTabDefs[i].nRightTw = pTabDefs[i+1].nLeftTw; + } + pTabDefs[ nTabCols-1 ].nRightTw += nTabDeltaSpace; + } + break; + case 07: + case 48: + { // WP: + // Breite der Tabelle ist RRand der letzten Zelle - LRand der + // ersten Zelle, d.h. der Text-Text-Abstand zaehlt nicht hinzu. + // Der Text-Text-Abstand ist hier immer 144 tw, egal was in WP + // eingestellt wird. + // Jede Zelle hat die Breite RRand(i)-LRand(i)+Abstand*(n-1)/n + // zur Ergaenzung: + // W4W meldet jetzt sogar Twips(!)-Werte, die hoehere Genauigkeit + // suggerieren. Leider sind diese Unsinn: in den Feldern stehen + // bloss die alten Werte mit 144 multipliziert. (khz, 9.3.1998) + long nKorr = 144; + if (nTabCols > 1) + nKorr = (pTabDefs[1].nLeftTw - pTabDefs[0].nRightTw) + / nTabCols; + long nKorr1 = 0; + for(i=1; i<(int)nTabCols; i++) + { + nKorr1 += nKorr; + pTabDefs[i].nRightTw -= nKorr1; + pTabDefs[i].nLeftTw -= nKorr1; + } + } + break; + } + + + nTabWidthTw = pTabDefs[nTabCols-1].nRightTw-pTabDefs[0].nLeftTw; + + // Falls nach unseren obigen Korrektur-Aktionen + // noch immer Spaltenzwischenraeume existieren, + // werden diese nun ausgewertet, damit die Tabellenbreite + // entsprechend vergroessert werden kann... + if( ( 33 != nDocType ) && ( 44 != nDocType ) ) + { + long nAbstand = 0; + if(nTabCols > 1) + { + // Zaehle alle Abstaende zwischen den Zellen zusammen + // ACHTUNG: iteriere ueber nTabCols, nicht ueber nCols!! + for (i=1; i<nTabCols; i++) + nAbstand += ( pTabDefs[ i ].nLeftTw + - pTabDefs[ i-1 ].nRightTw ); + // Nimm den durchschnittl. Zwischenraum aller Zellen + nAbstand = nAbstand / ( nTabCols-1 ); + } + else + nAbstand = (nDocType == 07) ? 0 : 140; // Defaults + nTabWidthTw += nAbstand; + } + + // hilfsweise naechste Zelle extrapoliert + pTabDefs[nTabCols].nLeftTw = pTabDefs[0].nLeftTw + nTabWidthTw; + + long nWidthTw; // Groesse der aktuellen Zelle + long nMittel; // zur Erkennung, ob alle Zellen gleich gross + + for (i=0; i<(int)nTabCols; i++) + { + nWidthTw = pTabDefs[i+1].nLeftTw - pTabDefs[i].nLeftTw; + + if( 0 == i ) + nMittel = nWidthTw; + pTabDefs[ i ].nWidthFrac = nWidthTw; + pTabDefs[ i ].nRemainingMergeRows = 0; + + if ( Abs( nMittel - nWidthTw ) > TAB_KULANZ ) + bTabOwnFrm = TRUE; // Breite der Zellen unterscheidet sich + // deutlich + // -> alle Zellen erhalten eigene + // Frame-Formate + } + + if( !bTabOwnFrm )// alle Zellen gleich gross ? + { // -> gemeinsames Frameformat mit + // Zellenbreite = Tabellenbreite / Zellenzahl + for (i=0; i<(int)nTabCols; i++) + pTabDefs[i].nWidthFrac = nTabWidthTw / nTabCols; + } +} + + +void SwW4WParser::ReadTabDefs( BYTE nCode, long nCols, W4W_ColdT* pActTabDefs ) +{ + register W4W_ColdT *pColI; + + // alles ausser dem ersten Parametersatz fehlt + if( nCode & 0x1 ) + nCols = 1; + + int i; + // lies Parameter + for (i=0, pColI=pActTabDefs; i<nCols; i++, pColI++) + if( !GetDecimal( pColI->nLeft ) || nError + || !GetDecimal( pColI->nRight ) || nError + || !GetDecimal( pColI->nNC ) || nError ) return; + + // lies opt. Parameter in Twips + for (i=0, pColI=pActTabDefs; i<nCols; i++, pColI++) + if( !GetDecimal( pColI->nLeftTw ) || nError + || !GetDecimal( pColI->nRightTw ) || nError + || !GetDecimal( pColI->nNC2 ) || nError ) break; + + // Optionale Parameter nicht vorhanden -> berechne Twip-Werte + if ( nError || ( i != nCols ) ) + { + for (i=0, pColI=pActTabDefs; i<nCols; i++, pColI++) + { + pColI->nLeftTw = pColI->nLeft * 144; // in 1/10 Inch + pColI->nRightTw = pColI->nRight * 144; // in 1/10 Inch + pColI->nNC2 = pColI->nNC; + } + } + + // nur 1. Zelle angegeben, -> errechne alle weiteren + if ( nCode & 0x1 ) // Parametersaetze + { + long nWidth = pActTabDefs->nRight - pActTabDefs->nLeft; + long nWidthTw = pActTabDefs->nRightTw - pActTabDefs->nLeftTw; + for (i=1; i<(int)nTabCols; i++) + { + pActTabDefs[i] = pActTabDefs[ 0]; + pActTabDefs[i].nLeft = pActTabDefs[i-1].nRight + 2; + pActTabDefs[i].nRight = pActTabDefs[i ].nLeft + nWidth; + pActTabDefs[i].nLeftTw = pActTabDefs[i-1].nRightTw + 2 * 144; + pActTabDefs[i].nRightTw = pActTabDefs[i ].nLeftTw + nWidthTw; + } + } +} + + +void SetCols( SwFrmFmt &rFmt, long nCols, W4W_ColdT* pActTabDefs, long nNettoWidth ) +{ + if( nCols < 2 ) + return; // keine oder bloedsinnige Spalten + + SwFmtCol aCol; + + BOOL bEqual = TRUE; + long nAveDist = 0; + long nLastDist = 0; + long nLastWidth = 0; + + for( int i=0; bEqual, i<(int)nCols; i++ ) + { + // Spalten-Breite + long nActWidth = pActTabDefs[ i ].nRightTw - pActTabDefs[ i ].nLeftTw; + if( 0 < i ) + { + if( nActWidth != nLastWidth ) + bEqual = FALSE; + // Spalten-Abstand + long nActDelta = pActTabDefs[ i ].nLeftTw - pActTabDefs[ i-1 ].nRightTw; + if( (1 < i) && (nActDelta != nLastDist) ) + bEqual = FALSE; + nAveDist += nActDelta; + nLastDist = nActDelta; + } + nLastWidth = nActWidth; + } + nAveDist /= (nCols - 1); + + // ULONG nNettoWidth = pActTabDefs[ nCols-1 ].nRightTw - pActTabDefs[ 0 ].nLeftTw; + + + + // Zwischen-Linie + /* + aCol.SetLineAdj( COLADJ_TOP ); + aCol.SetLineHeight( 100 ); + aCol.SetLinePen( Pen( Color( COL_BLACK ), 1, PEN_SOLID ) ); + */ + + + + if( bEqual ) // alle Spalten gleich ? + aCol.Init( (USHORT)nCols, (USHORT)nAveDist, (USHORT)nNettoWidth ); + else + { + aCol.Init( (USHORT)nCols, (USHORT)nAveDist, 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 ); + + long nWidth = pActTabDefs[ i ].nRightTw - pActTabDefs[ i ].nLeftTw; + if( i < nCols-1 ) + { + long nRightDist = pActTabDefs[ i ].nRightTw - pActTabDefs[ i+1 ].nLeftTw; + nRightDist = nWidth / 2; + pCol->SetRight( (USHORT)nRightDist ); + } + else + nRightDist = 0; // letzte Spalte hat keinen Zwischenraum mehr + + pCol->SetWishWidth( nWidth + nLeftDist + pCol->GetRight() ); + + // aufsummierte Spaltenbreiten ergeben Gesamtbreite + nWishWidth += pCol->GetWishWidth(); + // Halber Abstand ist an naechster Spalte noch zu setzen + nLeftDist = nRightDist; + } + aCol.SetWishWidth( nWishWidth ); + } + rFmt.SetAttr( aCol ); +} + + +void SwW4WParser::Read_EndSection() +{ + if( pBehindSection ) + { + // vorigen Absatz entfernen, + // falls unmittelbar hiervor ein 0x0d kam + if( 0 == pCurPaM->GetPoint()->nContent.GetIndex() ) + JoinNode( pCurPaM ); + + pCurPaM->GetPoint()->nNode = *pBehindSection; + pCurPaM->GetPoint()->nContent.Assign( + pCurPaM->GetCntntNode(), 0 ); + DELETEZ( pBehindSection ); + } +} + + +void SwW4WParser::Read_ColumnsDefinition() // (CDS) +{ + if( bNoExec && !bBCMStep1 ) + { + return; // Jetzt aber nix wie weg hier! + } + + if( pBehindSection ) + Read_EndSection(); + + if( nTablInTablDepth && !bCheckTabAppendMode ) + { + return; // keine Tabelle bzw. Mehrspaltigkeit IN Tabelle + } + + BYTE nCode; + long nCols; + W4W_ColdT* pActTabDefs = 0; // unten wird auf Initialwert geprueft! + + bIsColDefTab = FALSE; + if( GetHexByte( nCode ) && !nError && GetDecimal( nCols ) && !nError ) + { + /* + bitte beachten: + *************** + im Gegensatz zu den anderen Spalten-Code-Methoden + ist hier das Flag bBCMStep1 noch nicht fuer die + ERSTE sondern nur fuer die Folge-Tabellen gesetzt. + Das Flag bBCMStep2 hingegen stimmt immer. + Hier im .<CDS> ist deshalb auf ( !bBCMStep2 ) zu pruefen, + wenn man alle Teiltabellen (also auch die Start-Tabelle) + des ersten Durchgangs braucht + */ + if ( ( (int)nCode & 0x08 ) == 0x08 ) // Tabellendefinition + { + bIsColDefTab = TRUE; + + if( 48 == nDocType ) //!! Umpople Bug WP-W4W-Filter: + nCode &= ~1; // Bit 0 faelschlicherweise gesetzt + // loesche es ! + if( bCheckTabAppendMode ) + { + bIsTabAppendMode = BOOL( ( nCols == nTabCols ) + && ( nCode == nTabCode ) ); + } + + // Durchgang 2 - Starttabelle + if( bBCMStep2 && !bIsTabAppendMode ) + { + // Tabellendefinition wurde im Durchgang 1 fix und fertig + // aufgebaut, daher ist die Definition der Starttabelle + // im Durchgang 2 komplett zu ueberspringen + return; + } + + // Durchgang 1 - Folgetabellen + if( bIsTabAppendMode && bBCMStep1 ) + { + // Dummy-Array zur Ermittlung der Spaltenbreiten + pActTabDefs = new W4W_ColdT[nTabCols+1]; + } + else + { + // Durchgang 1 - Starttabelle + if( !bIsTabAppendMode ) + { + nTabCode = nCode; + nTabCols = (USHORT)nCols; + nTabRows = 0; + bTabOwnFrm = FALSE; + if( pMergeGroups ) DELETEZ( pMergeGroups ); + } + + // Durchgang 1 - nur Starttabelle und + // Durchgang 2 - nur Folgetabellen + if( ! ( bBCMStep1 && bIsTabAppendMode ) ) + { + // globales Array neu anlegen + if( pTabDefs ) + DELETEZ( pTabDefs ); + pTabDefs = new W4W_ColdT[nTabCols+1]; // +1 wird nur nLeft... benutzt + } + + // Parameter in globales Array einlesen + pActTabDefs = pTabDefs; + } + + + /* + Und auf gehts: Spalten-Parameter aus Input-Stream lesen... + */ + ReadTabDefs( nCode, nCols, pActTabDefs ); + + // Durchgang 1 - Start- und Folgetabellen + // durchschn. Zwischenraum ermitteln + if( !bBCMStep2 ) + { + // Starttabelle + if( !bIsTabAppendMode ) + nTabDeltaSpace = 0; // globalen Wert initialisieren + + // lokalen Wert ermitteln + long nActDeltaSpace = 0; + USHORT nActDeltaCount = 0; + for (int i=1; i<(int)nTabCols; i++) + { + if( pActTabDefs[ i ].nRightTw > pActTabDefs[ i ].nLeftTw+10 ) + { + nActDeltaSpace += + pActTabDefs[ i ].nLeftTw - pActTabDefs[ i-1 ].nRightTw; + nActDeltaCount++; + } + } + // ggfs. globalen Wert korrigieren + if( nActDeltaCount ) + { + nActDeltaSpace = nActDeltaSpace / nActDeltaCount; + if( nTabDeltaSpace < nActDeltaSpace ) + nTabDeltaSpace = nActDeltaSpace; + } + + // falls noetig das Dummy-Array freigeben + if( pActTabDefs + && ( pActTabDefs != pTabDefs ) ) + delete[] pActTabDefs; + } + // Durchgang 2: Tabellenspaltendefinitionen anpassen + else + Adjust_pTabDefs(); + } + else + { + // mehrspaltiger Bereich ODER mehrspaltiger Rahmen + pActTabDefs = new W4W_ColdT[nCols+1]; + + ReadTabDefs( nCode, nCols, pActTabDefs ); + + if( nCols && pActTabDefs ) + { + // mehrspaltiger Rahmen + if( pActFlySection ) + { + long nAveDist = 0; + for (int i=1; i<(int)nCols; i++) + nAveDist += + pActTabDefs[ i ].nLeftTw - pActTabDefs[ i-1 ].nRightTw; + nAveDist /= (nCols - 1); + + SwFmtCol aCol; + +// wozu braucht man denn dies? const SvxLRSpaceItem& rLR = (SvxLRSpaceItem&)pSet->Get( RES_LR_SPACE ); + + ULONG nWidth = USHRT_MAX; + aCol.Init( USHORT( nCols ), USHORT( nAveDist ), USHORT( nWidth ) ); + /* + spaeter nachruesten: unterschiedliche Spaltenbreiten und -Abstaende + + 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 ); + * + } + } + */ + pActFlySection->SetAttr( aCol ); + } + else + { + // normale Mehrspaltigkeit: Bereich einfuegen + SwSection aSection( CONTENT_SECTION, + pDoc->GetUniqueSectionName() ); + + SwSection* pNewSection = pDoc->Insert( *pCurPaM, aSection ); + pBehindSection = new SwNodeIndex( pCurPaM->GetPoint()->nNode ); + + // Anzahl der Spalten einstellen + 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(), nCols, + pActTabDefs, nWidth - nLeft - nRight ); + + // PaM in Node der Section setzen + const SwSectionNode* pSectionNode = + pNewSection->GetFmt()->GetSectionNode(); + ASSERT( pSectionNode, "Kein Inhalt vorbereitet." ); + pCurPaM->GetPoint()->nNode = + pSectionNode->GetIndex()+1; + pCurPaM->GetPoint()->nContent.Assign( + pCurPaM->GetCntntNode(), 0 ); + } + } + delete[] pActTabDefs; + } + } +} + + +// folgende pragma Anweisung nicht entfernen: die Complier Optimierung fuehrt +// ansonsten in NICHT-DEBUG Versionen zu fehlerhaften Tabellen-Zellen-Raendern + +#ifdef _MSC_VER +#pragma optimize("", off) +#endif +// ====================== +void SwW4WParser::Read_BeginColumnMode() // (BCM) +{ + if( bNoExec && !bBCMStep1 ) + { + return; // Jetzt aber nix wie weg hier! + } + + if( bIsTabAppendMode ) + { + return; // .<BCM>-Codes der angehaengten Tabellen werden ueberlesen + } + + if( !bIsColDefTab ) + { + return; // derzeit noch keine Mehrspaltigkeit ohne Tabellen + } + + // erzwinge AbsatzEnde, falls Content-Node nicht leer + if( pCurPaM->GetPoint()->nContent.GetIndex() != 0 ) + pDoc->SplitNode( *pCurPaM->GetPoint() ); + + if( bBCMStep2 && pDoc->IsIdxInTbl( pCurPaM->GetPoint()->nNode ) ) + { + // Tabellen-Daten IN einer anderen Tabelle als Rohtext lesen + Flush(); + BOOL bOldIsColMode = bIsColMode; + BOOL bOldIsTxtInPgDesc = bIsTxtInPgDesc; + bIsColMode = TRUE; + nTablInTablDepth++; + while( !nError + && bIsColMode + && EOF != GetNextRecord() ) + { + /*NOP*/; + } + bIsColMode = bOldIsColMode; + bIsTxtInPgDesc = bOldIsTxtInPgDesc; + nTablInTablDepth--; + return; // und raus hier! + } + + bIsSTYInTab = FALSE; + nTabStyleId = nAktStyleId; + nTabRows = nTabRow = 0; + bTabBorder = bTabSpezBorder = FALSE; + + Flush(); + + /* + Durchgang 1 starten: + Suche Ende der Tabelle oder EOF, zaehle dabei Zeilen und Spalten + und speichere die .<BRO>-Border-Infos aller Zellen in pTabBorders + und ermittle durchschnittl. Zwischenraum + */ + ULONG nOldPos = rInp.Tell(); // merke FilePos + BOOL bOldTxtInDoc = bTxtInDoc; + BOOL bOldIsTxtInPgDesc = bIsTxtInPgDesc; + BOOL bOldNoExec = bNoExec; + BYTE nOldErr = nError; + if( !pTabBorders ) + pTabBorders = new W4WTabBorders; // Array fuer .<BRO>-Raender + bTxtInDoc = FALSE; + bWasCellAfterCBreak = FALSE; + bNoExec = TRUE; + bBCMStep1 = TRUE; + bIsColMode = TRUE; + int iRet=0; + while( !nError + && bIsColMode + && EOF != iRet ) + { + iRet = GetNextRecord(); + } + + nParaLen = 0; // Neuer TextNode ist aktiv -> noch KEIN Zeichen drin + Flush(); + nError = nOldErr; + bTxtInDoc = bOldTxtInDoc; + bIsTxtInPgDesc = bOldIsTxtInPgDesc; + bNoExec = bOldNoExec; + bBCMStep1 = FALSE; + + if ( ( EOF == iRet ) // W4W-Fehler: Ende der Tabelle fehlt (WinWord 2) + || !nTabRows // leere Tabelle ( z.B. AmiPro ) geht schief + || !nTabCols ) + { + // Spule zurueck an TabellenAnfang + // und betrachte Tabelleninhalt als normalen Text + rInp.Seek( nOldPos + 1 ); + bIsColMode = FALSE; + } + else + { + // Column-Mode-Flag setzen (war durch .<ECM> ausgeschaltet worden) + bIsColMode = TRUE; + + // Inputstream zurueckspulen (wird im 2. Durchgang erneut gelesen) + rInp.Seek( nOldPos ); + + // ggfs. durchschn. Zellen-Zwischenraum ueber Defaults definieren + if( !nTabDeltaSpace ) + nTabDeltaSpace = (nDocType == 07) ? 0 : 140; + + // Tabellenspaltendefinitionen anpassen + Adjust_pTabDefs(); + + /* + wichtig: Korrektur der Werte in pTabBorders + */ + for( int iR=0; iR < nTabRows; iR++ ) // ueber alle Zeilen + { + // Hilfsvaris zum uebersichtlicheren Zugriff auf Zeilen-Arrays + USHORT* aThisRow = (*pTabBorders)[ iR ]; + USHORT* aAboveRow; + if( iR > 0 ) + aAboveRow = (*pTabBorders)[ iR-1 ]; + USHORT* aBelowRow; + if( iR < nTabRows-1 ) + aBelowRow = (*pTabBorders)[ iR+1 ]; + + for ( int iC=0; iC < nTabCols; iC++ )// ueber alle Spalten + { + // + // 1. Korrigiere senkrechte Raender + // + // 1.1 Verhindere doppelten (identischen) Rand + // aneinanderstossender Zellen + // + if( (iC > 0) + && ( ( aThisRow[ iC-1 ] & 0x000f ) + == ( (aThisRow[ iC ] & 0x0f00) >> 8 ) ) ) + { + // loesche li. Rand des aktuellen Feldes + aThisRow[ iC ] &= 0xf0ff; + } + // + // 1.2 Vermeide versetzte Kanten + // + if( iR > 0 ) + { + // pruefe, ob der re. Rand des aktuellen Feldes + // gleich ist dem li. Rand des Feldes oben rechts davon + if( (iC < nTabCols-1) + && (aThisRow[ iC ] & 0x000f) + && ( ( aAboveRow[ iC+1 ] & 0x0f00 ) + == ( (aThisRow [ iC ] & 0x000f) << 8 ) + ) + ) + { + // setze li. Rand des Folge-Feldes und + // loesche re. Rand des aktuellen Feldes + aThisRow[ iC+1 ] &= 0xf0ff; + aThisRow[ iC+1 ] |= ((aThisRow[ iC ] & 0x000f) << 8); + aThisRow[ iC ] &= 0xfff0; + } + // pruefe, ob der li. Rand des aktuellen Feldes + // gleich ist dem re. Rand des Feldes oben links davon + if( (iC > 0) + && (aThisRow[ iC ] & 0x0f00) + && ( ( aAboveRow[ iC-1 ] & 0x000f ) + == ((aThisRow [ iC ] & 0x0f00) >> 8 ) + ) + ) + { + // setze re. Rand des vorigen Feldes und + // loesche li. Rand des aktuellen Feldes + aThisRow[ iC-1 ] &= 0xfff0; + aThisRow[ iC-1 ] |= ((aThisRow[ iC ] & 0x0f00) >> 8); + aThisRow[ iC ] &= 0xf0ff; + } + } + // + // 2. Korrigiere waagerechte Raender + // + // 2.1 Verhindere doppelten (identischen) Rand + // aneinanderstossender Zellen + // + if( (iR > 0) + && ( ( (aAboveRow[ iC ] & 0x00f0) >> 4 ) + == ( (aThisRow[ iC ] & 0xf000) >>12 ) ) ) + { + // loesche oberen Rand des aktuellen Feldes + aThisRow[ iC ] &= 0x0fff; + } + // + // 2.2 Vermeide versetzte Kanten + // + if( iC > 0 ) + { + // pruefe, ob der unt. Rand des aktuellen Feldes + // gleich ist dem ob. Rand des Feldes links unten davon + if( (iR < nTabRows-1) + && (aThisRow[ iC ] & 0x00f0) + && ( ( aBelowRow[ iC-1 ] & 0xf000 ) + == ( (aThisRow [ iC ] & 0x00f0) << 8 ) + ) + ) + { + // setze ob. Rand des darunter liegenden Feldes und + // loesche unt. Rand des aktuellen Feldes + aBelowRow[ iC ] &= 0x0fff; + aBelowRow[ iC ] |= ((aThisRow[ iC ] & 0x00f0) << 8); + aThisRow[ iC ] &= 0xff0f; + } + // pruefe, ob der ob. Rand des aktuellen Feldes + // gleich ist dem unt. Rand des Feldes links oben davon + if( (iR > 0) + && (aThisRow[ iC ] & 0xf000) + && ( ( aAboveRow[ iC-1 ] & 0x00f0 ) + == ((aThisRow [ iC ] & 0xf000) >> 8 ) + ) + ) + { + // setze unt. Rand des darueber liegenden Feldes und + // loesche ob. Rand des aktuellen Feldes + aAboveRow[ iC ] &= 0xff0f; + aAboveRow[ iC ] |= ((aThisRow[ iC ] & 0xf000) >> 8); + aThisRow[ iC ] &= 0x0fff; + } + } + } + } + + // merke aktuelle Point-Position des pCurPaM + SwPosition aTmpPos( *pCurPaM->GetPoint() ); + + static const SwHoriOrient aOrientTab[5] = + { HORI_LEFT, HORI_FULL, HORI_CENTER, HORI_RIGHT, HORI_NONE }; + USHORT nIdx = nTabCode >> 4; + if ( nIdx > 4 ) nIdx = 0; + SwHoriOrient eOri = aOrientTab[ nIdx ]; + + /* + Einrueckung der Tabelle ermitteln + */ + long nNewLeft = 0; // Default: keine Einrueckung + long nNewRight; + + if(( eOri == HORI_LEFT ) || ( eOri == HORI_NONE )) + { + nNewLeft = pTabDefs[0].nLeftTw; + if( nTabCols > 1 ) + nNewLeft -= (pTabDefs[1].nLeftTw - pTabDefs[0].nRightTw) /2; + + // Umrechnen auf SW-Koordinaten + nNewRight = nPgRight - nNewLeft - nTabWidthTw; + nNewLeft -= nPgLeft; + if( nNewRight < 0 ) nNewRight = 0; + if( nNewLeft < 0 ) nNewLeft = 0; + + // ggfs. Linksbuendigkeit abschalten, + // damit korrekt positioniert wird + if( nNewLeft ) + { + eOri = HORI_LEFT_AND_WIDTH; + } + } + + // schalte evtl. aktuell gesetzten Style aus + BOOL bWasStyleBeforeTable = (USHRT_MAX != nAktStyleId); + if( bWasStyleBeforeTable ) + { + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_FLTR_STYLESHEET ); + } + + // Tabelle im pDoc anlegen + // und Table-Node aus dem Rueckgabewert ermitteln + pTblNd= (SwTableNode*) + ( pDoc->InsertTable( aTmpPos, nTabRows, nTabCols, eOri ) + ->GetTabSortBoxes()[ 0 ] + ->GetSttNd() + ->FindTableNode() ); + ASSERT( pTblNd, "wo ist mein TabellenNode" ); + + // lokale Variable zum bequemeren Zugriff + SwTable& rTable = pTblNd->GetTable(); + + // schalte ggfs. vorigen Style wieder ein + if( bWasStyleBeforeTable ) + { + SetAttr( SwW4WStyle( nAktStyleId ) ); + } + + SwFrmFmt* pFrmFmt = rTable.GetFrmFmt(); + + // setze Gesamtbreite der Tabelle + SwFmtFrmSize aSize; + aSize.SetWidth( nTabWidthTw ); + pFrmFmt->SetAttr( aSize ); + + // Tabelle einruecken (falls noetig) + if( HORI_LEFT_AND_WIDTH == eOri ) + { + SvxLRSpaceItem aLR; + aLR.SetLeft( USHORT(nNewLeft) ); + // aLR.SetRight( USHORT(nNewRight) ); + pFrmFmt->SetAttr( aLR ); + } + + // Init glob. Vars + nTabRow = -1; + nLastProcessedCol = -1; + SetPamInCell( 0, 0 ); + + // setze pCurPaM-Point auf den TabellenNode + rTable.SetHeadlineRepeat( FALSE ); + + + /* + Durchgang 2 starten: + Suche Ende der Tabelle oder EOF + und lies dabei den Tabellen-Inhalt in rTable ein + */ + bWasCellAfterCBreak = FALSE; + BOOL bOldIsTxtInPgDesc = bIsTxtInPgDesc; + bBCMStep2 = TRUE; + while ( !nError + && bIsColMode + && (EOF != GetNextRecord()) ) + { + /*NOP*/; + } + bBCMStep2 = FALSE; + bIsTxtInPgDesc = bOldIsTxtInPgDesc; + + // pCurPaM-Point zuruecksetzen + *pCurPaM->GetPoint() = aTmpPos; + + // falls noetig, zu mergende Zellen gruppenweise zusammenfassen + if( pMergeGroups ) + { + // bearbeite alle Merge-Gruppen nacheinander + SwTableBox* pTargetBox; + SwSelBoxes_SAR* pActMGroup; + USHORT nActBoxCount; + for( USHORT iGr = 0; iGr < pMergeGroups->Count(); iGr++ ) + { + pActMGroup = (*pMergeGroups)[ iGr ]; + nActBoxCount = pActMGroup->Count(); + + if( 1 < nActBoxCount ) + { + // beachten: der 0. Eintrag ist die + // bereits fix und fertig formatierte Target-Box !!! + pTargetBox = (*pActMGroup)[ 0 ]; + + // oeffne Merge-Array passender Groesse + SwSelBoxes aBoxes( nActBoxCount-1 ); + + // alle Boxen dieser Gruppe in aBoxes versammeln + aBoxes.Insert( pActMGroup->GetData()+1, nActBoxCount-1 ); + + // Vorsicht: erstmal pruefen, ob sich die aBoxes mergen + // lassen wuerden, ansonsten den Inhalt der Target-Box + // in die obere linke Box verschieben und die Target-Box + // den Hasen geben... + + switch( CheckMergeSel( aBoxes ) ) // siehe TBLSEL.HXX + { + case TBLMERGE_OK: + // das praktische Merge() + rTable.Merge( pDoc, aBoxes, pTargetBox ); + break; + case TBLMERGE_NOSELECTION: + /*NOP*/; // war wohl nix? + break; + case TBLMERGE_TOOCOMPLEX: + // hoppla: die Daten der Gruppe schlummern jetzt + // 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 ); + +// pLine->GetTabBoxes().Insert( pTargetBox, nPos ); + // dann die Nodes loeschen!! + pDoc->DeleteSection( pSttNd ); + } + break; + default: // was wollen wir denn hier ??? + ASSERT( !this, "CheckMergeSel() with undefined return value" ); + break; + } + } + } + } + } + DELETEZ( pTabBorders ); +} +#ifdef _MSC_VER +#pragma optimize("", off) +#endif +// ====================== + + +void SwW4WParser::Read_EndColumnMode() // (ECM) End Column Mode +{ + if( pBehindSection ) + { + Read_EndSection(); // spaltiger Bereich zu Ende + return; + } + + if( bNoExec && !bBCMStep1 ) + { + return; // Jetzt aber nix wie weg hier! + } + + if ( !bIsColMode ) return; // W4W-Fehler + + if( nTablInTablDepth ) // Tabelle / Mehrspaltigkeit IN Tabelle ? + { + bIsColMode = FALSE; + } + else + { + // sieh nach, ob .<CDS> folgt, das + // noch zu DIESER Tabelle gehoert + ULONG nOldPos = rInp.Tell(); // FilePos merken + bIsTabAppendMode = FALSE; + BOOL bOldIsTxtInPgDesc = bIsTxtInPgDesc; + bCheckTabAppendMode = TRUE; + SkipEndRecord(); + GetNextRecord(); + bCheckTabAppendMode = FALSE; + bIsTxtInPgDesc = bOldIsTxtInPgDesc; + + // tatsaechliches Tabellen-Ende erreicht? + if( !bIsTabAppendMode ) + { + rInp.Seek( nOldPos ); // FilePos restaurieren + bIsColMode = FALSE; + if ( bBCMStep2 && pTabDefs ) + DELETEZ( pTabDefs ); + } + } +} + + +/* + SwW4WParser::SetPamInCell() ist eine Mehrzweck-Methode: + 1. sorgt immer fuer gueltige Werte in den globalen Variablen + pTabLine, pTabBoxes und pTabBox + 2. setzt den PaM (falls bSetPaM wahr ist), +*/ +void SwW4WParser::SetPamInCell( USHORT nRow, USHORT nCol, BOOL bSetPaM ) +{ + SwTableLines& rTheTabLines = pTblNd->GetTable().GetTabLines(); + + // nRow gegen max. Zeilenzahl im Zeilen-Array pruefen + if(nRow >= rTheTabLines.Count()) nRow = rTheTabLines.Count() - 1; + + // akt. Zeile holen + pTabLine = rTheTabLines[ nRow ]; + + // akt. Boxen-Array holen + pTabBoxes = &pTabLine->GetTabBoxes(); + + // nCol gegen max. Boxenzahl im Boxen-Array pruefen + if (nCol >= pTabBoxes->Count()) nCol = pTabBoxes->Count() - 1; + + // akt. Box holen + pTabBox = (*pTabBoxes)[nCol]; + + // Start-Node der akt. Box holen + const SwNode* pSttNd = pTabBox->GetSttNd(); + + ASSERT(pSttNd, "Probleme beim Aufbau der Tabelle"); + + // JETZT den PaM-Point auf den Start-Node der Box setzen + if (bSetPaM) + { + PtNd( pCurPaM ) = pSttNd->GetIndex()+ 1; + + PtCnt( pCurPaM ).Assign( pCurPaM->GetCntntNode(), 0 ); + } +} + + +void SwW4WParser::Read_BeginTabRow() // (BRO) Header einer Zeile +{ + if( bNoExec && !bBCMStep1 ) + { + return; // Jetzt aber nix wie weg hier! + } + + if( nTablInTablDepth ) // Tabelle / Mehrspaltigkeit IN Tabelle ? + { + return; + } + + long nCols, nHeight, nHeightTw, nJust; + int i; + + if( !bIsColMode ) return; // W4W-Fehler + + if( GetDecimal( nCols ) && !nError && + GetDecimal( nHeight ) && !nError && + GetDecimal( nHeightTw ) && !nError ) + { + nTabRow++; // aktuelle Zeilen-Nr. + + // Merge: nTabCols aus .<CDS> ist der Maximalwert, + // der in .<BRO> nie ueberschritten werden darf. + if( (USHORT)nCols > nTabCols ) + nCols = nTabCols; + + if( bBCMStep1 ) + { + /* + Durchgang 1: Anzahl der Zeilen ermitteln, + Border-Codes fuer alle Spalten einlesen, + aber den Tabelleninhalt noch nicht einlesen + */ + nTabRows++; + + // Border-Zeile an pTabBorders anhaengen + UShortPtr pActRow = new USHORT[ nTabCols ]; + pTabBorders->Insert( pActRow, pTabBorders->Count() ); + + // Codes einlesen + for ( i=0; i < nCols; i++ ) + { + // + // Hinweis: LEIDER schreibt W4W bei WordPerfekt 8 des oefteren + // den Wert 0x0000 anstatt der richtigen Border-Flags. + // Dies geschieht z.B. oft, wenn in WP der Zellen-Rand mit + // der Maus nach oben o. unten geschoben wurde. + // + // Abhilfe: leider unbekannt! + // + USHORT & rActBFlag = pActRow[ i ]; + + if ( !GetHexUShort( rActBFlag ) || nError ) + return; + + // nachschauen, ob spezielle Borders definiert + bTabBorder |= ( rActBFlag != 0x0000 ); + if ( nTabRow==1 && i==0 ) + nTabDefBorder = rActBFlag; + else + if ( rActBFlag != nTabDefBorder ) + bTabSpezBorder = TRUE; + } + if( GetDecimal( nJust ) && !nError ) + { + /*NOP*/ // nJust wird noch ignoriert + } + } + else + { + /* + Durchgang 2: einlesen der Daten vorbereiten + */ + SetPamInCell( nTabRow, 0 ); // noetig ??? + UpdatePercent( rInp.Tell(), nW4WFileSize ); + nLastProcessedCol = -1; + bWasCellAfterCBreak = FALSE; + } + } +} + +// Setze Umrandung, nach SetPamInCell() aufrufen + +USHORT SwW4WParser::Read_SetTabBorder( USHORT nW4WRow, + USHORT nW4WCol, + SvxBoxItem& rFmtBox ) +{ + rFmtBox.SetDistance( DEFAULT_TAB_CELL_DISTANCE ); + + if ( bTabBorder ) + { + USHORT nBor = (*pTabBorders)[ nW4WRow ][ nW4WCol ]; + + if( nBor ) + return Read_SetBorder( nBor, rFmtBox ); + } + return 1; +} + + +SwTableBox* SwW4WParser::UpdateTableMergeGroup( SwSelBoxes_SAR* pActGroup, + SwTableBox* pActBox, + USHORT nCol ) +{ + // ggfs. die Box in fuer diese Col offene Merge-Gruppe eintragen + if( 0 < pTabDefs[ nCol ].nRemainingMergeRows ) + { + // passende Merge-Gruppe uebernehmen bzw. ermitteln + SwSelBoxes_SAR* pTheMergeGroup; + if( pActGroup ) + pTheMergeGroup = pActGroup; + else + { + USHORT nMGrIdx = pTabDefs[ nCol ].nMergeGroupIdx; + ASSERT( nMGrIdx < pMergeGroups->Count(), + "Merge Group Idx zu gross" ); + pTheMergeGroup = (*pMergeGroups)[ nMGrIdx ]; + } + + // aktuelle Box der Merge-Gruppe hinzufuegen + pTheMergeGroup->Insert( pActBox, pTheMergeGroup->Count() ); + + // Merge-Row-Zaehler vermindern + pTabDefs[ nCol ].nRemainingMergeRows--; + + // Target-Box zurueckmelden + return (*pTheMergeGroup)[ 0 ]; + } + else + { + // NULL zurueckmelden + return 0; + } +} + + +void SwW4WParser::Read_BeginTabCell() // (BCO) Header eines Feldes +{ + if( bNoExec && !bBCMStep1 ) + { + return; // Jetzt aber nix wie weg hier! + } + + if( nTablInTablDepth ) // Tabelle / Mehrspaltigkeit IN Tabelle ? + { + return; + } + + long nCol, nCellSpan, nRowSpan, nNotExist, nDecimals; + long nHAlign = 0; + long nVAlign = 0; + SwTableBox* pTargetBox; + + + if (!bIsColMode) return; // W4W-Fehler + + if( GetDecimal( nCol ) && !nError + && GetDecimal( nCellSpan ) && !nError + && GetDecimal( nRowSpan ) && !nError + && GetDecimal( nNotExist ) && !nError + && GetDecimal( nHAlign ) && !nError + && GetDecimal( nDecimals ) && !nError + && GetDecimal( nVAlign ) && !nError ) + { + + // Zelle 0 gilt nicht + if( !nCol ) + return; + + // Spalten-Nr. gegen maximale Zahl der Spalten pruefen + if( nTabCols < (USHORT)nCol ) + return; + + bWasCellAfterCBreak = TRUE; + + // falschen Wert korrigieren + if( nRowSpan < 1 ) + nRowSpan = 1; + + if( bBCMStep1 ) + { + /* + Durchgang 1: ggfs. Borders von Merge-Zellen anpassen + */ + if( nCellSpan > 1 ) + { + USHORT* aThisRow = (*pTabBorders)[ nTabRow-1 ]; + USHORT nActColIdx = (USHORT)nCol-1; + if( nDocType == 44 ) + // Macke WW2: alle Border muessen verodert werden + for (USHORT j=nActColIdx; j < nActColIdx+nCellSpan; j++ ) + { + aThisRow[ nActColIdx ] |= aThisRow[ j ]; + } + else + // rechte Border der re. Zelle in Zelle 1 hineinodern + aThisRow[ nActColIdx ] + |= (aThisRow[ nActColIdx+nCellSpan-1 ] & 0x000f); + // Re. Border der re. Zelle entsprechend setzen. + // Diese wird nie sichtbar, ermoeglicht aber die + // Randkorrektur in SwW4WParser::Read_BeginColumnMode() + aThisRow[ nActColIdx+nCellSpan-1 ] &= 0xfff0; + aThisRow[ nActColIdx+nCellSpan-1 ] |= + ( aThisRow[ nActColIdx ] & 0x000f ); + } + } + else + { + /* + Durchgang 2: Tabelleninhalt einlesen + */ + + nParaLen = 0; // Neuer TextNode aktiv -> noch kein Zeichen drin + + // korrigiere nCol (tatsaechliche Zellen-Nr beginnt ja mit 0) + nCol--; + + // merke nCol in nTabCol (auch in W4WPAR1.CXX mehrfach benoetigt) + nTabCol = (USHORT)nCol; + + SetPamInCell( nTabRow, nTabCol ); + if ( bTabOwnFrm ) + { + pTabBox->ClaimFrmFmt(); + pTabBox->GetFrmFmt()->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, + pTabDefs[ nTabCol ].nWidthFrac )); + } + SvxBoxItem aFmtBox; + USHORT nRet + = Read_SetTabBorder( nTabRow, nTabCol, aFmtBox ); + // eigenes Format, falls noch nicht vorhanden + if ( 0 != nRet ) + pTabBox->ClaimFrmFmt(); + // Setze evtl Umrandung + if ( 0 != ( 0x1 & nRet )) + pTabBox->GetFrmFmt()->SetAttr( aFmtBox ); + // setze evtl Hintergrund + if ( 0 != ( 0x2 & nRet )) + { + const Color aCol( COL_LIGHTGRAY ); + const SvxBrushItem aBack( aCol, RES_BACKGROUND ); + pTabBox->GetFrmFmt()->SetAttr( aBack ); + } + + SwSelBoxes_SAR* pActMGroup = 0; + + /* + ggfs. eine neue Merge-Gruppe beginnen + */ + if( ( 0 == pTabDefs[ nTabCol ].nRemainingMergeRows ) + && ( (nCellSpan > 1) + || (nRowSpan > 1) ) ) + { + // 0. falls noetig das Array fuer die Merge-Gruppen anlegen + if( !pMergeGroups ) + pMergeGroups = new W4WMergeGroups; + + // 1. aktuelle Merge-Gruppe anlegen + // und in Gruppen-Array eintragen + pActMGroup = new SwSelBoxes_SAR( BYTE(nCellSpan * nRowSpan)); + + pMergeGroups->Insert( pActMGroup, pMergeGroups->Count() ); +// pMergeGroups->Insert( pActMGroup, pMergeGroups->Count() ); + + // 3. Index dieser Merge-Gruppe und Anzahl der betroffenen + // Zeilen in allen betroffenen Spalten vermerken + USHORT nMGrIdx = pMergeGroups->Count()-1; + long nSizCell = 0; + + for( USHORT i = 0; i < nCellSpan; i++ ) + { + pTabDefs[ nTabCol+i ].nMergeGroupIdx = nMGrIdx; + pTabDefs[ nTabCol+i ].nRemainingMergeRows = nRowSpan; + // dabei auch gleich die Gesamtbreite berechnen + nSizCell += pTabDefs[ nTabCol+i ].nWidthFrac; + } + + /* + 4. Target-Box anlegen und als 0. in Merge-Group setzen + */ + pDoc->GetNodes().InsBoxen( + pTblNd, pTabLine, + (SwTableBoxFmt*)pTabBox->GetFrmFmt(), + (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl(), + 0, + nTabCol ); + pTargetBox = (*pTabBoxes)[ nTabCol ]; + // eingefuegte Box wieder aus der Row entfernen + // (wird vom Merge() dann endgueltig richtig eingebaut) + pTabBoxes->Remove( nTabCol ); + // 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 zuweisen + pNewFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nSizCell )); + } + + // ggfs. akt. Box zu einer Merge-Group hinzufuegen + pTargetBox = UpdateTableMergeGroup( pActMGroup,pTabBox,nTabCol ); + 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 ?"); + + PtNd( pCurPaM ) = pEndNd->GetIndex(); + + pCurPaM->Move( fnMoveBackward ); + } + + + const SwPosition& rPos = *pCurPaM->GetPoint(); + // Override Style "Tabellenkopf", "Tabelleninhalt" mit + // vorher gueltigem Style wenn kein Style hart gesetzt ist + if ( !bIsSTYInTab ) + { + pCtrlStck->NewAttr( rPos, SwW4WStyle( nTabStyleId ) ); + pCtrlStck->SetAttr( rPos, RES_FLTR_STYLESHEET ); + } + // setze die horizontale Zellenausrichtung + switch( nHAlign ) + { + case 0:pCtrlStck->NewAttr( rPos, SvxAdjustItem( SVX_ADJUST_LEFT )); break; + case 1:pCtrlStck->NewAttr( rPos, SvxAdjustItem( SVX_ADJUST_BLOCK )); break; + case 2:pCtrlStck->NewAttr( rPos, SvxAdjustItem( SVX_ADJUST_CENTER )); break; + case 3:pCtrlStck->NewAttr( rPos, SvxAdjustItem( SVX_ADJUST_RIGHT )); break; + case 4:pCtrlStck->NewAttr( rPos, SvxAdjustItem( SVX_ADJUST_RIGHT )); break; + } + pCtrlStck->SetAttr( rPos, RES_PARATR_ADJUST ); + nLastProcessedCol = nCol; + } + } +} + + +void SwW4WParser::Read_ColumnBreak() // (HCB, SCB) +{ + if( pBehindSection ) // im spaltigen Bereich + { + pDoc->AppendTxtNode( *pCurPaM->GetPoint() ); + pDoc->Insert(*pCurPaM, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE )); + } + + if( !bIsColDefTab ) return; // W4W-Fehler; + + if( nTablInTablDepth ) // Tabelle / Mehrspaltigkeit IN Tabelle ? + { + return; + } + + if( !bIsColMode ) + { + return; // noch keine Mehrspaltigkeit ohne Tabelle + } + + +#ifdef MOGEL_WW2 + if ( nDocType == 44 ) //!!! Schlechte Umpopelung eines Fehlers : + // Beim Import von WW2-Tabellen mit CTX, AFR in der + // 1. Zelle ( Spalte? ) der Tabelle wird 2mal das + // Attribut ausgeschaltet. Dadurch erkenne ich eine + // harte Attribut-Ausschaltung, was in diesem Fall + // nicht stimmt. + // Diese Umpopelung sollte verschwinden, sobald MASO + // den Fehler beseitigt hat, da hiermit in Tabellen + // die Moeglichkeit einer harten Attributausschaltung + // abgeklemmt wird. + pCtrlStck->StealWWTabAttr( *pCurPaM->GetPoint() ); +#endif + + // sicherstellen, dass wir keine Zelle uebersprungen haben + if( bIsColDefTab && !bWasCellAfterCBreak ) + { + nLastProcessedCol++; + + // Spalten-Nr. (mit Offs. 0) gegen max. Spalten-Zahl pruefen + if( nTabCols-1 < (USHORT)nLastProcessedCol ) + return; + + SetPamInCell( nTabRow, (USHORT)nLastProcessedCol ); + SvxBoxItem aFmtBox; + if ( bTabOwnFrm ) + { + pTabBox->ClaimFrmFmt(); + pTabBox->GetFrmFmt()->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, + pTabDefs[ nLastProcessedCol ].nWidthFrac )); + } + USHORT nRet = Read_SetTabBorder(nTabRow, + (USHORT)nLastProcessedCol, + aFmtBox ); + + UpdateTableMergeGroup( 0, pTabBox, (USHORT)nLastProcessedCol ); + + // eigenes Format, falls noch nicht vorhanden + if ( 0 != nRet ) + pTabBox->ClaimFrmFmt(); + // Setze evtl Umrandung + if ( 0 != ( 0x1 & nRet )) + pTabBox->GetFrmFmt()->SetAttr( aFmtBox ); + // setze evtl Hintergrund + if ( 0 != ( 0x2 & nRet )) + { + const Color aCol( COL_LIGHTGRAY ); + const SvxBrushItem aBack( aCol, RES_BACKGROUND ); + pTabBox->GetFrmFmt()->SetAttr( aBack ); + } + // Override Style "Tabellenkopf", "Tabelleninhalt" mit + // vorher gueltigem Style wenn kein Style hart gesetzt ist + if ( !bIsSTYInTab ) + { + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->NewAttr( rPos, SwW4WStyle( nTabStyleId ) ); + pCtrlStck->SetAttr( rPos, RES_FLTR_STYLESHEET ); + } + /* + const Color aCol( COL_LIGHTRED ); + const Brush aBrush( aCol ); + const SvxBrushItem aBack( aBrush, RES_BACKGROUND ); + pTabBox->GetFrmFmt()->SetAttr( aBack ); + +#ifdef TEST_BOX + String sHlp = "forgotten Box now inserted\n\nat Row #"; + sHlp += nTabRow; + sHlp += " Col #"; + sHlp += nLastProcessedCol; + InfoBox(0, sHlp).Execute(); +#endif + */ + } + ActivateTxtFlags(); // .<HCB> gilt als 'Text ist aufgetreten' + + /* + BOOL bOldTxtInPgD = bIsTxtInPgDesc; + + + if( bHeadFootDef ) + bIsTxtInPgDesc = bOldTxtInPgD; // beruecksichtige, dass es auch Tabellen in Hd/Ft geben kann! + */ + + bIsTxtInPara = FALSE; + bIsSTMInPara = FALSE; + bIsNumListPara = FALSE; + bWasCellAfterCBreak = FALSE; +} + + + + +/*************************************************************************************** +Fuss- und Endnoten +***************************************************************************************/ + + +void SwW4WParser::Read_FootNoteStart(char nType, BYTE nNoLow, + BYTE nNoHigh, + USHORT nFootNo) +{ + if ( pCurPaM->GetPoint()->nNode < pDoc->GetNodes().GetEndOfExtras().GetIndex() ) + { + BOOL bOldTxtInDoc = bTxtInDoc; + BOOL bOldNExec = bNoExec; + bTxtInDoc = FALSE; + bNoExec = TRUE; + bFootnoteDef = TRUE; + + while( (!nError) + && bFootnoteDef // ignoriere Footnote-Text + && (EOF != GetNextRecord())) //$ EOF + ; + bTxtInDoc = bOldTxtInDoc; + bNoExec = bOldNExec; + return; + } + + nFtnType = nType; + + const SwEndNoteInfo* pInfo; + + SwFmtFtn aFtn; + + /* + TYP der Fuss-/Endnote ermitteln + */ + if( 2 == nFtnType ) + { + // End-Note + aFtn.SetEndNote( TRUE ); + SwEndNoteInfo aInfo( pDoc->GetEndNoteInfo() ); + if( !bEndNoteInfoAlreadySet ) + { + // am liebsten kleine, roemische Ziffern (i, ii, iii, iv...) + aInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER); + // ansonsten Kleinbuchstaben (a, b, c, d...) + if( bFtnInfoAlreadySet + && ( SVX_NUM_ROMAN_LOWER == pDoc->GetFtnInfo().aFmt.GetNumberingType() ) ) + aInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); + bEndNoteInfoAlreadySet = TRUE; + } + pDoc->SetEndNoteInfo( aInfo ); + pInfo = &pDoc->GetEndNoteInfo(); + } + else + { + // Fuss-Note + SwFtnInfo aInfo( pDoc->GetFtnInfo() ); + // aInfo.ePos = ( nFtnType!=2 ) ? FTNPOS_PAGE : FTNPOS_CHAPTER; + aInfo.ePos = FTNPOS_PAGE; + if( !bFtnInfoAlreadySet ) + { + // am liebsten arabische Ziffern (1, 2, 3, 4...) + aInfo.aFmt.SetNumberingType(SVX_NUM_ARABIC); + // ansonsten Kleinbuchstaben (a, b, c, d...) + if( bEndNoteInfoAlreadySet + && ( SVX_NUM_ARABIC == pDoc->GetEndNoteInfo().aFmt.GetNumberingType() ) ) + aInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); + bFtnInfoAlreadySet = TRUE; + } + pDoc->SetFtnInfo( aInfo ); + pInfo = &pDoc->GetFtnInfo(); + } + + /* + abzuziehenden Differenzwert ermitteln + */ + BOOL bSingleLetter = FALSE; + BYTE nSingleLetterDelta = 0; + if( !nFootNo ) + { + if( SVX_NUM_CHARS_LOWER_LETTER == pInfo->aFmt.GetNumberingType() ) + { + bSingleLetter = TRUE; + nSingleLetterDelta = 0x60; + } + else if( SVX_NUM_CHARS_UPPER_LETTER == pInfo->aFmt.GetNumberingType() ) + { + bSingleLetter = TRUE; + nSingleLetterDelta = 0x40; + } + } + + /* + Ueberlauf pruefen + */ + if( bSingleLetter ) + { + // vorlaeufiger Wert setzen + nFootNo = nNoLow; + if( 2 == nFtnType ) + { + // Ende-Note + nFootNo += 0x100 * nEndNoOverflow; + // Ueberlaufpruefung + if( 0xFF == ( nFootNo & 0xFF ) ) + nEndNoOverflow++; + } + else + { + // Fuss-Note + nFootNo += 0x100 * nFootNoOverflow; + // Ueberlaufpruefung + if( 0xFF == ( nFootNo & 0xFF ) ) + nFootNoOverflow++; + } + // endgueltiger Wert + nFootNo -= nSingleLetterDelta; + } + else + { + // gleich den richtigen Wert setzen + nFootNo = (nNoHigh << 8) | nNoLow; + } + + /* + Kontinuitaet pruefen + */ + if( 2 == nFtnType ) + { + if( ( USHRT_MAX != nLastReadEndNo ) + && ( nFootNo != nLastReadEndNo+1 ) ) + { + bEndNoteNumberAutomatic = FALSE; + } + nLastReadEndNo = nFootNo; + } + else + { + // Bei Fussnoten auf Neu-Zaehlung je Seite pruefen + if( ( USHRT_MAX != nLastReadFootNo ) + && ( nFootNo != nLastReadFootNo+1 ) ) + { + if( ( 1 == nFootNo ) + && ( VALUE_FALSE != eFootNotePageRestart ) + && !bWasFootNoteOnW4WPage ) + { + eFootNotePageRestart = VALUE_TRUE; + } + else + { + bFootNoteNumberAutomatic = FALSE; + eFootNotePageRestart = VALUE_FALSE; + } + } + else + { // es gab *keinen* Bruch, also + // nachschauen, ob jede/s Seite mit 1 anfaengt + if( ( 1 != nFootNo ) && !bWasFootNoteOnW4WPage ) + { + eFootNotePageRestart = VALUE_FALSE; + } + } + bWasFootNoteOnW4WPage = TRUE; + nLastReadFootNo = nFootNo; + } + + /* + ACHTUNG: die NUMMER wird HIER hart eingesetzt. + Die automatische Berechnung durch den Writer wird ggfs. + erst am Ende von ::CallParser aktiviert, wenn dort + zweifelsfrei feststeht, dass die Zaehlung im gesamten + Dokument kontinuierlich verlief. + */ + String sMyStr( pInfo->GetPrefix() ); + sMyStr += pInfo->aFmt.GetNumStr( nFootNo ); + sMyStr += pInfo->GetSuffix(); + + aFtn.SetNumStr( sMyStr ); + + pDoc->Insert( *pCurPaM, aFtn ); + + // merke alte Cursorposition + SwPosition aTmpPos( *pCurPaM->GetPoint() ); + + pCurPaM->Move( fnMoveBackward, fnGoCntnt ); + + SwTxtNode* pTxt = pCurPaM->GetNode()->GetTxtNode(); + SwTxtAttr* pFN = pTxt->GetTxtAttr( pCurPaM->GetPoint()->nContent, RES_TXTATR_FTN ); + ASSERT(pFN, "Probleme beim Anlegen des Fussnoten-Textes"); + + const SwNodeIndex* pSttIdx = ((SwTxtFtn*)pFN)->GetStartNode(); + ASSERT(pSttIdx, "Probleme beim Anlegen des Fussnoten-Textes"); + + PtNd( pCurPaM ) = pSttIdx->GetIndex() + 1; + PtCnt( pCurPaM ).Assign( pCurPaM->GetCntntNode(), 0 ); + + USHORT nOldStyleId = nAktStyleId; + W4WCtrlStack* pOldStack = pCtrlStck; + pCtrlStck = new W4WCtrlStack( *pOldStack, *pCurPaM->GetPoint() ); + + // grosser Mist: eingeschalteter SuperScript-Modus kann die gesamte + // Fussnote vermurksen, daher hier auf jeden Falle ausschalten ... + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), SVX_ESCAPEMENT_OFF ); + + /* + lies Footnote-Text ein, dabei ersten, fuehrenden TAB uebergehen + */ + bFootnoteDef = TRUE; + bIsTxtInFNote = FALSE; + while(!nError && bFootnoteDef + && (EOF!=GetNextRecord())) + ; + + // UEble Sache: W4W liefert manchmal ein ueberfluessiges + // .<HNL> am Ende der Fussnoten! + // Hilfskonstruktion: Wir pruefen, ob der letzte Absatz + // der Fussnote Text enthaelt und entfernen ihn andernfalls: + if( !bIsTxtInPara ) + JoinNode( pCurPaM ); + + DeleteZStk( pCtrlStck ); + pCtrlStck = pOldStack; + nAktStyleId = nOldStyleId; + pCtrlStck->SetEndForClosedEntries( aTmpPos ); + *pCurPaM->GetPoint() = aTmpPos; +} + + +void SwW4WParser::Read_FootNoteStart1() // (FNT) +{ + BYTE nDef; + BYTE nNumberHi, nNumberLo; + + if( GetHexByte( nDef ) && !nError && GetHexByte( nNumberHi ) && !nError + && GetHexByte( nNumberLo ) && !nError ) + { + SkipEndRecord(); // restliche Parameter interessieren nicht + Read_FootNoteStart( nDef, nNumberLo, nNumberHi, 0 ); + } +} + + +void SwW4WParser::Read_FootNoteStart2() // (FTN) +{ + long nNumber; + + if( GetDecimal( nNumber ) && !nError) + { + SkipEndRecord(); // restliche Parameter interessieren nicht + Read_FootNoteStart( 0, 0, 0, (USHORT)nNumber); + } +} + + +void SwW4WParser::Read_FootNoteEnd() // (EFN, EFT) +{ + bFootnoteDef = FALSE; +} + + +void SwW4WParser::SetFtnInfoIntoDoc(BOOL bEndNote, + BYTE nRestart, + BYTE nStyle, + String& rPrefixTxt, + String& rSuffixTxt ) +{ + static SvxExtNumType __READONLY_DATA aNumArr[] + = { SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_CHARS_LOWER_LETTER, SVX_NUM_CHARS_UPPER_LETTER, + SVX_NUM_ROMAN_LOWER, SVX_NUM_ROMAN_UPPER }; + if( bEndNote ) + { + // End-Noten + SwEndNoteInfo aInfo; + aInfo = pDoc->GetEndNoteInfo(); + if (nStyle <= 5) + aInfo.aFmt.SetNumberingType(aNumArr[ nStyle ]); + // sicherstellen, dass Typ anders als Fussnoten-Typ + if( bFtnInfoAlreadySet + && ( aInfo.aFmt.GetNumberingType() == pDoc->GetFtnInfo().aFmt.GetNumberingType() ) ) + { + if( SVX_NUM_ROMAN_LOWER == aInfo.aFmt.GetNumberingType() ) + aInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); + else + aInfo.aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER); + } + aInfo.SetPrefix( rPrefixTxt ); + aInfo.SetSuffix( rSuffixTxt ); + pDoc->SetEndNoteInfo( aInfo ); + bEndNoteInfoAlreadySet = TRUE; + } + else + { + // Fuss-Noten + SwFtnInfo aInfo; + aInfo = pDoc->GetFtnInfo(); + aInfo.ePos = nRestart ? FTNPOS_PAGE : FTNPOS_CHAPTER; + if (nStyle <= 5) + aInfo.aFmt.SetNumberingType(aNumArr[ nStyle ]); + // sicherstellen, dass Typ anders als Endnoten-Typ + if( bEndNoteInfoAlreadySet + && ( aInfo.aFmt.GetNumberingType() == pDoc->GetEndNoteInfo().aFmt.GetNumberingType() ) ) + { + if( SVX_NUM_ARABIC == aInfo.aFmt.GetNumberingType() ) + aInfo.aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); + else + aInfo.aFmt.SetNumberingType(SVX_NUM_ARABIC); + } + aInfo.SetPrefix( rPrefixTxt ); + aInfo.SetSuffix( rSuffixTxt ); + pDoc->SetFtnInfo( aInfo ); + bFtnInfoAlreadySet = TRUE; + } +} + + +void SwW4WParser::Read_FootNoteInfo() // (FNI) +{ + BYTE nDef; + BYTE nRestart, nStyle; + + if( GetHexByte( nDef ) && !nError && GetHexByte( nRestart ) && !nError + && GetHexByte( nStyle ) && !nError ) + { + String aPrefixTxt; + String aSuffixTxt; + if( GetString( aPrefixTxt, W4WR_TXTERM, W4WR_TXTERM ) ) + GetString( aSuffixTxt, W4WR_TXTERM, W4WR_TXTERM ); + SetFtnInfoIntoDoc( ( 2 == nDef ), + nRestart, + nStyle, + aPrefixTxt, + aSuffixTxt ); + } +} + + + +void SwW4WParser::UpdateCacheVars() +{ +#if 0 + const SwFrmFmt &rFmt = pPageDesc->GetMaster(); + ASSERT( pPageDesc->GetMaster().GetFrmSize().GetFixSize() != LONG_MAX , + "Seitenbreite (Master) falsch" ); + ASSERT( pPageDesc->GetLeft().GetFrmSize().GetFixSize() != LONG_MAX , + "Seitenbreite (Left) falsch" ); + ASSERT( pPageDesc->GetMaster().GetFrmSize().GetVarSize() != LONG_MAX , + "Seitenlaenge (Master) falsch" ); + ASSERT( pPageDesc->GetLeft().GetFrmSize().GetVarSize() != LONG_MAX , + "Seitenlaenge (Left) falsch" ); +#else + SwFrmFmt *pFmt = &pPageDesc->GetLeft(); + SwFmtFrmSize aSz( pFmt->GetFrmSize() ); + BOOL bSet = FALSE; + if (( aSz.GetWidth() > 2 * lA3Height ) // Kein Drucker + ||( aSz.GetWidth() < lA5Width / 2 )) // Kein Drucker + { + aSz.SetWidth( lA4Width ); + bSet = TRUE; + } + + if (( aSz.GetHeight() > 2 * lA3Height ) // Kein Drucker + ||( aSz.GetHeight() < lA5Width / 2 )) // Kein Drucker + { // Dann A4 + aSz.SetHeight( lA4Height ); + bSet = TRUE; + } + if( bSet ) + pFmt->SetAttr( aSz ); + + pFmt = &pPageDesc->GetMaster(); + aSz = pFmt->GetFrmSize(); + bSet = FALSE; + if (( aSz.GetWidth() > 2 * lA3Height ) // Kein Drucker + ||( aSz.GetWidth() < lA5Width / 2 )) // Kein Drucker + { + aSz.SetWidth( lA4Width ); + bSet = TRUE; + } + + if (( aSz.GetHeight() > 2 * lA3Height ) // Kein Drucker + ||( aSz.GetHeight() < lA5Width / 2 )) // Kein Drucker + { // Dann A4 + aSz.SetHeight( lA4Height ); + bSet = TRUE; + } + if( bSet ) + pFmt->SetAttr( aSz ); + +#endif + const SvxLRSpaceItem& rPageLR = pFmt->GetLRSpace(); + nPgLeft = (USHORT)(rPageLR.GetTxtLeft() + nLeftMgnCorr); + nPgRightDelta = (USHORT)( rPageLR.GetRight() ); + nPgRight = (USHORT)( aSz.GetWidth() - rPageLR.GetRight() ); + //!! nRSMRight + Left auch Updaten ???? +} + + +/*************************************************************************************** +Kopf- und Fusszeilen +***************************************************************************************/ + +#define W4W_EVEN 0x1 // linke Seiten +#define W4W_ODD 0x2 // rechte Seiten +#define W4W_EVENODD 0x3 // alle Seiten == EVEN | ODD +#define W4W_MASK1 0x3 // Maske fuer links/rechts +#define W4W_FIRST 0x10 // 1. Seite ? +#define W4W_NFIRST 0x20 // Vorsicht bei AEndern dieser Konstanten: +#define W4W_ALL 0x30 // FIRST | NFIRST == ALL +#define W4W_MASK2 0x30 // Maske fuer erste / andere / alle Seiten +#define W4W_HEADER 0x100 +#define W4W_FOOTER 0x200 +#define W4W_FOOTNOTE 0x300 +#define W4W_MASK3 0x300 // Maske fuer Header / Footer / Footnote +#define W4W_NO2 0x1000 // Hd/Ft #2 aus W4W-Datei + + +SwFrmFmt* lcl_GetMasterLeft( SwPageDesc& rPgDsc, USHORT nType ) +{ + SwFrmFmt* pFmt = 0; + switch ( nType & W4W_MASK1 ){ + case W4W_EVENODD: pFmt = &rPgDsc.GetMaster(); + break; + case W4W_EVEN: pFmt = &rPgDsc.GetLeft(); + break; + case W4W_ODD: pFmt = &rPgDsc.GetMaster(); + break; + } + ASSERT( 0 != pFmt, "header/footer ohne entsprechendes Format im PgDesc" ); + + return pFmt; +} + + +void lcl_GetMstLftHdFt( SwPageDesc& rPgDsc, USHORT nType, + BOOL bDoTheHeader, + SwFrmFmt*& rpMasterLeft, + SwFrmFmt*& rpHdFtFmt ) +{ + rpMasterLeft = lcl_GetMasterLeft( rPgDsc, nType ); + if( bDoTheHeader ) + rpHdFtFmt = (SwFrmFmt*)rpMasterLeft->GetHeader().GetHeaderFmt(); + else + rpHdFtFmt = (SwFrmFmt*)rpMasterLeft->GetFooter().GetFooterFmt(); +} + + +BOOL SwW4WParser::ContinueHdFtDefinition( BOOL bFollow, + long nLMarg, + long nRMarg ) +{ + BOOL bDoCreatePageDesc; + BOOL bRet = FALSE; + SwFrmFmt* pMasterLeft = 0; + SwFrmFmt* pHdFtFmt = 0; + SwPageDesc* pThisPageDesc = 0; + UseOnPage eOldHdFtShare = PD_NONE; + + BOOL bDoTheHeader = ( W4W_HEADER == (nHdFtType & W4W_MASK3) ); + ASSERT( bDoTheHeader != ( W4W_FOOTER == (nHdFtType & W4W_MASK3) ), + "Hier muss Header ODER Footer definiert werden" ); + + // something special: + // + // when a Follow was allready defined + // and now we are to define a START-PgDesc + // we will use the old(!) Start-PgDesc + // that was active before the definition of it's Follow + // + if( pOpen1stPgPageDesc + && ( nPDType == W4W_FIRST ) + && !bIsTxtInPgDesc ) + { + pThisPageDesc = pOpen1stPgPageDesc; + lcl_GetMstLftHdFt( *pThisPageDesc, nHdFtType, + bDoTheHeader, + pMasterLeft, pHdFtFmt ); + /* + * Do NOT create a new PgDesc !!! + */ + bDoCreatePageDesc = FALSE; + } + else + { + pThisPageDesc = pPageDesc; + // Let's see if the current Page-Descriptor + // has got a Header/Footer of this type + lcl_GetMstLftHdFt( *pThisPageDesc, nHdFtType, + bDoTheHeader, + pMasterLeft, pHdFtFmt ); + + /* + * in case of PageDesc still waiting for next chance + * use this one and do NOT create a new PgDesc !!! + */ + if( pPageDescForNextHNP ) + bDoCreatePageDesc = FALSE; + else + if( pOpen1stPgPageDesc + && ( 33 == nDocType ) ) + /* + * Do NOT create a new PgDesc !!! + */ + bDoCreatePageDesc = FALSE; + else + /* + * We need a new PgDesc, when there's allready text in the current + * PgDesc and a Header/Footer of the same kind is also defined. + */ + bDoCreatePageDesc = ( ( bIsTxtInPgDesc + && pHdFtFmt ) + || ( bFollow + && !pOpen1stPgPageDesc ) ); + } + + UseOnPage eOldUse = pThisPageDesc->ReadUseOn(); + if( bDoTheHeader ) + eOldHdFtShare = (UseOnPage) + (eOldHdFtShare | ( eOldUse & PD_FOOTERSHARE )); + else + eOldHdFtShare = (UseOnPage) + (eOldHdFtShare | ( eOldUse & PD_HEADERSHARE )); + + // create [and insert] the new Page Descriptor + if( bDoCreatePageDesc ) + { + USHORT eCreateMode = 0; + + if( bFollow ) + eCreateMode |= CRPGD_AS_FOLLOW; + + // Should the new PgDesc be instantly inserted into the pDoc ? + if( bIsTxtInPgDesc && !bFollow) + eCreateMode |= CRPGD_AND_INSERT; + + if( bDoTheHeader ) + eCreateMode |= CRPGD_REMOVE_HD; + else + eCreateMode |= CRPGD_REMOVE_FT; + + + if( bFollow + && !(eCreateMode & CRPGD_AND_INSERT) + && !pOpen1stPgPageDesc ) + { + pOpen1stPgPageDesc = pThisPageDesc; + } + + BOOL bAmiProHdFtMustWait = ( 33 == nDocType ); + if ( bAmiProHdFtMustWait ) + { + // with AmiPro NEVER insert Hd/Ft instantly into the pDoc + // but store the PgDesc elswhere and insert it + // when the next .<HNP> occurs ( see W4WPAR1.CXX ) + eCreateMode &= ~CRPGD_AND_INSERT; + } + + CreatePageDesc( eCreateMode ); + + // Attention: pPageDesc points NOW to the newly created PgDesc + // no matter if it was inserted into the pDoc or not + if( bAmiProHdFtMustWait ) + { + pPageDescForNextHNP = pPageDesc; + } + pThisPageDesc = pPageDesc; + lcl_GetMstLftHdFt( *pThisPageDesc, nHdFtType, + bDoTheHeader, + pMasterLeft, pHdFtFmt ); + bRet = TRUE; + } + + // create HEADER + if( bDoTheHeader ) + { + bWasTxtSinceLastHF2 = FALSE; + // if old header exists we remove it to erase it's content section + if( pHdFtFmt ) + pMasterLeft->ResetAttr( RES_HEADER ); + // our new header + pMasterLeft->SetAttr( SwFmtHeader( TRUE )); + pHdFtFmt = (SwFrmFmt*)pMasterLeft->GetHeader().GetHeaderFmt(); + + } + // create FOOTER + else + { + bWasTxtSinceLastHF1 = FALSE; + // if old footer exists we remove it to erase it's content section + if( pHdFtFmt ) + pMasterLeft->ResetAttr( RES_FOOTER ); + // our new footer + pMasterLeft->SetAttr( SwFmtFooter( TRUE )); + pHdFtFmt = (SwFrmFmt*)pMasterLeft->GetFooter().GetFooterFmt(); + } + + //JP 29.5.2001: Bug #74471#: + // "share" the content of the header / footer of the first and the + // following pagedesc. + BOOL bShareHdFtCntntOfFirstPgDsc = FALSE; + if( pOpen1stPgPageDesc && W4W_EVENODD == (nHdFtType & W4W_MASK1) ) + { + SwFrmFmt* pTmp = &pOpen1stPgPageDesc->GetMaster(); + if( SFX_ITEM_SET != pTmp->GetItemState( + bDoTheHeader ? RES_HEADER : RES_FOOTER )) + { + if( bDoTheHeader ) + pTmp->SetAttr( SwFmtHeader( TRUE )); + else + pTmp->SetAttr( SwFmtFooter( TRUE )); + bShareHdFtCntntOfFirstPgDsc = TRUE; + } + } + + // Define the PgDesc's eUse flag: PD_ALL with/without PD_xxSHARE + UseOnPage eUse = PD_ALL; + if( ( nHdFtType & W4W_MASK1 ) == W4W_EVENODD ) + { + if( bDoTheHeader ) + eUse = (UseOnPage)(eUse | PD_HEADERSHARE); + else + eUse = (UseOnPage)(eUse | PD_FOOTERSHARE); + } + pThisPageDesc->WriteUseOn( (UseOnPage)(eUse | eOldHdFtShare) ); + + +#ifdef HDFT_MARGIN + /* + * Raender gemaess rudimentaeren Angaben aus w4w-File setzen + * wird meistens ungenau, da Angabe in Spalten (d.h. in 10tel Inch) + * erst neuerdings gibt W4W uns hier Twips durch + * (Werte werden unten in Read_HdFtDefinition() hochgerechnet) + */ + long nHdFtLeft; + long nHdFtRight; + + // die W4W-Angaben gelten ab Seitenrand !! + const SvxLRSpaceItem& rPageLR = pMasterLeft->GetLRSpace(); + + nHdFtLeft = nLMarg - rPageLR.GetLeft(); // Twips + + nHdFtRight = pMasterLeft->GetFrmSize().GetWidth() // Twips + - rPageLR.GetRight() // Twips + - nRMarg; // Twips + + if ( nHdFtLeft < 0 ) nHdFtLeft = 0; + if ( nHdFtRight < 0 ) nHdFtRight = 0; + + SvxLRSpaceItem aLR( pHdFtFmt->GetLRSpace() ); // LR-Rand + + aLR.SetLeft( USHORT( nHdFtLeft ) ); + aLR.SetRight( USHORT( nHdFtRight ) ); + + pHdFtFmt->SetAttr( aLR ); +#endif // HDFT_MARGIN + + if( bDoTheHeader ) + UpdatePageMarginSettings( CALLED_BY_HF2 ); + else + UpdatePageMarginSettings( CALLED_BY_HF1 ); + + const SwNodeIndex* pSttIdx = pHdFtFmt->GetCntnt().GetCntntIdx(); + if( !pSttIdx ) return bRet; + + USHORT nOldStyleId = nAktStyleId; + W4WCtrlStack* pOldStack = pCtrlStck; + + // alte Cursorposition merken + SwPosition aTmpPos( *pCurPaM->GetPoint() ); + + PtNd( pCurPaM ) = pSttIdx->GetIndex() + 1; + PtCnt( pCurPaM ).Assign( pCurPaM->GetCntntNode(), 0 ); + + if( ( nIniFlags && W4WFL_ALL_HDFT_MAINATTR ) + || ( ( nDocType == 15) + && !( nIniFlags & W4WFL_NO_PCTEXT4_HDFT_MAINATTR ) ) ) + pCtrlStck = new W4WCtrlStack( *pOldStack, *pCurPaM->GetPoint() ); + else + pCtrlStck = new W4WCtrlStack( *this ); + + bHeadFootDef = TRUE; + + // K/F-Text einlesen + while ( !nError + && bHeadFootDef + && ( EOF != GetNextRecord() ) ) + { + ;//NOP + } + +#ifdef MOGEL_WW2 + if ( !(nIniFlags & W4WFL_NO_APO_HNL_REMOVE) && nDocType == 44 + && !bIsTxtInPara ) + { + const SwNode* pNd = pCurPaM->GetNode(); + if( 2 < ( pNd->EndOfSectionIndex() - pNd->StartOfSectionIndex() )) + { // Bit 4 : HNL nicht klauen, bevor die Attribute gesetzt sind + pCtrlStck->StealAttr( *pCurPaM->GetPoint() ); + JoinNode( pCurPaM ); + } + } +#endif + + DeleteZStk( pCtrlStck ); + pCtrlStck = pOldStack; + nAktStyleId = nOldStyleId; + pCtrlStck->SetEndForClosedEntries( aTmpPos ); + *pCurPaM->GetPoint() = aTmpPos; + + if( bShareHdFtCntntOfFirstPgDsc ) + { + if( bDoTheHeader ) + pDoc->CopyHeader( pThisPageDesc->GetMaster(), + pOpen1stPgPageDesc->GetMaster() ); + else + pDoc->CopyFooter( pThisPageDesc->GetMaster(), + pOpen1stPgPageDesc->GetMaster() ); + } + + return bRet; +} + + +void SwW4WParser::Read_HdFtDefinition( BOOL bHeader ) +{ + BOOL bFollow = FALSE; + BYTE nOldDef; + long nOldLines, nLMarg, nRMarg, nPos, nLinePos; + + if( GetHexByte( nOldDef ) && !nError + && GetDecimal( nOldLines ) && !nError + && GetDecimal( nLMarg ) && !nError + && GetDecimal( nRMarg ) && !nError + && GetDecimal( nPos ) && !nError + && GetDecimal( nLinePos ) && !nError ) + { + long nHdFtUl = nLinePos * 240; // Grundlage: Zeilenabstand 6 LPI + // stimmt so zumindest fuer WW2 + // was tun wir mit diesem Wert? + // vielleicht sollten wir nHdFtUl + // ggfs. in nNewValueHTM umwandeln ??? + + // gibt es die optionale Angabe ? + long nOptNew1, nOptNew2; + if( W4WR_TXTERM == GetDecimal( nOptNew1 ) && !nError && + W4WR_TXTERM == GetDecimal( nOptNew2 ) && !nError ) + { + nLMarg = nOptNew1; // in Twip + nRMarg = nOptNew2; + }else + { + nLMarg *= nColSize; // in 1/10 Inch / ?? + nRMarg *= nColSize; + } + + USHORT nOldPDT = nPDType; + + Flush(); + + ULONG nOldPos = rInp.Tell(); // merke FilePos + // ======================== + + BOOL bOldTxtInDoc=bTxtInDoc; + BOOL bOldNoExec=bNoExec; + BYTE nOldErr=nError; + + bTxtInDoc=FALSE; + bHeadFootDef = TRUE; + bNoExec = TRUE; + + // Suche das Ende der Kopf-/Fusstext-Definition (HFX) + // und lies die Parameter + // siehe: SwW4WParser::Read_HeadFootEnd() + while (!nError && bHeadFootDef + && (EOF!=GetNextRecord())) + ; + + Flush(); + nError=nOldErr; + bTxtInDoc=bOldTxtInDoc; + bNoExec = bOldNoExec; + + if (( nHdFtType & W4W_MASK1 ) == 0 ) // WP 5.1 : Kopf/Fusstext + { // ist ausgeschaltet + return; + } + + rInp.Seek( nOldPos ); // Spule zurueck an den Anfang der + // Kopf/Fusstexte, um den K/F-Text zu lesen + + // Falls im HFX-Befehl Mist steht, hier berichtigen: + nHdFtType &= ~W4W_MASK3; // Weder Header noch Footer + if ( bHeader ) nHdFtType |= W4W_HEADER; // Header oder Footer ?? + else nHdFtType |= W4W_FOOTER; + + SwPageDesc* pOldPgD = pPageDesc; + + // Falls bereits ein Follow definiert wurde, ist nOldPDT inzwischen + // ungueltig, wird aber auch nicht mehr benoetigt, da wir ja am + // gesetzten pOpen1stPgPageDesc erkennen, dass der Vorgaenger-PgDesc + // nur fuer Startseiten gilt und der Follow-PgDesc noch nicht ins + // pDoc inserted wurde. + // + // Was bedeutet nun bFollow? + // + // "Folge-PgDesc des derzeit tatsaechlich aktiven Page-Descriptors" + // also nicht immer Folge von pPageDesc sondern gegebenenfalls + // halt Folge von pOpen1stPgPageDesc. + // + bFollow = ( ( ( pOpen1stPgPageDesc ) + || ( nOldPDT == W4W_FIRST ) + || ( nOldPDT == 0 ) + ) + && ( nPDType == W4W_NFIRST ) ); + /* + * Lies K/F-Zeilen ein, mache evtl neuen PageDesc + */ + BOOL bNewPD = ContinueHdFtDefinition( bFollow, nLMarg, nRMarg ); + + if( bFollow && bNewPD ) + { + pOldPgD->SetFollow( pPageDesc ); + // Spaeter neu kreierte Pagedescs + // bekommen die Header / Footer vom Follow + pLastActPageDesc = pPageDesc; + } + } +} + + +void SwW4WParser::Read_FooterStart() // (HF1) +{ + Read_HdFtDefinition( FALSE ); +} + + +void SwW4WParser::Read_HeaderStart() // (HF2) +{ + Read_HdFtDefinition( TRUE ); +} + + +void SwW4WParser::Read_HeadFootEnd() // (HFX) +{ + long nNewLines, nOptHeight=0, nOptFirstP=0; + BYTE nNewDef; + + if( bNoExec ) // das Auswerten nur beim 1. Durchlauf reicht aus + { + if( GetDecimal( nNewLines ) && !nError + && GetHexByte( nNewDef ) && !nError ) + { + // Fehlen optionale Parameter ? + if( (W4WR_TXTERM != GetDecimal( nOptHeight )) || nError + || (W4WR_TXTERM != GetDecimal( nOptFirstP )) || nError ) + { + // Default: alle Seiten + nOptFirstP = 3; + } + if (0==nOptFirstP) nOptFirstP=3; + + nPDType = nHdFtType = 0; + + // Test auf Header/Footer No. 2 + if (nNewDef & 0x1) nHdFtType |= W4W_NO2; + + // Entscheidung, ob Header oder Footer + if (nNewDef & 0x2) nHdFtType |= W4W_FOOTER; + else nHdFtType |= W4W_HEADER; + + // auf welchen Seiten solls erscheinen (gerade/ungerade) + if( nNewDef & 0x4 ) nHdFtType |= W4W_EVENODD; + else if( nNewDef & 0x8 ) nHdFtType |= W4W_ODD; + else if( nNewDef & 0x10 ) nHdFtType |= W4W_EVEN; + + // auf welchen Seiten solls erscheinen (erste/folgende) + switch( nOptFirstP ) + { + case 0: + case 3: nHdFtType |= W4W_ALL; + nPDType = W4W_ALL; + break; + case 1: nHdFtType |= W4W_FIRST; + nPDType = W4W_FIRST; + break; + case 2: nHdFtType |= W4W_NFIRST; + nPDType = W4W_NFIRST; + break; + } + } + } + bHeadFootDef=FALSE; +} + +/*************************************************************************** +* Hilfsroutinen fuer W4WPAR1-Formatierungen und Kopf- / Fusszeilen * +***************************************************************************/ + + +SwPageDesc* SwW4WParser::CreatePageDesc( USHORT eCreateMode ) +{ + USHORT nPos; + UseOnPage eOldHdFtShare = PD_NONE; + const BOOL bRemoveAllHdFt = (eCreateMode & CRPGD_REMOVE_HD) + && (eCreateMode & CRPGD_REMOVE_FT); + + /* + * If PageDesc follows to SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE ) + * that Break-Item must be erased. + */ + if( (eCreateMode & CRPGD_AND_INSERT) && !bWasTxtSince_BREAK_PAGE ) + { + SfxItemSet* pSet = pCurPaM->GetCntntNode()->GetpSwAttrSet(); + if( pSet + && (SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, FALSE )) ) + { + // PageBreak was set in same paragraph (same Content-Node), + // and is to be deleted now to avoid creating an empty page. + pSet->ClearItem( RES_BREAK ); + } + } + + if( bIsTxtInPgDesc && (eCreateMode & CRPGD_AND_INSERT) ) + DoSplit(); + + + /* + * Now create new Page-Descriptor: + * + * copy information of Last Active PageDesc (without Header/Footer) + */ + nPos = pDoc->MakePageDesc( ViewShell::GetShellRes()->GetPageDescName( + pDoc->GetPageDescCnt(), FALSE, + eCreateMode & CRPGD_AS_FOLLOW ), + pLastActPageDesc, FALSE ); + + pPageDesc = &((SwPageDesc&)pDoc->GetPageDesc( nPos )); + + /* + * Now copy header/footer info + * avoiding the info of the header/footer that is to be removed. + */ + if( pLastActPageDesc ) + { + // store old HdFtShare value + UseOnPage eOldUse = pLastActPageDesc->ReadUseOn(); + + // copy even header content section + if( ! ( (eCreateMode & CRPGD_REMOVE_HD) + && (nHdFtType & W4W_EVEN) ) ) + { + pDoc->CopyHeader( pLastActPageDesc->GetMaster(), + pPageDesc->GetMaster() ); + } + // copy even footer content section + if( ! ( (eCreateMode & CRPGD_REMOVE_FT) + && (nHdFtType & W4W_EVEN) ) ) + { + pDoc->CopyFooter( pLastActPageDesc->GetMaster(), + pPageDesc->GetMaster() ); + } + // copy odd header content section + if( ! ( (eCreateMode & CRPGD_REMOVE_HD) + && (nHdFtType & W4W_ODD) ) ) + { + if( eOldUse & PD_HEADERSHARE ) + pPageDesc->GetLeft().SetAttr( + pLastActPageDesc->GetMaster().GetHeader() ); + else + pDoc->CopyHeader( pLastActPageDesc->GetLeft(), + pPageDesc->GetLeft() ); + } + // copy odd footer content section + if( ! ( (eCreateMode & CRPGD_REMOVE_FT) + && (nHdFtType & W4W_ODD) ) ) + { + if( eOldUse & PD_FOOTERSHARE ) + pPageDesc->GetLeft().SetAttr( + pLastActPageDesc->GetMaster().GetFooter() ); + else + pDoc->CopyFooter( pLastActPageDesc->GetLeft(), + pPageDesc->GetLeft() ); + } + + // Look which old UseOn values shall continue + if( !(eCreateMode & CRPGD_REMOVE_HD) ) + eOldHdFtShare = (UseOnPage) + (eOldHdFtShare | ( eOldUse & PD_HEADERSHARE )); + if( !(eCreateMode & CRPGD_REMOVE_FT) ) + eOldHdFtShare = (UseOnPage) + (eOldHdFtShare | ( eOldUse & PD_FOOTERSHARE )); + } + else + { + USHORT nMinTopBottom, nMinLeftRight; + if ( MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() ) + nMinTopBottom = nMinLeftRight = 1134; //2 Zentimeter + else + { + nMinTopBottom = 1440; //al la WW: 1Inch + nMinLeftRight = 1800; // 1,25 Inch + } + //SvxULSpaceItem aUL( nMinTopBottom, nMinTopBottom ); + pPageDesc->GetMaster().SetAttr( SvxULSpaceItem( nMinTopBottom, nMinTopBottom ) ); + pPageDesc->GetMaster().SetAttr( SvxLRSpaceItem( nMinLeftRight, nMinLeftRight ) ); + } + + if( eCreateMode & CRPGD_AND_INSERT ) + { + pLastActPageDesc = pPageDesc; + pOpen1stPgPageDesc = 0; + } + + if( bRemoveAllHdFt ) + { + pPageDesc->GetMaster().ResetAttr( RES_HEADER, RES_FOOTER ); + pPageDesc->GetLeft ().ResetAttr( RES_HEADER, RES_FOOTER ); + } + else if( (eCreateMode & (CRPGD_REMOVE_HD | CRPGD_REMOVE_FT)) ) + { + /* + * Find out which Hd or Ft is to be removed + */ + SwFrmFmt* pMasterLeft = lcl_GetMasterLeft( *pPageDesc, nHdFtType ); + + if( eCreateMode & CRPGD_REMOVE_HD ) + pMasterLeft->ResetAttr( RES_HEADER ); + else + pMasterLeft->ResetAttr( RES_FOOTER ); + } + + pPageDesc->WriteUseOn( (UseOnPage)(PD_ALL | eOldHdFtShare) ); + + nAktPgDesc = nPos; // merke als aktuelles SeitenLayout + + // den Follow-PageDesc immer auf sich selbst setzen + pPageDesc->SetFollow( pPageDesc ); + + // ggfs. den neuen PgDesc-Attr ins Doc setzen + if( eCreateMode & CRPGD_AND_INSERT ) + pDoc->Insert( *pCurPaM, SwFmtPageDesc( &pDoc->GetPageDesc( nPos ))); + + /* Der neue Page-Descriptor ist noch ohne Text + + 2 Faelle: + a. Page-Descriptor wurde soeben aktiviert (s. vorige Anweisung) + b. PgDesc greift erst mit naechstem Seitenumbruch + Beide Male ist sie in pPageDesc gespeichert. + Daher duerfen wir das bool-Flag getrost auf FALSE setzen: + alle Abfragen darauf stehen naemlich IMMER in Zusammenhang mit + Zugriffen auf die Variable pPageDesc + */ + bIsTxtInPgDesc = FALSE; + + + // Up to now there was no .<HNP> within this Page-Descriptor's scope. + // ( We need this information in SwW4WParser::Read_HardNewPage() ) + bWasHNPInPgDesc = FALSE; + + if( (eCreateMode & CRPGD_UPDT_MRGN) + && bPgMgnChanged ) + SetPageMgn(); // neue Raender gueltig + + UpdateCacheVars(); + + return pPageDesc; +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4wpar3.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar3.cxx new file mode 100644 index 000000000000..d7526f31c5be --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4wpar3.cxx @@ -0,0 +1,1430 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdlib.h> +#include <stdio.h> + +#include <hintids.hxx> + +#include <bf_svx/paperinf.hxx> +#include <bf_svx/lrspitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/spltitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/kernitem.hxx> +#include <bf_svx/hyznitem.hxx> +#include <bf_svx/widwitem.hxx> +#include <bf_svx/orphitem.hxx> +#include <bf_svx/unolingu.hxx> +#include <unotools/localedatawrapper.hxx> + +#include <fmthdft.hxx> +#include <fmtcol.hxx> +#include <docufld.hxx> +#include <fmtfld.hxx> +#include <fmtpdsc.hxx> +#include <doc.hxx> +#include <swtypes.hxx> // GET_POOLID_TXTCOLL +#include <paratr.hxx> +#include <pam.hxx> +#include <pagedesc.hxx> +#include <poolfmt.hxx> // RES_POOLCOLL_STANDARD +#include <w4wstk.hxx> // fuer den Attribut Stack +#include <w4wpar.hxx> // GetDecimal() +#include <SwStyleNameMapper.hxx> +namespace binfilter { + + +SV_IMPL_PTRARR( W4WPDTInfos, W4WPDTInfo_Ptr ) + // fuer PDT beim FrameMaker + +SV_IMPL_PTRARR( W4WFLOInfos, W4WFLOInfo_Ptr ) + // fuer FLO beim FrameMaker + +SV_DECL_PTRARR_SORT( W4WStyleIdTab, W4WStyleIdTabEntryPtr, 0, 1 ) + // Implementation der W4WStyleIdTab ist in w4wpar1.cxx + + + + +// -------- Methoden fuer die StyleSheet-Verarbeitung: ------------ + + +W4WStyleIdTabEntry::W4WStyleIdTabEntry( SwW4WParser& rParser, USHORT nId, + const sal_Unicode* pName ) + : nStyleId( nId ), pColl( 0 ), bSetAttributes( TRUE ) +{ + String aName( pName ); + + if( !aName.Len() ) + { + do + { + rParser.MakeUniqueStyleName( aName ); + pColl = rParser.GetDoc().FindTxtFmtCollByName( aName ); + } while( pColl ); + } + else + pColl = rParser.GetDoc().FindTxtFmtCollByName( aName ); // Suche zuerst in den Doc-Styles + + if( !pColl ) // Collection nicht gefunden, vielleicht im Pool ? + { + USHORT n = SwStyleNameMapper::GetPoolIdFromUIName( aName , GET_POOLID_TXTCOLL ); + if ( nId == USHRT_MAX ) // USHRT_MAX bedeutet Standard + // z.B. Nr. 0 bei WinWord2 + n = RES_POOLCOLL_STANDARD; + if ( n != USHRT_MAX ) // gefunden oder Standard + pColl = rParser.GetDoc().GetTxtCollFromPoolSimple( n, FALSE ); + } + SwTxtFmtColl* pStandardColl = + rParser.GetDoc().GetTxtCollFromPoolSimple( RES_POOLCOLL_STANDARD, + FALSE ); + if( !pColl ) + { + // die Collection nicht gefunden, also erzeuge neue + pColl = rParser.GetDoc().MakeTxtFmtColl( aName, pStandardColl ); + } + else + { + if( !rParser.IsNewDocument() ) + bSetAttributes = FALSE; + if( pColl != pStandardColl ) + { + // definierte Collection soll von Standard-Coll abgeleitet sein + pColl->SetDerivedFrom( pStandardColl ); + } + } +} + +inline BOOL W4WStyleIdTabEntry::operator==( const W4WStyleIdTabEntry& rEntry ) const +{ return nStyleId == rEntry.nStyleId; } +inline BOOL W4WStyleIdTabEntry::operator<( const W4WStyleIdTabEntry& rEntry ) const +{ return nStyleId < rEntry.nStyleId; } + +SV_IMPL_OP_PTRARR_SORT( W4WStyleIdTab, W4WStyleIdTabEntryPtr ) + + +// TranslateDefaultStyle gibt der Stylenummer, die den Defaultstyle darstellt, +// die Nummer USHRT_MAX. WW2 kennt #0 aks Default, rtf kennt keinen Default. + +inline void TranslateDefaultStyle( long& nStyleId, USHORT nDocType ) +{ + if ( 0 == nStyleId ) // != 0 ist niemals Default + { + if ( nDocType == 44 || nDocType == 49 ) // WW2 und WW6 benutzen Default + nStyleId = USHRT_MAX; // Default-Style + //!! .. WP??? + } +} + + +void SwW4WParser::MakeUniqueStyleName( String& rName ) +{ + nNoNameStylesCount++; + rName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NoName(" )); + rName += String::CreateFromInt32( nNoNameStylesCount ); + rName += ')'; +} + + +void SwW4WParser::Read_StyleBasedOn() // (SBO) +{ + long nStyNo; + + if ( !bStyleDef ) return; + + if( !GetNextName() || nError +// if( W4WR_TXTERM != GetNextRecord() || nError + || W4WR_TXTERM != GetDecimal( nStyNo ) ) return; + + TranslateDefaultStyle ( nStyNo, nDocType ); + +#ifdef NIE // Es wird sich nur noch an die Nummer gehalten, + // der Name wird ignoriert. + + Flush(); // '\0' hinter Dateinamen setzen + String aName( aCharBuffer ); + + pColl = pDoc->FindTxtFmtCollByName( aName ) +#endif // NIE + + SwTxtFmtColl* pColl = 0; + { + W4WStyleIdTabEntry aEntry( (USHORT)nStyNo ); + W4WStyleIdTabEntry* pTmp = &aEntry; + USHORT nPos; + if( pStyleTab->Seek_Entry( pTmp, &nPos )) + pColl = (*pStyleTab)[ nPos ]->pColl; + } + SwTxtFmtColl* pAktColl = GetAktColl(); + ASSERT( pAktColl, "StyleId ungueltig" ); + + // nicht gefunden -> in Liste aufnehmen + if( pColl == 0 ) + { + // Liste anlegen ? + if( !pStyleBaseTab ) + pStyleBaseTab = new W4WStyleIdTab( 1, 1 ); + + W4WStyleIdTabEntry* pNewStyle = + new W4WStyleIdTabEntry( (USHORT)nStyNo ); + // Abhaengigkeit merken + pNewStyle->pColl = pAktColl; + pStyleBaseTab->Insert( pNewStyle ); +// const W4WStyleIdTabEntry* &rpNewStyle = pNewStyle; +// pStyleBaseTab->Insert( rpNewStyle ); + + } + else + { + // gefunden -> Abhaengigkeit eintragen + if ( pAktColl ) + pAktColl->SetDerivedFrom( pColl ); + } +} + +void SwW4WParser::Read_StyleTable() // (SYT) +{ + bDefFontSet = TRUE; // keine globalen Einstellungen mehr + bPageDefRdy = TRUE; + + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + bStyleDef = TRUE; + bSepar = FALSE; + bIsTab = FALSE; + + StyleAnfang(); // Lesen des StyleSheet-Headers + + if( nError ) return; + + Flush(); // Haenge \0 an String an + if( !pStyleTab ) + pStyleTab = new W4WStyleIdTab( 1, 1 ); + W4WStyleIdTabEntry * pNewStyle = new + W4WStyleIdTabEntry( *this, nAktStyleId, aCharBuffer ); + + pStyleTab->Insert( pNewStyle ); +// const W4WStyleIdTabEntry* &rpNewStyle = pNewStyle; +// pStyleTab->Insert( rpNewStyle ); + +// NOTE3( "[Style Def: %s, Id: %ld]", aCharBuffer, nAktStyleId ); + + // lese alle Records vor RED + // ignoriere dabei alle Records nach (SEP) + BYTE c; + while( !nError ) +// while( !nError && !pInput->get(c).eof() && W4WR_RED != c ) + { + c = ReadChar(); + if ( rInp.IsEof() || W4WR_RED == c ) + break; + rInp.SeekRel( - 1 ); +// pInput->putback(c); + if (EOF==GetNextRecord()) + break; + } + + if( rInp.IsEof() ) + nError = ERR_RECORD; + + Flush(); // loesche Pufferinhalt + bStyleDef = FALSE; + bSepar = FALSE; + bTxtInDoc = bOldTxtInDoc; + + SwTxtFmtColl* pAktColl = GetAktColl(); +// if ( 0 == nAktStyleId ) // 0 : Dieser Style ist der Default +// pDoc->SetTxtFmtColl( *pCurPaM, pAktColl, FALSE );//!!!??? + + if ( pStyleBaseTab ){ // Es sind noch Verbindungen herzustellen + W4WStyleIdTabEntry aEntry( nAktStyleId ); + W4WStyleIdTabEntry* pTmp = &aEntry; + USHORT nPos; + if( pStyleBaseTab->Seek_Entry( pTmp, &nPos )) + { + // loesbar + W4WStyleIdTabEntry* pOldStyle = (*pStyleBaseTab)[ nPos ]; + // stelle Verbindung her + pOldStyle->pColl->SetDerivedFrom( pAktColl ); + pStyleBaseTab->DeleteAndDestroy( nPos ); + } + } +// if( 0 == pNewStyle->pColl->DerivedFrom() ) +// { + // falls kein SBO kam, + // wird der neue Style vom Default abgeleitet +// pNewStyle->pColl->SetDerivedFrom( 0 ); +// } + nAktStyleId = 0; // Starte normalen Text mit Default-Style +} + + + +SwTxtFmtColl* SwW4WParser::GetAktColl( BOOL* pSetAttrFlag ) const +{ + if( pSetAttrFlag ) + *pSetAttrFlag = TRUE; + // hole die durche nAktStyleId angegebe Style + W4WStyleIdTabEntry aEntry( nAktStyleId ); + W4WStyleIdTabEntry* pTmp = &aEntry; + USHORT nPos; + if( !pStyleTab || !pStyleTab->Seek_Entry( pTmp, &nPos )) + return pDoc->GetTxtCollFromPoolSimple( RES_POOLCOLL_STANDARD, FALSE ); + + W4WStyleIdTabEntry* pStyle = (*pStyleTab)[ nPos ]; + if( pSetAttrFlag ) + *pSetAttrFlag = pStyle->bSetAttributes; + + return pStyle->pColl; +} + + +BOOL SwW4WParser::GetNextName() // liest Namen (inc. Sonderzeichen) +{ // und legt ihn im aCharBuffer ab + BYTE c; + while( !nError ) + { + c = ReadChar(); + + if( rInp.IsEof() || W4WR_TXTERM == c ) break; + + if( W4WR_BEGICF == c ) + { + rInp.SeekRel( - 1 ); + + if( EOF == GetNextRecord() ) break; + + continue; + } + else + FlushChar( c ); + } + if( rInp.IsEof() ) + { + nError = ERR_RECORD; + return FALSE; + } + else + return TRUE; +} + + +void SwW4WParser::StyleAnfang() +{ + if( !GetNextName() || nError ) return; + + long nStyleId; + if( !nError && GetDecimal( nStyleId ) && !nError ) + { + TranslateDefaultStyle( nStyleId, nDocType ); + nAktStyleId = (USHORT)nStyleId; + } + + // Ab hier Umpopelungen dafuer, dass W4W Die Umlaute in den Stylenamen + // anscheinend nur bei WP richtig quotet. Bei WW stimmt's bei OS/2 nicht, + // bei AMI stimmt's nie + +//JP 11.05.00: UNICODE-CHANGE - stimmt das noch so ?? +#if 0 + if ( nDocType == 44 || nDocType == 33 ) // Hier stimmen die Umlaute nicht + { + rtl_TextEncoding eCS = RTL_TEXTENCODING_IBM_437; // Wandle Umlaute in ALay - Namen + if ( nDocType == 44 ) + eCS = RTL_TEXTENCODING_MS_1252; // WinWord hat Ansi-Charset + register BYTE ch, ch2; + for ( USHORT i=0; i<nChrCnt; i++ ) + { + ch = aCharBuffer[i]; + if ( ch < 32 || ch > 127 ) + { + ch2 = String::Convert( ch, eCS, eSysCharSet ); + aCharBuffer[i] = ( ch2 == 0 ) ? ch : ch2; + } + else if ( nDocType == 33 && ch == '<' // AMI-Pro-Umlaute + && aCharBuffer[i+1] == '\\' ) + { + ch = aCharBuffer[i+2]; + switch ( ch ) + { + case 'd': ch = 0x84; break; + case 'v': ch = 0x94; break; + case '|': ch = 0x81; break; + case '_': ch = 0xe1; break; + case 'D': ch = 0x8e; break; + case 'V': ch = 0x99; break; + case '\\': ch = 0x9a; break; + default: ch = 'X' ; break; + } + ch2 = String::Convert( ch, eCS, eSysCharSet ); // Umlaut in's System + aCharBuffer[i] = ch2; + for ( USHORT j=i+1; j+3<nChrCnt; j++ ) // loesche Klammern + aCharBuffer[j] = aCharBuffer[j+3]; + nChrCnt -= 3; + } + } + } // Ende Umpopelungen +#endif +} + + +void SwW4WParser::Read_Separator() // (SEP) +{ + bSepar=TRUE; +} + + +void SwW4WParser::Read_StyleOn() // (STY) +{ + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + bStyleOnOff = TRUE; + bStyleOn = TRUE; + if ( bIsColMode ) bIsSTYInTab = TRUE; + + StyleAnfang(); // lies den StyleSheet-Header + if( !nError ) // Damit Flags zurueckgesetzt werden + { + + Flush(); +// NOTE3( "[Style On: %s, Id: %ld]", aCharBuffer, nAktStyleId ); + + if( !pStyleTab ) + { + ASSERT( !this, "+keine StyleTabelle definiert" ); + } + else + { + // pCtrlStck->StealAttr( RES_PARATR_TABSTOP, W4WR_NODE, pCurPaM->GetPoint() ); + // pCtrlStck->StealAttr( RES_FLTR_STYLESHEET, W4WR_NODE, pCurPaM->GetPoint() ); + // const SwPosition& rPos = *pCurPaM->GetPoint(); + // pCtrlStck->SetAttr( rPos, RES_LR_SPACE ); + // pCtrlStck->SetAttr( rPos, RES_UL_SPACE ); + // pCtrlStck->SetAttr( rPos, RES_CHRATR_FONT ); + // pCtrlStck->SetAttr( rPos, RES_CHRATR_FONTSIZE ); + + SetAttr( SwW4WStyle( nAktStyleId )); + + bStyleEndRec = FALSE; + + while( !nError && !bStyleEndRec // lies alles bis zum SEP + && EOF!=GetNextRecord()) // und ignoriere alle bis zum Ende + ; + + nChrCnt = 0; + } + } + bStyleOn = bStyleOnOff = bStyleEndRec = FALSE; + bTxtInDoc = bOldTxtInDoc; + bStyleOff = FALSE; +} + + +void SwW4WParser::Read_StyleOff() // (STF) +{ + BOOL bOldTxtInDoc = bTxtInDoc; + bTxtInDoc = FALSE; + bStyleOnOff = TRUE; + bStyleOff=TRUE; + +// zumindest bei WinWord2-Dokumenten wird beim Ausschalten des Styles +// erwartet, dass der hart gesetzte Font mit ausgeschaltet wird. +// Dieses sieht man aus Dokument k:\sw6\testplan.71\bugdoc\4295.doc + + if ( bOldTxtInDoc && !bStyleDef ){ + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->SetAttr( rPos, RES_CHRATR_FONT ); + pCtrlStck->SetAttr( rPos, RES_CHRATR_FONTSIZE ); + } + + StyleAnfang(); // lese den StyleSheet-Header + if( nError ) + return; + + Flush(); + + bStyleEndRec = FALSE; + while( !nError && !bStyleEndRec + && EOF!=GetNextRecord()) + ; + nChrCnt = 0; + + if( nDocType == 44 && bIsColMode ){ // Hier kommen STFs immer erst am + // Anfang der naechsten Zelle + if ( pCurPaM->GetPoint()->nContent.GetIndex() == 0 ) + { + // Umpopele WinWord2-Fehler: Ausschalten + // erfolgt oft erst am Anfang der folgenden Tab-Zelle + BOOL bForward = pCurPaM->Move( fnMoveBackward, fnGoCntnt ); + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), + RES_FLTR_STYLESHEET, TRUE, bForward ); + + if( bForward ) + pCurPaM->Move( fnMoveForward, fnGoCntnt ); + } + else + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_FLTR_STYLESHEET ); + + } + else + { // normale Behandlung + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_FLTR_STYLESHEET ); + } + + nAktStyleId = USHRT_MAX; // Default ist ab jetzt gueltig + + bStyleOnOff = bStyleEndRec = FALSE; + bTxtInDoc = bOldTxtInDoc; + if( bIsColMode ) bIsSTYInTab = FALSE; +} + + +void SwW4WParser::Read_StyleEnd() // (STE) +{ + bStyleEndRec = TRUE; +} + + +// -------- andere Methoden: ----------------------------------- + + + +void SwW4WParser::Read_LangGroup() // (SLG) +{ + long nLang; + + if ( bStyleOnOff ) return; + + if ( W4WR_TXTERM != GetDecimal( nLang ) || nError ) + return; + + //!!! Eigentlich muesste auf sinnvolle + // Sprache getestet werden, aber ich + // weiss nicht, wie das geht. + + if( !nLang || 0x400 == nLang ) // No Language || No Proofing + nLang = LANGUAGE_DONTKNOW; + + if ( !bWasSLG && !bIsTxtInDoc ){ // 1. Angabe ist der Default + // (heuristisch erwiesen) + nDefLanguage = (USHORT)nLang; // Merke Default + bWasSLG = TRUE; // genau einmal !?? + } + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_LANGUAGE ); + + if ( (USHORT)nLang != nDefLanguage ){ // Es gibt keinen "Ausschalter" bzw. + // Endezeichen fuer das Sprachattribut. + // Deshalb wird dann der Defaultwert + // geschickt, d.h. wenn der Defaultwert + // ankommt, ist Attributende gemeint. + // Schade eigentlich! + SetAttr( SvxLanguageItem( (const LanguageType)nLang ) ); + } +} + +void SwW4WParser::Read_BeginKerning() // (KER) +{ + long nPos, nDist; + + if( bStyleOnOff ) return; + + if ( W4WR_TXTERM != GetDecimal( nPos ) || nError + || W4WR_TXTERM != GetDecimal( nDist ) || nError ) + return; + + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_KERNING ); + if ( nPos == 0 ) nDist = - nDist; + SetAttr( SvxKerningItem( (const USHORT)nDist )); +} + +void SwW4WParser::Read_EndKerning() // (EKR) +{ + if( !bStyleOnOff ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_CHRATR_KERNING ); +} + +void SwW4WParser::Read_BeginHyphen() // (BHP) +{ + if( bStyleOnOff ) return; + + SvxHyphenZoneItem aHyph( TRUE ); + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_HYPHENZONE ); + SetAttr( aHyph ); +} + +void SwW4WParser::Read_EndHyphen() // (EHP) +{ + if( !bStyleOnOff ) + pCtrlStck->SetAttr( *pCurPaM->GetPoint(), RES_PARATR_HYPHENZONE ); +} + +void SwW4WParser::Read_Split() // (KEP) +{ + if( !bStyleOnOff ) + { + SetAttr( SvxFmtSplitItem( FALSE ) ); + } +} + + +void SwW4WParser::Read_WidowOrphOn() // (WON) +{ + if( !bStyleOnOff ) + { + long nLines; + + if( W4WR_TXTERM != GetDecimal( nLines ) || nError ) + nLines = 2; + + SetAttr( SvxWidowsItem( (const BYTE)nLines ) ); + SetAttr( SvxOrphansItem( (const BYTE)nLines ) ); + } +} + + +void SwW4WParser::Read_WidowOrphOff() // (WOY) +{ + if( !bStyleOnOff ) + { + const SwPosition& rPos = *pCurPaM->GetPoint(); + pCtrlStck->SetAttr( rPos, RES_PARATR_WIDOWS ); + pCtrlStck->SetAttr( rPos, RES_PARATR_ORPHANS ); + } +} + + +/************************** + * * + * Hidden Text einlesen * + * * + **************************/ + +void SwW4WParser::Read_BeginHiddenText() // (BHT) +{ + Read_ProcessHiddenText( FALSE ); +} + + +void SwW4WParser::Read_EndHiddenText() // (EHT) +{ + /*NOP*/ // hier keine Befehle! +} + + +void SwW4WParser::Read_CommentLine() // (CMT) +{ + Read_ProcessHiddenText( TRUE ); +} + + +void SwW4WParser::ProcessRecordInHiddenText() +{ + if( pActW4WRecord->fnReadRec == &SwW4WParser::Read_HardNewLine ) + { + *pReadTxtString += '\n'; + } + else + if( ( pActW4WRecord->fnReadRec == &SwW4WParser::Read_ExtendCharSet ) + || ( pActW4WRecord->fnReadRec == &SwW4WParser::Read_UpperCharSet ) + || ( pActW4WRecord->fnReadRec == &SwW4WParser::Read_Hex ) ) + { + rInp.Seek( nStreamPosInRec ); + (this->*pActW4WRecord->fnReadRec)(); + rInp.SeekRel( - 1 ); + SkipEndRecord(); + } +} + + +void SwW4WParser::Read_ProcessHiddenText( BOOL bInline ) +{ + /* + Schade: der Writer kennt Hidden Text nur als *Feld* + daher gehen wechselnde Formatierungen innerhalb + des Hidden Textes verloren. + */ + String aHiddenTxt; + BOOL bOldNixExec = bNixNoughtNothingExec; + bNixNoughtNothingExec = TRUE; + bReadTxtIntoString = TRUE; + pReadTxtString = &aHiddenTxt; + if( bInline ) + { + register BYTE c; + while( !nError ) + { + c = ReadChar(); + + if( rInp.IsEof() || W4WR_TXTERM == c ) break; + + if( W4WR_BEGICF == c ) + { + rInp.SeekRel( - 1 ); + + if( EOF == GetNextRecord() ) return; + + if( pActW4WRecord ) ProcessRecordInHiddenText(); + + continue; + } + else + { + // naechsten Buchstaben nach XCS ueberlesen + if( bWasXCS ) + bWasXCS = FALSE; + else + *pReadTxtString += (char)c; + } + } + if( rInp.IsEof() ) return; + } + else + { + while( ( !nError ) + && ( EOF != GetNextRecord() ) + && pActW4WRecord + && ( pActW4WRecord->fnReadRec != &SwW4WParser::Read_EndHiddenText)) + { + ProcessRecordInHiddenText(); + } + } + bNixNoughtNothingExec = bOldNixExec; + bReadTxtIntoString = FALSE; + pReadTxtString = 0; + if( aHiddenTxt.Len() ) + { + SwHiddenTxtField aFld( (SwHiddenTxtFieldType*) + pDoc->GetSysFldType( RES_HIDDENTXTFLD ), + TRUE, aEmptyStr, aHiddenTxt, TRUE ); + + pDoc->Insert( *pCurPaM, SwFmtFld( aFld ) ); + } +} + + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ + * * + * * + * besondere Methoden fuer F r a m e M a k e r - Dokumente * + * * + * * +\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +/* + Datenstrukturen: + - Page: steckt in einem SV_DECL_PTRARR_DEL + - Page: enthaellt ein normales array mit den R-Ids + + - Rechteck: steck in 'SwTable' + siehe: DECLARE_TABLE() in w4wpar.hxx, + Key ist die R-Id. +*/ + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ +* * +* Vorbereitung: lesen und analysieren der Strukturinformationen * +* * + \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +BOOL SwW4WParser::Read_Analyze_FLO_PDT()// analysieren aller PDTs und ggfs. +{ // erzeugen entsprechender PageDesc + BOOL bOk = TRUE; + + if( pFLOInfos ) + { + for( USHORT iFLO = 0; iFLO < pFLOInfos->Count(); ++iFLO ) + { + // diese PDT analysieren + W4WFLOInfo& rFLOInfo = *pFLOInfos->GetObject( iFLO ); + for(int i = 0; i < rFLOInfo.nRects; i++) + { + W4WRectInfo* pRectInfo = pRDTInfos->Get(rFLOInfo.pIds[ i ]); + if( pRectInfo ) + pRectInfo->nFLOId = rFLOInfo.nFlowId; + } + } + } + + if( pPDTInfos ) + { + for( USHORT iPDT = 0; iPDT < pPDTInfos->Count(); ++iPDT ) + { + // diese PDT analysieren (falls er Rects hat) + W4WPDTInfo& rPDTInfo = *pPDTInfos->GetObject( iPDT ); + if( rPDTInfo.nRects ) + { + USHORT nBodyRect= USHRT_MAX; + USHORT nHdRect = USHRT_MAX; + USHORT nFtRect = USHRT_MAX; + + // Hilfs-Array mit den Rect-Grenzen anlegen + + W4WRectInfo** ppTmpRects = new W4WRectInfo*[ rPDTInfo.nRects ]; + + + for(int i = 0; i < rPDTInfo.nRects; i++) + { + W4WRectInfo* pRectInfo = pRDTInfos->Get(rPDTInfo.pIds[ i ]); + if( pRectInfo ) + { + int nInsert = i; + if( i ) + { + // 0. einsortieren nach Y (innerhalb gleicher Y nach X) + for(int i2 = 0; i2 < i; i2++) + { + if( ( pRectInfo->aRect.Pos().Y() + < ppTmpRects[ i2 ]->aRect.Pos().Y() + ) + || ( ( pRectInfo->aRect.Pos().Y() + == ppTmpRects[ i2 ]->aRect.Pos().Y() ) + && ( pRectInfo->aRect.Pos().X() + <= ppTmpRects[ i2 ]->aRect.Pos().X() ) + ) ) + { + memmove( ppTmpRects+i2+1, ppTmpRects+i2, + sizeof( void* ) * (i-i2) ); + nInsert = i2; + break; + } + } + } + ppTmpRects[ nInsert ] = pRectInfo; + // Seitennummer auch im globalen Rect-array vermerken + pRectInfo->nPDTId = iPDT; + } + else + { + bOk = FALSE; + break; + } + } + // cleverFrames: vertraute Strukturen zu erkennen + const BOOL bOnlyFrames = 0 != (W4WFL_FM_onlyFrames & nIniFMFlags); + const BOOL bCleverFrames = + (0 == ( ( W4WFL_FM_onlyFrames + | W4WFL_FM_neverFrames ) + & nIniFMFlags)); + + if( bOk ) + { + /**********************************************************\ + Regeln der Analyse: + ^^^^^^^^^^^^^^^^^^^ + 1. Rects, die in anderen drinnen stecken, werden ignoriert + + 2. nebeneinanderliegende Rects, die auf gleicher Hoehe + beginnen *und* enden, werden zu einer spaltigen Einheit + + 3. zur Erkennung, ob ein Rect als Kopf- (bzw. Fuss-)bereich + anzusehen ist, genuegt es, dass EINE seiner Kanten + buendig mit dem Rumpfbereich ist + \**********************************************************/ + /* + Realisierung: + + 0. sortiere nach Y (innerhalb gleicher Y nach X) (s.o.!) + 1. raus mit allen /innerhalb/ anderer liegenden Rects + 2. erkenne Spaltigkeit + 3. finde den Bodybereich + 4. suche ggfs. nach dem Kopf- und dem Fussbereich + */ + const int maxDelta = 287;// Spalten: knapp 1/2 cm Versatz der + // Ober-/Unterkante ist Ok. + int i; + for(i = 0; i < rPDTInfo.nRects; i++) + { + W4WRectInfo& rRectInfo = *(ppTmpRects[ i ]); + if( rRectInfo.IsActive() ) + { + const long nXa1 = rRectInfo.aRect.Pos().X(); + const long nYa1 = rRectInfo.aRect.Pos().Y(); + const long nXa2 = nXa1 + rRectInfo.aRect.SSize().Width(); + const long nYa2 = nYa1 + rRectInfo.aRect.SSize().Height(); + for(int i2 = i+1; i2 < rPDTInfo.nRects; i2++) + { + W4WRectInfo& rRectInfo2 = *(ppTmpRects[ i2 ]); + if( rRectInfo2.IsActive() ) + { + const long nXb1 = rRectInfo2.aRect.Pos().X(); + const long nYb1 = rRectInfo2.aRect.Pos().Y(); + const long nXb2 + = nXb1 + rRectInfo2.aRect.SSize().Width(); + const long nYb2 + = nYb1 + rRectInfo2.aRect.SSize().Height(); + + // 1. raus mit /innerhalb/ liegenden Rects + if( (nXa1 <= nXb1) + && (nXa2 >= nXb2) + && (nYa1 <= nYb1) + && (nYa2 >= nYb2) ) + { + ppTmpRects[ i2 ]->bInside = TRUE; + } + else + + // 2. erkenne Spaltigkeit ( im gleichen FLO ! ) + if( bCleverFrames + && (maxDelta > (abs(nYa1 - nYb1))) + && (maxDelta > (abs(nYa2 - nYb2))) + && ( ppTmpRects[ i ]->nFLOId + == ppTmpRects[ i2]->nFLOId) ) + { + ppTmpRects[ i2 ]->nSWId + = ppTmpRects[ i ]->nFMId; + // linkes Rect waechst ggfs. nach rechts + if( nXa2 < nXb2 ) + { + ppTmpRects[ i ]->aRect.Width( nXb2 + - nXa1 ); + ppTmpRects[ i ]->bColXYZ = TRUE; + } + } + } + } + } + } + + // 3. finde den Bodybereich + long nBodyRectVol=-1; + for(i = 0; i < rPDTInfo.nRects; i++) + { + W4WRectInfo& rRect = *(ppTmpRects[ i ]); + if( rRect.IsActive() ) + { + const long nVol = rRect.aRect.SSize().Width() + * rRect.aRect.SSize().Height(); + // ermittele das groesste Rect + if( nBodyRectVol < nVol ) + { + rRect.bBody = TRUE; + nBodyRectVol= nVol; + nBodyRect = rRect.nSWId; + } + } + } + + /* + Body-Rect merken + */ + if( USHRT_MAX != nBodyRect ) + rPDTInfo.nBodyRectId = nBodyRect; + + // 4. suche ggfs. nach dem Kopf- und dem Fussbereich + long nHdRectVol =-1; + long nFtRectVol =-1; + if( bCleverFrames && (USHRT_MAX != nBodyRect) ) + { + W4WRectInfo& rRect = *pRDTInfos->Get( nBodyRect ); + const long nXa1 = rRect.aRect.Pos().X(); + const long nXa2 + = nXa1 + rRect.aRect.SSize().Width(); + const long nYa1 = rRect.aRect.Pos().Y(); + const long nYa2 + = nYa1 + rRect.aRect.SSize().Height(); + + for(i = 0; i < rPDTInfo.nRects; i++) + { + if( i != nBodyRect ) + { + W4WRectInfo& rRect2 = *(ppTmpRects[ i ]); + if( rRect2.IsActive() ) + { + /* + falls mehrere(!) Frames links oder rechts + buendig ueber bzw. unter dem Body-Frame stehen, + nehmen wir den jeweils groessten von diesen als + Kopf- bzw. Fuss-Frame + */ + const long nXb1 = rRect2.aRect.Pos().X(); + const long nXb2 + = nXb1 + rRect2.aRect.SSize().Width(); + + if( (maxDelta > (abs(nXa1 - nXb1))) + || (maxDelta > (abs(nXa2 - nXb2))) ) + { + const long nVol + = rRect2.aRect.SSize().Width() + * rRect2.aRect.SSize().Height(); + const long nYb1 = rRect2.aRect.Pos().Y(); + const long nYb2 + = nYb1 + rRect2.aRect.SSize().Height(); + if( nYa1 >= nYb1 ) + { + if( nHdRectVol < nVol ) + { + nHdRectVol = nVol; + nHdRect = rRect.nSWId; + } + } + else + if( nYa2 <= nYb2 ) + { + if( nFtRectVol < nVol ) + { + nFtRectVol = nVol; + nFtRect = rRect.nSWId; + } + } + } + } + } + } + /* + Sonder-Rects merken + */ + if(USHRT_MAX != nHdRect) + { + rPDTInfo.nHdRectId = nHdRect; + pRDTInfos->Get( nHdRect )->bHeader = TRUE; + } + if(USHRT_MAX != nFtRect) + { + rPDTInfo.nFtRectId = nFtRect; + pRDTInfos->Get( nFtRect )->bFooter = TRUE; + } + } + // Ok, wir haben getan, was wir konnten, also versuchen wir nun, + // den entsprechenden Pagedesk aufzubauen... + String aNm( String::CreateFromAscii( + RTL_CONSTASCII_STRINGPARAM( "Convert " ))); + if( 1 < rPDTInfo.nPageSubType ) // 2,3 == Left, Right Page + aNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "Follow " )); + aNm += String::CreateFromInt32( pDoc->GetPageDescCnt() ); + + rPDTInfo.nSwPdId = pDoc->MakePageDesc( aNm, 0, FALSE ); + + pPageDesc = &((SwPageDesc&)pDoc->GetPageDesc( rPDTInfo.nSwPdId )); + + pPageDesc->SetFollow( pPageDesc );// Follow-PgDesc erstmal self + + if( bCleverFrames ) + { + /* + PageDesc soweit moeglich einrichten: + + wir koennen hier schon obere, linke Ecke + des Rumpf, Kopf- und Fussbereichs definieren. + + was noch fehlt, ist die Groesse, da diese sich + auch aus der Seitengroesse ergibt, die noch + unbekant ist. + */ + + // Upper und Left der PrtArea definieren + USHORT nMinTop, nMinLeft, nMinBottom, nMinRight; + if( MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() ) + { + nMinTop = nMinLeft = + nMinBottom = nMinRight = 1134; //2 cm + } + else + { + nMinTop = nMinBottom= 1440; //wie zB. in WW: 1 Inch + nMinLeft = nMinRight = 1800; // 1,25 Inch + } + USHORT nTop = nMinTop; + USHORT nLeft = nMinLeft; + W4WRectInfo& rBodyInfo = + *pRDTInfos->Get( rPDTInfo.nBodyRectId); + W4WRectInfo* pHdInfo = + (USHRT_MAX != rPDTInfo.nHdRectId) + ? pRDTInfos->Get( rPDTInfo.nHdRectId ) + : 0; + W4WRectInfo* pFtInfo = + (USHRT_MAX != rPDTInfo.nFtRectId) + ? pRDTInfos->Get( rPDTInfo.nFtRectId ) + : 0; + + SwRect& rBodyRect = rBodyInfo.aRect; + Point& rUpPos = pHdInfo ? pHdInfo->aRect.Pos() + : rBodyRect.Pos(); + Point& rLoPos = pFtInfo ? pFtInfo->aRect.Pos() + : rBodyRect.Pos(); + + nTop = (USHORT)rUpPos.Y(); + nLeft = (USHORT)rUpPos.X(); + + SwFrmFmt& rFrmFmt = pPageDesc->GetMaster(); + + rFrmFmt.SetAttr( SvxULSpaceItem( nTop, nMinBottom ) ); + rFrmFmt.SetAttr( SvxLRSpaceItem( nLeft, nMinRight ) ); + + // Header und Footer definieren + SwFrmFmt* pHdFmt = 0; + SwFrmFmt* pFtFmt = 0; + W4WRectInfo& rRectInfo = *pRDTInfos->Get( rPDTInfo.nHdRectId ); + if( pHdInfo ) + { + rFrmFmt.SetAttr( SwFmtHeader( TRUE )); + + pHdFmt = (SwFrmFmt*)rFrmFmt.GetHeader().GetHeaderFmt(); + SwRect& rUpRect = pHdInfo->aRect; + UpdateHdFtMarginSettings( + pHdFmt, + rUpRect.Height(), // Kopf-Hoehe + rBodyRect.Top() -rUpRect.Bottom(),// Kopf-Lower + TRUE); + } + if(USHRT_MAX != rPDTInfo.nFtRectId) + { + rFrmFmt.SetAttr( SwFmtFooter( TRUE )); + + pFtFmt = (SwFrmFmt*)rFrmFmt.GetFooter().GetFooterFmt(); + SwRect& rLoRect = pFtInfo->aRect; + UpdateHdFtMarginSettings( + pFtFmt, + rLoRect.Height(), // Fuss-Hoehe + rLoRect.Top() -rBodyRect.Bottom(),// Fuss-Upper + FALSE); + } + /* + UEber pPDTInfo->PageSizeKnown() koennen wir jederzeit + nachsehen, ob der PgDesc noch unvollstaendig ist, + damit spaetere Erst-AEnderungen nicht + zur Erstellung eines *neuen* PgDesc fuehren + */ + } + } + // Hilfsliste mit den *Rects dieser Seite wieder loeschen + delete ppTmpRects; + } + } + } + return bOk; +} + +void SwW4WParser::Read_PageDefinitionTable() // PDT +{ + // FrameMaker (oder aehnl.) ohne Flag 'W4WFL_FM_neverFrames' + if( !(W4WFL_FM_neverFrames & nIniFMFlags) ) + { + if( !pPDTInfos ) + pPDTInfos = new W4WPDTInfos; + + W4WPDTInfo_Ptr pInfo = new W4WPDTInfo(); + + BOOL bOk = FALSE; + if( GetDecimal( pInfo->nPageType ) && !nError + && GetDecimal( pInfo->nPageSubType ) && !nError + && GetString( pInfo->sPageName, + W4WR_TXTERM, W4WR_TXTERM ) && !nError + && GetDecimal( pInfo->nRects ) && !nError ) + { + pInfo->pIds = new long[ pInfo->nRects ]; + + bOk = TRUE; + for (int i=0; i < pInfo->nRects; i++) + if( !GetDecimal(pInfo->pIds[ i ]) || nError ) + { + bOk = FALSE; + break; + } + } + if( bOk ) + pPDTInfos->Insert( pInfo, pPDTInfos->Count() ); + else + delete pInfo; + } +} + +void SwW4WParser::Read_RectangleDefinitionTable() // RDT +{ + // FrameMaker (oder aehnl.) ohne Flag 'W4WFL_FM_neverFrames' + if( !(W4WFL_FM_neverFrames & nIniFMFlags) ) + { + if( !pRDTInfos ) + pRDTInfos = new W4WRDTInfos; + + SwRect aRect; + ULONG nId; + + if( GetDecimal( (long&)nId ) && !nError + && GetDecimal( aRect.Pos().X() ) && !nError + && GetDecimal( aRect.Pos().Y() ) && !nError + && GetDecimal( aRect.SSize().Width() ) && !nError + && GetDecimal( aRect.SSize().Height() ) && !nError ) + { + W4WRectInfo* pRectInfo = new W4WRectInfo( aRect, nId ); + if( !pRDTInfos->Insert( nId, pRectInfo ) ) + delete pRectInfo; + } + } +} + +void SwW4WParser::Read_Flow() // FLO +{ + // FrameMaker (oder aehnl.) ohne Flag 'W4WFL_FM_neverFrames' + if( !(W4WFL_FM_neverFrames & nIniFMFlags) ) + { + if( !pFLOInfos ) + pFLOInfos = new W4WFLOInfos; + + W4WFLOInfo_Ptr pInfo = new W4WFLOInfo(); + + BOOL bOk = FALSE; + if( GetDecimal( pInfo->nFlowId ) && !nError + && GetDecimal( pInfo->nRects ) && !nError ) + { + pInfo->pIds = new long[ pInfo->nRects ]; + + bOk = TRUE; + for (int i=0; i < pInfo->nRects; i++) + if( !GetDecimal(pInfo->pIds[ i ]) || nError ) + { + bOk = FALSE; + break; + } + } + if( bOk ) + pFLOInfos->Insert( pInfo, pFLOInfos->Count() ); + else + delete pInfo; + } +} + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ +* * +* es wird ernst: Reaktion auf Start-/Endmarken im Fliesstext * +* * + \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +void SwW4WParser::Read_BeginTextFlow() // BTF +{ + if( !pFLOInfos ) return; + + if( !bPDTanalyzed ) + bPDTanalyzed = Read_Analyze_FLO_PDT(); + + long nFlowId; + if( GetDecimal( nFlowId ) && !nError ) + { + W4WFLOInfo_Ptr pFLO = 0; + for(int i = 0; i < pFLOInfos->Count(); i++) + { + if( nFlowId == pFLOInfos->GetObject( i )->nFlowId ) + { + pFLO = pFLOInfos->GetObject( i ); + break; + } + } + if( pFLO ) + { + W4WRectInfo* pRectInfo = pRDTInfos->Get(pFLO->pIds[ 0 ]); + // Rechteck 1 ist bekannt, also ggfs. PaM in die Seite setzen! + if( pRectInfo ) + { + // ACHTUNG: PgDesk darf ich immer in den Body setzen!! + // + // daher lieber nachsehen, ob dieses neue Rect noch + // im aktuellen Hd-/Ft-Abschnitt + // auf der gleichen Seite steckt + if( bHeadFootDef + && !( pActRectInfo + && ( ( pActRectInfo->BodyHdFtMode() + != pRectInfo->BodyHdFtMode() ) + || ( (1 < pActRectInfo->BodyHdFtMode()) + && ( pActRectInfo->nPDTId + != pRectInfo->nPDTId ) ) ) ) ) + { + // wichtig: zurueck VOR den Beginn des .<BTF..> + // gehen, damit dieser NACH dem Verlassen + // des K-/F-Bereichs nochmals gelesen wird + rInp.Seek( nStartOfActRecord - 1 ); + + bHeadFootDef = FALSE; + } + else + { + W4WRectInfo* pLastRectInfo = pActRectInfo; + pActRectInfo = pRectInfo; + if( pLastRectInfo != pActRectInfo ) + { + /* + anderes Rect ist jetzt aktiv, also nachschauen, ob + wir vielleicht einen neuen PageDesc benoetigen + */ + if( 0 <= pRectInfo->nPDTId ) + { + // global die PDTInfo merken + pPDTInfo = pPDTInfos->GetObject( pRectInfo->nPDTId ); + + SwPageDesc& rNextPageDesc = + (SwPageDesc&)pDoc->GetPageDesc( pPDTInfo->nSwPdId ); + + if( pPageDesc != &rNextPageDesc ) + { + // dies ist der neue PageDesc + pPageDesc = &rNextPageDesc; + + // Ok, neuen PageDesc ins Doc setzen... + pDoc->Insert( *pCurPaM, SwFmtPageDesc( pPageDesc )); + bIsTxtInPgDesc = FALSE; + + // Up to now there was no .<HNP> within this Page-Descriptor's scope. + // ( We need this information in SwW4WParser::Read_HardNewPage() ) + bIsTxtInPara + = bIsTxtInPgDesc + = bWasTxtSince_BREAK_PAGE + = bWasHNPInPgDesc + = FALSE; + + //UpdateCacheVars(); + } + } + } + } + } + } + } +} + +void SwW4WParser::Read_EndTextFlow() // ETF +{ + if( !pFLOInfos ) return; + +} + +void SwW4WParser::Read_TextRectangelId() // TRI +{ + if( !pFLOInfos ) return; + + if( !bPDTanalyzed ) + bPDTanalyzed = Read_Analyze_FLO_PDT(); + + long nRectId; + if( GetDecimal( nRectId ) && !nError ) + { + W4WRectInfo* pRectInfo = pRDTInfos->Get( nRectId ); + if( pRectInfo ) + { + W4WRectInfo* pLastRectInfo = pActRectInfo; + pActRectInfo = pRectInfo; + if( pLastRectInfo != pActRectInfo ) + { + // anderes Rect ist jetzt aktiv, also nachschauen, ob wir + // vielleicht einen neuen PageDesc benoetigen + + if( 0 <= pRectInfo->nPDTId ) + { + // global die PDTInfo merken + pPDTInfo = pPDTInfos->GetObject( pRectInfo->nPDTId ); + SwPageDesc& rNextPageDesc = + (SwPageDesc&)pDoc->GetPageDesc( pPDTInfo->nSwPdId ); + if( (pPageDesc != &rNextPageDesc) + && (USHRT_MAX != pPDTInfo->nBodyRectId) ) + { + // Ok, Werte fuer neuen PageDesc setzen... + + // Upper und Left der PrtArea definieren + USHORT nMinTop, nMinLeft, nMinBottom, nMinRight; + if( MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() ) + { + nMinTop = nMinLeft = + nMinBottom = nMinRight = 1134; //2 cm + } + else + { + nMinTop = nMinBottom= 1440; //wie zB. in WW: 1 Inch + nMinLeft = nMinRight = 1800; // 1,25 Inch + } + USHORT nTop = nMinTop; + USHORT nLeft = nMinLeft; + W4WRectInfo& rBodyInfo = + *pRDTInfos->Get( pPDTInfo->nBodyRectId); + W4WRectInfo* pHdInfo = + (USHRT_MAX != pPDTInfo->nHdRectId) + ? pRDTInfos->Get( pPDTInfo->nHdRectId ) + : 0; + W4WRectInfo* pFtInfo = + (USHRT_MAX != pPDTInfo->nFtRectId) + ? pRDTInfos->Get( pPDTInfo->nFtRectId ) + : 0; + + SwRect& rBodyRect = rBodyInfo.aRect; + Point& rUpPos = pHdInfo ? pHdInfo->aRect.Pos() + : rBodyRect.Pos(); + Point& rLoPos = pFtInfo ? pFtInfo->aRect.Pos() + : rBodyRect.Pos(); + + nTop = (USHORT)rUpPos.Y(); + nLeft = (USHORT)rUpPos.X(); + + SwFrmFmt& rFrmFmt = pPageDesc->GetMaster(); + + rFrmFmt.SetAttr( SvxULSpaceItem( nTop, nMinBottom ) ); + rFrmFmt.SetAttr( SvxLRSpaceItem( nLeft, nMinRight ) ); + + SwFrmFmt* pHdFmt = 0; + SwFrmFmt* pFtFmt = 0; + W4WRectInfo& rRectInfo = *pRDTInfos->Get( pPDTInfo->nHdRectId ); + if( pHdInfo ) + { + pHdFmt = (SwFrmFmt*)pPageDesc->GetMaster().GetHeader().GetHeaderFmt(); + SwRect& rUpRect = pHdInfo->aRect; + UpdateHdFtMarginSettings( + pHdFmt, + rUpRect.Height(), // Kopf-Hoehe + rBodyRect.Top() -rUpRect.Bottom(),// Kopf-Lower + TRUE); + } + if(USHRT_MAX != pPDTInfo->nFtRectId) + { + pFtFmt = (SwFrmFmt*)pPageDesc->GetMaster().GetFooter().GetFooterFmt(); + SwRect& rLoRect = pFtInfo->aRect; + UpdateHdFtMarginSettings( + pFtFmt, + rLoRect.Height(), // Fuss-Hoehe + rLoRect.Top() -rBodyRect.Bottom(),// Fuss-Upper + FALSE); + } + + // PgDesk immer nur im Body setzen!! + + } + } + } + } + } +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_w4wstk.cxx b/binfilter/bf_sw/source/filter/w4w/sw_w4wstk.cxx new file mode 100644 index 000000000000..0bf3f5f26b74 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_w4wstk.cxx @@ -0,0 +1,591 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +/************************************************************************* + + zu W4WStkEntry.bCopied .bClosed .bNeverIntoDoc + ------------------------------------------------ + + bCopied: Attr war auf dem Parent-Stack offen ( bLocked ) und wurde + deshalb beim Anlegen des aktuellen Stacks auch hier als + offen angelegt. + + Sinn: Bei HdFt, Fussnoten und APOs muessen offene Attr + in neuen Stack uebertragen werden. + Dies geschieht durch Aufruf des Copy-Construktors + von W4WCtrlStack. ---- + + + bClosed: Waehrend ein Child-Stack aktiv war, wurde festgestellt, + dass dieses Attr zu schliessen ist. + + Sinn: In HdFt, Fussnoten und APOs koennen kopierte(!) + Attribute geschlossen werden (s.o. unter bCopied). + Dann wird beim Original-Attr das bClosed ueber + WCtrlStack::SetLockedAttrClosed() gesetzt, damit + NACH dem Einlesen des Bereichs (und dem Restaurieren + des Original-Stacks und von pCurPaM) das Original + durch WCtrlStack::SetEndForClosedEntries() + geschlossen wird. + + + bNeverIntoDoc: Attr liegt nur dashalb auf dem Stack, damit der + entsprechende Schliessen-Befehl einen passenden + Gegenpart findet, es soll jedoch NICHT ins + Dokument eingesetzt sondern bloss vom Stack + genommen werden. + + Sinn: Werden Attr definiert, die in IDENTISCHER Form + bereits im derzeit gueltigen STYLE definiert sind, + legen wir sie zwar hilfsweise auf den Stack, + vermeiden jedoch, dass sie aktiv werden, um nicht + ein HARTES Attribut zu setzen, wo der gewuenschte + Effekt ja bereits durch den Style sichergestellt ist. + Gesetzt wird das Flag in WCtrlStack::NewAttr() + und ausgewertet dann in WCtrlStack::SetAttr(). + + + zu WCtrlStack::SetAttr() + ------------------------ + + bDoNotSetInDoc: ist dies TRUE, dann das Attr noch nicht + ins Dokument setzen, sondern auf dem Stack lassen. + + Sinn: Falls wir den pCurPaM manuell zurueck gesetzt haben, + z.B.: mit pCurPaM->Move( fnMoveBackward, fnGoCntnt ), + liefert rPos.nNode.GetIndex() einen Wert, der dazu + fueher wuerde, das das Attr ins Doc gesetzt wird. + Um dies zu verhindern, setzen wir dieses Hilfs-Flag. + +*************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <bf_svx/adjitem.hxx> + + +#include <fmtanchr.hxx> +#include <frmfmt.hxx> +#include <pam.hxx> +#include <doc.hxx> +#include <ndtxt.hxx> +#include <paratr.hxx> // GetAdjust() +#include <w4wstk.hxx> // W4WStkEntry, W4WStack +#include <w4wpar.hxx> // SwW4WParser + + +namespace binfilter { + +SV_IMPL_PTRARR( W4WCtrlStkEntries,W4WStkEntryPtr ) + + +static SwCntntNode* GetCntntNode( SwNodeIndex& rIdx, BOOL bNext ) +{ + SwCntntNode* pCNd = rIdx.GetNode().GetCntntNode(); + if( !pCNd && 0 == ( pCNd = bNext ? rIdx.GetNodes().GoNext( &rIdx ) + : rIdx.GetNodes().GoPrevious( &rIdx ) )) + { + pCNd = bNext ? rIdx.GetNodes().GoPrevious( &rIdx ) + : rIdx.GetNodes().GoNext( &rIdx ); + ASSERT( pCNd, "kein ContentNode gefunden" ); + } + return pCNd; +} + +// ------ Stack-Eintrag fuer die gesamten - Attribute vom Text ----------- + + +W4WStkEntry::W4WStkEntry( const SwPosition & rStartPos, + SfxPoolItem * pHt, + BOOL bInitCopied, + BOOL bInitNID ) + : nMkNode( rStartPos.nNode, -1 ), nPtNode( nMkNode ) +{ + // Anfang vom Bereich merken + nMkCntnt = rStartPos.nContent.GetIndex(); + pAttr = pHt; // speicher eine Kopie vom Attribut + bLocked = TRUE; // locke das Attribut --> darf erst + bCopied = bInitCopied; // gesetzt werden, wenn es wieder geunlocked ist + bClosed = FALSE; + bNeverIntoDoc = bInitNID; +} + + +W4WStkEntry::~W4WStkEntry() +{ + // Attribut kam zwar als Pointer, wird aber hier geloescht + if( pAttr ) + delete pAttr; +} + + +void W4WStkEntry::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 W4WStkEntry::MakeRegion( SwPaM& rRegion ) const +{ + // wird ueberhaupt ein Bereich umspannt ?? + // - ist kein Bereich, dann nicht returnen wenn am Anfang vom Absatz + // - Felder aussortieren, koennen keinen Bereich haben !! + 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( rRegion.GetPoint()->nNode, TRUE ); + rRegion.GetPoint()->nContent.Assign( pCNd, nMkCntnt ); + rRegion.SetMark(); + rRegion.GetPoint()->nNode = nPtNode.GetIndex() + 1; + pCNd = GetCntntNode( rRegion.GetPoint()->nNode, FALSE ); + rRegion.GetPoint()->nContent.Assign( pCNd, nPtCntnt ); + return TRUE; +} + + + +W4WCtrlStack::W4WCtrlStack( SwW4WParser& rPars ) + : W4WCtrlStkEntries( 10, 5 ), pParentStack( 0 ), pParser( &rPars ) +{ +} + + + +// W4WCtrlStack Copy-Ctor ist dafuer da, +// bei HdFt, Fussnoten und APOs +// die Char- und Para-Attribute des Haupttextes zu uebernehmen + +W4WCtrlStack::W4WCtrlStack( W4WCtrlStack& rCpy, const SwPosition& rPos ) + : W4WCtrlStkEntries( 10, 5 ), + pParser( rCpy.pParser ), + pParentStack( &rCpy ) +{ + USHORT nCnt = rCpy.Count(); + + W4WStkEntry* pEntry; + + for ( USHORT i=0; i < nCnt; i++ ) + { + pEntry = rCpy[ i ]; + USHORT nWhich = pEntry->pAttr->Which(); + if( pEntry->bLocked + && ( ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END ) + || ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_PARATR_END ) ) ) + { + W4WStkEntry *pTmp = + new W4WStkEntry( rPos, pEntry->pAttr->Clone(), TRUE ); + Insert( pTmp, Count() ); + } + } +} + + +W4WCtrlStack::~W4WCtrlStack() +{ + ASSERT( !Count(), "noch Attribute auf dem Stack" ); +} + + +// W4WCtrlStack::NewAttr() beendet alle gleichen Attribute, +// die vielleicht auf dem Stack liegen und legt neues Attribut an. +// Falls identisches Attr im gueltigen Style definiert ist, +// wird beim neuen Attr das Flag bNeverIntoDoc gesetzt. + +void W4WCtrlStack::NewAttr( const SwPosition& rPos, + const SfxPoolItem& rAttr ) +{ + register USHORT nAttrId = rAttr.Which(); // Id ermitteln + SetAttr( rPos, nAttrId ); // altes Attr beenden + + SwTxtFmtColl* pAktColl; // auf Stack nachsehen + BOOL bFoundInStyle = + ( ( ( POOLATTR_BEGIN <= nAttrId ) + && ( POOLATTR_END > nAttrId ) + ) + && ( 0 != ( pAktColl = pParser->GetAktColl() ) ) + && ( rAttr == pAktColl->GetAttr( nAttrId ) ) ); + + W4WStkEntry *pTmp = + new W4WStkEntry( rPos, rAttr.Clone(), // neues Attr anlegen + FALSE, bFoundInStyle ); + Insert( pTmp, Count() ); +} + + +// W4WCtrlStack::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. +// Sinn ist, z.B. bei doppelten Tabs (bei WW-Import staendig) keine Berge von +// ueberfluessigen Attributen entstehen zu lassen + +void W4WCtrlStack::StealAttr( const SwPosition& rPos, USHORT nAttrId ) +{ + USHORT nCnt = Count(); + if( nCnt ) + { + const ULONG nNodeIndex = rPos.nNode.GetIndex(); + + register W4WStkEntry* pEntry; + + while( --nCnt ) + { + pEntry = /*(W4WStkEntry*)*/(*this)[ nCnt ]; + if( ( nNodeIndex == pEntry->nPtNode.GetIndex()+1 ) + && ( !nAttrId + || ( nAttrId == pEntry->pAttr->Which() ) ) ) + // loesche aus dem Stack + DeleteAndDestroy( nCnt ); + } + } +} + + +// W4WCtrlStack::SetLockedAttrClosed() sucht auf dem nach Attributen des +// angegebenen Typs und setzt sie bClosed. +// Anschliessend rekurs. Aufruf auf dem Parent-Stack. +void W4WCtrlStack::SetLockedAttrClosed( USHORT nAttrId ) +{ + ASSERT( ( POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId ) + || ( RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId ), + "Attribut-Id ist ungueltig" ); + + USHORT nCnt = Count(); + if( nCnt ) + { + register W4WStkEntry* pEntry; + + while( --nCnt ) + { + pEntry = GetObject( nCnt ); + /* + nachschauen, ob Id gleich und Attr offen + */ + if( pEntry->bLocked + && ( nAttrId == pEntry->pAttr->Which() ) ) + { + pEntry->bClosed = TRUE; + if( pEntry->bCopied && pParentStack ) + pParentStack->SetLockedAttrClosed( nAttrId ); + } + } + } +} + + +// W4WCtrlStack::StealWWTabAttr wird gebraucht, um beim WW2-Import von Tabellen +// falsche Absatz-Adjust-Attribute wieder herauszufischen. Hierbei handelt es +// sich um harte ADJLEFT-Attribute, die noch offen sind. ( siehe auch w4wpar2 ) + +void W4WCtrlStack::StealWWTabAttr( const SwPosition& rPos ) +{ + USHORT nCnt = Count(); + if( nCnt ) + { + const ULONG nIdx = rPos.nNode.GetIndex(); + register W4WStkEntry* pEntry; + + while( --nCnt ) + { + pEntry = /*(W4WStkEntry*)*/GetObject( nCnt ); + register SfxPoolItem* pAt = pEntry->pAttr; + if ( pAt->Which() == RES_PARATR_ADJUST + && pEntry->bLocked + && ((SvxAdjustItem*)pAt)->GetAdjust() == SVX_ADJUST_LEFT + && pEntry->nPtNode.GetIndex()+1 == nIdx ) + // selber Absatz + 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 W4WCtrlStack::SetAttr( const SwPosition& rPos, USHORT nAttrId, + BOOL bTstEnde, BOOL bDoNotSetInDoc ) +{ + 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(); + + if( !nCnt ) return FALSE; + + W4WStkEntry* pEntry; + + for ( USHORT i=0; i < nCnt; i++ ) + { + pEntry = GetObject( i ); + if( pEntry->bLocked ) + { + // setze das Ende vom Attribut + if( !nAttrId || nAttrId == pEntry->pAttr->Which() ) + { + if( nAttrId && pEntry->bCopied && pParentStack ) + pParentStack->SetLockedAttrClosed( nAttrId ); + pEntry->SetEndPos( rPos ); + bFound = TRUE; + } + continue; + } + + // ist die Endposition die Cursor-Position, dann noch nicht + // ins Dokument setzen, es muss noch Text folgen; + // ausser am Dokumentende. (Attribut-Expandierung !!) + if( bTstEnde + && ( bDoNotSetInDoc + || ( pEntry->nPtNode.GetIndex()+1 == rPos.nNode.GetIndex()))) + continue; + + if( !pEntry->bNeverIntoDoc ) + { + SwPaM aTmpCrsr( rPos ); + SetAttrInDoc( aTmpCrsr, *pEntry ); + } + DeleteAndDestroy( i ); // loesche diesen Entry vom Stack, + i--; nCnt--; // danach rutschen alle folgenden nach unten + } + return bFound; +} + + +void W4WCtrlStack::SetEndForClosedEntries( const SwPosition& rPos ) +{ + USHORT nCnt = Count(); + + if( !nCnt ) return; + + W4WStkEntry* pEntry; + + for( USHORT i=0; i < nCnt; i++ ) + { + pEntry = GetObject( i ); + if( pEntry->bLocked && pEntry->bClosed ) + /* + setze das Ende vom Attribut + */ + pEntry->SetEndPos( rPos ); + } +} + + +void W4WCtrlStack::SetAttrInDoc( SwPaM& rRegion, const W4WStkEntry& rEntry ) +{ + if( rEntry.bNeverIntoDoc ) return; // nur eine Sicherheitsabfrage ;-) + + SwDoc* pDoc = rRegion.GetDoc(); + + switch( rEntry.pAttr->Which() ) + { + case RES_FLTR_ANCHOR: + { + // der Anker ist der Point vom Pam. Dieser wird beim Einfugen + // von Text usw. veraendert; darum wird er auf dem Stack + // gespeichert Stack. Das Attribut muss nur noch im Format + // gesetzt werden. + rRegion.DeleteMark(); + rRegion.GetPoint()->nNode = rEntry.nMkNode.GetIndex() + 1; + SwCntntNode* pCNd = GetCntntNode( rRegion.GetPoint()->nNode, TRUE ); + rRegion.GetPoint()->nContent.Assign( pCNd, rEntry.nMkCntnt ); + + SwFrmFmt* pFmt = ((SwW4WAnchor*)rEntry.pAttr)->GetFlyFmt(); + SwFmtAnchor aAnchor( pFmt->GetAnchor() ); + aAnchor.SetAnchor( rRegion.GetPoint() ); + pFmt->SetAttr( aAnchor ); + } + break; + + case RES_FLTR_STYLESHEET: + { + rRegion.DeleteMark(); + rRegion.GetPoint()->nNode = rEntry.nMkNode.GetIndex() + 1; + SwCntntNode* pCNd = GetCntntNode( rRegion.GetPoint()->nNode, TRUE ); + rRegion.GetPoint()->nContent.Assign( pCNd, rEntry.nMkCntnt ); + rRegion.SetMark(); + rRegion.GetPoint()->nNode = rEntry.nPtNode.GetIndex() + 1; + pCNd = GetCntntNode( rRegion.GetPoint()->nNode, FALSE ); + rRegion.GetPoint()->nContent.Assign( pCNd, rEntry.nPtCntnt ); + + USHORT nId = ((SwW4WStyle*)rEntry.pAttr)->GetStyleId(); + + USHORT nOldId = pParser->GetAktCollId(); // Id vom aktuellen StyleSheet + pParser->SetAktCollId( nId ); + SwTxtFmtColl* pTFC = pParser->GetAktColl(); + pDoc->SetTxtFmtColl( rRegion, pTFC, FALSE ); + pParser->SetAktCollId( nOldId ); // restore It !!! + } + break; + case RES_TXTATR_FIELD: + break; +/* +// JP 14.01.97: sollte auch ueber die normle Attribut-SS gehen! + case RES_TXTATR_TOXMARK: + { + USHORT nLen; + if ( rRegion.GetPoint()->nNode == rRegion.GetMark()->nNode ){ + // Anf u. Ende im selben Absatz ? + nLen = rRegion.GetPoint()->nContent.GetIndex() + - rRegion.GetMark()->nContent.GetIndex(); + }else{ // nein + nLen = pDoc->GetNodes()[rRegion.GetMark()->nNode] + ->GetTxtNode()->GetTxt().Len() // nur bis zum Ende des Absatzes + - rRegion.GetMark()->nContent.GetIndex(); + } + if ( nLen ) + pDoc->Insert( *rRegion.GetPoint(), nLen, + *(SwTOXMark*)rEntry.pAttr ); + } + break; +*/ + default: + if( rEntry.MakeRegion( rRegion ) ) + pDoc->Insert( rRegion, *rEntry.pAttr ); + break; + } +} + + +SfxPoolItem* W4WCtrlStack::GetFmtStkAttr( USHORT nWhich, USHORT * pPos ) +{ + W4WStkEntry* 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* W4WCtrlStack::GetFmtAttr( const SwPaM& rPaM, USHORT nWhich ) +{ + SfxPoolItem* pHt = GetFmtStkAttr( nWhich ); + if( pHt ) + return (const SfxPoolItem*)pHt; + + // im Stack ist das Attribut nicht vorhanden, also befrage das Dokument + SwCntntNode * pNd = rPaM.GetCntntNode(); + if( !pNd ) // kein ContentNode, dann das dflt. Attribut + return &rPaM.GetDoc()->GetAttrPool().GetDefaultItem( nWhich ); + return &pNd->GetAttr( nWhich ); +} + + +BOOL W4WCtrlStack::IsAttrOpen( USHORT nAttrId ) +{ + USHORT nCnt = Count(); + + if( !nCnt ) return FALSE; + + W4WStkEntry* pEntry; + + for ( USHORT i=0; i < nCnt; i++ ) + { + pEntry = GetObject( i ); + if( pEntry->bLocked && nAttrId == pEntry->pAttr->Which() ) + return TRUE; + } + return FALSE; +} + + +// weitere Teile aus ehemaligem swrtf.hxx + +SwW4WStyle::SwW4WStyle( USHORT nId ) + : SfxPoolItem( RES_FLTR_STYLESHEET ), nStyleId( nId ) +{} + + +SwW4WStyle::SwW4WStyle( const SwW4WStyle & rRTFFld ) + : SfxPoolItem( RES_FLTR_STYLESHEET ), nStyleId( rRTFFld.nStyleId ) {} + + +SfxPoolItem* SwW4WStyle::Clone( SfxItemPool* ) const +{ return new SwW4WStyle( *this ); } + + +int SwW4WStyle::operator==( const SfxPoolItem& rHt ) const +{ return nStyleId == ((const SwW4WStyle&)rHt).nStyleId; } + +//------ hier steht die Klasse fuer das SwW4WAnchor ----------- + +SwW4WAnchor::SwW4WAnchor( SwFlyFrmFmt* pFmt ) + : SfxPoolItem( RES_FLTR_ANCHOR ), pFlyFmt( pFmt ) +{} + +SwW4WAnchor::SwW4WAnchor( const SwW4WAnchor& rCpy ) + : SfxPoolItem( RES_FLTR_ANCHOR ), pFlyFmt( rCpy.pFlyFmt ) +{} + +int SwW4WAnchor::operator==( const SfxPoolItem& rItem ) const +{ + return pFlyFmt == ((SwW4WAnchor&)rItem).pFlyFmt; +} + +SfxPoolItem* SwW4WAnchor::Clone( SfxItemPool* ) const +{ + return new SwW4WAnchor( *this ); +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_wrtgraf.cxx b/binfilter/bf_sw/source/filter/w4w/sw_wrtgraf.cxx new file mode 100644 index 000000000000..0b0bb064d84c --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_wrtgraf.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <frmfmt.hxx> +#include <ndgrf.hxx> +#include <wrtw4w.hxx> +namespace binfilter { + +void SwW4WWriter::OutW4W_Grf( const SwGrfNode* ) +{ +// Anhand des alten WindowCodes muss das gesamte mal auf Stream-Interfaces +// umgestellt werden !!! + return; +} + // WIN + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/sw_wrtw4w.cxx b/binfilter/bf_sw/source/filter/w4w/sw_wrtw4w.cxx new file mode 100644 index 000000000000..c1b2bf71efb4 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/sw_wrtw4w.cxx @@ -0,0 +1,1255 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <stdlib.h> +#include <stdio.h> + + +#define ITEMID_BOXINFO SID_ATTR_BORDER_INNER +#include <hintids.hxx> + + +#include <unotools/tempfile.hxx> +#include <bf_svx/paperinf.hxx> +#include <tools/stream.hxx> +#include <bf_sfx2/docfile.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/ulspitem.hxx> +#include <bf_svx/lrspitem.hxx> + + +#include <fmtfsize.hxx> +#include <fmtornt.hxx> +#include <fmtcntnt.hxx> +#include <fmtanchr.hxx> +#include <fmtsrnd.hxx> +#include <fmtfsize.hxx> +#include <frmatr.hxx> +#include <node.hxx> +#include <pam.hxx> +#include <doc.hxx> +#include <docary.hxx> +#include <mdiexp.hxx> // ...Percent() +#include <paratr.hxx> +#include <fmtcol.hxx> +#include <flypos.hxx> +#include <pagedesc.hxx> +#include <w4wflt.hxx> +#include <pageiter.hxx> +#include <swtable.hxx> +#include <w4wpar.hxx> +#include <wrtw4w.hxx> +#include <swfltopt.hxx> + +#include <swerror.h> +#include <statstr.hrc> // ResId fuer Statusleiste +namespace binfilter { + +const sal_Char __FAR_DATA sW4W_RECBEGIN[3] = { cW4W_BEGICF, cW4W_LED, 0 }; +const sal_Char __FAR_DATA sW4W_TERMEND[3] = { cW4W_TXTERM, cW4W_RED, 0 }; + + +//------------------------------------------------------------------- +// Tabelle + +void GetW4WWriter( const String& rFltName, WriterRef& xRet ) +{ + xRet = new SwW4WWriter( rFltName ); +} + + +BOOL SwW4WWriter::IsStgWriter() +{ + return bStorageFlag; +} + +void SwW4WWriter::OutW4W_CountTableSize( const SwTable* pTab, USHORT& rLines, + USHORT& rMaxCols, USHORT& rBrtCol ) +{ + rLines = pTab->GetTabLines().Count(); + USHORT nC, i; + rMaxCols = 0; + rBrtCol = 0; + for( i=0; i<rLines; i++){ + nC = pTab->GetTabLines()[i]->GetTabBoxes().Count(); + if ( nC > rMaxCols ){ + rMaxCols = nC; + rBrtCol = i; + } + } +} + + +BYTE SwW4WWriter::OutW4W_GetTableColPos( const SwTableLine* pL, + SwHoriOrient eHor, SwTwips* pCellPos ) +{ + USHORT nCols = pL->GetTabBoxes().Count(); + SwTwips nLeft = nPgLeft; //(USHORT)(pLR->GetLeft()); + USHORT j; + + + BYTE nCode = 0x0a; + pCellPos[0]=0; + + for( j=0; j<nCols; j++ ){ // Berechne Cell-Positionen + const SwTableBox* pB = pL->GetTabBoxes()[j]; + SwTwips nWid = pB->GetFrmFmt()->GetFrmSize().GetWidth(); + if ( nWid > 0x10000 ) + nWid = ( nWid / 0x10000 ) * ( nPgRight - nPgLeft ) + / ( LONG_MAX / 0x10000 ); // SpezialWert + pCellPos[j+1] = pCellPos[j] + nWid; + } + USHORT nWidth = (USHORT)pCellPos[nCols]; // Merke Tabellenbreite + + switch ( eHor ){ + case HORI_NONE: nCode |= 0x40; break; + case HORI_RIGHT: nCode |= 0x30; + nLeft = nPgRight - nWidth; + break; + case HORI_CENTER: nCode |= 0x20; + nLeft = ( nPgLeft + nPgRight - nWidth ) / 2; + break; + case HORI_FULL: nCode |= 0x10; + nLeft = ( nPgLeft + nPgRight - nWidth ) / 2; + break; + // alles andere wird zu left + } + + nLeft -= nFlyLeft; // zumindest WW2 verlangt Pos relativ zu FlyFrame + if ( nLeft < 0 ) + nLeft = 0; + + for( j=0; j<=nCols; j++ ){ // korrigiere Cell-Positionen + pCellPos[j] += nLeft; + } + return nCode; +} + + +void SwW4WWriter::OutW4W_WriteTableHeader( BYTE nCode, USHORT nCols, + SwTwips* pCellPos ) +{ + USHORT j; + + OutHex( Strm() << sW4W_RECBEGIN << "CDS", nCode ) + << cW4W_TXTERM; + OutULong( nCols ) << cW4W_TXTERM; + + for( j=0; j<nCols; j++ ) + { + OutULong( pCellPos[j] / 144 ) << cW4W_TXTERM; + OutULong( (pCellPos[j+1] -1 ) / 144) << cW4W_TXTERM + << '0' << cW4W_TXTERM; + } + + for( j=0; j<nCols; j++ ) + { + OutULong( pCellPos[j] ) << cW4W_TXTERM; + OutULong( pCellPos[j+1] -1 ) << cW4W_TXTERM + << '0' << cW4W_TXTERM; + } + Strm() << cW4W_RED << sW4W_RECBEGIN << "BCM" << cW4W_RED; +} + +void SwW4WWriter::OutW4W_WriteTableLineHeader( USHORT nCols, USHORT nLineHeight, + USHORT *pBorder ) +{ + USHORT j; + OutULong( Strm() << sW4W_RECBEGIN << "BRO", nCols ) + << cW4W_TXTERM; + OutULong( nLineHeight / 240 ) << cW4W_TXTERM; + OutULong( nLineHeight ) << cW4W_TXTERM; + + if ( pBorder ) + for ( j=0; j<nCols; j++ ) + OutHex4( pBorder[j] ) << cW4W_TXTERM; // Border-Code + else + for ( j=0; j<nCols; j++ ) + Strm() << "0000" << cW4W_TXTERM; // Border-Code 0 + + Strm() << '0' << sW4W_TERMEND; // Left justify +} + +void SwW4WWriter::OutW4W_WriteTableBoxHeader( USHORT nNumCol, USHORT nSpan ) +{ + OutULong( Strm() << sW4W_RECBEGIN << "BCO", nNumCol ) + << cW4W_TXTERM; + OutULong( nSpan ) << cW4W_TXTERM + << '1' << cW4W_TXTERM // hor. ausgeglichen + << '0' << cW4W_TXTERM // vert. ausgeglichen + << '0' << cW4W_TXTERM // Linksbuendig + << '2' << cW4W_TXTERM // 2 Dezimalen + << '0' << sW4W_TERMEND; // V-Align: Top +} + + + +// OutW4W_TestTableLineWW2 returned, ob sich die Position der Spalten +// geaendert hat + +BOOL SwW4WWriter::OutW4W_TestTableLineWW2( const SwTable* pTab, + USHORT nLineNo, USHORT nCols, SwTwips* pCellPos ) +{ + const SwTableLine* pL = pTab->GetTabLines()[nLineNo]; + + if ( nCols != pL->GetTabBoxes().Count() ) + return TRUE; + + SwTwips nPos=pCellPos[0]; + + for( USHORT j=0; j<pL->GetTabBoxes().Count(); j++){ + + const SwTableBox* pB = pL->GetTabBoxes()[j]; + SwTwips nW = pB->GetFrmFmt()->GetFrmSize().GetWidth(); + if ( nW > 0x10000 ) // SpezialWert + nW = (nW/0x10000) * (nPgRight-nPgLeft) / (LONG_MAX/0x10000 ); + nPos += nW; // aktualisiere x-Position + SwTwips nDiff = pCellPos[j+1] - nPos; + if ( nDiff > 56 || nDiff < -56 ) + return TRUE; + } + return FALSE; +} + +// OutW4W_GetBorder holt zu einem gegebenen Frameformat den Border, +// konvertiert ihn in das MASO-Format und liefert ihn in rBorder zurueck. +// ist kein Rahmen vorhanden, wird FALSE returned. + +BOOL SwW4WWriter::OutW4W_GetBorder( const SvxBoxItem* pBox, USHORT& rBorder ) +{ + rBorder = 0; + + if ( !pBox ) return FALSE; + + for ( USHORT i=0; i<4; i++ ){ + const SvxBorderLine *pBrd; + switch (i){ + case 0: pBrd = pBox->GetRight(); break; + case 1: pBrd = pBox->GetBottom(); break; + case 2: pBrd = pBox->GetLeft(); break; + case 3: pBrd = pBox->GetTop(); break; + } + if ( pBrd ){ + if ( pBrd->GetInWidth() && pBrd->GetOutWidth() ){ + rBorder |= 2 << (i*4); // doppelt umrandet + }else{ + SwTwips nBr = pBrd->GetInWidth() + pBrd->GetOutWidth(); + if ( nBr <= 5 ) + rBorder |= 7 << (i*4); // Haarlinie + else if ( nBr <= 50 ) + rBorder |= 1 << (i*4); // duenne Linie + else if ( nBr <= 80 ) + rBorder |= 5 << (i*4); // dicke Linie + else + rBorder |= 6 << (i*4); // extra dicke Linie + } + } + } + return TRUE; +} + +void SwW4WWriter::OutW4W_TableLineWW2( const SwTable* pTab, + + USHORT nLineNo, USHORT nCols, USHORT nLineHeight, SwTwips* pCellPos ) +{ + const SwTableLine* pL = pTab->GetTabLines()[nLineNo]; + USHORT j; + + USHORT* pBorders = new USHORT[nCols]; + + for( j=0; j<nCols; j++){ // hole Umrandungen + if ( j < pL->GetTabBoxes().Count()){ + const SwFrmFmt * pFr; + pFr = pL->GetTabBoxes()[j]->GetFrmFmt(); // hole FrameFmt + if ( pFr ) + OutW4W_GetBorder( &pFr->GetBox(), pBorders[j] ); + }else{ + pBorders[j] = 0; + } + } + + OutW4W_WriteTableLineHeader( nCols, nLineHeight, pBorders ); + + DELETEZ( pBorders ); + + for( j=0; j<nCols; j++){ // hole Zellinhalt + + const SwStartNode *pSN = 0; + + OutW4W_WriteTableBoxHeader( j, 1 ); + + if ( j < pL->GetTabBoxes().Count()) + pSN = pL->GetTabBoxes()[j]->GetSttNd(); // hole StartNode + // des TabellenInhalts + if ( pSN ){ // StartNode wirklich vorhanden ? + + pOrigPam = pCurPam = NewSwPaM( *pDoc, + pSN->GetIndex(), pSN->EndOfSectionIndex() ); + + BOOL bOldTab = bTable; + bTable = TRUE; + pCurPam->Exchange(); + Out_SwDoc( pCurPam, FALSE ); // Inhalt der Zelle (mit Attributen) + bTable = bOldTab; + + delete pCurPam; + } + Strm() << sW4W_RECBEGIN << "HCB" << cW4W_RED; + } +} + +// OutW4W_SwTableWW2 schreibt eine Tabelle 'raus. Dabei wird bei jeder +// Aenderung der Zellenbreiten die aktuelle Tabelle beendet und eine +// neue mit den passenden Zellenbreiten direkt drangehaengt. Dieses +// ist bei WW2 noetig, da der WW2-Exportfilter die verbundenen Zellen +// ignoriert statt unterstuetzt. Evtl. kann diese Vorgehensweise auch +// fuer andere Exportformate guenstig sein, da Verschiebungen von +// Trennlinien im Zielformat dargestellt werden. + +void SwW4WWriter::OutW4W_SwTableWW2( const SwTable* pTab, USHORT nLines, + USHORT nMaxCols, USHORT nBCol, SwHoriOrient eHor, SwTwips* pCellPos ) +{ + const SwTableLine* pL = pTab->GetTabLines()[0]; + USHORT nCols = pL->GetTabBoxes().Count(); + USHORT nHei = (USHORT)(pL->GetFrmFmt()->GetFrmSize().GetHeight()); + + BYTE nCode = OutW4W_GetTableColPos( pL, eHor, pCellPos ); + OutW4W_WriteTableHeader( nCode, nCols, pCellPos ); + + for( USHORT i=0; i<nLines; i++){ + BOOL bRet = OutW4W_TestTableLineWW2( pTab, i, nCols, pCellPos ); + if ( bRet ){ // Spalten geaendert -> neue Tabelle + Strm() << sW4W_RECBEGIN << "ECM" << cW4W_RED; + pL = pTab->GetTabLines()[i]; + nCols = pL->GetTabBoxes().Count(); + BYTE nCode = OutW4W_GetTableColPos( pL, eHor, pCellPos ); + OutW4W_WriteTableHeader( nCode, nCols, pCellPos ); + } + OutW4W_TableLineWW2( pTab, i, nCols, nHei, pCellPos ); + } + Strm() << sW4W_RECBEGIN << "ECM" << cW4W_RED; +} + +void SwW4WWriter::OutW4W_TableLineNorm( const SwTable* pTab, + USHORT nLineNo, USHORT nMaxCols, USHORT nLineHeight, SwTwips* pCellPos ) +{ + const SwTableLine* pL = pTab->GetTabLines()[nLineNo]; + USHORT nHidden = nMaxCols - pL->GetTabBoxes().Count(); + USHORT* pBorders = new USHORT[nMaxCols]; + USHORT j, k; + + SwTwips nPos=pCellPos[0]; + for( j=0, k=0; j<nMaxCols&&k<nMaxCols; j++){ // Hole Umrandungen + + //!!! 2 Indices mitfuehren: j fuer Sw, k fuer W4W + + USHORT nSpan = 1; + const SwFrmFmt * pFr = 0; + + if ( j < pL->GetTabBoxes().Count()){ + const SwTableBox* pB = pL->GetTabBoxes()[j]; + SwTwips nW = pB->GetFrmFmt()->GetFrmSize().GetWidth(); + if ( nW > 0x10000 ) // SpezialWert + nW = (nW/0x10000) * (nPgRight-nPgLeft) / (LONG_MAX/0x10000 ); + nPos += nW; // aktualisiere x-Position + pFr = pB->GetFrmFmt(); // hole FrameFmt fuer Umrandungen + } + + if ( nHidden ) + while ( k+nSpan < nMaxCols + && nPos > pCellPos[k+nSpan] + 10 ){ + nSpan++; + } + if ( pFr ) + OutW4W_GetBorder( &pFr->GetBox(), pBorders[j] ); // hole Umrandungen + + k += nSpan; + } + + + OutW4W_WriteTableLineHeader( nMaxCols, nLineHeight, pBorders ); + + DELETEZ( pBorders ); + + nPos=pCellPos[0]; + + for( j=0, k=0; j<nMaxCols&&k<nMaxCols; j++){ // Hole Zelleninhalt + + //!!! 2 Indices mitfuehren: j fuer Sw, k fuer W4W + + USHORT nSpan = 1; + const SwStartNode *pSN = 0; + + if ( j < pL->GetTabBoxes().Count()){ + const SwTableBox* pB = pL->GetTabBoxes()[j]; + SwTwips nW = pB->GetFrmFmt()->GetFrmSize().GetWidth(); + if ( nW > 0x10000 ) // SpezialWert + nW = (nW/0x10000) * (nPgRight-nPgLeft) / (LONG_MAX/0x10000 ); + nPos += nW; // aktualisiere x-Position + pSN = pB->GetSttNd(); // hole StartNode TabellenInhalt + } + + if ( nHidden ) + while ( k+nSpan < nMaxCols + && nPos > pCellPos[k+nSpan] + 10 ){ + nSpan++; + } + + OutW4W_WriteTableBoxHeader( k, nSpan ); + + if ( pSN ){ // StartNode wirklich vorhanden ? + + pOrigPam = pCurPam = NewSwPaM( *pDoc, + pSN->GetIndex(), pSN->EndOfSectionIndex() ); + + BOOL bOldTab = bTable; + bTable = TRUE; + pCurPam->Exchange(); + Out_SwDoc( pCurPam, FALSE ); // Inhalt der Zelle (mit Attributen) + bTable = bOldTab; + + delete pCurPam; + } + + Strm() << sW4W_RECBEGIN << "HCB" << cW4W_RED; + + k += nSpan; + } +} + + +// OutW4W_SwTableNorm schreibt eine Tabelle 'raus. Dabei wird versucht, +// hor. verbundene Zellen anhand der Zellenbreiten zu erkennen +// und als entsprechend verbundene Zellen herauszuschreiben. + +void SwW4WWriter::OutW4W_SwTableNorm( const SwTable* pTab, USHORT nLines, + USHORT nMaxCols, USHORT nBCol, SwHoriOrient eHor, SwTwips* pCellPos ) +{ + const SwTableLine* pL = pTab->GetTabLines()[nBCol]; + USHORT nHei = (USHORT)(pL->GetFrmFmt()->GetFrmSize().GetHeight()); + + BYTE nCode = OutW4W_GetTableColPos( pL, eHor, pCellPos ); + OutW4W_WriteTableHeader( nCode, nMaxCols, pCellPos ); + + + for( USHORT i=0; i<nLines; i++) + OutW4W_TableLineNorm( pTab, i, nMaxCols, nHei, pCellPos ); + + Strm() << sW4W_RECBEGIN << "ECM" << cW4W_RED; +} + + +void SwW4WWriter::OutW4W_SwTable( const SwTableNode* pTableNd ) +{ +#if OSL_DEBUG_LEVEL > 1 + Strm() << sW4W_RECBEGIN << "NOP_Table_Node" << sW4W_TERMEND; +// Sound::Beep(); +#endif + const SwTable* pTab = &(pTableNd->GetTable()); + USHORT nLines, nMaxCols, nBCol; + + OutW4W_CountTableSize( pTab, nLines, nMaxCols, nBCol ); + + SwHoriOrient eHor = pTab->GetFrmFmt()->GetHoriOrient().GetHoriOrient(); + SwTwips* pCellPos = new SwTwips[nMaxCols+1]; + + SwPaM* pOldPam = pCurPam; + SwPaM* pOldEndPam = pOrigPam; + BOOL bOldWriteAll = bWriteAll; + + if ( GetFilter() == 44 || GetFilter() == 49 ) + OutW4W_SwTableWW2( pTab, nLines, nMaxCols, nBCol, eHor, pCellPos ); + else + OutW4W_SwTableNorm( pTab, nLines, nMaxCols, nBCol, eHor, pCellPos ); + + bWriteAll = bOldWriteAll; + pCurPam = pOldPam; + pOrigPam = pOldEndPam; + + pCurPam->GetPoint()->nNode = *pTableNd->EndOfSectionNode(); + DELETEZ( pCellPos ); +} + +//------------------------------------------------------------------- + +SwW4WWriter::SwW4WWriter( const String& rFltName ) +{ + bFirstLine = TRUE; + nFontHeight = 0; + pFlyFmt = 0; + pStyleEndStrm = pPostNlStrm = 0; + bFirstLine = bStyleDef = bStyleOnOff = bTable = bPageDesc = bEvenPage + = bLastPg = bHdFt = bFly = bTxtAttr = FALSE; + nPgLeft = 0; + nPgRight = lA4Width; + nIniFlags = 0; + pNdFmt = 0; + bStorageFlag = FALSE; + + String sFilter( rFltName.Copy( 3 )); + xub_StrLen nFndPos = sFilter.Search( '_' ); + sVersion = sFilter.Copy( nFndPos + 1 ); + sFilter.Erase( nFndPos + 1 ); + if( 0 != ( bStorageFlag = 'C' == sFilter.GetChar(0))) + sFilter.Erase( 0, 1 ); + + nFilter = sFilter.ToInt32(); +} + + +SwW4WWriter::~SwW4WWriter() {} + +ULONG SwW4WWriter::WriteStream() +{ + { + USHORT nFltNo = GetFilter(); + const sal_Char* aNames[ 2 ] = { "W4W/W4W000", "W4W/W4W000" }; + sal_uInt32 aVal[ 2 ]; + + SwFilterOptions aOpt; + + // set into the first name the filter number + sal_Char* pStr = (sal_Char*)aNames[0]; + pStr += 7; + *pStr++ = '0' + ( nFltNo / 100 ); nFltNo %= 100; + *pStr++ = '0' + ( nFltNo / 10 ); nFltNo %= 10; + *pStr++ = '0' + nFltNo; + + // first test if the node & content exist. If not, then we may not + // ask the configuration (produce assertions!) + pStr = (sal_Char*)aNames[0]; + pStr[ 3 ] = 0; + + if( aOpt.CheckNodeContentExist( pStr, pStr + 4 )) + { + pStr[ 3 ] = '/'; + aOpt.GetValues( 2, aNames, aVal ); + } + else + { + aOpt.GetValues( 1, aNames+1, aVal+1 ); + aVal[0] = 0; + } + + nIniFlags = aVal[ 0 ]; + if( !nIniFlags ) + nIniFlags = aVal[ 1 ]; + } + + bStyleDef = bStyleOnOff = bTable = bPageDesc = bEvenPage = bLastPg + = bHdFt = bIsTxtInPgDesc = bFly = FALSE; + nFlyWidth = nFlyHeight = 0; + nFlyLeft = nFlyRight = 0; + // Hier wird festgelegt, welches Ziel welche Buchstabencodierung + // per XCS vorgeworfen bekommt. HEX und UCS benutzen immer den + // IBMPC-Code. Wenn es nicht stimmt, klappt der + // Re-Import der Umlaute nicht. Es koennte auch etwas + // schlimmeres passieren, wenn der Export-Filter zu bloed ist. + // + // Im Moment wird nur fuer WW1/2/6 ANSI angenommen, sonst IBMPC. + // Wahrscheinlich erwarten alle Win-Ziele oder vielleicht auch + // alle Ziele Ansi, das konnte ich aber noch nicht ausprobieren. + // Dasselbe wird fuer die Styles benutzt, allerdings ohne + // XCS, sondern als direktes Zeichen, da ich vermute, dass es dann + // besser durch die Filter geht. + switch ( nFilter ) + { + case 44 : + case 49 : eTargCharSet = RTL_TEXTENCODING_MS_1252; break; + default : eTargCharSet = RTL_TEXTENCODING_IBM_850; break; + } + nFontId = 0; + + nMaxNode = pDoc->GetNodes().Count(); + + pFlyFmt = 0; // kein FlyFrmFormat gesetzt + pStyleEndStrm = pPostNlStrm = 0; // kein StyleEndStream gesetzt + + pNxtPg = new SwPosition( *pOrigPam->GetMark() ); + +// ValidateLayout(); // Nach ValidateLayout() aus pageiter.cxx + // sind alle Umbrueche richtig + + pIter = new SwPageIter( *pDoc, *pOrigPam->GetMark() ); + + ASSERT( pIter->GetPageDesc(), "1. Seite: PageDesc weg"); + pPgDsc2 = pPageDesc = pIter->GetPageDesc(); + pPgFrm = (SwFrmFmt*)&(pPgDsc2->GetMaster()); + pIter->NextPage(); + bLastPg = !( pIter->GetPosition( *pNxtPg )); + + // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn + // das gesamte Dokument geschrieben wird + nAktFlyPos = 0; + BYTE nSz = (BYTE)Min( pDoc->GetSpzFrmFmts()->Count(), USHORT(255) ); + SwPosFlyFrms aFlyPos( nSz, nSz ); + pDoc->GetAllFlyFmts( aFlyPos, bWriteAll ? 0 : pOrigPam ); + pFlyPos = &aFlyPos; + nDefLanguage = ((const SvxLanguageItem&)pDoc + ->GetDefault( RES_CHRATR_LANGUAGE )).GetLanguage(); + + // schreibe die StyleTabelle, allg. Angaben,Header/Footer/Footnotes + MakeHeader(); + + // kein PageDesc im 1. Absatz vorhanden ? + SfxItemSet* pSet = pCurPam->GetCntntNode(FALSE)->GetpSwAttrSet(); + if( !pSet || SFX_ITEM_SET != pSet->GetItemState( RES_PAGEDESC, FALSE )) + { +// Sound::Beep(); // dann gebe den Default-Pagedesc aus + OutW4W_SwFmtPageDesc1( *this, pPgDsc2 ); + } + + // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn + // das gesamte Dokument geschrieben wird + nAktFlyPos = 0; + + Out_SwDoc( pOrigPam, TRUE ); + + DELETEZ( pIter ); + DELETEZ( pNxtPg ); + + // loesche die Tabelle mit den freifliegenden Rahmen + for( USHORT i = aFlyPos.Count(); i > 0; ) + delete aFlyPos[ --i ]; + pFlyPos = 0; + + return 0; +} + +void SwW4WWriter::Out_SwDoc( SwPaM* pPam, BOOL bAttrOn ) +{ + BOOL bSaveWriteAll = bWriteAll; // sichern + + + // gebe alle Bereiche des Pams in das W4W-File aus. + do { + // Wenn der Pam innerhalb einer Tabelle steht, ruecke an den + // Tabellenanfang zurueck, damit Tabellen am Anfang eines Docs oder + // eines Flys mit uebernommen werden + if ( !bTable ){ + const SwNode* pNode = pDoc->GetNodes()[pCurPam->GetPoint()->nNode]; + const SwTableNode* pTblNd = pNode->FindTableNode(); + if ( pTblNd ){ + pCurPam->GetPoint()->nNode = *pTblNd; // TableNode ist StartNode + // TableNode ist kein ContentNode, deshalb darf kein Assign stattfinden + } + } + + bWriteAll = bSaveWriteAll; + bFirstLine = TRUE; + + // setze die dflt. Formate mit 0, damit auf jedenfall am Anfang + // eines jeden Cursors die Format-Attribute ausgegeben werden. + + while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode || + (pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode && + pCurPam->GetPoint()->nContent <= pCurPam->GetMark()->nContent ) ) + { + SwNode * pNd = + pDoc->GetNodes()[ pCurPam->GetPoint()->nNode ]; + SwCntntNode * pCtNd = pNd->GetCntntNode(); + + if( pCtNd ) // Normaler ContentNode + { + if( !bFirstLine ) + pCurPam->GetPoint()->nContent.Assign( pCtNd, 0 ); + Out( aW4WNodeFnTab, *pCtNd, *this ); + OutFlyFrm(); + } + else if( pNd->IsTableNode() ) // TableNode + OutW4W_SwTable( pNd->GetTableNode() ); + + ULONG nPos = pCurPam->GetPoint()->nNode++; // Bewegen + + ::binfilter::SetProgressState( nPos * 67L / nMaxNode, pDoc->GetDocShell() ); // Wie weit ? + + /* sollen nur die Selektierten 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 SwW4WWriter::MakeHeader() +{ + + Strm() << sW4W_RECBEGIN << "DID0" << sW4W_TERMEND; + OutW4WFontTab(); // baue die FontTbl + + // die globalen Daten nicht speichern, wenn nur teilweise ausgegeben wird + if( !bWriteAll ) + return; + + // gebe die Groesse und die Raender der Seite aus + if( pDoc->GetPageDescCnt() ) + { +// SwFrmFmt &rFmtPage = (SwFrmFmt&)pDoc->GetPageDesc(0).GetMaster(); + SwFrmFmt &rFmtPage = (SwFrmFmt&)*pPgFrm; + const SwFmtFrmSize& rSz = rFmtPage.GetFrmSize(); + const SvxLRSpaceItem& rLR = rFmtPage.GetLRSpace(); + const SvxULSpaceItem& rUL = rFmtPage.GetULSpace(); + + long nTxtLen = rSz.GetHeight() - rUL.GetUpper() - rUL.GetLower(); + Strm() << sW4W_RECBEGIN << "SFL0" << cW4W_TXTERM << '0' << cW4W_TXTERM; + + OutLong( rSz.GetHeight() / 240 ) << cW4W_TXTERM; + OutLong( nTxtLen / 240 ) << cW4W_TXTERM; + OutLong( rSz.GetHeight() ) << cW4W_TXTERM; + OutLong( nTxtLen ) << sW4W_TERMEND; + + Strm() << sW4W_RECBEGIN << "PGW"; + OutLong( rSz.GetWidth() / 144) << cW4W_TXTERM; + OutLong( rSz.GetWidth() ) << sW4W_TERMEND; + + nPgLeft = (USHORT)rLR.GetLeft(); + nPgRight = (USHORT)(rSz.GetWidth() - rLR.GetRight()); + + Strm() << sW4W_RECBEGIN << "RSM0" << cW4W_TXTERM << '0' << cW4W_TXTERM; + OutLong( rLR.GetLeft() / 144 ) << cW4W_TXTERM; + OutLong( rSz.GetWidth() - rLR.GetRight() / 144 ) << cW4W_TXTERM; + OutLong( nPgLeft ) << cW4W_TXTERM; + OutLong( nPgRight ) << sW4W_TERMEND; + + Strm() << sW4W_RECBEGIN << "STP0" << cW4W_TXTERM; + OutLong( rUL.GetUpper() / 240 ) << cW4W_TXTERM; + OutLong( rUL.GetUpper() ) << sW4W_TERMEND; + + Strm() << sW4W_RECBEGIN << "SBP"; + OutLong( rUL.GetLower() / 240 ) << cW4W_TXTERM; + OutLong( rUL.GetLower() )<< sW4W_TERMEND; + + Strm() << sW4W_RECBEGIN << "SLG"; + OutLong( nDefLanguage ) << sW4W_TERMEND; + } + + OutW4WStyleTab(); // Besser hier +} + +void SwW4WWriter::OutW4WFontTab() +{ + USHORT n = 0, nGet = 0; + const SfxItemPool& rPool = pDoc->GetAttrPool(); + + const SvxFontItem *pDfltFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( + RES_CHRATR_FONT ); + const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT ); + + // Zaehle die Anzahl + USHORT nMaxItem = rPool.GetItemCount( RES_CHRATR_FONT ); + for( nGet = 0; nGet < nMaxItem; ++nGet ) + if( rPool.GetItem( RES_CHRATR_FONT, nGet ) ) + n++; + + if( pDfltFont ) + ++n; + + // der default Font steht auf der Position 0 in der Tabelle !! + // (eigentlich reichen 2 Eintraege, aber nur mit 3 funktionierts) + Strm() << sW4W_RECBEGIN << "FDT"; + OutLong( n ) << cW4W_TXTERM << '3' << cW4W_TXTERM << "00" << cW4W_TXTERM; + + n = 0; + OutLong( n++ ) << cW4W_TXTERM; + OutW4W_String( *this, pFont->GetFamilyName() ).Strm() + << cW4W_TXTERM << "00" << cW4W_TXTERM; + if( pDfltFont ) + { + OutLong( n++ ) << cW4W_TXTERM; + OutW4W_String( *this, pFont->GetFamilyName() ).Strm() + << cW4W_TXTERM << "00" << cW4W_TXTERM; + } + + for( nGet = 0; nGet < nMaxItem; ++nGet ) + if( rPool.GetItem( RES_CHRATR_FONT, nGet ) ) + { + OutLong( n++ ) << cW4W_TXTERM; + OutW4W_String( *this, pFont->GetFamilyName() ).Strm() + << cW4W_TXTERM << "00" << cW4W_TXTERM; + } + Strm() << cW4W_RED; +} + + + +void SwW4WWriter::OutW4WStyleTab() +{ + const SvPtrarr & rArr = *pDoc->GetTxtFmtColls(); + // das 0-Style ist das Default, wird nie ausgegeben !! + if( rArr.Count() <= 1 ) + return; + + // das Default-TextStyle wird nicht mit ausgegeben !! + nFontId = 0; + for( USHORT n = 1; n < rArr.Count(); n++ ) + { + SwTxtFmtColl * pColl = (SwTxtFmtColl*)rArr[ n ]; + + Strm() << sW4W_RECBEGIN << "SYT"; + OutW4W_String( *this, pColl->GetName() ).Strm() << cW4W_TXTERM; + OutLong( n ) << cW4W_TXTERM; + + if ( !pColl->IsDefault() ) // Abgeleitet von ? + { + SwFmt* pC = pColl->DerivedFrom(); + void* pN = pC; + USHORT nSty = rArr.GetPos( pN ); // Index der Ableitung + if ( nSty>0 && nSty < USHRT_MAX ) // wirklich sinnvoller Index + { // und nicht "(keins)" ? + Strm() << sW4W_RECBEGIN << "SBO"; + OutW4W_String( *this, pC->GetName()).Strm() << cW4W_TXTERM; + OutLong( nSty ) << sW4W_TERMEND; + } + } + + BOOL bOldStyle = bStyleDef; bStyleDef = TRUE; + pStyleEndStrm = new SvMemoryStream; + OutW4W_SwFmt( *this, *pColl ); + + pStyleEndStrm->Seek( 0L ); + Strm() << sW4W_RECBEGIN << "SEP" << cW4W_RED << *pStyleEndStrm; + delete pStyleEndStrm; + pStyleEndStrm = 0; + + bStyleDef = bOldStyle; + + Strm() << cW4W_RED; + } +} + + + +// Bei Fonts werden ihre Inhalte verglichen + +const SvxFontItem& SwW4WWriter::GetFont( USHORT nId ) const +{ + if( !nId ) + return *(const SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT ); + + USHORT n = 1; + const SfxItemPool& rPool = pDoc->GetAttrPool(); + const SvxFontItem* pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( + RES_CHRATR_FONT ); + if( pFont && n++ == nId ) + return *pFont; + + 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 ) ) && n++ == nId ) + break; +// pFont = (const SvxFontItem*)rPool.GetItem( RES_CHRATR_FONT, nId - n ); + ASSERT( pFont, "falsche Font-Id" ); + return *pFont; +} + +USHORT SwW4WWriter::GetId( const SvxFontItem& rFont ) +{ + 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( !this, "Font nicht in der Tabelle" ); + return 0; +} + +USHORT SwW4WWriter::GetId( const SwTxtFmtColl& rColl ) +{ + // 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( !this, "TextCollection nicht in der Tabelle" ); + return 0; +} + +void SwW4WWriter::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 + USHORT n; + for( 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 !! + OutW4WFlyFrms( (const SwFlyFrmFmt&)(*pFlyPos)[n++]->GetFmt() ); + } +} + + + +void SwW4WWriter::OutW4WFlyFrms( 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(); + if( !rFlyCntnt.GetCntntIdx() ) + return; + + ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1; + ULONG nEnd = rFlyCntnt.GetCntntIdx()->GetNode().EndOfSectionIndex(); + + if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node + return; + + +#if OSL_DEBUG_LEVEL > 1 + Strm() << sW4W_RECBEGIN << "NOP_FlyFrame" << sW4W_TERMEND; +// Sound::Beep(); +#endif + + pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt; + + USHORT nAType = 1; + const SwFmtAnchor& rA = pFlyFmt->GetAnchor(); //!!! + switch ( rA.GetAnchorId() ) + { + case FLY_PAGE: nAType = 1; break; + case FLY_AT_CNTNT: nAType = 0; break; + case FLY_IN_CNTNT: nAType = 2; break; + default: ASSERT( !this, "+ Watn dette fuer'n FlyFrame"); + } + + USHORT nHAlign = 0; + const SwFmtHoriOrient& rH = pFlyFmt->GetHoriOrient(); + switch ( rH.GetHoriOrient() ) + { + case HORI_NONE: nHAlign = 0; break; + case HORI_RIGHT: nHAlign = 1; break; + case HORI_CENTER: nHAlign = 2; break; + case HORI_LEFT: nHAlign = 0; break; + // 3 = Full Just + } + SwTwips nXPos = rH.GetPos(); //!!! Relation & Anchor ?? + + USHORT nVAlign = 1; + const SwFmtVertOrient& rV = pFlyFmt->GetVertOrient(); + switch ( rV.GetVertOrient() ) + { + case VERT_NONE: nVAlign = 4; break; + case VERT_TOP: + case VERT_LINE_TOP: nVAlign = 1; break; + case VERT_CENTER: + case VERT_LINE_CENTER: nVAlign = 2; break; + case VERT_BOTTOM: + case VERT_LINE_BOTTOM: nVAlign = 3; break; + } + SwTwips nYPos = rV.GetPos(); + USHORT nAlignW = 2; // Default: absolute ( x und y ) + + USHORT nWrap = 0; + if( SURROUND_NONE != pFlyFmt->GetSurround().GetSurround() ) + ++nWrap; + + SwTwips nTpSpace = 0, nLeSpace = 0, nBoSpace = 0, nRiSpace = 0; + + const SwFmtFrmSize& rS = pFlyFmt->GetFrmSize(); + SwTwips nXSize = rS.GetWidth(); + SwTwips nYSize = rS.GetHeight(); + nFlyWidth = nXSize; // Fuer Anpassung Graphic-Groesse + nFlyHeight = nYSize; + nFlyLeft = nXPos; // Fuer Anpassung Raender + nFlyRight = nYPos; // ( Absolute Positionen ) + + // Ist der Fly relativ zu Seitenraendern ? + if ( nAType == 1 // RND_STD_PAGE ? + && rH.GetRelationOrient() != PRTAREA // x und y relativ zur + && rV.GetRelationOrient() != PRTAREA // Printarea ? + && nXPos >= (SwTwips)pPgFrm->GetLRSpace().GetLeft() // und keine daraus resul- + && nYPos >= (SwTwips)pPgFrm->GetULSpace().GetUpper())//tierenden negativen + { // Koordinaten ? + + nXPos -= pPgFrm->GetLRSpace().GetLeft(); // dann umrechnen auf rela- + nYPos -= pPgFrm->GetULSpace().GetUpper(); // tive Koordinaten + nAlignW = 0; // Wert auf "Align with Margin" setzen + } + + Strm() << sW4W_RECBEGIN << "APO00" << cW4W_TXTERM; + OutLong( nAType ) << cW4W_TXTERM; + OutLong( nVAlign ) << cW4W_TXTERM; + OutLong( nHAlign ) << cW4W_TXTERM; + OutLong( nAlignW ) << cW4W_TXTERM; + OutLong( nWrap ) << cW4W_TXTERM; + OutLong( nXSize ) << cW4W_TXTERM; + OutLong( nYSize ) << cW4W_TXTERM; + OutULong( nXPos ) << cW4W_TXTERM; + OutULong( nYPos ) << cW4W_TXTERM; + OutLong( nTpSpace ) << cW4W_TXTERM; + OutLong( nLeSpace ) << cW4W_TXTERM; + OutLong( nBoSpace ) << cW4W_TXTERM; + OutLong( nRiSpace ) << cW4W_TXTERM << "0000" << cW4W_TXTERM + << '0' << cW4W_TXTERM // shading / VPos from frame ??? + << sW4W_TERMEND; // FileName + + { + W4WSaveData aSaveData( *this, nStt, nEnd ); + BOOL bOldFly = bFly; + bFly = TRUE; + + Out_SwDoc( pCurPam, TRUE ); //!!! Keine ueberfluessigen Attrs !?! + + bFly = bOldFly; + + } // SaveData D'tor + + Strm() << sW4W_RECBEGIN << "APF" << cW4W_RED; + +#if OSL_DEBUG_LEVEL > 1 + Strm() << sW4W_RECBEGIN << "NOP_End_FlyFrame" << sW4W_TERMEND; +#endif + + nFlyWidth = nFlyHeight = 0; // APO zuende + nFlyLeft = nFlyRight = 0; // APO zuende + +} + +#ifdef NIE + + +void SwW4WWriter::OutW4WFlyFrms( 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* pFlyCntnt = (const SwFmtCntnt*) + rFlyFrmFmt.GetAttr( RES_CNTNT ); + if( !pFlyCntnt ) + return; + + ULONG nStt = pFlyCntnt->GetCntntIdx()->GetIndex()+1; + ULONG nEnd = pFlyCntnt->GetCntntIdx()->GetNode().EndOfSectionIndex(); + + if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node + return; + + SwPaM *pOldPam = pCurPam, *pOldEnd = pOrigPam; + BOOL bSaveWriteAll = bWriteAll; + SwFlyFrmFmt* pOldFlyFmt = pFlyFmt; + + pOrigPam = pCurPam = NewSwPaM( *pDoc, nStt, nEnd ); + pCurPam->Exchange(); + bWriteAll = TRUE; + + pFlyFmt = (SwFlyFrmFmt*)&rFlyFrmFmt; + Out_SwDoc( pCurPam, TRUE ); + + delete pCurPam; // Pam wieder loeschen + + pCurPam = pOldPam; + pOrigPam = pOldEnd; + bWriteAll = bSaveWriteAll; + pFlyFmt = pOldFlyFmt; +} +#endif //NIE + +// ermmittle die Distanz zum linken+rechten Rand +// D.H es werden die akt. Raender vom Frame-Format und von der Seite +// addiert. (das kommt dann so "ungefaehr" hin ). Der negative +// Erstzeileneinzug wird beim linken Rand beachtet. +// Wenn es innerhalb von FlyFrames 'rundgeht, werden keine absoluten +// Werte geliefert, sondern statt den Frame-Raendern die Seitenraender +// addiert / subtrahiert. Das ist aber gut so, da WW2 es genau so erwartet. + +void SwW4WWriter::GetMargins( SwTwips& rLeft, SwTwips& rWidth ) +{ + ASSERT( pNdFmt, "Attribut LRSpace vom Node nicht gesetzt!" ); + if( !pNdFmt ) + return; + + // gebe die Groesse und die Raender der Seite aus + ASSERT( pDoc->GetPageDescCnt(), "kein Seiten-Format definiert??" ); +// SwFrmFmt &rFmtPage = (SwFrmFmt&)pDoc->GetPageDesc(0).GetMaster(); + SwFrmFmt &rFmtPage = (SwFrmFmt&)*pPgFrm; + SwTwips nWidth = rFmtPage.GetFrmSize().GetWidth(); + const SvxLRSpaceItem& rPageLR = rFmtPage.GetLRSpace(); + const SvxLRSpaceItem& rNdLR = pNdFmt->GetLRSpace(); + + rLeft = rPageLR.GetLeft() + rNdLR.GetTxtLeft(); + rWidth = nWidth - rLeft - rPageLR.GetRight() - rNdLR.GetRight(); +} + + + // gebe die TextCollection am TextNode aus. Die Attribute + // werden im Style an- und abgeschaltet. Das Abschalten wird im + // extra Stream gespeichert !! +void SwW4WWriter::Out_SwTxtColl_OnOff( const SwTxtFmtColl& rTxtColl, + const SwAttrSet* pAutoSet, BOOL bOn ) +{ + if( !bOn ) + { + ASSERT( pStyleEndStrm, "Style Ende ohne StyleEndStream??" ); + pStyleEndStrm->Seek( 0L ); + *pStrm << *pStyleEndStrm; + delete pStyleEndStrm; + pStyleEndStrm = 0; + return; + } + + USHORT nId = GetId( rTxtColl ); + + // Anfang vom Style, sprich alle Attribute einschalten + // und den StyleEnd-Stream zuruecksetzen + if( pStyleEndStrm ) + delete pStyleEndStrm; + pStyleEndStrm = new SvMemoryStream; + + if( nId ) + { + BOOL bOldStyle = bStyleOnOff; bStyleOnOff = TRUE; + + // erstmal den StyleEnd-Stream vorbereiten: + { + SvStream* pOld = pStrm; + pStrm = pStyleEndStrm; // fuer den String diesen Stream + Strm() << sW4W_RECBEGIN << "STF"; // als akt Ausgabe + OutW4W_String( *this, rTxtColl.GetName() ).Strm() << cW4W_TXTERM; + OutULong( nId ) << sW4W_TERMEND; + pStrm = pOld; + } + Strm() << sW4W_RECBEGIN << "STY"; + OutW4W_String( *this, rTxtColl.GetName()).Strm() << cW4W_TXTERM; + OutULong( nId ) << sW4W_TERMEND; + + OutW4W_SwFmt( *this, rTxtColl ); + Strm() << sW4W_RECBEGIN << "STE" << cW4W_RED; + GetStrm(TRUE) << sW4W_RECBEGIN << "STE" << cW4W_RED; + bStyleOnOff = bOldStyle; + } + + // gilt am Node harte Attributierung ? + if( pAutoSet ) + Out_SfxItemSet( aW4WAttrFnTab, *this, *pAutoSet, FALSE ); // ausgeben +} + + + // nicht Inline, um Pointer zu pruefen +SvStream& SwW4WWriter::GetStrm( BOOL bStyleStream ) //$ ostream +{ + if( !bStyleStream ) + return *pStrm; + + ASSERT( pStyleEndStrm, "kein StyleStream vorhanden !!" ); + return *pStyleEndStrm; +} + +SvStream& SwW4WWriter::GetNlStrm() //$ ostream +{ + if ( !pPostNlStrm ) + pPostNlStrm = new SvMemoryStream; + return *pPostNlStrm; +} + + +// Struktur speichert die aktuellen Daten des Writers zwischen, um + + +// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer +W4WSaveData::W4WSaveData( SwW4WWriter& rWriter, ULONG nStt, ULONG nEnd ) + : rWrt( rWriter ), bOldWriteAll( rWrt.bWriteAll ), + pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ), + pOldFlyFmt( rWrt.pFlyFmt ), pOldPageDesc( rWrt.pPageDesc ), + pOldStyleEndStrm( rWrt.pStyleEndStrm ), pOldNdFmt( rWrt.pNdFmt ) +{ + rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd ); + rWrt.SetEndPaM( rWrt.pCurPam ); + rWrt.pCurPam->Exchange( ); + rWrt.bWriteAll = TRUE; + + rWrt.pStyleEndStrm = 0; +} + + +W4WSaveData::~W4WSaveData() +{ + delete rWrt.pCurPam; // Pam wieder loeschen + + rWrt.pCurPam = pOldPam; + rWrt.SetEndPaM( pOldEnd ); + rWrt.bWriteAll = bOldWriteAll; + rWrt.pFlyFmt = pOldFlyFmt; + rWrt.pPageDesc = pOldPageDesc; + + rWrt.pStyleEndStrm = pOldStyleEndStrm; + rWrt.pNdFmt = pOldNdFmt; +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/w4wgraf.hxx b/binfilter/bf_sw/source/filter/w4w/w4wgraf.hxx new file mode 100644 index 000000000000..cb38029f62a3 --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/w4wgraf.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <tools/gen.hxx> +class Graphic; +class SvStream; +class Bitmap; +class OutputDevice; +namespace binfilter { + + +class RGBQuad; +class BmpFileHd; +class BmpInfoHd; +struct WmfFileHd; +class BmpFileHd; + + +class SwW4WGraf +{ + Point aVectPos; // W4W-Vector: aktuelle Position MoveTo/LineTo + SvStream& rInp; // aus diesem Stream lesen + Graphic* pGraph; + Bitmap* pBmp; + RGBQuad* pPal; + BmpFileHd* pBmpHead; + BmpInfoHd* pBmpInfo; + USHORT nPalColors; + USHORT nVectMinX; + USHORT nVectMaxX; + USHORT nVectMinY; + USHORT nVectMaxY; +// Size aVectSiz; // Maximale Ausdehnung der W4W-Vectorgrafik (wird von ReadHexPoint() gesezt) + + short nStat; // 1 = File-Grafik, 2 = Mem-Grafik + BYTE nError; + + void ReadHexPoint(Point& aPnt); + int GetNextRecord(); + int GetNextVectRec(OutputDevice& rOut); + short GetHexByte(); + USHORT GetHexUShort(); + ULONG GetHexULong(); + long GetVarSize(); + short ReadPalette( long nVarSize ); + short DefaultPalette( USHORT nColors ); + short ReadBitmap( long nVarSize ); + void SkipBytes( register long nBytes ); + + ULONG ReadWmfHeader( WmfFileHd& rHd ); + short ReadW4WGrafBMap( long nTyp, long nWidth, long nHeight ); + short ReadW4WGrafVect( long nTyp, long nWidth, long nHeight ); + short ReadGrafFile( long nTyp, long nWidth, long nHeight ); + + BOOL CheckW4WVector(); // enth„lt die W4W-Grafik Vektordaten ? (Joe) + + sal_Char ReadChar() { sal_Char c = 0; rInp.Read( &c, 1 ); return c; } + +public: + SwW4WGraf( SvStream& rIstream ); + ~SwW4WGraf(); + short Read( long nGrafPDSType, long nGrWidthTw, long nGrHeightTw ); + Graphic* GetGraphic() const { return pGraph; }; +}; + +} //namespace binfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/w4w/wrtw4w.hxx b/binfilter/bf_sw/source/filter/w4w/wrtw4w.hxx new file mode 100644 index 000000000000..b211b988b16f --- /dev/null +++ b/binfilter/bf_sw/source/filter/w4w/wrtw4w.hxx @@ -0,0 +1,249 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _WRTW4W_HXX +#define _WRTW4W_HXX + +#include <swtypes.hxx> +#include <shellio.hxx> +#include <wrt_fn.hxx> +#include <horiornt.hxx> +class SvMemoryStream; +namespace binfilter { + +// einige Forward Deklarationen + +class SvxBoxItem; +class SvxFontItem; +class SwAttrSet; +class SwDoc; +class SwFlyFrmFmt; +class SwFmt; +class SwFrmFmt; +class SwGrfNode; +class SwPageDesc; +class SwPageIter; +class SwPosFlyFrms; +class SwTable; +class SwTableLine; +class SwTableNode; +class SwTxtFmtColl; +struct SwPosition; + +extern SwAttrFnTab aW4WAttrFnTab; +extern SwNodeFnTab aW4WNodeFnTab; + +#define cW4W_BEGICF '\x1b' +#define cW4W_LED '\x1d' +#define cW4W_TXTERM '\x1f' +#define cW4W_RED '\x1e' + +#ifdef JP_STR_OPTIMIERUNG + JP 23.09.94: leider kann der MAC-Compiler keine String-Concatinierung + +#define sW4W_BEGICF "\x1b" +#define sW4W_LED "\x1d" +#define sW4W_TXTERM "\x1f" +#define sW4W_RED "\x1e" + +// lasse den Compiler die Strings zusammenbauen! +#define CNCT_STR2(a,b) ( a b ) +#define CNCT_STR3(a,b,c) ( a b c ) +#define CNCT_STR4(a,b,c,d) ( a b c d ) +#define CNCT_STR5(a,b,c,d,e) ( a b c d e ) +#define CNCT_STR6(a,b,c,d,e,f) ( a b c d e f ) +#define CNCT_STR7(a,b,c,d,e,f,g) ( a b c d e f g ) +#define CNCT_STR12(a,b,c,d,e,f,g,h,i,j,k,l) ( a b c d e f g h i j k l ) + +#define CNCT_STR1_RECSTT(a) ( sW4W_BEGICF sW4W_LED a ) +#define CNCT_STR2_RECSTT(a,b) ( sW4W_BEGICF sW4W_LED a b ) +#define CNCT_STR3_RECSTT(a,b,c) ( sW4W_BEGICF sW4W_LED a b c ) +#define CNCT_STR4_RECSTT(a,b,c,d) ( sW4W_BEGICF sW4W_LED a b c d ) + +#endif + +extern const sal_Char __FAR_DATA sW4W_RECBEGIN[3]; // W4W_BEGICF W4W_LED +extern const sal_Char __FAR_DATA sW4W_TERMEND[3]; // W4W_TXTREM W4W_RED + +// der W4W-Writer + +class SwW4WWriter : public Writer +{ + String sVersion; // fuer die Verschiedenen Formate + SwPosFlyFrms* pFlyPos; // Pointer auf die aktuelle "FlyFrmTabelle" + + ULONG nIniFlags; // Flags aus der writer.ini + // obere 16 Bits fuer den W4W-Writer + // Bedeutung siehe Datei filter\inc\w4wpar.hxx + ULONG nMaxNode; // Fuer Prozent-Balken + + USHORT nFilter; + USHORT nAktFlyPos; // Index auf das naechste "FlyFrmFmt" + USHORT nPgLeft; + USHORT nPgRight; + + BOOL bStorageFlag; + + + void OutW4WFontTab(); + void OutW4WStyleTab(); + + void MakeHeader(); + + // gebe die evt. an der akt. Position stehenden FlyFrame aus. + void OutFlyFrm(); + void OutW4WFlyFrms( const SwFlyFrmFmt& ); + + ULONG WriteStream(); + +public: + + SwFlyFrmFmt* pFlyFmt; // liegt der Node in einem FlyFrame, ist + // das Format gesetzt, sonst 0 + SvMemoryStream* pStyleEndStrm; // fuer StyleOn/Off + SvMemoryStream* pPostNlStrm; // fuer Attribute, die nach dem naechsten + // HNL abgeschaltet werden muessen + const SwPageDesc* pPageDesc; // aktuelles Seitenlayout + SwPosition* pNxtPg; // AnfangsPosition der naechsten Seite + const SwPageDesc* pPgDsc2; // aktuelles Seitenlayout, + // doppelt gemoppelt !? + SwPageIter* pIter; // Iterator fuer seitenweise Spruenge + const SwFrmFmt* pPgFrm; // akt. PageFrame, i.A. pPgDsc2->GetMaster() + const SwFmt* pNdFmt; // akt. Format/Collection vom Node + // fuer den Zugriff auf einige Attribute + // z.B. Font-Size, LR-Space,.. + + SwTwips nFlyWidth, nFlyHeight; // Fuer Anpassung Graphic + SwTwips nFlyLeft, nFlyRight; // fuer Anpassung Raender + + rtl_TextEncoding eTargCharSet; // Target-CharSet + + USHORT nFontHeight; // akt. Hoehe vom Font + USHORT nFontId; // Id vom akt. Font + USHORT nDefLanguage; // Default-Language zum Ausschalten d. Attr + + BOOL bFirstLine : 1; // wird die 1. Zeile ausgegeben ? + BOOL bStyleDef : 1; // ist gerade eine Style-Def am werden ? + BOOL bStyleOnOff : 1; // wird gerade ein Style An/Ausgeschaltet ? + BOOL bTable : 1; // ist gerade eine Tabelle am werden ? + BOOL bPageDesc : 1; // wird gerade ein PageDesc ausgegeben ? + BOOL bEvenPage : 1; // ist gerade Seitenzahl ? + BOOL bLastPg :1; // Letzte Seite ? + BOOL bHdFt : 1; // wird gerade Header oder Footer ausgegeben ? + BOOL bIsTxtInPgDesc : 1; // gegen ueberfluessige HNLs + BOOL bFly : 1; // ist gerade ein FlyFrame am werden ? + BOOL bTxtAttr : 1; // werden TextAttribute ausgegeben ? + BOOL bAttrOnOff: 1; // TRUE: Attribut StartCode; sonst + // den EndCode ausgeben + + SwW4WWriter( const String& rFilterName ); + virtual ~SwW4WWriter(); + + void Out_SwDoc( SwPaM*, BOOL bAttrOn ); + + void OutW4W_CountTableSize( const SwTable*, USHORT&, USHORT&, USHORT& ); + BYTE OutW4W_GetTableColPos( const SwTableLine*, SwHoriOrient, SwTwips* ); + void OutW4W_WriteTableHeader( BYTE nCode, USHORT nCols, SwTwips* pCellPos ); + BOOL OutW4W_GetBorder( const SvxBoxItem* pBox, USHORT& rBorder ); + void OutW4W_WriteTableLineHeader( USHORT nCols, USHORT , USHORT* = 0); + void OutW4W_WriteTableBoxHeader( USHORT nNumCol, USHORT nSpan ); + BOOL OutW4W_TestTableLineWW2( const SwTable*, USHORT, USHORT, SwTwips* ); + void OutW4W_TableLineWW2( const SwTable*, USHORT, USHORT, USHORT, SwTwips* ); + void OutW4W_SwTableWW2( const SwTable*, USHORT, USHORT, USHORT, + SwHoriOrient, SwTwips* ); + void OutW4W_TableLineNorm( const SwTable*, USHORT, USHORT, USHORT, SwTwips* ); + void OutW4W_SwTableNorm( const SwTable*, USHORT, USHORT, USHORT, + SwHoriOrient, SwTwips* ); + + void OutW4W_SwTable( const SwTableNode* pTableNd ); + + USHORT GetId( const SwTxtFmtColl& ); + USHORT GetId( const SvxFontItem& ); + const SvxFontItem& GetFont( USHORT nId ) const; + + void GetMargins( SwTwips& rLeft, SwTwips& rWidth ); // ermittle Raender + + USHORT GetFilter() const { return nFilter; } + const String& GetVersion() const { return sVersion; } + void ChgVersion( const String& rVers ) { sVersion = rVers; } + void ChgFilter( USHORT nFltr ) { nFilter = nFltr; } + ULONG GetIniFlags() const { return nIniFlags; } + + // gebe die TextCollection am TextNode aus. Die Attribute + // werden im Style an- und abgeschaltet. Das Abschalten wird im + // extra Stream gespeichert !! + void Out_SwTxtColl_OnOff( const SwTxtFmtColl& rTxtColl, + const SwAttrSet* pAutoSet, BOOL bOn ); + + // nicht inline, um Pointer zu pruefen + // bStyleStream = FALSE returnt den normalen Ausgabe-Stream (wird + // fuer die TextAttribute benoetigt!) + SvStream& GetStrm( BOOL bStyleStream = TRUE ); //$ ostream + + SvStream& GetNlStrm(); //$ ostream + + // fuer W4WSaveData + SwPaM* GetEndPaM() { return pOrigPam; } + void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; } + + // fuer Grafiken + void OutW4W_Grf( const SwGrfNode* pGrfNd ); + + // fuer Storage / Stream + virtual BOOL IsStgWriter(); +}; + +struct W4WSaveData +{ + SwW4WWriter& rWrt; + SwPaM* pOldPam, *pOldEnd; + SwFlyFrmFmt* pOldFlyFmt; + const SwPageDesc* pOldPageDesc; + SvMemoryStream* pOldStyleEndStrm; // fuer StyleOn/Off + const SwFmt* pOldNdFmt; // akt. Attribute vom Node + BOOL bOldWriteAll; + + W4WSaveData( SwW4WWriter&, ULONG nStt, ULONG nEnd ); + ~W4WSaveData(); +}; + +// einige Funktions-Deklarationen +Writer& OutW4W_SwChar( Writer& rWrt, sal_Unicode c, BOOL bRaw ); +Writer& OutW4W_String( Writer& rWrt, const String& rStr ); +Writer& OutW4W_SwFmt( Writer& rWrt, const SwFmt& rFmt ); + +SvStream& W4WOutHex( SvStream& rStrm, USHORT nHex ); +SvStream& W4WOutHex4( SvStream& rStrm, USHORT nHex ); +SvStream& W4WOutLong( SvStream& rStrm, long nVal ); +SvStream& W4WOutULong( SvStream& rStrm, ULONG nVal ); +void OutW4W_SwFmtPageDesc1( SwW4WWriter& rW4WWrt, const SwPageDesc* pPg ); + + +} //namespace binfilter +#endif // _WRTW4W_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/writer/makefile.mk b/binfilter/bf_sw/source/filter/writer/makefile.mk new file mode 100644 index 000000000000..a0062ce7cbd2 --- /dev/null +++ b/binfilter/bf_sw/source/filter/writer/makefile.mk @@ -0,0 +1,63 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_writer + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw +# --- Files -------------------------------------------------------- + +CXXFILES = \ + sw_writer.cxx \ + sw_wrt_fn.cxx \ + sw_wrtswtbl.cxx + +SLOFILES = \ + $(SLO)$/sw_writer.obj \ + $(SLO)$/sw_wrt_fn.obj \ + $(SLO)$/sw_wrtswtbl.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/writer/sw_writer.cxx b/binfilter/bf_sw/source/filter/writer/sw_writer.cxx new file mode 100644 index 000000000000..59c8e6f20ee7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/writer/sw_writer.cxx @@ -0,0 +1,412 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#define _SVSTDARR_STRINGSSORTDTOR + + #ifndef _STREAM_HXX //autogen + #include <tools/stream.hxx> + #endif +#include <bf_svx/fontitem.hxx> +#include <bf_svx/eeitem.hxx> + +#include <shellio.hxx> + +#include <horiornt.hxx> +#include <errhdl.hxx> + +#include <pam.hxx> +#include <doc.hxx> +#include <docary.hxx> +#include <bookmrk.hxx> // fuer SwBookmark ... +#include <numrule.hxx> + +#include <swerror.h> +namespace binfilter { + +// Stringbuffer fuer die umgewandelten Zahlen +static sal_Char aNToABuf[] = "0000000000000000000000000"; +#define NTOABUFLEN (sizeof(aNToABuf)) + +/*N*/ DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* ) + +/*N*/ struct Writer_Impl +/*N*/ { +/*N*/ SvStringsSortDtor *pSrcArr, *pDestArr; +/*N*/ SvPtrarr* pFontRemoveLst, *pBkmkArr; +/*N*/ SwBookmarkNodeTable* pBkmkNodePos; +/*N*/ +/*N*/ Writer_Impl( const SwDoc& rDoc ); +/*N*/ ~Writer_Impl(); +/*N*/ +/*N*/ void RemoveFontList( SwDoc& rDoc ); +/*N*/ }; + +/*N*/ Writer_Impl::Writer_Impl( const SwDoc& rDoc ) +/*N*/ : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) +/*N*/ { +/*N*/ } + +/*N*/ Writer_Impl::~Writer_Impl() +/*N*/ { +/*N*/ delete pSrcArr; +/*N*/ delete pDestArr; +/*N*/ delete pFontRemoveLst; +/*N*/ +/*N*/ if( pBkmkNodePos ) +/*N*/ { +/*?*/ for( SvPtrarr* p = pBkmkNodePos->First(); p; p = pBkmkNodePos->Next() ) +/*?*/ delete p; +/*?*/ delete pBkmkNodePos; +/*N*/ } +/*N*/ } + +/*N*/ void Writer_Impl::RemoveFontList( SwDoc& rDoc ) +/*N*/ { +/*N*/ ASSERT( pFontRemoveLst, "wo ist die FontListe?" ); +/*N*/ for( USHORT i = pFontRemoveLst->Count(); i; ) +/*N*/ { +/*N*/ SvxFontItem* pItem = (SvxFontItem*)(*pFontRemoveLst)[ --i ]; +/*N*/ rDoc.GetAttrPool().Remove( *pItem ); +/*N*/ } +/*N*/ } + + +/* + * 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. + */ + +/*N*/ Writer::Writer() +/*N*/ : pImpl( 0 ), pStrm( 0 ), pOrigPam( 0 ), pOrigFileName( 0 ), +/*N*/ pCurPam(0), pDoc( 0 ) +/*N*/ { +/*N*/ bWriteAll = bShowProgress = bUCS2_WithStartChar = TRUE; +/*N*/ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = +/*N*/ bWriteClipboardDoc = bWriteOnlyFirstTable = bBlock = +/*N*/ bOrganizerMode = FALSE; +/*N*/ } + +/*N*/ Writer::~Writer() +/*N*/ { +/*N*/ } + +/*N*/ void Writer::ResetWriter() +/*N*/ { +/*N*/ if( pImpl && pImpl->pFontRemoveLst ) +/*N*/ pImpl->RemoveFontList( *pDoc ); +/*N*/ delete pImpl, pImpl = 0; +/*N*/ +/*N*/ if( pCurPam ) +/*N*/ { +/*N*/ while( pCurPam->GetNext() != pCurPam ) +/*?*/ delete pCurPam->GetNext(); +/*N*/ delete pCurPam; +/*N*/ } +/*N*/ pCurPam = 0; +/*N*/ pOrigFileName = 0; +/*N*/ pDoc = 0; +/*N*/ pStrm = 0; +/*N*/ +/*N*/ bShowProgress = bUCS2_WithStartChar = TRUE; +/*N*/ bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = +/*N*/ bWriteClipboardDoc = bWriteOnlyFirstTable = bBlock = +/*N*/ bOrganizerMode = FALSE; +/*N*/ } + +/*N*/ BOOL Writer::CopyNextPam( SwPaM ** ppPam ) +/*N*/ { +/*N*/ if( (*ppPam)->GetNext() == pOrigPam ) +/*N*/ { +/*N*/ *ppPam = pOrigPam; // wieder auf den Anfangs-Pam setzen +/*N*/ return FALSE; // Ende vom Ring +/*N*/ } +/*N*/ +/*N*/ // ansonsten kopiere den die Werte aus dem naechsten Pam +/*?*/ *ppPam = ((SwPaM*)(*ppPam)->GetNext() ); +/*?*/ +/*?*/ *pCurPam->GetPoint() = *(*ppPam)->Start(); +/*?*/ *pCurPam->GetMark() = *(*ppPam)->End(); +/*?*/ +/*?*/ return TRUE; +/*N*/ } + +// suche die naechste Bookmark-Position aus der Bookmark-Tabelle + + SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx ) const + { + SwNodes* pNds = &rDoc.GetNodes(); + + 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 +/*N*/ #ifdef DBG_UTIL +/*N*/ SvStream& Writer::Strm() +/*N*/ { +/*N*/ ASSERT( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" ); +/*N*/ return *pStrm; +/*N*/ } +/*N*/ #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; +} + + +/*N*/ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) +/*N*/ { +/*N*/ pStrm = &rStrm; +/*N*/ pDoc = rPaM.GetDoc(); +/*N*/ pOrigFileName = pFName; +/*N*/ pImpl = new Writer_Impl( *pDoc ); +/*N*/ +/*N*/ // PaM kopieren, damit er veraendert werden kann +/*N*/ pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); +/*N*/ // zum Vergleich auf den akt. Pam sichern +/*N*/ pOrigPam = &rPaM; +/*N*/ +/*N*/ ULONG nRet = WriteStream(); +/*N*/ +/*N*/ ResetWriter(); +/*N*/ +/*N*/ return nRet; +/*N*/ } + + +/*N*/ ULONG Writer::Write( SwPaM& rPam, SvStorage&, const String* ) +/*N*/ { +/*N*/ ASSERT( !this, "Schreiben in Storages auf einem Stream?" ); +/*N*/ return ERR_SWG_WRITE_ERROR; +/*N*/ } + + + +/*N*/ void Writer::PutNumFmtFontsInAttrPool() +/*N*/ { +/*N*/ if( !pImpl ) +/*?*/ pImpl = new Writer_Impl( *pDoc ); +/*N*/ +/*N*/ // dann gibt es noch in den NumRules ein paar Fonts +/*N*/ // Diese in den Pool putten. Haben sie danach einen RefCount > 1 +/*N*/ // kann es wieder entfernt werden - ist schon im Pool +/*N*/ SfxItemPool& rPool = pDoc->GetAttrPool(); +/*N*/ const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl(); +/*N*/ const SwNumRule* pRule; +/*N*/ const SwNumFmt* pFmt; +/*N*/ const Font *pFont, *pDefFont = &SwNumRule::GetDefBulletFont(); +/*N*/ BOOL bCheck = FALSE; +/*N*/ +/*N*/ for( USHORT nGet = rListTbl.Count(); nGet; ) +/*N*/ if( pDoc->IsUsed( *(pRule = rListTbl[ --nGet ] ))) +/*?*/ for( BYTE nLvl = 0; nLvl < MAXLEVEL; ++nLvl ) +/*?*/ if( SVX_NUM_CHAR_SPECIAL == (pFmt = &pRule->Get( nLvl ))->GetNumberingType() || +/*?*/ SVX_NUM_BITMAP == pFmt->GetNumberingType() ) +/*?*/ { +/*?*/ 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() )); +/*N*/ } +/*N*/ } + +/*N*/ void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL ) +/*N*/ { +/*N*/ if( !pImpl ) +/*?*/ pImpl = new Writer_Impl( *pDoc ); +/*N*/ +/*N*/ SfxItemPool& rPool = pDoc->GetAttrPool(); +/*N*/ if( rPool.GetSecondaryPool() ) +/*N*/ { +/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO ); +/*N*/ if( bIncl_CJK_CTL ) +/*N*/ { +/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO_CJK ); +/*N*/ _AddFontItems( rPool, EE_CHAR_FONTINFO_CTL ); +/*N*/ } +/*N*/ } +/*N*/ } + + + +/*N*/ void Writer::_AddFontItems( SfxItemPool& rPool, USHORT nW ) +/*N*/ { +/*N*/ const SvxFontItem* pFont = (const SvxFontItem*)&rPool.GetDefaultItem( nW ); +/*N*/ _AddFontItem( rPool, *pFont ); +/*N*/ +/*N*/ if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( nW )) ) +/*N*/ _AddFontItem( rPool, *pFont ); +/*N*/ +/*N*/ USHORT nMaxItem = rPool.GetItemCount( nW ); +/*N*/ for( USHORT nGet = 0; nGet < nMaxItem; ++nGet ) +/*N*/ if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem( nW, nGet )) ) +/*N*/ _AddFontItem( rPool, *pFont ); +/*N*/ } + +/*N*/ void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ) +/*N*/ { +/*N*/ const SvxFontItem* pItem; +/*N*/ if( RES_CHRATR_FONT != rFont.Which() ) +/*N*/ { +/*N*/ SvxFontItem aFont( rFont ); +/*N*/ aFont.SetWhich( RES_CHRATR_FONT ); +/*N*/ pItem = (SvxFontItem*)&rPool.Put( aFont ); +/*N*/ } +/*N*/ else +/*?*/ pItem = (SvxFontItem*)&rPool.Put( rFont ); +/*N*/ +/*N*/ if( 1 < pItem->GetRefCount() ) +/*N*/ rPool.Remove( *pItem ); +/*N*/ else +/*N*/ { +/*N*/ if( !pImpl->pFontRemoveLst ) +/*N*/ pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 ); +/*N*/ +/*N*/ void* p = (void*)pItem; +/*N*/ pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() ); +/*N*/ } +/*N*/ } + +// build a bookmark table, which is sort by the node position. The +// OtherPos of the bookmarks also inserted. + + +// search alle Bookmarks in the range and return it in the Array + +//////////////////////////////////////////////////////////////////////////// + +// Storage-spezifisches + + +/*N*/ ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) +/*N*/ { +/*N*/ pStrm = 0; +/*N*/ pStg = &rStg; +/*N*/ pDoc = rPaM.GetDoc(); +/*N*/ pOrigFileName = pFName; +/*N*/ pImpl = new Writer_Impl( *pDoc ); +/*N*/ +/*N*/ // PaM kopieren, damit er veraendert werden kann +/*N*/ pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); +/*N*/ // zum Vergleich auf den akt. Pam sichern +/*N*/ pOrigPam = &rPaM; +/*N*/ +/*N*/ ULONG nRet = WriteStorage(); +/*N*/ +/*N*/ pStg = NULL; +/*N*/ ResetWriter(); +/*N*/ +/*N*/ return nRet; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx b/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx new file mode 100644 index 000000000000..101bbe55ac64 --- /dev/null +++ b/binfilter/bf_sw/source/filter/writer/sw_wrt_fn.cxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_svtools/itemiter.hxx> +#include <bf_svtools/whiter.hxx> + + +#include "shellio.hxx" +#include "wrt_fn.hxx" + +#include <errhdl.hxx> + +#include "node.hxx" +namespace binfilter { + + + +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; +} + +/*N*/ Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt ) +/*N*/ { +/*N*/ // es muss ein CntntNode sein !! +/*N*/ SwCntntNode * pCNd = rNode.GetCntntNode(); +/*N*/ if( !pCNd ) +/*?*/ return rWrt; +/*N*/ +/*N*/ USHORT nId = RES_TXTNODE; +/*N*/ switch( pCNd->GetNodeType() ) +/*N*/ { +/*N*/ 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?" ); +/*N*/ } +/*N*/ FnNodeOut pOut; +/*N*/ if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] )) +/*N*/ (*pOut)( rWrt, *pCNd ); +/*N*/ return rWrt; +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/writer/sw_wrtswtbl.cxx b/binfilter/bf_sw/source/filter/writer/sw_wrtswtbl.cxx new file mode 100644 index 000000000000..c8c1b86cb286 --- /dev/null +++ b/binfilter/bf_sw/source/filter/writer/sw_wrtswtbl.cxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + + +#include <wrtswtbl.hxx> +#include <errhdl.hxx> +#include <swtable.hxx> +#include <frmfmt.hxx> +#include <fmtfsize.hxx> + +#include <errhdl.hxx> + +namespace binfilter { + + + +//----------------------------------------------------------------------- + + +//----------------------------------------------------------------------- + + + + +//----------------------------------------------------------------------- + +/*N*/ SwWriteTableCol::SwWriteTableCol( USHORT nPosition ) +/*N*/ : nPos(nPosition), +/*N*/ bLeftBorder(TRUE), bRightBorder(TRUE), +/*N*/ nWidthOpt( 0 ), bRelWidthOpt( FALSE ), +/*N*/ bOutWidth( TRUE ) +/*N*/ { +/*N*/ } + +//----------------------------------------------------------------------- + +/*N*/ long SwWriteTable::GetBoxWidth( const SwTableBox *pBox ) +/*N*/ { +/*N*/ const SwFrmFmt *pFmt = pBox->GetFrmFmt(); +/*N*/ const SwFmtFrmSize& aFrmSize= +/*N*/ (const SwFmtFrmSize&)pFmt->GetAttr( RES_FRM_SIZE ); +/*N*/ +/*N*/ return aFrmSize.GetSize().Width(); +/*N*/ } + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/ForbiddenCharactersEnum.hxx b/binfilter/bf_sw/source/filter/xml/ForbiddenCharactersEnum.hxx new file mode 100644 index 000000000000..a5b49e547019 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/ForbiddenCharactersEnum.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _FORBIDDEN_CHARACTERS_ENUM_HXX +#define _FORBIDDEN_CHARACTERS_ENUM_HXX +namespace binfilter { + +enum ForbiddenCharactersEnum +{ + SW_FORBIDDEN_CHARACTER_LANGUAGE, + SW_FORBIDDEN_CHARACTER_COUNTRY, + SW_FORBIDDEN_CHARACTER_VARIANT, + SW_FORBIDDEN_CHARACTER_BEGIN_LINE, + SW_FORBIDDEN_CHARACTER_END_LINE, + SW_FORBIDDEN_CHARACTER_MAX +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/XMLRedlineImportHelper.hxx b/binfilter/bf_sw/source/filter/xml/XMLRedlineImportHelper.hxx new file mode 100644 index 000000000000..54ff63162d3b --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/XMLRedlineImportHelper.hxx @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLREDLINEIMPORTHELPER_HXX +#define _XMLREDLINEIMPORTHELPER_HXX + +#include <rtl/ustring.hxx> + +#include <com/sun/star/uno/Reference.h> + +#include <com/sun/star/uno/Sequence.h> + +#include <com/sun/star/util/DateTime.hpp> + +#include "redline.hxx" + +#include "redlenum.hxx" + +#include <map> +namespace com { namespace sun { namespace star { + namespace text { class XTextCursor; } + namespace text { class XTextRange; } + namespace frame { class XModel; } +} } } +namespace binfilter { + +class RedlineInfo; +class SwRedlineData; +class SwDoc; +//STRIP008 namespace com { namespace sun { namespace star { +//STRIP008 namespace text { class XTextCursor; } +//STRIP008 namespace text { class XTextRange; } +//STRIP008 namespace frame { class XModel; } +//STRIP008 } } } + + +typedef ::std::map< ::rtl::OUString, RedlineInfo* > RedlineMapType; + +class XMLRedlineImportHelper +{ + const ::rtl::OUString sEmpty; + const ::rtl::OUString sInsertion; + const ::rtl::OUString sDeletion; + const ::rtl::OUString sFormatChange; + const ::rtl::OUString sShowChanges; + const ::rtl::OUString sRecordChanges; + const ::rtl::OUString sRedlineProtectionKey; + + RedlineMapType aRedlineMap; + + /// if sal_True, no redlines should be inserted into document + /// (This typically happen when a document is loaded in 'insert'-mode.) + sal_Bool bIgnoreRedlines; + + /// save information for saving and reconstruction of the redline mode + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> xModelPropertySet; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> xImportInfoPropertySet; + sal_Bool bShowChanges; + sal_Bool bRecordChanges; + ::com::sun::star::uno::Sequence<sal_Int8> aProtectionKey; + +public: + + XMLRedlineImportHelper( + sal_Bool bIgnoreRedlines, /// ignore redlines mode + + // property sets of model + import info for saving + restoring the + // redline mode + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rImportInfoSet ); + virtual ~XMLRedlineImportHelper(); + + /// create a redline object + /// (The redline will be inserted into the document after both start + /// and end cursor has been set.) + void Add( + const ::rtl::OUString& rType, /// redline type (insert, del,... ) + const ::rtl::OUString& rId, /// use to identify this redline + const ::rtl::OUString& rAuthor, /// name of the author + const ::rtl::OUString& rComment, /// redline comment + const ::com::sun::star::util::DateTime& rDateTime, /// date+time + sal_Bool bMergeLastParagraph); /// merge last paragraph? + + /// create a text section for the redline, and return an + /// XText/XTextCursor that may be used to write into it. + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor> CreateRedlineTextSection( + ::com::sun::star::uno::Reference< /// needed to get the document + ::com::sun::star::text::XTextCursor> xOldCursor, + const ::rtl::OUString& rId); /// ID used to RedlineAdd() call + + /// Set start or end position for a redline in the text body. + /// Accepts XTextRange objects. + void SetCursor( + const ::rtl::OUString& rId, /// ID used in RedlineAdd() call + sal_Bool bStart, /// start or end Range + ::com::sun::star::uno::Reference< /// the actual XTextRange + ::com::sun::star::text::XTextRange> & rRange, + /// text range is (from an XML view) outside of a paragraph + /// (i.e. before a table) + sal_Bool bIsOusideOfParagraph); + + /** + * Adjust the start (end) position for a redline that begins in a + * start node. It takes the cursor positions _inside_ the redlined + * element (e.g. section or table). + * + * We will do sanity checking of the given text range: It will + * only be considered valid if it points to the next text node + * after the position given in a previous SetCursor */ + void AdjustStartNodeCursor( + const ::rtl::OUString& rId, /// ID used in RedlineAdd() call + sal_Bool bStart, + /// XTextRange _inside_ a table/section + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange> & rRange); + + /// set redline mode: show changes + void SetShowChanges( sal_Bool bShowChanges ); + + /// set redline mode: record changes + void SetRecordChanges( sal_Bool bRecordChanges ); + + /// set redline protection key + void SetProtectionKey( + const ::com::sun::star::uno::Sequence<sal_Int8> & rKey ); + +private: + + inline sal_Bool IsReady(RedlineInfo* pRedline); + + void InsertIntoDocument(RedlineInfo* pRedline); + + SwRedlineData* ConvertRedline( + RedlineInfo* pRedline, /// RedlineInfo to be converted + SwDoc* pDoc); /// document needed for Author-ID conversion + + /** save the redline mode (if rPropertySet is non-null) */ + void SaveRedlineMode( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropertySet); + + /** don't restore the saved redline mode */ + void DontRestoreRedlineMode(); + +}; + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/makefile.mk b/binfilter/bf_sw/source/filter/xml/makefile.mk new file mode 100644 index 000000000000..413481d37f23 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/makefile.mk @@ -0,0 +1,128 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/..$/.. +BFPRJ=..$/..$/.. + +PRJNAME=binfilter +TARGET=sw_xml + +#GEN_HID=TRUE +#GEN_HID_OTHER=TRUE +NO_HIDS=TRUE + +# --- Settings ----------------------------------------------------- + +#.INCLUDE : $(PRJ)$/inc$/swpre.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/swpre.mk +.INCLUDE : settings.mk +#.INCLUDE : $(PRJ)$/inc$/sw.mk +.INCLUDE : $(PRJ)$/inc$/bf_sw$/sw.mk +INC+= -I$(PRJ)$/inc$/bf_sw +.IF "$(mydebug)" != "" +CDEFS=$(CDEFS) -Dmydebug +.ENDIF + +# --- Files -------------------------------------------------------- + +CXXFILES = \ + sw_swxml.cxx \ + sw_xmlimp.cxx \ + sw_wrtxml.cxx \ + sw_xmlexp.cxx \ + sw_xmltext.cxx \ + sw_xmltexte.cxx \ + sw_xmltexti.cxx \ + sw_xmltbli.cxx \ + sw_xmltble.cxx \ + sw_xmlfmt.cxx \ + sw_xmlfmte.cxx \ + sw_xmlmeta.cxx \ + sw_xmlitemm.cxx \ + sw_xmlitemi.cxx \ + sw_xmliteme.cxx \ + sw_xmlbrsh.cxx \ + sw_xmlfonte.cxx \ + sw_XMLRedlineImportHelper.cxx \ + sw_xmlitem.cxx \ + sw_xmlithlp.cxx \ + sw_xmlitmpr.cxx \ + sw_xmlimpit.cxx \ + sw_xmlexpit.cxx + +SLOFILES = \ + $(SLO)$/sw_swxml.obj \ + $(SLO)$/sw_xmlimp.obj \ + $(SLO)$/sw_wrtxml.obj \ + $(SLO)$/sw_xmlexp.obj \ + $(SLO)$/sw_xmltext.obj \ + $(SLO)$/sw_xmltexte.obj \ + $(SLO)$/sw_xmltexti.obj \ + $(SLO)$/sw_xmltbli.obj \ + $(SLO)$/sw_xmltble.obj \ + $(SLO)$/sw_xmlfmt.obj \ + $(SLO)$/sw_xmlfmte.obj \ + $(SLO)$/sw_xmlmeta.obj \ + $(SLO)$/sw_xmlscript.obj \ + $(SLO)$/sw_xmlitemm.obj \ + $(SLO)$/sw_xmlitemi.obj \ + $(SLO)$/sw_xmliteme.obj \ + $(SLO)$/sw_xmlithlp.obj \ + $(SLO)$/sw_xmlbrsh.obj \ + $(SLO)$/sw_xmlfonte.obj \ + $(SLO)$/sw_XMLRedlineImportHelper.obj \ + $(SLO)$/sw_xmlitem.obj \ + $(SLO)$/sw_xmlitmpr.obj \ + $(SLO)$/sw_xmlimpit.obj \ + $(SLO)$/sw_xmlexpit.obj + +EXCEPTIONSFILES= \ + $(SLO)$/sw_swxml.obj \ + $(SLO)$/sw_xmlimp.obj \ + $(SLO)$/sw_wrtxml.obj \ + $(SLO)$/sw_xmlexp.obj \ + $(SLO)$/sw_xmltext.obj \ + $(SLO)$/sw_xmltexti.obj \ + $(SLO)$/sw_xmltbli.obj \ + $(SLO)$/sw_xmltble.obj \ + $(SLO)$/sw_xmlfmt.obj \ + $(SLO)$/sw_xmlfmte.obj \ + $(SLO)$/sw_xmlmeta.obj \ + $(SLO)$/sw_xmlscript.obj \ + $(SLO)$/sw_xmlitemi.obj \ + $(SLO)$/sw_xmliteme.obj \ + $(SLO)$/sw_xmlithlp.obj \ + $(SLO)$/sw_xmlbrsh.obj \ + $(SLO)$/sw_xmlfonte.obj \ + $(SLO)$/sw_XMLRedlineImportHelper.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/binfilter/bf_sw/source/filter/xml/sw_XMLRedlineImportHelper.cxx b/binfilter/bf_sw/source/filter/xml/sw_XMLRedlineImportHelper.cxx new file mode 100644 index 000000000000..80162c5895c4 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_XMLRedlineImportHelper.cxx @@ -0,0 +1,746 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#include <errhdl.hxx> + +#include "XMLRedlineImportHelper.hxx" + +#include "unoobj.hxx" + +#include <unocrsr.hxx> + +#include <horiornt.hxx> + +#include "doc.hxx" + +#include <tools/datetime.hxx> + +#include "poolfmt.hxx" + +#include "unoredline.hxx" + +#include <bf_xmloff/xmltoken.hxx> + +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <com/sun/star/text/XWordCursor.hpp> + +#include <com/sun/star/frame/XModel.hpp> + +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <com/sun/star/beans/XPropertySetInfo.hpp> + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> +namespace binfilter { + + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::binfilter::xmloff::token; + +using ::rtl::OUString; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::text::XTextCursor; +using ::com::sun::star::text::XTextRange; +using ::com::sun::star::text::XText; +using ::com::sun::star::text::XWordCursor; +using ::com::sun::star::lang::XUnoTunnel; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::XPropertySetInfo; +// collision with tools/DateTime: use UNO DateTime as util::DateTime +// using ::com::sun::star::util::DateTime; + + +// +// a few helper functions +// + +SwDoc* lcl_GetDocViaTunnel( Reference<XTextCursor> & rCursor ) +{ + Reference<XUnoTunnel> xTunnel( rCursor, UNO_QUERY); + DBG_ASSERT( xTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper* pSwXCursor = + (OTextCursorHelper*)xTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()); + DBG_ASSERT( NULL != pSwXCursor, "OTextCursorHelper missing" ); + return pSwXCursor->GetDoc(); +} + +SwDoc* lcl_GetDocViaTunnel( Reference<XTextRange> & rRange ) +{ + Reference<XUnoTunnel> xTunnel(rRange, UNO_QUERY); + DBG_ASSERT(xTunnel.is(), "Can't tunnel XTextRange"); + SwXTextRange *pRange = + (SwXTextRange*)xTunnel->getSomething(SwXTextRange::getUnoTunnelId()); + DBG_ASSERT( NULL != pRange, "SwXTextRange missing" ); + return pRange->GetDoc(); +} + + +// +// XTextRangeOrNodeIndexPosition: store a position into the text +// *either* as an XTextRange or as an SwNodeIndex. The reason is that +// we must store either pointers to StartNodes (because redlines may +// start on start nodes) or to a text position, and there appears to +// be no existing type that could do both. Things are complicated by +// the matter that (e.g in section import) we delete a few characters, +// which may cause bookmarks (as used by XTextRange) to be deleted. +// + +class XTextRangeOrNodeIndexPosition +{ + Reference<XTextRange> xRange; + SwNodeIndex* pIndex; /// pIndex will point to the *previous* node + +public: + XTextRangeOrNodeIndexPosition(); + ~XTextRangeOrNodeIndexPosition(); + + void Set( Reference<XTextRange> & rRange ); + void Set( SwNodeIndex& rIndex ); + void SetAsNodeIndex( Reference<XTextRange> & rRange ); + + void CopyPositionInto(SwPosition& rPos); + SwDoc* GetDoc(); + + sal_Bool IsValid(); +}; + +XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition() : + xRange(NULL), + pIndex(NULL) +{ +} + +XTextRangeOrNodeIndexPosition::~XTextRangeOrNodeIndexPosition() +{ + delete pIndex; +} + +void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange> & rRange ) +{ + xRange = rRange->getStart(); // set bookmark + if (NULL != pIndex) + { + delete pIndex; + pIndex = NULL; + } +} + +void XTextRangeOrNodeIndexPosition::Set( SwNodeIndex& rIndex ) +{ + if (NULL != pIndex) + delete pIndex; + + pIndex = new SwNodeIndex(rIndex); + (*pIndex)-- ; // previous node!!! + xRange = NULL; +} + +void XTextRangeOrNodeIndexPosition::SetAsNodeIndex( + Reference<XTextRange> & rRange ) +{ + // XTextRange -> XTunnel -> SwXTextRange + SwDoc* pDoc = lcl_GetDocViaTunnel(rRange); + + // SwXTextRange -> PaM + SwUnoInternalPaM aPaM(*pDoc); + sal_Bool bSuccess = SwXTextRange::XTextRangeToSwPaM( aPaM, rRange); + DBG_ASSERT(bSuccess, "illegal range"); + + // PaM -> Index + Set(aPaM.GetPoint()->nNode); +} + +void XTextRangeOrNodeIndexPosition::CopyPositionInto(SwPosition& rPos) +{ + DBG_ASSERT(IsValid(), "Can't get Position"); + + // create PAM from start cursor (if no node index is present) + if (NULL == pIndex) + { + SwUnoInternalPaM aUnoPaM(*GetDoc()); + sal_Bool bSuccess = SwXTextRange::XTextRangeToSwPaM(aUnoPaM, xRange); + DBG_ASSERT(bSuccess, "illegal range"); + + rPos = *aUnoPaM.GetPoint(); + } + else + { + rPos.nNode = *pIndex; + rPos.nNode++; // pIndex points to previous index !!! + rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), 0 ); + } +} + +SwDoc* XTextRangeOrNodeIndexPosition::GetDoc() +{ + DBG_ASSERT(IsValid(), "Can't get Doc"); + + return (NULL != pIndex) ? pIndex->GetNodes().GetDoc() : lcl_GetDocViaTunnel(xRange); +} + +sal_Bool XTextRangeOrNodeIndexPosition::IsValid() +{ + return ( xRange.is() || (pIndex != NULL) ); +} + + +// +// RedlineInfo: temporary storage for redline data +// + +class RedlineInfo +{ +public: + RedlineInfo(); + ~RedlineInfo(); + + /// redline type (insert, delete, ...) + enum SwRedlineType eType; + + // info fields: + OUString sAuthor; /// change author string + OUString sComment; /// change comment string + util::DateTime aDateTime; /// change DateTime + sal_Bool bMergeLastParagraph; /// the SwRedline::IsDelLastPara flag + + // each position can may be either empty, an XTextRange, or an SwNodeIndex + + // start pos of anchor (may be empty) + XTextRangeOrNodeIndexPosition aAnchorStart; + + // end pos of anchor (may be empty) + XTextRangeOrNodeIndexPosition aAnchorEnd; + + /// index of content node (maybe NULL) + SwNodeIndex* pContentIndex; + + /// next redline info (for hierarchical redlines) + RedlineInfo* pNextRedline; + + /// store whether we expect an adjustment for this redline + sal_Bool bNeedsAdjustment; +}; + +RedlineInfo::RedlineInfo() : + eType(REDLINE_INSERT), + sAuthor(), + sComment(), + aDateTime(), + aAnchorStart(), + aAnchorEnd(), + pContentIndex(NULL), + pNextRedline(NULL), + bNeedsAdjustment( sal_False ), + bMergeLastParagraph( sal_False ) +{ +} + +RedlineInfo::~RedlineInfo() +{ + delete pContentIndex; + delete pNextRedline; +} + + +// +// XMLRedlineImportHelper +// + +XMLRedlineImportHelper::XMLRedlineImportHelper( + sal_Bool bNoRedlinesPlease, + const Reference<XPropertySet> & rModel, + const Reference<XPropertySet> & rImportInfo ) : + sEmpty(), + sInsertion( GetXMLToken( XML_INSERTION )), + sDeletion( GetXMLToken( XML_DELETION )), + sFormatChange( GetXMLToken( XML_FORMAT_CHANGE )), + sShowChanges(RTL_CONSTASCII_USTRINGPARAM("ShowChanges")), + sRecordChanges(RTL_CONSTASCII_USTRINGPARAM("RecordChanges")), + sRedlineProtectionKey(RTL_CONSTASCII_USTRINGPARAM("RedlineProtectionKey")), + aRedlineMap(), + bIgnoreRedlines(bNoRedlinesPlease), + xModelPropertySet(rModel), + xImportInfoPropertySet(rImportInfo) +{ + // check to see if redline mode is handled outside of component + sal_Bool bHandleShowChanges = sal_True; + sal_Bool bHandleRecordChanges = sal_True; + if ( xImportInfoPropertySet.is() ) + { + Reference<XPropertySetInfo> xInfo = + xImportInfoPropertySet->getPropertySetInfo(); + + bHandleShowChanges = ! xInfo->hasPropertyByName( sShowChanges ); + bHandleRecordChanges = ! xInfo->hasPropertyByName( sRecordChanges ); + } + + // get redline mode + bShowChanges = *(sal_Bool*) + ( bHandleShowChanges ? xModelPropertySet : xImportInfoPropertySet ) + ->getPropertyValue( sShowChanges ).getValue(); + bRecordChanges = *(sal_Bool*) + ( bHandleRecordChanges ? xModelPropertySet : xImportInfoPropertySet ) + ->getPropertyValue( sRecordChanges ).getValue(); + + // set redline mode to "don't record changes" + if( bHandleRecordChanges ) + { + Any aAny; + sal_Bool bTmp = sal_False; + aAny.setValue( &bTmp, ::getBooleanCppuType() ); + xModelPropertySet->setPropertyValue( sRecordChanges, aAny ); + } +} + +XMLRedlineImportHelper::~XMLRedlineImportHelper() +{ + // delete all left over (and obviously incomplete) RedlineInfos (and map) + RedlineMapType::iterator aFind = aRedlineMap.begin(); + for( ; aRedlineMap.end() != aFind; aFind++ ) + { + RedlineInfo* pInfo = aFind->second; + + // left-over redlines. Insert them if possible (but assert), + // and delete the incomplete ones. Finally, delete it. + if( IsReady(pInfo) ) + { + DBG_ERROR("forgotten RedlineInfo; now inserted"); + InsertIntoDocument( pInfo ); + } + else + { + // try if only the adjustment was missing + pInfo->bNeedsAdjustment = sal_False; + if( IsReady(pInfo) ) + { + DBG_ERROR("RedlineInfo without adjustment; now inserted"); + InsertIntoDocument( pInfo ); + } + else + { + // this situation occurs if redlines aren't closed + // (i.e. end without start, or start without + // end). This may well be a problem in the file, + // rather than the code. + DBG_ERROR("incomplete redline (maybe file was corrupt); " + "now deleted"); + } + } + delete pInfo; + } + aRedlineMap.clear(); + + // set redline mode, either to info property set, or directly to + // the document + sal_Bool bHandleShowChanges = sal_True; + sal_Bool bHandleRecordChanges = sal_True; + sal_Bool bHandleProtectionKey = sal_True; + if ( xImportInfoPropertySet.is() ) + { + Reference<XPropertySetInfo> xInfo = + xImportInfoPropertySet->getPropertySetInfo(); + + bHandleShowChanges = ! xInfo->hasPropertyByName( sShowChanges ); + bHandleRecordChanges = ! xInfo->hasPropertyByName( sRecordChanges ); + bHandleProtectionKey = ! xInfo->hasPropertyByName( sRedlineProtectionKey ); + } + + // set redline mode & key + Any aAny; + + aAny.setValue( &bShowChanges, ::getBooleanCppuType() ); + if ( bHandleShowChanges ) + xModelPropertySet->setPropertyValue( sShowChanges, aAny ); + else + xImportInfoPropertySet->setPropertyValue( sShowChanges, aAny ); + + aAny.setValue( &bRecordChanges, ::getBooleanCppuType() ); + if ( bHandleRecordChanges ) + xModelPropertySet->setPropertyValue( sRecordChanges, aAny ); + else + xImportInfoPropertySet->setPropertyValue( sRecordChanges, aAny ); + + aAny <<= aProtectionKey; + if ( bHandleProtectionKey ) + xModelPropertySet->setPropertyValue( sRedlineProtectionKey, aAny ); + else + xImportInfoPropertySet->setPropertyValue( sRedlineProtectionKey, aAny); +} + +void XMLRedlineImportHelper::Add( + const OUString& rType, + const OUString& rId, + const OUString& rAuthor, + const OUString& rComment, + const util::DateTime& rDateTime, + sal_Bool bMergeLastPara) +{ + // we need to do the following: + // 1) parse type string + // 2) create RedlineInfo and fill it with data + // 3) check for existing redline with same ID + // 3a) insert redline into map + // 3b) attach to existing redline + + // ad 1) + enum SwRedlineType eType; + if (rType.equals(sInsertion)) + { + eType = REDLINE_INSERT; + } + else if (rType.equals(sDeletion)) + { + eType = REDLINE_DELETE; + } + else if (rType.equals(sFormatChange)) + { + eType = REDLINE_FORMAT; + } + else + { + // no proper type found: early out! + return; + } + + // ad 2) create a new RedlineInfo + RedlineInfo* pInfo = new RedlineInfo(); + + // fill entries + pInfo->eType = eType; + pInfo->sAuthor = rAuthor; + pInfo->sComment = rComment; + pInfo->aDateTime = rDateTime; + pInfo->bMergeLastParagraph = bMergeLastPara; + + + // ad 3) + if (aRedlineMap.end() == aRedlineMap.find(rId)) + { + // 3a) insert into map + aRedlineMap[rId] = pInfo; + } + else + { + // 3b) we already have a redline with this name: hierarchical redlines + // insert pInfo as last element in the chain. + // (hierarchy sanity checking happens on insertino into the document) + + // find last element + RedlineInfo* pInfoChain; + for( pInfoChain = aRedlineMap[rId]; + NULL != pInfoChain->pNextRedline; + pInfoChain = pInfoChain->pNextRedline) ; // empty loop + + // insert as last element + pInfoChain->pNextRedline = pInfo; + } +} + +Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection( + Reference<XTextCursor> xOldCursor, + const OUString& rId) +{ + Reference<XTextCursor> xReturn; + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + // get RedlineInfo + RedlineMapType::iterator aFind = aRedlineMap.find(rId); + if (aRedlineMap.end() != aFind) + { + // get document from old cursor (via tunnel) + SwDoc* pDoc = lcl_GetDocViaTunnel(xOldCursor); + + // create text section for redline + SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPoolSimple + (RES_POOLCOLL_STANDARD, FALSE); + SwStartNode* pRedlineNode = pDoc->GetNodes().MakeTextSection( + pDoc->GetNodes().GetEndOfRedlines(), + SwNormalStartNode, + pColl); + + // remember node-index in RedlineInfo + SwNodeIndex aIndex(*pRedlineNode); + aFind->second->pContentIndex = new SwNodeIndex(aIndex); + + // create XText for document + SwXText* pXText = new SwXRedlineText(pDoc, aIndex); + Reference<XText> xText = pXText; // keep Reference until end of method + + // create (UNO-) cursor + SwPosition aPos(*pRedlineNode); + SwXTextCursor* pCursor = + new SwXTextCursor(pXText, aPos, CURSOR_REDLINE, pDoc); + pCursor->GetCrsr()->Move(fnMoveForward, fnGoNode); + + xReturn = (XWordCursor*)pCursor; // cast to avoid ambigiouty + } + // else: unknown redline -> Ignore + + return xReturn; +} + +void XMLRedlineImportHelper::SetCursor( + const OUString& rId, + sal_Bool bStart, + Reference<XTextRange> & rRange, + sal_Bool bIsOutsideOfParagraph) +{ + RedlineMapType::iterator aFind = aRedlineMap.find(rId); + if (aRedlineMap.end() != aFind) + { + // RedlineInfo found; now set Cursor + RedlineInfo* pInfo = aFind->second; + if (bIsOutsideOfParagraph) + { + // outside of paragraph: remember SwNodeIndex + if (bStart) + { + pInfo->aAnchorStart.SetAsNodeIndex(rRange); + } + else + { + pInfo->aAnchorEnd.SetAsNodeIndex(rRange); + } + + // also remember that we expect an adjustment for this redline + pInfo->bNeedsAdjustment = sal_True; + } + else + { + // inside of a paragraph: use regular XTextRanges (bookmarks) + if (bStart) + pInfo->aAnchorStart.Set(rRange); + else + pInfo->aAnchorEnd.Set(rRange); + } + + // if this Cursor was the last missing info, we insert the + // node into the document + // then we can remove the entry from the map and destroy the object + if (IsReady(pInfo)) + { + InsertIntoDocument(pInfo); + aRedlineMap.erase(rId); + delete pInfo; + } + } + // else: unknown Id -> ignore +} + +void XMLRedlineImportHelper::AdjustStartNodeCursor( + const OUString& rId, /// ID used in RedlineAdd() call + sal_Bool bStart, + Reference<XTextRange> & rRange) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + // start + end nodes are treated the same. For either it's + // necessary that the target node already exists. + + RedlineMapType::iterator aFind = aRedlineMap.find(rId); + if (aRedlineMap.end() != aFind) + { + // RedlineInfo found; now set Cursor + RedlineInfo* pInfo = aFind->second; + + pInfo->bNeedsAdjustment = sal_False; + + // if now ready, insert into document + if( IsReady(pInfo) ) + { + InsertIntoDocument(pInfo); + aRedlineMap.erase(rId); + delete pInfo; + } + } + // else: can't find redline -> ignore +} + + +inline sal_Bool XMLRedlineImportHelper::IsReady(RedlineInfo* pRedline) +{ + // we can insert a redline if we have start & end, and we don't + // expect adjustments for either of these + return ( pRedline->aAnchorEnd.IsValid() && + pRedline->aAnchorStart.IsValid() && + !pRedline->bNeedsAdjustment ); +} + +void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) +{ + DBG_ASSERT(NULL != pRedlineInfo, "need redline info"); + DBG_ASSERT(IsReady(pRedlineInfo), "redline info not complete yet!"); + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + // Insert the Redline as described by pRedlineInfo into the + // document. If we are in insert mode, don't insert any redlines + // (and delete 'deleted' inline redlines) + + // get the document (from one of the positions) + SwDoc* pDoc = pRedlineInfo->aAnchorStart.GetDoc(); + + // now create the PaM for the redline + SwPaM aPaM(pDoc->GetNodes().GetEndOfContent()); + pRedlineInfo->aAnchorStart.CopyPositionInto(*aPaM.GetPoint()); + aPaM.SetMark(); + pRedlineInfo->aAnchorEnd.CopyPositionInto(*aPaM.GetPoint()); + + // collapse PaM if (start == end) + if (*aPaM.GetPoint() == *aPaM.GetMark()) + { + aPaM.DeleteMark(); + } + + + // cover three cases: + // 1) empty redlines (no range, no content) #100921# + // 2) check for: + // a) bIgnoreRedline (e.g. insert mode) + // b) illegal PaM range (CheckNodesRange()) + // 3) normal case: insert redline + if( !aPaM.HasMark() && (pRedlineInfo->pContentIndex == NULL) ) + { + // these redlines have no function, and will thus be ignored (just as + // in sw3io), so no action here + } + else if ( bIgnoreRedlines || + !CheckNodesRange( aPaM.GetPoint()->nNode, + aPaM.GetMark()->nNode, + sal_True ) ) + { + // ignore redline (e.g. file loaded in insert mode): + // delete 'deleted' redlines and forget about the whole thing + if (REDLINE_DELETE == pRedlineInfo->eType) + { + pDoc->Delete(aPaM); + } + } + else + { + // regular file loading: insert redline + + // create redline (using pRedlineData which gets copied in SwRedline()) + SwRedlineData* pRedlineData = ConvertRedline(pRedlineInfo, pDoc); + SwRedline* pRedline = + new SwRedline( pRedlineData, *aPaM.GetPoint(), TRUE, + !pRedlineInfo->bMergeLastParagraph, FALSE ); + + // set mark + if( aPaM.HasMark() ) + { + pRedline->SetMark(); + *(pRedline->GetMark()) = *aPaM.GetMark(); + } + + // set content node (if necessary) + if (NULL != pRedlineInfo->pContentIndex) + { + pRedline->SetContentIdx(pRedlineInfo->pContentIndex); + } + + // set redline mode (without doing the associated book-keeping) + pDoc->SetRedlineMode_intern(REDLINE_ON); + pDoc->AppendRedline(pRedline); + pDoc->SetRedlineMode_intern(REDLINE_NONE); + } +} + +SwRedlineData* XMLRedlineImportHelper::ConvertRedline( + RedlineInfo* pRedlineInfo, + SwDoc* pDoc) +{ + // convert info: + // 1) Author String -> Author ID (default to zero) + sal_uInt16 nAuthorId = (NULL == pDoc) ? 0 : + pDoc->InsertRedlineAuthor( pRedlineInfo->sAuthor ); + + // 2) util::DateTime -> DateTime + DateTime aDT; + aDT.SetYear( pRedlineInfo->aDateTime.Year ); + aDT.SetMonth( pRedlineInfo->aDateTime.Month ); + aDT.SetDay( pRedlineInfo->aDateTime.Day ); + aDT.SetHour( pRedlineInfo->aDateTime.Hours ); + aDT.SetMin( pRedlineInfo->aDateTime.Minutes ); + aDT.SetSec( pRedlineInfo->aDateTime.Seconds ); + aDT.Set100Sec( pRedlineInfo->aDateTime.HundredthSeconds ); + + // 3) recursively convert next redline + // ( check presence and sanity of hierarchical redline info ) + SwRedlineData* pNext = NULL; + if ( (NULL != pRedlineInfo->pNextRedline) && + (REDLINE_DELETE == pRedlineInfo->eType) && + (REDLINE_INSERT == pRedlineInfo->pNextRedline->eType) ) + { + pNext = ConvertRedline(pRedlineInfo->pNextRedline, pDoc); + } + + // create redline data + SwRedlineData* pData = new SwRedlineData(pRedlineInfo->eType, + nAuthorId, aDT, + pRedlineInfo->sComment, + pNext, // next data (if available) + NULL); // no extra data + + return pData; +} + + +void XMLRedlineImportHelper::SetShowChanges( sal_Bool bShow ) +{ + bShowChanges = bShow; +} + +void XMLRedlineImportHelper::SetRecordChanges( sal_Bool bRecord ) +{ + bRecordChanges = bRecord; +} + +void XMLRedlineImportHelper::SetProtectionKey( + const Sequence<sal_Int8> & rKey ) +{ + aProtectionKey = rKey; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_swxml.cxx b/binfilter/bf_sw/source/filter/xml/sw_swxml.cxx new file mode 100644 index 000000000000..cd23c3b5a9df --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_swxml.cxx @@ -0,0 +1,712 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#define _SVSTDARR_STRINGS + +#include <rsc/rscsfx.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/xml/sax/InputSource.hpp> +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/io/XActiveDataControl.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/packages/zip/ZipIOException.hpp> +#include <bf_svtools/svstdarr.hxx> + +#include <bf_sfx2/appuno.hxx> + +#include <bf_sfx2/docfile.hxx> +#include <bf_svtools/sfxecode.hxx> +#include <unotools/streamwrap.hxx> +#include <bf_svx/xmlgrhlp.hxx> +#include <bf_svx/xmleohlp.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <rtl/logfile.hxx> + +#include <swerror.h> +#include <errhdl.hxx> + +#include "swtypes.hxx" + +#include <fltini.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <docsh.hxx> +#include <unoobj.hxx> +#include <swmodule.hxx> +#include <SwXMLSectionList.hxx> +#include <xmlimp.hxx> + +#include <statstr.hrc> +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +#define LOGFILE_AUTHOR "mb93740" +namespace binfilter { + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::lang; + +using rtl::OUString; + + +void lcl_EnsureValidPam( SwPaM& rPam ) +{ + if( rPam.GetCntntNode() != NULL ) + { + // set proper point content + if( rPam.GetCntntNode() != rPam.GetPoint()->nContent.GetIdxReg() ) + { + rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 ); + } + // else: point was already valid + + // if mark is invalid, we delete it + if( ( rPam.GetCntntNode( FALSE ) == NULL ) || + ( rPam.GetCntntNode( FALSE ) != rPam.GetMark()->nContent.GetIdxReg() ) ) + { + rPam.DeleteMark(); + } + } + else + { + // point is not valid, so move it into the first content + rPam.DeleteMark(); + rPam.GetPoint()->nNode = + *rPam.GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); + ++ rPam.GetPoint()->nNode; + rPam.Move( fnMoveForward, fnGoCntnt ); // go into content + } +} + +XMLReader::XMLReader() +{ +} + +int XMLReader::GetReaderType() +{ + return SW_STORAGE_READER; +} + +/// read a component (file + filter version) +sal_Int32 ReadThroughComponent( + Reference<io::XInputStream> xInputStream, + Reference<XComponent> xModelComponent, + const String& rStreamName, + Reference<lang::XMultiServiceFactory> & rFactory, + const sal_Char* pFilterName, + Sequence<Any> rFilterArguments, + const OUString& rName, + sal_Bool bMustBeSuccessfull, + + // parameters for special modes + sal_Bool bBlockMode, + Reference<XTextRange> & rInsertTextRange, + sal_Bool bFormatsOnly, + sal_uInt16 nStyleFamilyMask, + sal_Bool bMergeStyles, + sal_Bool bOrganizerMode, + sal_Bool bEncrypted ) +{ + DBG_ASSERT(xInputStream.is(), "input stream missing"); + DBG_ASSERT(xModelComponent.is(), "document missing"); + DBG_ASSERT(rFactory.is(), "factory missing"); + DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!"); + + RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "sw", LOGFILE_AUTHOR, "ReadThroughComponent" ); + + // prepare ParserInputSrouce + xml::sax::InputSource aParserInput; + aParserInput.sSystemId = rName; + aParserInput.aInputStream = xInputStream; + + // get parser + Reference< xml::sax::XParser > xParser( + rFactory->createInstance( + OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), + UNO_QUERY ); + DBG_ASSERT( xParser.is(), "Can't create parser" ); + if( !xParser.is() ) + return ERR_SWG_READ_ERROR; + RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" ); + + // get filter + Reference< xml::sax::XDocumentHandler > xFilter( + rFactory->createInstanceWithArguments( + OUString::createFromAscii(pFilterName), rFilterArguments), + UNO_QUERY ); + DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." ); + if( !xFilter.is() ) + return ERR_SWG_READ_ERROR; + RTL_LOGFILE_CONTEXT_TRACE1( aLog, "%s created", pFilterName ); + + // connect parser and filter + xParser->setDocumentHandler( xFilter ); + + // connect model and filter + Reference < XImporter > xImporter( xFilter, UNO_QUERY ); + xImporter->setTargetDocument( xModelComponent ); + + // prepare filter for special modes + if( bBlockMode || bFormatsOnly || rInsertTextRange.is() || bOrganizerMode ) + { + Reference<XUnoTunnel> xFilterTunnel( xFilter, UNO_QUERY ); + if (xFilterTunnel.is()) + { + SwXMLImport* pFilter = (SwXMLImport *)xFilterTunnel->getSomething( + SwXMLImport::getUnoTunnelId() ); + + if ( NULL != pFilter ) + { + // In formats only mode the reader's bInsertMode is set + if ( bFormatsOnly ) + pFilter->setStyleInsertMode( nStyleFamilyMask, + !bMergeStyles ); + if ( rInsertTextRange.is() ) + pFilter->setTextInsertMode( rInsertTextRange ); + + if ( bBlockMode ) + pFilter->setBlockMode(); + + if ( bOrganizerMode ) + pFilter->setOrganizerMode(); + } + } + } + +#ifdef TIMELOG + // if we do profiling, we want to know the stream + ByteString aString( (String)rStreamName, RTL_TEXTENCODING_ASCII_US ); + RTL_LOGFILE_TRACE_AUTHOR1( "sw", LOGFILE_AUTHOR, + "ReadThroughComponent : parsing \"%s\"", aString.GetBuffer() ); +#endif + + // finally, parser the stream + try + { + xParser->parseStream( aParserInput ); + } + catch( xml::sax::SAXParseException& r ) + { + if( bEncrypted ) + return ERRCODE_SFX_WRONGPASSWORD; + +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "SAX parse exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + + String sErr( String::CreateFromInt32( r.LineNumber )); + sErr += ','; + sErr += String::CreateFromInt32( r.ColumnNumber ); + + if( rStreamName.Len() ) + { + return *new TwoStringErrorInfo( + (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL + : WARN_FORMAT_FILE_ROWCOL), + rStreamName, sErr, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + } + else + { + ASSERT( bMustBeSuccessfull, "Warnings are not supported" ); + return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + } + } + catch( xml::sax::SAXException& r ) + { + if( bEncrypted ) + return ERRCODE_SFX_WRONGPASSWORD; + +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "SAX exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + return ERR_SWG_READ_ERROR; + } + catch( packages::zip::ZipIOException& r ) + { +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "Zip exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + return ERRCODE_IO_BROKENPACKAGE; + } + catch( io::IOException& r ) + { +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "IO exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + return ERR_SWG_READ_ERROR; + } + catch( uno::Exception& r ) + { +#if OSL_DEBUG_LEVEL > 1 + ByteString aError( "uno exception catched while importing:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + return ERR_SWG_READ_ERROR; + } + + // success! + return 0; +} + +/// read a component (storage version) +sal_Int32 ReadThroughComponent( + SvStorage* pStorage, + Reference<XComponent> xModelComponent, + const sal_Char* pStreamName, + const sal_Char* pCompatibilityStreamName, + Reference<lang::XMultiServiceFactory> & rFactory, + const sal_Char* pFilterName, + Sequence<Any> rFilterArguments, + const OUString& rName, + sal_Bool bMustBeSuccessfull, + + // parameters for special modes + sal_Bool bBlockMode, + Reference<XTextRange> & rInsertTextRange, + sal_Bool bFormatsOnly, + sal_uInt16 nStyleFamilyMask, + sal_Bool bMergeStyles, + sal_Bool bOrganizerMode ) +{ + DBG_ASSERT(NULL != pStorage, "Need storage!"); + DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!"); + + // open stream (and set parser input) + OUString sStreamName = OUString::createFromAscii(pStreamName); + if (! pStorage->IsStream(sStreamName)) + { + // stream name not found! Then try the compatibility name. + // if no stream can be opened, return immediatly with OK signal + + // do we even have an alternative name? + if ( NULL == pCompatibilityStreamName ) + return 0; + + // if so, does the stream exist? + sStreamName = OUString::createFromAscii(pCompatibilityStreamName); + if (! pStorage->IsStream(sStreamName) ) + return 0; + } + + // get input stream + SvStorageStreamRef xEventsStream; + xEventsStream = pStorage->OpenStream( sStreamName, + STREAM_READ | STREAM_NOCREATE ); + + Any aAny; + sal_Bool bEncrypted = + xEventsStream->GetProperty( + OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ), aAny ) && + aAny.getValueType() == ::getBooleanCppuType() && + *(sal_Bool *)aAny.getValue(); + + Reference < io::XInputStream > xStream = xEventsStream->GetXInputStream(); + // read from the stream + return ReadThroughComponent( + xStream, xModelComponent, sStreamName, rFactory, + pFilterName, rFilterArguments, + rName, bMustBeSuccessfull, bBlockMode, rInsertTextRange, bFormatsOnly, + nStyleFamilyMask, bMergeStyles, bOrganizerMode, bEncrypted ); +} + + +ULONG XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) +{ + // Get service factory + Reference< lang::XMultiServiceFactory > xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + ASSERT( xServiceFactory.is(), + "XMLReader::Read: got no service manager" ); + if( !xServiceFactory.is() ) + return ERR_SWG_READ_ERROR; + + Reference< io::XActiveDataSource > xSource; + Reference< XInterface > xPipe; + Reference< document::XGraphicObjectResolver > xGraphicResolver; + SvXMLGraphicHelper *pGraphicHelper = 0; + Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = 0; + + // get the input stream (storage or stream) + SvStorageStreamRef xDocStream; + Reference<io::XInputStream> xInputStream; + SvStorage *pStorage = 0; + if( pMedium ) + pStorage = pMedium->GetStorage(); + else + pStorage = pStg; + + ASSERT( pStorage, "XML Reader can only read from storage" ); + if( !pStorage ) + return ERR_SWG_READ_ERROR; + + pGraphicHelper = SvXMLGraphicHelper::Create( *pStorage, + GRAPHICHELPER_MODE_READ, + sal_False ); + xGraphicResolver = pGraphicHelper; + SvPersist *pPersist = rDoc.GetPersist(); + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + *pStorage, *pPersist, + EMBEDDEDOBJECTHELPER_MODE_READ, + sal_False ); + xObjectResolver = pObjectHelper; + } + + // Get the docshell, the model, and finally the model's component + SwDocShell *pDocSh = rDoc.GetDocShell(); + ASSERT( pDocSh, "XMLReader::Read: got no doc shell" ); + if( !pDocSh ) + return ERR_SWG_READ_ERROR; + Reference< lang::XComponent > xModelComp( pDocSh->GetModel(), UNO_QUERY ); + ASSERT( xModelComp.is(), + "XMLReader::Read: got no model" ); + if( !xModelComp.is() ) + return ERR_SWG_READ_ERROR; + + + // create and prepare the XPropertySet that gets passed through + // the components, and the XStatusIndicator that shows progress to + // the user. + + // create XPropertySet with three properties for status indicator + ::comphelper::PropertyMapEntry aInfoMap[] = + { + { "ProgressRange", sizeof("ProgressRange")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "ProgressMax", sizeof("ProgressMax")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "ProgressCurrent", sizeof("ProgressCurrent")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "NumberStyles", sizeof("NumberStyles")-1, 0, + &::getCppuType( (Reference<container::XNameContainer> *) 0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "RecordChanges", sizeof("RecordChanges")-1, 0, + &::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "ShowChanges", sizeof("ShowChanges")-1, 0, + &::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "RedlineProtectionKey", sizeof("RedlineProtectionKey")-1, 0, +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) + new uno::Type(::getCppuType((Sequence<sal_Int8>*)0)), +#else + &::getCppuType((Sequence<sal_Int8>*)0), +#endif + beans::PropertyAttribute::MAYBEVOID, 0 }, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( + ::comphelper::GenericPropertySet_CreateInstance( + new comphelper::PropertySetInfo( aInfoMap ) ) ); + + // try to get an XStatusIndicator from the Medium + uno::Reference<task::XStatusIndicator> xStatusIndicator; + if (pDocSh->GetMedium()) + { + SfxItemSet* pSet = pDocSh->GetMedium()->GetItemSet(); + if (pSet) + { + const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>( + pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); + if (pItem) + { + pItem->GetValue() >>= xStatusIndicator; + } + } + } + + + // set progress range and start status indicator + sal_Int32 nProgressRange(1000000); + if (xStatusIndicator.is()) + { + xStatusIndicator->start(SW_RESSTR(STR_STATSTR_SWGREAD), nProgressRange); + } + uno::Any aProgRange; + aProgRange <<= nProgressRange; + OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")); + xInfoSet->setPropertyValue(sProgressRange, aProgRange); + + // prepare filter arguments + Sequence<Any> aFilterArgs( 5 ); + Any *pArgs = aFilterArgs.getArray(); + *pArgs++ <<= xGraphicResolver; + *pArgs++ <<= xObjectResolver; + *pArgs++ <<= xStatusIndicator; + *pArgs++ <<= xInfoSet; + Sequence<Any> aEmptyArgs( 3 ); + pArgs = aEmptyArgs.getArray(); + *pArgs++ <<= xStatusIndicator; + *pArgs++ <<= xInfoSet; + + // prepare for special modes + sal_uInt16 nStyleFamilyMask = 0U; + Reference<XTextRange> xInsertTextRange = NULL; + if( aOpt.IsFmtsOnly() ) + { + 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 if( bInsertMode ) + { + xInsertTextRange = SwXTextRange::CreateTextRangeFromPosition( + &rDoc, *rPaM.GetPoint(), 0 ); + } + else + { + rPaM.GetBound(true).nContent.Assign(0, 0); + rPaM.GetBound(false).nContent.Assign(0, 0); + } + + rDoc.AddLink(); // prevent deletion + ULONG nRet = 0; + + // save redline mode into import info property set + Any aAny; + sal_Bool bTmp; + OUString sShowChanges( RTL_CONSTASCII_USTRINGPARAM("ShowChanges") ); + bTmp = IsShowChanges( rDoc.GetRedlineMode() ); + aAny.setValue( &bTmp, ::getBooleanCppuType() ); + xInfoSet->setPropertyValue( sShowChanges, aAny ); + OUString sRecordChanges( RTL_CONSTASCII_USTRINGPARAM("RecordChanges") ); + bTmp = IsRedlineOn(rDoc.GetRedlineMode()); + aAny.setValue( &bTmp, ::getBooleanCppuType() ); + xInfoSet->setPropertyValue( sRecordChanges, aAny ); + OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM("RedlineProtectionKey") ); + aAny <<= rDoc.GetRedlinePasswd(); + xInfoSet->setPropertyValue( sRedlineProtectionKey, aAny ); + + // force redline mode to "none" + rDoc.SetRedlineMode_intern( REDLINE_NONE ); + + sal_uInt32 nWarn = 0; + sal_uInt32 nWarn2 = 0; + // read storage streams + if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || + bInsertMode) ) + { + nWarn = ReadThroughComponent( + pStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLMetaImporter", + aEmptyArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + sal_False ); + + nWarn2 = ReadThroughComponent( + pStorage, xModelComp, "settings.xml", NULL, xServiceFactory, + "com.sun.star.comp.Writer.XMLSettingsImporter", + aFilterArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + IsOrganizerMode() ); + } + + nRet = ReadThroughComponent( + pStorage, xModelComp, "styles.xml", NULL, xServiceFactory, + "com.sun.star.comp.Writer.XMLStylesImporter", + aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + IsOrganizerMode() ); + + if( !nRet && !(IsOrganizerMode() || aOpt.IsFmtsOnly()) ) + nRet = ReadThroughComponent( + pStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLContentImporter", + aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + sal_False ); + + if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode || + aOpt.IsFmtsOnly() ) ) + { + OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); + SvStorageStreamRef xStrm = pStorage->OpenStream( sStreamName, + STREAM_READ | STREAM_NOCREATE ); + if( xStrm.Is() && !xStrm->GetError() ) + { + xStrm->SetBufferSize( 16*1024 ); + rDoc.ReadLayoutCache( *xStrm ); + } + } + + // Notify math objects + if( bInsertMode ) + rDoc.PrtOLENotify( FALSE ); + else if ( rDoc.IsOLEPrtNotifyPending() ) + rDoc.PrtOLENotify( TRUE ); + + if( !nRet ) + { + if( nWarn ) + nRet = nWarn; + else if( nWarn2 ) + nRet = nWarn2; + } + + aOpt.ResetAllFmtsOnly(); + + // redline password + aAny = xInfoSet->getPropertyValue( sRedlineProtectionKey ); + Sequence<sal_Int8> aKey; + aAny >>= aKey; + rDoc.SetRedlinePasswd( aKey ); + + // restore redline mode from import info property set + sal_Int16 nRedlineMode = REDLINE_SHOW_INSERT; + aAny = xInfoSet->getPropertyValue( sShowChanges ); + if ( *(sal_Bool*)aAny.getValue() ) + nRedlineMode |= REDLINE_SHOW_DELETE; + aAny = xInfoSet->getPropertyValue( sRecordChanges ); + if ( *(sal_Bool*)aAny.getValue() || (aKey.getLength() > 0) ) + nRedlineMode |= REDLINE_ON; + else + nRedlineMode |= REDLINE_NONE; + + // ... restore redline mode + // (First set bogus mode to make sure the mode in SetRedlineMode() + // is different from it's previous mode.) + rDoc.SetRedlineMode_intern( ~nRedlineMode ); + rDoc.SetRedlineMode( nRedlineMode ); + + // #103728# move Pam into valid content + lcl_EnsureValidPam( rPaM ); + + if( pGraphicHelper ) + SvXMLGraphicHelper::Destroy( pGraphicHelper ); + xGraphicResolver = 0; + if( pObjectHelper ) + SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + xObjectResolver = 0; + rDoc.RemoveLink(); + + if (xStatusIndicator.is()) + { + xStatusIndicator->end(); + } + + return nRet; +} + + // read the sections of the document, which is equal to the medium. + // returns the count of it +USHORT XMLReader::GetSectionList( SfxMedium& rMedium, + SvStrings& rStrings ) const +{ + SvStorage* pStg; + Reference< lang::XMultiServiceFactory > xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + ASSERT( xServiceFactory.is(), + "XMLReader::Read: got no service manager" ); + if( xServiceFactory.is() && 0 != ( pStg = rMedium.GetStorage() ) ) + { + xml::sax::InputSource aParserInput; + OUString sDocName( RTL_CONSTASCII_USTRINGPARAM( "content.xml" ) ); + aParserInput.sSystemId = sDocName; + SvStorageStreamRef xDocStream = pStg->OpenStream( sDocName, + ( STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE ) ); + aParserInput.aInputStream = xDocStream->GetXInputStream(); + + // 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() ) + { + // get filter + // #110680# + // Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLSectionList( rStrings ); + Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLSectionList( xServiceFactory, rStrings ); + + // connect parser and filter + Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY ); + xParser->setDocumentHandler( xFilter ); + + // parse + try + { + xParser->parseStream( aParserInput ); + } + catch( xml::sax::SAXParseException& ) + { + // re throw ? + } + catch( xml::sax::SAXException& ) + { + // re throw ? + } + catch( io::IOException& ) + { + // re throw ? + } + } + } + return rStrings.Count(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_swxmlat.cxx b/binfilter/bf_sw/source/filter/xml/sw_swxmlat.cxx new file mode 100644 index 000000000000..83397d2b6f23 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_swxmlat.cxx @@ -0,0 +1,376 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <rsc/rscsfx.hxx> + +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <fchrfmt.hxx> +#include <charfmt.hxx> +#include <paratr.hxx> +#include <paratr.hxx> +#include <fmtpdsc.hxx> +#include "fmtlsplt.hxx" +#include "fmtornt.hxx" +#include "fmtfsize.hxx" +#include <unomid.h> +#include "unostyle.hxx" + +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmltkmap.hxx> +#include <bf_xmloff/i18nmap.hxx> + +#include "xmlimp.hxx" +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::binfilter::xmloff::token; + +// --------------------------------------------------------------------- + +sal_Bool SwFmtDrop::equalsXML( const SfxPoolItem& rItem ) const +{ + ASSERT( !this, "obsolete implementation!" ); + return sal_True; +} + +// --------------------------------------------------------------------- + +sal_Bool SwRegisterItem::importXML( const OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) +{ + ASSERT( !this, "obsolete implementation!" ); + return sal_False; +} + +sal_Bool SwRegisterItem::exportXML( + OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) const +{ + ASSERT( !this, "obsolete implementation!" ); + return sal_True; +} + +// --------------------------------------------------------------------- + +sal_Bool SwNumRuleItem::equalsXML( const SfxPoolItem& rItem ) const +{ + ASSERT( !this, "obsolete implementation!" ); + return sal_True; +} + +// --------------------------------------------------------------------- + +sal_Bool SwFmtPageDesc::importXML( const OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bRet = sal_False; + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + sal_Int32 nVal; + bRet = rUnitConverter.convertNumber( nVal, rValue, 0, USHRT_MAX ); + if( bRet ) + SetNumOffset( (USHORT)nVal ); + } + + return bRet; +} + +sal_Bool SwFmtPageDesc::exportXML( + OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRet = sal_False; + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + OUStringBuffer aOut; + + rUnitConverter.convertNumber( aOut, (sal_Int32)GetNumOffset() ); + rValue = aOut.makeStringAndClear(); + + bRet = sal_True; + } + + return bRet; +} +sal_Bool SwFmtPageDesc::equalsXML( const SfxPoolItem& rItem ) const +{ + // Everything except pDefinedIn must be the same. + return ( nNumOffset == ((SwFmtPageDesc&)rItem).nNumOffset ) && + ( GetPageDesc() == ((SwFmtPageDesc&)rItem).GetPageDesc() ); +} + +// --------------------------------------------------------------------- + +sal_Bool SwFmtCharFmt::exportXML( OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& ) const +{ + ASSERT( !this, "obsolete implementation!" ); + return sal_True; +} + +// --------------------------------------------------------------------- + +sal_Bool SwFmtLayoutSplit::importXML( const OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bValue; + sal_Bool bRet = rUnitConverter.convertBool( bValue, rValue ); + if( bRet ) + SetValue( bValue ); + + return bRet; +} + +sal_Bool SwFmtLayoutSplit::exportXML( + OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) const +{ + OUStringBuffer aOut; + + rUnitConverter.convertBool( aOut, GetValue() ); + rValue = aOut.makeStringAndClear(); + + return sal_True; +} + +// --------------------------------------------------------------------- + +static __FAR_DATA struct SvXMLEnumMapEntry aXMLTableAlignMap[] = +{ + { XML_LEFT, HORI_LEFT }, + { XML_LEFT, HORI_LEFT_AND_WIDTH }, + { XML_CENTER, HORI_CENTER }, + { XML_RIGHT, HORI_RIGHT }, + { XML_MARGINS, HORI_FULL }, + { XML_MARGINS, HORI_NONE }, + { XML_TOKEN_INVALID, 0 } +}; + +sal_Bool SwFmtHoriOrient::importXML( const OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_uInt16 nValue; + sal_Bool bRet = rUnitConverter.convertEnum( nValue, rValue, + aXMLTableAlignMap ); + if( bRet ) + SetHoriOrient( (SwHoriOrient)nValue ); + + return bRet; +} + +sal_Bool SwFmtHoriOrient::exportXML( + OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) const +{ + OUStringBuffer aOut; + + rUnitConverter.convertEnum( aOut, GetHoriOrient(), aXMLTableAlignMap ); + rValue = aOut.makeStringAndClear(); + + return sal_True; +} + +// --------------------------------------------------------------------- + +static __FAR_DATA SvXMLEnumMapEntry aXMLTableVAlignMap[] = +{ + { XML_TOP, VERT_TOP }, + { XML_MIDDLE, VERT_CENTER }, + { XML_BOTTOM, VERT_BOTTOM }, + { XML_TOKEN_INVALID, 0 } +}; + +sal_Bool SwFmtVertOrient::importXML( const OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_uInt16 nValue; + sal_Bool bRet = + rUnitConverter.convertEnum( nValue, rValue,aXMLTableVAlignMap ); + if( bRet ) + SetVertOrient( (SwVertOrient)nValue ); + + return bRet; +} + +sal_Bool SwFmtVertOrient::exportXML( + OUString& rValue, sal_uInt16, + const SvXMLUnitConverter& rUnitConverter ) const +{ + OUStringBuffer aOut; + + rUnitConverter.convertEnum( aOut, GetVertOrient(), aXMLTableVAlignMap ); + rValue = aOut.makeStringAndClear(); + + return sal_True; +} + +// --------------------------------------------------------------------- + +sal_Bool SwFmtFrmSize::importXML( const OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bRet = sal_False; + sal_Bool bSetHeight = sal_False; + sal_Bool bSetWidth = sal_False; + sal_Bool bSetSizeType = sal_False; + SwFrmSize eSizeType = ATT_VAR_SIZE; + sal_Int32 nMin = MINLAY; + + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + { + sal_Int32 nValue; + bRet = rUnitConverter.convertPercent( nValue, rValue ); + if( bRet ) + { + if( nValue < 1 ) + nValue = 1; + else if( nValue > 100 ) + nValue = 100; + + SetWidthPercent( (sal_Int8)nValue ); + } + } + break; + case MID_FRMSIZE_WIDTH: + bSetWidth = sal_True; + break; + case MID_FRMSIZE_MIN_HEIGHT: + eSizeType = ATT_MIN_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + eSizeType = ATT_FIX_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_COL_WIDTH: + eSizeType = ATT_FIX_SIZE; + bSetWidth = sal_True; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_REL_COL_WIDTH: + { + sal_Int32 nPos = rValue.indexOf( (sal_Unicode)'*' ); + if( -1L != nPos ) + { + OUString sNum( rValue.copy( 0L, nPos ) ); + sal_Int32 nValue = rValue.toInt32(); + if( nValue < MINLAY ) + nValue = MINLAY; + else if( nValue > USHRT_MAX ) + nValue = USHRT_MAX; + + SetWidth( (sal_uInt16)nValue ); + SetSizeType( ATT_VAR_SIZE ); + bRet = sal_True; + } + } + break; + } + + sal_Int32 nValue; + if( bSetHeight || bSetWidth ) + { + bRet = rUnitConverter.convertMeasure( nValue, rValue, nMin, + USHRT_MAX ); + if( bRet ) + { + if( bSetWidth ) + SetWidth( (sal_uInt16)nValue ); + if( bSetHeight ) + SetHeight( (sal_uInt16)nValue ); + if( bSetSizeType ) + SetSizeType( eSizeType ); + } + } + return bRet; +} + +sal_Bool SwFmtFrmSize::exportXML( + OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRet = sal_False; + sal_Bool bOutHeight = sal_False; + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + if( GetWidthPercent() ) + { + OUStringBuffer aOut; + rUnitConverter.convertPercent( aOut, GetWidthPercent() ); + rValue = aOut.makeStringAndClear(); + bRet = sal_True; + } + break; + case MID_FRMSIZE_MIN_HEIGHT: + if( ATT_MIN_SIZE == GetSizeType() ) + bOutHeight = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + if( ATT_FIX_SIZE == GetSizeType() ) + bOutHeight = sal_True; + break; + } + + if( bOutHeight ) + { + OUStringBuffer aOut; + rUnitConverter.convertMeasure( aOut, GetHeight() ); + rValue = aOut.makeStringAndClear(); + bRet = sal_True; + } + + return bRet; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_wrtxml.cxx b/binfilter/bf_sw/source/filter/xml/sw_wrtxml.cxx new file mode 100644 index 000000000000..88fbf51824c0 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_wrtxml.cxx @@ -0,0 +1,555 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <comphelper/processfactory.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <unotools/streamwrap.hxx> +#include <bf_svx/xmlgrhlp.hxx> +#include <bf_svx/xmleohlp.hxx> +#include <bf_svtools/saveopt.hxx> + +#include <bf_sfx2/docfile.hxx> + +#include <errhdl.hxx> + +#include <pam.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <docstat.hxx> +#include <docsh.hxx> + +#include <errhdl.hxx> +#include <swerror.h> +#include <wrtxml.hxx> +#include <xmlexp.hxx> +#include <statstr.hrc> +#include <rtl/logfile.hxx> +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; + +using rtl::OUString; + +#define LOGFILE_AUTHOR "mb93740" + +SwXMLWriter::SwXMLWriter() +{ +} + + +__EXPORT SwXMLWriter::~SwXMLWriter() +{ +} + + +sal_uInt32 SwXMLWriter::_Write() +{ + // Get service factory + Reference< lang::XMultiServiceFactory > xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + ASSERT( xServiceFactory.is(), + "SwXMLWriter::Write: got no service manager" ); + if( !xServiceFactory.is() ) + return ERR_SWG_WRITE_ERROR; + + // Get data sink ... + Reference< io::XOutputStream > xOut; + SvStorageStreamRef xDocStream; + Reference< document::XGraphicObjectResolver > xGraphicResolver; + SvXMLGraphicHelper *pGraphicHelper = 0; + Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = 0; + + ASSERT( pStg, "Where is my storage?" ); + pGraphicHelper = SvXMLGraphicHelper::Create( *pStg, + GRAPHICHELPER_MODE_WRITE, + sal_False ); + xGraphicResolver = pGraphicHelper; + + SvPersist *pPersist = pDoc->GetPersist(); + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + *pStg, *pPersist, + EMBEDDEDOBJECTHELPER_MODE_WRITE, + sal_False ); + xObjectResolver = pObjectHelper; + } + + // create and prepare the XPropertySet that gets passed through + // the components, and the XStatusIndicator that shows progress to + // the user. + + // create XPropertySet with three properties for status indicator + ::comphelper::PropertyMapEntry aInfoMap[] = + { + { "ProgressRange", sizeof("ProgressRange")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "ProgressMax", sizeof("ProgressMax")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "ProgressCurrent", sizeof("ProgressCurrent")-1, 0, + &::getCppuType((sal_Int32*)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "WrittenNumberStyles", sizeof("WrittenNumberStyles")-1, 0, + &::getCppuType((uno::Sequence<sal_Int32> *)0), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "UsePrettyPrinting", sizeof("UsePrettyPrinting")-1, 0, + &::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "ShowChanges", sizeof("ShowChanges")-1, 0, + &::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( + ::comphelper::GenericPropertySet_CreateInstance( + new comphelper::PropertySetInfo( aInfoMap ) ) ); + + // create XStatusIndicator + uno::Reference<task::XStatusIndicator> xStatusIndicator; + + uno::Any aAny; + if (bShowProgress) + { + try + { + uno::Reference<frame::XModel> xModel( pDoc->GetDocShell()->GetModel()); + if (xModel.is()) + { + uno::Reference<frame::XController> xController( + xModel->getCurrentController()); + if( xController.is()) + { + uno::Reference<frame::XFrame> xFrame( xController->getFrame()); + if( xFrame.is()) + { + uno::Reference<task::XStatusIndicatorFactory> xFactory( + xFrame, uno::UNO_QUERY ); + if( xFactory.is()) + { + xStatusIndicator = + xFactory->createStatusIndicator(); + } + } + } + } + } + catch( const RuntimeException& ) + { + xStatusIndicator = 0; + } + + // set progress range and start status indicator + sal_Int32 nProgressRange(1000000); + if (xStatusIndicator.is()) + { + xStatusIndicator->start(SW_RESSTR( STR_STATSTR_SWGWRITE), + nProgressRange); + } + aAny <<= nProgressRange; + OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")); + xInfoSet->setPropertyValue(sProgressRange, aAny); + + aAny <<= XML_PROGRESS_REF_NOT_SET; + OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM("ProgressMax")); + xInfoSet->setPropertyValue(sProgressMax, aAny); + } + SvtSaveOptions aSaveOpt; + OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")); + sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() ); + aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() ); + xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny ); + + // save show redline mode ... + OUString sShowChanges(RTL_CONSTASCII_USTRINGPARAM("ShowChanges")); + sal_uInt16 nRedlineMode = pDoc->GetRedlineMode(); + sal_Bool bShowChanges( IsShowChanges( nRedlineMode ) ); + aAny.setValue( &bShowChanges, ::getBooleanCppuType() ); + xInfoSet->setPropertyValue( sShowChanges, aAny ); + // ... and hide redlines for export + nRedlineMode &= ~REDLINE_SHOW_MASK; + nRedlineMode |= REDLINE_SHOW_INSERT; + pDoc->SetRedlineMode( nRedlineMode ); + + + // filter arguments + // - graphics + object resolver for styles + content + // - status indicator + // - info property set + // - else empty + sal_Int32 nArgs = 1; + if( xStatusIndicator.is() ) + nArgs++; + + Sequence < Any > aEmptyArgs( nArgs ); + Any *pArgs = aEmptyArgs.getArray(); + if( xStatusIndicator.is() ) + *pArgs++ <<= xStatusIndicator; + *pArgs++ <<= xInfoSet; + + if( xGraphicResolver.is() ) + nArgs++; + if( xObjectResolver.is() ) + nArgs++; + + Sequence < Any > aFilterArgs( nArgs ); + pArgs = aFilterArgs.getArray(); + if( xGraphicResolver.is() ) + *pArgs++ <<= xGraphicResolver; + if( xObjectResolver.is() ) + *pArgs++ <<= xObjectResolver; + if( xStatusIndicator.is() ) + *pArgs++ <<= xStatusIndicator; + *pArgs++ <<= xInfoSet; + + //Get model + Reference< lang::XComponent > xModelComp( + pDoc->GetDocShell()->GetModel(), UNO_QUERY ); + ASSERT( xModelComp.is(), "XMLWriter::Write: got no model" ); + if( !xModelComp.is() ) + return ERR_SWG_WRITE_ERROR; + + PutNumFmtFontsInAttrPool(); + PutEditEngFontsInAttrPool(); + + // properties + Sequence < PropertyValue > aProps( pOrigFileName ? 1 : 0 ); + if( pOrigFileName ) + { + PropertyValue *pProps = aProps.getArray(); + pProps->Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FileName") ); + (pProps++)->Value <<= OUString( *pOrigFileName ); + } + + // export sub streams for package, else full stream into a file + sal_Bool bWarn = sal_False, bErr = sal_False; + String sWarnFile, sErrFile; + + if( !bOrganizerMode && !bBlock && + SFX_CREATE_MODE_EMBEDDED != pDoc->GetDocShell()->GetCreateMode() ) + { + if( !WriteThroughComponent( + xModelComp, "meta.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLMetaExporter", + aEmptyArgs, aProps, sal_True ) ) + { + bWarn = sal_True; + sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("meta.xml"), + RTL_TEXTENCODING_ASCII_US ); + } + } + + if( !WriteThroughComponent( + xModelComp, "styles.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLStylesExporter", + aFilterArgs, aProps, sal_False ) ) + { + bErr = sal_True; + sErrFile = String( RTL_CONSTASCII_STRINGPARAM("styles.xml"), + RTL_TEXTENCODING_ASCII_US ); + } + + if( !bErr ) + { + if( !bBlock ) + { + if( !WriteThroughComponent( + xModelComp, "settings.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLSettingsExporter", + aEmptyArgs, aProps, sal_False ) ) + { + if( !bWarn ) + { + bWarn = sal_True; + sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("settings.xml"), + RTL_TEXTENCODING_ASCII_US ); + } + } + } + } + + if( !bOrganizerMode && !bErr ) + { + if( !WriteThroughComponent( + xModelComp, "content.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLContentExporter", + aFilterArgs, aProps, sal_False ) ) + { + bErr = sal_True; + sErrFile = String( RTL_CONSTASCII_STRINGPARAM("content.xml"), + RTL_TEXTENCODING_ASCII_US ); + } + } + + if( pDoc->GetRootFrm() && pDoc->GetDocStat().nPage > 1 && + !(bOrganizerMode || bBlock || bErr) ) + { +// DBG_ASSERT( !pDoc->GetDocStat().bModified, +// "doc stat is modified!" ); + OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); + SvStorageStreamRef xStrm = pStg->OpenStream( sStreamName, + STREAM_WRITE | STREAM_SHARE_DENYWRITE ); + DBG_ASSERT(xStrm.Is(), "Can't create output stream in package!"); + if( xStrm.Is() ) + { + xStrm->SetSize( 0 ); + String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); + OUString aMime( RTL_CONSTASCII_USTRINGPARAM("appication/binary") ); + uno::Any aAny; + aAny <<= aMime; + xStrm->SetProperty( aPropName, aAny ); + xStrm->SetBufferSize( 16*1024 ); + pDoc->WriteLayoutCache( *xStrm ); + xStrm->Commit(); + } + } + + if( pGraphicHelper ) + SvXMLGraphicHelper::Destroy( pGraphicHelper ); + xGraphicResolver = 0; + + if( pObjectHelper ) + SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + xObjectResolver = 0; + + // restore redline mode + aAny = xInfoSet->getPropertyValue( sShowChanges ); + nRedlineMode = pDoc->GetRedlineMode(); + nRedlineMode &= ~REDLINE_SHOW_MASK; + nRedlineMode |= REDLINE_SHOW_INSERT; + if ( *(sal_Bool*)aAny.getValue() ) + nRedlineMode |= REDLINE_SHOW_DELETE; + pDoc->SetRedlineMode( nRedlineMode ); + + if (xStatusIndicator.is()) + { + xStatusIndicator->end(); + } + + if( bErr ) + { + if( sErrFile.Len() ) + return *new StringErrorInfo( ERR_WRITE_ERROR_FILE, sErrFile, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + else + return ERR_SWG_WRITE_ERROR; + } + else if( bWarn ) + { + if( sWarnFile.Len() ) + return *new StringErrorInfo( WARN_WRITE_ERROR_FILE, sWarnFile, + ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR ); + else + return WARN_SWG_FEATURES_LOST; + } + + return 0; +} + +ULONG SwXMLWriter::WriteStorage() +{ + return _Write(); +} + +ULONG SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed, + const String* pFileName ) +{ + return IsStgWriter() + ? ((StgWriter *)this)->Write( rPaM, *rMed.GetOutputStorage( sal_True ), pFileName ) + : ((Writer *)this)->Write( rPaM, *rMed.GetOutStream(), pFileName ); +} + +sal_Bool SwXMLWriter::WriteThroughComponent( + const Reference<XComponent> & xComponent, + const sal_Char* pStreamName, + const Reference<lang::XMultiServiceFactory> & rFactory, + const sal_Char* pServiceName, + const Sequence<Any> & rArguments, + const Sequence<beans::PropertyValue> & rMediaDesc, + sal_Bool bPlainStream ) +{ + DBG_ASSERT( NULL != pStg, "Need storage!" ); + DBG_ASSERT( NULL != pStreamName, "Need stream name!" ); + DBG_ASSERT( NULL != pServiceName, "Need service name!" ); + + RTL_LOGFILE_TRACE_AUTHOR1( "sw", LOGFILE_AUTHOR, + "SwXMLWriter::WriteThroughComponent : stream %s", + pStreamName ); + + Reference< io::XOutputStream > xOutputStream; + SvStorageStreamRef xDocStream; + + // open stream + OUString sStreamName = OUString::createFromAscii( pStreamName ); + xDocStream = pStg->OpenStream( sStreamName, + STREAM_WRITE | STREAM_SHARE_DENYWRITE ); + DBG_ASSERT(xDocStream.Is(), "Can't create output stream in package!"); + if (! xDocStream.Is()) + return sal_False; + + xDocStream->SetSize( 0 ); + + String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); + OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") ); + uno::Any aAny; + aAny <<= aMime; + xDocStream->SetProperty( aPropName, aAny ); + + if( bPlainStream ) + { + OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Compressed") ); + sal_Bool bFalse = sal_False; + aAny.setValue( &bFalse, ::getBooleanCppuType() ); + xDocStream->SetProperty( aPropName, aAny ); + } + else + { + OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ); + sal_Bool bTrue = sal_True; + aAny.setValue( &bTrue, ::getBooleanCppuType() ); + xDocStream->SetProperty( aPropName, aAny ); + } + + + // set buffer and create outputstream + xDocStream->SetBufferSize( 16*1024 ); + xOutputStream = new ::utl::OOutputStreamWrapper( *xDocStream ); + + // write the stuff + sal_Bool bRet = WriteThroughComponent( + xOutputStream, xComponent, rFactory, + pServiceName, rArguments, rMediaDesc ); + + // finally, commit stream. + if( bRet ) + xDocStream->Commit(); + + return bRet; + +} + +sal_Bool SwXMLWriter::WriteThroughComponent( + const Reference<io::XOutputStream> & xOutputStream, + const Reference<XComponent> & xComponent, + const Reference<XMultiServiceFactory> & rFactory, + const sal_Char* pServiceName, + const Sequence<Any> & rArguments, + const Sequence<PropertyValue> & rMediaDesc ) +{ + ASSERT( xOutputStream.is(), "I really need an output stream!" ); + ASSERT( xComponent.is(), "Need component!" ); + ASSERT( NULL != pServiceName, "Need component name!" ); + + RTL_LOGFILE_CONTEXT_AUTHOR( aFilterLog, "sw", LOGFILE_AUTHOR, + "SwXMLWriter::WriteThroughComponent" ); + + // get component + Reference< io::XActiveDataSource > xSaxWriter( + rFactory->createInstance( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.xml.sax.Writer")) ), + UNO_QUERY ); + ASSERT( xSaxWriter.is(), "can't instantiate XML writer" ); + if(!xSaxWriter.is()) + return sal_False; + + RTL_LOGFILE_CONTEXT_TRACE( aFilterLog, "SAX-Writer created" ); + + // connect XML writer to output stream + xSaxWriter->setOutputStream( xOutputStream ); + + // prepare arguments (prepend doc handler to given arguments) + Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY); + Sequence<Any> aArgs( 1 + rArguments.getLength() ); + aArgs[0] <<= xDocHandler; + for(sal_Int32 i = 0; i < rArguments.getLength(); i++) + aArgs[i+1] = rArguments[i]; + + // get filter component + Reference< document::XExporter > xExporter( + rFactory->createInstanceWithArguments( + OUString::createFromAscii(pServiceName), aArgs), UNO_QUERY); + ASSERT( xExporter.is(), + "can't instantiate export filter component" ); + if( !xExporter.is() ) + return sal_False; + RTL_LOGFILE_CONTEXT_TRACE1( aFilterLog, "%s instantiated.", pServiceName ); + + // set block mode (if appropriate) + if( bBlock ) + { + Reference<XUnoTunnel> xFilterTunnel( xExporter, UNO_QUERY ); + if (xFilterTunnel.is()) + { + SwXMLExport *pFilter = (SwXMLExport *)xFilterTunnel->getSomething( + SwXMLExport::getUnoTunnelId() ); + if (NULL != pFilter) + pFilter->setBlockMode(); + } + } + + + // connect model and filter + xExporter->setSourceDocument( xComponent ); + + // filter! + RTL_LOGFILE_CONTEXT_TRACE( aFilterLog, "call filter()" ); + Reference<XFilter> xFilter( xExporter, UNO_QUERY ); + return xFilter->filter( rMediaDesc ); +} + + +// ----------------------------------------------------------------------- + +void GetXMLWriter( const String& rName, WriterRef& xRet ) +{ + xRet = new SwXMLWriter(); +} + +// ----------------------------------------------------------------------- +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlbrsh.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlbrsh.cxx new file mode 100644 index 000000000000..86576a638b8a --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlbrsh.cxx @@ -0,0 +1,259 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "hintids.hxx" +#include <tools/debug.hxx> + +#include <com/sun/star/io/XOutputStream.hpp> + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmlimp.hxx> +#include <bf_xmloff/xmltkmap.hxx> +#include <bf_xmloff/XMLBase64ImportContext.hxx> + +#include <bf_svx/unomid.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include "xmlbrshi.hxx" +#include "xmlbrshe.hxx" +#include "xmlexp.hxx" +#include "xmlimpit.hxx" +#include "xmlexpit.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; + +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, XML_HREF, XML_TOK_BGIMG_HREF }, + { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_BGIMG_TYPE }, + { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_BGIMG_ACTUATE }, + { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_BGIMG_SHOW }, + { XML_NAMESPACE_STYLE, XML_POSITION, XML_TOK_BGIMG_POSITION }, + { XML_NAMESPACE_STYLE, XML_REPEAT, XML_TOK_BGIMG_REPEAT }, + { XML_NAMESPACE_STYLE, XML_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: + SvXMLImportItemMapper::PutXMLValue( + *pItem, GetImport().ResolveGraphicObjectURL( rValue,sal_False), + 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: + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_POSITION, rUnitConv ); + break; + case XML_TOK_BGIMG_REPEAT: + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_REPEAT, rUnitConv ); + break; + case XML_TOK_BGIMG_FILTER: + SvXMLImportItemMapper::PutXMLValue( + *pItem, rValue, MID_GRAPHIC_FILTER, rUnitConv ); + break; + } + } + +} + +SvXMLImportContext *SwXMLBrushItemImportContext::CreateChildContext( + sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + if( xmloff::token::IsXMLToken( rLocalName, + xmloff::token::XML_BINARY_DATA ) ) + { + if( !(pItem->GetGraphicLink() || pItem->GetGraphic() ) && !xBase64Stream.is() ) + { + xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); + if( xBase64Stream.is() ) + pContext = new XMLBase64ImportContext( GetImport(), nPrefix, + rLocalName, xAttrList, + xBase64Stream ); + } + } + if( !pContext ) + { + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + } + + return pContext; +} + +void SwXMLBrushItemImportContext::EndElement() +{ + if( xBase64Stream.is() ) + { + OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ) ); + xBase64Stream = 0; + SvXMLImportItemMapper::PutXMLValue( *pItem, sURL, MID_GRAPHIC_LINK, GetImport().GetMM100UnitConverter() ); + } + + 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; +} + +SwXMLBrushItemExport::SwXMLBrushItemExport( SwXMLExport& rExp ) : + rExport( rExp ) +{ +} + +SwXMLBrushItemExport::~SwXMLBrushItemExport() +{ +} + + +void SwXMLBrushItemExport::exportXML( const SvxBrushItem& rItem ) +{ + GetExport().CheckAttrList(); + + OUString sValue, sURL; + const SvXMLUnitConverter& rUnitConv = GetExport().GetTwipUnitConverter(); + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sURL, MID_GRAPHIC_LINK, rUnitConv ) ) + { + sValue = GetExport().AddEmbeddedGraphicObject( sURL ); + if( sValue.getLength() ) + { + GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sValue ); + GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); + // AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, ACP2WS(sXML_embed) ); + GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); + } + + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_POSITION, rUnitConv ) ) + GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION, sValue ); + + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_REPEAT, rUnitConv ) ) + GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REPEAT, sValue ); + + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, MID_GRAPHIC_FILTER, rUnitConv ) ) + GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FILTER_NAME, sValue ); + } + + { + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, XML_BACKGROUND_IMAGE, + sal_True, sal_True ); + if( sURL.getLength() ) + { + // optional office:binary-data + GetExport().AddEmbeddedGraphicObjectAsBase64( sURL ); + } + } +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlexp.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlexp.cxx new file mode 100644 index 000000000000..ab9991c5322e --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlexp.cxx @@ -0,0 +1,875 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> + +#include <bf_svx/svdmodel.hxx> +#include <bf_svx/svdpage.hxx> +#ifndef _XMLGRHLP_HXX +#include <bf_svx/xmlgrhlp.hxx> +#include <bf_svx/xmleohlp.hxx> +#include <bf_svx/xmlgrhlp.hxx> +#endif +#include <bf_svx/xmleohlp.hxx> +#include <bf_svx/eeitem.hxx> +#include <bf_svx/svddef.hxx> + +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_svx/xmlcnitm.hxx> +#include <bf_xmloff/ProgressBarHelper.hxx> +#include <bf_xmloff/xmluconv.hxx> + +#include <errhdl.hxx> + +#include <pam.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <swmodule.hxx> +#include <docsh.hxx> +#include <docstat.hxx> +#include <swerror.h> +#include <unoobj.hxx> + +#include <xmltexte.hxx> +#include <xmlexp.hxx> + +#ifndef _COMPHELPER_PROCESSFACTORYHXX_ +#include <comphelper/processfactory.hxx> +#endif + +#include <docary.hxx> + +#include <bf_svx/unolingu.hxx> + +#include <bf_svx/forbiddencharacterstable.hxx> + +#include <ForbiddenCharactersEnum.hxx> + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 + +#include <bf_svx/xdef.hxx> + +namespace binfilter { + +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::i18n; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; +using rtl::OUStringBuffer; + +#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 + +// #110680# +SwXMLExport::SwXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nExportFlags) +: SvXMLExport( xServiceFactory, MAP_INCH, XML_TEXT, nExportFlags ), +#ifdef XML_CORE_API + pCurPaM( 0 ), + pOrigPaM( &rPaM ), +#endif + pTableItemMapper( 0 ), + pTableLines( 0 ), +#ifdef XML_CORE_API + bExportWholeDoc( bExpWholeDoc ), + bExportFirstTableOnly( bExpFirstTableOnly ), +#endif + bBlock( sal_False ), + bShowProgress( sal_True ), + sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")), + sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected")), + sCell(RTL_CONSTASCII_USTRINGPARAM("Cell")) +{ + _InitItemExport(); +} + +#ifdef XML_CORE_API +// #110680# +SwXMLExport::SwXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const Reference< XModel >& rModel, + SwPaM& rPaM, + const OUString& rFileName, + const Reference< XDocumentHandler > & rHandler, + const Reference< XGraphicObjectResolver > & rEmbeddedGrfObjs, + sal_Bool bExpWholeDoc, sal_Bool bExpFirstTableOnly, + sal_Bool bShowProg ) +: SvXMLExport( xServiceFactory, rFileName, rHandler, rModel, rEmbeddedGrfObjs, + SW_MOD()->GetMetric( rPaM.GetDoc()->IsHTMLMode() ) ), + pCurPaM( 0 ), + pOrigPaM( &rPaM ), + pTableItemMapper( 0 ), + pTableLines( 0 ), + bExportWholeDoc( bExpWholeDoc ), + bExportFirstTableOnly( bExpFirstTableOnly ), + bShowProgress( bShowProg ), + sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")), + sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected")), + sCell(RTL_CONSTASCII_USTRINGPARAM("Cell")) +{ + _InitItemExport(); +} +#endif + +void SwXMLExport::setBlockMode() +{ + bBlock = sal_True; + +} + +sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass ) +{ + if( !GetModel().is() ) + return ERR_SWG_WRITE_ERROR; + + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( !xTextTunnel.is() ) + return ERR_SWG_WRITE_ERROR; + + // from here, we use core interfaces -> lock Solar-Mutex (#91949#) + SolarMutexGuard aGuard; + + SwXText *pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + if( !pText ) + return ERR_SWG_WRITE_ERROR; + + SwDoc *pDoc = pText->GetDoc(); + + sal_Bool bExtended = sal_False; + if( (getExportFlags() & (EXPORT_FONTDECLS|EXPORT_STYLES| + EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 ) + { + GetTextParagraphExport()->SetBlockMode( bBlock ); + + const SfxPoolItem* pItem; + const SfxItemPool& rPool = pDoc->GetAttrPool(); + sal_uInt16 aWhichIds[5] = { RES_UNKNOWNATR_CONTAINER, + RES_TXTATR_UNKNOWN_CONTAINER, + SDRATTR_XMLATTRIBUTES, + EE_PARA_XMLATTRIBS, + EE_CHAR_XMLATTRIBS }; + + sal_uInt16 nWhichIds = rPool.GetSecondaryPool() ? 5 : 2; + for( sal_uInt16 j=0; j < nWhichIds; j++ ) + { + sal_uInt16 nWhichId = aWhichIds[j]; + sal_uInt16 i=0, nItems = rPool.GetItemCount( nWhichId ); + for( i = 0; i < nItems; ++i ) + { + if( 0 != (pItem = rPool.GetItem( nWhichId , i ) ) ) + { + const SvXMLAttrContainerItem *pUnknown = + PTR_CAST( SvXMLAttrContainerItem, pItem ); + ASSERT( pUnknown, "illegal attribute container item" ); + if( pUnknown && (pUnknown->GetAttrCount() > 0) ) + { + sal_uInt16 nIdx = pUnknown->GetFirstNamespaceIndex(); + while( USHRT_MAX != nIdx ) + { + const OUString& rPrefix = + pUnknown->GetPrefix( nIdx ); + _GetNamespaceMap().Add( rPrefix, + pUnknown->GetNamespace( nIdx ), + XML_NAMESPACE_UNKNOWN ); + nIdx = pUnknown->GetNextNamespaceIndex( nIdx ); + } + bExtended = sal_True; + } + } + } + } + } + + MapUnit eUnit = + SvXMLUnitConverter::GetMapUnit( SW_MOD()->GetMetric(pDoc->IsHTMLMode()) ); + if( GetMM100UnitConverter().getXMLMeasureUnit() != eUnit ) + { + GetMM100UnitConverter().setXMLMeasureUnit( eUnit ); + pTwipUnitConv->setXMLMeasureUnit( eUnit ); + } + + SetExtended( bExtended ); + + SwDocStat aDocStat( pDoc->GetDocStat() ); + if( (getExportFlags() & EXPORT_META) != 0 ) + { + // Update doc stat, so that correct values are exported and + // the progress works correctly. + if( aDocStat.bModified ) + pDoc->UpdateDocStat( aDocStat ); + + SfxObjectShell* pObjSh = pDoc->GetDocShell(); + if( pObjSh ) + pObjSh->UpdateDocInfoForSave(); // update information + } + if( bShowProgress ) + { + ProgressBarHelper *pProgress = GetProgressBarHelper(); + if( XML_PROGRESS_REF_NOT_SET == pProgress->GetReference() ) + { + // progress isn't initialized: + // We assume that the whole doc is exported, and the following + // durations: + // - meta information: 2 + // - settings: 4 (TODO: not now!) + // - styles (except page styles): 2 + // - page styles: 2 (TODO: not now!) + 2 for each paragraph + // - paragraph: 2 (1 for automatic styles and one for content) + + // If required, update doc stat, so that + // the progress works correctly. + if( aDocStat.bModified ) + pDoc->UpdateDocStat( aDocStat ); + + // count each item once, and then multiply by two to reach the + // figures given above + // The styles in pDoc also count the default style that never + // gets exported -> subtract one. + sal_Int32 nRef = 1; + nRef += pDoc->GetCharFmts()->Count() - 1; + nRef += pDoc->GetFrmFmts()->Count() - 1; + nRef += pDoc->GetTxtFmtColls()->Count() - 1; +// nRef += pDoc->GetPageDescCnt(); + nRef += aDocStat.nPara; + pProgress->SetReference( 2*nRef ); + pProgress->SetValue( 0 ); + } + } + + if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 ) + { + //Auf die Korrektheit der OrdNums sind wir schon angewiesen. + SdrModel* pModel = pDoc->GetDrawModel(); + if( pModel ) + pModel->GetPage( 0 )->RecalcObjOrdNums(); + } + + // adjust document class (eClass) + if (pDoc->IsGlobalDoc()) + { + eClass = XML_TEXT_GLOBAL; + + // additionally, we take care of the save-linked-sections-thingy + bSaveLinkedSections = pDoc->IsGlblDocSaveLinks(); + } + else if (pDoc->IsLabelDoc()) + { + eClass = XML_LABEL; + } + // else: keep default pClass that we received + + SvXMLGraphicHelper *pGraphicResolver = 0; + if( !GetGraphicResolver().is() ) + { + pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE ); + Reference< XGraphicObjectResolver > xGraphicResolver( pGraphicResolver ); + SetGraphicResolver( xGraphicResolver ); + } + + SvXMLEmbeddedObjectHelper *pEmbeddedResolver = 0; + if( !GetEmbeddedResolver().is() ) + { + SvPersist *pPersist = pDoc->GetPersist(); + if( pPersist ) + { + pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create( + *pPersist, + EMBEDDEDOBJECTHELPER_MODE_WRITE ); + Reference< XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver ); + SetEmbeddedResolver( xEmbeddedResolver ); + } + } + + // set redline mode if we export STYLES or CONTENT, unless redline + // mode is taken care of outside (through info XPropertySet) + sal_Bool bSaveRedline = + ( (getExportFlags() & (EXPORT_CONTENT|EXPORT_STYLES)) != 0 ); + if( bSaveRedline ) + { + // if the info property set has a ShowChanges property, + // then change tracking is taken care of on the outside, + // so we don't have to! + Reference<XPropertySet> rInfoSet = getExportInfo(); + if( rInfoSet.is() ) + { + OUString sShowChanges( RTL_CONSTASCII_USTRINGPARAM("ShowChanges")); + bSaveRedline = ! rInfoSet->getPropertySetInfo()->hasPropertyByName( + sShowChanges ); + } + } + sal_uInt16 nRedlineMode = 0; + bSavedShowChanges = IsShowChanges( pDoc->GetRedlineMode() ); + if( bSaveRedline ) + { + // now save and switch redline mode + nRedlineMode = pDoc->GetRedlineMode(); + pDoc->SetRedlineMode( + ( nRedlineMode & REDLINE_SHOW_MASK ) | REDLINE_INSERT ); + } + + sal_uInt32 nRet = SvXMLExport::exportDoc( eClass ); + + // now we can restore the redline mode (if we changed it previously) + if( bSaveRedline ) + { + pDoc->SetRedlineMode( nRedlineMode ); + } + + + if( pGraphicResolver ) + SvXMLGraphicHelper::Destroy( pGraphicResolver ); + if( pEmbeddedResolver ) + SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver ); + + ASSERT( !pTableLines, "there are table columns infos left" ); + + return nRet; +} + +XMLTextParagraphExport* SwXMLExport::CreateTextParagraphExport() +{ + return new SwXMLTextParagraphExport( *this, *GetAutoStylePool().get() ); +} + +XMLShapeExport* SwXMLExport::CreateShapeExport() +{ + XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) ); + Reference < XDrawPageSupplier > xDPS( GetModel(), UNO_QUERY ); + if( xDPS.is() ) + { + Reference < XShapes > xShapes( xDPS->getDrawPage(), UNO_QUERY ); + pShapeExport->seekShapes( xShapes ); + } + + return pShapeExport; +} + +__EXPORT SwXMLExport::~SwXMLExport() +{ + _FinitItemExport(); +} + + +void SwXMLExport::_ExportFontDecls() +{ + GetFontAutoStylePool(); // make sure the pool is created + SvXMLExport::_ExportFontDecls(); +} + +#define NUM_EXPORTED_VIEW_SETTINGS 11 +void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps) +{ + Reference< XMultiServiceFactory > xServiceFactory = + ::legacy_binfilters::getLegacyProcessServiceFactory(); + ASSERT( xServiceFactory.is(), + "XMLReader::Read: got no service manager" ); + if( !xServiceFactory.is() ) + return; + + aProps.realloc( NUM_EXPORTED_VIEW_SETTINGS ); + // Currently exporting 9 properties + PropertyValue *pValue = aProps.getArray(); + sal_Int32 nIndex = 0; + + Reference < XIndexContainer > xBox (xServiceFactory->createInstance + (OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), UNO_QUERY); + if (xBox.is() ) + { +#if 0 + Any aAny; + sal_Int32 i=0; + for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(); + pFrame; + i++, pFrame = SfxViewFrame::GetNext(*pFrame ) ) + { + Sequence < PropertyValue > aSequence; + pFrame->GetViewShell()->WriteUserDataSequence( aSequence, sal_False ); + aAny <<= aSequence; + xBox->insertByIndex(i, aAny); + } +#endif + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "Views") ); + pValue[nIndex++].Value <<= Reference < XIndexAccess > ( xBox, UNO_QUERY ); + } + + Reference < XText > xText; + SwXText *pText = 0; + + if( GetModel().is() ) + { + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( xTextTunnel.is() ) + { + pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + } + } + + if( !pText ) + { + aProps.realloc(nIndex); + return; + } + + SwDoc *pDoc = pText->GetDoc(); + const Rectangle rRect = + pDoc->GetDocShell()->SfxInPlaceObject::GetVisArea(); + sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MAP_TWIP; + + ASSERT( bTwip || ( pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit() == MAP_100TH_MM ), + "Map unit for visible area is neither in TWIPS nor in 100th mm!" ); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") ); + pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.Top() ) : rRect.Top(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") ); + pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.Left() ) : rRect.Left(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") ); + pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.GetWidth() ) : rRect.GetWidth(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") ); + pValue[nIndex++].Value <<= bTwip ? TWIP_TO_MM100 ( rRect.GetHeight() ) : rRect.GetHeight(); + + // "show redline mode" cannot simply be read from the document + // since it gets changed during execution. If it's in the info + // XPropertySet, we take it from there. + sal_Bool bShowRedlineChanges = bSavedShowChanges; + Reference<XPropertySet> xInfoSet( getExportInfo() ); + if ( xInfoSet.is() ) + { + OUString sShowChanges( RTL_CONSTASCII_USTRINGPARAM( "ShowChanges" )); + if( xInfoSet->getPropertySetInfo()->hasPropertyByName( sShowChanges ) ) + { + bShowRedlineChanges = *(sal_Bool*) xInfoSet-> + getPropertyValue( sShowChanges ).getValue(); + } + } + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ShowRedlineChanges") ); + pValue[nIndex++].Value.setValue( &bShowRedlineChanges, ::getBooleanCppuType() ); + + sal_Bool bShowHead = pDoc->IsHeadInBrowse(); + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ShowHeaderWhileBrowsing") ); + pValue[nIndex++].Value.setValue( &bShowHead, ::getBooleanCppuType() ); + + sal_Bool bShowFoot = pDoc->IsFootInBrowse(); + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ShowFooterWhileBrowsing") ); + pValue[nIndex++].Value.setValue( &bShowFoot, ::getBooleanCppuType() ); + + sal_Bool bInBrowse = pDoc->IsBrowseMode(); + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "InBrowseMode") ); + pValue[nIndex++].Value.setValue( &bInBrowse, ::getBooleanCppuType() ); + + if ( nIndex < NUM_EXPORTED_VIEW_SETTINGS ) + aProps.realloc(nIndex); +} +#undef NUM_EXPORTED_VIEW_SETTINGS + +void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps) +{ + Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY ); + if( xFac.is() ) + { + Reference< XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY ); + if( xProps.is() ) + SvXMLUnitConverter::convertPropertySet( rProps, xProps ); + } +} + +void SwXMLExport::_ExportContent() +{ + // export forms + Reference<XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY); + if (xDrawPageSupplier.is()) + { + // export only if we actually have elements + Reference<XDrawPage> xPage = xDrawPageSupplier->getDrawPage(); + if (xPage.is()) + { + // #103597# prevent export of form controls which are embedded in + // mute sections + Reference<XIndexAccess> xIAPage( xPage, UNO_QUERY ); + GetTextParagraphExport()->PreventExportOfControlsInMuteSections( + xIAPage, GetFormExport() ); + + Reference<XFormsSupplier> xFormSupp(xPage, UNO_QUERY); + if (xFormSupp->getForms()->hasElements()) + { + ::binfilter::xmloff::OOfficeFormsExport aOfficeForms(*this); + + GetFormExport()->seekPage(xPage); + GetFormExport()->exportForms(xPage); + } + } + } + + Reference<XPropertySet> xPropSet(GetModel(), UNO_QUERY); + if (xPropSet.is()) + { + OUString sTwoDigitYear(RTL_CONSTASCII_USTRINGPARAM("TwoDigitYear")); + + Any aAny = xPropSet->getPropertyValue( sTwoDigitYear ); + aAny <<= (sal_Int16)1930; + + sal_Int16 nYear; + aAny >>= nYear; + if (nYear != 1930 ) + { + ::rtl::OUStringBuffer sBuffer; + GetMM100UnitConverter().convertNumber(sBuffer, nYear); + AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear()); + SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True); + } + } + + GetTextParagraphExport()->exportTrackedChanges( sal_False ); + GetTextParagraphExport()->exportTextDeclarations(); + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + + GetTextParagraphExport()->exportFramesBoundToPage( bShowProgress ); + GetTextParagraphExport()->exportText( xText, bShowProgress ); +} + + + +// +// uno component registration +// helper functions for export service(s) +// + +OUString SAL_CALL SwXMLExport_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLExporter" ) ); +} + +Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames() + throw() +{ + const OUString aServiceName(SwXMLExport_getImplementationName()); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SwXMLExport_createInstance( + const Reference< XMultiServiceFactory > & rSMgr) + throw( Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLExport(EXPORT_ALL); + return (cppu::OWeakObject*)new SwXMLExport( rSMgr, EXPORT_ALL ); +} + +OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLStylesExporter" ) ); +} + +Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames() + throw() +{ + const OUString aServiceName(SwXMLExportStyles_getImplementationName()); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SwXMLExportStyles_createInstance( + const Reference< XMultiServiceFactory > & rSMgr) + throw( Exception ) +{ + // #110680# + //return (cppu::OWeakObject*)new SwXMLExport( + // EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES | + // EXPORT_FONTDECLS ); + return (cppu::OWeakObject*)new SwXMLExport( + rSMgr, + EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES | EXPORT_FONTDECLS ); +} + +OUString SAL_CALL SwXMLExportContent_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLContentExporter" ) ); +} + +Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames() + throw() +{ + const OUString aServiceName(SwXMLExportContent_getImplementationName()); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SwXMLExportContent_createInstance( + const Reference< XMultiServiceFactory > & rSMgr) + throw( Exception ) +{ + // #110680# + //return (cppu::OWeakObject*)new SwXMLExport( + // EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS | + // EXPORT_FONTDECLS ); + return (cppu::OWeakObject*)new SwXMLExport( + rSMgr, + EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS | + EXPORT_FONTDECLS ); +} + +OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLMetaExporter" ) ); +} + +Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames() + throw() +{ + const OUString aServiceName(SwXMLExportMeta_getImplementationName()); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SwXMLExportMeta_createInstance( + const Reference< XMultiServiceFactory > & rSMgr) + throw( Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLExport(EXPORT_META); + return (cppu::OWeakObject*)new SwXMLExport( rSMgr, EXPORT_META ); +} + +OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLSettingsExporter" ) ); +} + +Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames() + throw() +{ + const OUString aServiceName(SwXMLExportSettings_getImplementationName()); + const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +Reference< XInterface > SAL_CALL SwXMLExportSettings_createInstance( + const Reference< XMultiServiceFactory > & rSMgr) + throw( Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLExport(EXPORT_SETTINGS); + return (cppu::OWeakObject*)new SwXMLExport( rSMgr, EXPORT_SETTINGS ); +} + +const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw() +{ + static Sequence< sal_Int8 > aSeq = ::binfilter::CreateUnoTunnelId(); + return aSeq; +} + +sal_Int64 SAL_CALL SwXMLExport::getSomething( const Sequence< sal_Int8 >& rId ) + throw(RuntimeException) +{ + if( rId.getLength() == 16 + && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + { + return (sal_Int64)this; + } + return SvXMLExport::getSomething( rId ); +} + + +// XServiceInfo +// override empty method from parent class +OUString SAL_CALL SwXMLExport::getImplementationName() + throw(RuntimeException) +{ + switch( getExportFlags() ) + { + case EXPORT_ALL: + return SwXMLExport_getImplementationName(); + break; + case (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS): + return SwXMLExportStyles_getImplementationName(); + break; + case (EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS): + return SwXMLExportContent_getImplementationName(); + break; + case EXPORT_META: + return SwXMLExportMeta_getImplementationName(); + break; + case EXPORT_SETTINGS: + return SwXMLExportSettings_getImplementationName(); + break; + default: + // generic name for 'unknown' cases + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.SwXMLExport" ) ); + break; + } +} + + +#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 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 +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlexpit.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlexpit.cxx new file mode 100644 index 000000000000..8c4b9c9bdaf9 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlexpit.cxx @@ -0,0 +1,1007 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "xmlexpit.hxx" + +#include <bf_xmloff/xmluconv.hxx> + + + + + + + +#include <bf_xmloff/nmspmap.hxx> + +#include <bf_xmloff/xmlnmspe.hxx> + +#include <bf_svx/xmlcnitm.hxx> + +#include <bf_xmloff/xmlexp.hxx> + +#ifndef _SVSTDARR_USHORTS +#define _SVSTDARR_USHORTS +#include <bf_svtools/svstdarr.hxx> +#endif + + + +#include "hintids.hxx" + +#include "unomid.h" + + +#include <bf_svx/lrspitem.hxx> + +#include <bf_svx/ulspitem.hxx> + +#include <bf_svx/shaditem.hxx> + +#include <bf_svx/boxitem.hxx> + +#include <bf_svx/brkitem.hxx> + +#include <bf_svx/keepitem.hxx> + + +#include "fmtpdsc.hxx" + +#include <horiornt.hxx> + +#include "fmtornt.hxx" + +#include "fmtfsize.hxx" + +#include "fmtlsplt.hxx" + + + + +#include "xmlithlp.hxx" +namespace binfilter { + + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; +using ::com::sun::star::uno::Any; + +/** fills the given attribute list with the items in the given set */ +void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList, + const SfxItemSet& rSet, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + sal_uInt16 nFlags, + SvUShorts* pIndexArray ) const +{ + const sal_uInt16 nCount = mrMapEntries->getCount(); + sal_uInt16 nIndex = 0; + + while( nIndex < nCount ) + { + SvXMLItemMapEntry* pEntry = mrMapEntries->getByIndex( nIndex ); + + // we have a valid map entry here, so lets use it... + if( 0 == (pEntry->nMemberId & MID_FLAG_NO_ITEM_EXPORT) ) + { + const SfxPoolItem* pItem = GetItem( rSet, pEntry->nWhichId, + nFlags ); + // do we have an item? + if(pItem) + { + if( 0 != (pEntry->nMemberId & MID_FLAG_ELEMENT_ITEM_EXPORT) ) + { + // element items do not add any properties, + // we export it later + if( pIndexArray ) + pIndexArray->Insert( nIndex, pIndexArray->Count() ); + + } + else + { + exportXML( rAttrList, *pItem, *pEntry, rUnitConverter, + rNamespaceMap, nFlags, &rSet ); + } + } + } + else + { + handleNoItem( rAttrList, *pEntry, rUnitConverter, rNamespaceMap, + rSet ); + } + nIndex++; + } +} + +void SvXMLExportItemMapper::exportXML( SvXMLAttributeList& rAttrList, + const SfxPoolItem& rItem, + const SvXMLItemMapEntry& rEntry, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + sal_uInt16 nFlags, + const SfxItemSet *pSet ) const +{ + if( 0 != (rEntry.nMemberId & MID_FLAG_SPECIAL_ITEM_EXPORT) ) + { + if( rItem.ISA( SvXMLAttrContainerItem ) ) + { + SvXMLNamespaceMap *pNewNamespaceMap = 0; + const SvXMLNamespaceMap *pNamespaceMap = &rNamespaceMap; + + const SvXMLAttrContainerItem *pUnknown = + PTR_CAST( SvXMLAttrContainerItem, &rItem ); + + sal_uInt16 nCount = pUnknown->GetAttrCount(); + OUStringBuffer sName; + for( sal_uInt16 i=0; i < nCount; i++ ) + { + OUString sPrefix( pUnknown->GetAttrPrefix( i ) ); + if( sPrefix.getLength() ) + { + OUString sNamespace( pUnknown->GetAttrNamespace( i ) ); + + // if the prefix isn't defined yet or has another meaning, + // we have to redefine it now. + sal_uInt16 nIdx = pNamespaceMap->GetIndexByPrefix( sPrefix ); + if( USHRT_MAX == nIdx || + pNamespaceMap->GetNameByIndex( nIdx ) != sNamespace ) + { + if( !pNewNamespaceMap ) + { + pNewNamespaceMap = + new SvXMLNamespaceMap( rNamespaceMap ); + pNamespaceMap = pNewNamespaceMap; + } + pNewNamespaceMap->Add( sPrefix, sNamespace ); + + sName.append( GetXMLToken(XML_XMLNS) ); + sName.append( sal_Unicode(':') ); + sName.append( sPrefix ); + rAttrList.AddAttribute( sName.makeStringAndClear(), + sNamespace ); + } + + sName.append( sPrefix ); + sName.append( sal_Unicode(':') ); + } + + sName.append( pUnknown->GetAttrLName( i ) ); + rAttrList.AddAttribute( sName.makeStringAndClear(), + pUnknown->GetAttrValue(i) ); + } + + delete pNewNamespaceMap; + } + else + { + handleSpecialItem( rAttrList, rEntry, rItem, rUnitConverter, + rNamespaceMap, pSet ); + } + } + else if( 0 == (rEntry.nMemberId & MID_FLAG_ELEMENT_ITEM_EXPORT) ) + { + OUString aValue; + if( QueryXMLValue(rItem, aValue, rEntry.nMemberId & MID_FLAG_MASK, + rUnitConverter ) ) + { + OUString sName( + rNamespaceMap.GetQNameByKey( rEntry.nNameSpace, + GetXMLToken(rEntry.eLocalName))); + rAttrList.AddAttribute( sName, aValue ); + } + } +} + +void SvXMLExportItemMapper::exportElementItems( + SvXMLExport& rExport, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet &rSet, + sal_uInt16 nFlags, + const SvUShorts& rIndexArray ) const +{ + const sal_uInt16 nCount = rIndexArray.Count(); + + sal_Bool bItemsExported = sal_False; + for( sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++ ) + { + const sal_uInt16 nElement = rIndexArray.GetObject( nIndex ); + SvXMLItemMapEntry* pEntry = mrMapEntries->getByIndex( nElement ); + DBG_ASSERT( 0 != (pEntry->nMemberId & MID_FLAG_ELEMENT_ITEM_EXPORT), + "wrong mid flag!" ); + + const SfxPoolItem* pItem = GetItem( rSet, pEntry->nWhichId, nFlags ); + // do we have an item? + if(pItem) + { + rExport.IgnorableWhitespace(); + handleElementItem( rExport, *pEntry, *pItem, rUnitConverter, + rSet, nFlags); + bItemsExported = sal_True; + } + } + + if( bItemsExported ) + rExport.IgnorableWhitespace(); +} + +/** returns the item with the givin WhichId from the given ItemSet if its + set or its default item if its not set and the XML_EXPORT_FLAG_DEEP + is set in the flags +*/ +const SfxPoolItem* SvXMLExportItemMapper::GetItem( const SfxItemSet& rSet, + sal_uInt32 nWhichId, + sal_uInt16 nFlags ) +{ + // first get item from itemset + const SfxPoolItem* pItem; + SfxItemState eState = + rSet.GetItemState( nWhichId, + ( nFlags & XML_EXPORT_FLAG_DEEP ) != 0, + &pItem ); + + if( SFX_ITEM_SET == eState ) + { + return pItem; + } + else if( (nFlags & XML_EXPORT_FLAG_DEFAULTS) != 0 && + SFX_WHICH_MAX > nWhichId ) + { + // if its not set, try the pool if we export defaults + return &rSet.GetPool()->GetDefaultItem(nWhichId); + } + else + { + return NULL; + } +} + +SvXMLExportItemMapper::SvXMLExportItemMapper( SvXMLItemMapEntriesRef rMapEntries ) +{ + mrMapEntries = rMapEntries; +} + +SvXMLExportItemMapper::~SvXMLExportItemMapper() +{ +} + +void SvXMLExportItemMapper::exportXML( SvXMLExport& rExport, + const SfxItemSet& rSet, + const SvXMLUnitConverter& rUnitConverter, + sal_uInt16 nFlags ) const +{ + SvUShorts aIndexArray; + + exportXML( rExport.GetAttrList(), rSet, rUnitConverter, + rExport.GetNamespaceMap(), nFlags, &aIndexArray ); + + if( rExport.GetAttrList().getLength() > 0L || + (nFlags & XML_EXPORT_FLAG_EMPTY) != 0 || + aIndexArray.Count() != 0 ) + { + if( (nFlags & XML_EXPORT_FLAG_IGN_WS) != 0 ) + { + rExport.IgnorableWhitespace(); + } + + SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_PROPERTIES, + sal_False, sal_False ); + exportElementItems( rExport, rUnitConverter, + rSet, nFlags, aIndexArray ); + } +} + +/** this method is called for every item that has the + MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ +void SvXMLExportItemMapper::handleSpecialItem( SvXMLAttributeList& rAttrList, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const SfxItemSet* pSet /* = NULL */ ) const +{ + DBG_ERROR( "special item not handled in xml export" ); +} + +/** this method is called for every item that has the + MID_FLAG_NO_ITEM_EXPORT flag set */ +void SvXMLExportItemMapper::handleNoItem( SvXMLAttributeList& rAttrList, + const SvXMLItemMapEntry& rEntry, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const SfxItemSet& rSet ) const +{ + DBG_ERROR( "no item not handled in xml export" ); +} + +/** this method is called for every item that has the + MID_FLAG_ELEMENT_EXPORT flag set */ +void SvXMLExportItemMapper::handleElementItem( + SvXMLExport& rExport, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet& rSet, + sal_uInt16 nFlags ) const +{ + DBG_ERROR( "element item not handled in xml export" ); +} + + +sal_Bool SvXMLExportItemMapper::QueryXMLValue( + const SfxPoolItem& rItem, + OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bOk = sal_False; + OUStringBuffer aOut; + + switch ( rItem.Which() ) + { + + case ITEMID_LRSPACE: + { + const SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem); + DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" ); + + bOk = sal_True; + switch( nMemberId ) + { + case MID_L_MARGIN: + if(pLRSpace->GetPropLeft() != 100) + rUnitConverter.convertPercent( aOut, pLRSpace->GetPropLeft() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtLeft() ); + break; + + case MID_R_MARGIN: + if(pLRSpace->GetPropRight() != 100) + rUnitConverter.convertPercent( aOut, pLRSpace->GetPropRight() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetRight() ); + break; + + case MID_FIRST_AUTO: + if( pLRSpace->IsAutoFirst() ) + rUnitConverter.convertBool( aOut, pLRSpace->IsAutoFirst() ); + else + bOk = sal_False; + break; + + case MID_FIRST_LINE_INDENT: + if( !pLRSpace->IsAutoFirst() ) + { + if(pLRSpace->GetPropTxtFirstLineOfst() != 100) + rUnitConverter.convertPercent( + aOut, pLRSpace->GetPropTxtFirstLineOfst() ); + else + rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtFirstLineOfst() ); + } + else + bOk = sal_False; + break; + + default: + DBG_ERROR( "unknown member id!"); + bOk = sal_False; + break; + } + } + break; + + case ITEMID_ULSPACE: + { + const SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem); + DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" ); + + switch( nMemberId ) + { + case MID_UP_MARGIN: + if( pULSpace->GetPropUpper() != 100 ) + rUnitConverter.convertPercent( aOut, pULSpace->GetPropUpper() ); + else + rUnitConverter.convertMeasure( aOut, pULSpace->GetUpper() ); + break; + + case MID_LO_MARGIN: + if( pULSpace->GetPropLower() != 100 ) + rUnitConverter.convertPercent( aOut, pULSpace->GetPropLower() ); + else + rUnitConverter.convertMeasure( aOut, pULSpace->GetLower() ); + break; + + default: + DBG_ERROR("unknown MemberId"); + }; + + bOk = sal_True; + } + break; + + case ITEMID_SHADOW: + { + const SvxShadowItem* pShadow = PTR_CAST(SvxShadowItem, &rItem); + DBG_ASSERT( pShadow != NULL, "Wrong Which-ID" ); + + sal_Int32 nX = 1, nY = 1; + switch( pShadow->GetLocation() ) + { + case SVX_SHADOW_TOPLEFT: + nX = -1; + nY = -1; + break; + case SVX_SHADOW_TOPRIGHT: + nY = -1; + break; + case SVX_SHADOW_BOTTOMLEFT: + nX = -1; + break; + case SVX_SHADOW_BOTTOMRIGHT: + break; + case SVX_SHADOW_NONE: + default: + rValue = GetXMLToken(XML_NONE); + return sal_True; + } + + nX *= pShadow->GetWidth(); + nY *= pShadow->GetWidth(); + + rUnitConverter.convertColor( aOut, pShadow->GetColor() ); + aOut.append( sal_Unicode(' ') ); + rUnitConverter.convertMeasure( aOut, nX ); + aOut.append( sal_Unicode(' ') ); + rUnitConverter.convertMeasure( aOut, nY ); + + bOk = sal_True; + } + break; + + case ITEMID_BOX: + { + SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem); + DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" ); + + /** + xml -> MemberId + + border-padding ALL_BORDER_PADDING + border-padding-before LEFT_BORDER_PADDING + border-padding-after RIGHT_BORDER_PADDING + border-padding-start TOP_BORDER_PADDING + border-padding-end BOTTOM_BORDER_PADDING + + border ALL_BORDER + border-before LEFT_BORDER + border-after RIGHT_BORDER + border-start TOP_BORDER + border-end BOTTOM_BORDER + + border-line-width ALL_BORDER_LINE_WIDTH + border-line-width-before LEFT_BORDER_LINE_WIDTH + border-line-width-after RIGHT_BORDER_LINE_WIDTH + border-line-width-start TOP_BORDER_LINE_WIDTH + border-line-width-end BOTTOM_BORDER_LINE_WIDTH + */ + + const SvxBorderLine* pLeft = pBox->GetLeft(); + const SvxBorderLine* pRight = pBox->GetRight(); + const SvxBorderLine* pTop = pBox->GetTop(); + const SvxBorderLine* pBottom = pBox->GetBottom(); + sal_uInt16 nTopDist = pBox->GetDistance( BOX_LINE_TOP ); + sal_uInt16 nBottomDist = pBox->GetDistance( BOX_LINE_BOTTOM ); + sal_uInt16 nLeftDist = pBox->GetDistance( BOX_LINE_LEFT ); + sal_uInt16 nRightDist = pBox->GetDistance( BOX_LINE_RIGHT ); + + + // check if we need to export it + switch( nMemberId ) + { + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + case RIGHT_BORDER_PADDING: + case TOP_BORDER_PADDING: + case BOTTOM_BORDER_PADDING: + { + sal_Bool bEqual = nLeftDist == nRightDist && + nLeftDist == nTopDist && + nLeftDist == nBottomDist; + // don't export individual paddings if all paddings are equal and + // don't export all padding if some paddings are not equal + if( (bEqual && ALL_BORDER_PADDING != nMemberId) || + (!bEqual && ALL_BORDER_PADDING == nMemberId) ) + return sal_False; + } + break; + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + sal_Bool bEqual = ( NULL == pTop && NULL == pBottom && + NULL == pLeft && NULL == pRight ) || + ( pTop && pBottom && pLeft && pRight && + *pTop == *pBottom && *pTop == *pLeft && + *pTop == *pRight ); + + // don't export individual borders if all are the same and + // don't export all borders if some are not equal + if( (bEqual && ALL_BORDER != nMemberId) || + (!bEqual && ALL_BORDER == nMemberId) ) + return sal_False; + } + break; + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + { + // if no line is set, there is nothing to export + if( !pTop && !pBottom && !pLeft && !pRight ) + return sal_False; + + sal_Bool bEqual = NULL != pTop && + NULL != pBottom && + NULL != pLeft && + NULL != pRight; + + if( bEqual ) + { + const sal_uInt16 nDistance = pTop->GetDistance(); + const sal_uInt16 nInWidth = pTop->GetInWidth(); + const sal_uInt16 nOutWidth = pTop->GetOutWidth(); + + bEqual = nDistance == pLeft->GetDistance() && + nInWidth == pLeft->GetInWidth() && + nOutWidth == pLeft->GetOutWidth() && + nDistance == pRight->GetDistance() && + nInWidth == pRight->GetInWidth() && + nOutWidth == pRight->GetOutWidth() && + nDistance == pBottom->GetDistance() && + nInWidth == pBottom->GetInWidth() && + nOutWidth == pBottom->GetOutWidth(); + } + + switch( nMemberId ) + { + case ALL_BORDER_LINE_WIDTH: + if( !bEqual || pTop->GetDistance() == 0 ) + return sal_False; + break; + case LEFT_BORDER_LINE_WIDTH: + if( bEqual || NULL == pLeft || + 0 == pLeft->GetDistance() ) + return sal_False; + break; + case RIGHT_BORDER_LINE_WIDTH: + if( bEqual || NULL == pRight || + 0 == pRight->GetDistance() ) + return sal_False; + break; + case TOP_BORDER_LINE_WIDTH: + if( bEqual || NULL == pTop || + 0 == pTop->GetDistance() ) + return sal_False; + break; + case BOTTOM_BORDER_LINE_WIDTH: + if( bEqual || NULL == pBottom || + 0 == pBottom->GetDistance() ) + return sal_False; + break; + } + } + break; + } + + // now export it export + switch( nMemberId ) + { + // padding + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nLeftDist ); + break; + case RIGHT_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nRightDist ); + break; + case TOP_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nTopDist ); + break; + case BOTTOM_BORDER_PADDING: + rUnitConverter.convertMeasure( aOut, nBottomDist ); + break; + + // border + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + const SvxBorderLine* pLine; + switch( nMemberId ) + { + case ALL_BORDER: + case LEFT_BORDER: + pLine = pLeft; + break; + case RIGHT_BORDER: + pLine = pRight; + break; + case TOP_BORDER: + pLine = pTop; + break; + case BOTTOM_BORDER: + pLine = pBottom; + break; + default: + pLine = NULL; + break; + } + + if( NULL != pLine ) + { + sal_Int32 nWidth = pLine->GetOutWidth(); + const sal_uInt16 nDistance = pLine->GetDistance(); + if( 0 != nDistance ) + { + nWidth += nDistance; + nWidth += pLine->GetInWidth(); + } + + enum XMLTokenEnum eStyle = + (0 == nDistance) ? XML_SOLID : XML_DOUBLE; + + rUnitConverter.convertMeasure( aOut, nWidth ); + aOut.append( sal_Unicode( ' ' ) ); + aOut.append( GetXMLToken( eStyle ) ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertColor( aOut, pLine->GetColor() ); + + } + else + { + aOut.append( GetXMLToken(XML_NONE) ); + } + } + break; + + // width + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + const SvxBorderLine* pLine; + switch( nMemberId ) + { + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + pLine = pLeft; + break; + case RIGHT_BORDER_LINE_WIDTH: + pLine = pRight; + break; + case TOP_BORDER_LINE_WIDTH: + pLine = pTop; + break; + case BOTTOM_BORDER_LINE_WIDTH: + pLine = pBottom; + break; + default: + return sal_False; + } + rUnitConverter.convertMeasure( aOut, pLine->GetInWidth() ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertMeasure( aOut, pLine->GetDistance() ); + aOut.append( sal_Unicode( ' ' ) ); + rUnitConverter.convertMeasure( aOut, pLine->GetOutWidth() ); + break; + } + + bOk = sal_True; + } + break; + + case ITEMID_FMTBREAK: + { + const SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem); + DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" ); + + sal_uInt16 eEnum = 0; + + switch( nMemberId ) + { + case MID_BREAK_BEFORE: + switch( pFmtBreak->GetValue() ) + { + case SVX_BREAK_COLUMN_BEFORE: + eEnum = 1; + break; + case SVX_BREAK_PAGE_BEFORE: + eEnum = 2; + break; + case SVX_BREAK_NONE: + eEnum = 0; + break; + default: + return sal_False; + } + break; + case MID_BREAK_AFTER: + switch( pFmtBreak->GetValue() ) + { + case SVX_BREAK_COLUMN_AFTER: + eEnum = 1; + break; + case SVX_BREAK_PAGE_AFTER: + eEnum = 2; + break; + case SVX_BREAK_NONE: + eEnum = 0; + break; + default: + return sal_False; + } + break; + } + + bOk = rUnitConverter.convertEnum( aOut, eEnum, psXML_BreakType ); + } + break; + + case ITEMID_FMTKEEP: + { + SvxFmtKeepItem* pFmtKeep = PTR_CAST(SvxFmtKeepItem, &rItem); + DBG_ASSERT( pFmtKeep != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertBool( aOut, pFmtKeep->GetValue() ); + bOk = sal_True; + } + break; + + case ITEMID_BRUSH: + { + SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem); + DBG_ASSERT( pBrush != NULL, "Wrong Which-ID" ); + + // note: the graphic is only exported if nMemberId equals + // MID_GRAPHIC.. + // If not, only the color or transparency is exported + + switch( nMemberId ) + { + case MID_BACK_COLOR: + if ( pBrush->GetColor().GetTransparency() ) + aOut.append( GetXMLToken(XML_TRANSPARENT) ); + else + rUnitConverter.convertColor( aOut, pBrush->GetColor()); + bOk = sal_True; + break; + + case MID_GRAPHIC_LINK: + if( pBrush->GetGraphicPos() != GPOS_NONE ) + { + uno::Any aAny; + pBrush->QueryValue( aAny, MID_GRAPHIC_URL ); + OUString sTmp; + aAny >>= sTmp; + aOut.append( sTmp ); + bOk = sal_True; + } + break; + + case MID_GRAPHIC_POSITION: + switch( pBrush->GetGraphicPos() ) + { + case GPOS_LT: + case GPOS_MT: + case GPOS_RT: + aOut.append( GetXMLToken(XML_TOP) ); + bOk = sal_True; + break; + case GPOS_LM: + case GPOS_MM: + case GPOS_RM: + aOut.append( GetXMLToken(XML_CENTER) ); + bOk = sal_True; + break; + case GPOS_LB: + case GPOS_MB: + case GPOS_RB: + aOut.append( GetXMLToken(XML_BOTTOM) ); + bOk = sal_True; + break; + } + + if( bOk ) + { + aOut.append( sal_Unicode( ' ' ) ); + + switch( pBrush->GetGraphicPos() ) + { + case GPOS_LT: + case GPOS_LB: + case GPOS_LM: + aOut.append( GetXMLToken(XML_LEFT) ); + break; + case GPOS_MT: + case GPOS_MM: + case GPOS_MB: + aOut.append( GetXMLToken(XML_CENTER) ); + break; + case GPOS_RM: + case GPOS_RT: + case GPOS_RB: + aOut.append( GetXMLToken(XML_RIGHT) ); + break; + } + } + break; + + case MID_GRAPHIC_REPEAT: + { + SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos(); + if( GPOS_AREA == eGraphicPos ) + { + aOut.append( GetXMLToken(XML_BACKGROUND_STRETCH) ); + bOk = sal_True; + } + else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos ) + { + aOut.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT) ); + bOk = sal_True; + } + } + break; + + case MID_GRAPHIC_FILTER: + if( pBrush->GetGraphicPos() != GPOS_NONE && + pBrush->GetGraphicFilter() ) + { + aOut.append( pBrush->GetGraphicFilter()->GetBuffer() ); + bOk = sal_True; + } + break; + } + } + break; + + case RES_PAGEDESC: + { + const SwFmtPageDesc* pPageDesc = PTR_CAST(SwFmtPageDesc, &rItem); + DBG_ASSERT( pPageDesc != NULL, "Wrong Which-ID" ); + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + + rUnitConverter.convertNumber( + aOut, (sal_Int32)pPageDesc->GetNumOffset() ); + bOk = sal_True; + } + } + break; + + case RES_LAYOUT_SPLIT: + { + const SwFmtLayoutSplit* pLayoutSplit = PTR_CAST(SwFmtLayoutSplit, &rItem); + DBG_ASSERT( pLayoutSplit != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertBool( aOut, pLayoutSplit->GetValue() ); + bOk = sal_True; + } + break; + + case RES_HORI_ORIENT: + { + SwFmtHoriOrient* pHoriOrient = PTR_CAST(SwFmtHoriOrient, &rItem); + DBG_ASSERT( pHoriOrient != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertEnum( aOut, pHoriOrient->GetHoriOrient(), + aXMLTableAlignMap ); + bOk = sal_True; + } + break; + + case RES_VERT_ORIENT: + { + SwFmtVertOrient* pVertOrient = PTR_CAST(SwFmtVertOrient, &rItem); + DBG_ASSERT( pVertOrient != NULL, "Wrong Which-ID" ); + + rUnitConverter.convertEnum( aOut, pVertOrient->GetVertOrient(), + aXMLTableVAlignMap ); + bOk = sal_True; + } + break; + + case RES_FRM_SIZE: + { + SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem); + DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" ); + + sal_Bool bOutHeight = sal_False; + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + if( pFrmSize->GetWidthPercent() ) + { + rUnitConverter.convertPercent( aOut, pFrmSize->GetWidthPercent() ); + bOk = sal_True; + } + break; + case MID_FRMSIZE_MIN_HEIGHT: + if( ATT_MIN_SIZE == pFrmSize->GetSizeType() ) + bOutHeight = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + if( ATT_FIX_SIZE == pFrmSize->GetSizeType() ) + bOutHeight = sal_True; + break; + } + + if( bOutHeight ) + { + rUnitConverter.convertMeasure( aOut, pFrmSize->GetHeight() ); + bOk = sal_True; + } + } + break; + + case RES_FRAMEDIR: + { + Any aAny; + bOk = rItem.QueryValue( aAny ); + if( bOk ) + { + const XMLPropertyHandler* pWritingModeHandler = + XMLPropertyHandlerFactory::CreatePropertyHandler( + XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT ); + OUString sValue; + bOk = pWritingModeHandler->exportXML( sValue, aAny, + rUnitConverter ); + if( bOk ) + aOut.append( sValue ); + } + } + break; + + default: + DBG_ERROR("GetXMLValue not implemented for this item."); + break; + } + + if ( bOk ) + rValue = aOut.makeStringAndClear(); + + return bOk; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlfmt.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlfmt.cxx new file mode 100644 index 000000000000..dfd7b00a29e7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlfmt.cxx @@ -0,0 +1,1136 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <rtl/ustrbuf.hxx> + +#include <tools/urlobj.hxx> + +#ifndef _SVSTDARR_STRINGSSORT_DECL +#define _SVSTDARR_STRINGSSORT +#include <bf_svtools/svstdarr.hxx> +#endif + +#include <bf_xmloff/nmspmap.hxx> + +#include <format.hxx> + +#include <errhdl.hxx> + +#include <fmtcol.hxx> +#include <hints.hxx> +#include <unoobj.hxx> + +#include <poolfmt.hxx> +#include <charfmt.hxx> +#include <frmfmt.hxx> +#include <paratr.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include "docary.hxx" +#include "unostyle.hxx" +#include "fmtpdsc.hxx" +#include "pagedesc.hxx" + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/i18nmap.hxx> +#include <bf_xmloff/xmltkmap.hxx> +#include "xmlitem.hxx" +#include <bf_xmloff/xmlstyle.hxx> +#include <bf_xmloff/xmltoken.hxx> +#include <bf_xmloff/txtstyli.hxx> +#include <bf_xmloff/txtimp.hxx> +#include <bf_xmloff/families.hxx> +#include <bf_xmloff/XMLTextMasterStylesContext.hxx> +#include <bf_xmloff/XMLTextShapeStyleContext.hxx> +#include <bf_xmloff/XMLGraphicsDefaultStyle.hxx> + +#include <numrule.hxx> +#include "xmlimp.hxx" +#include "xmltbli.hxx" +#include "cellatr.hxx" +#include <SwStyleNameMapper.hxx> +namespace binfilter { + + +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 ::binfilter::xmloff::token; + +using rtl::OUString; +using rtl::OUStringBuffer; + +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 ) + { + if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub ) + nCondition = PARA_IN_ENDNOTE; + else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub ) + nCondition = PARA_IN_FOOTER; + else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub ) + nCondition = PARA_IN_FOOTENOTE; + else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub ) + nCondition = PARA_IN_HEADER; + else if( IsXMLToken( sFunc, XML_LIST_LEVEL) && + nSub >=1 && nSub <= MAXLEVEL ) + { + nCondition = PARA_IN_LIST; + nSubCondition = nSub-1; + } + else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) && + nSub >=1 && nSub <= MAXLEVEL ) + { + nCondition = PARA_IN_OUTLINE; + nSubCondition = nSub-1; + } + else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub ) + { + nCondition = PARA_IN_SECTION; + } + else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub ) + { + nCondition = PARA_IN_TABLEBODY; + } + else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub ) + { + nCondition = PARA_IN_TABLEHEAD; + } + else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub ) + { + nCondition = PARA_IN_FRAME; + } + } +} + +// --------------------------------------------------------------------- + +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( IsXMLToken( aLocalName, XML_CONDITION ) ) + { + SwXMLConditionParser_Impl aCondParser( rValue ); + if( aCondParser.IsValid() ) + { + nCondition = aCondParser.GetCondition(); + nSubCondition = aCondParser.GetSubCondition(); + } + } + else if( IsXMLToken( aLocalName, XML_APPLY_STYLE_NAME ) ) + { + sApplyStyle = rValue; + } + } + } +} + +SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl() +{ +} + +// --------------------------------------------------------------------- + +typedef SwXMLConditionContext_Impl *SwXMLConditionContextPtr; +SV_DECL_PTRARR( SwXMLConditions_Impl, SwXMLConditionContextPtr, 5, 2 )//STRIP008 ; + +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, nFamily ), + pConditions( 0 ) +{ +} + +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 && IsXMLToken( rLocalName, XML_MAP ) ) + { + 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; + + const SwDoc *pDoc = pStyle->GetDoc(); + + SwTxtFmtColl *pColl = pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() ); + ASSERT( pColl, "Text collection not found" ); + if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() ) + return; + + sal_uInt16 nCount = pConditions->Count(); + String aString; + OUString sName; + for( sal_uInt16 i = 0; i < nCount; i++ ) + { + const SwXMLConditionContext_Impl *pCond = (*pConditions)[i]; + SwStyleNameMapper::FillUIName( pCond->GetApplyStyle(), + aString, + GET_POOLID_TXTCOLL, + sal_True); + sName = aString; + SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName ); + ASSERT( pCondColl, + "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" ); + if( pCondColl ) + { + SwCollCondition aCond( pCondColl, pCond->GetCondition(), + pCond->GetSubCondition() ); + ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond ); + } + } +} + +// --------------------------------------------------------------------- + +class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext +{ + OUString sMasterPageName; + SfxItemSet *pItemSet; + + OUString sDataStyleName; + + sal_Bool bHasMasterPageName : 1; + sal_Bool bPageDescConnected : 1; + sal_Bool bDataStyleIsResolved; + + SvXMLImportContext *CreateItemSetContext( + sal_uInt16 nPrefix, + const OUString& rLName, + const Reference< xml::sax::XAttributeList > & xAttrList); + +protected: + + virtual void SetAttribute( sal_uInt16 nPrefixKey, + const OUString& rLocalName, + const OUString& rValue ); + + 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, + sal_uInt16 nFamily); + virtual ~SwXMLItemSetStyleContext_Impl(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ); + + // The item set may be empty! + SfxItemSet *GetItemSet() { return pItemSet; } + const SfxItemSet *GetItemSet() const { return pItemSet; } + + const OUString& GetMasterPageName() const { return sMasterPageName; } + sal_Bool HasMasterPageName() const { return bHasMasterPageName; } + + sal_Bool IsPageDescConnected() const { return bPageDescConnected; } + void ConnectPageDesc(); + + sal_Bool ResolveDataStyleName(); +}; + +void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey, + const OUString& rLocalName, + const OUString& rValue ) +{ + if( XML_NAMESPACE_STYLE == nPrefixKey ) + { + if ( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) ) + { + sMasterPageName = rValue; + bHasMasterPageName = sal_True; + } + else if ( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) ) + { + // if we have a valid data style name + if (rValue.getLength() > 0) + { + sDataStyleName = rValue; + bDataStyleIsResolved = sal_False; // needs to be resolved + } + } + else + { + SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); + } + } + else + { + SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); + } +} + +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; + + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SfxItemPool& rItemPool = pTxtCrsr->GetDoc()->GetAttrPool(); + 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 ); + 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, + sal_uInt16 nFamily ) : + SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, nFamily ), + pItemSet( 0 ), + bHasMasterPageName( sal_False ), + bPageDescConnected( sal_False ), + sDataStyleName(), + bDataStyleIsResolved( sal_True ) +{ +} + +SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl() +{ + delete pItemSet; +} + +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( IsXMLToken( rLocalName, XML_PROPERTIES ) ) + { + pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList ); + } + } + + if( !pContext ) + pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName, + xAttrList ); + + return pContext; +} + +void SwXMLItemSetStyleContext_Impl::ConnectPageDesc() +{ + if( bPageDescConnected || !HasMasterPageName() ) + return; + bPageDescConnected = sal_True; + + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + String sName; + SwStyleNameMapper::FillUIName( GetMasterPageName(), + sName, + GET_POOLID_PAGEDESC, + sal_True); + SwPageDesc *pPageDesc = pDoc->FindPageDescByName( sName ); + if( !pPageDesc ) + { + // If the page style is a pool style, then we maybe have to create it + // first if it hasn't been used by now. + sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sName, GET_POOLID_PAGEDESC ); + if( USHRT_MAX != nPoolId ) + pPageDesc = pDoc->GetPageDescFromPoolSimple( nPoolId, FALSE ); + } + + if( !pPageDesc ) + return; + + if( !pItemSet ) + { + SfxItemPool& rItemPool = pDoc->GetAttrPool(); + pItemSet = new SfxItemSet( rItemPool, aTableSetRange ); + } + + const SfxPoolItem *pItem; + SwFmtPageDesc *pFmtPageDesc = 0; + if( SFX_ITEM_SET == pItemSet->GetItemState( RES_PAGEDESC, sal_False, + &pItem ) ) + { + if( ((SwFmtPageDesc *)pItem)->GetPageDesc() != pPageDesc ) + pFmtPageDesc = new SwFmtPageDesc( *(SwFmtPageDesc *)pItem ); + } + else + pFmtPageDesc = new SwFmtPageDesc(); + + if( pFmtPageDesc ) + { + pPageDesc->Add( pFmtPageDesc ); + pItemSet->Put( *pFmtPageDesc ); + delete pFmtPageDesc; + } +} + +sal_Bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName() +{ + sal_Bool bTmp = bDataStyleIsResolved; + + // resolve, if not already done + if (! bDataStyleIsResolved) + { + // get the format key + sal_Int32 nFormat = + GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName); + + // if the key is valid, insert Item into ItemSet + if( -1 != nFormat ) + { + if( !pItemSet ) + { + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + SfxItemPool& rItemPool = pDoc->GetAttrPool(); + pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange ); + } + SwTblBoxNumFormat aNumFormatItem(nFormat); + pItemSet->Put(aNumFormatItem); + } + + // now resolved + bDataStyleIsResolved = sal_True; + return sal_True; + } + else + { + // was already resolved; nothing to do + return sal_False; + } +} + +// --------------------------------------------------------------------- +// +class SwXMLStylesContext_Impl : public SvXMLStylesContext +{ + sal_Bool bAutoStyles; + + SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const; + + SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); } + const SwXMLImport& GetSwImport() const + { return (const SwXMLImport&)GetImport(); } + +protected: + + virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily, + sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ); + virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext( + 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 + +public: + + TYPEINFO(); + + SwXMLStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName , + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Bool bAuto ); + virtual ~SwXMLStylesContext_Impl(); + + virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; + + virtual void EndElement(); +}; + +TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext ); + +inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle( + sal_uInt16 i ) const +{ + return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) ); +} + +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: + // As long as there are no element items, we can use the text + // style class. + pStyle = new XMLTextShapeStyleContext( GetImport(), nPrefix, + rLocalName, xAttrList, *this, nFamily ); + break; + default: + pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily, + nPrefix, + rLocalName, + xAttrList ); + break; + } + + return pStyle; +} + +SvXMLStyleContext *SwXMLStylesContext_Impl::CreateDefaultStyleStyleChildContext( + sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStyleContext *pStyle = 0; + + switch( nFamily ) + { + case XML_STYLE_FAMILY_TEXT_PARAGRAPH: + pStyle = new XMLTextStyleContext( GetImport(), nPrefix, rLocalName, + xAttrList, *this, nFamily, + sal_True ); + break; + case XML_STYLE_FAMILY_SD_GRAPHICS_ID: + // There are no writer specific defaults for graphic styles! + pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix, + rLocalName, xAttrList, *this ); + break; + default: + pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, + nPrefix, + rLocalName, + xAttrList ); + break; + } + + return pStyle; +} + + +SwXMLStylesContext_Impl::SwXMLStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Bool bAuto ) : + SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ), + bAutoStyles( bAuto ) +{ +} + +SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl() +{ +} + +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: + case XML_STYLE_FAMILY_TEXT_FOOTNOTECONFIG: + case XML_STYLE_FAMILY_TEXT_ENDNOTECONFIG: + case XML_STYLE_FAMILY_TEXT_LINENUMBERINGCONFIG: + case XML_STYLE_FAMILY_TEXT_BIBLIOGRAPHYCONFIG: + bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode() || + rSwImport.IsBlockMode()); + 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; +} + +void SwXMLStylesContext_Impl::EndElement() +{ + GetSwImport().InsertStyles( bAutoStyles ); +} + +// --------------------------------------------------------------------- +// +class SwXMLMasterStylesContext_Impl : public XMLTextMasterStylesContext +{ +protected: + virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; + + SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); } + const SwXMLImport& GetSwImport() const + { return (const SwXMLImport&)GetImport(); } + +public: + + TYPEINFO(); + + SwXMLMasterStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName , + const Reference< xml::sax::XAttributeList > & xAttrList ); + virtual ~SwXMLMasterStylesContext_Impl(); + virtual void EndElement(); +}; + +TYPEINIT1( SwXMLMasterStylesContext_Impl, XMLTextMasterStylesContext ); + +SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName , + const Reference< xml::sax::XAttributeList > & xAttrList ) : + XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList ) +{ +} + +SwXMLMasterStylesContext_Impl::~SwXMLMasterStylesContext_Impl() +{ +} + +sal_Bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const +{ + sal_Bool bIns; + + const SwXMLImport& rSwImport = GetSwImport(); + sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask(); + if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily ) + bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0; + else + bIns = XMLTextMasterStylesContext::InsertStyleFamily( nFamily ); + + return bIns; +} + +void SwXMLMasterStylesContext_Impl::EndElement() +{ + FinishStyles( !GetSwImport().IsInsertMode() ); + GetSwImport().FinishStyles(); +} +// --------------------------------------------------------------------- + +SvXMLImportContext *SwXMLImport::CreateStylesContext( + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_Bool bAuto ) +{ + SvXMLStylesContext *pContext = + new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName, + xAttrList, bAuto ); + if( bAuto ) + SetAutoStyles( pContext ); + else + SetStyles( pContext ); + + return pContext; +} + +SvXMLImportContext *SwXMLImport::CreateMasterStylesContext( + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLStylesContext *pContext = + new SwXMLMasterStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName, + xAttrList ); + SetMasterStyles( pContext ); + + return pContext; +} + +void SwXMLImport::InsertStyles( sal_Bool bAuto ) +{ + if( !bAuto && GetStyles() ) + GetStyles()->CopyStylesToDoc( !IsInsertMode(), sal_False ); +} + +void SwXMLImport::FinishStyles() +{ + if( GetStyles() ) + GetStyles()->FinishStyles( !IsInsertMode() ); +} + +void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc ) +{ + if( !pDoc ) + { + Reference<XUnoTunnel> xCrsrTunnel( GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + pDoc = pTxtCrsr->GetDoc(); + + ASSERT( pDoc, "document missing" ); + } + + const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls(); + sal_uInt16 nCount = rColls.Count(); + for( sal_uInt16 i=0; i < nCount; i++ ) + { + SwTxtFmtColl *pColl = rColls[i]; + if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() ) + { + const SwFmtCollConditions& rConditions = + ((const SwConditionTxtFmtColl *)pColl)->GetCondColls(); + sal_Bool bSendModify = sal_False; + for( sal_uInt16 j=0; j < rConditions.Count() && !bSendModify; j++ ) + { + const SwCollCondition& rCond = *rConditions[j]; + switch( rCond.GetCondition() ) + { + case PARA_IN_TABLEHEAD: + case PARA_IN_TABLEBODY: + case PARA_IN_FOOTER: + case PARA_IN_HEADER: + bSendModify = sal_True; + break; + } + } + if( bSendModify ) + { + SwCondCollCondChg aMsg( pColl ); + pColl->Modify( &aMsg, &aMsg ); + } + } + } +} + +sal_Bool SwXMLImport::FindAutomaticStyle( + sal_uInt16 nFamily, + const OUString& rName, + const SfxItemSet **ppItemSet, + OUString *pParent ) const +{ + SwXMLItemSetStyleContext_Impl *pStyle = 0; + if( GetAutoStyles() ) + { + pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl, + GetAutoStyles()-> + FindStyleChildContext( nFamily, rName, + sal_True ) ); + if( pStyle ) + { + if( ppItemSet ) + { + if( XML_STYLE_FAMILY_TABLE_TABLE == pStyle->GetFamily() && + pStyle->HasMasterPageName() && + !pStyle->IsPageDescConnected() ) + pStyle->ConnectPageDesc(); + (*ppItemSet) = pStyle->GetItemSet(); + + // resolve data style name late + if( XML_STYLE_FAMILY_TABLE_CELL == pStyle->GetFamily() && + pStyle->ResolveDataStyleName() ) + { + (*ppItemSet) = pStyle->GetItemSet(); + } + + } + + if( pParent ) + *pParent = pStyle->GetParent(); + } + } + + return pStyle != 0; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlfmte.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlfmte.cxx new file mode 100644 index 000000000000..ae019ac924d0 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlfmte.cxx @@ -0,0 +1,362 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <com/sun/star/text/XTextDocument.hpp> + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/attrlist.hxx> +#include "xmlexpit.hxx" +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/XMLTextListAutoStylePool.hxx> +#ifndef _XMLOFF_XMLTEXTMASTERPAGEEXPORT +#include <bf_xmloff/XMLTextMasterPageExport.hxx> +#endif + +#include <bf_xmloff/txtprmap.hxx> +#include <bf_xmloff/xmlaustp.hxx> +#include <bf_xmloff/families.hxx> +#include <bf_xmloff/ProgressBarHelper.hxx> + +#include <format.hxx> +#include <fmtpdsc.hxx> +#include <pagedesc.hxx> + +#include <cppuhelper/implbase4.hxx> + +#include <unostyle.hxx> +#include <cellatr.hxx> + +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include "xmlexp.hxx" +#include <SwStyleNameMapper.hxx> +namespace binfilter { + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::lang; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; + +void SwXMLExport::ExportFmt( const SwFmt& rFmt, enum XMLTokenEnum eFamily ) +{ + // <style:style ...> + CheckAttrList(); + + // style:family="..." + DBG_ASSERT( RES_FRMFMT==rFmt.Which(), "frame format expected" ); + if( RES_FRMFMT != rFmt.Which() ) + return; + DBG_ASSERT( eFamily != XML_TOKEN_INVALID, "family must be specified" ); + // style:name="..." + AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, rFmt.GetName() ); + + if( eFamily != XML_TOKEN_INVALID ) + AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, eFamily ); + + // style:parent-style-name="..." (if its not the default only) + const SwFmt* pParent = rFmt.DerivedFrom(); + // Parent-Namen nur uebernehmen, wenn kein Default + ASSERT( !pParent || pParent->IsDefault(), "unexpected parent" ); + + ASSERT( USHRT_MAX == rFmt.GetPoolFmtId(), "pool ids arent'supported" ); + ASSERT( USHRT_MAX == rFmt.GetPoolHelpId(), "help ids arent'supported" ); + ASSERT( USHRT_MAX == rFmt.GetPoolHelpId() || + UCHAR_MAX == rFmt.GetPoolHlpFileId(), "help file ids aren't supported" ); + + // style:master-page-name + if( RES_FRMFMT == rFmt.Which() && XML_TABLE == eFamily ) + { + const SfxPoolItem *pItem; + if( SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState( RES_PAGEDESC, + sal_False, &pItem ) ) + { + String sName; + const SwPageDesc *pPageDesc = + ((const SwFmtPageDesc *)pItem)->GetPageDesc(); + if( pPageDesc ) + SwStyleNameMapper::FillProgName( + pPageDesc->GetName(), + sName, + GET_POOLID_PAGEDESC, + sal_True); + AddAttribute( XML_NAMESPACE_STYLE, XML_MASTER_PAGE_NAME, sName ); + } + } + + if( XML_TABLE_CELL == eFamily ) + { + DBG_ASSERT(RES_FRMFMT == rFmt.Which(), "only frame format"); + + const SfxPoolItem *pItem; + if( SFX_ITEM_SET == + rFmt.GetAttrSet().GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + { + sal_Int32 nFormat = (sal_Int32) + ((const SwTblBoxNumFormat *)pItem)->GetValue(); + + if ( (nFormat != -1) && (nFormat != NUMBERFORMAT_TEXT) ) + { + // if we have a format, register and then export + // (Careful: here we assume that data styles will be + // written after cell styles) + addDataStyle(nFormat); + OUString sDataStyleName = getDataStyleName(nFormat); + if( sDataStyleName.getLength() > 0 ) + AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, + sDataStyleName ); + } + } + } + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, + sal_True, sal_True ); + + SvXMLItemMapEntriesRef xItemMap; + if( XML_TABLE == eFamily ) + xItemMap = xTableItemMap; + else if( XML_TABLE_ROW == eFamily ) + xItemMap = xTableRowItemMap; + else if( XML_TABLE_CELL == eFamily ) + xItemMap = xTableCellItemMap; + + if( xItemMap.Is() ) + { + SvXMLExportItemMapper& rItemMapper = GetTableItemMapper(); + rItemMapper.setMapEntries( xItemMap ); + + GetTableItemMapper().exportXML( *this, + rFmt.GetAttrSet(), + GetTwipUnitConverter(), + XML_EXPORT_FLAG_IGN_WS ); + } + } +} + + +void SwXMLExport::_ExportStyles( sal_Bool bUsed ) +{ + SvXMLExport::_ExportStyles( bUsed ); + + // drawing defaults + GetShapeExport()->ExportGraphicDefaults(); + + GetTextParagraphExport()->exportTextStyles( bUsed + ,IsShowProgress() + ); +} + +void SwXMLExport::_ExportAutoStyles() +{ + // The order in which styles are collected *MUST* be the same as + // the order in which they are exported. Otherwise, caching will + // fail. + + if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 ) + { + if( (getExportFlags() & EXPORT_CONTENT) == 0 ) + { + // only master pages are exported => styles for frames bound + // to frames (but none for frames bound to pages) need to be + // collected. + GetTextParagraphExport()->collectFramesBoundToFrameAutoStyles( + bShowProgress ); + } + else + { + // content (and optional master pages) are exported => styles + // for frames bound to frame or to pages need to be + // collected. + GetTextParagraphExport()->collectFramesBoundToPageOrFrameAutoStyles( + bShowProgress ); + } + + } + + // exported in _ExportMasterStyles + if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 ) + GetPageExport()->collectAutoStyles( sal_False ); + + // if we don't export styles (i.e. in content stream only, but not + // in single-stream case), then we can save ourselves a bit of + // work and memory by not collecting field masters + if( (getExportFlags() & EXPORT_STYLES ) == 0 ) + GetTextParagraphExport()->exportUsedDeclarations( sal_False ); + + // exported in _ExportContent + if( (getExportFlags() & EXPORT_CONTENT) != 0 ) + { + GetTextParagraphExport()->exportTrackedChanges( sal_True ); + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + + // collect form autostyle + // (do this before collectTextAutoStyles, 'cause the shapes need the results of the work + // done by examineForms) + Reference<XDrawPageSupplier> xDrawPageSupplier( GetModel(), UNO_QUERY ); + if (xDrawPageSupplier.is() && GetFormExport().is()) + { + Reference<XDrawPage> xPage = xDrawPageSupplier->getDrawPage(); + if (xPage.is()) + GetFormExport()->examineForms(xPage); + } + + GetTextParagraphExport()->collectTextAutoStyles( xText, bShowProgress ); + } + + GetTextParagraphExport()->exportTextAutoStyles(); + GetShapeExport()->exportAutoStyles(); + if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 ) + GetPageExport()->exportAutoStyles(); + + // we rely on data styles being written after cell styles in the + // ExportFmt() method; so be careful when changing order. + exportAutoDataStyles(); + + sal_uInt16 nContentAutostyles = EXPORT_CONTENT | EXPORT_AUTOSTYLES; + if ( ( getExportFlags() & nContentAutostyles ) == nContentAutostyles ) + GetFormExport()->exportAutoStyles(); +} + +XMLPageExport* SwXMLExport::CreatePageExport() +{ + return new XMLTextMasterPageExport( *this ); +} + +void SwXMLExport::_ExportMasterStyles() +{ + // export master styles + GetPageExport()->exportMasterStyles( sal_False ); +} + +// --------------------------------------------------------------------- +class SwXMLAutoStylePoolP : public SvXMLAutoStylePoolP +{ + SvXMLExport& rExport; + const OUString sListStyleName; + const OUString sMasterPageName; + 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 +{ + SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap); + + 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; + GetExport().AddAttribute( XML_NAMESPACE_STYLE, + sListStyleName, sStyleName ); + } + } + break; + case CTF_PAGEDESCNAME: + { + OUString sStyleName; + aProperty->maValue >>= sStyleName; + GetExport().AddAttribute( XML_NAMESPACE_STYLE, + sMasterPageName, sStyleName ); + } + break; + } + } + } +} + +SwXMLAutoStylePoolP::SwXMLAutoStylePoolP(SvXMLExport& rExp ) : + SvXMLAutoStylePoolP( rExp ), + rExport( rExp ), + sListStyleName( GetXMLToken( XML_LIST_STYLE_NAME ) ), + sMasterPageName( GetXMLToken( XML_MASTER_PAGE_NAME ) ), + sCDATA( GetXMLToken( XML_CDATA ) ) +{ +} + + +SwXMLAutoStylePoolP::~SwXMLAutoStylePoolP() +{ +} + +SvXMLAutoStylePoolP* SwXMLExport::CreateAutoStylePool() +{ + return new SwXMLAutoStylePoolP( *this ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlfonte.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlfonte.cxx new file mode 100644 index 000000000000..12b1b349cb95 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlfonte.cxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "hintids.hxx" + +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XText.hpp> + +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XText.hpp> +#include <bf_xmloff/XMLFontAutoStylePool.hxx> +#include <bf_svx/fontitem.hxx> + +#include <errhdl.hxx> + +#include <unoobj.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include <xmlexp.hxx> +namespace binfilter { + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::text; + +class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool +{ + public: + + SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport ); + +}; + +SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl( + SwXMLExport& rExport ) : + XMLFontAutoStylePool( rExport ) +{ + sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, + RES_CHRATR_CTL_FONT }; + + Reference < XTextDocument > xTextDoc( rExport.GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( !xTextTunnel.is() ) + return; + + SwXText *pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + if( !pText ) + return; + + const SfxItemPool& rPool = pText->GetDoc()->GetAttrPool(); + const SfxPoolItem* pItem; + for( sal_uInt16 i=0; i<3; i++ ) + { + sal_uInt16 nWhichId = aWhichIds[i]; + + const SvxFontItem& rFont = + (const SvxFontItem&)rPool.GetDefaultItem( nWhichId ); + Add( rFont.GetFamilyName(), rFont.GetStyleName(), + rFont.GetFamily(), rFont.GetPitch(), rFont.GetCharSet() ); + sal_uInt16 nItems = rPool.GetItemCount( nWhichId ); + for( sal_uInt16 j = 0; j < nItems; ++j ) + { + if( 0 != (pItem = rPool.GetItem( nWhichId, j ) ) ) + { + const SvxFontItem *pFont = + (const SvxFontItem *)pItem; + Add( pFont->GetFamilyName(), pFont->GetStyleName(), + pFont->GetFamily(), pFont->GetPitch(), + pFont->GetCharSet() ); + } + } + } +} + + +XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool() +{ + return new SwXMLFontAutoStylePool_Impl( *this ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlimp.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlimp.cxx new file mode 100644 index 000000000000..a36c616fa1f9 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlimp.cxx @@ -0,0 +1,1331 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/xmltkmap.hxx> +#include <bf_xmloff/xmlictxt.hxx> +#include <bf_xmloff/txtimp.hxx> +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/XMLTextShapeImportHelper.hxx> +#include <bf_xmloff/XMLFontStylesContext.hxx> +#include <bf_xmloff/ProgressBarHelper.hxx> +#include <com/sun/star/i18n/XForbiddenCharacters.hpp> +#include <com/sun/star/document/PrinterIndependentLayout.hpp> + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include <errhdl.hxx> + +#include <viscrs.hxx> +#include <unoobj.hxx> +#include "unocrsr.hxx" +#include <poolfmt.hxx> +#include <ndtxt.hxx> +#include <pam.hxx> +#include <editsh.hxx> + +#include "xmlimp.hxx" + +#include <bf_xmloff/DocumentSettingsContext.hxx> + +#include <docsh.hxx> + +#include <bf_svx/unolingu.hxx> +#include <bf_svx/xmlgrhlp.hxx> +#include <bf_svx/xmleohlp.hxx> +#include <bf_sfx2/printer.hxx> + +#include <ForbiddenCharactersEnum.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_svtools/saveopt.hxx> + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> +#include <sal/macros.h> +#include <osl/mutex.hxx> +namespace binfilter { + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::i18n; +using namespace ::com::sun::star::drawing; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; + +struct OUStringEquals +{ + sal_Bool operator()( const ::rtl::OUString &r1, + const ::rtl::OUString &r2) const + { + return r1 == r2; + } +}; + +//---------------------------------------------------------------------------- + +enum SwXMLDocTokens +{ + XML_TOK_DOC_FONTDECLS, + XML_TOK_DOC_STYLES, + XML_TOK_DOC_AUTOSTYLES, + XML_TOK_DOC_MASTERSTYLES, + XML_TOK_DOC_META, + XML_TOK_DOC_BODY, + XML_TOK_DOC_SCRIPT, + XML_TOK_DOC_SETTINGS, + XML_TOK_OFFICE_END=XML_TOK_UNKNOWN +}; + +static __FAR_DATA SvXMLTokenMapEntry aDocTokenMap[] = +{ + { XML_NAMESPACE_OFFICE, XML_FONT_DECLS, XML_TOK_DOC_FONTDECLS }, + { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES }, + { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES }, + { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES }, + { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META }, + { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY }, + { XML_NAMESPACE_OFFICE, XML_SCRIPT, XML_TOK_DOC_SCRIPT }, + { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS }, + 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 ) +{ + // process document class + // global-text is handled via document shell; + // we only handle label documents + sal_Int16 nLength = xAttrList->getLength(); + for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + + if ( (XML_NAMESPACE_OFFICE == nPrefix) && + IsXMLToken( sLocalName, XML_CLASS ) ) + { + if ( IsXMLToken( xAttrList->getValueByIndex(nAttr), XML_LABEL ) ) + { + // OK, we need to set label mode. To do this, tunnel + // to get the SwDoc, then set label mode. + + Reference<XText> xText(GetImport().GetModel(), UNO_QUERY); + Reference<XUnoTunnel> xTunnel( + GetImport().GetTextImport()->GetText(), UNO_QUERY); + DBG_ASSERT(xTunnel.is(), "I can't get the Tunnel"); + SwXText* pText = (SwXText*)xTunnel->getSomething( + SwXText::getUnoTunnelId()); + if (NULL != pText) + { + SwDoc* pDoc = pText->GetDoc(); + if (NULL != pDoc) + pDoc->SetLabelDoc(); + } + } + } + } +} + +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_FONTDECLS: + pContext = GetSwImport().CreateFontDeclsContext( rLocalName, + xAttrList ); + break; + case XML_TOK_DOC_STYLES: + GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = GetSwImport().CreateStylesContext( rLocalName, xAttrList, + sal_False ); + break; + case XML_TOK_DOC_AUTOSTYLES: + // don't use the autostyles from the styles-document for the progress + if ( ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) ) + GetSwImport().GetProgressBarHelper()->Increment + ( PROGRESS_BAR_STEP ); + 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_SCRIPT: + pContext = GetSwImport().CreateScriptContext( rLocalName ); + break; + case XML_TOK_DOC_BODY: + GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + pContext = GetSwImport().CreateBodyContext( rLocalName ); + break; + case XML_TOK_DOC_SETTINGS: + pContext = new XMLDocumentSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList ); + 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 && + ( IsXMLToken( rLocalName, XML_DOCUMENT ) || + IsXMLToken( rLocalName, XML_DOCUMENT_META ) || + IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS ) || + IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) || + IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) )) + pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName, + xAttrList ); + else + pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList ); + + return pContext; +} + +// #110680# +SwXMLImport::SwXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nImportFlags) +: SvXMLImport( xServiceFactory, nImportFlags ), + bLoadDoc( sal_True ), + bInsert( sal_False ), + bBlock( sal_False ), + bOrganizerMode( sal_False ), + nStyleFamilyMask( SFX_STYLE_FAMILY_ALL ), + pDocElemTokenMap( 0 ), + pTableElemTokenMap( 0 ), + pTableCellAttrTokenMap( 0 ), + pTableItemMapper( 0 ), + pSttNdIdx( 0 ), + bShowProgress( sal_True ), + bPreserveRedlineMode( sal_True ), + pGraphicResolver( 0 ), + pEmbeddedResolver( 0 ) +{ + _InitItemImport(); + +} + +#ifdef XML_CORE_API +// #110680# +SwXMLImport::SwXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + 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, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rEGO, + SvStorage *pPkg ) +: SvXMLImport( xServiceFactory, rModel, rEGO ), + bLoadDoc( bLDoc ), + bInsert( bInsertMode ), + nStyleFamilyMask( nStyleFamMask ), + pDocElemTokenMap( 0 ), + pTableElemTokenMap( 0 ), + pTableCellAttrTokenMap( 0 ), + pTableItemMapper( 0 ), + pSttNdIdx( 0 ), + bShowProgress( sal_True ), + bPreserveRedlineMode( sal_True ), + xPackage( pPkg ) +{ + _InitItemImport(); + + Reference < XTextRange > xTextRange = + SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(), 0 ); + Reference < XText > xText = xTextRange->getText(); + Reference < XTextCursor > xTextCursor = + xText->createTextCursorByRange( xTextRange ); + GetTextImport()->SetCursor( xTextCursor ); +} +#endif + +SwXMLImport::~SwXMLImport() throw () +{ + delete pDocElemTokenMap; + delete pTableElemTokenMap; + delete pTableCellAttrTokenMap; + _FinitItemImport(); +} + +void SwXMLImport::setTextInsertMode( + const Reference< XTextRange > & rInsertPos ) +{ + bInsert = sal_True; + + Reference < XText > xText = rInsertPos->getText(); + Reference < XTextCursor > xTextCursor = + xText->createTextCursorByRange( rInsertPos ); + GetTextImport()->SetCursor( xTextCursor ); +} + +void SwXMLImport::setStyleInsertMode( sal_uInt16 nFamilies, + sal_Bool bOverwrite ) +{ + bInsert = !bOverwrite; + nStyleFamilyMask = nFamilies; + bLoadDoc = sal_False; +} + +void SwXMLImport::setBlockMode( ) +{ + bBlock = sal_True; +} + +void SwXMLImport::setOrganizerMode( ) +{ + bOrganizerMode = sal_True; +} + +const Sequence< sal_Int8 > & SwXMLImport::getUnoTunnelId() throw() +{ + static uno::Sequence< sal_Int8 > aSeq = ::binfilter::CreateUnoTunnelId(); + return aSeq; +} + +sal_Int64 SAL_CALL SwXMLImport::getSomething( const Sequence< sal_Int8 >& rId ) + throw(RuntimeException) +{ + if( rId.getLength() == 16 + && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + { + return (sal_Int64)this; + } + return SvXMLImport::getSomething( rId ); +} + +OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor ) +{ + Reference<XUnoTunnel> xCrsrTunnel( rTextCursor, UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( !xCrsrTunnel.is() ) + return 0; + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper *)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + return pTxtCrsr; +} + +void SwXMLImport::startDocument( void ) + throw( xml::sax::SAXException, uno::RuntimeException ) +{ + // delegate to parent + SvXMLImport::startDocument(); + + DBG_ASSERT( GetModel().is(), "model is missing" ); + if( !GetModel().is() ) + return; + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + // There only is a text cursor by now if we are in insert mode. In any + // other case we have to create one at the start of the document. + // We also might change into the insert mode later, so we have to make + // sure to first set the insert mode and then create the text import + // helper. Otherwise it won't have the insert flag set! + OTextCursorHelper *pTxtCrsr = 0; + Reference < XTextCursor > xTextCursor; + if( HasTextImport() ) + xTextCursor = GetTextImport()->GetCursor(); + if( !xTextCursor.is() ) + { + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + xTextCursor = xText->createTextCursor(); + SwCrsrShell *pCrsrSh = 0; + SwDoc *pDoc = 0; + if( IMPORT_ALL == getImportFlags() ) + { + pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + if( !pTxtCrsr ) + return; + + pDoc = pTxtCrsr->GetDoc(); + ASSERT( pDoc, "SwDoc missing" ); + if( !pDoc ) + return; + + // Is there a edit shell. If yes, then we are currently inserting + // a document. We then have to insert at the current edit shell's + // cursor position. That not quite clean code, but there is no other + // way currently. + pCrsrSh = pDoc->GetEditShell(); + } + if( pCrsrSh ) + { + Reference<XTextRange> xInsertTextRange( + SwXTextRange::CreateTextRangeFromPosition( + pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); + setTextInsertMode( xInsertTextRange ); + xTextCursor = GetTextImport()->GetCursor(); + pTxtCrsr = 0; + } + else + GetTextImport()->SetCursor( xTextCursor ); + } + + if( (getImportFlags() & (IMPORT_CONTENT|IMPORT_MASTERSTYLES)) == 0 ) + return; + + if( !pTxtCrsr ) + pTxtCrsr = lcl_xml_GetSwXTextCursor( xTextCursor ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + if( !pTxtCrsr ) + return; + + SwDoc *pDoc = pTxtCrsr->GetDoc(); + ASSERT( pDoc, "SwDoc missing" ); + if( !pDoc ) + return; + + if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() ) + { + pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() ); + if( IsInsertMode() ) + { + SwPaM *pPaM = pTxtCrsr->GetPaM(); + 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->GetTxtCollFromPoolSimple(RES_POOLCOLL_STANDARD, + FALSE) ); + } + } + + // We need a draw model to be able to set the z order + pDoc->MakeDrawModel(); + + if( !GetGraphicResolver().is() ) + { + pGraphicResolver = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ ); + Reference< document::XGraphicObjectResolver > xGraphicResolver( pGraphicResolver ); + SetGraphicResolver( xGraphicResolver ); + } + + if( !GetEmbeddedResolver().is() ) + { + SvPersist *pPersist = pDoc->GetPersist(); + if( pPersist ) + { + pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create( + *pPersist, + EMBEDDEDOBJECTHELPER_MODE_READ ); + Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver ); + SetEmbeddedResolver( xEmbeddedResolver ); + } + } +} + +void SwXMLImport::endDocument( void ) + throw( xml::sax::SAXException, uno::RuntimeException ) +{ + DBG_ASSERT( GetModel().is(), "model missing; maybe startDocument wasn't called?" ); + if( !GetModel().is() ) + return; + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + if( pGraphicResolver ) + SvXMLGraphicHelper::Destroy( pGraphicResolver ); + if( pEmbeddedResolver ) + SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver ); + // Clear the shape import to sort the shapes (and not in the + // destructor that might be called after the import has finished + // for Java filters. + if( HasShapeImport() ) + ClearShapeImport(); + + + SwDoc *pDoc = 0; + if( (getImportFlags() & IMPORT_CONTENT) != 0 && !IsStylesOnlyMode() ) + { + Reference<XUnoTunnel> xCrsrTunnel( GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwPaM *pPaM = pTxtCrsr->GetPaM(); + 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. Or in other words: + // Revert the first split node. + SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode(); + SwNodeIndex aNxtIdx( *pSttNdIdx ); + if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ) && + pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex() ) + { + // 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, + pTxtNode->GetTxt().Len() ); + } + +#ifdef DBG_UTIL + // !!! 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(); + DBG_ASSERT( !pPos->nContent.GetIndex(), "last paragraph isn't empty" ); + if( !pPos->nContent.GetIndex() ) + { + SwTxtNode* pCurrNd; + ULONG nNodeIdx = pPos->nNode.GetIndex(); + pDoc = pPaM->GetDoc(); + + DBG_ASSERT( pPos->nNode.GetNode().IsCntntNode(), + "insert position is not a content node" ); + if( !IsInsertMode() ) + { + // If we're not in insert mode, the last node is deleted. + const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1]; + if( pPrev->IsCntntNode() || + ( pPrev->IsEndNode() && + pPrev->StartOfSectionNode()->IsSectionNode() ) ) + { + 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()) ) + { + // Id we're in insert mode, the empty node is joined with + // the next and the previous one. + if( pCurrNd->CanJoinNext( &pPos->nNode )) + { + SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode(); + pPos->nContent.Assign( pNextNd, 0 ); + pPaM->SetMark(); pPaM->DeleteMark(); + pNextNd->JoinPrev(); + + // Remove line break that has been inserted by the import, + // but only if one has been inserted! + if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && + *pSttNdIdx != pPos->nNode ) + { +// SwTxtNode* pPrevNd = pPos->nNode.GetNode().GetTxtNode(); +// pPos->nContent.Assign( pPrevNd, 0 ); +// pPaM->SetMark(); pPaM->DeleteMark(); +// pPrevNd->JoinNext(); + 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 ); + } + } + } + } + + /* #108146# Was called too early. Moved from + SwXMLBodyContext_Impl::EndElement */ + + GetTextImport()->RedlineAdjustStartNodeCursor( sal_False ); + + if( (getImportFlags() & IMPORT_CONTENT) != 0 || + ((getImportFlags() & IMPORT_MASTERSTYLES) != 0 && IsStylesOnlyMode()) ) + { + // pDoc might be 0. In this case UpdateTxtCollCondition is looking + // for it itself. + UpdateTxtCollConditions( pDoc ); + } + + GetTextImport()->ResetCursor(); + + delete pSttNdIdx; + pSttNdIdx = 0; + + if( (getImportFlags() == IMPORT_ALL ) ) + { + // Notify math objects. If we are in the package filter this will + // be done by the filter object itself + if( IsInsertMode() ) + pDoc->PrtOLENotify( FALSE ); + else if ( pDoc->IsOLEPrtNotifyPending() ) + pDoc->PrtOLENotify( TRUE ); + } + + // delegate to parent: takes care of error handling + SvXMLImport::endDocument(); +} + + +// Locally derive XMLTextShapeImportHelper, so we can take care of the +// form import This is Writer, but not text specific, so it should go +// here! +class SvTextShapeImportHelper : public XMLTextShapeImportHelper +{ + // hold own reference form import helper, because the SvxImport + // stored in the superclass, from whom we originally got the + // reference, is already destroyed when we want to use it in the + // destructor + UniReference< ::binfilter::xmloff::OFormLayerXMLImport > rFormImport; + + // hold reference to the one page (if it exists) for calling startPage() + // and endPage. If !xPage.is(), then this document doesn't have a + // XDrawPage. + Reference<drawing::XDrawPage> xPage; + +public: + + SvTextShapeImportHelper(SvXMLImport& rImp); + virtual ~SvTextShapeImportHelper(); +}; + +SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) : + XMLTextShapeImportHelper(rImp) +{ + Reference<drawing::XDrawPageSupplier> xSupplier(rImp.GetModel(),UNO_QUERY); + if (xSupplier.is()) + { + if (rImp.GetFormImport().is()) + { + rImp.GetFormImport()->startPage(xSupplier->getDrawPage()); + rFormImport = rImp.GetFormImport(); + } + + xPage = xSupplier->getDrawPage(); + Reference<XShapes> xShapes( xPage, UNO_QUERY ); + XMLShapeImportHelper::startPage( xShapes ); + } +} + +SvTextShapeImportHelper::~SvTextShapeImportHelper() +{ + rFormImport->endPage(); + + if (xPage.is()) + { + Reference<XShapes> xShapes( xPage, UNO_QUERY ); + XMLShapeImportHelper::endPage(xShapes); + } +} + + +XMLShapeImportHelper* SwXMLImport::CreateShapeImport() +{ + return new SvTextShapeImportHelper( *this ); +} + +SvXMLImportContext *SwXMLImport::CreateFontDeclsContext( + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + XMLFontStylesContext *pFSContext = + new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, + rLocalName, xAttrList, + gsl_getSystemTextEncoding() ); + SetFontDecls( pFSContext ); + return pFSContext; +} +void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps) +{ + if (IsInsertMode() || IsStylesOnlyMode() || IsBlockMode() || IsOrganizerMode() || !GetModel().is() ) + return; + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( !xTextTunnel.is() ) + return; + + SwXText *pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + if( !pText ) + return; + + SwDoc *pDoc = pText->GetDoc(); + Rectangle aRect; + if( pDoc->GetDocShell() ) + aRect = ((SfxInPlaceObject *)pDoc->GetDocShell())->GetVisArea(); + + sal_Int32 nCount = aViewProps.getLength(); + const PropertyValue *pValue = aViewProps.getConstArray(); + + long nTmp; + sal_Bool bShowRedlineChanges = sal_False, bBrowseMode = sal_False, + bShowFooter = sal_False, bShowHeader = sal_False; + sal_Bool bChangeShowRedline = sal_False, bChangeBrowseMode = sal_False, + bChangeFooter = sal_False, bChangeHeader = sal_False; + + sal_Bool bTwip = pDoc->GetDocShell()->SfxInPlaceObject::GetMapUnit ( ) == MAP_TWIP; + + for (sal_Int32 i = 0; i < nCount ; i++) + { + if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) ) + { + pValue->Value >>= nTmp; + aRect.setY( bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) ) + { + pValue->Value >>= nTmp; + aRect.setX( bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) ) + { + pValue->Value >>= nTmp; + Size aSize( aRect.GetSize() ); + aSize.Width() = bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp; + aRect.SetSize( aSize ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) ) + { + pValue->Value >>= nTmp; + Size aSize( aRect.GetSize() ); + aSize.Height() = bTwip ? MM100_TO_TWIP ( nTmp ) : nTmp; + aRect.SetSize( aSize ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowRedlineChanges" ) ) ) + { + bShowRedlineChanges = *(sal_Bool *)(pValue->Value.getValue()); + bChangeShowRedline = sal_True; + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowHeaderWhileBrowsing" ) ) ) + { + bShowHeader = *(sal_Bool *)(pValue->Value.getValue()); + bChangeFooter = sal_True; + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowFooterWhileBrowsing" ) ) ) + { + bShowFooter = *(sal_Bool *)(pValue->Value.getValue()); + bChangeHeader = sal_True; + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "InBrowseMode" ) ) ) + { + bBrowseMode = *(sal_Bool *)(pValue->Value.getValue()); + bChangeBrowseMode = sal_True; + } + pValue++; + } + if( pDoc->GetDocShell() ) + pDoc->GetDocShell()->SetVisArea ( aRect ); + + if (bChangeHeader) + pDoc->SetHeadInBrowse ( bShowHeader ); + if (bChangeFooter) + pDoc->SetFootInBrowse ( bShowFooter ); + if (bChangeBrowseMode) + pDoc->SetBrowseMode ( bBrowseMode ); + if (bChangeShowRedline) + GetTextImport()->SetShowChanges( bShowRedlineChanges ); +} + +void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY ); + if( !xFac.is() ) + return; + + Reference< XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY ); + if( !xProps.is() ) + return; + + Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() ); + if( !xInfo.is() ) + return; + + // static array of setting names which are not loaded. + // This table is created with the iout commended procedure. This will + // be need if anybody add more or change strings!!! + /* + program to calculate the best hash parameters for the property names. +----------------------------------------------------------------- +#include <stdio.h> +#include <string.h> + +#include <sal/macros.h> + + const char* aNmArr[] = { + "ForbiddenCharacters" , + "IsKernAsianPunctuation" , + "CharacterCompressionType" , + "LinkUpdateMode" , + "FieldAutoUpdate" , + "ChartAutoUpdate" , + "AddParaTableSpacing" , + "AddParaTableSpacingAtStart" , + "PrintAnnotationMode" , + "PrintBlackFonts" , + "PrintControls" , + "PrintDrawings" , + "PrintGraphics" , + "PrintLeftPages" , + "PrintPageBackground" , + "PrintProspect" , + "PrintReversed" , + "PrintRightPages" , + "PrintFaxName" , + "PrintPaperFromSetup" , + "PrintTables" , + "PrintSingleJobs", + "UpdateFromTemplate", + "PrinterIndependentLayout" + }; +#define TBL_MAX 100 +int aArr[ TBL_MAX ]; +int nPrime, nSub; + +unsigned long calc_hash( const char* p ) +{ + unsigned long ii = 0; + while( *p ) + ii = (ii * nPrime) ^ ( *p++ - nSub ); + return ii; +} +int Chk_Unique_hashValue( unsigned short nTblSize ) +{ + memset( aArr, 0, sizeof( aArr ) ); + unsigned long ii; + for( int n = 0; n < SAL_N_ELEMENTS( aNmArr ); ++n ) + { + ii = calc_hash( aNmArr[ n ] ) % nTblSize; + if( aArr[ ii ] ) + break; + aArr[ ii ] = 1; + } + return n == SAL_N_ELEMENTS( aNmArr ); +} + +void Show_Result( unsigned short nTblSize ) +{ + printf( "\nTblSz = %d\n", nTblSize ); + for( int n = 0; n < SAL_N_ELEMENTS( aNmArr ); ++n ) + { + unsigned long ii = calc_hash( aNmArr[ n ] ) % nTblSize; + printf( "%-30s -> %3d\n", aNmArr[ n ], ii ); + } +} + +void main() +{ + int nPrm = nPrime, nSb = nSub; + unsigned short nLTbl = TBL_MAX, nTblSize; + + for( nSub = ' '; nSub < 127; ++nSub ) + for( nPrime = 13 ; nPrime < 99; ++nPrime ) + for( nTblSize = SAL_N_ELEMENTS( aNmArr ); + nTblSize < TBL_MAX; ++nTblSize ) + if( Chk_Unique_hashValue( nTblSize )) + { + if( nLTbl > nTblSize ) + { + nLTbl = nTblSize; + nPrm = nPrime; + nSb = nSub; + } + break; + } + + nPrime = nPrm; + nSub = nSb; + nTblSize = nLTbl; + + Show_Result( nTblSize ); + printf( "\nPrime: %d, nSub: %d, TblSz = %d - %d", nPrime, nSub, + SAL_N_ELEMENTS( aNmArr ), nTblSize ); +} +----------------------------------------------------------------- + */ + static const struct { + const sal_Char* pName; + sal_uInt16 nLen; + } aNotSetArr[40] = { +/* 0*/ {0,0}, +/* 1*/ {RTL_CONSTASCII_STRINGPARAM( "PrintTables" )}, +/* 2*/ {RTL_CONSTASCII_STRINGPARAM( "ForbiddenCharacters" )}, +/* 3*/ {0,0}, +/* 4*/ {0,0}, +/* 5*/ {RTL_CONSTASCII_STRINGPARAM( "AddParaTableSpacingAtStart" )}, +/* 6*/ {0,0}, +/* 7*/ {RTL_CONSTASCII_STRINGPARAM( "CharacterCompressionType" )}, +/* 8*/ {0,0}, +/* 9*/ {RTL_CONSTASCII_STRINGPARAM( "PrintDrawings" )}, +/*10*/ {RTL_CONSTASCII_STRINGPARAM( "PrintRightPages" )}, +/*11*/ {RTL_CONSTASCII_STRINGPARAM( "PrintPageBackground" )}, +/*12*/ {RTL_CONSTASCII_STRINGPARAM( "LinkUpdateMode" )}, +/*13*/ {RTL_CONSTASCII_STRINGPARAM( "UpdateFromTemplate" )}, +/*14*/ {0,0}, +/*15*/ {RTL_CONSTASCII_STRINGPARAM( "PrintBlackFonts" )}, +/*16*/ {RTL_CONSTASCII_STRINGPARAM( "PrintSingleJobs" )}, +/*17*/ {RTL_CONSTASCII_STRINGPARAM( "ChartAutoUpdate" )}, +/*18*/ {RTL_CONSTASCII_STRINGPARAM( "IsKernAsianPunctuation" )}, +/*19*/ {RTL_CONSTASCII_STRINGPARAM( "AddParaTableSpacing" )}, +/*20*/ {0,0}, +/*21*/ {0,0}, +/*22*/ {0,0}, +/*23*/ {0,0}, +/*24*/ {RTL_CONSTASCII_STRINGPARAM( "PrintReversed" )}, +/*25*/ {RTL_CONSTASCII_STRINGPARAM( "FieldAutoUpdate" )}, +/*26*/ {RTL_CONSTASCII_STRINGPARAM( "PrintProspect" )}, +/*27*/ {0,0}, +/*28*/ {RTL_CONSTASCII_STRINGPARAM( "PrintControls" )}, +/*29*/ {0,0}, +/*30*/ {RTL_CONSTASCII_STRINGPARAM( "PrintAnnotationMode" )}, +/*31*/ {RTL_CONSTASCII_STRINGPARAM( "PrintGraphics" )}, +/*32*/ {RTL_CONSTASCII_STRINGPARAM( "PrinterIndependentLayout" )}, +/*33*/ {0,0}, +/*34*/ {0,0}, +/*35*/ {RTL_CONSTASCII_STRINGPARAM( "PrintPaperFromSetup" )}, +/*36*/ {RTL_CONSTASCII_STRINGPARAM( "PrintLeftPages" )}, +/*37*/ {RTL_CONSTASCII_STRINGPARAM( "PrintFaxName" )}, +/*38*/ {0,0}, +/*39*/ {0,0}, + }; + const ULONG nPrime = 51; + const ULONG nSub = 51; + + sal_Int32 nCount = aConfigProps.getLength(); + const PropertyValue* pValues = aConfigProps.getConstArray(); + + SvtSaveOptions aSaveOpt; + BOOL bIsUserSetting = aSaveOpt.IsLoadUserSettings(), + bSet = bIsUserSetting; + + // for some properties we don't want to use the application + // default if they're missing. So we watch for them in the loop + // below, and set them if not found + bool bPrinterIndependentLayout = false; + + while( nCount-- ) + { + ULONG nHash = 0; + if( !bIsUserSetting ) + { + // test over the hash value if the entry is in the table. + const sal_Unicode* p = pValues->Name; + for( ULONG nLen = pValues->Name.getLength(); nLen; --nLen, ++p ) + nHash = (nHash * nPrime) ^ ( *p - nSub ); + nHash %= SAL_N_ELEMENTS( aNotSetArr ); + bSet = 0 == aNotSetArr[ nHash ].pName || + !pValues->Name.equalsAsciiL( + aNotSetArr[ nHash ].pName, + aNotSetArr[ nHash ].nLen ); + } + + if( bSet ) + { + try + { + if( xInfo->hasPropertyByName( pValues->Name ) ) + { + xProps->setPropertyValue( pValues->Name, pValues->Value ); + } + + // did we find any of the non-default cases? + if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("PrinterIndependentLayout")) ) + bPrinterIndependentLayout = true; + + } + catch( Exception& ) + { + DBG_ERROR( "SwXMLImport::SetConfigurationSettings: Exception!" ); + } + } + pValues++; + } + + // finally, treat the non-default cases + if( ! bPrinterIndependentLayout ) + { + Any aAny; + sal_Int16 nTmp = document::PrinterIndependentLayout::DISABLED; + aAny <<= nTmp; + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("PrinterIndependentLayout") ), + aAny ); + } + + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( xTextTunnel.is() ) + { + SwXText *pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + if( pText ) + { + SwDoc *pDoc = pText->GetDoc(); + if( pDoc ) + { + // If the printer is known, then the OLE objects will + // already have correct sizes, and we don't have to call + // PrtOLENotify again. Otherwise we have to call it. + // The flag might be set from setting the printer, so it + // it is required to clear it. + SfxPrinter *pPrinter = pDoc->GetPrt( sal_False ); + if( pPrinter ) + pDoc->SetOLEPrtNotifyPending( !pPrinter->IsKnown() ); + } + } + } +} + + +void SwXMLImport::initialize( + const Sequence<Any>& aArguments ) + throw( uno::Exception, uno::RuntimeException) +{ + // delegate to super class + SvXMLImport::initialize(aArguments); + + // we are only looking for a PropertyValue "PreserveRedlineMode" + sal_Int32 nLength = aArguments.getLength(); + for(sal_Int32 i = 0; i < nLength; i++) + { + if (aArguments[i].getValueType() == + ::getCppuType((const beans::PropertyValue*)0) ) + { + beans::PropertyValue aValue; + aArguments[i] >>= aValue; + + if (aValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("PreserveRedlineMode"))) + { + bPreserveRedlineMode = *(sal_Bool*)aValue.Value.getValue(); + } + } + } +} + + +// +// UNO component registration helper functions +// + +OUString SAL_CALL SwXMLImport_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( SwXMLImport_getImplementationName() ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLImport(IMPORT_ALL); + return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_ALL ); +} + +OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLStylesImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( SwXMLImportStyles_getImplementationName() ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + //return (cppu::OWeakObject*)new SwXMLImport( + // IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES | + // IMPORT_FONTDECLS ); + return (cppu::OWeakObject*)new SwXMLImport( + rSMgr, + IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES | + IMPORT_FONTDECLS ); +} + +OUString SAL_CALL SwXMLImportContent_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLContentImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( SwXMLImportContent_getImplementationName() ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + //return (cppu::OWeakObject*)new SwXMLImport( + // IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS | + // IMPORT_FONTDECLS ); + return (cppu::OWeakObject*)new SwXMLImport( + rSMgr, + IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS | + IMPORT_FONTDECLS ); +} + +OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLMetaImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( SwXMLImportMeta_getImplementationName() ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLImport( IMPORT_META ); + return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_META ); +} + +OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.XMLSettingsImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( SwXMLImportSettings_getImplementationName() ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SwXMLImport( IMPORT_SETTINGS ); + return (cppu::OWeakObject*)new SwXMLImport( rSMgr, IMPORT_SETTINGS ); +} + + +// XServiceInfo +// override empty method from parent class +OUString SAL_CALL SwXMLImport::getImplementationName() + throw(RuntimeException) +{ + switch( getImportFlags() ) + { + case IMPORT_ALL: + return SwXMLImport_getImplementationName(); + break; + case (IMPORT_STYLES|IMPORT_MASTERSTYLES|IMPORT_AUTOSTYLES|IMPORT_FONTDECLS): + return SwXMLImportStyles_getImplementationName(); + break; + case (IMPORT_AUTOSTYLES|IMPORT_CONTENT|IMPORT_SCRIPTS|IMPORT_FONTDECLS): + return SwXMLImportContent_getImplementationName(); + break; + case IMPORT_META: + return SwXMLImportMeta_getImplementationName(); + break; + case IMPORT_SETTINGS: + return SwXMLImportSettings_getImplementationName(); + break; + default: + // generic name for 'unknown' cases + return OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.Writer.SwXMLImport" ) ); + break; + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlimpit.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlimpit.cxx new file mode 100644 index 000000000000..e73a3a537a08 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlimpit.cxx @@ -0,0 +1,952 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "xmlimpit.hxx" +#include <bf_xmloff/xmluconv.hxx> + + + + + +#include <bf_xmloff/nmspmap.hxx> + + +#include <bf_svx/xmlcnitm.hxx> + + +#include "hintids.hxx" + +#include "unomid.h" + + +#include <bf_svx/lrspitem.hxx> + +#include <bf_svx/ulspitem.hxx> + +#include <bf_svx/shaditem.hxx> + +#include <bf_svx/boxitem.hxx> + +#include <bf_svx/brkitem.hxx> + +#include <bf_svx/keepitem.hxx> + + +#include "fmtpdsc.hxx" + +#include <horiornt.hxx> + +#include "fmtornt.hxx" + +#include "fmtfsize.hxx" + +#include "fmtlsplt.hxx" + + +#include <bf_xmloff/prhdlfac.hxx> + +#include <bf_xmloff/xmltypes.hxx> + +#include "xmlithlp.hxx" + +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; +using ::com::sun::star::uno::Any; + +SvXMLImportItemMapper::SvXMLImportItemMapper( + SvXMLItemMapEntriesRef rMapEntries, + USHORT nUnknWhich ) : + mrMapEntries( rMapEntries ), + nUnknownWhich( nUnknWhich ) +{ +} + +SvXMLImportItemMapper::~SvXMLImportItemMapper() +{ +} + +/** fills the given itemset with the attributes in the given list */ +void SvXMLImportItemMapper::importXML( SfxItemSet& rSet, + uno::Reference< xml::sax::XAttributeList > xAttrList, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const +{ + INT16 nAttr = xAttrList->getLength(); + + SvXMLAttrContainerItem *pUnknownItem = 0; + for( INT16 i=0; i < nAttr; i++ ) + { + const OUString& rAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName, aPrefix, aNamespace; + USHORT nPrefix = + rNamespaceMap.GetKeyByAttrName( rAttrName, &aPrefix, &aLocalName, + &aNamespace ); + if( XML_NAMESPACE_XMLNS == nPrefix ) + continue; + + const OUString& rValue = xAttrList->getValueByIndex( i ); + + // find a map entry for this attribute + SvXMLItemMapEntry* pEntry = mrMapEntries->getByName( nPrefix, aLocalName ); + + if( pEntry ) + { + // we have a valid map entry here, so lets use it... + if( 0 == (pEntry->nMemberId & (MID_FLAG_NO_ITEM_IMPORT| + MID_FLAG_ELEMENT_ITEM_IMPORT)) ) + { + // first get item from itemset + const SfxPoolItem* pItem = 0; + SfxItemState eState = rSet.GetItemState( pEntry->nWhichId, TRUE, + &pItem ); + + // if its not set, try the pool + if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > pEntry->nWhichId ) + pItem = &rSet.GetPool()->GetDefaultItem(pEntry->nWhichId); + + // do we have an item? + if(eState >= SFX_ITEM_DEFAULT && pItem) + { + SfxPoolItem *pNewItem = pItem->Clone(); + BOOL bPut = FALSE; + + if( 0 == (pEntry->nMemberId&MID_FLAG_SPECIAL_ITEM_IMPORT) ) + { +// bPut = pNewItem->importXML( rValue, +// pEntry->nMemberId & MID_FLAG_MASK, +// rUnitConverter ); + bPut = PutXMLValue( *pNewItem, rValue, + pEntry->nMemberId & MID_FLAG_MASK, + rUnitConverter ); + + } + else + { + bPut = handleSpecialItem( *pEntry, *pNewItem, rSet, + rValue, rUnitConverter, + rNamespaceMap ); + } + + if( bPut ) + rSet.Put( *pNewItem ); + + delete pNewItem; + } + else + { + DBG_ERROR( "Could not get a needed item for xml import!" ); + } + } + else if( 0 != (pEntry->nMemberId & MID_FLAG_NO_ITEM_IMPORT) ) + { + handleNoItem( *pEntry, rSet, rValue, rUnitConverter, + rNamespaceMap ); + } + } + else if( USHRT_MAX != nUnknownWhich ) + { + if( !pUnknownItem ) + { + const SfxPoolItem* pItem = 0; + if( SFX_ITEM_SET == rSet.GetItemState( nUnknownWhich, TRUE, + &pItem ) ) + { + SfxPoolItem *pNew = pItem->Clone(); + pUnknownItem = PTR_CAST( SvXMLAttrContainerItem, pNew ); + DBG_ASSERT( pUnknownItem, + "SvXMLAttrContainerItem expected" ); + if( !pUnknownItem ) + delete pNew; + } + else + { + pUnknownItem = new SvXMLAttrContainerItem( nUnknownWhich ); + } + } + if( pUnknownItem ) + { + if( XML_NAMESPACE_NONE == nPrefix ) + pUnknownItem->AddAttr( aLocalName, rValue ); + else + pUnknownItem->AddAttr( aPrefix, aNamespace, aLocalName, + rValue ); + } + } + } + + if( pUnknownItem ) + { + rSet.Put( *pUnknownItem ); + delete pUnknownItem; + } + + finished( rSet ); +} + +/** this method is called for every item that has the + MID_FLAG_SPECIAL_ITEM_IMPORT flag set */ +BOOL +SvXMLImportItemMapper::handleSpecialItem( const SvXMLItemMapEntry& rEntry, + SfxPoolItem& rItem, + SfxItemSet& rSet, + const OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const +{ + DBG_ERROR( "unsuported special item in xml import" ); + return FALSE; +} + +/** this method is called for every item that has the + MID_FLAG_NO_ITEM_IMPORT flag set */ +BOOL SvXMLImportItemMapper::handleNoItem( const SvXMLItemMapEntry& rEntry, + SfxItemSet& rSet, + const OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap) const +{ + DBG_ERROR( "unsuported no item in xml import" ); + return FALSE; +} + +void SvXMLImportItemMapper::finished( SfxItemSet& ) const +{ + // nothing to do here +} + + + +// put an XML-string value into an item +sal_Bool SvXMLImportItemMapper::PutXMLValue( + SfxPoolItem& rItem, + const ::rtl::OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ) +{ + sal_Bool bOk = sal_False; + + switch (rItem.Which()) + { + case ITEMID_LRSPACE: + { + SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem); + DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" ); + + switch( nMemberId ) + { + case MID_L_MARGIN: + case MID_R_MARGIN: + { + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue ); + + if( bOk ) + { + switch( nMemberId ) + { + case MID_L_MARGIN: + pLRSpace->SetTxtLeft( (sal_Int32)nAbs, (sal_uInt16)nProp ); + break; + case MID_R_MARGIN: + pLRSpace->SetRight( (sal_Int32)nAbs, (sal_uInt16)nProp ); + break; + } + } + } + break; + case MID_FIRST_LINE_INDENT: + { + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue, + -0x7fff, 0x7fff ); + + pLRSpace->SetTxtFirstLineOfst( (short)nAbs, (sal_uInt16)nProp ); + } + + case MID_FIRST_AUTO: + { + sal_Bool bAutoFirst; + bOk = rUnitConverter.convertBool( bAutoFirst, rValue ); + if( bOk ) + pLRSpace->SetAutoFirst( bAutoFirst ); + } + break; + + default: + DBG_ERROR( "unknown member id!"); + } + } + break; + + case ITEMID_ULSPACE: + { + SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem); + DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" ); + + sal_Int32 nProp = 100; + sal_Int32 nAbs = 0; + + if( rValue.indexOf( sal_Unicode('%') ) != -1 ) + bOk = rUnitConverter.convertPercent( nProp, rValue ); + else + bOk = rUnitConverter.convertMeasure( nAbs, rValue ); + + switch( nMemberId ) + { + case MID_UP_MARGIN: + pULSpace->SetUpper( (sal_uInt16)nAbs, (sal_uInt16)nProp ); + break; + case MID_LO_MARGIN: + pULSpace->SetLower( (sal_uInt16)nAbs, (sal_uInt16)nProp ); + break; + default: + DBG_ERROR("unknown MemberId"); + } + } + break; + + case ITEMID_SHADOW: + { + SvxShadowItem* pShadow = PTR_CAST(SvxShadowItem, &rItem); + DBG_ASSERT( pShadow != NULL, "Wrong Which-ID" ); + + sal_Bool bColorFound = sal_False; + sal_Bool bOffsetFound = sal_False; + + SvXMLTokenEnumerator aTokenEnum( rValue ); + + Color aColor( 128,128, 128 ); + pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT ); + + OUString aToken; + while( aTokenEnum.getNextToken( aToken ) ) + { + if( IsXMLToken( aToken, XML_NONE ) ) + { + pShadow->SetLocation( SVX_SHADOW_NONE ); + bOk = sal_True; + } + else if( !bColorFound && aToken.compareToAscii( "#", 1 ) == 0 ) + { + bOk = rUnitConverter.convertColor( aColor, aToken ); + if( !bOk ) + return sal_False; + + bColorFound = sal_True; + } + else if( !bOffsetFound ) + { + sal_Int32 nX = 0, nY = 0; + + bOk = rUnitConverter.convertMeasure( nX, aToken ); + if( bOk && aTokenEnum.getNextToken( aToken ) ) + bOk = rUnitConverter.convertMeasure( nY, aToken ); + + if( bOk ) + { + if( nX < 0 ) + { + if( nY < 0 ) + { + pShadow->SetLocation( SVX_SHADOW_TOPLEFT ); + } + else + { + pShadow->SetLocation( SVX_SHADOW_BOTTOMLEFT ); + } + } + else + { + if( nY < 0 ) + { + pShadow->SetLocation( SVX_SHADOW_TOPRIGHT ); + } + else + { + pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT ); + } + } + + if( nX < 0 ) nX *= -1; + if( nY < 0 ) nY *= -1; + + pShadow->SetWidth( (nX + nY) >> 1 ); + } + } + } + + if( bOk && ( bColorFound || bOffsetFound ) ) + { + pShadow->SetColor( aColor ); + } + else + bOk = sal_False; + } + break; + + case ITEMID_BOX: + { + SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem); + DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" ); + + /** copy SvxBorderLines */ + SvxBorderLine* pTop = pBox->GetTop() == NULL ? + NULL : new SvxBorderLine( *pBox->GetTop() ); + SvxBorderLine* pBottom = pBox->GetBottom() == NULL ? + NULL : new SvxBorderLine( *pBox->GetBottom() ); + SvxBorderLine* pLeft = pBox->GetLeft() == NULL ? + NULL : new SvxBorderLine( *pBox->GetLeft() ); + SvxBorderLine* pRight = pBox->GetRight() == NULL ? + NULL : new SvxBorderLine( *pBox->GetRight() ); + + sal_Int32 nTemp; + + switch( nMemberId ) + { + case ALL_BORDER_PADDING: + case LEFT_BORDER_PADDING: + case RIGHT_BORDER_PADDING: + case TOP_BORDER_PADDING: + case BOTTOM_BORDER_PADDING: + if(!rUnitConverter.convertMeasure( nTemp, rValue, 0, 0xffff )) + return sal_False; + + if( nMemberId == LEFT_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_LEFT ); + if( nMemberId == RIGHT_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_RIGHT ); + if( nMemberId == TOP_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_TOP ); + if( nMemberId == BOTTOM_BORDER_PADDING || + nMemberId == ALL_BORDER_PADDING ) + pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_BOTTOM); + break; + + case ALL_BORDER: + case LEFT_BORDER: + case RIGHT_BORDER: + case TOP_BORDER: + case BOTTOM_BORDER: + { + sal_Bool bHasStyle = sal_False; + sal_Bool bHasWidth = sal_False; + sal_Bool bHasColor = sal_False; + + sal_uInt16 nStyle = USHRT_MAX; + sal_uInt16 nWidth = 0; + sal_uInt16 nNamedWidth = USHRT_MAX; + + Color aColor( COL_BLACK ); + + if( !lcl_frmitems_parseXMLBorder( rValue, rUnitConverter, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ) ) + return sal_False; + + if( TOP_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pTop, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( BOTTOM_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pBottom, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( LEFT_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pLeft, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + + if( RIGHT_BORDER == nMemberId || ALL_BORDER == nMemberId ) + lcl_frmitems_setXMLBorder( pRight, + bHasStyle, nStyle, + bHasWidth, nWidth, nNamedWidth, + bHasColor, aColor ); + } + break; + case ALL_BORDER_LINE_WIDTH: + case LEFT_BORDER_LINE_WIDTH: + case RIGHT_BORDER_LINE_WIDTH: + case TOP_BORDER_LINE_WIDTH: + case BOTTOM_BORDER_LINE_WIDTH: + { + SvXMLTokenEnumerator aTokenEnum( rValue ); + + sal_Int32 nInWidth, nDistance, nOutWidth; + + OUString aToken; + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nInWidth, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nDistance, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + if( !aTokenEnum.getNextToken( aToken ) ) + return sal_False; + + if( !rUnitConverter.convertMeasure( nOutWidth, aToken, + DEF_LINE_WIDTH_0, + DEF_LINE_WIDTH_4 ) ) + return sal_False; + + sal_uInt16 nSize = sizeof( aDBorderWidths ); + sal_uInt16 i=0; + for( i=0; i < nSize; i += 4 ) + { + if( aDBorderWidths[i+1] == nOutWidth && + aDBorderWidths[i+2] == nInWidth && + aDBorderWidths[i+3] == nDistance ) + break; + } + + sal_uInt16 nWidth = i < nSize ? 0 : nOutWidth + nInWidth + nDistance; + + if( TOP_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pTop, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( BOTTOM_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pBottom, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( LEFT_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pLeft, nWidth, nOutWidth, + nInWidth, nDistance ); + + if( RIGHT_BORDER_LINE_WIDTH == nMemberId || + ALL_BORDER_LINE_WIDTH == nMemberId ) + lcl_frmitems_setXMLBorder( pRight, nWidth, nOutWidth, + nInWidth, nDistance ); + } + break; + } + + pBox->SetLine( pTop, BOX_LINE_TOP ); + pBox->SetLine( pBottom, BOX_LINE_BOTTOM ); + pBox->SetLine( pLeft, BOX_LINE_LEFT ); + pBox->SetLine( pRight, BOX_LINE_RIGHT ); + + delete pTop; + delete pBottom; + delete pLeft; + delete pRight; + + bOk = sal_True; + } + break; + + case ITEMID_FMTBREAK: + { + SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem); + DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" ); + + sal_uInt16 eEnum; + + if( !rUnitConverter.convertEnum( eEnum, rValue, psXML_BreakType ) ) + return sal_False; + + if( eEnum == 0 ) + { + pFmtBreak->SetValue( SVX_BREAK_NONE ); + bOk = sal_True; + } + else + { + switch( nMemberId ) + { + case MID_BREAK_BEFORE: + pFmtBreak->SetValue( (eEnum == 1) ? + SVX_BREAK_COLUMN_BEFORE : + SVX_BREAK_PAGE_BEFORE ); + break; + case MID_BREAK_AFTER: + pFmtBreak->SetValue( (eEnum == 1) ? + SVX_BREAK_COLUMN_AFTER : + SVX_BREAK_PAGE_AFTER ); + break; + } + bOk = sal_True; + } + } + break; + + case ITEMID_FMTKEEP: + { + SvxFmtKeepItem* pFmtKeep = PTR_CAST(SvxFmtKeepItem, &rItem); + DBG_ASSERT( pFmtKeep != NULL, "Wrong Which-ID" ); + + sal_Bool bValue; + bOk = rUnitConverter.convertBool( bValue, rValue ); + if ( bOk ) + pFmtKeep->SetValue( bValue ); + } + break; + + case ITEMID_BRUSH: + { + SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem); + DBG_ASSERT( pBrush != NULL, "Wrong Which-ID" ); + + Color aTempColor; + switch( nMemberId ) + { + case MID_BACK_COLOR: + if( IsXMLToken( rValue, XML_TRANSPARENT ) ) + { + pBrush->GetColor().SetTransparency(0xff); + bOk = sal_True; + } + else if( rUnitConverter.convertColor( aTempColor, rValue ) ) + { + aTempColor.SetTransparency(0); + pBrush->SetColor( aTempColor ); + bOk = sal_True; + } + break; + + case MID_GRAPHIC_LINK: + { + SvxGraphicPosition eOldGraphicPos = pBrush->GetGraphicPos(); + uno::Any aAny; + aAny <<= rValue; + pBrush->PutValue( aAny, MID_GRAPHIC_URL ); + if( GPOS_NONE == eOldGraphicPos && + GPOS_NONE != pBrush->GetGraphicPos() ) + pBrush->SetGraphicPos( GPOS_TILED ); + bOk = sal_True ; + } + break; + + case MID_GRAPHIC_REPEAT: + { + SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos(); + sal_uInt16 nPos = GPOS_NONE; + if( rUnitConverter.convertEnum( nPos, rValue, + psXML_BrushRepeat ) ) + { + if( GPOS_MM != nPos || GPOS_NONE == eGraphicPos || + GPOS_AREA == eGraphicPos || GPOS_TILED == eGraphicPos ) + pBrush->SetGraphicPos( (SvxGraphicPosition)nPos ); + bOk = sal_True; + } + } + break; + + case MID_GRAPHIC_POSITION: + { + SvxGraphicPosition ePos = GPOS_NONE, eTmp; + sal_uInt16 nTmp; + SvXMLTokenEnumerator aTokenEnum( rValue ); + OUString aToken; + sal_Bool bHori = sal_False, bVert = sal_False; + bOk = sal_True; + while( bOk && aTokenEnum.getNextToken( aToken ) ) + { + if( bHori && bVert ) + { + bOk = sal_False; + } + else if( -1 != aToken.indexOf( sal_Unicode('%') ) ) + { + sal_Int32 nPrc = 50; + if( rUnitConverter.convertPercent( nPrc, aToken ) ) + { + if( !bHori ) + { + ePos = nPrc < 25 ? GPOS_LT : + (nPrc < 75 ? GPOS_MM : GPOS_RB); + bHori = sal_True; + } + else + { + eTmp = nPrc < 25 ? GPOS_LT: + (nPrc < 75 ? GPOS_LM : GPOS_LB); + lcl_frmitems_MergeXMLVertPos( ePos, eTmp ); + bVert = sal_True; + } + } + else + { + // wrong percentage + bOk = sal_False; + } + } + else if( IsXMLToken( aToken, XML_CENTER ) ) + { + if( bHori ) + lcl_frmitems_MergeXMLVertPos( ePos, GPOS_MM ); + else if ( bVert ) + lcl_frmitems_MergeXMLHoriPos( ePos, GPOS_MM ); + else + ePos = GPOS_MM; + } + else if( rUnitConverter.convertEnum( nTmp, aToken, + psXML_BrushHoriPos ) ) + { + if( bVert ) + lcl_frmitems_MergeXMLHoriPos( + ePos, (SvxGraphicPosition)nTmp ); + else if( !bHori ) + ePos = (SvxGraphicPosition)nTmp; + else + bOk = sal_False; + bHori = sal_True; + } + else if( rUnitConverter.convertEnum( nTmp, aToken, + psXML_BrushVertPos ) ) + { + if( bHori ) + lcl_frmitems_MergeXMLVertPos( + ePos, (SvxGraphicPosition)nTmp ); + else if( !bVert ) + ePos = (SvxGraphicPosition)nTmp; + else + bOk = sal_False; + bVert = sal_True; + } + else + { + bOk = sal_False; + } + } + + bOk &= GPOS_NONE != ePos; + if( bOk ) + pBrush->SetGraphicPos( ePos ); + } + break; + + case MID_GRAPHIC_FILTER: + pBrush->SetGraphicFilter( rValue.getStr() ); + bOk = sal_True; + break; + } + } + break; + + case RES_PAGEDESC: + { + SwFmtPageDesc* pPageDesc = PTR_CAST(SwFmtPageDesc, &rItem); + DBG_ASSERT( pPageDesc != NULL, "Wrong Which-ID" ); + + if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId ) + { + sal_Int32 nVal; + bOk = rUnitConverter.convertNumber( nVal, rValue, 0, USHRT_MAX ); + if( bOk ) + pPageDesc->SetNumOffset( (USHORT)nVal ); + } + } + break; + + case RES_LAYOUT_SPLIT: + { + SwFmtLayoutSplit* pLayoutSplit = PTR_CAST(SwFmtLayoutSplit, &rItem); + DBG_ASSERT( pLayoutSplit != NULL, "Wrong Which-ID" ); + + sal_Bool bValue; + bOk = rUnitConverter.convertBool( bValue, rValue ); + if( bOk ) + pLayoutSplit->SetValue( bValue ); + } + break; + + case RES_HORI_ORIENT: + { + SwFmtHoriOrient* pHoriOrient = PTR_CAST(SwFmtHoriOrient, &rItem); + DBG_ASSERT( pHoriOrient != NULL, "Wrong Which-ID" ); + + sal_uInt16 nValue; + bOk = rUnitConverter.convertEnum( nValue, rValue, + aXMLTableAlignMap ); + if( bOk ) + pHoriOrient->SetHoriOrient( (SwHoriOrient)nValue ); + } + break; + + case RES_VERT_ORIENT: + { + SwFmtVertOrient* pVertOrient = PTR_CAST(SwFmtVertOrient, &rItem); + DBG_ASSERT( pVertOrient != NULL, "Wrong Which-ID" ); + + sal_uInt16 nValue; + bOk = rUnitConverter.convertEnum( nValue, rValue, + aXMLTableVAlignMap ); + if( bOk ) + pVertOrient->SetVertOrient( (SwVertOrient)nValue ); + } + break; + + case RES_FRM_SIZE: + { + SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem); + DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" ); + + sal_Bool bSetHeight = sal_False; + sal_Bool bSetWidth = sal_False; + sal_Bool bSetSizeType = sal_False; + SwFrmSize eSizeType = ATT_VAR_SIZE; + sal_Int32 nMin = MINLAY; + + switch( nMemberId ) + { + case MID_FRMSIZE_REL_WIDTH: + { + sal_Int32 nValue; + bOk = rUnitConverter.convertPercent( nValue, rValue ); + if( bOk ) + { + if( nValue < 1 ) + nValue = 1; + else if( nValue > 100 ) + nValue = 100; + + pFrmSize->SetWidthPercent( (sal_Int8)nValue ); + } + } + break; + case MID_FRMSIZE_WIDTH: + bSetWidth = sal_True; + break; + case MID_FRMSIZE_MIN_HEIGHT: + eSizeType = ATT_MIN_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_FIX_HEIGHT: + eSizeType = ATT_FIX_SIZE; + bSetHeight = sal_True; + nMin = 1; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_COL_WIDTH: + eSizeType = ATT_FIX_SIZE; + bSetWidth = sal_True; + bSetSizeType = sal_True; + break; + case MID_FRMSIZE_REL_COL_WIDTH: + { + sal_Int32 nPos = rValue.indexOf( (sal_Unicode)'*' ); + if( -1L != nPos ) + { + OUString sNum( rValue.copy( 0L, nPos ) ); + sal_Int32 nValue = rValue.toInt32(); + if( nValue < MINLAY ) + nValue = MINLAY; + else if( nValue > USHRT_MAX ) + nValue = USHRT_MAX; + + pFrmSize->SetWidth( (sal_uInt16)nValue ); + pFrmSize->SetSizeType( ATT_VAR_SIZE ); + bOk = sal_True; + } + } + break; + } + + sal_Int32 nValue; + if( bSetHeight || bSetWidth ) + { + bOk = rUnitConverter.convertMeasure( nValue, rValue, nMin, + USHRT_MAX ); + if( bOk ) + { + if( bSetWidth ) + pFrmSize->SetWidth( (sal_uInt16)nValue ); + if( bSetHeight ) + pFrmSize->SetHeight( (sal_uInt16)nValue ); + if( bSetSizeType ) + pFrmSize->SetSizeType( eSizeType ); + } + } + } + break; + + case RES_FRAMEDIR: + { + const XMLPropertyHandler* pWritingModeHandler = + XMLPropertyHandlerFactory::CreatePropertyHandler( + XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT ); + if( pWritingModeHandler != NULL ) + { + Any aAny; + bOk = pWritingModeHandler->importXML( rValue, aAny, + rUnitConverter ); + if( bOk ) + bOk = rItem.PutValue( aAny ); + } + } + break; + + default: + DBG_ERROR("Item not implemented!"); + break; + } + + return bOk; +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlitem.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlitem.cxx new file mode 100644 index 000000000000..fe378c4599de --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlitem.cxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <bf_xmloff/xmlimp.hxx> + +#include "xmlimpit.hxx" + +#include "xmlitem.hxx" +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; + +SvXMLItemSetContext::SvXMLItemSetContext( SvXMLImport& rImp, USHORT nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + SfxItemSet& rISet, + const SvXMLImportItemMapper& rIMap, + const SvXMLUnitConverter& rUnitConverter ): + SvXMLImportContext( rImp, nPrfx, rLName ), + rItemSet( rISet ), + rIMapper( rIMap ), + rUnitConv( rUnitConverter ) + +{ + rIMapper.importXML( rItemSet, xAttrList, rUnitConv, + GetImport().GetNamespaceMap() ); +} + +SvXMLItemSetContext::~SvXMLItemSetContext() +{ +} + +SvXMLImportContext *SvXMLItemSetContext::CreateChildContext( USHORT nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +{ + SvXMLItemMapEntriesRef xMapEntries = rIMapper.getMapEntries(); + SvXMLItemMapEntry* pEntry = xMapEntries->getByName( nPrefix, rLocalName ); + + if( pEntry && 0 != (pEntry->nMemberId & MID_FLAG_ELEMENT_ITEM_IMPORT) ) + { + return CreateChildContext( nPrefix, rLocalName, xAttrList, + rItemSet, *pEntry, rUnitConv ); + } + else + { + return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + } +} + +/** This method is called from this instance implementation of + CreateChildContext if the element matches an entry in the + SvXMLImportItemMapper with the mid flag MID_FLAG_ELEMENT +*/ +SvXMLImportContext *SvXMLItemSetContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList, + SfxItemSet& rItemSet, + const SvXMLItemMapEntry& rEntry, + const SvXMLUnitConverter& rUnitConv ) +{ + return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmliteme.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmliteme.cxx new file mode 100644 index 000000000000..03dc7b6f9b72 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmliteme.cxx @@ -0,0 +1,269 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> + +#include <tools/shl.hxx> + +#include <bf_xmloff/xmluconv.hxx> +#include "xmlexpit.hxx" +#include <bf_xmloff/nmspmap.hxx> +#include <bf_xmloff/xmltabe.hxx> +#include "xmlbrshe.hxx" + +#include <bf_svx/tstpitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/unomid.hxx> + +#include <vcl/fldunit.hxx> + +#include <swmodule.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include "fmtornt.hxx" +#include <unomid.h> +#include "frmfmt.hxx" +#include "fmtfsize.hxx" +#include "swrect.hxx" + +#include "xmlexp.hxx" +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::binfilter::xmloff::token; + +extern SvXMLItemMapEntry aXMLTableItemMap[]; +extern SvXMLItemMapEntry aXMLTableRowItemMap[]; +extern SvXMLItemMapEntry aXMLTableCellItemMap[]; + + +class SwXMLTableItemMapper_Impl: public SvXMLExportItemMapper +{ + SwXMLBrushItemExport aBrushItemExport; + +protected: + + sal_uInt32 nAbsWidth; + + void AddAttribute( sal_uInt16 nPrefix, enum XMLTokenEnum eLName, + const OUString& rValue, + const SvXMLNamespaceMap& rNamespaceMap, + SvXMLAttributeList& rAttrList ) const; + +public: + + SwXMLTableItemMapper_Impl( + SvXMLItemMapEntriesRef rMapEntries, + SwXMLExport& rExp ); + + 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( + SvXMLExport& rExport, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet& rSet, + sal_uInt16 nFlags ) const; + + inline void SetAbsWidth( sal_uInt32 nAbs ); +}; + +SwXMLTableItemMapper_Impl::SwXMLTableItemMapper_Impl( + SvXMLItemMapEntriesRef rMapEntries, + SwXMLExport& rExp ) : + SvXMLExportItemMapper( rMapEntries ), + aBrushItemExport( rExp ), + nAbsWidth( USHRT_MAX ) +{ +} + +SwXMLTableItemMapper_Impl::~SwXMLTableItemMapper_Impl() +{ +} + +void SwXMLTableItemMapper_Impl::AddAttribute( sal_uInt16 nPrefix, + enum XMLTokenEnum eLName, + const OUString& rValue, + const SvXMLNamespaceMap& rNamespaceMap, + SvXMLAttributeList& rAttrList ) const +{ + OUString sName( rNamespaceMap.GetQNameByKey( nPrefix, + GetXMLToken(eLName) ) ); + rAttrList.AddAttribute( sName, 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 && SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, nMemberId, rUnitConverter ) ) + { + AddAttribute( rEntry.nNameSpace, rEntry.eLocalName, 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.eLocalName, + sBuffer.makeStringAndClear(), + rNamespaceMap, rAttrList ); + } + break; + case MID_FRMSIZE_REL_WIDTH: + { + OUString sValue; + if( SvXMLExportItemMapper::QueryXMLValue( + rItem, sValue, nMemberId, rUnitConverter ) ) + { + AddAttribute( rEntry.nNameSpace, rEntry.eLocalName, + 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( + SvXMLExport& rExport, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet&, + sal_uInt16 ) const +{ + switch( rEntry.nWhichId ) + { + case RES_BACKGROUND: + { + ((SwXMLTableItemMapper_Impl *)this)->aBrushItemExport.exportXML( + (const SvxBrushItem&)rItem ); + } + break; + } +} + +inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs ) +{ + nAbsWidth = nAbs; +} + +// ---------------------------------------------------------------------------- + +void SwXMLExport::_InitItemExport() +{ + // #110680# + pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP, + GetMM100UnitConverter().getXMLMeasureUnit(), getServiceFactory() ); + + xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap ); + xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap ); + xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap ); + + pTableItemMapper = new SwXMLTableItemMapper_Impl( xTableItemMap, *this ); +} + +void SwXMLExport::_FinitItemExport() +{ + delete pTableItemMapper; + delete pTwipUnitConv; +} + +void SwXMLExport::ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth ) +{ + ((SwXMLTableItemMapper_Impl *)pTableItemMapper) + ->SetAbsWidth( nAbsWidth ); + ExportFmt( rFmt, XML_TABLE ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlitemi.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlitemi.cxx new file mode 100644 index 000000000000..14e3fa5ee2ab --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlitemi.cxx @@ -0,0 +1,306 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <rtl/ustring.hxx> +#include <rsc/rscsfx.hxx> + +#include "xmlitmap.hxx" +#include "xmlimpit.hxx" +#include "xmlitem.hxx" +#include <bf_xmloff/i18nmap.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/families.hxx> + +#include <bf_svx/unomid.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/fontitem.hxx> +#include <bf_svx/tstpitem.hxx> +#include <bf_svx/boxitem.hxx> +#include <bf_svx/brshitem.hxx> +#include <bf_svx/langitem.hxx> + +#include "xmlbrshi.hxx" + +#include <paratr.hxx> + +#include <horiornt.hxx> + +#include <doc.hxx> +#include <unomid.h> + +#include "xmlimp.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +using rtl::OUString; + +extern SvXMLItemMapEntry aXMLTableItemMap[]; +extern SvXMLItemMapEntry aXMLTableColItemMap[]; +extern SvXMLItemMapEntry aXMLTableRowItemMap[]; +extern SvXMLItemMapEntry aXMLTableCellItemMap[]; + +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 = SvXMLImportItemMapper::PutXMLValue( + rItem, 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; + +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() +{ + 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 ) + { + 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() +{ + // #110680# + pTwipUnitConv = new SvXMLUnitConverter( MAP_TWIP, MAP_TWIP, getServiceFactory() ); + + xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap ); + xTableColItemMap = new SvXMLItemMapEntries( aXMLTableColItemMap ); + xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap ); + xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap ); + + pTableItemMapper = new SwXMLImportTableItemMapper_Impl( xTableItemMap ); +} + +void SwXMLImport::_FinitItemImport() +{ + delete pTableItemMapper; + delete pTwipUnitConv; +} + +SvXMLImportContext *SwXMLImport::CreateTableItemImportContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList, + sal_uInt16 nFamily, + SfxItemSet& rItemSet ) +{ + SvXMLItemMapEntriesRef xItemMap; + + switch( nFamily ) + { + case XML_STYLE_FAMILY_TABLE_TABLE: + xItemMap = xTableItemMap; + break; + case XML_STYLE_FAMILY_TABLE_COLUMN: + xItemMap = xTableColItemMap; + break; + case XML_STYLE_FAMILY_TABLE_ROW: + xItemMap = xTableRowItemMap; + break; + case XML_STYLE_FAMILY_TABLE_CELL: + xItemMap = xTableCellItemMap; + break; + } + + pTableItemMapper->setMapEntries( xItemMap ); + + return new SwXMLItemSetContext_Impl( *this, nPrefix, rLocalName, + xAttrList, rItemSet, + GetTableItemMapper(), + GetTwipUnitConverter() ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlitemm.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlitemm.cxx new file mode 100644 index 000000000000..e1ed34ddc3b5 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlitemm.cxx @@ -0,0 +1,291 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <bf_svx/unomid.hxx> + +#include <bf_xmloff/xmlnmspe.hxx> +#include "xmlitmap.hxx" + +#include <unomid.h> +namespace binfilter { + +using namespace ::binfilter::xmloff::token; + +#define M_E( p, l, w, m ) \ + { XML_NAMESPACE_##p, XML_##l, w, m } +#define M_E_SI( p, l, w, m ) \ + { XML_NAMESPACE_##p, XML_##l, w, MID_FLAG_SPECIAL_ITEM_IMPORT|m } +#define M_E_SE( p, l, w, m ) \ + { XML_NAMESPACE_##p, XML_##l, w, MID_FLAG_SPECIAL_ITEM_EXPORT|m } + +#define M_END { 0, XML_TOKEN_INVALID, 0, 0 } + +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 + M_E( STYLE, PAGE_NUMBER, RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET), + // 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 ), + + // RES_FRAMEDIR + M_E( STYLE, WRITING_MODE, RES_FRAMEDIR, 0 ), + M_END +}; + +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 ), + M_END +}; + +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 ), + M_END +}; + +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( FO, 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 ), + M_END +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlithlp.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlithlp.cxx new file mode 100644 index 000000000000..b5fac2c2cbb1 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlithlp.cxx @@ -0,0 +1,428 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "xmlithlp.hxx" + +#include "hintids.hxx" + +#include "unomid.h" + +#include <bf_svx/unomid.hxx> + +#include <bf_svx/lrspitem.hxx> + +#include <bf_svx/ulspitem.hxx> + +#include <bf_svx/shaditem.hxx> + +#include <bf_svx/boxitem.hxx> + +#include <bf_svx/brkitem.hxx> + +#include <bf_svx/keepitem.hxx> + +#include <bf_svx/brshitem.hxx> + +#include "fmtpdsc.hxx" + +#include <horiornt.hxx> + +#include "fmtornt.hxx" + +#include "fmtfsize.hxx" + +#include "fmtlsplt.hxx" + +#include <bf_xmloff/xmluconv.hxx> + +#include <bf_xmloff/xmltoken.hxx> +namespace binfilter { + + +using namespace ::rtl; +using namespace ::binfilter::xmloff::token; + + +#define SVX_XML_BORDER_STYLE_NONE 0 +#define SVX_XML_BORDER_STYLE_SOLID 1 +#define SVX_XML_BORDER_STYLE_DOUBLE 2 + +#define SVX_XML_BORDER_WIDTH_THIN 0 +#define SVX_XML_BORDER_WIDTH_MIDDLE 1 +#define SVX_XML_BORDER_WIDTH_THICK 2 + + +const struct SvXMLEnumMapEntry psXML_BorderStyles[] = +{ + { XML_NONE, SVX_XML_BORDER_STYLE_NONE }, + { XML_HIDDEN, SVX_XML_BORDER_STYLE_NONE }, + { XML_SOLID, SVX_XML_BORDER_STYLE_SOLID }, + { XML_DOUBLE, SVX_XML_BORDER_STYLE_DOUBLE }, + { XML_DOTTED, SVX_XML_BORDER_STYLE_SOLID }, + { XML_DASHED, SVX_XML_BORDER_STYLE_SOLID }, + { XML_GROOVE, SVX_XML_BORDER_STYLE_SOLID }, + { XML_RIDGE, SVX_XML_BORDER_STYLE_SOLID }, + { XML_INSET, SVX_XML_BORDER_STYLE_SOLID }, + { XML_OUTSET, SVX_XML_BORDER_STYLE_SOLID }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_NamedBorderWidths[] = +{ + { XML_THIN, SVX_XML_BORDER_WIDTH_THIN }, + { XML_MIDDLE, SVX_XML_BORDER_WIDTH_MIDDLE }, + { XML_THICK, SVX_XML_BORDER_WIDTH_THICK }, + { XML_TOKEN_INVALID, 0 } +}; +// mapping tables to map external xml input to intarnal box line widths + +// 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 + + +const sal_uInt16 aSBorderWidths[] = +{ + SBORDER_ENTRY( 0 ), SBORDER_ENTRY( 1 ), SBORDER_ENTRY( 2 ), + SBORDER_ENTRY( 3 ), SBORDER_ENTRY( 4 ) +}; + +const sal_uInt16 aDBorderWidths[5*11] = +{ + 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( 6 ), + DBORDER_ENTRY( 5 ) +}; + +sal_Bool lcl_frmitems_parseXMLBorder( const OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + sal_Bool& rHasStyle, sal_uInt16& rStyle, + sal_Bool& rHasWidth, sal_uInt16& rWidth, + sal_uInt16& rNamedWidth, + sal_Bool& rHasColor, Color& rColor ) +{ + OUString aToken; + SvXMLTokenEnumerator aTokens( rValue ); + + rHasStyle = sal_False; + rHasWidth = sal_False; + rHasColor = sal_False; + + rStyle = USHRT_MAX; + rWidth = 0; + rNamedWidth = USHRT_MAX; + + sal_Int32 nTemp; + while( aTokens.getNextToken( aToken ) && aToken.getLength() != 0 ) + { + if( !rHasWidth && + rUnitConverter.convertEnum( rNamedWidth, aToken, + psXML_NamedBorderWidths ) ) + { + rHasWidth = sal_True; + } + else if( !rHasStyle && + rUnitConverter.convertEnum( rStyle, aToken, + psXML_BorderStyles ) ) + { + rHasStyle = sal_True; + } + else if( !rHasColor && rUnitConverter.convertColor( rColor, aToken ) ) + { + rHasColor = sal_True; + } + else if( !rHasWidth && + rUnitConverter.convertMeasure( nTemp, aToken, 0, USHRT_MAX ) ) + { + rWidth = (sal_uInt16)nTemp; + rHasWidth = sal_True; + } + else + { + // missformed + return sal_False; + } + } + + return rHasStyle || rHasWidth || rHasColor; +} + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nOutWidth, sal_uInt16 nInWidth, + sal_uInt16 nDistance ) +{ + rLine.SetOutWidth( nOutWidth ); + rLine.SetInWidth( nInWidth ); + rLine.SetDistance( nDistance ); +} + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nWidth, sal_Bool bDouble ) +{ + const sal_uInt16 *aWidths; + sal_uInt16 nSize; + if( !bDouble ) + { + aWidths = aSBorderWidths; + nSize = sizeof( aSBorderWidths ); + } + else + { + aWidths = aDBorderWidths; + nSize = sizeof( aDBorderWidths ); + } + + sal_uInt16 i = (nSize / sizeof(sal_uInt16)) - 4; + while( i>0 && + nWidth <= ((aWidths[i] + aWidths[i-4]) / 2) ) + { + DBG_ASSERT( aWidths[i] >= aWidths[i-4], "line widths are unordered!" ); + i -= 4; + } + + rLine.SetOutWidth( aWidths[i+1] ); + rLine.SetInWidth( aWidths[i+2] ); + rLine.SetDistance( aWidths[i+3] ); +} + +sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_Bool bHasStyle, sal_uInt16 nStyle, + sal_Bool bHasWidth, sal_uInt16 nWidth, + sal_uInt16 nNamedWidth, + sal_Bool bHasColor, const Color& rColor ) +{ + // first of all, delete an empty line + if( (bHasStyle && SVX_XML_BORDER_STYLE_NONE == nStyle) || + (bHasWidth && USHRT_MAX == nNamedWidth && 0 == nWidth) ) + { + sal_Bool bRet = 0 != rpLine; + if( rpLine ) + { + delete rpLine; + rpLine = 0; + } + + return bRet; + } + + // if there is no line and no style and no with, there will never be a line + if( !rpLine && !(bHasStyle && bHasWidth) ) + return sal_False; + + // We now do know that there will be a line + if( !rpLine ) + rpLine = new SvxBorderLine; + + + if( ( bHasWidth && + (USHRT_MAX != nNamedWidth || (nWidth != rpLine->GetOutWidth() + + rpLine->GetInWidth() + + rpLine->GetDistance()) ) ) || + ( bHasStyle && + ((SVX_XML_BORDER_STYLE_SOLID == nStyle && rpLine->GetDistance()) || + (SVX_XML_BORDER_STYLE_DOUBLE == nStyle && !rpLine->GetDistance())) )) + { + sal_Bool bDouble = (bHasWidth && SVX_XML_BORDER_STYLE_DOUBLE == nStyle ) || + rpLine->GetDistance(); + + // The width has to be changed + if( bHasWidth && USHRT_MAX != nNamedWidth ) + { + const sal_uInt16 *aWidths = bDouble ? aDBorderWidths :aSBorderWidths; + + sal_uInt16 nNWidth = nNamedWidth * 4; + rpLine->SetOutWidth( aWidths[nNWidth+1] ); + rpLine->SetInWidth( aWidths[nNWidth+2] ); + rpLine->SetDistance( aWidths[nNWidth+3] ); + + } + else + { + if( !bHasWidth ) + nWidth = rpLine->GetInWidth() + rpLine->GetDistance() + + rpLine->GetOutWidth(); + + lcl_frmitems_setXMLBorderWidth( *rpLine, nWidth, bDouble ); + } + } + + // set color + if( bHasColor ) + rpLine->SetColor( rColor ); + + return sal_True; +} + +void lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_uInt16 nWidth, sal_uInt16 nOutWidth, + sal_uInt16 nInWidth, sal_uInt16 nDistance ) +{ + if( !rpLine ) + rpLine = new SvxBorderLine; + + if( nWidth > 0 ) + lcl_frmitems_setXMLBorderWidth( *rpLine, nWidth, sal_True ); + else + lcl_frmitems_setXMLBorderWidth( *rpLine, nOutWidth, nInWidth, + nDistance ); +} + +const struct SvXMLEnumMapEntry psXML_BrushRepeat[] = +{ + { XML_BACKGROUND_REPEAT, GPOS_TILED }, + { XML_BACKGROUND_NO_REPEAT, GPOS_MM }, + { XML_BACKGROUND_STRETCH, GPOS_AREA }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_BrushHoriPos[] = +{ + { XML_LEFT, GPOS_LM }, + { XML_RIGHT, GPOS_RM }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry psXML_BrushVertPos[] = +{ + { XML_TOP, GPOS_MT }, + { XML_BOTTOM, GPOS_MB }, + { XML_TOKEN_INVALID, 0 } +}; + +void lcl_frmitems_MergeXMLHoriPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eHori ) +{ + DBG_ASSERT( GPOS_LM==eHori || GPOS_MM==eHori || GPOS_RM==eHori, + "lcl_frmitems_MergeXMLHoriPos: vertical pos must be middle" ); + + switch( ePos ) + { + case GPOS_LT: + case GPOS_MT: + case GPOS_RT: + ePos = GPOS_LM==eHori ? GPOS_LT : (GPOS_MM==eHori ? GPOS_MT : GPOS_RT); + break; + + case GPOS_LM: + case GPOS_MM: + case GPOS_RM: + ePos = eHori; + break; + + case GPOS_LB: + case GPOS_MB: + case GPOS_RB: + ePos = GPOS_LM==eHori ? GPOS_LB : (GPOS_MM==eHori ? GPOS_MB : GPOS_RB); + break; + } +} + +void lcl_frmitems_MergeXMLVertPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eVert ) +{ + DBG_ASSERT( GPOS_MT==eVert || GPOS_MM==eVert || GPOS_MB==eVert, + "lcl_frmitems_MergeXMLVertPos: horizontal pos must be middle" ); + + switch( ePos ) + { + case GPOS_LT: + case GPOS_LM: + case GPOS_LB: + ePos = GPOS_MT==eVert ? GPOS_LT : (GPOS_MM==eVert ? GPOS_LM : GPOS_LB); + ePos = eVert; + break; + + case GPOS_MT: + case GPOS_MM: + case GPOS_MB: + ePos = eVert; + break; + + case GPOS_RT: + case GPOS_RM: + case GPOS_RB: + ePos = GPOS_MT==eVert ? GPOS_RT : (GPOS_MM==eVert ? GPOS_RM : GPOS_RB); + break; + } +} + + +const struct SvXMLEnumMapEntry psXML_BreakType[] = +{ + { XML_AUTO, 0 }, + { XML_COLUMN, 1 }, + { XML_PAGE, 2 }, + { XML_EVEN_PAGE, 2 }, + { XML_ODD_PAGE, 2 }, + { XML_TOKEN_INVALID, 0} +}; + +const struct SvXMLEnumMapEntry aXMLTableAlignMap[] = +{ + { XML_LEFT, HORI_LEFT }, + { XML_LEFT, HORI_LEFT_AND_WIDTH }, + { XML_CENTER, HORI_CENTER }, + { XML_RIGHT, HORI_RIGHT }, + { XML_MARGINS, HORI_FULL }, + { XML_MARGINS, HORI_NONE }, + { XML_TOKEN_INVALID, 0 } +}; + +const struct SvXMLEnumMapEntry aXMLTableVAlignMap[] = +{ + { XML_TOP, VERT_TOP }, + { XML_MIDDLE, VERT_CENTER }, + { XML_BOTTOM, VERT_BOTTOM }, + { XML_TOKEN_INVALID, 0 } +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlitmpr.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlitmpr.cxx new file mode 100644 index 000000000000..246abd112395 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlitmpr.cxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "xmlitmap.hxx" +namespace binfilter { + +using namespace rtl; +using ::binfilter::xmloff::token::IsXMLToken; +using ::binfilter::xmloff::token::XML_TOKEN_INVALID; + +// TODO: optimize this! + +class SvXMLItemMapEntries_impl +{ +public: + SvXMLItemMapEntry* mpEntries; + sal_uInt16 mnCount; +}; + +SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries ) +{ + mpImpl = new SvXMLItemMapEntries_impl; + mpImpl->mpEntries = pEntries; + + mpImpl->mnCount = 0; + while( pEntries->eLocalName != XML_TOKEN_INVALID ) + { + pEntries++; + mpImpl->mnCount++; + } +} + +SvXMLItemMapEntries::~SvXMLItemMapEntries() +{ + delete mpImpl; +} + +SvXMLItemMapEntry* SvXMLItemMapEntries::getByName( sal_uInt16 nNameSpace, + const OUString& rString, + SvXMLItemMapEntry* pStartAt /* = NULL */ ) const +{ + SvXMLItemMapEntry* pMap = + (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ? + &(pStartAt[1]) : mpImpl->mpEntries; + while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) ) + { + if( pMap->nNameSpace == nNameSpace && + IsXMLToken( rString, pMap->eLocalName ) ) + break; + pMap++; + } + + return (pMap->eLocalName != XML_TOKEN_INVALID) ? pMap : NULL; +} + +SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( UINT16 nIndex ) const +{ + return &mpImpl->mpEntries[nIndex]; +} + +UINT16 SvXMLItemMapEntries::getCount() const +{ + return mpImpl->mnCount; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlmeta.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlmeta.cxx new file mode 100644 index 000000000000..1d6b371b4889 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlmeta.cxx @@ -0,0 +1,289 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/document/XDocumentInfoSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XText.hpp> + +#include <bf_xmloff/xmlnmspe.hxx> + +#include <bf_xmloff/xmlmetai.hxx> + +#include <bf_xmloff/xmlmetae.hxx> +#include <bf_svx/langitem.hxx> +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/nmspmap.hxx> + +#include "docstat.hxx" +#include "docsh.hxx" + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include <errhdl.hxx> + +#include <unoobj.hxx> + +#include "xmlimp.hxx" +#include <bf_xmloff/ProgressBarHelper.hxx> +#include "xmlexp.hxx" +namespace binfilter { + + +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 ::binfilter::xmloff::token; + +using rtl::OUString; +using rtl::OUStringBuffer; + +// --------------------------------------------------------------------- + +#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( !pContext ) + pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE, + rLocalName ); + + return pContext; +} + +// --------------------------------------------------------------------- + +enum SvXMLTokenMapAttrs +{ + XML_TOK_META_STAT_TABLE = 1, + XML_TOK_META_STAT_IMAGE = 2, + XML_TOK_META_STAT_OLE = 4, + XML_TOK_META_STAT_PAGE = 8, + XML_TOK_META_STAT_PARA = 16, + XML_TOK_META_STAT_WORD = 32, + XML_TOK_META_STAT_CHAR = 64, + XML_TOK_META_STAT_END=XML_TOK_UNKNOWN +}; + +static __FAR_DATA SvXMLTokenMapEntry aMetaStatAttrTokenMap[] = +{ + { XML_NAMESPACE_META, XML_TABLE_COUNT, XML_TOK_META_STAT_TABLE }, + { XML_NAMESPACE_META, XML_IMAGE_COUNT, XML_TOK_META_STAT_IMAGE }, + { XML_NAMESPACE_META, XML_OBJECT_COUNT, XML_TOK_META_STAT_OLE }, + { XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, XML_TOK_META_STAT_PARA }, + { XML_NAMESPACE_META, XML_PAGE_COUNT, XML_TOK_META_STAT_PAGE }, + { XML_NAMESPACE_META, XML_WORD_COUNT, XML_TOK_META_STAT_WORD }, + { XML_NAMESPACE_META, XML_CHARACTER_COUNT, XML_TOK_META_STAT_CHAR }, + XML_TOKEN_MAP_END +}; +void SwXMLImport::SetStatisticAttributes( + const Reference< xml::sax::XAttributeList > & xAttrList) +{ + if( IsStylesOnlyMode() || IsInsertMode() ) + return; + + SvXMLImport::SetStatisticAttributes(xAttrList); + + Reference<XUnoTunnel> xCrsrTunnel( GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + SwDocStat aDocStat( pDoc->GetDocStat() ); + + SvXMLTokenMap aTokenMap( aMetaStatAttrTokenMap ); + + sal_uInt32 nTokens = 0; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rValue = xAttrList->getValueByIndex( i ); + sal_Int32 nValue; + if( !GetMM100UnitConverter().convertNumber( nValue, rValue ) ) + continue; + + const OUString& rAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + sal_uInt16 nPrefix = + GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); + + sal_uInt32 nToken = aTokenMap.Get( nPrefix, aLocalName ); + switch( nToken ) + { + case XML_TOK_META_STAT_TABLE: + aDocStat.nTbl = (sal_uInt16)nValue; + break; + case XML_TOK_META_STAT_IMAGE: + aDocStat.nGrf = (sal_uInt16)nValue; + break; + case XML_TOK_META_STAT_OLE: + aDocStat.nOLE = (sal_uInt16)nValue; + break; + case XML_TOK_META_STAT_PAGE: + aDocStat.nPage = (sal_uInt32)nValue; + break; + case XML_TOK_META_STAT_PARA: + aDocStat.nPara = (sal_uInt32)nValue; + break; + case XML_TOK_META_STAT_WORD: + aDocStat.nWord = (sal_uInt32)nValue; + break; + case XML_TOK_META_STAT_CHAR: + aDocStat.nChar = (sal_uInt32)nValue; + break; + default: + nToken = 0; + } + nTokens |= nToken; + } + + if( 127 == nTokens ) + aDocStat.bModified = sal_False; + if( nTokens ) + pDoc->SetDocStat( aDocStat ); + + // set progress bar reference to #paragraphs. If not available, + // use #pages*10, or guesstimate 250 paragraphs. Additionally + // guesstimate PROGRESS_BAR_STEPS each for meta+settings, styles, + // and autostyles. + sal_Int32 nProgressReference = 250; + if( nTokens & XML_TOK_META_STAT_PARA ) + nProgressReference = (sal_Int32)aDocStat.nPara; + else if ( nTokens & XML_TOK_META_STAT_PAGE ) + nProgressReference = 10 * (sal_Int32)aDocStat.nPage; + ProgressBarHelper* pProgress = GetProgressBarHelper(); + pProgress->SetReference( nProgressReference + 3*PROGRESS_BAR_STEP ); + pProgress->SetValue( 0 ); +} + +// --------------------------------------------------------------------- + +void SwXMLExport::_ExportMeta() +{ + SvXMLExport::_ExportMeta(); + + if( !IsBlockMode() ) + { + OUStringBuffer aOut(16); + + Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY ); + Reference < XText > xText = xTextDoc->getText(); + Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY); + ASSERT( xTextTunnel.is(), "missing XUnoTunnel for Cursor" ); + if( !xTextTunnel.is() ) + return; + + SwXText *pText = (SwXText *)xTextTunnel->getSomething( + SwXText::getUnoTunnelId() ); + ASSERT( pText, "SwXText missing" ); + if( !pText ) + return; + + SwDocStat aDocStat( pText->GetDoc()->GetDocStat() ); + aOut.append( (sal_Int32)aDocStat.nTbl ); + AddAttribute( XML_NAMESPACE_META, XML_TABLE_COUNT, + aOut.makeStringAndClear() ); + aOut.append( (sal_Int32)aDocStat.nGrf ); + AddAttribute( XML_NAMESPACE_META, XML_IMAGE_COUNT, + aOut.makeStringAndClear() ); + aOut.append( (sal_Int32)aDocStat.nOLE ); + AddAttribute( XML_NAMESPACE_META, XML_OBJECT_COUNT, + aOut.makeStringAndClear() ); + if( aDocStat.nPage ) + { + aOut.append( (sal_Int32)aDocStat.nPage ); + AddAttribute( XML_NAMESPACE_META, XML_PAGE_COUNT, + aOut.makeStringAndClear() ); + } + aOut.append( (sal_Int32)aDocStat.nPara ); + AddAttribute( XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, + aOut.makeStringAndClear() ); + aOut.append( (sal_Int32)aDocStat.nWord ); + AddAttribute( XML_NAMESPACE_META, XML_WORD_COUNT, + aOut.makeStringAndClear() ); + aOut.append( (sal_Int32)aDocStat.nChar ); + AddAttribute( XML_NAMESPACE_META, XML_CHARACTER_COUNT, + aOut.makeStringAndClear() ); + SvXMLElementExport aElem( *this, XML_NAMESPACE_META, + XML_DOCUMENT_STATISTIC, + sal_True, sal_True ); + + if( IsShowProgress() ) + { + ProgressBarHelper *pProgress = GetProgressBarHelper(); + pProgress->SetValue( pProgress->GetValue() + 2 ); + } + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmlscript.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmlscript.cxx new file mode 100644 index 000000000000..551a1ef7b6f4 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmlscript.cxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <hintids.hxx> + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/document/XDocumentInfoSupplier.hpp> + +#include <bf_xmloff/xmlnmspe.hxx> + +#include <bf_xmloff/xmlscripti.hxx> + +#include <bf_svx/langitem.hxx> + +#include "docsh.hxx" + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include "xmlimp.hxx" +#include "xmlexp.hxx" +namespace binfilter { + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +// --------------------------------------------------------------------- + +SvXMLImportContext *SwXMLImport::CreateScriptContext( + const OUString& rLocalName ) +{ + SvXMLImportContext *pContext = 0; + + if( !(IsStylesOnlyMode() || IsInsertMode()) ) + { + pContext = new XMLScriptContext( *this, + XML_NAMESPACE_OFFICE, rLocalName, + GetModel() ); + } + + if( !pContext ) + pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE, + rLocalName ); + + return pContext; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmltble.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmltble.cxx new file mode 100644 index 000000000000..f015d362d8e2 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmltble.cxx @@ -0,0 +1,1157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <hintids.hxx> + +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/text/XTextTable.hpp> + +#include <com/sun/star/table/XCell.hpp> + +#include <bf_xmloff/xmlnmspe.hxx> + +#include <bf_xmloff/xmltoken.hxx> + +#include <bf_xmloff/xmluconv.hxx> + +#include <bf_xmloff/numehelp.hxx> + +#include <bf_svtools/cntnrsrt.hxx> +#include <bf_svtools/zforlist.hxx> + +#include <bf_svx/brshitem.hxx> +#include <bf_svx/boxitem.hxx> +#ifndef __SGI_STL_LIST +#include <list> +#endif + +#include <errhdl.hxx> +#include "swtable.hxx" + +#include <horiornt.hxx> + +#include "doc.hxx" + +#include <errhdl.hxx> + +#include "pam.hxx" +#include "frmfmt.hxx" +#include "wrtswtbl.hxx" +#include "fmtfsize.hxx" +#include "fmtornt.hxx" +#include "cellatr.hxx" +#include "ddefld.hxx" +#include "swddetbl.hxx" +#include <ndole.hxx> + +#include <bf_so3/linkmgr.hxx> // for cTokenSeperator + +#include "unoobj.hxx" +#include "unotbl.hxx" + +#include "xmltexte.hxx" +#include "xmlexp.hxx" +#include <bf_sw/swrect.hxx> +namespace binfilter { + + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::binfilter::xmloff::token; +using ::com::sun::star::table::XCell; + +using rtl::OUString; +using rtl::OUStringBuffer; + + +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 ) +{ +#ifdef DBG_UTIL + 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 + { +#ifdef DBG_UTIL + 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 = (sal_uInt16)nWidth; +#ifdef DBG_UTIL + SwXMLTableColumn_Impl aCol( (sal_uInt16)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 != *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_uInt32 nCol, sal_uInt32 nRow, sal_Bool bTop ) +{ + rBuffer.append( rNamePrefix ); + rBuffer.append( (sal_Unicode)'.' ); + if( bTop ) + { + String sTmp; + lcl_GetTblBoxColStr( (sal_uInt16)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 SwTblBoxNumFormat *pNumFmt = 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; + + if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + pNumFmt = (const SwTblBoxNumFormat *)pItem; + + // empty styles have not to be exported + if( !pVertOrient && !pBrush && !pBox && !pNumFmt ) + return sal_False; + + // order is: -/-/-/num, + // -/-/box/-, --/-/box/num, + // -/brush/-/-, -/brush/-/num, -/brush/box/-, -/brush/box/num, + // vert/-/-/-, vert/-/-/num, vert/-/box/-, ver/-/box/num, + // vert/brush/-/-, vert/brush/-/num, vert/brush/box/-, + // vert/brush/box/num + 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 SwTblBoxNumFormat *pTestNumFmt = 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 ( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + { + if( !pNumFmt ) + break; + + pTestNumFmt = (const SwTblBoxNumFormat *)pItem; + } + else + { + if( pNumFmt ) + continue; + + } + + if( pVertOrient && + pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() ) + continue; + + if( pBrush && ( *pBrush != *pTestBrush ) ) + continue; + + if( pBox && ( *pBox != *pTestBox ) ) + continue; + + if( pNumFmt && pNumFmt->GetValue() != pTestNumFmt->GetValue() ) + 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; +} +// --------------------------------------------------------------------- + +class SwXMLTableInfo_Impl +{ + const SwTable *pTable; + Reference < XTextSection > xBaseSection; + sal_Bool bBaseSectionValid; + +public: + + inline SwXMLTableInfo_Impl( const SwTable *pTbl ); + + const SwTable *GetTable() const { return pTable; } + const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); } + + sal_Bool IsBaseSectionValid() const { return bBaseSectionValid; } + const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; } + inline void SetBaseSection( const Reference < XTextSection >& rBase ); +}; + +inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) : + pTable( pTbl ), + bBaseSectionValid( sal_False ) +{ +} + +inline void SwXMLTableInfo_Impl::SetBaseSection( + const Reference < XTextSection >& rBaseSection ) +{ + xBaseSection = rBaseSection; + bBaseSectionValid = sal_True; +} + +// --------------------------------------------------------------------- + + +void SwXMLExport::ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol ) +{ + // <style:style ...> + CheckAttrList(); + + // style:name="..." + AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, rCol.GetStyleName() ); + + // style:family="table-column" + AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE_COLUMN ); + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, XML_STYLE, sal_True, + sal_True ); + OUStringBuffer sValue; + if( rCol.GetWidthOpt() ) + { + GetTwipUnitConverter().convertMeasure( sValue, rCol.GetWidthOpt() ); + AddAttribute( XML_NAMESPACE_STYLE, XML_COLUMN_WIDTH, + sValue.makeStringAndClear() ); + } + if( rCol.GetRelWidth() ) + { + sValue.append( (sal_Int32)rCol.GetRelWidth() ); + sValue.append( (sal_Unicode)'*' ); + AddAttribute( XML_NAMESPACE_STYLE, XML_REL_COLUMN_WIDTH, + sValue.makeStringAndClear() ); + } + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, + XML_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, + SwXMLTableInfo_Impl& rTblInfo, + 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( (sal_uInt16)nColAbsWidth, sal_False ); + } + + ULONG 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, XML_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++ ) + { + SwTableBox *pBox = rBoxes[nBox]; + + sal_uInt16 nOldCPos = nCPos; + if( nBox < nBoxes-1U ) + nCPos += (sal_uInt16)SwWriteTable::GetBoxWidth( pBox ); + else + nCPos = (sal_uInt16)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 ) + { + SwFrmFmt *pFrmFmt = pBox->GetFrmFmt(); + if( rExpCells.AddCell( *pFrmFmt, rNamePrefix, nOldCol, nLine, + bTop) ) + ExportFmt( *pFrmFmt, XML_TABLE_CELL ); + + Reference < XCell > xCell = SwXCell::CreateXCell( + (SwFrmFmt *)rTblInfo.GetTblFmt(), + pBox, 0, + (SwTable *)rTblInfo.GetTable() ); + if (xCell.is()) + { + Reference < XText > xText( xCell, UNO_QUERY ); + if( !rTblInfo.IsBaseSectionValid() ) + { + Reference<XPropertySet> xCellPropertySet( xCell, + UNO_QUERY ); + OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") ); + Any aAny = xCellPropertySet->getPropertyValue(sTextSection); + Reference < XTextSection > xTextSection; + aAny >>= xTextSection; + rTblInfo.SetBaseSection( xTextSection ); + } + GetTextParagraphExport()->collectTextAutoStyles( + xText, rTblInfo.GetBaseSection(), IsShowProgress() ); + } + else + DBG_ERROR("here should be a XCell"); + } + else + { + lcl_xmltble_appendBoxPrefix( sBuffer, rNamePrefix, nOldCol, + nLine, bTop ); + + ExportTableLinesAutoStyles( pBox->GetTabLines(), + nAbsWidth, nBaseWidth, + sBuffer.makeStringAndClear(), + rExpCols, rExpRows, rExpCells, + rTblInfo ); + } + + 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 ); + SwXMLTableInfo_Impl aTblInfo( &rTbl ); + ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth, + sName, aExpCols, aExpRows, aExpCells, + aTblInfo, sal_True); + } +} + +// --------------------------------------------------------------------- + +void SwXMLExport::ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan, + SwXMLTableInfo_Impl& rTblInfo ) +{ + 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, XML_STYLE_NAME, rName ); + } + } + } + + if( nColSpan != 1 ) + { + OUStringBuffer sTmp; + sTmp.append( (sal_Int32)nColSpan ); + AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, + sTmp.makeStringAndClear() ); + } + + { + if( pBoxSttNd ) + { + // start node -> normal cell + + // get cell range for table + Reference<XCell> xCell = SwXCell::CreateXCell( (SwFrmFmt *)rTblInfo.GetTblFmt(), + (SwTableBox *)&rBox, 0, + (SwTable *)rTblInfo.GetTable() ); + + if (xCell.is()) + { + Reference<XText> xText( xCell, UNO_QUERY ); + + // get formula (and protection) + OUString sCellFormula = xCell->getFormula(); + + // if this cell has a formula, export it + // (with value and number format) + if (sCellFormula.getLength()>0) + { + // formula + AddAttribute(XML_NAMESPACE_TABLE, XML_FORMULA, + sCellFormula); + } + + // value and format (if NumberFormat != -1) + Reference<XPropertySet> xCellPropertySet(xCell, + UNO_QUERY); + if (xCellPropertySet.is()) + { + sal_Int32 nNumberFormat; + Any aAny = xCellPropertySet->getPropertyValue(sNumberFormat); + aAny >>= nNumberFormat; + + if (NUMBERFORMAT_TEXT == nNumberFormat) + { + // text format + AddAttribute( XML_NAMESPACE_TABLE, + XML_VALUE_TYPE, XML_STRING ); + } + else if (-1 != nNumberFormat) + { + // number format key: + // (export values only if cell contains text; + // cf. #83755#) + XMLNumberFormatAttributesExportHelper:: + SetNumberFormatAttributes( + *this, nNumberFormat, xCell->getValue(), + XML_NAMESPACE_TABLE, + (xText->getString().getLength() > 0) ); + } + // else: invalid key; ignore + + // cell protection + aAny = xCellPropertySet->getPropertyValue(sIsProtected); + if (*(sal_Bool*)aAny.getValue()) + { + AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED, + XML_TRUE ); + } + + if( !rTblInfo.IsBaseSectionValid() ) + { + OUString sTextSection( RTL_CONSTASCII_USTRINGPARAM("TextSection") ); + aAny = xCellPropertySet->getPropertyValue(sTextSection); + Reference < XTextSection > xTextSection; + aAny >>= xTextSection; + rTblInfo.SetBaseSection( xTextSection ); + } + } + + // export cell element + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_TABLE_CELL, sal_True, sal_True ); + + // export cell content + GetTextParagraphExport()->exportText( xText, + rTblInfo.GetBaseSection(), + IsShowProgress() ); + } + else + { + DBG_ERROR("here should be a XCell"); + ClearAttrList(); + } + } + else + { + // no start node -> merged cells: export subtable in cell + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_TABLE_CELL, sal_True, sal_True ); + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_SUB_TABLE, sal_True, sal_True ); + ExportTableLines( rBox.GetTabLines(), rTblInfo ); + } + } + } +} + +void SwXMLExport::ExportTableLine( const SwTableLine& rLine, + const SwXMLTableLines_Impl& rLines, + SwXMLTableInfo_Impl& rTblInfo ) +{ + const SwFrmFmt *pFrmFmt = rLine.GetFrmFmt(); + if( pFrmFmt ) + { + const String& rName = pFrmFmt->GetName(); + if( rName.Len() ) + { + AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, rName ); + } + } + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_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 = (sal_uInt16)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, rTblInfo ); + for( sal_uInt16 i=nOldCol; i<nCol; i++ ) + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_COVERED_TABLE_CELL, sal_True, + sal_False ); + } + + nCol++; + } + } +} + +void SwXMLExport::ExportTableLines( const SwTableLines& rLines, + SwXMLTableInfo_Impl& rTblInfo, + 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; + + pTableLines->Remove( nInfoPos ); + if( 0 == pTableLines->Count() ) + { + delete pTableLines ; + pTableLines = 0; + } + + // 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, XML_STYLE_NAME, + pColumn->GetStyleName() ); + + if( nColRep > 1U ) + { + OUStringBuffer sTmp(4); + sTmp.append( (sal_Int32)nColRep ); + AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, + sTmp.makeStringAndClear() ); + } + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + XML_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, + XML_TABLE_HEADER_ROWS, sal_True, sal_True ); + ExportTableLine( *pLine, *pLines, rTblInfo ); + } + else + { + ExportTableLine( *pLine, *pLines, rTblInfo ); + } + } + + 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, XML_NAME, pTblFmt->GetName() ); + AddAttribute( XML_NAMESPACE_TABLE, XML_STYLE_NAME, + pTblFmt->GetName() ); + } + + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_TABLE, + sal_True, sal_True ); + + // export DDE source (if this is a DDE table) + if ( rTbl.ISA(SwDDETable) ) + { + // get DDE Field Type (contains the DDE connection) + const SwDDEFieldType* pDDEFldType = + ((SwDDETable&)rTbl).GetDDEFldType(); + + // connection name + AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, + pDDEFldType->GetName() ); + + // DDE command + const String sCmd = pDDEFldType->GetCmd(); + AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION, + sCmd.GetToken(0, ::binfilter::cTokenSeperator) ); + AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_ITEM, + sCmd.GetToken(1, ::binfilter::cTokenSeperator) ); + AddAttribute( XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, + sCmd.GetToken(2, ::binfilter::cTokenSeperator) ); + + // auto update + if (pDDEFldType->GetType() == ::binfilter::LINKUPDATE_ALWAYS) + { + AddAttribute( XML_NAMESPACE_OFFICE, + XML_AUTOMATIC_UPDATE, XML_TRUE ); + } + + // DDE source element (always empty) + SvXMLElementExport aSource(*this, XML_NAMESPACE_OFFICE, + XML_DDE_SOURCE, sal_True, sal_False); + } + + SwXMLTableInfo_Impl aTblInfo( &rTbl ); + ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.IsHeadlineRepeat() ); + + ((SwTable &)rTbl).GetTabLines().ForEach( &lcl_xmltble_ClearName_Line, + 0 ); + } +} + +void SwXMLTextParagraphExport::exportTable( + const Reference < XTextContent > & rTextContent, + sal_Bool bAutoStyles, sal_Bool bProgress ) +{ + sal_Bool bOldShowProgress = ((SwXMLExport&)GetExport()).IsShowProgress(); + ((SwXMLExport&)GetExport()).SetShowProgress( bProgress ); + + Reference < XTextTable > xTxtTbl( rTextContent, UNO_QUERY ); + 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 ); + } + } + } + + ((SwXMLExport&)GetExport()).SetShowProgress( bOldShowProgress ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmltbli.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmltbli.cxx new file mode 100644 index 000000000000..c360d4db3b8c --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmltbli.cxx @@ -0,0 +1,2774 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "hintids.hxx" + +#include <limits.h> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/text/XTextTable.hpp> + +#include <com/sun/star/table/XCellRange.hpp> + +#include <bf_svtools/itemset.hxx> + +#include <bf_xmloff/xmlnmspe.hxx> + +#include <bf_xmloff/xmltkmap.hxx> + +#include <bf_xmloff/nmspmap.hxx> + +#include <bf_xmloff/families.hxx> + +#include <bf_xmloff/xmluconv.hxx> +#include <bf_xmloff/i18nmap.hxx> + +#include <bf_svx/protitem.hxx> + +#include "poolfmt.hxx" +#include "fmtfsize.hxx" + +#include <horiornt.hxx> + +#include "fmtornt.hxx" + +#include <errhdl.hxx> + +#include "fmtfordr.hxx" +#include "doc.hxx" +#include "swtable.hxx" +#include "swtblfmt.hxx" + +#include <errhdl.hxx> + +#include "pam.hxx" +#include "unotbl.hxx" +#include "unocrsr.hxx" +#include "cellatr.hxx" +#include "swddetbl.hxx" +#include "ddefld.hxx" + +#include <bf_so3/linkmgr.hxx> // for cTokenSeparator + +#include "xmlimp.hxx" +#include "xmltbli.hxx" + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> + +#include "ndtxt.hxx" +namespace binfilter { + +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; +using namespace ::binfilter::xmloff::token; +using ::std::hash_map; + +using rtl::OUString; + +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_OFFICE_DDE_SOURCE, + XML_TOK_TABLE_ELEM_END=XML_TOK_UNKNOWN +}; + +enum SwXMLTableCellAttrTokens +{ + XML_TOK_TABLE_STYLE_NAME, + XML_TOK_TABLE_NUM_COLS_SPANNED, + XML_TOK_TABLE_NUM_ROWS_SPANNED, + XML_TOK_TABLE_NUM_COLS_REPEATED, + XML_TOK_TABLE_FORMULA, + XML_TOK_TABLE_VALUE, + XML_TOK_TABLE_TIME_VALUE, + XML_TOK_TABLE_DATE_VALUE, + XML_TOK_TABLE_BOOLEAN_VALUE, + XML_TOK_TABLE_PROTECTED, + XML_TOK_TABLE_CELL_ATTR_END=XML_TOK_UNKNOWN +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, + XML_TOK_TABLE_HEADER_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS }, + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COL }, + { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, + XML_TOK_TABLE_HEADER_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS }, + { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW }, + { XML_NAMESPACE_OFFICE, XML_DDE_SOURCE, + XML_TOK_OFFICE_DDE_SOURCE }, + + // There are slight differences between <table:table-columns> and + // <table:table-columns-groups>. However, none of these are + // supported in Writer (they are Calc-only features), so we + // support column groups by simply using the <table:table-columns> + // token for column groups, too. + { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN_GROUP, XML_TOK_TABLE_COLS }, + + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aTableCellAttrTokenMap[] = +{ + { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, + { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_NUM_COLS_SPANNED }, + { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_NUM_ROWS_SPANNED }, + { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, XML_TOK_TABLE_NUM_COLS_REPEATED }, + { XML_NAMESPACE_TABLE, XML_FORMULA, XML_TOK_TABLE_FORMULA }, + { XML_NAMESPACE_TABLE, XML_VALUE, XML_TOK_TABLE_VALUE }, + { XML_NAMESPACE_TABLE, XML_TIME_VALUE, XML_TOK_TABLE_TIME_VALUE }, + { XML_NAMESPACE_TABLE, XML_DATE_VALUE, XML_TOK_TABLE_DATE_VALUE }, + { XML_NAMESPACE_TABLE, XML_BOOLEAN_VALUE, XML_TOK_TABLE_BOOLEAN_VALUE }, + { XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TOK_TABLE_PROTECTED }, + { XML_NAMESPACE_TABLE, XML_PROTECT, XML_TOK_TABLE_PROTECTED }, // for backwards compatibility with SRC629 (and before) + + XML_TOKEN_MAP_END +}; + +const SvXMLTokenMap& SwXMLImport::GetTableElemTokenMap() +{ + if( !pTableElemTokenMap ) + pTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap ); + + return *pTableElemTokenMap; +} + +const SvXMLTokenMap& SwXMLImport::GetTableCellAttrTokenMap() +{ + if( !pTableCellAttrTokenMap ) + pTableCellAttrTokenMap = new SvXMLTokenMap( aTableCellAttrTokenMap ); + + return *pTableCellAttrTokenMap; +} + +// --------------------------------------------------------------------- + +class SwXMLTableCell_Impl +{ + OUString aStyleName; + + OUString sFormula; // cell formula; valid if length > 0 + double dValue; // formula value + + SvXMLImportContextRef xSubTable; + + const SwStartNode *pStartNode; + sal_uInt32 nRowSpan; + sal_uInt32 nColSpan; + + sal_Bool bProtected : 1; + sal_Bool bHasValue; // determines whether dValue attribute is valid + +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 bProtect = sal_False, + const OUString* pFormula = NULL, + sal_Bool bHasValue = sal_False, + double dVal = 0.0 ); + + 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 OUString& GetFormula() const { return sFormula; } + double GetValue() const { return dValue; } + sal_Bool HasValue() const { return bHasValue; } + sal_Bool IsProtected() const { return bProtected; } + + 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, + sal_Bool bProtect, + const OUString* pFormula, + sal_Bool bHasVal, + double dVal) +{ + aStyleName = rStyleName; + nRowSpan = nRSpan; + nColSpan = nCSpan; + pStartNode = pStNd; + xSubTable = pTable; + dValue = dVal; + bHasValue = bHasVal; + bProtected = bProtect; + + // set formula, if valid + if (pFormula != NULL) + { + sFormula = *pFormula; + } +} + +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; + OUString aDfltCellStyleName; + + SwXMLTableCells_Impl aCells; + + sal_Bool bSplitable; + +public: + + SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells, + const OUString *pDfltCellStyleName = 0 ); + ~SwXMLTableRow_Impl() {} + + inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol ) const; + + inline void Set( const OUString& rStyleName, + const OUString& rDfltCellStyleName ); + + 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; } + const OUString& GetDefaultCellStyleName() const { return aDfltCellStyleName; } + + void Dispose(); +}; + +SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName, + sal_uInt32 nCells, + const OUString *pDfltCellStyleName ) : + aStyleName( rStyleName ), + bSplitable( sal_False ) +{ + if( pDfltCellStyleName ) + aDfltCellStyleName = *pDfltCellStyleName; + 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, + const OUString& rDfltCellStyleName ) +{ + aStyleName = rStyleName; + aDfltCellStyleName = rDfltCellStyleName; +} + +void SwXMLTableRow_Impl::Dispose() +{ + for( sal_uInt16 i=0; i < aCells.Count(); i++ ) + aCells[i]->Dispose(); +} + +// --------------------------------------------------------------------- + +class SwXMLTableCellContext_Impl : public SvXMLImportContext +{ + OUString aStyleName; + OUString sFormula; + + SvXMLImportContextRef xMyTable; + + double fValue; + sal_Bool bHasValue; + sal_Bool bProtect; + + sal_uInt32 nRowSpan; + sal_uInt32 nColSpan; + sal_uInt32 nColRepeat; + + sal_Bool bHasTextContent : 1; + sal_Bool bHasTableContent : 1; + + SwXMLTableContext *GetTable() { return (SwXMLTableContext *)&xMyTable; } + + sal_Bool HasContent() const { return bHasTextContent || bHasTableContent; } + inline void _InsertContent(); + inline void InsertContent(); + 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 ), + nColRepeat( 1UL ), + bHasTextContent( sal_False ), + bHasTableContent( sal_False ), + sFormula(), + fValue( 0.0 ), + bHasValue( sal_False ), + bProtect( 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 ); + const SvXMLTokenMap& rTokenMap = + GetSwImport().GetTableCellAttrTokenMap(); + switch( rTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_TABLE_STYLE_NAME: + aStyleName = rValue; + break; + case XML_TOK_TABLE_NUM_COLS_SPANNED: + nColSpan = (sal_uInt32)rValue.toInt32(); + if( nColSpan < 1UL ) + nColSpan = 1UL; + break; + case XML_TOK_TABLE_NUM_ROWS_SPANNED: + nRowSpan = (sal_uInt32)rValue.toInt32(); + if( nRowSpan < 1UL ) + nRowSpan = 1UL; + break; + case XML_TOK_TABLE_NUM_COLS_REPEATED: + nColRepeat = (sal_uInt32)rValue.toInt32(); + if( nColRepeat < 1UL ) + nColRepeat = 1UL; + break; + case XML_TOK_TABLE_FORMULA: + sFormula = rValue; + break; + case XML_TOK_TABLE_VALUE: + { + double fTmp; + if (SvXMLUnitConverter::convertDouble(fTmp, rValue)) + { + fValue = fTmp; + bHasValue = sal_True; + } + } + break; + case XML_TOK_TABLE_TIME_VALUE: + { + double fTmp; + if (SvXMLUnitConverter::convertTime(fTmp, rValue)) + { + fValue = fTmp; + bHasValue = sal_True; + } + } + break; + case XML_TOK_TABLE_DATE_VALUE: + { + double fTmp; + if (GetImport().GetMM100UnitConverter().convertDateTime(fTmp, + rValue)) + { + fValue = fTmp; + bHasValue = sal_True; + } + } + break; + case XML_TOK_TABLE_BOOLEAN_VALUE: + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, rValue)) + { + fValue = (bTmp ? 1.0 : 0.0); + bHasValue = sal_True; + } + } + break; + case XML_TOK_TABLE_PROTECTED: + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, rValue)) + { + bProtect = bTmp; + } + } + break; + } + } +} + +SwXMLTableCellContext_Impl::~SwXMLTableCellContext_Impl() +{ +} + +inline void SwXMLTableCellContext_Impl::_InsertContent() +{ + GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, + GetTable()->InsertTableSection(), + NULL, bProtect, &sFormula, bHasValue, fValue); +} + +inline void SwXMLTableCellContext_Impl::InsertContent() +{ + ASSERT( !HasContent(), "content already there" ); + _InsertContent(); + bHasTextContent = sal_True; +} + +inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere() +{ + if( !HasContent() ) + InsertContent(); +} + +inline void SwXMLTableCellContext_Impl::InsertContent( + SwXMLTableContext *pTable ) +{ + GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, pTable, bProtect ); + bHasTableContent = sal_True; +} + +SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList > & xAttrList ) +{ + SvXMLImportContext *pContext = 0; + + if( XML_NAMESPACE_TABLE == nPrefix && + IsXMLToken( rLocalName, XML_SUB_TABLE ) ) + { + if( !HasContent() ) + { + SwXMLTableContext *pTblContext = + new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName, + xAttrList, GetTable() ); + pContext = pTblContext; + if( GetTable()->IsValid() ) + InsertContent( pTblContext ); + } + } + else + { + if( GetTable()->IsValid() ) + InsertContentIfNotThere(); + pContext = GetImport().GetTextImport()->CreateTextChildContext( + GetImport(), nPrefix, rLocalName, xAttrList, + XML_TEXT_TYPE_CELL ); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void SwXMLTableCellContext_Impl::EndElement() +{ + if( GetTable()->IsValid() ) + { + sal_Bool bEmpty = sal_False; + if( bHasTextContent ) + { + GetImport().GetTextImport()->DeleteParagraph(); + if( nColRepeat > 1 && nColSpan == 1 ) + { + // The original text is is invalid after deleting the last + // paragraph + Reference < XTextCursor > xSrcTxtCursor = + GetImport().GetTextImport()->GetText()->createTextCursor(); + xSrcTxtCursor->gotoEnd( sal_True ); + + // Until we have an API for copying we have to use the core. + Reference<XUnoTunnel> xSrcCrsrTunnel( xSrcTxtCursor, UNO_QUERY); + ASSERT( xSrcCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pSrcTxtCrsr = + (OTextCursorHelper*)xSrcCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pSrcTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pSrcTxtCrsr->GetDoc(); + const SwPaM *pSrcPaM = pSrcTxtCrsr->GetPaM(); + + while( nColRepeat > 1 && GetTable()->IsInsertCellPossible() ) + { + _InsertContent(); + + Reference<XUnoTunnel> xDstCrsrTunnel( + GetImport().GetTextImport()->GetCursor(), UNO_QUERY); + ASSERT( xDstCrsrTunnel.is(), + "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pDstTxtCrsr = + (OTextCursorHelper*)xDstCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pDstTxtCrsr, "SwXTextCursor missing" ); + SwPaM aSrcPaM( *pSrcPaM->GetPoint(), + *pSrcPaM->GetMark() ); + SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); + pDoc->Copy( aSrcPaM, aDstPos ); + + nColRepeat--; + } + } + } + else if( !bHasTableContent ) + { + InsertContent(); + if( nColRepeat > 1 && nColSpan == 1 ) + { + while( nColRepeat > 1 && GetTable()->IsInsertCellPossible() ) + { + _InsertContent(); + nColRepeat--; + } + } + } + } +} + +// --------------------------------------------------------------------- + +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, aDfltCellStyleName; + + 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( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + aStyleName = rValue; + else if( IsXMLToken( aLocalName, XML_NUMBER_COLUMNS_REPEATED ) ) + nColRep = (sal_uInt32)rValue.toInt32(); + else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) + aDfltCellStyleName = rValue; + } + } + + sal_Int32 nWidth = MINLAY; + sal_Bool bRelWidth = sal_True; + if( aStyleName.getLength() ) + { + const SfxPoolItem *pItem; + const SfxItemSet *pAutoItemSet = 0; + if( GetSwImport().FindAutomaticStyle( + XML_STYLE_FAMILY_TABLE_COLUMN, + 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, &aDfltCellStyleName ); + } +} + +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 && + IsXMLToken( rLocalName, XML_TABLE_COLUMN ) && + 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; + + sal_uInt32 nRowRepeat; + + 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 ), + nRowRepeat( 1 ) +{ + OUString aStyleName, aDfltCellStyleName; + + 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( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + { + aStyleName = rValue; + } + else if( IsXMLToken( aLocalName, XML_NUMBER_ROWS_REPEATED ) ) + { + nRowRepeat = (sal_uInt32)rValue.toInt32(); + if( nRowRepeat < 1UL ) + nRowRepeat = 1UL; + } + else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) + { + aDfltCellStyleName = rValue; + } + } + } + if( GetTable()->IsValid() ) + GetTable()->InsertRow( aStyleName, aDfltCellStyleName, bInHead ); +} + +void SwXMLTableRowContext_Impl::EndElement() +{ + if( GetTable()->IsValid() ) + { + GetTable()->FinishRow(); + + if( nRowRepeat > 1UL ) + GetTable()->InsertRepRows( nRowRepeat ); + } +} + +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( IsXMLToken( rLocalName, XML_TABLE_CELL ) ) + { + if( !GetTable()->IsValid() || GetTable()->IsInsertCellPossible() ) + pContext = new SwXMLTableCellContext_Impl( GetSwImport(), + nPrefix, + rLocalName, + xAttrList, + GetTable() ); + } + else if( IsXMLToken( rLocalName, XML_COVERED_TABLE_CELL ) ) + 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 && + IsXMLToken( rLocalName, XML_TABLE_ROW ) && + GetTable()->IsInsertRowPossible() ) + pContext = new SwXMLTableRowContext_Impl( GetSwImport(), nPrefix, + rLocalName, xAttrList, + GetTable(), + bHeader ); + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +// --------------------------------------------------------------------- + +class SwXMLDDETableContext_Impl : public SvXMLImportContext +{ + OUString sConnectionName; + OUString sDDEApplication; + OUString sDDEItem; + OUString sDDETopic; + sal_Bool bIsAutomaticUpdate; + +public: + + TYPEINFO(); + + SwXMLDDETableContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName); + + ~SwXMLDDETableContext_Impl(); + + virtual void StartElement( + const Reference<xml::sax::XAttributeList> & xAttrList); + + OUString& GetConnectionName() { return sConnectionName; } + OUString& GetDDEApplication() { return sDDEApplication; } + OUString& GetDDEItem() { return sDDEItem; } + OUString& GetDDETopic() { return sDDETopic; } + sal_Bool GetIsAutomaticUpdate() { return bIsAutomaticUpdate; } +}; + +TYPEINIT1( SwXMLDDETableContext_Impl, SvXMLImportContext ); + +SwXMLDDETableContext_Impl::SwXMLDDETableContext_Impl( + SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName) : + SvXMLImportContext(rImport, nPrfx, rLName), + sConnectionName(), + sDDEApplication(), + sDDEItem(), + sDDETopic(), + bIsAutomaticUpdate(sal_False) +{ +} + +SwXMLDDETableContext_Impl::~SwXMLDDETableContext_Impl() +{ +} + +void SwXMLDDETableContext_Impl::StartElement( + const Reference<xml::sax::XAttributeList> & xAttrList) +{ + 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_OFFICE == nPrefix) + { + if ( IsXMLToken( aLocalName, XML_DDE_APPLICATION ) ) + { + sDDEApplication = rValue; + } + else if ( IsXMLToken( aLocalName, XML_DDE_TOPIC ) ) + { + sDDETopic = rValue; + } + else if ( IsXMLToken( aLocalName, XML_DDE_ITEM ) ) + { + sDDEItem = rValue; + } + else if ( IsXMLToken( aLocalName, XML_NAME ) ) + { + sConnectionName = rValue; + } + else if ( IsXMLToken( aLocalName, XML_AUTOMATIC_UPDATE ) ) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, rValue)) + { + bIsAutomaticUpdate = bTmp; + } + } + // else: unknown attribute + } + // else: unknown attribute namespace + } +} + +// generate a new name for DDE field type (called by lcl_GetDDEFieldType below) +String lcl_GenerateFldTypeName(OUString sPrefix, SwTableNode* pTableNode) +{ + String sPrefixStr(sPrefix); + + if (sPrefixStr.Len() == 0) + { + sPrefixStr = String('_'); + } +// else if (sPrefixStr.Copy(0, 1).IsAlphaAscii()) +// { +// sPrefixStr.Insert('_', 0); +// } + // else: name is OK. + + // increase count until we find a name that is not yet taken + String sName; + sal_Int32 nCount = 0; + do + { + // this is crazy, but just in case all names are taken: exit gracefully + if (nCount < 0) + return sName; + + nCount++; + sName = sPrefixStr; + sName += String::CreateFromInt32(nCount); + + } + while (NULL != pTableNode->GetDoc()->GetFldType(RES_DDEFLD, sName)); + + return sName; +} + +// set table properties +SwDDEFieldType* lcl_GetDDEFieldType(SwXMLDDETableContext_Impl* pContext, + SwTableNode* pTableNode) +{ + // make command string + String sCommand(pContext->GetDDEApplication()); + sCommand += ::binfilter::cTokenSeperator; + sCommand += String(pContext->GetDDEItem()); + sCommand += ::binfilter::cTokenSeperator; + sCommand += String(pContext->GetDDETopic()); + + sal_uInt16 nType = pContext->GetIsAutomaticUpdate() ? ::binfilter::LINKUPDATE_ALWAYS + : ::binfilter::LINKUPDATE_ONCALL; + + String sName(pContext->GetConnectionName()); + + // field type to be returned + SwDDEFieldType* pType = NULL; + + // valid name? + if (sName.Len() == 0) + { + sName = lcl_GenerateFldTypeName(pContext->GetDDEApplication(), + pTableNode); + } + else + { + // check for existing DDE field type with the same name + SwDDEFieldType* pOldType = (SwDDEFieldType*)pTableNode->GetDoc()-> + GetFldType(RES_DDEFLD, sName); + if (NULL != pOldType) + { + // same values -> return old type + if ( (pOldType->GetCmd() == sCommand) && + (pOldType->GetType() == nType) ) + { + // same name, same values -> return old type! + pType = pOldType; + } + else + { + // same name, different values -> think of new name + sName = lcl_GenerateFldTypeName(pContext->GetDDEApplication(), + pTableNode); + } + } + // no old type -> create new one + } + + // create new field type (unless we already have one) + if (NULL == pType) + { + // create new field type and return + SwDDEFieldType aDDEFieldType(sName, sCommand, nType); + pType = (SwDDEFieldType*)pTableNode-> + GetDoc()->InsertFldType(aDDEFieldType); + } + + DBG_ASSERT(NULL != pType, "We really want a SwDDEFieldType here!"); + return pType; +} + + +// --------------------------------------------------------------------- + +class TableBoxIndex +{ +public: + OUString msName; + sal_Int32 mnWidth; + sal_Bool mbProtected; + + TableBoxIndex( const OUString& rName, sal_Int32 nWidth, + sal_Bool bProtected ) : + msName( rName ), + mnWidth( nWidth ), + mbProtected( bProtected ) + { } + + bool operator== ( const TableBoxIndex& rArg ) const + { + return (rArg.mnWidth == mnWidth) && + (rArg.mbProtected == mbProtected) && + (rArg.msName == msName); + } +}; + +class TableBoxIndexHasher +{ +public: + size_t operator() (const TableBoxIndex& rArg) const + { + return rArg.msName.hashCode() + rArg.mnWidth + rArg.mbProtected; + } +}; + + + + +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)[(sal_uInt16)nRow]->GetCell( (sal_uInt16)nCol ); +} + +TYPEINIT1( SwXMLTableContext, XMLTextTableContext ); + +SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, + sal_uInt16 nPrfx, + const OUString& rLName, + const Reference< xml::sax::XAttributeList > & xAttrList ) : + XMLTextTableContext( rImport, nPrfx, rLName ), + pRows( new SwXMLTableRows_Impl ), + pColumnDefaultCellStyleNames( 0 ), + 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 ), + pDDESource(NULL), + pSharedBoxFormats(NULL) +{ + OUString aName; + + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + 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( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + aStyleName = rValue; + else if( IsXMLToken( aLocalName, XML_NAME ) ) + aName = rValue; + else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) + aDfltCellStyleName = rValue; + } + } + + SwXMLImport& rSwImport = GetSwImport(); + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + String sTblName; + if( aName.getLength() ) + { + const SwTableFmt *pTblFmt = pDoc->FindTblFmtByName( aName ); + if( !pTblFmt ) + sTblName = aName; + } + if( !sTblName.Len() ) + { + sTblName = pDoc->GetUniqueTblName(); + GetImport().GetTextImport() + ->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_TABLE, aName, sTblName ); + } + + 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 ); + + try + { + xTextContent = Reference< XTextContent >( xTable, UNO_QUERY ); + GetImport().GetTextImport()->InsertTextContent( xTextContent ); + } + catch( IllegalArgumentException& ) + { + xTable = 0; + } + } + + if( xTable.is() ) + { + 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() ); + + // take care of open redlines for tables + GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(sal_True); + } + 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(); + } +} + +SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, + sal_uInt16 nPrfx, + const OUString& rLName, + const Reference< xml::sax::XAttributeList > & xAttrList, + SwXMLTableContext *pTable ) : + XMLTextTableContext( rImport, nPrfx, rLName ), + xParentTable( pTable ), + pRows( new SwXMLTableRows_Impl ), + pColumnDefaultCellStyleNames( 0 ), + 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 ), + pDDESource(NULL), + pSharedBoxFormats(NULL) +{ +} + +SwXMLTableContext::~SwXMLTableContext() +{ + delete pColumnDefaultCellStyleNames; + delete pSharedBoxFormats; + delete pRows; + + // close redlines on table end nodes + GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(sal_False); +} + +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: + if( IsValid() ) + pContext = new SwXMLTableColsContext_Impl( GetSwImport(), nPrefix, + rLocalName, xAttrList, + this, bHeader ); + break; + case XML_TOK_TABLE_COL: + if( IsValid() && 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; + case XML_TOK_OFFICE_DDE_SOURCE: + // save context for later processing (discard old context, if approp.) + if( IsValid() ) + { + if (pDDESource != NULL) + { + pDDESource->ReleaseRef(); + } + pDDESource = new SwXMLDDETableContext_Impl( GetSwImport(), nPrefix, + rLocalName ); + pDDESource->AddRef(); + pContext = pDDESource; + } + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void SwXMLTableContext::InsertColumn( sal_Int32 nWidth, sal_Bool bRelWidth, + const OUString *pDfltCellStyleName ) +{ + 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() ); + if( (pDfltCellStyleName && pDfltCellStyleName->getLength() > 0) || + pColumnDefaultCellStyleNames ) + { + if( !pColumnDefaultCellStyleNames ) + { + pColumnDefaultCellStyleNames = new SvStringsDtor; + sal_uInt16 nCount = aColumnRelWidths.Count() - 1; + while( nCount-- ) + pColumnDefaultCellStyleNames->Insert( new String, + pColumnDefaultCellStyleNames->Count() ); + } + + pColumnDefaultCellStyleNames->Insert( + pDfltCellStyleName ? new String( *pDfltCellStyleName ) : new String, + pColumnDefaultCellStyleNames->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=(sal_uInt16)nCol; i < nLast; i++ ) + nWidth += aColumnWidths[i]; + + return nWidth; +} + +OUString SwXMLTableContext::GetColumnDefaultCellStyleName( sal_uInt32 nCol ) const +{ + OUString sRet; + if( pColumnDefaultCellStyleNames ) + sRet = *(*pColumnDefaultCellStyleNames)[(sal_uInt16)nCol]; + + return sRet; +} + +void SwXMLTableContext::InsertCell( const OUString& rStyleName, + sal_uInt32 nRowSpan, sal_uInt32 nColSpan, + const SwStartNode *pStartNode, + SwXMLTableContext *pTable, + sal_Bool bProtect, + const OUString* pFormula, + sal_Bool bHasValue, + double fValue) +{ + 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 (if # required columns greater than # columns): + // This should never happen, since we require column definitions! + if ( nColsReq > GetColumnCount() ) + { + for( i=GetColumnCount(); i<nColsReq; i++ ) + { + aColumnWidths.Insert( MINLAY, aColumnWidths.Count() ); + aColumnRelWidths.Insert( sal_True, aColumnRelWidths.Count() ); + } + // adjust columns in *all* rows, if columns must be inserted + 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() ); + } + + OUString sStyleName( rStyleName ); + if( !sStyleName.getLength() ) + { + sStyleName = ((*pRows)[(sal_uInt16)nCurRow])->GetDefaultCellStyleName(); + if( !sStyleName.getLength() && HasColumnDefaultCellStyleNames() ) + { + sStyleName = GetColumnDefaultCellStyleName( nCurCol ); + if( !sStyleName.getLength() ) + sStyleName = aDfltCellStyleName; + } + } + + // Fill the cells + for( i=nColSpan; i>0UL; i-- ) + for( j=nRowSpan; j>0UL; j-- ) + GetCell( nRowsReq-j, nColsReq-i ) + ->Set( sStyleName, j, i, pStartNode, pTable, bProtect, + pFormula, bHasValue, fValue); + + // Set current col to the next (free) column + nCurCol = nColsReq; + while( nCurCol<GetColumnCount() && GetCell(nCurRow,nCurCol)->IsUsed() ) + nCurCol++; +} + +void SwXMLTableContext::InsertRow( const OUString& rStyleName, + const OUString& rDfltCellStyleName, + sal_Bool bInHead ) +{ + ASSERT( nCurRow < USHRT_MAX, + "SwXMLTableContext::InsertRow: no space left" ); + if( nCurRow >= USHRT_MAX ) + return; + + // Make sure there is at least one column. + if( 0==nCurRow && 0UL == GetColumnCount() ) + InsertColumn( USHRT_MAX, sal_True ); + + if( nCurRow < pRows->Count() ) + { + // The current row has already been inserted because of a row span + // of a previous row. + (*pRows)[(sal_uInt16)nCurRow]->Set( rStyleName, rDfltCellStyleName ); + } + else + { + // add a new row + pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount(), + &rDfltCellStyleName ), + 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::InsertRepRows( sal_uInt32 nCount ) +{ + const SwXMLTableRow_Impl *pSrcRow = (*pRows)[(sal_uInt16)nCurRow-1]; + while( nCount > 1 && IsInsertRowPossible() ) + { + InsertRow( pSrcRow->GetStyleName(), pSrcRow->GetDefaultCellStyleName(), + sal_False ); + while( nCurCol < GetColumnCount() ) + { + if( !GetCell(nCurRow,nCurCol)->IsUsed() ) + { + const SwXMLTableCell_Impl *pSrcCell = + GetCell( nCurRow-1, nCurCol ); + InsertCell( pSrcCell->GetStyleName(), 1U, + pSrcCell->GetColSpan(), + InsertTableSection(), 0, pSrcCell->IsProtected(), + &pSrcCell->GetFormula(), + pSrcCell->HasValue(), pSrcCell->GetValue() ); + } + } + FinishRow(); + nCount--; + } +} + +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 = NULL; + 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 = (sal_uInt16)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)[(sal_uInt16)i]; + for( sal_uInt32 j=nCol; j<nLastCol; j++ ) + pRow->GetCell( j )->SetStartNode( pSttNd ); + } +} + +SwTableBox *SwXMLTableContext::NewTableBox( const SwStartNode *pStNd, + SwTableLine *pUpper ) +{ + // The topmost table is the only table that maintains the two members + // pBox1 and bFirstSection. + if( xParentTable.Is() ) + return ((SwXMLTableContext *)&xParentTable)->NewTableBox( pStNd, + 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; +} + +SwTableBoxFmt* SwXMLTableContext::GetSharedBoxFormat( + SwTableBox* pBox, + const OUString& rStyleName, + sal_Int32 nColumnWidth, + sal_Bool bProtected, + sal_Bool bMayShare, + sal_Bool& bNew, + sal_Bool* pModifyLocked ) +{ + if ( pSharedBoxFormats == NULL ) + pSharedBoxFormats = new map_BoxFmt(); + + SwTableBoxFmt* pBoxFmt; + + TableBoxIndex aKey( rStyleName, nColumnWidth, bProtected ); + map_BoxFmt::iterator aIter = pSharedBoxFormats->find( aKey ); + if ( aIter == pSharedBoxFormats->end() ) + { + // unknown format so far -> construct a new one + + // get the old format, and reset all attributes + // (but preserve FillOrder) + pBoxFmt = (SwTableBoxFmt*)pBox->ClaimFrmFmt(); + SwFmtFillOrder aFillOrder( pBoxFmt->GetFillOrder() ); + pBoxFmt->ResetAllAttr(); + pBoxFmt->SetAttr( aFillOrder ); + bNew = sal_True; // it's a new format now + + // share this format, if allowed + if ( bMayShare ) + (*pSharedBoxFormats)[ aKey ] = pBoxFmt; + } + else + { + // set the shared format + pBoxFmt = aIter->second; + pBox->ChgFrmFmt( pBoxFmt ); + bNew = sal_False; // copied from an existing format + + // claim it, if we are not allowed to share + if ( !bMayShare ) + pBoxFmt = (SwTableBoxFmt*)pBox->ClaimFrmFmt(); + } + + // lock format (if so desired) + if ( pModifyLocked != NULL ) + { + (*pModifyLocked) = pBoxFmt->IsModifyLocked(); + pBoxFmt->LockModify(); + } + + return pBoxFmt; +} + +SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, + sal_uInt32 nTopRow, + sal_uInt32 nLeftCol, + sal_uInt32 nBottomRow, + sal_uInt32 nRightCol ) +{ + SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper ); + + sal_uInt32 nColSpan = nRightCol - nLeftCol; + sal_Int32 nColWidth = GetColumnWidth( nLeftCol, nColSpan ); + + // TODO: Share formats! + SwFrmFmt *pFrmFmt = pBox->ClaimFrmFmt(); + SwFmtFillOrder aFillOrder( pFrmFmt->GetFillOrder() ); + pFrmFmt->ResetAllAttr(); + pFrmFmt->SetAttr( aFillOrder ); + + pFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nColWidth ) ); + + SwTableLines& rLines = pBox->GetTabLines(); + sal_Bool bSplitted = sal_False; + + while( !bSplitted ) + { + sal_uInt32 nStartRow = nTopRow; + sal_uInt32 i; + for( 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 ); + } + + // Share formats! + OUString sStyleName = pCell->GetStyleName(); + sal_Bool bModifyLocked; + sal_Bool bNew; + SwTableBoxFmt *pBoxFmt = GetSharedBoxFormat( + pBox, sStyleName, nColWidth, pCell->IsProtected(), + pCell->GetStartNode() && pCell->GetFormula().getLength() == 0 && + ! pCell->HasValue(), + bNew, &bModifyLocked ); + + // if a new format was created, then we need to set the style + if ( bNew ) + { + // set style + const SfxItemSet *pAutoItemSet = 0; + if( pCell->GetStartNode() && sStyleName && + GetSwImport().FindAutomaticStyle( + XML_STYLE_FAMILY_TABLE_CELL, sStyleName, &pAutoItemSet ) ) + { + if( pAutoItemSet ) + pBoxFmt->SetAttr( *pAutoItemSet ); + } + } + + if( pCell->GetStartNode() ) + { + + // #104801# try to rescue broken documents with a certain pattern + // if: 1) the cell has a default number format (number 0) + // 2) the call has no formula + // 3) the value is 0.0 + // 4) the text doesn't look anything like 0.0 + // [read: length > 10, or length smaller 10 and no 0 in it] + // then make it a text cell! + bool bSuppressNumericContent = false; + if( pCell->HasValue() && (pCell->GetValue() == 0.0) && + (pCell->GetFormula().getLength() == 0) && + (sStyleName.getLength() != 0) ) + { + // default num format? + const SfxPoolItem* pItem = NULL; + if( pBoxFmt->GetItemState( RES_BOXATR_FORMAT, FALSE, &pItem ) + == SFX_ITEM_SET ) + { + const SwTblBoxNumFormat* pNumFormat = + static_cast<const SwTblBoxNumFormat*>( pItem ); + if( ( pNumFormat != NULL ) && ( pNumFormat->GetValue() == 0 ) ) + { + // only one text node? + SwNodeIndex aNodeIndex( *(pCell->GetStartNode()), 1 ); + if( ( aNodeIndex.GetNode().EndOfSectionIndex() - + aNodeIndex.GetNode().StartOfSectionIndex() ) == 2 ) + { + SwTxtNode* pTxtNode= aNodeIndex.GetNode().GetTxtNode(); + if( pTxtNode != NULL ) + { + // check text: does it look like some form of 0.0? + const String& rText = pTxtNode->GetTxt(); + if( ( rText.Len() > 10 ) || + ( rText.Search( '0' ) == STRING_NOTFOUND ) ) + { + bSuppressNumericContent = true; + } + } + } + else + bSuppressNumericContent = true; // several nodes + } + } + } + + if( bSuppressNumericContent ) + { + // suppress numeric content? Then reset number format! + pBoxFmt->ResetAttr( RES_BOXATR_FORMULA ); + pBoxFmt->ResetAttr( RES_BOXATR_FORMAT ); + pBoxFmt->ResetAttr( RES_BOXATR_VALUE ); + } + else + { + // the normal case: set formula and value (if available) + + const OUString& rFormula = pCell->GetFormula(); + if (rFormula.getLength() > 0) + { + // formula cell: insert formula if valid + SwTblBoxFormula aFormulaItem( rFormula ); + pBoxFmt->SetAttr( aFormulaItem ); + } + + // always insert value, even if default + if( pCell->HasValue() ) + { + SwTblBoxValue aValueItem( pCell->GetValue() ); + pBoxFmt->SetAttr( aValueItem ); + } + } + + // update cell content depend on the default language + pBox->ChgByLanguageSystem(); + } + + // table cell protection + if( pCell->IsProtected() ) + { + SvxProtectItem aProtectItem; + aProtectItem.SetCntntProtect( sal_True ); + pBoxFmt->SetAttr( aProtectItem ); + } + + // restore old modify-lock state + if (! bModifyLocked) + pBoxFmt->UnlockModify(); + + pBoxFmt->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)[(sal_uInt16)nTopRow]->GetStyleName(); + if( 1UL == (nBottomRow - nTopRow) && + rStyleName.getLength() && + GetSwImport().FindAutomaticStyle( + XML_STYLE_FAMILY_TABLE_ROW, 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; + } + } + +#ifdef DBG_UTIL + 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( (sal_uInt16)i ); + } + + 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[(sal_uInt16)i]; + if( aColumnRelWidths[(sal_uInt16)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[(sal_uInt16)i] * nMinRelColWidth) / + nMinAbsColWidth; + aColumnWidths.Replace( (sal_uInt16)nRelCol, (sal_uInt16)i ); + nRelWidth += nRelCol; + nAbsCols--; + } + } + } + + if( !nWidth ) + { + // This happens only for percentage values for the table itself. + // In this case, the columns get the correct width even if the + // the sum of the relative withs is smaller than the available + // width in TWIP. Therfore, we can use the relative width. + // + 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[(sal_uInt16)i] * n); + aColumnWidths.Replace( (sal_uInt16)nW, (sal_uInt16)i ); + nRelWidth += nW; + } + aColumnWidths.Replace( (sal_uInt16)(nWidth-nRelWidth), + (sal_uInt16)nCols-1U ); + } + } + 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[(sal_uInt16)i] - nMinRelColWidth; + nAbsCol = MINLAY + (nExtraRelCol * nExtraAbs) / + nExtraRel; + } + else + { + nAbsCol = (aColumnWidths[(sal_uInt16)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[(sal_uInt16)i]; + sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) / + nAbsWidth; + nAbsCol += nExtraAbsCol; + aColumnWidths.Replace( (sal_uInt16)nAbsCol, (sal_uInt16)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[(sal_uInt16)i]; + sal_Int32 nExtraAbsCol = (nAbsCol * nExtraAbs) / + nAbsWidth; + nAbsCol = MINLAY + nExtraAbsCol; + aColumnWidths.Replace( (sal_uInt16)nAbsCol, (sal_uInt16)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() +{ + // this method will modify the document directly -> lock SolarMutex + // This will call all other MakeTable*(..) methods, so + // those don't need to be locked separately. + SolarMutexGuard aGuard; + + 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( + XML_STYLE_FAMILY_TABLE_TABLE, 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; + } + + const SwFmtFrmSize *pSize = 0; + if( SFX_ITEM_SET == pAutoItemSet->GetItemState( RES_FRM_SIZE, sal_False, + &pItem ) ) + pSize = (const SwFmtFrmSize *)pItem; + + switch( eHoriOrient ) + { + case HORI_FULL: + case HORI_NONE: + // #78246#: For HORI_NONE we would prefere to use the sum + // of the relative column widths as reference width. + // Unfortunately this works only if this sum interpreted as + // twip value is larger than the space that is avaialable. + // We don't know that space, so we have to use USHRT_MAX, too. + // Even if a size is speczified, it will be ignored! + nWidth = USHRT_MAX; + break; + break; + default: + if( pSize ) + { + if( pSize->GetWidthPercent() ) + { + // The width will be set in _MakeTable + nPrcWidth = pSize->GetWidthPercent(); + } + else + { + nWidth = pSize->GetWidth(); + if( nWidth < (sal_Int32)GetColumnCount() * MINLAY ) + { + nWidth = GetColumnCount() * MINLAY; + } + else if( nWidth > USHRT_MAX ) + { + nWidth = USHRT_MAX; + } + bRelWidth = sal_False; + } + } + else + { + eHoriOrient = HORI_LEFT_AND_WIDTH == eHoriOrient + ? HORI_NONE : HORI_FULL; + bSetHoriOrient = sal_True; + nWidth = USHRT_MAX; + } + break; + } + + pFrmFmt->SetAttr( *pAutoItemSet ); + } + else + { + bSetHoriOrient = sal_True; + nWidth = USHRT_MAX; + } + + SwTableLine *pLine1 = pTableNode->GetTable().GetTabLines()[0U]; + DBG_ASSERT( pBox1 == pLine1->GetTabBoxes()[0U], + "Why is box 1 change?" ); + pBox1->pSttNd = pSttNd1; + 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(); + + // now that table is complete, change into DDE table (if appropriate) + if (NULL != pDDESource) + { + // change existing table into DDE table: + // 1) Get DDE field type (get data from dde-source context), + SwDDEFieldType* pFldType = lcl_GetDDEFieldType( pDDESource, + pTableNode ); + + // 2) release the DDE source context, + pDDESource->ReleaseRef(); + + // 3) create new DDE table, and + SwDDETable* pDDETable = new SwDDETable( pTableNode->GetTable(), + pFldType, FALSE ); + + // 4) set new (DDE)table at node. + pTableNode->SetNewTable(pDDETable, FALSE); + } + + if( pTableNode->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 ) +{ + // The topmost table is the only table that maintains the two members + // pBox1 and bFirstSection. + if( xParentTable.Is() ) + return ((SwXMLTableContext *)&xParentTable)->InsertTableSection( pPrevSttNd ); + + const SwStartNode *pStNd; + Reference<XUnoTunnel> xCrsrTunnel( GetImport().GetTextImport()->GetCursor(), + UNO_QUERY); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + + if( bFirstSection ) + { + // The Cursor already is in the first section + pStNd = pTxtCrsr->GetPaM()->GetNode()->FindTableBoxStartNode(); + bFirstSection = sal_False; + OUString sStyleName( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + GetImport().GetTextImport()->SetStyleAndAttrs( + GetImport().GetTextImport()->GetCursor(), sStyleName, sal_True ); + } + else + { + SwDoc* pDoc = pTxtCrsr->GetDoc(); + const SwEndNode *pEndNd = pPrevSttNd ? pPrevSttNd->EndOfSectionNode() + : pTableNode->EndOfSectionNode(); + sal_uInt32 nOffset = pPrevSttNd ? 1UL : 0UL; + SwNodeIndex aIdx( *pEndNd, nOffset ); + SwTxtFmtColl *pColl = + pDoc->GetTxtCollFromPoolSimple( RES_POOLCOLL_STANDARD, FALSE ); + pStNd = pDoc->GetNodes().MakeTextSection( aIdx, SwTableBoxStartNode, + pColl ); + if( !pPrevSttNd ) + { + pBox1->pSttNd = pStNd; + SwCntntNode *pCNd = pDoc->GetNodes()[ pStNd->GetIndex() + 1 ] + ->GetCntntNode(); + SwPosition aPos( *pCNd ); + aPos.nContent.Assign( pCNd, 0U ); + + Reference < XTextRange > xTextRange = + SwXTextRange::CreateTextRangeFromPosition( pDoc, aPos, 0 ); + Reference < XText > xText = xTextRange->getText(); + Reference < XTextCursor > xTextCursor = + xText->createTextCursorByRange( xTextRange ); + GetImport().GetTextImport()->SetCursor( xTextCursor ); + } + } + + return pStNd; +} + +void SwXMLTableContext::EndElement() +{ + if( IsValid() && !xParentTable.Is() ) + { + MakeTable(); + GetImport().GetTextImport()->SetCursor( xOldCursor ); + } +} + +Reference < XTextContent > SwXMLTableContext::GetXTextContent() const +{ + return xTextContent; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmltext.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmltext.cxx new file mode 100644 index 000000000000..872eda3b6066 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmltext.cxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_xmloff/xmlnmspe.hxx> +#include "xmlimp.hxx" +namespace binfilter { + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; + +using rtl::OUString; + +// --------------------------------------------------------------------- + +class SwXMLBodyContext_Impl : public SvXMLImportContext +{ + 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 ); + + virtual void EndElement(); +}; + +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; + + pContext = GetSwImport().GetTextImport()->CreateTextChildContext( + GetImport(), nPrefix, rLocalName, xAttrList, + XML_TEXT_TYPE_BODY ); + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +void SwXMLBodyContext_Impl::EndElement() +{ + /* #108146# Code moved to SwXMLOmport::endDocument */ + GetImport().GetTextImport()->SetOutlineStyles(); +} + +SvXMLImportContext *SwXMLImport::CreateBodyContext( + const OUString& rLocalName ) +{ + 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; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmltexte.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmltexte.cxx new file mode 100644 index 000000000000..374df851cf5a --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmltexte.cxx @@ -0,0 +1,624 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <sot/clsids.hxx> + +#include <bf_xmloff/xmlnmspe.hxx> +#include <bf_xmloff/txtprmap.hxx> + +#include <bf_sfx2/frmdescr.hxx> + + +#include <horiornt.hxx> + +#include <doc.hxx> + +#include <errhdl.hxx> + +#include <ndole.hxx> + +#include <cppuhelper/implbase4.hxx> + +#include <unostyle.hxx> +#include <unoframe.hxx> +#include <ndgrf.hxx> + +#include "xmlexp.hxx" +#include "xmltexte.hxx" + + + + +#include <SwAppletImpl.hxx> + +#define _SVSTDARR_ULONGS +#include <bf_svtools/svstdarr.hxx> + +#include <SwStyleNameMapper.hxx> +#include "bf_so3/staticbaseurl.hxx" +namespace binfilter { + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::style; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::document; +using namespace ::binfilter::xmloff::token; + +using rtl::OUString; +using rtl::OUStringBuffer; + +enum SvEmbeddedObjectTypes +{ + SV_EMBEDDED_OWN, + SV_EMBEDDED_OUTPLACE, + SV_EMBEDDED_APPLET, + SV_EMBEDDED_PLUGIN, + SV_EMBEDDED_FRAME +}; + +// --------------------------------------------------------------------- + +SwNoTxtNode *SwXMLTextParagraphExport::GetNoTxtNode( + const Reference < XPropertySet >& rPropSet ) const +{ + Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" ); + SwXFrame *pFrame = + (SwXFrame *)xCrsrTunnel->getSomething( + SwXFrame::getUnoTunnelId() ); + ASSERT( pFrame, "SwXFrame missing" ); + SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt(); + const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); + const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx(); + return pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode(); +} + +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 *pDoc = pStyle->GetDoc(); + const SwTxtFmtColl *pColl = + pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() ); + 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]; + + enum XMLTokenEnum eFunc = XML_TOKEN_INVALID; + OUStringBuffer sBuffer( 20 ); + switch( rCond.GetCondition() ) + { + case PARA_IN_LIST: + eFunc = XML_LIST_LEVEL; + sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) ); + break; + case PARA_IN_OUTLINE: + eFunc = XML_OUTLINE_LEVEL; + sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) ); + break; + case PARA_IN_FRAME: + eFunc = XML_TEXT_BOX; + break; + case PARA_IN_TABLEHEAD: + eFunc = XML_TABLE_HEADER; + break; + case PARA_IN_TABLEBODY: + eFunc = XML_TABLE; + break; + case PARA_IN_SECTION: + eFunc = XML_SECTION; + break; + case PARA_IN_FOOTENOTE: + eFunc = XML_FOOTNOTE; + break; + case PARA_IN_FOOTER: + eFunc = XML_FOOTER; + break; + case PARA_IN_HEADER: + eFunc = XML_HEADER; + break; + case PARA_IN_ENDNOTE: + eFunc = XML_ENDNOTE; + break; + } + OUString sVal( sBuffer.makeStringAndClear() ); + + DBG_ASSERT( eFunc != XML_TOKEN_INVALID, + "SwXMLExport::ExportFmt: unknown condition" ); + if( eFunc != XML_TOKEN_INVALID ) + { + sBuffer.append( GetXMLToken(eFunc) ); + sBuffer.append( (sal_Unicode)'(' ); + sBuffer.append( (sal_Unicode)')' ); + if( sVal.getLength() ) + { + sBuffer.append( (sal_Unicode)'=' ); + sBuffer.append( sVal ); + } + + GetExport().AddAttribute( XML_NAMESPACE_STYLE, + XML_CONDITION, + sBuffer.makeStringAndClear() ); + String aString; + SwStyleNameMapper::FillProgName( + rCond.GetTxtFmtColl()->GetName(), + aString, + GET_POOLID_TXTCOLL, + sal_True); + GetExport().AddAttribute( XML_NAMESPACE_STYLE, + XML_APPLY_STYLE_NAME, aString ); + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, + XML_MAP, sal_True, sal_True ); + } + } + } + } +} + +SwXMLTextParagraphExport::SwXMLTextParagraphExport( + SwXMLExport& rExp, + SvXMLAutoStylePoolP& rAutoStylePool ) : + XMLTextParagraphExport( rExp, rAutoStylePool ), + sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) ), + sEmbeddedObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) ), + aAppletClassId( SO3_APPLET_CLASSID ), //STRIP003 + aPluginClassId( SO3_PLUGIN_CLASSID ), //STRIP003 + aIFrameClassId( BF_SO3_IFRAME_CLASSID ), + aOutplaceClassId( SO3_OUT_CLASSID ) //STRIP003 +{ +} + +SwXMLTextParagraphExport::~SwXMLTextParagraphExport() +{ +} + +void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL( + const Reference < XPropertySet >& rPropSet, + OUString& rURL) const +{ + if( !rURL.getLength() ) + return; + + SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode(); + if( !pGrfNd->IsGrfLink() ) + { + String aNewURL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.Package:") ); + aNewURL += String(rURL.copy( 1 ) ); + pGrfNd->SetNewStreamName( aNewURL ); + } +} + +static void lcl_addParam ( SvXMLExport &rExport, const SvCommand &rCommand ) +{ + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rCommand.GetCommand() ); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, rCommand.GetArgument() ); + SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True ); +} +static void lcl_addURL ( SvXMLExport &rExport, const String &rURL, + sal_Bool bToRel = sal_True ) +{ + String sRelURL; + + if( bToRel && (rURL.Len() > 0) ) + sRelURL = ::binfilter::StaticBaseUrl::AbsToRel(rURL, + INetURLObject::WAS_ENCODED, + INetURLObject::DECODE_UNAMBIGUOUS); + else + sRelURL = rURL; + + if (sRelURL.Len()) + { + rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, sRelURL ); + rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); + rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED ); + rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); + } +} + +void lcl_addOutplaceProperties( + const SvInfoObject *pInfo, + const XMLPropertyState **pStates, + const UniReference < XMLPropertySetMapper >& rMapper ) +{ + SvEmbeddedInfoObject * pEmbed = PTR_CAST(SvEmbeddedInfoObject, pInfo ); + if( pEmbed ) + { + const Rectangle& rVisArea = pEmbed->GetVisArea(); + if( !rVisArea.IsEmpty() ) + { + Any aAny; + + aAny <<= (sal_Int32)rVisArea.Left(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny ); + pStates++; + + aAny <<= (sal_Int32)rVisArea.Top(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny ); + pStates++; + + aAny <<= (sal_Int32)rVisArea.GetWidth(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny ); + pStates++; + + aAny <<= (sal_Int32)rVisArea.GetHeight(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny ); + pStates++; + + aAny <<= (sal_Int32)pEmbed->GetViewAspect(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), aAny ); + pStates++; + + // TODO: aspect + } + } +} + +void lcl_addFrameProperties( + const SfxFrameDescriptor *pDescriptor, + const XMLPropertyState **pStates, + const UniReference < XMLPropertySetMapper >& rMapper ) +{ + if( ScrollingAuto != pDescriptor->GetScrollingMode() ) + { + sal_Bool bValue = ScrollingYes == pDescriptor->GetScrollingMode(); + Any aAny( &bValue, ::getBooleanCppuType() ); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), aAny ); + pStates++; + } + if( pDescriptor->IsFrameBorderSet() ) + { + sal_Bool bValue = pDescriptor->IsFrameBorderOn(); + Any aAny( &bValue, ::getBooleanCppuType() ); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), aAny ); + pStates++; + } + const Size& rMargins = pDescriptor->GetMargin(); + if( SIZE_NOT_SET != rMargins.Width() ) + { + Any aAny; + aAny <<= (sal_Int32)rMargins.Width(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), aAny ); + pStates++; + } + if( SIZE_NOT_SET != rMargins.Height() ) + { + Any aAny; + aAny <<= (sal_Int32)rMargins.Height(); + *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), aAny ); + pStates++; + } +} + +void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles( + const Reference < XPropertySet > & rPropSet ) +{ + SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode(); + SwOLEObj& rOLEObj = pOLENd->GetOLEObj(); + SvPersist *pPersist = pOLENd->GetDoc()->GetPersist(); + ASSERT( pPersist, "no persist" ); + const SvInfoObject *pInfo = pPersist->Find( rOLEObj.GetName() ); + DBG_ASSERT( pInfo, "no info object for OLE object found" ); + + if( !pInfo ) + return; + + const XMLPropertyState *aStates[7] = { 0, 0, 0, 0, 0, 0, 0 }; + SvGlobalName aClassId( pInfo->GetClassName() ); + + if( aOutplaceClassId == aClassId ) + { + lcl_addOutplaceProperties( pInfo, aStates, + GetAutoFramePropMapper()->getPropertySetMapper() ); + } + else if( aIFrameClassId == aClassId ) + { + SfxFrameObjectRef xFrame( rOLEObj.GetOleRef() ); + ASSERT( xFrame.Is(), "wrong class id for frame" ); + + lcl_addFrameProperties( xFrame->GetFrameDescriptor(), aStates, + GetAutoFramePropMapper()->getPropertySetMapper() ); + } + + Add( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, aStates ); + + const XMLPropertyState **pStates = aStates; + while( *pStates ) + { + delete *pStates; + pStates++; + } +} + +void SwXMLTextParagraphExport::_exportTextEmbedded( + const Reference < XPropertySet > & rPropSet, + const Reference < XPropertySetInfo > & rPropSetInfo ) +{ + SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode(); + SwOLEObj& rOLEObj = pOLENd->GetOLEObj(); + SvPersist *pPersist = pOLENd->GetDoc()->GetPersist(); + const SvInfoObject *pInfo = pPersist->Find( rOLEObj.GetName() ); + DBG_ASSERT( pInfo, "no info object for OLE object found" ); + + if( !pInfo ) + return; + + SvGlobalName aClassId( pInfo->GetClassName() ); + + SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN; + SvPlugInObjectRef xPlugin; + SvAppletObjectRef xApplet; + SfxFrameObjectRef xFrame; + if( aPluginClassId == aClassId ) + { + xPlugin = SvPlugInObjectRef( rOLEObj.GetOleRef() ); + ASSERT( xPlugin.Is(), "wrong class id for plugin" ); + nType = SV_EMBEDDED_PLUGIN; + } + else if( aAppletClassId == aClassId ) + { + xApplet = SvAppletObjectRef( rOLEObj.GetOleRef() ); + ASSERT( xApplet.Is(), "wrong class id for applet" ); + nType = SV_EMBEDDED_APPLET; + } + else if( aIFrameClassId == aClassId ) + { + xFrame = SfxFrameObjectRef( rOLEObj.GetOleRef() ); + ASSERT( xFrame.Is(), "wrong class id for frame" ); + nType = SV_EMBEDDED_FRAME; + } + else if( aOutplaceClassId == aClassId ) + { + nType = SV_EMBEDDED_OUTPLACE; + } + + SvULongs aParams; + enum XMLTokenEnum eElementName; + SvXMLExport &rExport = GetExport(); + + // First the stuff common to each of Applet/Plugin/Floating Frame + OUString sStyle; + Any aAny; + if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) ) + { + aAny = rPropSet->getPropertyValue( sFrameStyleName ); + aAny >>= sStyle; + } + + const XMLPropertyState *aStates[7] = { 0, 0, 0, 0, 0, 0, 0 }; + switch( nType ) + { + case SV_EMBEDDED_FRAME: + lcl_addFrameProperties( xFrame->GetFrameDescriptor(), aStates, + GetAutoFramePropMapper()->getPropertySetMapper() ); + break; + case SV_EMBEDDED_OUTPLACE: + lcl_addOutplaceProperties( pInfo, aStates, + GetAutoFramePropMapper()->getPropertySetMapper() ); + break; + } + + OUString sAutoStyle( sStyle ); + sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle, + aStates ); + const XMLPropertyState **pStates = aStates; + while( *pStates ) + { + delete *pStates; + pStates++; + } + + if( sAutoStyle.getLength() ) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle ); + addTextFrameAttributes( rPropSet, sal_False ); + + switch (nType) + { + case SV_EMBEDDED_OUTPLACE: + case SV_EMBEDDED_OWN: + if( (rExport.getExportFlags() & EXPORT_EMBEDDED) == 0 ) + { + OUString sURL( sEmbeddedObjectProtocol ); + sURL += pInfo->GetStorageName(); + sURL = GetExport().AddEmbeddedObject( sURL ); + lcl_addURL( rExport, sURL, sal_False ); + } + if( SV_EMBEDDED_OWN == nType && pOLENd->GetChartTblName().Len() ) + { + OUString sRange( pOLENd->GetChartTblName() ); + OUStringBuffer aBuffer( sRange.getLength() + 2 ); + for( sal_Int32 i=0; i < sRange.getLength(); i++ ) + { + sal_Unicode c = sRange[i]; + switch( c ) + { + case ' ': + case '.': + case '\'': + case '\\': + if( !aBuffer.getLength() ) + { + aBuffer.append( (sal_Unicode)'\'' ); + aBuffer.append( sRange.copy( 0, i ) ); + } + if( '\'' == c || '\\' == c ) + aBuffer.append( (sal_Unicode)'\\' ); + // no break! + default: + if( aBuffer.getLength() ) + aBuffer.append( c ); + } + } + if( aBuffer.getLength() ) + { + aBuffer.append( (sal_Unicode)'\'' ); + sRange = aBuffer.makeStringAndClear(); + } + + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, + sRange ); + } + eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE + : XML_OBJECT; + break; + case SV_EMBEDDED_APPLET: + { + // It's an applet! + const XubString & rURL = xApplet->GetCodeBase(); + if (rURL.Len() ) + lcl_addURL(rExport, rURL); + + const String &rName = xApplet->GetName(); + if (rName.Len()) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, + rName ); + + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, + xApplet->GetClass() ); + + const SvCommandList& rCommands = xApplet->GetCommandList(); + + ULONG i = rCommands.Count(); + while ( i > 0 ) + { + const SvCommand& rCommand = rCommands [ --i ]; + const String &rName = rCommand.GetCommand(); + USHORT nType = SwApplet_Impl::GetOptionType( rName, TRUE ); + if ( nType == SWHTML_OPTTYPE_TAG) + rExport.AddAttribute( XML_NAMESPACE_DRAW, rName, rCommand.GetArgument()); + else if (SWHTML_OPTTYPE_PARAM == nType || + SWHTML_OPTTYPE_SIZE == nType ) + aParams.Insert( i, aParams.Count() ); + } + + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, + xApplet->IsMayScript() ? XML_TRUE : XML_FALSE ); + eElementName = XML_APPLET; + } + break; + case SV_EMBEDDED_PLUGIN: + { + // It's a plugin! + lcl_addURL( rExport, xPlugin->GetURL()->GetMainURL( INetURLObject::NO_DECODE ) ); + const String &rType = xPlugin->GetMimeType(); + if (rType.Len()) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, rType ); + eElementName = XML_PLUGIN; + } + break; + case SV_EMBEDDED_FRAME: + { + // It's a floating frame! + const SfxFrameDescriptor *pDescriptor = xFrame->GetFrameDescriptor(); + + lcl_addURL( rExport, pDescriptor->GetURL().GetMainURL( INetURLObject::NO_DECODE ) ); + + const String &rName = pDescriptor->GetName(); + if (rName.Len()) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, rName ); + eElementName = XML_FLOATING_FRAME; + } + break; + default: + ASSERT( !this, "unknown object type! Base class should have been called!" ); + } + + SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, eElementName, + sal_False, sal_True ); + switch( nType ) + { + case SV_EMBEDDED_OWN: + if( (rExport.getExportFlags() & EXPORT_EMBEDDED) != 0 ) + { + Reference < XEmbeddedObjectSupplier > xEOS( rPropSet, UNO_QUERY ); + ASSERT( xEOS.is(), "no embedded object supplier for own object" ); + Reference < XComponent > xComp = xEOS->getEmbeddedObject(); + rExport.ExportEmbeddedOwnObject( xComp ); + } + break; + case SV_EMBEDDED_OUTPLACE: + if( (rExport.getExportFlags() & EXPORT_EMBEDDED) != 0 ) + { + OUString sURL( sEmbeddedObjectProtocol ); + sURL += rOLEObj.GetName(); + GetExport().AddEmbeddedObjectAsBase64( sURL ); + } + break; + case SV_EMBEDDED_APPLET: + { + const SvCommandList& rCommands = xApplet->GetCommandList(); + USHORT ii = aParams.Count(); + while ( ii > 0 ) + { + const SvCommand& rCommand = rCommands [ aParams [ --ii] ]; + lcl_addParam (rExport, rCommand ); + } + } + break; + case SV_EMBEDDED_PLUGIN: + { + const SvCommandList& rCommands = xPlugin->GetCommandList(); + ULONG nCommands = rCommands.Count(); + for ( ULONG i = 0; i < nCommands; i++) + { + const SvCommand& rCommand = rCommands [ i ]; + const String& rName = rCommand.GetCommand(); + if (SwApplet_Impl::GetOptionType( rName, FALSE ) == SWHTML_OPTTYPE_TAG ) + lcl_addParam (rExport, rCommand ); + } + } + break; + } + + // Lastly the stuff common to each of Applet/Plugin/Floating Frame + exportEvents( rPropSet ); + exportAlternativeText( rPropSet, rPropSetInfo ); + exportContour( rPropSet, rPropSetInfo ); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/sw_xmltexti.cxx b/binfilter/bf_sw/source/filter/xml/sw_xmltexti.cxx new file mode 100644 index 000000000000..4c6dfa2b29a7 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/sw_xmltexti.cxx @@ -0,0 +1,792 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <rtl/ustrbuf.hxx> +#include <comphelper/classids.hxx> +#include <bf_so3/embobj.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <bf_xmloff/prstylei.hxx> +#include <bf_xmloff/maptype.hxx> +#include <bf_xmloff/xmlprmap.hxx> +#include <bf_xmloff/txtprmap.hxx> +#include <bf_xmloff/i18nmap.hxx> + +#include <errhdl.hxx> + +#include "unocrsr.hxx" +#include "unoobj.hxx" +#include "unoframe.hxx" + +#include <horiornt.hxx> + +#include "doc.hxx" +#include "unocoll.hxx" +#include <sw3io.hxx> +#include <fmtfsize.hxx> +#include <fmtanchr.hxx> + +#include "xmlimp.hxx" +#include "xmltbli.hxx" +#include "xmltexti.hxx" +#include "XMLRedlineImportHelper.hxx" +#include <bf_xmloff/XMLFilterServiceNames.h> + +#include <SwAppletImpl.hxx> +#include <ndole.hxx> + +#include <ndnotxt.hxx> + +#include <bf_sfx2/frmdescr.hxx> + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> + +#include <osl/mutex.hxx> +#include "bf_so3/staticbaseurl.hxx" +namespace binfilter { + + + +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::beans; +using namespace ::com::sun::star::xml::sax; + +using rtl::OUString; +using rtl::OUStringBuffer; + + +struct XMLServiceMapEntry_Impl +{ + const sal_Char *sFilterService; + sal_Int32 nFilterServiceLen; + + sal_uInt32 n1; + sal_uInt16 n2, n3; + sal_uInt8 n4, n5, n6, n7, n8, n9, n10, n11; +}; + +#define SERVICE_MAP_ENTRY( app, s ) \ + { XML_IMPORT_FILTER_##app, sizeof(XML_IMPORT_FILTER_##app)-1, \ + BF_SO3_##s##_CLASSID } + +const XMLServiceMapEntry_Impl aServiceMap[] = +{ + SERVICE_MAP_ENTRY( WRITER, SW ), + SERVICE_MAP_ENTRY( CALC, SC ), + SERVICE_MAP_ENTRY( DRAW, SDRAW ), + SERVICE_MAP_ENTRY( IMPRESS, SIMPRESS ), + SERVICE_MAP_ENTRY( CHART, SCH ), + SERVICE_MAP_ENTRY( MATH, SM ), + { 0, 0, 0, 0 } +}; +static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet, + sal_Int32 nHeight, sal_Int32 nWidth, + long *pTwipHeight=0, long *pTwipWidth=0 ) +{ + if( nWidth > 0 && nHeight > 0 ) + { + nWidth = MM100_TO_TWIP( nWidth ); + if( nWidth < MINFLY ) + nWidth = MINFLY; + nHeight = MM100_TO_TWIP( nHeight ); + if( nHeight < MINFLY ) + nHeight = MINFLY; + rItemSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) ); + } + + SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + rItemSet.Put( aAnchor ); + + if( pTwipWidth ) + *pTwipWidth = nWidth; + if( pTwipHeight ) + *pTwipHeight = nHeight; +} + +SwXMLTextImportHelper::SwXMLTextImportHelper( + const Reference < XModel>& rModel, + SvXMLImport& rImport, + const Reference<XPropertySet> & rInfoSet, + sal_Bool bInsertM, sal_Bool bStylesOnlyM, sal_Bool bProgress, + sal_Bool bBlockM, sal_Bool bOrganizerM, + sal_Bool bPreserveRedlineMode ) : + XMLTextImportHelper( rModel, rImport, bInsertM, bStylesOnlyM, bProgress, + bBlockM, bOrganizerM ), + pRedlineHelper( NULL ) +{ + Reference<XPropertySet> xDocPropSet( rModel, UNO_QUERY ); + pRedlineHelper = new XMLRedlineImportHelper( + bInsertM || bBlockM, xDocPropSet, rInfoSet ); +} + +SwXMLTextImportHelper::~SwXMLTextImportHelper() +{ + // #90463# the redline helper destructor sets properties on the document + // and may through an exception while doing so... catch this + try + { + delete pRedlineHelper; + } + catch ( const RuntimeException& ) + { + // ignore + } +} + +SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext( + SvXMLImport& rImport, + sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< XAttributeList > & xAttrList ) +{ + return new SwXMLTableContext( + (SwXMLImport&)rImport, nPrefix, rLocalName, xAttrList ); +} + +sal_Bool SwXMLTextImportHelper::IsInHeaderFooter() const +{ + Reference<XUnoTunnel> xCrsrTunnel( + ((SwXMLTextImportHelper *)this)->GetCursor(), UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + return pDoc->IsInHeaderFooter( pTxtCrsr->GetPaM()->GetPoint()->nNode ); +} + +SwOLENode *lcl_GetOLENode( const SwFrmFmt *pFrmFmt ) +{ + SwOLENode *pOLENd = 0; + if( pFrmFmt ) + { + const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); + const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx(); + pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetOLENode(); + } + ASSERT( pOLENd, "Where is the OLE node" ); + return pOLENd; +} + +Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject( + SvXMLImport& rImport, + const OUString& rHRef, + const OUString& rStyleName, + const OUString& rTblName, + sal_Int32 nWidth, sal_Int32 nHeight ) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference < XPropertySet > xPropSet; + + sal_Int32 nPos = rHRef.indexOf( ':' ); + if( -1 == nPos ) + return xPropSet; + + OUString aObjName( rHRef.copy( nPos+1) ); + + if( !aObjName.getLength() ) + return xPropSet; + + Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, + RES_FRMATR_END ); + Size aTwipSize( 0, 0 ); + Rectangle aVisArea( 0, 0, nWidth, nHeight ); + lcl_putHeightAndWidth( aItemSet, nHeight, nWidth, + &aTwipSize.Height(), &aTwipSize.Width() ); + + SwFrmFmt *pFrmFmt = 0; + SwOLENode *pOLENd = 0; + if( rHRef.copy( 0, nPos ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.ServiceName") ) ) + { + sal_Bool bInsert = sal_False; + SvGlobalName aClassName; + const XMLServiceMapEntry_Impl *pEntry = aServiceMap; + while( pEntry->sFilterService ) + { + if( aObjName.equalsAsciiL( pEntry->sFilterService, + pEntry->nFilterServiceLen ) ) + { + aClassName = SvGlobalName( pEntry->n1, pEntry->n2, + pEntry->n3, pEntry->n4, + pEntry->n5, pEntry->n6, + pEntry->n7, pEntry->n8, + pEntry->n9, pEntry->n10, + pEntry->n11 ); + bInsert = sal_True; + break; + } + pEntry++; + } + + if( bInsert ) + { + SvStorageRef aStor = new SvStorage( aEmptyStr ); + SvInPlaceObjectRef xIPObj = + &((SvFactory*)SvInPlaceObject::ClassFactory())->CreateAndInit( + aClassName, aStor ); + if( xIPObj.Is() ) + { + aVisArea.SetSize( aTwipSize ); + aVisArea = OutputDevice::LogicToLogic( + aVisArea, MAP_TWIP, xIPObj->GetMapUnit() ); + xIPObj->SetVisArea( aVisArea ); + } + pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(), xIPObj, &aItemSet ); + + pOLENd = lcl_GetOLENode( pFrmFmt ); + if( pOLENd ) + aObjName = pOLENd->GetOLEObj().GetName(); + } + } + else + { + String aName( aObjName ); + pFrmFmt = pDoc->InsertOLE( *pTxtCrsr->GetPaM(), aName, &aItemSet ); + aObjName = aName; + } + + if( !pFrmFmt ) + return xPropSet; + + if( IsInsertMode() ) + { + if( !pOLENd ) + pOLENd = lcl_GetOLENode( pFrmFmt ); + if( pOLENd ) + pOLENd->SetOLESizeInvalid( sal_True ); + } + + SwXFrame *pXFrame = SwXFrames::GetObject( *pFrmFmt, FLYCNTTYPE_OLE ); + xPropSet = pXFrame; + if( pDoc->GetDrawModel() ) + SwXFrame::GetOrCreateSdrObject( + static_cast<SwFlyFrmFmt*>( pXFrame->GetFrmFmt() ) ); // req for z-order + if( rTblName.getLength() ) + { + const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); + const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx(); + SwOLENode *pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetOLENode(); + ASSERT( pOLENd, "Where is the OLE node" ); + + OUStringBuffer aBuffer( rTblName.getLength() ); + sal_Bool bQuoted = sal_False; + sal_Bool bEscape = sal_False; + sal_Bool bError = sal_False; + for( sal_Int32 i=0; i < rTblName.getLength(); i++ ) + { + sal_Bool bEndOfNameFound = sal_False; + sal_Unicode c = rTblName[i]; + switch( c ) + { + case '\'': + if( bEscape ) + { + aBuffer.append( c ); + bEscape = sal_False; + } + else if( bQuoted ) + { + bEndOfNameFound = sal_True; + } + else if( 0 == i ) + { + bQuoted = sal_True; + } + else + { + bError = sal_True; + } + break; + case '\\': + if( bEscape ) + { + aBuffer.append( c ); + bEscape = sal_False; + } + else + { + bEscape = sal_True; + } + break; + case ' ': + case '.': + if( !bQuoted ) + { + bEndOfNameFound = sal_True; + } + else + { + aBuffer.append( c ); + bEscape = sal_False; + } + break; + default: + { + aBuffer.append( c ); + bEscape = sal_False; + } + break; + } + if( bError || bEndOfNameFound ) + break; + } + if( !bError ) + { + OUString sTblName( aBuffer.makeStringAndClear() ); + pOLENd->SetChartTblName( GetRenameMap().Get( XML_TEXT_RENAME_TYPE_TABLE, sTblName ) ); + } + } + + sal_Int32 nDrawAspect = 0; + const XMLPropStyleContext *pStyle = 0; + if( rStyleName.getLength() ) + { + pStyle = FindAutoFrameStyle( rStyleName ); + if( pStyle ) + { + UniReference < SvXMLImportPropertyMapper > xImpPrMap = + pStyle->GetStyles() + ->GetImportPropertyMapper(pStyle->GetFamily()); + ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" ); + if( xImpPrMap.is() ) + { + UniReference<XMLPropertySetMapper> rPropMapper = + xImpPrMap->getPropertySetMapper(); + + sal_Int32 nCount = pStyle->GetProperties().size(); + for( sal_Int32 i=0; i < nCount; i++ ) + { + const XMLPropertyState& rProp = pStyle->GetProperties()[i]; + sal_Int32 nIdx = rProp.mnIndex; + if( -1 == nIdx ) + continue; + + switch( rPropMapper->GetEntryContextId(nIdx) ) + { + case CTF_OLE_VIS_AREA_LEFT: + { + sal_Int32 nVal = 0; + rProp.maValue >>= nVal; + aVisArea.setX( nVal ); + } + break; + case CTF_OLE_VIS_AREA_TOP: + { + sal_Int32 nVal = 0; + rProp.maValue >>= nVal; + aVisArea.setY( nVal ); + } + break; + case CTF_OLE_VIS_AREA_WIDTH: + { + sal_Int32 nVal = 0; + rProp.maValue >>= nVal; + aVisArea.setWidth( nVal ); + } + break; + case CTF_OLE_VIS_AREA_HEIGHT: + { + sal_Int32 nVal = 0; + rProp.maValue >>= nVal; + aVisArea.setHeight( nVal ); + } + break; + case CTF_OLE_DRAW_ASPECT: + { + rProp.maValue >>= nDrawAspect; + } + break; + } + } + } + } + } + + SvInfoObject *pInfo = pDoc->GetPersist()->Find( aObjName ); + if( pInfo ) + { + SvEmbeddedInfoObject * pEmbed = PTR_CAST(SvEmbeddedInfoObject, pInfo ); + pEmbed->SetInfoVisArea( aVisArea ); + if( nDrawAspect ) + pEmbed->SetInfoViewAspect( (UINT32)nDrawAspect ); + } + return xPropSet; +} + +Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet( + const OUString &rName, + const OUString &rCode, + sal_Bool bMayScript, + const OUString& rHRef, + sal_Int32 nWidth, sal_Int32 nHeight ) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference < XPropertySet > xPropSet; + Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, + RES_FRMATR_END ); + lcl_putHeightAndWidth( aItemSet, nHeight, nWidth); + + SwApplet_Impl aAppletImpl ( aItemSet ); + aAppletImpl.CreateApplet ( rCode, rName, bMayScript, rHRef ); + + SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(), + aAppletImpl.GetApplet(), + &aAppletImpl.GetItemSet()); + SwXFrame *pXFrame = SwXFrames::GetObject( *pFrmFmt, FLYCNTTYPE_OLE ); + xPropSet = pXFrame; + if( pDoc->GetDrawModel() ) + SwXFrame::GetOrCreateSdrObject( + static_cast<SwFlyFrmFmt*>( pXFrame->GetFrmFmt() ) ); // req for z-order + + return xPropSet; +} +Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin( + const OUString &rMimeType, + const OUString& rHRef, + sal_Int32 nWidth, sal_Int32 nHeight ) +{ + Reference < XPropertySet > xPropSet; + Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, + RES_FRMATR_END ); + lcl_putHeightAndWidth( aItemSet, nHeight, nWidth); + + // We'll need a (valid) URL, or we need a MIME type. If we don't have + // either, do not insert plugin and return early. Copy URL into URL oject + // on the way. + INetURLObject aURLObj; + bool bValidURL = rHRef.getLength() != 0 && + aURLObj.SetURL( ::binfilter::StaticBaseUrl::RelToAbs(rHRef) ); + bool bValidMimeType = rMimeType.getLength() != 0; + if( !bValidURL && !bValidMimeType ) + return xPropSet; + + SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE); + SvFactory *pPlugInFactory = (SvFactory*)SvPlugInObject::ClassFactory(); // SvFactory::GetDefaultPlugInFactory() + SvPlugInObjectRef xPlugin = &pPlugInFactory->CreateAndInit( *pPlugInFactory, pStor ); + + xPlugin->EnableSetModified( FALSE ); + xPlugin->SetPlugInMode( (USHORT)PLUGIN_EMBEDED ); + if( bValidURL ) + xPlugin->SetURL( aURLObj ); + if( bValidMimeType ) + xPlugin->SetMimeType( rMimeType ); + + SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(), + xPlugin, + &aItemSet); + SwXFrame *pXFrame = SwXFrames::GetObject( *pFrmFmt, FLYCNTTYPE_OLE ); + xPropSet = pXFrame; + if( pDoc->GetDrawModel() ) + SwXFrame::GetOrCreateSdrObject( + static_cast<SwFlyFrmFmt*>( pXFrame->GetFrmFmt() ) ); // req for z-order + + return xPropSet; +} +Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFrame( + const OUString& rName, + const OUString& rHRef, + const OUString& rStyleName, + sal_Int32 nWidth, sal_Int32 nHeight ) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference < XPropertySet > xPropSet; + Reference<XUnoTunnel> xCrsrTunnel( GetCursor(), UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for Cursor" ); + OTextCursorHelper *pTxtCrsr = + (OTextCursorHelper*)xCrsrTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ); + ASSERT( pTxtCrsr, "SwXTextCursor missing" ); + SwDoc *pDoc = pTxtCrsr->GetDoc(); + + SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, + RES_FRMATR_END ); + lcl_putHeightAndWidth( aItemSet, nHeight, nWidth); + + SfxFrameDescriptor *pFrameDesc = new SfxFrameDescriptor( 0 ); + + pFrameDesc->SetURL( ::binfilter::StaticBaseUrl::RelToAbs( rHRef ) ); + pFrameDesc->SetName( rName ); + + ScrollingMode eScrollMode = ScrollingAuto; + sal_Bool bHasBorder = sal_False; + sal_Bool bIsBorderSet = sal_False; + Size aMargin( SIZE_NOT_SET, SIZE_NOT_SET ); + const XMLPropStyleContext *pStyle = 0; + if( rStyleName.getLength() ) + { + pStyle = FindAutoFrameStyle( rStyleName ); + if( pStyle ) + { + UniReference < SvXMLImportPropertyMapper > xImpPrMap = + pStyle->GetStyles() + ->GetImportPropertyMapper(pStyle->GetFamily()); + ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" ); + if( xImpPrMap.is() ) + { + UniReference<XMLPropertySetMapper> rPropMapper = + xImpPrMap->getPropertySetMapper(); + + sal_Int32 nCount = pStyle->GetProperties().size(); + for( sal_Int32 i=0; i < nCount; i++ ) + { + const XMLPropertyState& rProp = pStyle->GetProperties()[i]; + sal_Int32 nIdx = rProp.mnIndex; + if( -1 == nIdx ) + continue; + + switch( rPropMapper->GetEntryContextId(nIdx) ) + { + case CTF_FRAME_DISPLAY_SCROLLBAR: + { + sal_Bool bYes = *(sal_Bool *)rProp.maValue.getValue(); + eScrollMode = bYes ? ScrollingYes : ScrollingNo; + } + break; + case CTF_FRAME_DISPLAY_BORDER: + { + bHasBorder = *(sal_Bool *)rProp.maValue.getValue(); + bIsBorderSet = sal_True; + } + break; + case CTF_FRAME_MARGIN_HORI: + { + sal_Int32 nVal = SIZE_NOT_SET; + rProp.maValue >>= nVal; + aMargin.Width() = nVal; + } + break; + case CTF_FRAME_MARGIN_VERT: + { + sal_Int32 nVal = SIZE_NOT_SET; + rProp.maValue >>= nVal; + aMargin.Height() = nVal; + } + break; + } + } + } + } + } + pFrameDesc->SetScrollingMode( eScrollMode ); + if( bIsBorderSet ) + pFrameDesc->SetFrameBorder( bHasBorder ); + else + pFrameDesc->ResetBorder(); + pFrameDesc->SetMargin( aMargin ); + + SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE ); + SfxFrameObjectRef pFrame = new SfxFrameObject(); + pFrame->DoInitNew( pStor ); + + pFrame->EnableSetModified( FALSE ); + pFrame->SetFrameDescriptor( pFrameDesc ); + pFrame->EnableSetModified( TRUE ); + + SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(), + pFrame, + &aItemSet); + SwXFrame *pXFrame = SwXFrames::GetObject( *pFrmFmt, FLYCNTTYPE_OLE ); + xPropSet = pXFrame; + if( pDoc->GetDrawModel() ) + SwXFrame::GetOrCreateSdrObject( + static_cast<SwFlyFrmFmt*>( pXFrame->GetFrmFmt() ) ); // req for z-order + + return xPropSet; +} + +void SwXMLTextImportHelper::endAppletOrPlugin( + Reference < XPropertySet > &rPropSet, + ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess > &rParamMap) +{ + // this method will modify the document directly -> lock SolarMutex + SolarMutexGuard aGuard; + + Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY ); + ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" ); + SwXFrame *pFrame = + (SwXFrame *)xCrsrTunnel->getSomething( + SwXFrame::getUnoTunnelId() ); + ASSERT( pFrame, "SwXFrame missing" ); + SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt(); + const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); + const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx(); + SwOLENode *pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode()->GetOLENode(); + SwOLEObj& rOLEObj = pOLENd->GetOLEObj(); + + SvPlugInObjectRef xPlugin ( rOLEObj.GetOleRef() ); + SvAppletObjectRef xApplet ( rOLEObj.GetOleRef() ); + SvCommandList aCommandList; + + ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess > ::iterator aIter = rParamMap.begin(); + ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess > ::iterator aEnd = rParamMap.end(); + + while (aIter != aEnd ) + { + aCommandList.Append( (*aIter).first, (*aIter).second); + aIter++; + } + + if (xApplet.Is()) + { + xApplet->SetCommandList( aCommandList ); + xApplet->EnableSetModified ( TRUE ); + } + else if (xPlugin.Is()) + { + xPlugin->SetCommandList( aCommandList ); + xPlugin->EnableSetModified ( TRUE ); + } +} + +XMLTextImportHelper* SwXMLImport::CreateTextImport() +{ + return new SwXMLTextImportHelper( GetModel(), *this, getImportInfo(), + IsInsertMode(), + IsStylesOnlyMode(), bShowProgress, + IsBlockMode(), IsOrganizerMode(), + bPreserveRedlineMode ); +} + + +// redlining helper methods +// (override to provide the real implementation) + +void SwXMLTextImportHelper::RedlineAdd( + const OUString& rType, + const OUString& rId, + const OUString& rAuthor, + const OUString& rComment, + const util::DateTime& rDateTime, + sal_Bool bMergeLastPara) +{ + // create redline helper on demand + DBG_ASSERT(NULL != pRedlineHelper, "helper should have been created in constructor"); + if (NULL != pRedlineHelper) + pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime, + bMergeLastPara); +} + +Reference<XTextCursor> SwXMLTextImportHelper::RedlineCreateText( + Reference<XTextCursor> & rOldCursor, + const OUString& rId) +{ + Reference<XTextCursor> xRet; + + if (NULL != pRedlineHelper) + { + xRet = pRedlineHelper->CreateRedlineTextSection(rOldCursor, rId); + } + + return xRet; +} + +void SwXMLTextImportHelper::RedlineSetCursor( + const OUString& rId, + sal_Bool bStart, + sal_Bool bIsOutsideOfParagraph) +{ + if (NULL != pRedlineHelper) { + Reference<XTextRange> xTextRange( GetCursor()->getStart() ); + pRedlineHelper->SetCursor(rId, bStart, xTextRange, + bIsOutsideOfParagraph); + } + // else: ignore redline (wasn't added before, else we'd have a helper) +} + +void SwXMLTextImportHelper::RedlineAdjustStartNodeCursor( + sal_Bool bStart) +{ + OUString rId = GetOpenRedlineId(); + if ((NULL != pRedlineHelper) && (rId.getLength() > 0)) + { + Reference<XTextRange> xTextRange( GetCursor()->getStart() ); + pRedlineHelper->AdjustStartNodeCursor(rId, bStart, xTextRange ); + ResetOpenRedlineId(); + } + // else: ignore redline (wasn't added before, or no open redline ID +} + +void SwXMLTextImportHelper::SetShowChanges( sal_Bool bShowChanges ) +{ + if ( NULL != pRedlineHelper ) + pRedlineHelper->SetShowChanges( bShowChanges ); +} + +void SwXMLTextImportHelper::SetRecordChanges( sal_Bool bRecordChanges ) +{ + if ( NULL != pRedlineHelper ) + pRedlineHelper->SetRecordChanges( bRecordChanges ); +} + +void SwXMLTextImportHelper::SetChangesProtectionKey( + const Sequence<sal_Int8> & rKey ) +{ + if ( NULL != pRedlineHelper ) + pRedlineHelper->SetProtectionKey( rKey ); +} + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/wrtxml.hxx b/binfilter/bf_sw/source/filter/xml/wrtxml.hxx new file mode 100644 index 000000000000..025ff4ba4d6f --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/wrtxml.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _WRTXML_HXX +#define _WRTXML_HXX + +#include <shellio.hxx> +namespace com { namespace sun { namespace start { + namespace uno { template<class A> class Reference; } + namespace uno { template<class A> class Sequence; } + namespace uno { class Any; } + namespace lang { class XComponent; } + namespace lang { class XMultiServiceFactory; } + namespace beans { struct PropertyValue; } +} } } +namespace binfilter { + +class SwDoc; +class SwPaM; +class SfxMedium; + + +class SwXMLWriter : public StgWriter +{ + sal_uInt32 _Write(); + +protected: + virtual ULONG WriteStorage(); + +public: + + SwXMLWriter(); + virtual ~SwXMLWriter(); + + virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 ); + +private: + + // helper methods to write XML streams + + /// write a single XML stream into the package + sal_Bool WriteThroughComponent( + /// the component we export + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XComponent> & xComponent, + const sal_Char* pStreamName, /// the stream name + /// service factory for pServiceName + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory> & rFactory, + const sal_Char* pServiceName, /// service name of the component + /// the argument (XInitialization) + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any> & rArguments, + /// output descriptor + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue> & rMediaDesc, + sal_Bool bPlainStream ); /// neither compress nor encrypt + + /// write a single output stream + /// (to be called either directly or by WriteThroughComponent(...)) + sal_Bool WriteThroughComponent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::io::XOutputStream> & xOutputStream, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XComponent> & xComponent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory> & rFactory, + const sal_Char* pServiceName, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any> & rArguments, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue> & rMediaDesc ); +}; + + +} //namespace binfilter +#endif // _WRTXML_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlbrshe.hxx b/binfilter/bf_sw/source/filter/xml/xmlbrshe.hxx new file mode 100644 index 000000000000..63cca202c970 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlbrshe.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLBRSHE_HXX +#define _XMLBRSHE_HXX + +#include <rtl/ustring.hxx> + +namespace binfilter { + + +class SvxBrushItem; +class SwXMLExport; + +class SwXMLBrushItemExport +{ + SwXMLExport& rExport; + +protected: + + SwXMLExport& GetExport() { return rExport; } +public: + + SwXMLBrushItemExport( SwXMLExport& rExport ); + ~SwXMLBrushItemExport(); + + // core API + void exportXML( const SvxBrushItem& rItem ); +}; + + +} //namespace binfilter +#endif // _XMLBRSHE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlbrshi.hxx b/binfilter/bf_sw/source/filter/xml/xmlbrshi.hxx new file mode 100644 index 000000000000..749145b073d6 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlbrshi.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLBRSHI_HXX +#define _XMLBRSHI_HXX + +#include "bf_xmloff/xmlictxt.hxx" +namespace rtl { class OUString; } +namespace com { namespace sun { namespace star { + namespace io { class XOutputStream; } +} } } +namespace binfilter {//STRIP009 +class SvXMLImport; +class SvXMLUnitConverter; +class SvxBrushItem; +class SwXMLBrushItemImportContext : public SvXMLImportContext +{ +private: + ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > xBase64Stream; + 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(); + + 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 EndElement(); + + const SvxBrushItem& GetItem() const { return *pItem; } +}; + + +} //namespace binfilter +#endif // _XMLBRSHI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlexp.hxx b/binfilter/bf_sw/source/filter/xml/xmlexp.hxx new file mode 100644 index 000000000000..675d7266fe34 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlexp.hxx @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLEXP_HXX +#define _XMLEXP_HXX + +#include <bf_xmloff/xmlexp.hxx> + +#include "xmlitmap.hxx" +#include <bf_xmloff/uniref.hxx> +#include <bf_xmloff/xmltoken.hxx> +namespace binfilter { + +class SwPaM; +class SwFmt; +class SwFrmFmt; +class SvXMLUnitConverter; +class SvXMLAutoStylePoolP; +class XMLPropertySetMapper; + +class SvXMLExportItemMapper; + +class SwTableLine; +class SwTableLines; +class SwTableBox; +class SwXMLTableColumn_Impl; +class SwXMLTableLines_Impl; +class SwXMLTableLinesCache_Impl; +class SwXMLTableColumnsSortByWidth_Impl; +class SwXMLTableFrmFmtsSort_Impl; +class SwXMLTableInfo_Impl; +class SwTableNode; + + +#ifndef XML_PROGRESS_REF_NOT_SET +#define XML_PROGRESS_REF_NOT_SET ((sal_Int32)-1) +#endif + + +class SwXMLExport : public SvXMLExport +{ + friend class SwXMLExpContext; + +#ifdef XML_CORE_API + SwPaM *pCurPaM; // the current PaM + SwPaM *pOrigPaM; // the original PaM +#endif + + SvXMLUnitConverter *pTwipUnitConv; + + SvXMLExportItemMapper *pTableItemMapper; + SwXMLTableLinesCache_Impl *pTableLines; + + SvXMLItemMapEntriesRef xTableItemMap; + SvXMLItemMapEntriesRef xTableRowItemMap; + SvXMLItemMapEntriesRef xTableCellItemMap; + UniReference < XMLPropertySetMapper > xParaPropMapper; + + sal_Bool bExportWholeDoc : 1;// export whole document? + sal_Bool bBlock : 1; // export text block? + sal_Bool bExportFirstTableOnly : 1; + sal_Bool bShowProgress : 1; + sal_Bool bSavedShowChanges : 1; + + void _InitItemExport(); + void _FinitItemExport(); + void ExportTableLinesAutoStyles( const SwTableLines& rLines, + sal_uInt32 nAbsWidth, + sal_uInt32 nBaseWidth, + const ::rtl::OUString& rNamePrefix, + SwXMLTableColumnsSortByWidth_Impl& rExpCols, + SwXMLTableFrmFmtsSort_Impl& rExpRows, + SwXMLTableFrmFmtsSort_Impl& rExpCells, + SwXMLTableInfo_Impl& rTblInfo, + sal_Bool bTop=sal_False ); + + + void ExportFmt( const SwFmt& rFmt, enum ::binfilter::xmloff::token::XMLTokenEnum eClass = ::binfilter::xmloff::token::XML_TOKEN_INVALID ); + void ExportTableFmt( const SwFrmFmt& rFmt, sal_uInt32 nAbsWidth ); + + void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol ); + void ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan, + SwXMLTableInfo_Impl& rTblInfo ); + void ExportTableLine( const SwTableLine& rLine, + const SwXMLTableLines_Impl& rLines, + SwXMLTableInfo_Impl& rTblInfo ); + void ExportTableLines( const SwTableLines& rLines, + SwXMLTableInfo_Impl& rTblInfo, + sal_Bool bHeadline=sal_False ); + + virtual void _ExportMeta(); + virtual void _ExportFontDecls(); + virtual void _ExportStyles( sal_Bool bUsed ); + virtual void _ExportAutoStyles(); + virtual void _ExportMasterStyles(); + virtual void _ExportContent(); + virtual void GetViewSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps); + virtual void GetConfigurationSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps); + +#ifdef XML_CORE_API + void SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly ); +#endif + + // string constants for table cell export + const ::rtl::OUString sNumberFormat; + const ::rtl::OUString sIsProtected; + const ::rtl::OUString sCell; + +protected: + + virtual XMLTextParagraphExport* CreateTextParagraphExport(); + virtual SvXMLAutoStylePoolP* CreateAutoStylePool(); + virtual XMLPageExport* CreatePageExport(); + virtual XMLShapeExport* CreateShapeExport(); + virtual XMLFontAutoStylePool* CreateFontAutoStylePool(); + +public: + + // #110680# + SwXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nExportFlags = EXPORT_ALL); + +#ifdef XML_CORE_API + // #110680# + SwXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + 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, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > &, + sal_Bool bExpWholeDoc, + sal_Bool bExpFirstTableOnly, + sal_Bool bShowProgr ); +#endif + virtual ~SwXMLExport(); + + void setBlockMode(); + + virtual sal_uInt32 exportDoc( enum ::binfilter::xmloff::token::XMLTokenEnum eClass = ::binfilter::xmloff::token::XML_TOKEN_INVALID ); + + inline const SvXMLUnitConverter& GetTwipUnitConverter() const; + + void ExportTableAutoStyles( const SwTableNode& rTblNd ); + void ExportTable( const SwTableNode& rTblNd ); + + SvXMLExportItemMapper& GetTableItemMapper() { return *pTableItemMapper; } + const UniReference < XMLPropertySetMapper >& GetParaPropMapper() + { + return xParaPropMapper; + } + + sal_Bool IsShowProgress() const { return bShowProgress; } + void SetShowProgress( sal_Bool b ) { bShowProgress = b; } + sal_Bool IsBlockMode() const { return bBlock; } + + // XUnoTunnel + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo (override parent method) + ::rtl::OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ); +}; + +inline const SvXMLUnitConverter& SwXMLExport::GetTwipUnitConverter() const +{ + return *pTwipUnitConv; +} + + +} //namespace binfilter +#endif // _XMLEXP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlexpit.hxx b/binfilter/bf_sw/source/filter/xml/xmlexpit.hxx new file mode 100644 index 000000000000..9f301870c110 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlexpit.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLITMPR_HXX +#define _XMLITMPR_HXX + +#include <tools/solar.h> +#include <tools/ref.hxx> + +#include "xmlitmap.hxx" + +#define XML_EXPORT_FLAG_DEFAULTS 0x0001 // export also default items +#define XML_EXPORT_FLAG_DEEP 0x0002 // export also items from + // parent item sets +#define XML_EXPORT_FLAG_EMPTY 0x0004 // export attribs element + // even if its empty +#define XML_EXPORT_FLAG_IGN_WS 0x0008 + +namespace rtl { class OUString; } + +namespace binfilter { +class SvUShorts; +class SfxPoolItem; +class SfxItemSet; +class SvXMLUnitConverter; +class SvXMLAttributeList; +class SvXMLNamespaceMap; +class SvXMLExport; + +class SvXMLExportItemMapper +{ +protected: + SvXMLItemMapEntriesRef mrMapEntries; + + /** fills the given attribute list with the items in the given set */ + void exportXML( SvXMLAttributeList& rAttrList, + const SfxItemSet& rSet, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + sal_uInt16 nFlags, + SvUShorts* pIndexArray ) const; + + void exportXML( SvXMLAttributeList& rAttrList, + const SfxPoolItem& rItem, + const SvXMLItemMapEntry &rEntry, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + sal_uInt16 nFlags, + const SfxItemSet *pSet ) const; + + + void exportElementItems( SvXMLExport& rExport, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet &rSet, + sal_uInt16 nFlags, + const SvUShorts& rIndexArray ) const; + + static const SfxPoolItem* GetItem( const SfxItemSet &rSet, + sal_uInt32 nWhichId, + sal_uInt16 nFlags ); + +public: + SvXMLExportItemMapper( SvXMLItemMapEntriesRef rMapEntries ); + virtual ~SvXMLExportItemMapper(); + + /** fills the given attribute list with the representation of one + item */ + void exportXML( SvXMLExport& rExport, + const SfxItemSet& rSet, + const SvXMLUnitConverter& rUnitConverter, + sal_uInt16 nFlags = 0 ) const; + + /** this method is called for every item that has the + MID_FLAG_SPECIAL_ITEM_EXPORT flag set */ + virtual void handleSpecialItem( SvXMLAttributeList& rAttrList, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const SfxItemSet *pSet = NULL ) const; + + + /** this method is called for every item that has the + MID_FLAG_NO_ITEM_EXPORT flag set */ + virtual void handleNoItem( SvXMLAttributeList& rAttrList, + const SvXMLItemMapEntry& rEntry, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap, + const SfxItemSet& rSet ) const; + + /** this method is called for every item that has the + MID_FLAG_ELEMENT_EXPORT flag set */ + virtual void handleElementItem( SvXMLExport& rExport, + const SvXMLItemMapEntry& rEntry, + const SfxPoolItem& rItem, + const SvXMLUnitConverter& rUnitConverter, + const SfxItemSet& rSet, + sal_uInt16 nFlags ) const; + + inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); + + static sal_Bool QueryXMLValue( const SfxPoolItem& rItem, + ::rtl::OUString& rValue, sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ); +}; + +inline void +SvXMLExportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries ) +{ + mrMapEntries = rMapEntries; +} + +} //namespace binfilter +#endif // _XMLITMPR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlimp.hxx b/binfilter/bf_sw/source/filter/xml/xmlimp.hxx new file mode 100644 index 000000000000..0d46d7d87e06 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlimp.hxx @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLIMP_HXX +#define _XMLIMP_HXX + +#include <bf_so3/svstor.hxx> + +#include <bf_xmloff/xmlictxt.hxx> + +#include "xmlitmap.hxx" + +#include <bf_xmloff/xmlimp.hxx> +namespace binfilter { + +class SfxItemSet; +class SwDoc; +class SwPaM; +class SvXMLImportItemMapper; +class SvXMLUnitConverter; +class SvXMLTokenMap; +class XMLTextImportHelper; + +class SwNodeIndex; + +class SvXMLGraphicHelper; +class SvXMLEmbeddedObjectHelper; + +// define, how many steps ( = paragraphs ) the progress bar should advance +// for styles, autostyles and settings + meta +#define PROGRESS_BAR_STEP 20 + +class SwXMLImport: public SvXMLImport +{ + SwNodeIndex *pSttNdIdx; + + SvXMLUnitConverter *pTwipUnitConv; + SvXMLImportItemMapper *pTableItemMapper;// paragraph item import + SvXMLTokenMap *pDocElemTokenMap; + SvXMLTokenMap *pTableElemTokenMap; + SvXMLTokenMap *pTableCellAttrTokenMap; + SvXMLGraphicHelper *pGraphicResolver; + SvXMLEmbeddedObjectHelper *pEmbeddedResolver; + + SvXMLItemMapEntriesRef xTableItemMap; + SvXMLItemMapEntriesRef xTableColItemMap; + SvXMLItemMapEntriesRef xTableRowItemMap; + SvXMLItemMapEntriesRef xTableCellItemMap; + SvStorageRef xPackage; + + 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 bBlock : 1; // Load text block + sal_Bool bAutoStylesValid : 1; + sal_Bool bShowProgress : 1; + sal_Bool bOrganizerMode : 1; + sal_Bool bPreserveRedlineMode; + + void _InitItemImport(); + void _FinitItemImport(); + void UpdateTxtCollConditions( SwDoc *pDoc ); + +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(); + + virtual XMLShapeImportHelper* CreateShapeImport(); + +public: + + // #110680# + SwXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nImportFlags = IMPORT_ALL); + +#ifdef XML_CORE_API + // #110680# + SwXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + 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, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > &, + SvStorage *pPkg ); +#endif + + ~SwXMLImport() throw(); + + void setTextInsertMode( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & rInsertPos ); + void setStyleInsertMode( sal_uInt16 nFamilies, + sal_Bool bOverwrite ); + void setBlockMode(); + void setOrganizerMode(); + + // ::com::sun::star::xml::sax::XDocumentHandler + virtual void SAL_CALL startDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL endDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + // XUnoTunnel + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo (override parent method) + ::rtl::OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ); + + void InsertStyles( sal_Bool bAuto ); + void FinishStyles(); + + // namespace office + SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName ); + SvXMLImportContext *CreateScriptContext( 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 *CreateMasterStylesContext( + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext *CreateFontDeclsContext( + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext *CreateBodyContext( const ::rtl::OUString& rLocalName ); + sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; } + sal_Bool IsInsertMode() const { return bInsert; } + sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; } + sal_Bool IsBlockMode() const { return bBlock; } + sal_Bool IsOrganizerMode() const { return bOrganizerMode; } + + inline const SvXMLUnitConverter& GetTwipUnitConverter() const; + inline const SvXMLImportItemMapper& GetTableItemMapper() const; + 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(); + const SvXMLTokenMap& GetTableElemTokenMap(); + const SvXMLTokenMap& GetTableCellAttrTokenMap(); + + sal_Bool FindAutomaticStyle( sal_uInt16 nFamily, + const ::rtl::OUString& rName, + const SfxItemSet **ppItemSet=0, + ::rtl::OUString *pParent=0 ) const; + + virtual void SetStatisticAttributes(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs); + virtual void SetViewSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aViewProps); + virtual void SetConfigurationSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aConfigProps); + + SvStorage *GetPackage() { return &xPackage; } + + void SetProgressValue( sal_Int32 nValue ); +}; + +inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const +{ + return *pTwipUnitConv; +} + +inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const +{ + return *pTableItemMapper; +} + +inline void SwXMLImport::SetProgressValue( sal_Int32 nValue ) +{ + if ( bShowProgress ) + GetProgressBarHelper()->SetValue(nValue); +} + +} //namespace binfilter +#endif // _XMLIMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlimpit.hxx b/binfilter/bf_sw/source/filter/xml/xmlimpit.hxx new file mode 100644 index 000000000000..2d708e5c0d2f --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlimpit.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLIMPIT_HXX +#define _XMLIMPIT_HXX + +#include <limits.h> + +#include <tools/solar.h> +#include <tools/ref.hxx> + + +#include <com/sun/star/xml/sax/XAttributeList.hpp> + +#include "xmlitmap.hxx" + +namespace rtl { class OUString; } +namespace binfilter { + +class SfxPoolItem; +class SfxItemSet; + +class SvXMLUnitConverter; +class SvXMLAttributeList; +class SvXMLNamespaceMap; +struct SvXMLItemMapEntry; + +class SvXMLImportItemMapper +{ +protected: + SvXMLItemMapEntriesRef mrMapEntries; + USHORT nUnknownWhich; + +public: + SvXMLImportItemMapper( SvXMLItemMapEntriesRef rMapEntries , + USHORT nUnknWhich=USHRT_MAX ); + virtual ~SvXMLImportItemMapper(); + + /** fills the given itemset with the attributes in the given list */ + void importXML( SfxItemSet& rSet, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttrList, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const; + + /** this method is called for every item that has the + MID_FLAG_SPECIAL_ITEM_IMPORT flag set */ + virtual BOOL handleSpecialItem( const SvXMLItemMapEntry& rEntry, + SfxPoolItem& rItem, + SfxItemSet& rSet, + const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const; + + /** this method is called for every item that has the + MID_FLAG_NO_ITEM_IMPORT flag set */ + virtual BOOL handleNoItem( const SvXMLItemMapEntry& rEntry, + SfxItemSet& rSet, + const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + const SvXMLNamespaceMap& rNamespaceMap ) const; + + /** This method is called when all attributes have benn processed. It + * may be used to remove items that are incomplete */ + virtual void finished( SfxItemSet& rSet ) const; + + inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); + inline SvXMLItemMapEntriesRef getMapEntries() const; + + + /** This method is called for every item that should be set based + upon an XML attribute value. */ + static sal_Bool PutXMLValue( + SfxPoolItem& rItem, + const ::rtl::OUString& rValue, + sal_uInt16 nMemberId, + const SvXMLUnitConverter& rUnitConverter ); +}; + +inline void +SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries ) +{ + mrMapEntries = rMapEntries; +} + +inline SvXMLItemMapEntriesRef +SvXMLImportItemMapper::getMapEntries() const +{ + return mrMapEntries; +} + + +} //namespace binfilter +#endif // _XMLIMPIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlitem.hxx b/binfilter/bf_sw/source/filter/xml/xmlitem.hxx new file mode 100644 index 000000000000..5f7eebb7e2ad --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlitem.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLITEM_HXX +#define _XMLITEM_HXX + +#include <com/sun/star/xml/sax/XAttributeList.hpp> + +#include <tools/solar.h> +#include <limits.h> + +#include <bf_xmloff/xmlictxt.hxx> + +namespace rtl { class OUString; } +namespace binfilter { + +class SfxItemSet; + +class SvXMLUnitConverter; +class SvXMLImportItemMapper; + +struct SvXMLItemMapEntry; + +class SvXMLItemSetContext : public SvXMLImportContext +{ +protected: + SfxItemSet &rItemSet; + const SvXMLImportItemMapper &rIMapper; + const SvXMLUnitConverter &rUnitConv; + +public: + + SvXMLItemSetContext( SvXMLImport& rImport, USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, + SfxItemSet& rItemSet, + const SvXMLImportItemMapper& rIMappper, + const SvXMLUnitConverter& rUnitConv ); + + virtual ~SvXMLItemSetContext(); + + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + // This method is called from this instance implementation of + // CreateChildContext if the element matches an entry in the + // SvXMLImportItemMapper with the mid flag MID_FLAG_ELEMENT_ITEM_IMPORT + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, + SfxItemSet& rItemSet, + const SvXMLItemMapEntry& rEntry, + const SvXMLUnitConverter& rUnitConv ); + + +}; + + +} //namespace binfilter +#endif // _XMLITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlithlp.hxx b/binfilter/bf_sw/source/filter/xml/xmlithlp.hxx new file mode 100644 index 000000000000..7827b2727baf --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlithlp.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SW_XMLITHLP_HXX +#define _SW_XMLITHLP_HXX + +#include <sal/types.h> + +#include <bf_xmloff/xmlement.hxx> + +#include "hintids.hxx" // for following include + +#include <bf_svx/brshitem.hxx> // for SvxGraphicsPosition +namespace rtl { class OUString; } +class Color; + +namespace binfilter { +struct SvXMLEnumMapEntry; +class SvXMLUnitConverter; +class SvxBorderLine; +//STRIP008 namespace rtl { class OUString; } + + + +/** Define various helper variables and functions for xmlimpit.cxx and + * xmlexpit.cxx. */ + + +#define SVX_XML_BORDER_STYLE_NONE 0 +#define SVX_XML_BORDER_STYLE_SOLID 1 +#define SVX_XML_BORDER_STYLE_DOUBLE 2 + +#define SVX_XML_BORDER_WIDTH_THIN 0 +#define SVX_XML_BORDER_WIDTH_MIDDLE 1 +#define SVX_XML_BORDER_WIDTH_THICK 2 + + +sal_Bool lcl_frmitems_parseXMLBorder( const ::rtl::OUString& rValue, + const SvXMLUnitConverter& rUnitConverter, + sal_Bool& rHasStyle, sal_uInt16& rStyle, + sal_Bool& rHasWidth, sal_uInt16& rWidth, + sal_uInt16& rNamedWidth, + sal_Bool& rHasColor, Color& rColor ); + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nOutWidth, sal_uInt16 nInWidth, + sal_uInt16 nDistance ); + +void lcl_frmitems_setXMLBorderWidth( SvxBorderLine& rLine, + sal_uInt16 nWidth, sal_Bool bDouble ); + +sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_Bool bHasStyle, sal_uInt16 nStyle, + sal_Bool bHasWidth, sal_uInt16 nWidth, + sal_uInt16 nNamedWidth, + sal_Bool bHasColor, const Color& rColor ); + +void lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine, + sal_uInt16 nWidth, sal_uInt16 nOutWidth, + sal_uInt16 nInWidth, sal_uInt16 nDistance ); + +void lcl_frmitems_MergeXMLHoriPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eHori ); + +void lcl_frmitems_MergeXMLVertPos( SvxGraphicPosition& ePos, + SvxGraphicPosition eVert ); + +extern const sal_uInt16 aSBorderWidths[]; +extern const sal_uInt16 aDBorderWidths[5*11]; + +extern const struct SvXMLEnumMapEntry psXML_BorderStyles[]; +extern const struct SvXMLEnumMapEntry psXML_NamedBorderWidths[]; +extern const struct SvXMLEnumMapEntry psXML_BrushRepeat[]; +extern const struct SvXMLEnumMapEntry psXML_BrushHoriPos[]; +extern const struct SvXMLEnumMapEntry psXML_BrushVertPos[]; +extern const struct SvXMLEnumMapEntry psXML_BreakType[]; +extern const struct SvXMLEnumMapEntry aXMLTableAlignMap[]; +extern const struct SvXMLEnumMapEntry aXMLTableVAlignMap[]; + + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmlitmap.hxx b/binfilter/bf_sw/source/filter/xml/xmlitmap.hxx new file mode 100644 index 000000000000..1a93327aa092 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmlitmap.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLITMAP_HXX +#define _XMLITMAP_HXX + +#include <sal/types.h> + +#include <tools/ref.hxx> + +#include <bf_xmloff/xmltoken.hxx> + +namespace rtl { class OUString; } +namespace binfilter { + +#define MID_FLAG_MASK 0x0000ffff + +// this flags are used in the item mapper for import and export + +#define MID_FLAG_SPECIAL_ITEM_IMPORT 0x80000000 +#define MID_FLAG_NO_ITEM_IMPORT 0x40000000 +#define MID_FLAG_SPECIAL_ITEM_EXPORT 0x20000000 +#define MID_FLAG_NO_ITEM_EXPORT 0x10000000 +#define MID_FLAG_SPECIAL_ITEM 0xa0000000 // both import and export +#define MID_FLAG_NO_ITEM 0x50000000 // both import and export +#define MID_FLAG_ELEMENT_ITEM_IMPORT 0x08000000 +#define MID_FLAG_ELEMENT_ITEM_EXPORT 0x04000000 +#define MID_FLAG_ELEMENT_ITEM 0x0c000000 // both import and export + +// --- + +struct SvXMLItemMapEntry +{ + sal_uInt16 nNameSpace; // declares the Namespace in wich this item + // exists + enum ::binfilter::xmloff::token::XMLTokenEnum eLocalName; + // the local name for the item inside + // the Namespace (as an XMLTokenEnum) + sal_uInt32 nWhichId; // the WichId to identify the item + // in the pool + sal_uInt32 nMemberId; // the memberid specifies wich part + // of the item should be imported or + // exported with this Namespace + // and localName +}; + +// --- + +class SvXMLItemMapEntries_impl; + +/** this class manages an array of SvXMLItemMapEntry. It is + used for optimizing the static array on startup of import + or export */ +class SvXMLItemMapEntries : public SvRefBase +{ +protected: + SvXMLItemMapEntries_impl* mpImpl; + +public: + SvXMLItemMapEntries( SvXMLItemMapEntry* pEntrys ); + virtual ~SvXMLItemMapEntries(); + + SvXMLItemMapEntry* getByName( sal_uInt16 nNameSpace, + const ::rtl::OUString& rString, + SvXMLItemMapEntry* pStartAt = NULL ) const; + SvXMLItemMapEntry* getByIndex( sal_uInt16 nIndex ) const; + + sal_uInt16 getCount() const; +}; + +SV_DECL_REF( SvXMLItemMapEntries ) +SV_IMPL_REF( SvXMLItemMapEntries ) + + +} //namespace binfilter +#endif // _XMLITMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmltbli.hxx b/binfilter/bf_sw/source/filter/xml/xmltbli.hxx new file mode 100644 index 000000000000..a04846d3e92f --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmltbli.hxx @@ -0,0 +1,220 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLTBLI_HXX +#define _XMLTBLI_HXX + +#include <bf_xmloff/XMLTextTableContext.hxx> + +#include <hash_map> + +#if !defined(_SVSTDARR_USHORTS_DECL) || !defined(_SVSTDARR_BOOLS_DECL) || !defined(_SVSTDARR_STRINGSDTOR_DECL) +#define _SVSTDARR_USHORTS +#define _SVSTDARR_BOOLS +#define _SVSTDARR_STRINGSDTOR +#include <bf_svtools/svstdarr.hxx> +#endif +namespace binfilter { + +class SwXMLImport; +class SwTableNode; +class SwTableBox; +class SwTableLine; +class SwStartNode; +class SwTableBoxFmt; +class SwTableLineFmt; +class SwXMLTableCell_Impl; +class SwXMLTableRows_Impl; +class SwXMLDDETableContext_Impl; +class TableBoxIndexHasher; +class TableBoxIndex; + +namespace com { namespace sun { namespace star { + namespace text { class XTextContent; } + namespace text { class XTextCursor; } +} } } + + + +class SwXMLTableContext : public XMLTextTableContext +{ + ::rtl::OUString aStyleName; + ::rtl::OUString aDfltCellStyleName; + + SvUShorts aColumnWidths; + SvBools aColumnRelWidths; + SvStringsDtor *pColumnDefaultCellStyleNames; + + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextCursor > xOldCursor; + ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextContent > xTextContent; + + SwXMLTableRows_Impl *pRows; + + SwTableNode *pTableNode; + SwTableBox *pBox1; + const SwStartNode *pSttNd1; + + SwTableBoxFmt *pBoxFmt; + SwTableLineFmt *pLineFmt; + + // hash map of shared format, indexed by the (XML) style name, + // the column width, and protection flag + typedef std::hash_map<TableBoxIndex,SwTableBoxFmt*, + TableBoxIndexHasher> map_BoxFmt; + map_BoxFmt* pSharedBoxFormats; + + SvXMLImportContextRef xParentTable; // if table is a sub table + + SwXMLDDETableContext_Impl *pDDESource; + + 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 ); + + /** sets the appropriate SwTblBoxFmt at pBox. */ + SwTableBoxFmt* GetSharedBoxFormat( + SwTableBox* pBox, /// the table box + const ::rtl::OUString& rStyleName, /// XML style name + sal_Int32 nColumnWidth, /// width of column + sal_Bool bProtected, /// is cell protected? + sal_Bool bMayShare, /// may the format be shared (no value, formula...) + sal_Bool& bNew, /// true, if the format it not from the cache + sal_Bool* pModifyLocked ); /// if set, call pBox->LockModify() and return old lock status + +public: + + TYPEINFO(); + + 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, + const ::rtl::OUString *pDfltCellStyleName = 0 ); + sal_Int32 GetColumnWidth( sal_uInt32 nCol, sal_uInt32 nColSpan=1UL ) const; + ::rtl::OUString GetColumnDefaultCellStyleName( sal_uInt32 nCol ) const; + inline sal_uInt32 GetColumnCount() const; + inline sal_Bool HasColumnDefaultCellStyleNames() const; + + sal_Bool IsInsertCellPossible() const { return nCurCol < GetColumnCount(); } + sal_Bool IsInsertColPossible() const { return nCurCol < USHRT_MAX; } + sal_Bool IsInsertRowPossible() const { return nCurRow < USHRT_MAX; } + sal_Bool IsValid() const { return pTableNode != 0; } + + void InsertCell( const ::rtl::OUString& rStyleName, + sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U, + const SwStartNode *pStNd=0, + SwXMLTableContext *pTable=0, + sal_Bool bIsProtected = sal_False, + const ::rtl::OUString *pFormula=0, + sal_Bool bHasValue = sal_False, + double fValue = 0.0 ); + void InsertRow( const ::rtl::OUString& rStyleName, + const ::rtl::OUString& rDfltCellStyleName, + sal_Bool bInHead ); + void FinishRow(); + void InsertRepRows( sal_uInt32 nCount ); + SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const; + const SwStartNode *InsertTableSection( const SwStartNode *pPrevSttNd=0 ); + + virtual void EndElement(); + + virtual ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextContent > GetXTextContent() const; +}; + +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() ); +} + +inline sal_Bool SwXMLTableContext::HasColumnDefaultCellStyleNames() const +{ + return pColumnDefaultCellStyleNames != 0; +} + +} //namespace binfilter +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmltexte.hxx b/binfilter/bf_sw/source/filter/xml/xmltexte.hxx new file mode 100644 index 000000000000..643cd9b1fcb1 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmltexte.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLTEXTE_HXX +#define _XMLTEXTE_HXX + +#include <bf_xmloff/txtparae.hxx> +#include <tools/globname.hxx> +namespace com { namespace sun { namespace star { namespace style { + class XStyle; } } } } +namespace binfilter { + +class SwXMLExport; +class SvXMLAutoStylePoolP; +class SwNoTxtNode; + + + +class SwXMLTextParagraphExport : public XMLTextParagraphExport +{ + const ::rtl::OUString sTextTable; + const ::rtl::OUString sEmbeddedObjectProtocol; + + const SvGlobalName aAppletClassId; + const SvGlobalName aPluginClassId; + const SvGlobalName aIFrameClassId; + const SvGlobalName aOutplaceClassId; + + SwNoTxtNode *GetNoTxtNode( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet >& rPropSet ) const; + +protected: + virtual void exportStyleContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::style::XStyle > & rStyle ); + + virtual void _collectTextEmbeddedAutoStyles( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > & rPropSet ); + virtual void _exportTextEmbedded( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > & rPropSet, + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo ); + + virtual void exportTable( + const ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextContent > & rTextContent, + sal_Bool bAutoStyles, sal_Bool bProgress ); + +public: + SwXMLTextParagraphExport( + SwXMLExport& rExp, + SvXMLAutoStylePoolP& rAutoStylePool ); + ~SwXMLTextParagraphExport(); + + virtual void setTextEmbeddedGraphicURL( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet >& rPropSet, + ::rtl::OUString& rStreamName ) const; +}; + + +} //namespace binfilter +#endif // _XMLTEXTE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_sw/source/filter/xml/xmltexti.hxx b/binfilter/bf_sw/source/filter/xml/xmltexti.hxx new file mode 100644 index 000000000000..f92e00ab5e08 --- /dev/null +++ b/binfilter/bf_sw/source/filter/xml/xmltexti.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _XMLTEXTI_HXX +#define _XMLTEXTI_HXX + +#include <bf_xmloff/txtimp.hxx> +#include <bf_xmloff/functional.hxx> + +#include <bf_so3/plugin.hxx> + +#include <bf_sfx2/frameobj.hxx> +class SvPlugInObjectRef; +namespace binfilter { +class SvXMLImport; +class XMLRedlineImportHelper; +class SwApplet_Impl; + + +class SwXMLTextImportHelper : public XMLTextImportHelper +{ + XMLRedlineImportHelper *pRedlineHelper; + +protected: + virtual SvXMLImportContext *CreateTableChildContext( + SvXMLImport& rImport, + sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + +public: + SwXMLTextImportHelper( + const ::com::sun::star::uno::Reference < + ::com::sun::star::frame::XModel>& rModel, + SvXMLImport& rImport, + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet>& rInfoSet, + sal_Bool bInsertM, sal_Bool bStylesOnlyM, sal_Bool bProgress, + sal_Bool bBlockM, sal_Bool bOrganizerM, + sal_Bool bPreserveRedlineMode ); + ~SwXMLTextImportHelper(); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> + createAndInsertOLEObject( SvXMLImport& rImport, + const ::rtl::OUString& rHRef, + const ::rtl::OUString& rStyleName, + const ::rtl::OUString& rTblName, + sal_Int32 nWidth, sal_Int32 nHeight ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> + createAndInsertApplet( + const ::rtl::OUString &rName, + const ::rtl::OUString &rCode, + sal_Bool bMayScript, + const ::rtl::OUString& rHRef, + sal_Int32 nWidth, sal_Int32 nHeight ); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> + createAndInsertPlugin( + const ::rtl::OUString &rMimeType, + const ::rtl::OUString& rHRef, + sal_Int32 nWidth, sal_Int32 nHeight ); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> + createAndInsertFloatingFrame( + const ::rtl::OUString &rName, + const ::rtl::OUString &rHRef, + const ::rtl::OUString &rStyleName, + sal_Int32 nWidth, sal_Int32 nHeight ); + + virtual void endAppletOrPlugin( + ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &rPropSet, + ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> &rParamMap); + + virtual sal_Bool IsInHeaderFooter() const; + + // redlining helper methods + // (here is the real implementation) + virtual void RedlineAdd( + const ::rtl::OUString& rType, /// redline type (insert, del,... ) + const ::rtl::OUString& rId, /// use to identify this redline + const ::rtl::OUString& rAuthor, /// name of the author + const ::rtl::OUString& rComment, /// redline comment + const ::com::sun::star::util::DateTime& rDateTime, /// date+time + sal_Bool bMergeLastPara); /// merge last paragraph + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor> RedlineCreateText( + ::com::sun::star::uno::Reference< /// needed to get the document + ::com::sun::star::text::XTextCursor> & rOldCursor, + const ::rtl::OUString& rId); /// ID used to RedlineAdd() call + virtual void RedlineSetCursor( + const ::rtl::OUString& rId, /// ID used to RedlineAdd() call + sal_Bool bStart, /// start or end Cursor + sal_Bool bIsOutsideOfParagraph); + virtual void RedlineAdjustStartNodeCursor( + sal_Bool bStart); + virtual void SetShowChanges( sal_Bool bShowChanges ); + virtual void SetRecordChanges( sal_Bool bRecordChanges ); + virtual void SetChangesProtectionKey( + const ::com::sun::star::uno::Sequence<sal_Int8> & rKey ); +}; + +} //namespace binfilter +#endif // _XMLTEXTI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |