1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TokenWriter.cxx,v $
10 * $Revision: 1.36.14.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #include "TokenWriter.hxx"
34 #include <tools/debug.hxx>
35 #include <tools/diagnose_ex.h>
36 #include "RtfReader.hxx"
37 #include "HtmlReader.hxx"
38 #include "dbustrings.hrc"
39 #include <connectivity/dbtools.hxx>
40 #include <comphelper/types.hxx>
41 #include <com/sun/star/sdbc/XConnection.hpp>
42 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
43 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
44 #include <com/sun/star/sdbc/XRowSet.hpp>
45 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
46 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
47 #include <com/sun/star/sdbc/XDataSource.hpp>
48 #include <com/sun/star/awt/FontWeight.hpp>
49 #include <com/sun/star/awt/FontStrikeout.hpp>
50 #include <com/sun/star/awt/FontSlant.hpp>
51 #include <com/sun/star/awt/FontUnderline.hpp>
52 #include <com/sun/star/document/XDocumentProperties.hpp>
53 #include <svtools/htmlkywd.hxx>
54 #include <svtools/rtfkeywd.hxx>
55 #include <tools/color.hxx>
56 #include <svtools/htmlout.hxx>
57 #include <sfx2/frmhtmlw.hxx>
58 #include <svtools/numuno.hxx>
59 #include <vcl/svapp.hxx>
60 #include "UITools.hxx"
61 #include <toolkit/helper/vclunohelper.hxx>
62 #include <vcl/outdev.hxx>
63 #include <svtools/rtfout.hxx>
64 #include <svx/htmlcfg.hxx>
65 #include <connectivity/formattedcolumnvalue.hxx>
66 #include <svtools/syslocale.hxx>
67 #include <comphelper/componentcontext.hxx>
68 #include <rtl/logfile.hxx>
70 using namespace dbaui
;
71 using namespace dbtools
;
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::uno
;
75 using namespace ::com::sun::star::beans
;
76 using namespace ::com::sun::star::container
;
77 using namespace ::com::sun::star::sdbc
;
78 using namespace ::com::sun::star::sdb
;
79 using namespace ::com::sun::star::frame
;
80 using namespace ::com::sun::star::lang
;
81 using namespace ::com::sun::star::sdbcx
;
82 using namespace ::com::sun::star::awt
;
83 using namespace ::com::sun::star::util
;
84 using ::com::sun::star::frame::XModel
;
87 const char __FAR_DATA
ODatabaseImportExport::sNewLine
= '\012';
89 const char __FAR_DATA
ODatabaseImportExport::sNewLine
[] = "\015\012";
92 const static char __FAR_DATA sMyBegComment
[] = "<!-- ";
93 const static char __FAR_DATA sMyEndComment
[] = " -->";
94 const static char __FAR_DATA sFontFamily
[] = "font-family: ";
95 const static char __FAR_DATA sFontSize
[] = "font-size: ";
97 #define SBA_FORMAT_SELECTION_COUNT 4
100 DBG_NAME(ODatabaseImportExport
)
101 //======================================================================
102 ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor
& _aDataDescriptor
,
103 const Reference
< XMultiServiceFactory
>& _rM
,
104 const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxNumberF
,
105 const String
& rExchange
)
106 :m_xFormatter(_rxNumberF
)
108 ,m_nCommandType(CommandType::TABLE
)
109 ,m_bNeedToReInitialize(sal_False
)
112 ,m_bInInitialize(sal_False
)
113 ,m_bCheckOnly(sal_False
)
115 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
116 DBG_CTOR(ODatabaseImportExport
,NULL
);
118 m_eDestEnc
= osl_getThreadTextEncoding();
120 osl_incrementInterlockedCount( &m_refCount
);
121 impl_initFromDescriptor( _aDataDescriptor
, false );
123 xub_StrLen nCount
= rExchange
.GetTokenCount(char(11));
124 if( nCount
> SBA_FORMAT_SELECTION_COUNT
&& rExchange
.GetToken(4).Len())
126 m_pRowMarker
= new sal_Int32
[nCount
-SBA_FORMAT_SELECTION_COUNT
];
127 for(xub_StrLen i
=SBA_FORMAT_SELECTION_COUNT
;i
<nCount
;++i
)
128 m_pRowMarker
[i
-SBA_FORMAT_SELECTION_COUNT
] = rExchange
.GetToken(i
,char(11)).ToInt32();
130 osl_decrementInterlockedCount( &m_refCount
);
132 // -----------------------------------------------------------------------------
134 ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection
& _rxConnection
,
135 const Reference
< XNumberFormatter
>& _rxNumberF
, const Reference
< XMultiServiceFactory
>& _rM
)
136 :m_xConnection(_rxConnection
)
137 ,m_xFormatter(_rxNumberF
)
139 ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE
)
140 ,m_bNeedToReInitialize(sal_False
)
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();
158 //-------------------------------------------------------------------
159 ODatabaseImportExport::~ODatabaseImportExport()
161 DBG_DTOR(ODatabaseImportExport
,NULL
);
167 m_pReader
->release();
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
);
179 Reference
< XEventListener
> xEvt((::cppu::OWeakObject
*)this,UNO_QUERY
);
180 xComponent
->removeEventListener(xEvt
);
182 m_xConnection
.clear();
184 ::comphelper::disposeComponent(m_xRow
);
187 m_xResultSetMetaData
.clear();
188 m_xResultSet
.clear();
190 m_xFormatter
.clear();
192 // -----------------------------------------------------------------------------
193 void SAL_CALL
ODatabaseImportExport::disposing( const EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
)
195 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
196 DBG_CHKTHIS(ODatabaseImportExport
,NULL
);
197 Reference
<XConnection
> xCon(Source
.Source
,UNO_QUERY
);
198 if(m_xConnection
.is() && m_xConnection
== xCon
)
200 m_xConnection
.clear();
202 m_bNeedToReInitialize
= true;
203 //if(!m_bInInitialize)
207 // -----------------------------------------------------------------------------
208 void ODatabaseImportExport::initialize( const ODataAccessDescriptor
& _aDataDescriptor
)
210 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
211 impl_initFromDescriptor( _aDataDescriptor
, true );
214 // -----------------------------------------------------------------------------
215 void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor
& _aDataDescriptor
, bool _bPlusDefaultInit
)
217 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initFromDescriptor" );
218 DBG_CHKTHIS(ODatabaseImportExport
,NULL
);
219 if ( !_bPlusDefaultInit
)
221 m_sDataSourceName
= _aDataDescriptor
.getDataSource();
222 _aDataDescriptor
[daCommandType
] >>= m_nCommandType
;
223 _aDataDescriptor
[daCommand
] >>= m_sName
;
224 // some additonal information
225 if(_aDataDescriptor
.has(daConnection
))
227 Reference
< XConnection
> xPureConn( _aDataDescriptor
[daConnection
], UNO_QUERY
);
228 m_xConnection
.reset( xPureConn
, SharedConnection::NoTakeOwnership
);
229 Reference
< XEventListener
> xEvt((::cppu::OWeakObject
*)this,UNO_QUERY
);
230 Reference
< XComponent
> xComponent(m_xConnection
, UNO_QUERY
);
231 if (xComponent
.is() && xEvt
.is())
232 xComponent
->addEventListener(xEvt
);
234 if(_aDataDescriptor
.has(daSelection
))
235 _aDataDescriptor
[daSelection
] >>= m_aSelection
;
237 sal_Bool bBookmarkSelection
= sal_True
; // the default if not present
238 if ( _aDataDescriptor
.has( daBookmarkSelection
) )
240 _aDataDescriptor
[ daBookmarkSelection
] >>= bBookmarkSelection
;
241 DBG_ASSERT( !bBookmarkSelection
, "ODatabaseImportExport::ODatabaseImportExport: bookmarked selection not yet supported!" );
245 if(_aDataDescriptor
.has(daCursor
))
246 _aDataDescriptor
[daCursor
] >>= m_xResultSet
;
247 } // if ( !_bPlusDefaultInit )
253 SvtSysLocale aSysLocale
;
254 m_aLocale
= aSysLocale
.GetLocaleData().getLocale();
260 // -----------------------------------------------------------------------------
261 void ODatabaseImportExport::initialize()
263 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
264 DBG_CHKTHIS(ODatabaseImportExport
,NULL
);
265 m_bInInitialize
= sal_True
;
266 m_bNeedToReInitialize
= false;
268 if ( !m_xConnection
.is() )
269 { // we need a connection
270 OSL_ENSURE(m_sDataSourceName
.getLength(),"There must be a datsource name!");
271 Reference
<XNameAccess
> xDatabaseContext
= Reference
< XNameAccess
>(m_xFactory
->createInstance(SERVICE_SDB_DATABASECONTEXT
), UNO_QUERY
);
272 Reference
< XEventListener
> xEvt((::cppu::OWeakObject
*)this,UNO_QUERY
);
274 Reference
< XConnection
> xConnection
;
275 SQLExceptionInfo aInfo
= ::dbaui::createConnection( m_sDataSourceName
, xDatabaseContext
, m_xFactory
, xEvt
, xConnection
);
276 m_xConnection
.reset( xConnection
);
278 if(aInfo
.isValid() && aInfo
.getType() == SQLExceptionInfo::SQL_EXCEPTION
)
279 throw *static_cast<const SQLException
*>(aInfo
);
282 Reference
<XNameAccess
> xNameAccess
;
283 switch(m_nCommandType
)
285 case CommandType::TABLE
:
288 Reference
<XTablesSupplier
> xSup(m_xConnection
,UNO_QUERY
);
290 xNameAccess
= xSup
->getTables();
293 case CommandType::QUERY
:
295 Reference
<XQueriesSupplier
> xSup(m_xConnection
,UNO_QUERY
);
297 xNameAccess
= xSup
->getQueries();
301 if(xNameAccess
.is() && xNameAccess
->hasByName(m_sName
))
303 Reference
<XPropertySet
> xSourceObject
;
304 xNameAccess
->getByName(m_sName
) >>= m_xObject
;
311 if(m_xObject
->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT
))
312 m_xObject
->getPropertyValue(PROPERTY_FONT
) >>= m_aFont
;
314 // the result set may be already set with the datadescriptor
315 if ( !m_xResultSet
.is() )
317 m_xResultSet
.set(m_xFactory
->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.RowSet")),UNO_QUERY
);
318 Reference
<XPropertySet
> xProp(m_xResultSet
,UNO_QUERY
);
321 xProp
->setPropertyValue( PROPERTY_ACTIVE_CONNECTION
, makeAny( m_xConnection
.getTyped() ) );
322 xProp
->setPropertyValue(PROPERTY_COMMAND_TYPE
,makeAny(m_nCommandType
));
323 xProp
->setPropertyValue(PROPERTY_COMMAND
,makeAny(m_sName
));
324 Reference
<XRowSet
> xRowSet(xProp
,UNO_QUERY
);
328 OSL_ENSURE(sal_False
, "ODatabaseImportExport::initialize: could not instantiate a rowset!");
329 } // if ( !m_xResultSet.is() )
330 impl_initializeRowMember_throw();
335 m_xResultSetMetaData
= NULL
;
336 ::comphelper::disposeComponent(m_xResultSet
);
340 if ( !m_aFont
.Name
.getLength() )
342 Font aApplicationFont
= OutputDevice::GetDefaultFont(
343 DEFAULTFONT_SANS_UNICODE
,
344 Application::GetSettings().GetUILanguage(),
345 DEFAULTFONT_FLAGS_ONLYONE
347 m_aFont
= VCLUnoHelper::CreateFontDescriptor( aApplicationFont
);
350 m_bInInitialize
= sal_False
;
352 // -----------------------------------------------------------------------------
353 BOOL
ODatabaseImportExport::Write()
355 if ( m_bNeedToReInitialize
)
357 if ( !m_bInInitialize
)
359 } // if ( m_bNeedToReInitialize )
362 // -----------------------------------------------------------------------------
363 BOOL
ODatabaseImportExport::Read()
365 if ( m_bNeedToReInitialize
)
367 if ( !m_bInInitialize
)
369 } // if ( m_bNeedToReInitialize )
372 // -----------------------------------------------------------------------------
373 void ODatabaseImportExport::impl_initializeRowMember_throw()
375 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" );
376 if ( !m_xRow
.is() && m_xResultSet
.is() )
378 m_xRow
.set(m_xResultSet
,UNO_QUERY
);
379 m_xResultSetMetaData
= Reference
<XResultSetMetaDataSupplier
>(m_xRow
,UNO_QUERY
)->getMetaData();
380 Reference
<XColumnsSupplier
> xSup(m_xResultSet
,UNO_QUERY_THROW
);
381 m_xRowSetColumns
.set(xSup
->getColumns(),UNO_QUERY_THROW
);
384 //======================================================================
385 BOOL
ORTFImportExport::Write()
387 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Write" );
388 ODatabaseImportExport::Write();
389 (*m_pStream
) << '{' << OOO_STRING_SVTOOLS_RTF_RTF
;
390 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_ANSI
<< ODatabaseImportExport::sNewLine
;
391 rtl_TextEncoding eDestEnc
= RTL_TEXTENCODING_MS_1252
;
394 // Access RTF Export Beispiel
396 {\colortbl\red0\green0\blue0;\red255\green255\blue255;\red192\green192\blue192;}
397 {\fonttbl\f0\fcharset0\fnil MS Sans Serif;\f1\fcharset0\fnil Arial;\f2\fcharset0\fnil Arial;}
399 \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx1437
400 \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx2874
403 {\qc\fs20\b\f1\cf0\cb2 text\cell}
405 {\qc\fs20\b\f1\cf0\cb2 datum\cell}
408 \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
409 {\trrh-270\pard\intbl
410 {\ql\fs20\f2\cf0\cb1 heute\cell}
412 {\qr\fs20\f2\cf0\cb1 10.11.98\cell}
415 \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
416 {\trrh-270\pard\intbl
417 {\ql\fs20\f2\cf0\cb1 morgen\cell}
419 {\qr\fs20\f2\cf0\cb1 11.11.98\cell}
422 \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
423 {\trrh-270\pard\intbl
424 {\ql\fs20\f2\cf0\cb1 bruder\cell}
426 {\qr\fs20\f2\cf0\cb1 21.04.98\cell}
430 \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx
431 \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
432 {\trrh-270\pard\intbl
433 {\ql\fs20\f2\cf0\cb1 vater\cell}
435 {\qr\fs20\f2\cf0\cb1 28.06.98\cell}
441 BOOL bBold
= ( ::com::sun::star::awt::FontWeight::BOLD
== m_aFont
.Weight
);
442 BOOL bItalic
= ( ::com::sun::star::awt::FontSlant_ITALIC
== m_aFont
.Slant
);
443 BOOL bUnderline
= ( ::com::sun::star::awt::FontUnderline::NONE
!= m_aFont
.Underline
);
444 BOOL bStrikeout
= ( ::com::sun::star::awt::FontStrikeout::NONE
!= m_aFont
.Strikeout
);
446 sal_Int32 nColor
= 0;
448 m_xObject
->getPropertyValue(PROPERTY_TEXTCOLOR
) >>= nColor
;
449 ::Color
aColor(nColor
);
451 ByteString
aFonts(String(m_aFont
.Name
),eDestEnc
);
454 String aName
= Application::GetSettings().GetStyleSettings().GetAppFont().GetName();
455 aFonts
= ByteString (aName
,eDestEnc
);
457 ::rtl::OString
aFormat("\\fcharset0\\fnil ");
460 (*m_pStream
) << "{\\fonttbl";
461 xub_StrLen nTokenCount
= aFonts
.GetTokenCount();
462 for(xub_StrLen j
=0;j
<nTokenCount
;++j
)
464 (*m_pStream
) << "\\f";
465 m_pStream
->WriteNumber(j
);
466 (*m_pStream
) << aFormat
;
467 (*m_pStream
) << aFonts
.GetToken(j
).GetBuffer();
470 (*m_pStream
) << '}' ;
471 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
472 // write the rtf color table
473 (*m_pStream
) << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL
<< OOO_STRING_SVTOOLS_RTF_RED
;
474 m_pStream
->WriteNumber(aColor
.GetRed());
475 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_GREEN
;
476 m_pStream
->WriteNumber(aColor
.GetGreen());
477 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_BLUE
;
478 m_pStream
->WriteNumber(aColor
.GetBlue());
480 (*m_pStream
) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}"
481 << ODatabaseImportExport::sNewLine
;
483 ::rtl::OString
aTRRH("\\trrh-270\\pard\\intbl");
484 ::rtl::OString
aFS("\\fs20\\f0\\cf0\\cb2");
485 ::rtl::OString
aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx");
487 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_TROWD
<< OOO_STRING_SVTOOLS_RTF_TRGAPH
;
488 m_pStream
->WriteNumber(40);
489 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
493 Reference
<XColumnsSupplier
> xColSup(m_xObject
,UNO_QUERY
);
494 Reference
<XNameAccess
> xColumns
= xColSup
->getColumns();
495 Sequence
< ::rtl::OUString
> aNames(xColumns
->getElementNames());
496 const ::rtl::OUString
* pIter
= aNames
.getConstArray();
498 sal_Int32 nCount
= aNames
.getLength();
499 sal_Bool bUseResultMetaData
= sal_False
;
502 nCount
= m_xResultSetMetaData
->getColumnCount();
503 bUseResultMetaData
= sal_True
;
506 for( sal_Int32 i
=1; i
<=nCount
; ++i
)
508 (*m_pStream
) << aCell1
;
509 m_pStream
->WriteNumber(i
*CELL_X
);
510 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
513 // Spaltenbeschreibung
514 (*m_pStream
) << '{' << ODatabaseImportExport::sNewLine
;
515 (*m_pStream
) << aTRRH
;
518 ::rtl::OString
* pHorzChar
= new ::rtl::OString
[nCount
];
520 for ( sal_Int32 i
=1; i
<= nCount
; ++i
)
522 sal_Int32 nAlign
= 0;
523 ::rtl::OUString sColumnName
;
524 if ( bUseResultMetaData
)
525 sColumnName
= m_xResultSetMetaData
->getColumnName(i
);
528 sColumnName
= *pIter
;
529 Reference
<XPropertySet
> xColumn
;
530 xColumns
->getByName(sColumnName
) >>= xColumn
;
531 xColumn
->getPropertyValue(PROPERTY_ALIGN
) >>= nAlign
;
538 case 1: pChar
= OOO_STRING_SVTOOLS_RTF_QC
; break;
539 case 2: pChar
= OOO_STRING_SVTOOLS_RTF_QR
; break;
541 default:pChar
= OOO_STRING_SVTOOLS_RTF_QL
; break;
544 pHorzChar
[i
-1] = pChar
; // um sp"ater nicht immer im ITEMSET zuw"uhlen
546 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
548 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_QC
; // column header always centered
550 if ( bBold
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_B
;
551 if ( bItalic
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_I
;
552 if ( bUnderline
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_UL
;
553 if ( bStrikeout
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_STRIKE
;
557 RTFOutFuncs::Out_String(*m_pStream
,sColumnName
,eDestEnc
);
559 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_CELL
;
561 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
562 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_PARD
<< OOO_STRING_SVTOOLS_RTF_INTBL
;
565 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_ROW
;
566 (*m_pStream
) << ODatabaseImportExport::sNewLine
<< '}';
567 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
569 ::comphelper::ComponentContext
aContext(m_xFactory
);
570 Reference
< XRowSet
> xRowSet(m_xRow
,UNO_QUERY
);
573 if(m_aSelection
.getLength())
575 const Any
* pSelIter
= m_aSelection
.getConstArray();
576 const Any
* pEnd
= pSelIter
+ m_aSelection
.getLength();
577 sal_Bool bContinue
= sal_True
;
578 for(;pSelIter
!= pEnd
&& bContinue
;++pSelIter
)
582 OSL_ENSURE(nPos
!= -1,"Invalid posiotion!");
583 bContinue
= (m_xResultSet
->absolute(nPos
));
585 appendRow(pHorzChar
,nCount
,k
,kk
);
588 } // if(m_aSelection.getLength())
591 m_xResultSet
->beforeFirst(); // set back before the first row
592 while(m_xResultSet
->next())
594 appendRow(pHorzChar
,nCount
,k
,kk
);
600 (*m_pStream
) << '}' << ODatabaseImportExport::sNewLine
;
601 (*m_pStream
) << (BYTE
) 0;
602 return ((*m_pStream
).GetError() == SVSTREAM_OK
);
604 // -----------------------------------------------------------------------------
605 void ORTFImportExport::appendRow(::rtl::OString
* pHorzChar
,sal_Int32 _nColumnCount
,sal_Int32
& k
,sal_Int32
& kk
)
607 if(!m_pRowMarker
|| m_pRowMarker
[kk
] == k
)
610 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_TROWD
<< OOO_STRING_SVTOOLS_RTF_TRGAPH
;
611 m_pStream
->WriteNumber(40);
612 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
614 static const ::rtl::OString
aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx");
615 static const ::rtl::OString
aTRRH("\\trrh-270\\pard\\intbl");
617 for ( sal_Int32 i
=1; i
<=_nColumnCount
; ++i
)
619 (*m_pStream
) << aCell2
;
620 m_pStream
->WriteNumber(i
*CELL_X
);
621 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
624 const BOOL bBold
= ( ::com::sun::star::awt::FontWeight::BOLD
== m_aFont
.Weight
);
625 const BOOL bItalic
= ( ::com::sun::star::awt::FontSlant_ITALIC
== m_aFont
.Slant
);
626 const BOOL bUnderline
= ( ::com::sun::star::awt::FontUnderline::NONE
!= m_aFont
.Underline
);
627 const BOOL bStrikeout
= ( ::com::sun::star::awt::FontStrikeout::NONE
!= m_aFont
.Strikeout
);
628 static const ::rtl::OString
aFS2("\\fs20\\f1\\cf0\\cb1");
629 ::comphelper::ComponentContext
aContext(m_xFactory
);
630 Reference
< XRowSet
> xRowSet(m_xRow
,UNO_QUERY
);
633 (*m_pStream
) << aTRRH
;
634 for ( sal_Int32 i
=1; i
<= _nColumnCount
; ++i
)
636 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
638 (*m_pStream
) << pHorzChar
[i
-1];
640 if ( bBold
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_B
;
641 if ( bItalic
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_I
;
642 if ( bUnderline
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_UL
;
643 if ( bStrikeout
) (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_STRIKE
;
645 (*m_pStream
) << aFS2
;
650 Reference
<XPropertySet
> xColumn(m_xRowSetColumns
->getByIndex(i
-1),UNO_QUERY_THROW
);
651 dbtools::FormattedColumnValue
aFormatedValue(aContext
,xRowSet
,xColumn
);
652 ::rtl::OUString sValue
= aFormatedValue
.getFormattedValue();
653 // m_xRow->getString(i);
654 //if (!m_xRow->wasNull())
655 if ( sValue
.getLength() )
656 RTFOutFuncs::Out_String(*m_pStream
,sValue
,m_eDestEnc
);
660 OSL_ENSURE(0,"RTF WRITE!");
663 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_CELL
;
665 (*m_pStream
) << ODatabaseImportExport::sNewLine
;
666 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_PARD
<< OOO_STRING_SVTOOLS_RTF_INTBL
;
668 (*m_pStream
) << OOO_STRING_SVTOOLS_RTF_ROW
<< ODatabaseImportExport::sNewLine
;
673 //-------------------------------------------------------------------
674 BOOL
ORTFImportExport::Read()
676 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Read" );
677 ODatabaseImportExport::Read();
678 SvParserState eState
= SVPAR_ERROR
;
681 m_pReader
= new ORTFReader((*m_pStream
),m_xConnection
,m_xFormatter
,m_xFactory
);
682 ((ORTFReader
*)m_pReader
)->AddRef();
683 if ( isCheckEnabled() )
684 m_pReader
->enableCheckOnly();
685 eState
= ((ORTFReader
*)m_pReader
)->CallParser();
686 m_pReader
->release();
690 return eState
!= SVPAR_ERROR
;
692 //-------------------------------------------------------------------
693 //===================================================================
694 const sal_Int16 __FAR_DATA
OHTMLImportExport::nDefaultFontSize
[SBA_HTML_FONTSIZES
] =
696 HTMLFONTSZ1_DFLT
, HTMLFONTSZ2_DFLT
, HTMLFONTSZ3_DFLT
, HTMLFONTSZ4_DFLT
,
697 HTMLFONTSZ5_DFLT
, HTMLFONTSZ6_DFLT
, HTMLFONTSZ7_DFLT
700 sal_Int16
OHTMLImportExport::nFontSize
[SBA_HTML_FONTSIZES
] = { 0 };
702 const sal_Int16
OHTMLImportExport::nCellSpacing
= 0;
703 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";
705 //========================================================================
706 // Makros fuer HTML-Export
707 //========================================================================
708 #define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine)
709 #define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag )
710 #define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, FALSE )
711 #define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str )
712 #define OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine << GetIndentStr()
713 #define lcl_OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine
714 #define TAG_ON_LF( tag ) (TAG_ON( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
715 #define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
716 #define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule )
717 #define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine << GetIndentStr())
718 #define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine)
720 //-------------------------------------------------------------------
721 OHTMLImportExport::OHTMLImportExport(const ::svx::ODataAccessDescriptor
& _aDataDescriptor
,
722 const Reference
< XMultiServiceFactory
>& _rM
,
723 const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxNumberF
,
724 const String
& rExchange
)
725 : ODatabaseImportExport(_aDataDescriptor
,_rM
,_rxNumberF
,rExchange
)
731 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::OHTMLImportExport" );
732 // set HTML configuration
733 SvxHtmlOptions
* pHtmlOptions
= SvxHtmlOptions::Get();
734 m_eDestEnc
= pHtmlOptions
->GetTextEncoding();
735 strncpy( sIndent
, sIndentSource
,std::min(sizeof(sIndent
),sizeof(sIndentSource
)));
738 //-------------------------------------------------------------------
739 BOOL
OHTMLImportExport::Write()
741 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Write" );
742 ODatabaseImportExport::Write();
745 (*m_pStream
) << '<' << OOO_STRING_SVTOOLS_HTML_doctype
<< ' ' << OOO_STRING_SVTOOLS_HTML_doctype32
<< '>' << ODatabaseImportExport::sNewLine
<< ODatabaseImportExport::sNewLine
;
746 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html
);
751 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html
);
753 return ((*m_pStream
).GetError() == SVSTREAM_OK
);
757 //-------------------------------------------------------------------
758 BOOL
OHTMLImportExport::Read()
760 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Read" );
761 ODatabaseImportExport::Read();
762 SvParserState eState
= SVPAR_ERROR
;
765 m_pReader
= new OHTMLReader((*m_pStream
),m_xConnection
,m_xFormatter
,m_xFactory
);
766 ((OHTMLReader
*)m_pReader
)->AddRef();
767 if ( isCheckEnabled() )
768 m_pReader
->enableCheckOnly();
770 m_pReader
->SetTableName(m_sDefaultTableName
);
772 eState
= ((OHTMLReader
*)m_pReader
)->CallParser();
773 m_pReader
->release();
777 return eState
!= SVPAR_ERROR
;
779 //-------------------------------------------------------------------
780 void OHTMLImportExport::WriteHeader()
782 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteHeader" );
783 uno::Reference
<document::XDocumentProperties
> xDocProps(
784 m_xFactory
->createInstance(::rtl::OUString::createFromAscii(
785 "com.sun.star.document.DocumentProperties")),
787 if (xDocProps
.is()) {
788 xDocProps
->setTitle(m_sName
);
791 IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head
);
793 SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream
), String(),
794 xDocProps
, sIndent
);
796 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head
);
798 //-----------------------------------------------------------------------
799 void OHTMLImportExport::WriteBody()
801 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteBody" );
803 IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style
);
805 (*m_pStream
) << sMyBegComment
; OUT_LF();
806 (*m_pStream
) << OOO_STRING_SVTOOLS_HTML_body
<< " { " << sFontFamily
<< '\"' << ::rtl::OString(m_aFont
.Name
,m_aFont
.Name
.getLength(), gsl_getSystemTextEncoding()) << '\"';
807 // TODO : think about the encoding of the font name
808 (*m_pStream
) << "; " << sFontSize
;
809 m_pStream
->WriteNumber(m_aFont
.Height
);
813 (*m_pStream
) << sMyEndComment
;
814 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style
);
817 // default Textfarbe schwarz
818 (*m_pStream
) << '<' << OOO_STRING_SVTOOLS_HTML_body
<< ' ' << OOO_STRING_SVTOOLS_HTML_O_text
<< '=';
819 sal_Int32 nColor
= 0;
821 m_xObject
->getPropertyValue(PROPERTY_TEXTCOLOR
) >>= nColor
;
822 ::Color
aColor(nColor
);
823 HTMLOutFuncs::Out_Color( (*m_pStream
), aColor
);
825 ::rtl::OString
sOut( ' ' );
826 sOut
= sOut
+ OOO_STRING_SVTOOLS_HTML_O_bgcolor
;
828 (*m_pStream
) << sOut
;
829 HTMLOutFuncs::Out_Color( (*m_pStream
), aColor
);
831 (*m_pStream
) << '>'; OUT_LF();
835 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body
);
837 //-----------------------------------------------------------------------
838 void OHTMLImportExport::WriteTables()
840 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteTables" );
841 ::rtl::OString aStrOut
= OOO_STRING_SVTOOLS_HTML_table
;
842 aStrOut
= aStrOut
+ " ";
843 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_frame
;
844 aStrOut
= aStrOut
+ "=";
845 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_TF_void
;
847 Sequence
< ::rtl::OUString
> aNames
;
848 Reference
<XNameAccess
> xColumns
;
849 sal_Bool bUseResultMetaData
= sal_False
;
852 Reference
<XColumnsSupplier
> xColSup(m_xObject
,UNO_QUERY
);
853 xColumns
= xColSup
->getColumns();
854 aNames
= xColumns
->getElementNames();
855 if ( !aNames
.getLength() )
857 sal_Int32 nCount
= m_xResultSetMetaData
->getColumnCount();
858 aNames
.realloc(nCount
);
859 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
860 aNames
[i
] = m_xResultSetMetaData
->getColumnName(i
+1);
861 bUseResultMetaData
= sal_True
;
865 aStrOut
= aStrOut
+ " ";
866 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_align
;
867 aStrOut
= aStrOut
+ "=";
868 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_AL_left
;
869 aStrOut
= aStrOut
+ " ";
870 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_cellspacing
;
871 aStrOut
= aStrOut
+ "=";
872 aStrOut
= aStrOut
+ ::rtl::OString::valueOf((sal_Int32
)nCellSpacing
);
873 aStrOut
= aStrOut
+ " ";
874 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_cols
;
875 aStrOut
= aStrOut
+ "=";
876 aStrOut
= aStrOut
+ ::rtl::OString::valueOf(aNames
.getLength());
877 aStrOut
= aStrOut
+ " ";
878 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_border
;
879 aStrOut
= aStrOut
+ "=1";
886 TAG_ON( OOO_STRING_SVTOOLS_HTML_caption
);
887 TAG_ON( OOO_STRING_SVTOOLS_HTML_bold
);
889 (*m_pStream
) << ::rtl::OString(m_sName
,m_sName
.getLength(), gsl_getSystemTextEncoding());
890 // TODO : think about the encoding of the name
891 TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold
);
892 TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption
);
899 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead
);
902 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow
);
906 sal_Int32
* pFormat
= new sal_Int32
[aNames
.getLength()];
908 const char **pHorJustify
= new const char*[aNames
.getLength()];
909 sal_Int32
*pColWidth
= new sal_Int32
[aNames
.getLength()];
912 sal_Int32 nHeight
= 0;
913 m_xObject
->getPropertyValue(PROPERTY_ROW_HEIGHT
) >>= nHeight
;
915 // 1. die Spaltenbeschreibung rauspusten
916 const ::rtl::OUString
* pIter
= aNames
.getConstArray();
917 const ::rtl::OUString
* pEnd
= pIter
+ aNames
.getLength();
919 for( sal_Int32 i
=0;pIter
!= pEnd
; ++pIter
,++i
)
921 sal_Int32 nAlign
= 0;
924 if ( !bUseResultMetaData
)
926 Reference
<XPropertySet
> xColumn
;
927 xColumns
->getByName(*pIter
) >>= xColumn
;
928 xColumn
->getPropertyValue(PROPERTY_ALIGN
) >>= nAlign
;
929 pFormat
[i
] = ::comphelper::getINT32(xColumn
->getPropertyValue(PROPERTY_FORMATKEY
));
930 pColWidth
[i
] = ::comphelper::getINT32(xColumn
->getPropertyValue(PROPERTY_WIDTH
));
935 case 1: pHorJustify
[i
] = OOO_STRING_SVTOOLS_HTML_AL_center
; break;
936 case 2: pHorJustify
[i
] = OOO_STRING_SVTOOLS_HTML_AL_right
; break;
937 default: pHorJustify
[i
] = OOO_STRING_SVTOOLS_HTML_AL_left
; break;
940 if(i
== aNames
.getLength()-1)
943 WriteCell(pFormat
[i
],pColWidth
[i
],nHeight
,pHorJustify
[i
],*pIter
,OOO_STRING_SVTOOLS_HTML_tableheader
);
947 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow
);
948 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead
);
951 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody
);
953 // 2. und jetzt die Daten
954 ::comphelper::ComponentContext
aContext(m_xFactory
);
955 Reference
< XRowSet
> xRowSet(m_xRow
,UNO_QUERY
);
958 m_xResultSet
->beforeFirst(); // set back before the first row
959 while(m_xResultSet
->next())
962 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow
);
964 if(!m_pRowMarker
|| m_pRowMarker
[kk
] == j
)
967 for(sal_Int32 i
=1;i
<=aNames
.getLength();++i
)
969 if(i
== aNames
.getLength())
975 Reference
<XPropertySet
> xColumn(m_xRowSetColumns
->getByIndex(i
-1),UNO_QUERY_THROW
);
976 dbtools::FormattedColumnValue
aFormatedValue(aContext
,xRowSet
,xColumn
);
977 ::rtl::OUString sValue
= aFormatedValue
.getFormattedValue();
978 if (sValue
.getLength())
983 catch( const Exception
& )
985 DBG_UNHANDLED_EXCEPTION();
987 WriteCell(pFormat
[i
-1],pColWidth
[i
-1],nHeight
,pHorJustify
[i
-1],aValue
,OOO_STRING_SVTOOLS_HTML_tabledata
);
991 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow
);
995 delete [] pHorJustify
;
1001 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow
);
1002 TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead
);
1005 TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody
);
1008 IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody
);
1009 IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table
);
1011 //-----------------------------------------------------------------------
1012 void OHTMLImportExport::WriteCell( sal_Int32 nFormat
,sal_Int32 nWidthPixel
,sal_Int32 nHeightPixel
,const char* pChar
,
1013 const String
& rValue
,const char* pHtmlTag
)
1015 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteCell" );
1016 ::rtl::OString aStrTD
= pHtmlTag
;
1018 nWidthPixel
= nWidthPixel
? nWidthPixel
: 86;
1019 nHeightPixel
= nHeightPixel
? nHeightPixel
: 17;
1021 // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig,
1022 // da die nicht von Netscape beachtet werden..
1024 aStrTD
= aStrTD
+ " ";
1025 aStrTD
= aStrTD
+ OOO_STRING_SVTOOLS_HTML_O_width
;
1026 aStrTD
= aStrTD
+ "=";
1027 aStrTD
= aStrTD
+ ::rtl::OString::valueOf((sal_Int32
)nWidthPixel
);
1029 aStrTD
= aStrTD
+ " ";
1030 aStrTD
= aStrTD
+ OOO_STRING_SVTOOLS_HTML_O_height
;
1031 aStrTD
= aStrTD
+ "=";
1032 aStrTD
= aStrTD
+ ::rtl::OString::valueOf((sal_Int32
)nHeightPixel
);
1034 aStrTD
= aStrTD
+ " ";
1035 aStrTD
= aStrTD
+ OOO_STRING_SVTOOLS_HTML_O_align
;
1036 aStrTD
= aStrTD
+ "=";
1037 aStrTD
= aStrTD
+ pChar
;
1041 Reference
< ::com::sun::star::util::XNumberFormatsSupplier
> xSupplier
= m_xFormatter
->getNumberFormatsSupplier();
1042 SvNumberFormatsSupplierObj
* pSupplierImpl
= SvNumberFormatsSupplierObj::getImplementation( xSupplier
);
1043 SvNumberFormatter
* pFormatter
= pSupplierImpl
? pSupplierImpl
->GetNumberFormatter() : NULL
;
1048 fVal
= m_xFormatter
->convertStringToNumber(nFormat
,rValue
);
1049 ByteString
aTmpString(aStrTD
);
1050 HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString
, FALSE
, fVal
,nFormat
, *pFormatter
);
1054 ByteString
aTmpString(aStrTD
);
1055 HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString
, FALSE
, fVal
,nFormat
, *pFormatter
);
1063 BOOL bBold
= ( ::com::sun::star::awt::FontWeight::BOLD
== m_aFont
.Weight
);
1064 BOOL bItalic
= ( ::com::sun::star::awt::FontSlant_ITALIC
== m_aFont
.Slant
);
1065 BOOL bUnderline
= ( ::com::sun::star::awt::FontUnderline::NONE
!= m_aFont
.Underline
);
1066 BOOL bStrikeout
= ( ::com::sun::star::awt::FontStrikeout::NONE
!= m_aFont
.Strikeout
);
1068 if ( bBold
) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold
);
1069 if ( bItalic
) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic
);
1070 if ( bUnderline
) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline
);
1071 if ( bStrikeout
) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike
);
1073 if ( !rValue
.Len() )
1074 TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak
); // #42573# keine komplett leere Zelle
1076 HTMLOutFuncs::Out_String( (*m_pStream
), rValue
,m_eDestEnc
);
1079 if ( bStrikeout
) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike
);
1080 if ( bUnderline
) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline
);
1081 if ( bItalic
) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic
);
1082 if ( bBold
) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold
);
1086 TAG_OFF_LF( pHtmlTag
);
1088 //-----------------------------------------------------------------------
1089 void OHTMLImportExport::FontOn()
1091 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOn" );
1093 m_bCheckFont
= TRUE
;
1096 // <FONT FACE="xxx">
1097 ::rtl::OString aStrOut
= "<";
1098 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_font
;
1099 aStrOut
= aStrOut
+ " ";
1100 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_face
;
1101 aStrOut
= aStrOut
+ "=";
1102 aStrOut
= aStrOut
+ "\"";
1103 aStrOut
= aStrOut
+ ::rtl::OString(m_aFont
.Name
,m_aFont
.Name
.getLength(),gsl_getSystemTextEncoding());
1104 // TODO : think about the encoding of the font name
1105 aStrOut
= aStrOut
+ "\"";
1106 aStrOut
= aStrOut
+ " ";
1107 aStrOut
= aStrOut
+ OOO_STRING_SVTOOLS_HTML_O_color
;
1108 aStrOut
= aStrOut
+ "=";
1109 (*m_pStream
) << aStrOut
;
1111 sal_Int32 nColor
= 0;
1113 m_xObject
->getPropertyValue(PROPERTY_TEXTCOLOR
) >>= nColor
;
1114 ::Color
aColor(nColor
);
1116 HTMLOutFuncs::Out_Color( (*m_pStream
), aColor
);
1117 (*m_pStream
) << ">";
1119 //-----------------------------------------------------------------------
1120 inline void OHTMLImportExport::FontOff()
1122 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOff" );
1123 DBG_ASSERT(m_bCheckFont
,"Kein FontOn() gerufen");
1124 TAG_OFF( OOO_STRING_SVTOOLS_HTML_font
);
1126 m_bCheckFont
= FALSE
;
1129 //-----------------------------------------------------------------------
1130 void OHTMLImportExport::IncIndent( sal_Int16 nVal
)
1132 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::IncIndent" );
1133 sIndent
[m_nIndent
] = '\t';
1134 m_nIndent
= m_nIndent
+ nVal
;
1135 if ( m_nIndent
< 0 )
1137 else if ( m_nIndent
> nIndentMax
)
1138 m_nIndent
= nIndentMax
;
1139 sIndent
[m_nIndent
] = 0;
1141 // -----------------------------------------------------------------------------