diff options
Diffstat (limited to 'binfilter/bf_sw/source/filter/excel')
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/exccrts.hxx | 215 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/excdocum.hxx | 114 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/excfntbf.hxx | 125 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/excvfbff.hxx | 100 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/excxfbuf.hxx | 245 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/exlpar.hxx | 195 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/makefile.mk | 70 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/sw_excimpop.cxx | 1506 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/sw_excread.cxx | 523 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/sw_exctools.cxx | 1903 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/sw_exlpar.cxx | 229 | ||||
-rw-r--r-- | binfilter/bf_sw/source/filter/excel/sw_fltglbls.cxx | 156 |
12 files changed, 5381 insertions, 0 deletions
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: */ |