diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-02-16 14:54:09 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-02-16 14:54:09 +0000 |
commit | 711e7188f8c4f224da6cea4e4d564c5ee8ad3d63 (patch) | |
tree | 5be53798bcb5c657c84f0fc66f74eeff4c5d953a /dbaccess/source/ui/misc | |
parent | 2aa93b86bd4ee9a70350a1acb3ded91f452d1ab7 (diff) |
html and rtf ex- import
Diffstat (limited to 'dbaccess/source/ui/misc')
-rw-r--r-- | dbaccess/source/ui/misc/DExport.cxx | 489 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/HtmlReader.cxx | 635 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/RtfReader.cxx | 469 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/TokenWriter.cxx | 861 |
4 files changed, 2454 insertions, 0 deletions
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx new file mode 100644 index 000000000000..1dd2727f987b --- /dev/null +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -0,0 +1,489 @@ +/************************************************************************* + * + * $RCSfile: DExport.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-16 15:52:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_DATABASEEXPORT_HXX +#include "DExport.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/dbconversion.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#define CONTAINER_ENTRY_NOTFOUND ((ULONG)0xFFFFFFFF) + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; + +// ========================================================================== +// ========================================================================== +// ODatabaseExport +// ========================================================================== +ODatabaseExport::ODatabaseExport(sal_Int32 nRows,sal_Int32 nColumns,const Reference< XNumberFormatter >& _rxNumberF) + :m_vColumns(nColumns,0) + ,m_nColumnPos(0) + ,m_nRows(1) + ,m_nRowCount(0) + ,m_bError(FALSE) + ,m_bInTbl(FALSE) + ,m_xFormatter(_rxNumberF) + ,m_bHead(TRUE) + ,m_bDontAskAgain(FALSE) + ,m_bIsAutoIncrement(FALSE) +{ + m_nDefToken = gsl_getSystemTextEncoding(); + + m_nRows += nRows; + m_pColumnSize = new sal_Int32[nColumns]; + m_pFormatKeys = new sal_Int32[nColumns]; + for(sal_Int32 i=0;i<nColumns;++i) + { + m_pColumnSize[i] = 0; + m_pFormatKeys[i] = 0; + } + +} +//--------------------------------------------------------------------------- +ODatabaseExport::ODatabaseExport(const Reference< XConnection >& _rxConnection, + const Reference< XNumberFormatter >& _rxNumberF) + :m_xConnection(_rxConnection) + ,m_nColumnPos(0) + ,m_nRows(1) + ,m_nRowCount(0) + ,m_bError(FALSE) + ,m_bInTbl(FALSE) + ,m_xFormatter(_rxNumberF) + ,m_pColumnSize(0) + ,m_pFormatKeys(0) + ,m_bHead(TRUE) + ,m_bDontAskAgain(FALSE) + ,m_bIsAutoIncrement(FALSE) +{ + m_nDefToken = gsl_getSystemTextEncoding(); + Reference<XTablesSupplier> xTablesSup(m_xConnection,UNO_QUERY); + if(xTablesSup.is()) + m_xTables = xTablesSup->getTables(); + + Reference<XResultSet> xSet = m_xConnection->getMetaData()->getTypeInfo(); + if(xSet.is()) + { + Reference<XRow> xRow(xSet,UNO_QUERY); + while(xSet->next()) + { + if(xRow->getInt(2) == DataType::VARCHAR) + { + m_sVarChar = xRow->getString(1); + break; + } + } + } +} +//--------------------------------------------------------------------------- +ODatabaseExport::~ODatabaseExport() +{ + delete m_pColumnSize; + delete m_pFormatKeys; +} +//------------------------------------------------------------------------------ +String ODatabaseExport::ShortenFieldName( const String& rName, xub_StrLen nNewLength, + const Reference< XNameAccess>& rxDestList ) +{ + xub_StrLen nLength = nNewLength ? nNewLength : rName.Len(); + ////////////////////////////////////////////////////////////////////// + // Wenn es schon einen gekuerzten Namen gibt, Namen durchnumerieren (bis 99) + String aNewName( rName.Copy( 0, nLength )); + String aBaseName( rName.Copy( 0, nLength - 2 )); + xub_StrLen i=1; + while( rxDestList->hasByName(aNewName) && (i<100) ) + { + aNewName = aBaseName; + aNewName += String::CreateFromInt32(i); + i++; + } + + return aNewName; +} +// ----------------------------------------------------------------------------- +void ODatabaseExport::insertValueIntoColumn() +{ + if(m_nColumnPos >= m_xColumnsIdx->getCount()) + { + Reference<XPropertySet> xColumn; + m_xColumnsIdx->getByIndex(m_nColumnPos) >>= xColumn; + if(xColumn.is()) + { + if(!xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWVERSION) || + ! ::cppu::any2bool(xColumn->getPropertyValue(PROPERTY_ISROWVERSION))) + { + sal_Int32 nPos = m_vColumns[m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos]; + if(nPos != CONTAINER_ENTRY_NOTFOUND) + { +// if(m_nDefToken != LANGUAGE_DONTKNOW) // falls Sprache anders als Systemsprache +// m_pNF->ChangeIntl((LanguageType)m_nDefToken); + + if(!m_sTextToken.Len() && m_xResultSetMetaData->isNullable(nPos)) + m_xRowUpdate->updateNull(nPos); + else + { + sal_Int32 nNumberFormat = 0; + double fOutNumber = 0.0; + if (m_vColumnTypes[nPos] != DataType::VARCHAR) + { + Reference<XNumberFormatTypes> xNumType(m_xFormatter->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY); + + try + { + nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::DATETIME,m_nLocale),m_sTextToken); + } + catch(Exception&) + { + try + { + nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::DATE,m_nLocale),m_sTextToken); + } + catch(Exception&) + { + try + { + nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::TIME,m_nLocale),m_sTextToken); + } + catch(Exception&) + { + try + { + nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::NUMBER,m_nLocale),m_sTextToken); + } + catch(Exception&) + { + } + } + } + } + fOutNumber = m_xFormatter->convertStringToNumber(nNumberFormat,m_sTextToken); + m_xRowUpdate->updateDouble(nPos,::dbtools::DBTypeConversion::toStandardDbDate(::dbtools::DBTypeConversion::getStandardDate(),fOutNumber)); + } + else + m_xRowUpdate->updateString(nPos,m_sTextToken); + } + } + m_sTextToken.Erase(); + } + } + } +} +// ----------------------------------------------------------------------------- +sal_Int32 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int32 _nOldFormat) +{ + sal_Int32 F_Index = 0; + double fOutNumber = 0.0; + sal_Int32 nFormat = 0; + + try + { + Reference<XNumberFormats> xFormats = m_xFormatter->getNumberFormatsSupplier()->getNumberFormats(); + Reference<XNumberFormatTypes> xNumType(xFormats,UNO_QUERY); + nFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::ALL,m_nLocale),aCheckToken); + Reference<XPropertySet> xProp = xFormats->getByKey(nFormat); + sal_Int16 nType = 0; + xProp->getPropertyValue(PROPERTY_TYPE) >>= nType; + fOutNumber = m_xFormatter->convertStringToNumber(nFormat,aCheckToken); + + { + m_pFormatKeys[m_nColumnPos] = nFormat; // wird sp"ater f"ur die Column gebraucht + switch(nType) + { + case NumberFormat::ALL: + nFormat = NumberFormat::ALL; + break; + case NumberFormat::DEFINED: + nFormat = NumberFormat::TEXT; + break; + case NumberFormat::DATE: + switch(_nOldFormat) + { + case NumberFormat::DATETIME: + case NumberFormat::TEXT: + case NumberFormat::DATE: + break; + case NumberFormat::ALL: + nFormat = NumberFormat::DATE; + break; + default: + nFormat = NumberFormat::TEXT; + + } + break; + case NumberFormat::TIME: + switch(_nOldFormat) + { + case NumberFormat::DATETIME: + case NumberFormat::TEXT: + case NumberFormat::TIME: + break; + case NumberFormat::ALL: + nFormat = NumberFormat::TIME; + break; + default: + nFormat = NumberFormat::TEXT; + break; + } + break; + case NumberFormat::CURRENCY: + switch(_nOldFormat) + { + case NumberFormat::NUMBER: + nFormat = NumberFormat::CURRENCY; + break; + case NumberFormat::CURRENCY: + break; + case NumberFormat::ALL: + nFormat = NumberFormat::CURRENCY; + break; + default: + nFormat = NumberFormat::TEXT; + break; + } + break; + case NumberFormat::NUMBER: + case NumberFormat::SCIENTIFIC: + case NumberFormat::FRACTION: + case NumberFormat::PERCENT: + switch(_nOldFormat) + { + case NumberFormat::NUMBER: + break; + case NumberFormat::CURRENCY: + nFormat = NumberFormat::CURRENCY; + break; + case NumberFormat::ALL: + nFormat = nType; + break; + default: + nFormat = NumberFormat::TEXT; + break; + } + break; + case NumberFormat::TEXT: + case NumberFormat::UNDEFINED: + case NumberFormat::LOGICAL: + nFormat = NumberFormat::TEXT; // Text "uberschreibt alles + break; + case NumberFormat::DATETIME: + switch(_nOldFormat) + { + case NumberFormat::DATETIME: + case NumberFormat::TEXT: + case NumberFormat::TIME: + break; + case NumberFormat::ALL: + nFormat = NumberFormat::DATETIME; + break; + default: + nFormat = NumberFormat::TEXT; + break; + } + break; + default: + OSL_ENSURE(0,"ODatabaseExport: Unbekanntes Format"); + } + } + } + catch(Exception&) + { + m_pFormatKeys[m_nColumnPos] = 100; + nFormat = NumberFormat::TEXT; // Text "uberschreibt alles + } + + return nFormat; +} +// ----------------------------------------------------------------------------- +void ODatabaseExport::SetColumnTypes(const Reference< XNameAccess>& rList) +{ + if(!m_xConnection.is()) + return; + for(sal_Int32 i=0;i < m_xColumnsIdx->getCount();i++) + { + Reference<XPropertySet> xColumn; + m_xColumnsIdx->getByIndex(m_nColumnPos) >>= xColumn; + + sal_Int32 nDataType; + sal_Int32 nLength(0),nScale(0); + switch(m_vColumns[i]) + { + case NumberFormat::ALL: + nDataType = DataType::DOUBLE; + break; + case NumberFormat::DEFINED: + nDataType = DataType::VARCHAR; + nLength = ((m_pColumnSize[i] % 10 ) ? m_pColumnSize[i]/ 10 + 1: m_pColumnSize[i]/ 10) * 10; + break; + case NumberFormat::DATE: + nDataType = DataType::DATE; + break; + case NumberFormat::TIME: + nDataType = DataType::TIME; + break; + case NumberFormat::DATETIME: + nDataType = DataType::TIMESTAMP; + break; + case NumberFormat::CURRENCY: + nDataType = DataType::NUMERIC; + nScale = 4; + nLength = 19; + break; + case NumberFormat::NUMBER: + case NumberFormat::SCIENTIFIC: + case NumberFormat::FRACTION: + case NumberFormat::PERCENT: + nDataType = DataType::DOUBLE; + break; + case NumberFormat::TEXT: + case NumberFormat::UNDEFINED: + case NumberFormat::LOGICAL: + nDataType = DataType::VARCHAR; + nLength = ((m_pColumnSize[i] % 10 ) ? m_pColumnSize[i]/ 10 + 1: m_pColumnSize[i]/ 10) * 10; + break; + + default: + OSL_ENSURE(0,"ODatabaseExport: Unbekanntes Format"); + } + +// pColumn->Put(SbaDataFieldTypeItem(SBA_DEF_FLTTYPE,(SbaFieldType) nDataType )); +// pColumn->Put(SfxUInt32Item(SBA_DEF_FLTLENGTH,nLength)); +// pColumn->Put(SfxUInt16Item(SBA_DEF_FLTSCALE,nScale)); +// pColumn->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, m_pFormatKeys[i])); + xColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(m_pFormatKeys[i])); + } +} +// ----------------------------------------------------------------------------- +void ODatabaseExport::CreateDefaultColumn(const ::rtl::OUString& _rColumnName) +{ + Reference< XDatabaseMetaData> xDestMetaData(m_xConnection->getMetaData()); + sal_Int32 nMaxNameLen(xDestMetaData->getMaxColumnNameLength()); + ::rtl::OUString aAlias(::dbtools::convertName2SQLName(_rColumnName,xDestMetaData->getExtraNameCharacters())); + + if(nMaxNameLen && aAlias.getLength() > nMaxNameLen) + aAlias = aAlias.copy(0,aAlias.getLength() -(aAlias.getLength()-nMaxNameLen-2)); + aAlias = ::dbtools::createUniqueName(m_xColumns,aAlias); + // now create a column + Reference<XDataDescriptorFactory> xColumnFactory(m_xColumns,UNO_QUERY); + Reference<XPropertySet> xColumn = xColumnFactory->createDataDescriptor(); + + xColumn->setPropertyValue(PROPERTY_NAME,makeAny(aAlias)); + xColumn->setPropertyValue(PROPERTY_TYPE,makeAny(DataType::VARCHAR)); + xColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(m_sVarChar)); + xColumn->setPropertyValue(PROPERTY_PRECISION,makeAny((sal_Int32)255)); + xColumn->setPropertyValue(PROPERTY_SCALE,makeAny((sal_Int32)0)); + xColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(ColumnValue::NULLABLE)); + xColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(sal_False)); + xColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(sal_False)); + + Reference<XAppend> xAppend(m_xColumns,UNO_QUERY); + OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); + xAppend->appendByDescriptor(xColumn); +} + + + + + + + diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx new file mode 100644 index 000000000000..344461b245d8 --- /dev/null +++ b/dbaccess/source/ui/misc/HtmlReader.cxx @@ -0,0 +1,635 @@ +/************************************************************************* + * + * $RCSfile: HtmlReader.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-16 15:52:48 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_HTMLREADER_HXX +#include "HTMLReader.hxx" +#endif +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/dbconversion.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include <com/sun/star/awt/FontDescriptor.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_ +#include <com/sun/star/awt/FontWeight.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSTRIKEOUT_HPP_ +#include <com/sun/star/awt/FontStrikeout.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSLANT_HPP_ +#include <com/sun/star/awt/FontSlant.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP_ +#include <com/sun/star/awt/FontUnderline.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef _HTMLTOKN_H +#include <svtools/htmltokn.h> +#endif +#ifndef _HTMLKYWD_HXX +#include <svtools/htmlkywd.hxx> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif + + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::awt; + +#define DBAUI_HTML_FONTSIZES 7 // wie Export, HTML-Options +// ========================================================================== +DBG_NAME(OHTMLReader); +// ========================================================================== +// OHTMLReader +// ========================================================================== +OHTMLReader::OHTMLReader(SvStream& rIn,const Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF) : HTMLParser(rIn) + ,ODatabaseExport(_rxConnection,_rxNumberF) + ,m_nTableCount(0) + ,m_nColumnWidth(87) +{ + DBG_CTOR(OHTMLReader,NULL); +} +// --------------------------------------------------------------------------- +OHTMLReader::OHTMLReader(SvStream& rIn, + sal_Int32 nRows, + sal_Int32 nColumns, + const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF): HTMLParser(rIn) + ,ODatabaseExport(nRows,nColumns,_rxNumberF) + ,m_nTableCount(0) + ,m_nColumnWidth(87) +{ + DBG_CTOR(OHTMLReader,NULL); +} +// --------------------------------------------------------------------------- +OHTMLReader::~OHTMLReader() +{ + DBG_DTOR(OHTMLReader,NULL); +} +// --------------------------------------------------------------------------- +SvParserState OHTMLReader::CallParser() +{ + rInput.Seek(STREAM_SEEK_TO_BEGIN); + rInput.ResetError(); + return HTMLParser::CallParser(); +} +// --------------------------------------------------------------------------- +void OHTMLReader::NextToken( int nToken ) +{ + if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck + return; + + if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll + { + switch(nToken) + { + case HTML_TABLE_ON: + ++m_nTableCount; + { // es kann auch TD oder TH sein, wenn es vorher kein TABLE gab + const HTMLOptions* pOptions = GetOptions(); + sal_Int16 nArrLen = pOptions->Count(); + for ( sal_Int16 i = 0; i < nArrLen; i++ ) + { + const HTMLOption* pOption = (*pOptions)[i]; + switch( pOption->GetToken() ) + { + case HTML_O_WIDTH: + { // Prozent: von Dokumentbreite bzw. aeusserer Zelle + m_nColumnWidth = GetWidthPixel( pOption ); + } + break; + } + } + } + case HTML_THEAD_ON: + case HTML_TBODY_ON: + if(!m_xTable.is()) // erste Zeile als Header verwenden + m_bError = !CreateTable(nToken); + break; + case HTML_TABLE_OFF: + if(!--m_nTableCount) + { + m_xTable = NULL; + } + break; + case HTML_TABLEROW_ON: + m_xResultSetUpdate->moveToInsertRow(); // sonst neue Zeile anh"angen + break; + case HTML_TEXTTOKEN: + case HTML_SINGLECHAR: + if(m_bInTbl) // wichtig, da wir sonst auch die Namen der Fonts bekommen + m_sTextToken += aToken; + break; + case HTML_TABLEDATA_ON: + m_bInTbl = TRUE; + break; + case HTML_TABLEDATA_OFF: + { + insertValueIntoColumn(); + m_nColumnPos++; + m_sTextToken.Erase(); + m_bInTbl = sal_False; + } + break; + case HTML_TABLEROW_OFF: + try + { + m_nRowCount++; + if (m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement + m_xRowUpdate->updateInt(1,m_nRowCount); + m_xResultSetUpdate->insertRow(); + } + catch(SQLException& e) + ////////////////////////////////////////////////////////////////////// + // UpdateFehlerbehandlung + { + if(!m_bDontAskAgain) + { + String aMsg(e.Message); + aMsg += '\n'; + aMsg += String(ModuleRes(STR_QRY_CONTINUE)); + OSQLMessageBox aBox(NULL, String(ModuleRes(STR_STAT_WARNING)), + aMsg, WB_YES_NO | WB_DEF_NO, OSQLMessageBox::Warning); + + if (aBox.Execute() == RET_YES) + m_bDontAskAgain = TRUE; + else + m_bError = TRUE; + } + } + m_nColumnPos = 0; + break; + } + } + else // Zweig nur f"ur Typpr"ufung g"ultig + { + switch(nToken) + { + case HTML_THEAD_ON: + case HTML_TBODY_ON: + // Der Spalten Kopf z"ahlt nicht mit + if(m_bHead) + { + do + {} + while(GetNextToken() != HTML_TABLEROW_OFF); + m_bHead = sal_False; + } + break; + case HTML_TABLEDATA_ON: + case HTML_TABLEHEADER_ON: + m_bInTbl = TRUE; + break; + case HTML_TEXTTOKEN: + case HTML_SINGLECHAR: + if(m_bInTbl) + m_sTextToken += aToken; + break; + case HTML_TABLEDATA_OFF: + if(m_sTextToken.Len()) + { + m_vColumns[m_nColumnPos] = CheckString(m_sTextToken,m_vColumns[m_nColumnPos]); + m_pColumnSize[m_nColumnPos] = ::std::max((sal_Int32)m_pColumnSize[m_nColumnPos],(sal_Int32)m_sTextToken.Len()); + m_sTextToken.Erase(); + } + m_nColumnPos++; + m_bInTbl = sal_False; + break; + case HTML_TABLEROW_OFF: + if(m_sTextToken.Len()) + { + m_vColumns[m_nColumnPos] = CheckString(m_sTextToken,m_vColumns[m_nColumnPos]); + m_pColumnSize[m_nColumnPos] = ::std::max((sal_Int32)m_pColumnSize[m_nColumnPos],(sal_Int32)m_sTextToken.Len()); + m_sTextToken.Erase(); + } + m_nColumnPos = 0; + m_nRows--; + break; + } + } +} +//--------------------------------------------------------------------------------- +void OHTMLReader::TableDataOn(SvxCellHorJustify& eVal,String *pValue,int nToken) +{ + sal_Bool bHorJustifyCenterTH = (nToken == HTML_TABLEHEADER_ON); + const HTMLOptions* pOptions = GetOptions(); + sal_Int16 nArrLen = pOptions->Count(); + for ( sal_Int16 i = 0; i < nArrLen; i++ ) + { + const HTMLOption* pOption = (*pOptions)[i]; + switch( pOption->GetToken() ) + { + case HTML_O_ALIGN: + { + bHorJustifyCenterTH = sal_False; + const String& rOptVal = pOption->GetString(); + if (rOptVal.EqualsIgnoreCaseAscii( sHTML_AL_right )) + eVal = SVX_HOR_JUSTIFY_RIGHT; + else if (rOptVal.EqualsIgnoreCaseAscii( sHTML_AL_center )) + eVal = SVX_HOR_JUSTIFY_CENTER; + else if (rOptVal.EqualsIgnoreCaseAscii( sHTML_AL_left )) + eVal = SVX_HOR_JUSTIFY_LEFT; + else + eVal = SVX_HOR_JUSTIFY_STANDARD; + } + break; + case HTML_O_SDVAL: + { + pValue = new String( pOption->GetString() ); + } + break; + case HTML_O_SDNUM: + { + pValue = new String( pOption->GetString() ); + } + break; + case HTML_O_BGCOLOR: + //m_aFont.SetFillColor(Color((sal_Int32)pOption->GetString())); + break; + case HTML_O_WIDTH: + { + m_nWidth = GetWidthPixel( pOption ); + } + break; + } + } +} + +//--------------------------------------------------------------------------------- +void OHTMLReader::TableFontOn(sal_Int16 &nWidth,sal_Int16 &nHeight) +{ + FontDescriptor aFont; + const HTMLOptions* pOptions = GetOptions(); + sal_Int16 nArrLen = pOptions->Count(); + for ( sal_Int16 i = 0; i < nArrLen; i++ ) + { + const HTMLOption* pOption = (*pOptions)[i]; + switch( pOption->GetToken() ) + { + case HTML_O_COLOR: + { + Color aColor; + pOption->GetColor( aColor ); + m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,makeAny(aColor.GetRGBColor())); + } + break; + case HTML_O_FACE : + { + const String& rFace = pOption->GetString(); + String aFontName; + xub_StrLen nPos = 0; + while( nPos != STRING_NOTFOUND ) + { // Fontliste, VCL: Semikolon als Separator, HTML: Komma + String aFName = rFace.GetToken( 0, ',', nPos ); + aFName.EraseTrailingChars().EraseLeadingChars(); + if( aFontName.Len() ) + aFontName += ';'; + aFontName += aFName; + } + if ( aFontName.Len() ) + aFont.Name = ::rtl::OUString(aFontName); + } + break; + case HTML_O_SIZE : + { + sal_Int16 nSize = (sal_Int16) pOption->GetNumber(); + if ( nSize == 0 ) + nSize = 1; + else if ( nSize > DBAUI_HTML_FONTSIZES ) + nSize = DBAUI_HTML_FONTSIZES; + + aFont.Height = nSize; + } + break; + } + } +} +// --------------------------------------------------------------------------- +sal_Int16 OHTMLReader::GetWidthPixel( const HTMLOption* pOption ) +{ + const String& rOptVal = pOption->GetString(); + if ( rOptVal.Search('%') != STRING_NOTFOUND ) + { // Prozent + DBG_ASSERT( m_nColumnWidth, "WIDTH Option: m_nColumnWidth==0 und Width%" ); + return (sal_Int16)((pOption->GetNumber() * m_nColumnWidth) / 100); + } + else + { + if ( rOptVal.Search('*') != STRING_NOTFOUND ) + { // relativ zu was?!? +//2do: ColArray aller relativen Werte sammeln und dann MakeCol + return 0; + } + else + return (sal_Int16)pOption->GetNumber(); // Pixel + } +} +// --------------------------------------------------------------------------- +sal_Bool OHTMLReader::CreateTable(int nToken) +{ + String aTableName(ModuleRes(STR_TBL_TITLE)); + aTableName = aTableName.GetToken(0,' '); + + int nTmpToken2 = nToken; + sal_Bool bCaption = sal_False; + sal_Bool bTableHeader = sal_False; + String aColumnName; + SvxCellHorJustify eVal; + String *pValue=NULL; + sal_Int16 nWidth = 0; + sal_Int16 nHeight = 0; + + if(!m_xTable.is()) + { + Reference<XDataDescriptorFactory> xFact(m_xTables,UNO_QUERY); + OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!"); + m_xTable = xFact->createDataDescriptor(); + + aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName))); + Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY); + m_xColumns = xColSup->getColumns(); + } + + do + { + switch(nTmpToken2) + { + case HTML_TEXTTOKEN: + case HTML_SINGLECHAR: + if(bTableHeader) + aColumnName += aToken; + if(bCaption) + aTableName += aToken; + break; + case HTML_TABLEDATA_ON: + case HTML_TABLEHEADER_ON: + if(pValue) + { // HTML_TABLEHEADER_OFF oder HTML_TABLEDATA_OFF fehlte + aColumnName.EraseLeadingChars(); + aColumnName.EraseTrailingChars(); + if (!aColumnName.Len()) + aColumnName = String(ModuleRes(STR_COLUMN_NAME)); + + CreateDefaultColumn(aColumnName); +// SbaColumn* pColumn = CreateColumn(aColumnName,aTableName,pDestList); +// pColumn->Put(SvxHorJustifyItem( eVal, SBA_ATTR_ALIGN_HOR_JUSTIFY) ); +// +// pDestList->InsertAt(aColumnName,pColumn); + aColumnName.Erase(); + + DELETEZ(pValue); + eVal = SVX_HOR_JUSTIFY_STANDARD; + } + TableDataOn(eVal,pValue,nTmpToken2); + bTableHeader = TRUE; + break; + case HTML_TABLEDATA_OFF: + case HTML_TABLEHEADER_OFF: + { + aColumnName.EraseLeadingChars(); + aColumnName.EraseTrailingChars(); + if (!aColumnName.Len()) + aColumnName = String(ModuleRes(STR_COLUMN_NAME)); + + CreateDefaultColumn(aColumnName); + aColumnName.Erase(); + +// SbaColumn* pColumn = CreateColumn(aColumnName,aTableName,pDestList); +// pColumn->Put(SvxHorJustifyItem( eVal, SBA_ATTR_ALIGN_HOR_JUSTIFY) ); +// +// pDestList->InsertAt(aColumnName,pColumn); +// aColumnName.Erase(); +// +// SbaColRowSizeItem aRowHeightItem(*PTR_CAST(SbaColRowSizeItem,&((SbaDBDataDef*)&m_xTable)->GetObjAttrs()->Get( SBA_DEF_ROWHEIGHT ))); +// aRowHeightItem.PutPixelValue(nHeight); +// pColumn->Put(SbaColRowSizeItem(SBA_DEF_FLTCOLWIDTH,nWidth)); + + DELETEZ(pValue); + eVal = SVX_HOR_JUSTIFY_STANDARD; + bTableHeader = sal_False; + } + break; + + case HTML_TITLE_ON: + case HTML_CAPTION_ON: + bCaption = TRUE; + break; + case HTML_TITLE_OFF: + case HTML_CAPTION_OFF: + aTableName.EraseLeadingChars(); + aTableName.EraseTrailingChars(); + if(aTableName.Len()) + { + aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName))); + m_xTable->setPropertyValue(PROPERTY_NAME,makeAny(::rtl::OUString(aTableName))); + } + aTableName.Erase(); + bCaption = sal_False; + break; + case HTML_FONT_ON: + TableFontOn(nWidth,nHeight); + break; + case HTML_BOLD_ON: + { + FontDescriptor aFont; + m_xTable->getPropertyValue(PROPERTY_FONT) >>= aFont; + aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD; + m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(aFont)); + } + break; + case HTML_ITALIC_ON: + { + FontDescriptor aFont; + m_xTable->getPropertyValue(PROPERTY_FONT) >>= aFont; + aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC; + m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(aFont)); + } + break; + case HTML_UNDERLINE_ON: + { + FontDescriptor aFont; + m_xTable->getPropertyValue(PROPERTY_FONT) >>= aFont; + aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE; + m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(aFont)); + } + break; + case HTML_STRIKE_ON: + { + FontDescriptor aFont; + m_xTable->getPropertyValue(PROPERTY_FONT) >>= aFont; + aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE; + m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(aFont)); + } + break; + } + } + while((nTmpToken2 = GetNextToken()) != HTML_TABLEROW_OFF); + + if(aColumnName.Len()) + CreateDefaultColumn(aColumnName); + + m_bInTbl = sal_False; + + sal_Bool m_bError = sal_False; + +// SbaDBDataDefRef xSourceDef = (SbaDBDataDef*)m_xTable; +// CopyTableWizard aWizard(Application::GetDefDialogParent(),xSourceDef,m_xConnection); +// +// DlgCopyTable* pPage1 = new DlgCopyTable(&aWizard,SbaExplorerExchObj::AT_COPY, sal_False,0); +// SbaWizNameMatching* pPage2 = new SbaWizNameMatching(&aWizard); +// SbaWizColumnSelect* pPage3 = new SbaWizColumnSelect(&aWizard); +// SbaWizHTMLExtend* pPage4 = new SbaWizHTMLExtend(&aWizard,rInput); +// +// aWizard.AddWizardPage(pPage1); +// aWizard.AddWizardPage(pPage2); +// aWizard.AddWizardPage(pPage3); +// aWizard.AddWizardPage(pPage4); +// +// aWizard.ActivatePage(); +// +// if (aWizard.Execute()) +// { +// switch(aWizard.GetCreateStyle()) +// { +// case CopyTableWizard::WIZARD_DEF_DATA: +// case CopyTableWizard::WIZARD_APPEND_DATA: +// { +// m_bIsAutoIncrement = aWizard.SetAutoincrement(); +// m_vColumns = aWizard.GetColumnPositions(); +// m_vColumnTypes = aWizard.GetColumnTypes(); +// m_xTable = aWizard.GetTableDef(); +// void *pTemp = (void *)&m_vColumns; +// map<String,String,SbaStringCompare> aTmp = aWizard.GetNameMapping(); +// void* pTemp2 = (void *)&aTmp; +// m_bError = !SbaExplorerExchObj::CheckColumnMerge(xSourceDef->GetColumns(),m_xTable->GetOriginalColumns(),pTemp,pTemp2); +// } +// break; +// default: +// m_bError = TRUE; // there is no error but I have nothing more to do +// } +// } +// else +// m_bError = TRUE; +// +// if(!m_bError && m_xTable.Is()) +// { +// xDestCursor = m_xConnection->CreateCursor( SDB_SNAPSHOT, SDB_APPENDONLY ); +// String aDestTableName( m_xTable->Name()); +// if (!xDestCursor->Open(aDestTableName, TRUE)) +// return sal_False; +// } +// // this two statements are nessesary, else this would let to gpf +// pDestList = NULL; // it must be sure that the list is destroied before def object +// xSourceDef = NULL; + + + return !m_bError && m_xTable.is(); +} diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx new file mode 100644 index 000000000000..a15a995269fc --- /dev/null +++ b/dbaccess/source/ui/misc/RtfReader.cxx @@ -0,0 +1,469 @@ +/************************************************************************* + * + * $RCSfile: RtfReader.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-16 15:52:16 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_RTFREADER_HXX +#include "RtfReader.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include <com/sun/star/awt/FontDescriptor.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_ +#include <com/sun/star/awt/FontWeight.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSTRIKEOUT_HPP_ +#include <com/sun/star/awt/FontStrikeout.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSLANT_HPP_ +#include <com/sun/star/awt/FontSlant.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP_ +#include <com/sun/star/awt/FontUnderline.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ +#include <com/sun/star/util/NumberFormat.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#endif +#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "sqlmessage.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _RTFTOKEN_H +#include <svtools/rtftoken.h> +#endif +#ifndef _DBU_RESOURCE_HRC_ +#include "dbu_resource.hrc" +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/dbconversion.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_EXTRACT_HXX_ +#include <cppuhelper/extract.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::awt; + +DBG_NAME(ORTFReader); +// ========================================================================== +// ORTFReader +// ========================================================================== +ORTFReader::ORTFReader( SvStream& rIn, + const Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF): SvRTFParser(rIn) ,ODatabaseExport(_rxConnection,_rxNumberF) +{ + DBG_CTOR(ORTFReader,NULL); +} +// --------------------------------------------------------------------------- +ORTFReader::ORTFReader(SvStream& rIn, + sal_Int32 nRows, + sal_Int32 nColumns, + const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF) + :SvRTFParser(rIn) + ,ODatabaseExport(nRows,nColumns,_rxNumberF) +{ + DBG_CTOR(ORTFReader,NULL); +} +// --------------------------------------------------------------------------- +ORTFReader::~ORTFReader() +{ + DBG_DTOR(ORTFReader,NULL); +} +// --------------------------------------------------------------------------- +SvParserState ORTFReader::CallParser() +{ + rInput.Seek(STREAM_SEEK_TO_BEGIN); + rInput.ResetError(); + return SvRTFParser::CallParser(); +} + + +// --------------------------------------------------------------------------- +void ORTFReader::NextToken( int nToken ) +{ + if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck + return; + + if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll + { + switch(nToken) + { + case RTF_COLORTBL: + { + + int nTmpToken2 = GetNextToken(); + sal_Bool bNext = TRUE; + do + { + Color aColor; + do + { + switch(nTmpToken2) + { + case RTF_RED: aColor.SetRed(nTokenValue); break; + case RTF_BLUE: aColor.SetBlue(nTokenValue); break; + case RTF_GREEN: aColor.SetGreen(nTokenValue); break; + default: + bNext = sal_False; + } + nTmpToken2 = GetNextToken(); + } + while(aToken.GetChar(0) != ';'); + m_vecColor.push_back(aColor.GetRGBColor()); + nTmpToken2 = GetNextToken(); + } + while(nTmpToken2 == RTF_RED); + SkipToken(); + } + break; + + case RTF_DEFLANG: + case RTF_LANG: // Sprache abfragen + m_nDefToken = nTokenValue; + break; + case RTF_TROWD: + if(!m_xTable.is()) // erste Zeile als Header verwenden + m_bError = !CreateTable(nToken); + else + m_xResultSetUpdate->moveToInsertRow(); // sonst neue Zeile anh"angen + break; + case RTF_INTBL: + if(m_bInTbl) + m_sTextToken.Erase(); + m_bInTbl = TRUE; // jetzt befinden wir uns in einer Tabellenbeschreibung + break; + case RTF_TEXTTOKEN: + case RTF_SINGLECHAR: + if(m_bInTbl) // wichtig, da wir sonst auch die Namen der Fonts bekommen + m_sTextToken += aToken; + break; + case RTF_CELL: + { + insertValueIntoColumn(); + m_nColumnPos++; + m_sTextToken.Erase(); + } + break; + case RTF_ROW: + // es kann vorkommen, da die letzte Celle nicht mit \cell abgeschlossen ist + try + { + insertValueIntoColumn(); + m_nRowCount++; + if(m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement + m_xRowUpdate->updateInt(1,m_nRowCount); + m_xResultSetUpdate->insertRow(); + } + catch(SQLException& e) + ////////////////////////////////////////////////////////////////////// + // UpdateFehlerbehandlung + { + if(!m_bDontAskAgain) + { + String aMsg(e.Message); + aMsg += '\n'; + aMsg += String(ModuleRes(STR_QRY_CONTINUE)); + OSQLMessageBox aBox(NULL, String(ModuleRes(STR_STAT_WARNING)), + aMsg, WB_YES_NO | WB_DEF_NO, OSQLMessageBox::Warning); + + if (aBox.Execute() == RET_YES) + m_bDontAskAgain = TRUE; + else + m_bError = TRUE; + } + } + m_nColumnPos = 0; + break; + } + } + else // Zweig nur f"ur Typpr"ufung g"ultig + { + switch(nToken) + { + case RTF_TROWD: + // Der Spalten Kopf z"ahlt nicht mit + if(m_bHead) + { + do + {} + while(GetNextToken() != RTF_ROW); + m_bHead = sal_False; + } + break; + case RTF_INTBL: + m_bInTbl = TRUE; + break; + case RTF_TEXTTOKEN: + case RTF_SINGLECHAR: + if(m_bInTbl) + m_sTextToken += aToken; + break; + case RTF_CELL: + if(m_sTextToken.Len()) + { + m_vColumns[m_nColumnPos] = CheckString(m_sTextToken,m_vColumns[m_nColumnPos]); + m_pColumnSize[m_nColumnPos] = ::std::max(m_pColumnSize[m_nColumnPos],(sal_Int32)m_sTextToken.Len()); + + m_sTextToken.Erase(); + } + m_nColumnPos++; + break; + case RTF_ROW: + if(m_sTextToken.Len()) + { + m_vColumns[m_nColumnPos] = CheckString(m_sTextToken,m_vColumns[m_nColumnPos]); + m_pColumnSize[m_nColumnPos] = ::std::max(m_pColumnSize[m_nColumnPos],(sal_Int32)m_sTextToken.Len()); + m_sTextToken.Erase(); + } + m_nColumnPos = 0; + m_nRows--; + break; + } + } +} +// --------------------------------------------------------------------------- +sal_Bool ORTFReader::CreateTable(int nToken) +{ + String aTableName(ModuleRes(STR_TBL_TITLE)); + aTableName = aTableName.GetToken(0,' '); + ////////////////////////////////////////////////////////////////////////// + // Wenn keine Tabelle zum Anhaengen da ist, neue erzeugen + Reference<XDataDescriptorFactory> xFact(m_xTables,UNO_QUERY); + OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!"); + m_xTable = xFact->createDataDescriptor(); + + aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName))); + Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY); + m_xColumns = xColSup->getColumns(); + OSL_ENSURE(m_xColumns.is(),"No columns"); + Reference<XDataDescriptorFactory> xColumnFactory(m_xColumns,UNO_QUERY); + + Reference<XAppend> xAppend(m_xColumns,UNO_QUERY); + OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); + + + int nTmpToken2 = nToken; + String aColumnName; + sal_Bool bColorSet=sal_False; + sal_Bool bBoldSet=sal_False; + sal_Bool bUnderlineSet=sal_False; + sal_Bool bStrikeoutSet=sal_False; + sal_Bool bItalicSet=sal_False; + + FontDescriptor aFont; + do + { + switch(nTmpToken2) + { + case RTF_UNKNOWNCONTROL: + case RTF_UNKNOWNDATA: + m_bInTbl = sal_False; + aColumnName.Erase(); + break; + case RTF_INTBL: + if(m_bInTbl) + aColumnName.Erase(); + + m_bInTbl = TRUE; + break; + case RTF_TEXTTOKEN: + case RTF_SINGLECHAR: + if(m_bInTbl) + aColumnName += aToken; + break; + case RTF_CELL: + { + aColumnName.EraseLeadingChars(); + aColumnName.EraseTrailingChars(); + if (!aColumnName.Len()) + aColumnName = String(ModuleRes(STR_COLUMN_NAME)); + + CreateDefaultColumn(aColumnName); + aColumnName.Erase(); + } + break; + case RTF_CF: + if(nTokenValue < m_vecColor.size()) + m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,makeAny(m_vecColor[nTokenValue])); + break; + case RTF_B: + aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD; + break; + case RTF_I: + aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC; + break; + case RTF_UL: + aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE; + break; + case RTF_STRIKE: + aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE; + break; + } + } + while((nTmpToken2 = GetNextToken()) != RTF_ROW); + + + m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(aFont)); + + if(aColumnName.Len()) + CreateDefaultColumn(aColumnName); + + m_bInTbl = sal_False; + + sal_Bool m_bError = sal_False; + +// SbaDBDataDefRef xSourceDef = (SbaDBDataDef*)m_xTable; +// CopyTableWizard aWizard(Application::GetDefDialogParent(),xSourceDef,m_xConnection); +// +// DlgCopyTable* pPage1 = new DlgCopyTable(&aWizard,SbaExplorerExchObj::AT_COPY, sal_False,0); +// SbaWizNameMatching* pPage2 = new SbaWizNameMatching(&aWizard); +// SbaWizColumnSelect* pPage3 = new SbaWizColumnSelect(&aWizard); +// SbaWizRTFExtend* pPage4 = new SbaWizRTFExtend(&aWizard,rInput); +// +// aWizard.AddWizardPage(pPage1); +// aWizard.AddWizardPage(pPage2); +// aWizard.AddWizardPage(pPage3); +// aWizard.AddWizardPage(pPage4); +// +// aWizard.ActivatePage(); +// +// if (aWizard.Execute()) +// { +// switch(aWizard.GetCreateStyle()) +// { +// case CopyTableWizard::WIZARD_DEF_DATA: +// case CopyTableWizard::WIZARD_APPEND_DATA: +// { +// m_bIsAutoIncrement = aWizard.SetAutoincrement(); +// m_vColumns = aWizard.GetColumnPositions(); +// m_vColumnTypes = aWizard.GetColumnTypes(); +// m_xTable = aWizard.GetTableDef(); +// void *pTemp = (void *)&m_vColumns; +// map<String,String,SbaStringCompare> aTmp = aWizard.GetNameMapping(); +// void* pTemp2 = (void *)&aTmp; +// m_bError = !SbaExplorerExchObj::CheckColumnMerge(xSourceDef->GetColumns(),m_xTable->GetOriginalColumns(),pTemp,pTemp2); +// } +// break; +// default: +// m_bError = TRUE; // there is no error but I have nothing more to do +// } +// } +// else +// m_bError = TRUE; +// +// if(!m_bError && m_xTable.is()) +// { +// xDestCursor = m_xConnection->CreateCursor( SDB_SNAPSHOT, SDB_APPENDONLY ); +// String aDestTableName( m_xTable->Name()); +// if (!xDestCursor->Open(aDestTableName, TRUE)) +// return sal_False; +// } +// // this two statements are nessesary, else this would let to gpf +// //pDestList = NULL; // it must be sure that the list is destroied before def object +// xSourceDef = NULL; + + Reference<XAppend> xTableAppend(m_xTables,UNO_QUERY); + xTableAppend->appendByDescriptor(m_xTable); + + return !m_bError && m_xTable.is(); +} +// ----------------------------------------------------------------------------- + + + diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx new file mode 100644 index 000000000000..d710f407464d --- /dev/null +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -0,0 +1,861 @@ +/************************************************************************* + * + * $RCSfile: TokenWriter.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: oj $ $Date: 2001-02-16 15:52:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the License); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef DBAUI_TOKENWRITER_HXX +#include "TokenWriter.hxx" +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "moduledbu.hxx" +#endif +#ifndef DBAUI_RTFREADER_HXX +#include "RtfReader.hxx" +#endif +#ifndef DBAUI_HTMLREADER_HXX +#include "HtmlReader.hxx" +#endif +#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC +#include "dbustrings.hrc" +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_ +#include <com/sun/star/awt/FontWeight.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSTRIKEOUT_HPP_ +#include <com/sun/star/awt/FontStrikeout.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTSLANT_HPP_ +#include <com/sun/star/awt/FontSlant.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP_ +#include <com/sun/star/awt/FontUnderline.hpp> +#endif +#ifndef _HTMLKYWD_HXX +#include <svtools/htmlkywd.hxx> +#endif +#ifndef _RTFKEYWD_HXX +#include <svtools/rtfkeywd.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _HTMLOUT_HXX +#include <svtools/htmlout.hxx> +#endif +#ifndef _SFXDOCINF_HXX +#include <sfx2/docinf.hxx> +#endif +#ifndef _FRMHTMLW_HXX +#include <sfx2/frmhtmlw.hxx> +#endif +#ifndef _NUMUNO_HXX +#include <svtools/numuno.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +using namespace dbaui; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::awt; + + +#if defined(MAC) +const char __FAR_DATA ODatabaseImportExport::sNewLine = '\015'; +#elif defined(UNX) +const char __FAR_DATA ODatabaseImportExport::sNewLine = '\012'; +#else +const char __FAR_DATA ODatabaseImportExport::sNewLine[] = "\015\012"; +#endif + +const static char __FAR_DATA sMyBegComment[] = "<!-- "; +const static char __FAR_DATA sMyEndComment[] = " -->"; +const static char __FAR_DATA sFontFamily[] = "font-family: "; +const static char __FAR_DATA sFontSize[] = "font-size: "; + +#define SBA_FORMAT_SELECTION_COUNT 4 + +DBG_NAME(ODatabaseImportExport); +//====================================================================== +ODatabaseImportExport::ODatabaseImportExport(const Reference< XPropertySet >& _rxObject, + const Reference< XConnection >& _rxConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM, + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, + const String& rExchange) + :m_xObject(_rxObject) + ,m_xConnection(_rxConnection) + ,m_pReader(NULL) + ,m_pRowMarker(NULL) + ,m_xFormatter(_rxNumberF) +{ + + DBG_CTOR(ODatabaseImportExport,NULL); + + + if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT)) + m_xObject->getPropertyValue(PROPERTY_FONT) >>= m_aFont; + + xub_StrLen nCount = rExchange.GetTokenCount(char(11)); + if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len()) + { + m_pRowMarker = new sal_Int32[nCount-SBA_FORMAT_SELECTION_COUNT]; + for(xub_StrLen i=SBA_FORMAT_SELECTION_COUNT;i<nCount;++i) + m_pRowMarker[i-SBA_FORMAT_SELECTION_COUNT] = rExchange.GetToken(i,char(11)).ToInt32(); + } + + m_xResultSet = Reference< XResultSet >(_rM->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.RowSet")),UNO_QUERY); + Reference<XPropertySet > xProp(m_xResultSet,UNO_QUERY); + if(xProp.is()) + { + xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(m_xConnection)); + ::rtl::OUString sName; + sal_Int32 nCommandType; + if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND)) // here we have a query + { + m_xObject->getPropertyValue(PROPERTY_NAME) >>= sName; + nCommandType = CommandType::QUERY; + } + else + { + nCommandType = CommandType::TABLE; + ::rtl::OUString sCatalog, sSchema, sComposedName; + + m_xObject->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; + m_xObject->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + m_xObject->getPropertyValue(PROPERTY_NAME) >>= sName; + ::dbtools::composeTableName(m_xConnection->getMetaData(), sCatalog, sSchema, sName, sComposedName, sal_False); + sName = sComposedName; + } + xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(nCommandType)); + xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(sName)); + Reference<XRowSet> xRowSet(xProp,UNO_QUERY); + xRowSet->execute(); + m_xRow = Reference<XRow>(xRowSet,UNO_QUERY); + m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData(); + } + else + OSL_ASSERT(0); + +} +//------------------------------------------------------------------- +ODatabaseImportExport::~ODatabaseImportExport() +{ + ::comphelper::disposeComponent(m_xRow); + if(m_pReader) + ((SvRefBase*)m_pReader)->ReleaseRef(); + delete m_pRowMarker; + DBG_DTOR(ODatabaseImportExport,NULL); +} +//====================================================================== +BOOL ORTFImportExport::Write() +{ + (*m_pStream) << '{' << sRTF_RTF; +#ifdef MAC + (*m_pStream) << sRTF_MAC << sNewLine; +#else + (*m_pStream) << sRTF_ANSI << sNewLine; +#endif + + /* + // Access RTF Export Beispiel + {\rtf1\ansi + {\colortbl\red0\green0\blue0;\red255\green255\blue255;\red192\green192\blue192;} + {\fonttbl\f0\fcharset0\fnil MS Sans Serif;\f1\fcharset0\fnil Arial;\f2\fcharset0\fnil Arial;} + \trowd\trgaph40 + \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx1437 + \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx2874 + { + \trrh-270\pard\intbl + {\qc\fs20\b\f1\cf0\cb2 text\cell} + \pard\intbl + {\qc\fs20\b\f1\cf0\cb2 datum\cell} + \pard\intbl\row + } + \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874 + {\trrh-270\pard\intbl + {\ql\fs20\f2\cf0\cb1 heute\cell} + \pard\intbl + {\qr\fs20\f2\cf0\cb1 10.11.98\cell} + \pard\intbl\row + } + \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874 + {\trrh-270\pard\intbl + {\ql\fs20\f2\cf0\cb1 morgen\cell} + \pard\intbl + {\qr\fs20\f2\cf0\cb1 11.11.98\cell} + \pard\intbl\row + } + \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874 + {\trrh-270\pard\intbl + {\ql\fs20\f2\cf0\cb1 bruder\cell} + \pard\intbl + {\qr\fs20\f2\cf0\cb1 21.04.98\cell} + \pard\intbl\row + } + \trowd\trgaph40 + \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx + \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874 + {\trrh-270\pard\intbl + {\ql\fs20\f2\cf0\cb1 vater\cell} + \pard\intbl + {\qr\fs20\f2\cf0\cb1 28.06.98\cell} + \pard\intbl\row + } + } + */ + + BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight ); + BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant ); + BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline ); + BOOL bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout ); + + sal_Int32 nColor = 0; + m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; + Color aColor(nColor); + + ByteString aFonts(m_aFont.Name,m_aFont.Name.getLength(), gsl_getSystemTextEncoding()); + if(!aFonts.Len()) + { + String aName = Application::GetSettings().GetStyleSettings().GetAppFont().GetName();; + aFonts = ByteString (aName,aName.Len(), gsl_getSystemTextEncoding()); + } + // TODO : think about the encoding of the font name + ::rtl::OString aFormat("\\fcharset0\\fnil "); + ByteString aFontNr; + + (*m_pStream) << "{\\fonttbl"; + for(xub_StrLen j=0;j<aFonts.GetTokenCount();++j) + { + (*m_pStream) << "\\f"; + (*m_pStream) << ::rtl::OString::valueOf((sal_Int32)j); + (*m_pStream) << aFormat; + (*m_pStream) << aFonts.GetToken(j).GetBuffer(); + (*m_pStream) << ';'; + } + (*m_pStream) << '}' ; + (*m_pStream) << sNewLine; + (*m_pStream) << "{\\colortbl\\red" << ::rtl::OString::valueOf((sal_Int32)aColor.GetRed()) + << "\\green" << ::rtl::OString::valueOf((sal_Int32)aColor.GetGreen()) + << "\\blue" << ::rtl::OString::valueOf((sal_Int32)aColor.GetBlue()) + << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}" << sNewLine; + + sal_Int32 nCellx = 1437; + ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl"); + ::rtl::OString aFS("\\fs20\\f0\\cf0\\cb2"); + ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1"); + ::rtl::OString aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx"); + ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx"); + + ::rtl::OString s40 = ::rtl::OString::valueOf((sal_Int32)40); + + (*m_pStream) << sRTF_TROWD << sRTF_TRGAPH << s40 << sNewLine; + + Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY); + Reference<XNameAccess> xColumns = xColSup->getColumns(); + Sequence< ::rtl::OUString> aNames(xColumns->getElementNames()); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + + sal_Int32 nCount = aNames.getLength(); + + sal_Int32 i; + for(i=1;i<=nCount;++i) + { + (*m_pStream) << aCell1; + (*m_pStream) << ::rtl::OString::valueOf(sal_Int32(i*nCellx)); + (*m_pStream) << sNewLine; + } + + // Spaltenbeschreibung + (*m_pStream) << '{' << sNewLine; + (*m_pStream) << aTRRH; + + + ::rtl::OString* pHorzChar = new ::rtl::OString[nCount]; + + for(i=1;pBegin != pEnd;++pBegin,++i) + { + Reference<XPropertySet> xColumn; + xColumns->getByName(*pBegin) >>= xColumn; + sal_Int32 nAlign = 0; + xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; + + const char* pChar; + switch( nAlign ) + { + case 1: pChar = sRTF_QC; break; + case 2: pChar = sRTF_QR; break; + case 0: + default:pChar = sRTF_QL; break; + } + + pHorzChar[i-1] = pChar; // um sp"ater nicht immer im ITEMSET zuw"uhlen + + (*m_pStream) << sNewLine; + (*m_pStream) << '{'; + (*m_pStream) << sRTF_QC; // column header always centered + + if ( bBold ) (*m_pStream) << sRTF_B; + if ( bItalic ) (*m_pStream) << sRTF_I; + if ( bUnderline ) (*m_pStream) << sRTF_UL; + if ( bStrikeout ) (*m_pStream) << sRTF_STRIKE; + + (*m_pStream) << aFS; + (*m_pStream) << ' '; + (*m_pStream) << ::rtl::OString(*pBegin,pBegin->getLength(), gsl_getSystemTextEncoding()); + // TODO : think about the encoding of the column name + (*m_pStream) << sRTF_CELL; + (*m_pStream) << '}'; + (*m_pStream) << sNewLine; + (*m_pStream) << sRTF_PARD << sRTF_INTBL; + } + + (*m_pStream) << sRTF_ROW; + (*m_pStream) << sNewLine << '}'; + (*m_pStream) << sNewLine; + + sal_Int32 k=1; + sal_Int32 kk=0; + while(m_xResultSet->next()) + { + if(!m_pRowMarker || m_pRowMarker[kk] == k) + { + ++kk; + (*m_pStream) << sRTF_TROWD << sRTF_TRGAPH << s40 << sNewLine; + + for(i=1;i<=nCount;++i) + { + (*m_pStream) << aCell2; + (*m_pStream) << ::rtl::OString::valueOf((sal_Int32)(i*nCellx)); + (*m_pStream) << sNewLine; + } + + (*m_pStream) << '{'; + (*m_pStream) << aTRRH; + for(sal_Int32 i=1;i<=nCount;++i) + { + (*m_pStream) << sNewLine; + (*m_pStream) << '{'; + (*m_pStream) << pHorzChar[i-1]; + + if ( bBold ) (*m_pStream) << sRTF_B; + if ( bItalic ) (*m_pStream) << sRTF_I; + if ( bUnderline ) (*m_pStream) << sRTF_UL; + if ( bStrikeout ) (*m_pStream) << sRTF_STRIKE; + + (*m_pStream) << aFS2; + (*m_pStream) << ' '; + + try + { + ::rtl::OUString sValue = m_xRow->getString(i); + if (!m_xRow->wasNull()) + { + (*m_pStream) << ::rtl::OString(sValue,sValue.getLength(), gsl_getSystemTextEncoding()); + // TODO : think about the encoding of the value string + } + } + catch (Exception&) + { + OSL_ENSURE(0,"RTF WRITE!"); + } + + (*m_pStream) << sRTF_CELL; + (*m_pStream) << '}'; + (*m_pStream) << sNewLine; + (*m_pStream) << sRTF_PARD << sRTF_INTBL; + } + (*m_pStream) << sRTF_ROW << sNewLine; + (*m_pStream) << '}'; + } + ++k; + } + + delete [] pHorzChar; + + (*m_pStream) << '}' << sNewLine; + (*m_pStream) << (BYTE) 0; + return ((*m_pStream).GetError() == SVSTREAM_OK); +} +//------------------------------------------------------------------- +BOOL ORTFImportExport::Read() +{ + m_pReader = new ORTFReader((*m_pStream),m_xConnection,m_xFormatter); + ((ORTFReader*)m_pReader)->AddRef(); + SvParserState eState = ((ORTFReader*)m_pReader)->CallParser(); + ((ORTFReader*)m_pReader)->ReleaseRef(); + + return eState != SVPAR_ERROR; +} +//------------------------------------------------------------------- +//=================================================================== +const sal_Int16 __FAR_DATA OHTMLImportExport::nDefaultFontSize[SBA_HTML_FONTSIZES] = +{ + HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT, + HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT +}; + +sal_Int16 OHTMLImportExport::nFontSize[SBA_HTML_FONTSIZES] = { 0 }; + +const sal_Int16 OHTMLImportExport::nCellSpacing = 0; +const char __FAR_DATA OHTMLImportExport::sIndentSource[nIndentMax+1] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; + +//======================================================================== +// Makros fuer HTML-Export +//======================================================================== +#define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << sNewLine << sNewLine) +#define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag ) +#define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, FALSE ) +#define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str ) +#define OUT_LF() (*m_pStream) << sNewLine << GetIndentStr() +#define lcl_OUT_LF() (*m_pStream) << sNewLine +#define TAG_ON_LF( tag ) (TAG_ON( tag ) << sNewLine << GetIndentStr()) +#define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << sNewLine << GetIndentStr()) +#define OUT_HR() TAG_ON_LF( sHTML_horzrule ) +#define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << sNewLine << GetIndentStr()) +#define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << sNewLine) + +//------------------------------------------------------------------- +OHTMLImportExport::OHTMLImportExport(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM, + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, + const String& rExchange) + : ODatabaseImportExport(_rxObject,_rxConnection,_rM,_rxNumberF,rExchange) + ,m_nIndent(0) +#if DBG_UTIL + ,m_bCheckFont(FALSE) +#endif +{ + strcpy( sIndent, sIndentSource ); + sIndent[0] = 0; +} +//------------------------------------------------------------------- +BOOL OHTMLImportExport::Write() +{ + (*m_pStream) << '<' << sHTML_doctype << ' ' << sHTML_doctype32 << '>' << sNewLine << sNewLine; + TAG_ON_LF( sHTML_html ); + WriteHeader(); + OUT_LF(); + WriteBody(); + OUT_LF(); + TAG_OFF_LF( sHTML_html ); + + return ((*m_pStream).GetError() == SVSTREAM_OK); +} +//------------------------------------------------------------------- +BOOL OHTMLImportExport::Read() +{ + m_pReader = new OHTMLReader((*m_pStream),m_xConnection,m_xFormatter); + ((OHTMLReader*)m_pReader)->AddRef(); + SvParserState eState = ((OHTMLReader*)m_pReader)->CallParser(); + ((OHTMLReader*)m_pReader)->ReleaseRef(); + + return eState != SVPAR_ERROR; +} +//------------------------------------------------------------------- +void OHTMLImportExport::WriteHeader() +{ + SfxDocumentInfo rInfo; + ::rtl::OUString sName; + m_xObject->getPropertyValue(PROPERTY_NAME) >>= sName; + rInfo.SetTitle(sName); + String aStrOut; + + IncIndent(1); TAG_ON_LF( sHTML_head ); + + SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), &rInfo, sIndent ); + OUT_LF(); + /* + TAG_ON( sHTML_title ); + (*m_pStream) << m_rDBDef->Name(); + TAG_OFF_LF( sHTML_title ); + */ + IncIndent(-1); OUT_LF(); TAG_OFF_LF( sHTML_head ); +} +//----------------------------------------------------------------------- +void OHTMLImportExport::WriteBody() +{ + + IncIndent(1); TAG_ON_LF( sHTML_style ); + + (*m_pStream) << sMyBegComment; OUT_LF(); + (*m_pStream) << sHTML_body << " { " << sFontFamily << '\"' << ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(), gsl_getSystemTextEncoding()) << '\"'; + // TODO : think about the encoding of the font name + (*m_pStream) << "; " << sFontSize << ::rtl::OString::valueOf((sal_Int32)m_aFont.Height) << '}'; + OUT_LF(); + (*m_pStream) << sMyEndComment; + IncIndent(-1); OUT_LF(); TAG_OFF_LF( sHTML_style ); + OUT_LF(); + + // default Textfarbe schwarz + (*m_pStream) << '<' << sHTML_body << ' ' << sHTML_O_text << '='; + sal_Int32 nColor = 0; + m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; + Color aColor(nColor); + HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); + + ::rtl::OString sOut( ' ' ); + sOut = sOut + sHTML_O_bgcolor + '='; + (*m_pStream) << sOut; + HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); + + (*m_pStream) << '>'; OUT_LF(); + + WriteTables(); + + TAG_OFF_LF( sHTML_body ); +} +//----------------------------------------------------------------------- +void OHTMLImportExport::WriteTables() +{ + ::rtl::OString aStrOut = sHTML_table; + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_frame; + aStrOut = aStrOut + "="; + aStrOut = aStrOut + sHTML_TF_void; + + Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY); + Reference<XNameAccess> xColumns = xColSup->getColumns(); + Sequence< ::rtl::OUString> aNames(xColumns->getElementNames()); + + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_align; + aStrOut = aStrOut + "="; + aStrOut = aStrOut + sHTML_AL_left; + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_cellspacing; + aStrOut = aStrOut + "="; + aStrOut = aStrOut + ::rtl::OString::valueOf((sal_Int32)nCellSpacing); + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_cols; + aStrOut = aStrOut + "="; + aStrOut = aStrOut + ::rtl::OString::valueOf(aNames.getLength()); + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_border; + aStrOut = aStrOut + "=1"; + + IncIndent(1); + TAG_ON( aStrOut ); + + FontOn(); + + TAG_ON( sHTML_caption ); + TAG_ON( sHTML_bold ); + + ::rtl::OUString sName; + m_xObject->getPropertyValue(PROPERTY_NAME) >>= sName; + (*m_pStream) << ::rtl::OString(sName,sName.getLength(), gsl_getSystemTextEncoding()); + // TODO : think about the encoding of the name + TAG_OFF( sHTML_bold ); + TAG_OFF( sHTML_caption ); + + FontOff(); + OUT_LF(); + // </FONT> + + IncIndent(1); + TAG_ON_LF( sHTML_thead ); + + IncIndent(1); + TAG_ON_LF( sHTML_tablerow ); + + sal_Int32* pFormat = new sal_Int32[aNames.getLength()]; + + char **pHorJustify = new char*[aNames.getLength()]; + sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()]; + + + sal_Int32 nHeight = 0; + m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight; + + // 1. die Spaltenbeschreibung rauspusten + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + + for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i) + { + + Reference<XPropertySet> xColumn; + xColumns->getByName(*pBegin) >>= xColumn; + sal_Int32 nAlign = 0; + xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; + + pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH)); + + switch( nAlign ) + { + case 1: pHorJustify[i] = sHTML_AL_center; break; + case 2: pHorJustify[i] = sHTML_AL_right; break; + default: pHorJustify[i] = sHTML_AL_left; break; + } + + pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY)); + if(i == aNames.getLength()-1) + IncIndent(-1); + + WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pBegin,sHTML_tableheader); + } + + IncIndent(-1); + TAG_OFF_LF( sHTML_tablerow ); + TAG_OFF_LF( sHTML_thead ); + + IncIndent(1); + TAG_ON_LF( sHTML_tbody ); + + // 2. und jetzt die Daten + + sal_Int32 j=1; + sal_Int32 kk=0; + while(m_xResultSet->next()) + { + IncIndent(1); + TAG_ON_LF( sHTML_tablerow ); + + if(!m_pRowMarker || m_pRowMarker[kk] == j) + { + ++kk; + for(sal_Int32 i=1;i<=aNames.getLength();++i) + { + if(i == aNames.getLength()-1) + IncIndent(-1); + + String aValue; + try + { + ::rtl::OUString sValue = m_xRow->getString(i); + if (!m_xRow->wasNull()) + { + aValue = sValue; + } + } + catch ( Exception& ) + { + OSL_ASSERT(0); + } + WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,sHTML_tabledata); + } + } + ++j; + TAG_OFF_LF( sHTML_tablerow ); + } + + delete [] pFormat; + delete [] pHorJustify; + delete [] pColWidth; + + IncIndent(-1); OUT_LF(); TAG_OFF_LF( sHTML_tbody ); + IncIndent(-1); TAG_OFF_LF( sHTML_table ); +} +//----------------------------------------------------------------------- +void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int16 nWidthPixel,sal_Int16 nHeightPixel,const char* pChar,const String& rValue,const char* pHtmlTag) +{ + BOOL bValueData; + bValueData = FALSE; + + ::rtl::OString aStrTD = pHtmlTag; + + nWidthPixel = nWidthPixel ? nWidthPixel : 86; + nHeightPixel = nHeightPixel ? nHeightPixel : 17; + + // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig, + // da die nicht von Netscape beachtet werden.. + // Spaltenbreite + aStrTD = aStrTD + " "; + aStrTD = aStrTD + sHTML_O_width; + aStrTD = aStrTD + "="; + aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nWidthPixel); + // Zeilenhoehe + aStrTD = aStrTD + " "; + aStrTD = aStrTD + sHTML_O_height; + aStrTD = aStrTD + "="; + aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nHeightPixel); + + aStrTD = aStrTD + " "; + aStrTD = aStrTD + sHTML_O_align; + aStrTD = aStrTD + "="; + aStrTD = aStrTD + pChar; + + double fVal = 0.0; + + Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier(); + + Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY); + SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()); + SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL; + if(pFormatter) + { + try + { + fVal = m_xFormatter->convertStringToNumber(nFormat,rValue); + HTMLOutFuncs::CreateTableDataOptionsValNum( ByteString(aStrTD), bValueData, fVal,nFormat, *pFormatter ); + } + catch(Exception&) + { + HTMLOutFuncs::CreateTableDataOptionsValNum( ByteString(aStrTD), bValueData, fVal,nFormat, *pFormatter ); + } + } + + TAG_ON( aStrTD ); + + FontOn(); + + BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight ); + BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant ); + BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline ); + BOOL bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout ); + + if ( bBold ) TAG_ON( sHTML_bold ); + if ( bItalic ) TAG_ON( sHTML_italic ); + if ( bUnderline ) TAG_ON( sHTML_underline ); + if ( bStrikeout ) TAG_ON( sHTML_strike ); + + if ( !rValue.Len() ) + TAG_ON( sHTML_linebreak ); // #42573# keine komplett leere Zelle + else + OUT_STR( rValue ); + + if ( bStrikeout ) TAG_OFF( sHTML_strike ); + if ( bUnderline ) TAG_OFF( sHTML_underline ); + if ( bItalic ) TAG_OFF( sHTML_italic ); + if ( bBold ) TAG_OFF( sHTML_bold ); + + FontOff(); + + TAG_OFF_LF( pHtmlTag ); +} +//----------------------------------------------------------------------- +void OHTMLImportExport::FontOn() +{ +#if DBG_UTIL + m_bCheckFont = TRUE; +#endif + + // <FONT FACE="xxx"> + ::rtl::OString aStrOut = "<"; + aStrOut = aStrOut + sHTML_font; + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_face; + aStrOut = aStrOut + "="; + aStrOut = aStrOut + "\""; + aStrOut = aStrOut + ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(),gsl_getSystemTextEncoding()); + // TODO : think about the encoding of the font name + aStrOut = aStrOut + "\""; + aStrOut = aStrOut + " "; + aStrOut = aStrOut + sHTML_O_color; + aStrOut = aStrOut + "="; + (*m_pStream) << aStrOut; + + sal_Int32 nColor = 0; + m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; + Color aColor(nColor); + + HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); + (*m_pStream) << ">"; +} +//----------------------------------------------------------------------- +inline void OHTMLImportExport::FontOff() +{ + DBG_ASSERT(m_bCheckFont,"Kein FontOn() gerufen"); + TAG_OFF( sHTML_font ); +#if DBG_UTIL + m_bCheckFont = FALSE; +#endif +} +//----------------------------------------------------------------------- +void OHTMLImportExport::IncIndent( sal_Int16 nVal ) +{ + sIndent[m_nIndent] = '\t'; + m_nIndent += nVal; + if ( m_nIndent < 0 ) + m_nIndent = 0; + else if ( m_nIndent > nIndentMax ) + m_nIndent = nIndentMax; + sIndent[m_nIndent] = 0; +} +// ----------------------------------------------------------------------------- + |