Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / misc / TokenWriter.cxx
blob110278752e5bdd2e84bd50f120848eb6e0068685
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "TokenWriter.hxx"
30 #include <tools/debug.hxx>
31 #include <tools/diagnose_ex.h>
32 #include <osl/diagnose.h>
33 #include "RtfReader.hxx"
34 #include "HtmlReader.hxx"
35 #include "dbustrings.hrc"
36 #include <comphelper/componentcontext.hxx>
37 #include <comphelper/string.hxx>
38 #include <comphelper/types.hxx>
39 #include <connectivity/dbtools.hxx>
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
42 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
43 #include <com/sun/star/sdbc/XRowSet.hpp>
44 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
45 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
46 #include <com/sun/star/sdbc/XDataSource.hpp>
47 #include <com/sun/star/awt/FontWeight.hpp>
48 #include <com/sun/star/awt/FontStrikeout.hpp>
49 #include <com/sun/star/awt/FontSlant.hpp>
50 #include <com/sun/star/awt/FontUnderline.hpp>
51 #include <com/sun/star/document/XDocumentProperties.hpp>
52 #include <svtools/htmlkywd.hxx>
53 #include <svtools/rtfkeywd.hxx>
54 #include <tools/color.hxx>
55 #include <svtools/htmlout.hxx>
56 #include <sfx2/frmhtmlw.hxx>
57 #include <svl/numuno.hxx>
58 #include <vcl/svapp.hxx>
59 #include "UITools.hxx"
60 #include <toolkit/helper/vclunohelper.hxx>
61 #include <vcl/outdev.hxx>
62 #include <svtools/rtfout.hxx>
63 #include <svtools/htmlcfg.hxx>
64 #include <connectivity/formattedcolumnvalue.hxx>
65 #include <unotools/syslocale.hxx>
66 #include <rtl/logfile.hxx>
68 using namespace dbaui;
69 using namespace dbtools;
70 using namespace svx;
71 using namespace ::com::sun::star;
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::beans;
74 using namespace ::com::sun::star::container;
75 using namespace ::com::sun::star::sdbc;
76 using namespace ::com::sun::star::sdb;
77 using namespace ::com::sun::star::frame;
78 using namespace ::com::sun::star::lang;
79 using namespace ::com::sun::star::sdbcx;
80 using namespace ::com::sun::star::awt;
81 using namespace ::com::sun::star::util;
82 using ::com::sun::star::frame::XModel;
84 #if defined(UNX)
85 const char ODatabaseImportExport::sNewLine = '\012';
86 #else
87 const char ODatabaseImportExport::sNewLine[] = "\015\012";
88 #endif
90 const static char sMyBegComment[] = "<!-- ";
91 const static char sMyEndComment[] = " -->";
92 const static char sFontFamily[] = "font-family: ";
93 const static char sFontSize[] = "font-size: ";
95 #define SBA_FORMAT_SELECTION_COUNT 4
96 #define CELL_X 1437
98 DBG_NAME(ODatabaseImportExport)
99 //======================================================================
100 ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
101 const Reference< XMultiServiceFactory >& _rM,
102 const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
103 const String& rExchange)
104 :m_bBookmarkSelection( sal_False )
105 ,m_xFormatter(_rxNumberF)
106 ,m_xFactory(_rM)
107 ,m_nCommandType(CommandType::TABLE)
108 ,m_bNeedToReInitialize(sal_False)
109 ,m_pReader(NULL)
110 ,m_pRowMarker(NULL)
111 ,m_bInInitialize(sal_False)
112 ,m_bCheckOnly(sal_False)
114 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
115 DBG_CTOR(ODatabaseImportExport,NULL);
117 m_eDestEnc = osl_getThreadTextEncoding();
119 osl_incrementInterlockedCount( &m_refCount );
120 impl_initFromDescriptor( _aDataDescriptor, false );
122 xub_StrLen nCount = comphelper::string::getTokenCount(rExchange, char(11));
123 if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len())
125 m_pRowMarker = new sal_Int32[nCount-SBA_FORMAT_SELECTION_COUNT];
126 for(xub_StrLen i=SBA_FORMAT_SELECTION_COUNT;i<nCount;++i)
127 m_pRowMarker[i-SBA_FORMAT_SELECTION_COUNT] = rExchange.GetToken(i,char(11)).ToInt32();
129 osl_decrementInterlockedCount( &m_refCount );
131 // -----------------------------------------------------------------------------
132 // import data
133 ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
134 const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM )
135 :m_bBookmarkSelection( sal_False )
136 ,m_xConnection(_rxConnection)
137 ,m_xFormatter(_rxNumberF)
138 ,m_xFactory(_rM)
139 ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE)
140 ,m_bNeedToReInitialize(sal_False)
141 ,m_pReader(NULL)
142 ,m_pRowMarker(NULL)
143 ,m_bInInitialize(sal_False)
144 ,m_bCheckOnly(sal_False)
146 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
147 DBG_CTOR(ODatabaseImportExport,NULL);
148 m_eDestEnc = osl_getThreadTextEncoding();
151 SvtSysLocale aSysLocale;
152 m_aLocale = aSysLocale.GetLocaleData().getLocale();
154 catch(Exception&)
158 //-------------------------------------------------------------------
159 ODatabaseImportExport::~ODatabaseImportExport()
161 DBG_DTOR(ODatabaseImportExport,NULL);
162 acquire();
164 dispose();
166 if(m_pReader)
167 m_pReader->release();
168 delete m_pRowMarker;
170 // -----------------------------------------------------------------------------
171 void ODatabaseImportExport::dispose()
173 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
174 DBG_CHKTHIS(ODatabaseImportExport,NULL);
175 // remove me as listener
176 Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
177 if (xComponent.is())
179 Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
180 xComponent->removeEventListener(xEvt);
182 m_xConnection.clear();
184 ::comphelper::disposeComponent(m_xRow);
186 m_xObject.clear();
187 m_xResultSetMetaData.clear();
188 m_xResultSet.clear();
189 m_xRow.clear();
190 m_xRowLocate.clear();
191 m_xFormatter.clear();
193 // -----------------------------------------------------------------------------
194 void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
196 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
197 DBG_CHKTHIS(ODatabaseImportExport,NULL);
198 Reference<XConnection> xCon(Source.Source,UNO_QUERY);
199 if(m_xConnection.is() && m_xConnection == xCon)
201 m_xConnection.clear();
202 dispose();
203 m_bNeedToReInitialize = true;
206 // -----------------------------------------------------------------------------
207 void ODatabaseImportExport::initialize( const ODataAccessDescriptor& _aDataDescriptor )
209 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
210 impl_initFromDescriptor( _aDataDescriptor, true );
213 // -----------------------------------------------------------------------------
214 void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit)
216 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initFromDescriptor" );
217 DBG_CHKTHIS(ODatabaseImportExport,NULL);
218 if ( !_bPlusDefaultInit )
220 m_sDataSourceName = _aDataDescriptor.getDataSource();
221 _aDataDescriptor[daCommandType] >>= m_nCommandType;
222 _aDataDescriptor[daCommand] >>= m_sName;
223 // some additonal information
224 if(_aDataDescriptor.has(daConnection))
226 Reference< XConnection > xPureConn( _aDataDescriptor[daConnection], UNO_QUERY );
227 m_xConnection.reset( xPureConn, SharedConnection::NoTakeOwnership );
228 Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
229 Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
230 if (xComponent.is() && xEvt.is())
231 xComponent->addEventListener(xEvt);
234 if ( _aDataDescriptor.has( daSelection ) )
235 _aDataDescriptor[ daSelection ] >>= m_aSelection;
237 if ( _aDataDescriptor.has( daBookmarkSelection ) )
238 _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection;
240 if ( _aDataDescriptor.has( daCursor ) )
242 _aDataDescriptor[ daCursor ] >>= m_xResultSet;
243 m_xRowLocate.set( m_xResultSet, UNO_QUERY );
246 if ( m_aSelection.getLength() != 0 )
248 if ( !m_xResultSet.is() )
250 OSL_FAIL( "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" );
251 m_aSelection.realloc( 0 );
255 if ( m_aSelection.getLength() != 0 )
257 if ( m_bBookmarkSelection && !m_xRowLocate.is() )
259 OSL_FAIL( "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" );
260 m_aSelection.realloc( 0 );
264 else
265 initialize();
269 SvtSysLocale aSysLocale;
270 m_aLocale = aSysLocale.GetLocaleData().getLocale();
272 catch(Exception&)
276 // -----------------------------------------------------------------------------
277 void ODatabaseImportExport::initialize()
279 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
280 DBG_CHKTHIS(ODatabaseImportExport,NULL);
281 m_bInInitialize = sal_True;
282 m_bNeedToReInitialize = false;
284 if ( !m_xConnection.is() )
285 { // we need a connection
286 OSL_ENSURE(!m_sDataSourceName.isEmpty(),"There must be a datsource name!");
287 Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(m_xFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
288 Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
290 Reference< XConnection > xConnection;
291 SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xFactory, xEvt, xConnection );
292 m_xConnection.reset( xConnection );
294 if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION)
295 throw *static_cast<const SQLException*>(aInfo);
298 Reference<XNameAccess> xNameAccess;
299 switch(m_nCommandType)
301 case CommandType::TABLE:
303 // only for tables
304 Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY);
305 if(xSup.is())
306 xNameAccess = xSup->getTables();
308 break;
309 case CommandType::QUERY:
311 Reference<XQueriesSupplier> xSup(m_xConnection,UNO_QUERY);
312 if(xSup.is())
313 xNameAccess = xSup->getQueries();
315 break;
317 if(xNameAccess.is() && xNameAccess->hasByName(m_sName))
319 Reference<XPropertySet> xSourceObject;
320 xNameAccess->getByName(m_sName) >>= m_xObject;
323 if(m_xObject.is())
327 if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT))
328 m_xObject->getPropertyValue(PROPERTY_FONT) >>= m_aFont;
330 // the result set may be already set with the datadescriptor
331 if ( !m_xResultSet.is() )
333 m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RowSet")) ), UNO_QUERY );
334 Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW );
335 xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
336 xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) );
337 xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) );
338 Reference< XRowSet > xRowSet( xProp, UNO_QUERY );
339 xRowSet->execute();
341 impl_initializeRowMember_throw();
343 catch(Exception& )
345 m_xRow = NULL;
346 m_xResultSetMetaData = NULL;
347 ::comphelper::disposeComponent(m_xResultSet);
348 throw;
351 if ( m_aFont.Name.isEmpty() )
353 Font aApplicationFont = OutputDevice::GetDefaultFont(
354 DEFAULTFONT_SANS_UNICODE,
355 Application::GetSettings().GetUILanguage(),
356 DEFAULTFONT_FLAGS_ONLYONE
358 m_aFont = VCLUnoHelper::CreateFontDescriptor( aApplicationFont );
361 m_bInInitialize = sal_False;
363 // -----------------------------------------------------------------------------
364 sal_Bool ODatabaseImportExport::Write()
366 if ( m_bNeedToReInitialize )
368 if ( !m_bInInitialize )
369 initialize();
371 return sal_True;
373 // -----------------------------------------------------------------------------
374 sal_Bool ODatabaseImportExport::Read()
376 if ( m_bNeedToReInitialize )
378 if ( !m_bInInitialize )
379 initialize();
381 return sal_True;
383 // -----------------------------------------------------------------------------
384 void ODatabaseImportExport::impl_initializeRowMember_throw()
386 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" );
387 if ( !m_xRow.is() && m_xResultSet.is() )
389 m_xRow.set( m_xResultSet, UNO_QUERY );
390 m_xRowLocate.set( m_xResultSet, UNO_QUERY );
391 m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData();
392 Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW);
393 m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW);
396 //======================================================================
397 sal_Bool ORTFImportExport::Write()
399 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Write" );
400 ODatabaseImportExport::Write();
401 (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_RTF;
402 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ANSI << ODatabaseImportExport::sNewLine;
403 rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252;
405 sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
406 sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
407 sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
408 sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
410 sal_Int32 nColor = 0;
411 if(m_xObject.is())
412 m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
413 ::Color aColor(nColor);
415 rtl::OString aFonts(rtl::OUStringToOString(m_aFont.Name, eDestEnc));
416 if (aFonts.isEmpty())
418 rtl::OUString aName = Application::GetSettings().GetStyleSettings().GetAppFont().GetName();
419 aFonts = rtl::OUStringToOString(aName, eDestEnc);
422 (*m_pStream) << "{\\fonttbl";
423 xub_StrLen nTokenCount = comphelper::string::getTokenCount(aFonts, ';');
424 for(sal_uInt32 j=0;j<nTokenCount;++j)
426 (*m_pStream) << "\\f";
427 m_pStream->WriteNumber(static_cast<sal_Int32>(j));
428 (*m_pStream) << "\\fcharset0\\fnil ";
429 (*m_pStream) << comphelper::string::getToken(aFonts, j, ';').getStr();
430 (*m_pStream) << ';';
432 (*m_pStream) << '}' ;
433 (*m_pStream) << ODatabaseImportExport::sNewLine;
434 // write the rtf color table
435 (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL << OOO_STRING_SVTOOLS_RTF_RED;
436 m_pStream->WriteNumber(static_cast<sal_uInt32>(aColor.GetRed()));
437 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_GREEN;
438 m_pStream->WriteNumber(static_cast<sal_uInt32>(aColor.GetGreen()));
439 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_BLUE;
440 m_pStream->WriteNumber(static_cast<sal_uInt32>(aColor.GetBlue()));
442 (*m_pStream) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}"
443 << ODatabaseImportExport::sNewLine;
445 static char const aTRRH[] = "\\trrh-270\\pard\\intbl";
446 static char const aFS[] = "\\fs20\\f0\\cf0\\cb2";
447 static char const aCell1[] = "\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx";
449 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
450 m_pStream->WriteNumber(static_cast<sal_Int32>(40));
451 (*m_pStream) << ODatabaseImportExport::sNewLine;
453 if(m_xObject.is())
455 Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
456 Reference<XNameAccess> xColumns = xColSup->getColumns();
457 Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
458 const ::rtl::OUString* pIter = aNames.getConstArray();
460 sal_Int32 nCount = aNames.getLength();
461 sal_Bool bUseResultMetaData = sal_False;
462 if ( !nCount )
464 nCount = m_xResultSetMetaData->getColumnCount();
465 bUseResultMetaData = sal_True;
468 for( sal_Int32 i=1; i<=nCount; ++i )
470 (*m_pStream) << aCell1;
471 m_pStream->WriteNumber(i*CELL_X);
472 (*m_pStream) << ODatabaseImportExport::sNewLine;
475 // Spaltenbeschreibung
476 (*m_pStream) << '{' << ODatabaseImportExport::sNewLine;
477 (*m_pStream) << aTRRH;
480 ::rtl::OString* pHorzChar = new ::rtl::OString[nCount];
482 for ( sal_Int32 i=1; i <= nCount; ++i )
484 sal_Int32 nAlign = 0;
485 ::rtl::OUString sColumnName;
486 if ( bUseResultMetaData )
487 sColumnName = m_xResultSetMetaData->getColumnName(i);
488 else
490 sColumnName = *pIter;
491 Reference<XPropertySet> xColumn;
492 xColumns->getByName(sColumnName) >>= xColumn;
493 xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
494 ++pIter;
497 const char* pChar;
498 switch( nAlign )
500 case 1: pChar = OOO_STRING_SVTOOLS_RTF_QC; break;
501 case 2: pChar = OOO_STRING_SVTOOLS_RTF_QR; break;
502 case 0:
503 default:pChar = OOO_STRING_SVTOOLS_RTF_QL; break;
506 pHorzChar[i-1] = pChar; // um sp"ater nicht immer im ITEMSET zuw"uhlen
508 (*m_pStream) << ODatabaseImportExport::sNewLine;
509 (*m_pStream) << '{';
510 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_QC; // column header always centered
512 if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
513 if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
514 if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
515 if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
517 (*m_pStream) << aFS;
518 (*m_pStream) << ' ';
519 RTFOutFuncs::Out_String(*m_pStream,sColumnName,eDestEnc);
521 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
522 (*m_pStream) << '}';
523 (*m_pStream) << ODatabaseImportExport::sNewLine;
524 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
527 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW;
528 (*m_pStream) << ODatabaseImportExport::sNewLine << '}';
529 (*m_pStream) << ODatabaseImportExport::sNewLine;
531 ::comphelper::ComponentContext aContext(m_xFactory);
532 Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
533 sal_Int32 k=1;
534 sal_Int32 kk=0;
535 if ( m_aSelection.getLength() )
537 const Any* pSelIter = m_aSelection.getConstArray();
538 const Any* pEnd = pSelIter + m_aSelection.getLength();
540 sal_Bool bContinue = sal_True;
541 for( ; pSelIter != pEnd && bContinue; ++pSelIter )
543 if ( m_bBookmarkSelection )
545 bContinue = m_xRowLocate->moveToBookmark( *pSelIter );
547 else
549 sal_Int32 nPos = -1;
550 OSL_VERIFY( *pSelIter >>= nPos );
551 bContinue = ( m_xResultSet->absolute( nPos ) );
554 if ( bContinue )
555 appendRow( pHorzChar, nCount, k, kk );
558 else
560 m_xResultSet->beforeFirst(); // set back before the first row
561 while(m_xResultSet->next())
563 appendRow(pHorzChar,nCount,k,kk);
566 delete [] pHorzChar;
569 (*m_pStream) << '}' << ODatabaseImportExport::sNewLine;
570 (*m_pStream) << (sal_uInt8) 0;
571 return ((*m_pStream).GetError() == SVSTREAM_OK);
573 // -----------------------------------------------------------------------------
574 void ORTFImportExport::appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk)
576 if(!m_pRowMarker || m_pRowMarker[kk] == k)
578 ++kk;
579 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
580 m_pStream->WriteNumber(static_cast<sal_Int32>(40));
581 (*m_pStream) << ODatabaseImportExport::sNewLine;
583 static char const aCell2[] = "\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx";
584 static char const aTRRH[] = "\\trrh-270\\pard\\intbl";
586 for ( sal_Int32 i=1; i<=_nColumnCount; ++i )
588 (*m_pStream) << aCell2;
589 m_pStream->WriteNumber(i*CELL_X);
590 (*m_pStream) << ODatabaseImportExport::sNewLine;
593 const sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
594 const sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
595 const sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
596 const sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
597 ::comphelper::ComponentContext aContext(m_xFactory);
598 Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
600 (*m_pStream) << '{';
601 (*m_pStream) << aTRRH;
602 for ( sal_Int32 i=1; i <= _nColumnCount; ++i )
604 (*m_pStream) << ODatabaseImportExport::sNewLine;
605 (*m_pStream) << '{';
606 (*m_pStream) << pHorzChar[i-1].getStr();
608 if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
609 if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
610 if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
611 if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
613 (*m_pStream) << "\\fs20\\f1\\cf0\\cb1 ";
617 Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
618 dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
619 ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
620 if ( !sValue.isEmpty() )
621 RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
623 catch (Exception&)
625 OSL_FAIL("RTF WRITE!");
628 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
629 (*m_pStream) << '}';
630 (*m_pStream) << ODatabaseImportExport::sNewLine;
631 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
633 (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine;
634 (*m_pStream) << '}';
636 ++k;
638 //-------------------------------------------------------------------
639 sal_Bool ORTFImportExport::Read()
641 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Read" );
642 ODatabaseImportExport::Read();
643 SvParserState eState = SVPAR_ERROR;
644 if ( m_pStream )
646 m_pReader = new ORTFReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
647 ((ORTFReader*)m_pReader)->AddRef();
648 if ( isCheckEnabled() )
649 m_pReader->enableCheckOnly();
650 eState = ((ORTFReader*)m_pReader)->CallParser();
651 m_pReader->release();
652 m_pReader = NULL;
655 return eState != SVPAR_ERROR;
657 //-------------------------------------------------------------------
658 //===================================================================
659 const sal_Int16 OHTMLImportExport::nDefaultFontSize[SBA_HTML_FONTSIZES] =
661 HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT,
662 HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT
665 sal_Int16 OHTMLImportExport::nFontSize[SBA_HTML_FONTSIZES] = { 0 };
667 const sal_Int16 OHTMLImportExport::nCellSpacing = 0;
668 const char 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";
670 //========================================================================
671 // Macros for HTML-Export
672 //========================================================================
673 #define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine)
674 #define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag )
675 #define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, sal_False )
676 #define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str )
677 #define OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine << GetIndentStr()
678 #define lcl_OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine
679 #define TAG_ON_LF( tag ) (TAG_ON( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
680 #define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
681 #define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule )
682 #define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine << GetIndentStr())
683 #define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine)
685 //-------------------------------------------------------------------
686 OHTMLImportExport::OHTMLImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
687 const Reference< XMultiServiceFactory >& _rM,
688 const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
689 const String& rExchange)
690 : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange)
691 ,m_nIndent(0)
692 #if OSL_DEBUG_LEVEL > 0
693 ,m_bCheckFont(sal_False)
694 #endif
696 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::OHTMLImportExport" );
697 // set HTML configuration
698 SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
699 m_eDestEnc = rHtmlOptions.GetTextEncoding();
700 strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource)));
701 sIndent[0] = 0;
703 //-------------------------------------------------------------------
704 sal_Bool OHTMLImportExport::Write()
706 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Write" );
707 ODatabaseImportExport::Write();
708 if(m_xObject.is())
710 (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_doctype << ' ' << OOO_STRING_SVTOOLS_HTML_doctype32 << '>' << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine;
711 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
712 WriteHeader();
713 OUT_LF();
714 WriteBody();
715 OUT_LF();
716 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
718 return ((*m_pStream).GetError() == SVSTREAM_OK);
720 return sal_False;
722 //-------------------------------------------------------------------
723 sal_Bool OHTMLImportExport::Read()
725 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Read" );
726 ODatabaseImportExport::Read();
727 SvParserState eState = SVPAR_ERROR;
728 if ( m_pStream )
730 m_pReader = new OHTMLReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
731 ((OHTMLReader*)m_pReader)->AddRef();
732 if ( isCheckEnabled() )
733 m_pReader->enableCheckOnly();
734 m_pReader->SetTableName(m_sDefaultTableName);
735 eState = ((OHTMLReader*)m_pReader)->CallParser();
736 m_pReader->release();
737 m_pReader = NULL;
740 return eState != SVPAR_ERROR;
742 //-------------------------------------------------------------------
743 void OHTMLImportExport::WriteHeader()
745 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteHeader" );
746 uno::Reference<document::XDocumentProperties> xDocProps(
747 m_xFactory->createInstance(::rtl::OUString(
748 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.DocumentProperties"))),
749 uno::UNO_QUERY);
750 if (xDocProps.is()) {
751 xDocProps->setTitle(m_sName);
754 IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head );
756 SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), String(),
757 xDocProps, sIndent );
758 OUT_LF();
759 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head );
761 //-----------------------------------------------------------------------
762 void OHTMLImportExport::WriteBody()
764 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteBody" );
766 IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style );
768 (*m_pStream) << sMyBegComment; OUT_LF();
769 (*m_pStream) << OOO_STRING_SVTOOLS_HTML_body " { " << sFontFamily << '"' << ::rtl::OUStringToOString(m_aFont.Name, osl_getThreadTextEncoding()).getStr() << '\"';
770 // TODO : think about the encoding of the font name
771 (*m_pStream) << "; " << sFontSize;
772 m_pStream->WriteNumber(static_cast<sal_Int32>(m_aFont.Height));
773 (*m_pStream) << '}';
775 OUT_LF();
776 (*m_pStream) << sMyEndComment;
777 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style );
778 OUT_LF();
780 // default Textcolour black
781 (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_body << ' ' << OOO_STRING_SVTOOLS_HTML_O_text << '=';
782 sal_Int32 nColor = 0;
783 if(m_xObject.is())
784 m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
785 ::Color aColor(nColor);
786 HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
788 (*m_pStream) << " " OOO_STRING_SVTOOLS_HTML_O_bgcolor "=";
789 HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
791 (*m_pStream) << '>'; OUT_LF();
793 WriteTables();
795 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
797 //-----------------------------------------------------------------------
798 void OHTMLImportExport::WriteTables()
800 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteTables" );
801 ::rtl::OString aStrOut = OOO_STRING_SVTOOLS_HTML_table;
802 aStrOut = aStrOut + " ";
803 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_frame;
804 aStrOut = aStrOut + "=";
805 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_TF_void;
807 Sequence< ::rtl::OUString> aNames;
808 Reference<XNameAccess> xColumns;
809 sal_Bool bUseResultMetaData = sal_False;
810 if(m_xObject.is())
812 Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
813 xColumns = xColSup->getColumns();
814 aNames = xColumns->getElementNames();
815 if ( !aNames.getLength() )
817 sal_Int32 nCount = m_xResultSetMetaData->getColumnCount();
818 aNames.realloc(nCount);
819 for (sal_Int32 i= 0; i < nCount; ++i)
820 aNames[i] = m_xResultSetMetaData->getColumnName(i+1);
821 bUseResultMetaData = sal_True;
825 aStrOut = aStrOut + " ";
826 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_align;
827 aStrOut = aStrOut + "=";
828 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_AL_left;
829 aStrOut = aStrOut + " ";
830 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cellspacing;
831 aStrOut = aStrOut + "=";
832 aStrOut = aStrOut + ::rtl::OString::valueOf((sal_Int32)nCellSpacing);
833 aStrOut = aStrOut + " ";
834 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cols;
835 aStrOut = aStrOut + "=";
836 aStrOut = aStrOut + ::rtl::OString::valueOf(aNames.getLength());
837 aStrOut = aStrOut + " ";
838 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_border;
839 aStrOut = aStrOut + "=1";
841 IncIndent(1);
842 TAG_ON( aStrOut.getStr() );
844 FontOn();
846 TAG_ON( OOO_STRING_SVTOOLS_HTML_caption );
847 TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
849 (*m_pStream) << ::rtl::OUStringToOString(m_sName, osl_getThreadTextEncoding()).getStr();
850 // TODO : think about the encoding of the name
851 TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
852 TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption );
854 FontOff();
855 OUT_LF();
856 // </FONT>
858 IncIndent(1);
859 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead );
861 IncIndent(1);
862 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
864 if(m_xObject.is())
866 sal_Int32* pFormat = new sal_Int32[aNames.getLength()];
868 const char **pHorJustify = new const char*[aNames.getLength()];
869 sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()];
872 sal_Int32 nHeight = 0;
873 m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight;
875 // 1. die Spaltenbeschreibung rauspusten
876 const ::rtl::OUString* pIter = aNames.getConstArray();
877 const ::rtl::OUString* pEnd = pIter + aNames.getLength();
879 for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i )
881 sal_Int32 nAlign = 0;
882 pFormat[i] = 0;
883 pColWidth[i] = 100;
884 if ( !bUseResultMetaData )
886 Reference<XPropertySet> xColumn;
887 xColumns->getByName(*pIter) >>= xColumn;
888 xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
889 pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY));
890 pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH));
893 switch( nAlign )
895 case 1: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_center; break;
896 case 2: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_right; break;
897 default: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_left; break;
900 if(i == aNames.getLength()-1)
901 IncIndent(-1);
903 WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader);
906 IncIndent(-1);
907 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
908 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
910 IncIndent(1);
911 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
913 // 2. und jetzt die Daten
914 ::comphelper::ComponentContext aContext(m_xFactory);
915 Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
916 sal_Int32 j=1;
917 sal_Int32 kk=0;
918 m_xResultSet->beforeFirst(); // set back before the first row
919 while(m_xResultSet->next())
921 IncIndent(1);
922 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
924 if(!m_pRowMarker || m_pRowMarker[kk] == j)
926 ++kk;
927 for(sal_Int32 i=1;i<=aNames.getLength();++i)
929 if(i == aNames.getLength())
930 IncIndent(-1);
932 String aValue;
935 Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
936 dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
937 ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
938 if (!sValue.isEmpty())
940 aValue = sValue;
943 catch( const Exception& )
945 DBG_UNHANDLED_EXCEPTION();
947 WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,OOO_STRING_SVTOOLS_HTML_tabledata);
950 ++j;
951 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
954 delete [] pFormat;
955 delete [] pHorJustify;
956 delete [] pColWidth;
958 else
960 IncIndent(-1);
961 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
962 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
964 IncIndent(1);
965 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
968 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody );
969 IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
971 //-----------------------------------------------------------------------
972 void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,
973 const String& rValue,const char* pHtmlTag)
975 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteCell" );
976 ::rtl::OString aStrTD = pHtmlTag;
978 nWidthPixel = nWidthPixel ? nWidthPixel : 86;
979 nHeightPixel = nHeightPixel ? nHeightPixel : 17;
981 // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig,
982 // da die nicht von Netscape beachtet werden..
983 // Spaltenbreite
984 aStrTD = aStrTD + " ";
985 aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_width;
986 aStrTD = aStrTD + "=";
987 aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nWidthPixel);
988 // Zeilenhoehe
989 aStrTD = aStrTD + " ";
990 aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_height;
991 aStrTD = aStrTD + "=";
992 aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nHeightPixel);
994 aStrTD = aStrTD + " ";
995 aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_align;
996 aStrTD = aStrTD + "=";
997 aStrTD = aStrTD + pChar;
999 Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
1000 SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
1001 SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
1002 if(pFormatter)
1004 double fVal = 0.0;
1008 fVal = m_xFormatter->convertStringToNumber(nFormat,rValue);
1009 HTMLOutFuncs::CreateTableDataOptionsValNum(sal_False, fVal,nFormat, *pFormatter);
1011 catch(const Exception&)
1013 HTMLOutFuncs::CreateTableDataOptionsValNum(sal_False, fVal,nFormat, *pFormatter);
1017 TAG_ON( aStrTD.getStr() );
1019 FontOn();
1021 sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
1022 sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
1023 sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
1024 sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
1026 if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
1027 if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic );
1028 if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline );
1029 if ( bStrikeout ) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike );
1031 if ( !rValue.Len() )
1032 TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // keine komplett leere Zelle
1033 else
1034 HTMLOutFuncs::Out_String( (*m_pStream), rValue ,m_eDestEnc);
1037 if ( bStrikeout ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike );
1038 if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
1039 if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic );
1040 if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
1042 FontOff();
1044 TAG_OFF_LF( pHtmlTag );
1046 //-----------------------------------------------------------------------
1047 void OHTMLImportExport::FontOn()
1049 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOn" );
1050 #if OSL_DEBUG_LEVEL > 0
1051 m_bCheckFont = sal_True;
1052 #endif
1054 // <FONT FACE="xxx">
1055 ::rtl::OString aStrOut = "<";
1056 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_font;
1057 aStrOut = aStrOut + " ";
1058 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_face;
1059 aStrOut = aStrOut + "=";
1060 aStrOut = aStrOut + "\"";
1061 aStrOut = aStrOut + ::rtl::OUStringToOString(m_aFont.Name,osl_getThreadTextEncoding());
1062 // TODO : think about the encoding of the font name
1063 aStrOut = aStrOut + "\"";
1064 aStrOut = aStrOut + " ";
1065 aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_color;
1066 aStrOut = aStrOut + "=";
1067 (*m_pStream) << aStrOut.getStr();
1069 sal_Int32 nColor = 0;
1070 if(m_xObject.is())
1071 m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
1072 ::Color aColor(nColor);
1074 HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
1075 (*m_pStream) << ">";
1077 //-----------------------------------------------------------------------
1078 inline void OHTMLImportExport::FontOff()
1080 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOff" );
1081 OSL_ENSURE(m_bCheckFont,"Kein FontOn() gerufen");
1082 TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
1083 #if OSL_DEBUG_LEVEL > 0
1084 m_bCheckFont = sal_False;
1085 #endif
1087 //-----------------------------------------------------------------------
1088 void OHTMLImportExport::IncIndent( sal_Int16 nVal )
1090 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::IncIndent" );
1091 sIndent[m_nIndent] = '\t';
1092 m_nIndent = m_nIndent + nVal;
1093 if ( m_nIndent < 0 )
1094 m_nIndent = 0;
1095 else if ( m_nIndent > nIndentMax )
1096 m_nIndent = nIndentMax;
1097 sIndent[m_nIndent] = 0;
1099 // -----------------------------------------------------------------------------
1101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */