summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/misc/TokenWriter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/misc/TokenWriter.cxx')
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx330
1 files changed, 158 insertions, 172 deletions
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index 3d73e9427b0e..17db6b7cdd5d 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -18,7 +18,7 @@
*/
#include <TokenWriter.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/stream.hxx>
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
@@ -48,6 +48,7 @@
#include <svtools/htmlout.hxx>
#include <sfx2/frmhtmlw.hxx>
#include <svl/numuno.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <UITools.hxx>
#include <toolkit/helper/vclunohelper.hxx>
@@ -55,6 +56,7 @@
#include <vcl/settings.hxx>
#include <svtools/rtfout.hxx>
#include <svtools/htmlcfg.hxx>
+#include <o3tl/string_view.hxx>
#include <connectivity/formattedcolumnvalue.hxx>
#include <memory>
@@ -72,12 +74,13 @@ using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::util;
-#define CELL_X 1437
+constexpr sal_Int32 CELL_X = 1437;
ODatabaseImportExport::ODatabaseImportExport(const svx::ODataAccessDescriptor& _aDataDescriptor,
const Reference< XComponentContext >& _rM,
const Reference< css::util::XNumberFormatter >& _rxNumberF)
:m_bBookmarkSelection( false )
+ ,m_pStream(nullptr)
,m_xFormatter(_rxNumberF)
,m_xContext(_rM)
,m_nCommandType(CommandType::TABLE)
@@ -93,11 +96,11 @@ ODatabaseImportExport::ODatabaseImportExport(const svx::ODataAccessDescriptor& _
}
// import data
-ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
+ODatabaseImportExport::ODatabaseImportExport( ::dbtools::SharedConnection _xConnection,
const Reference< XNumberFormatter >& _rxNumberF, const Reference< XComponentContext >& _rM )
:m_bBookmarkSelection( false )
,m_pStream(nullptr)
- ,m_xConnection(_rxConnection)
+ ,m_xConnection(std::move(_xConnection))
,m_xFormatter(_rxNumberF)
,m_xContext(_rM)
,m_nCommandType(css::sdb::CommandType::TABLE)
@@ -120,7 +123,7 @@ void ODatabaseImportExport::dispose()
Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
if (xComponent.is())
{
- Reference< XEventListener> xEvt(static_cast<cppu::OWeakObject*>(this),UNO_QUERY);
+ Reference< XEventListener> xEvt(this);
xComponent->removeEventListener(xEvt);
}
m_xConnection.clear();
@@ -133,6 +136,7 @@ void ODatabaseImportExport::dispose()
m_xRow.clear();
m_xRowLocate.clear();
m_xFormatter.clear();
+ m_xRowSetColumns.clear();
}
void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source )
@@ -163,7 +167,7 @@ void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor
{
Reference< XConnection > xPureConn( _aDataDescriptor[DataAccessDescriptorProperty::Connection], UNO_QUERY );
m_xConnection.reset( xPureConn, SharedConnection::NoTakeOwnership );
- Reference< XEventListener> xEvt(static_cast<cppu::OWeakObject*>(this),UNO_QUERY);
+ Reference< XEventListener> xEvt(this);
Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
if (xComponent.is() && xEvt.is())
xComponent->addEventListener(xEvt);
@@ -212,7 +216,7 @@ void ODatabaseImportExport::initialize()
{ // we need a connection
OSL_ENSURE(!m_sDataSourceName.isEmpty(),"There must be a datsource name!");
Reference<XNameAccess> xDatabaseContext( DatabaseContext::create(m_xContext), UNO_QUERY_THROW);
- Reference< XEventListener> xEvt(static_cast<cppu::OWeakObject*>(this),UNO_QUERY);
+ Reference< XEventListener> xEvt(this);
Reference< XConnection > xConnection;
SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xContext, xEvt, xConnection );
@@ -256,11 +260,11 @@ void ODatabaseImportExport::initialize()
// the result set may be already set with the datadescriptor
if ( !m_xResultSet.is() )
{
- m_xResultSet.set( m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.sdb.RowSet", m_xContext), UNO_QUERY );
+ m_xResultSet.set( m_xContext->getServiceManager()->createInstanceWithContext(u"com.sun.star.sdb.RowSet"_ustr, m_xContext), UNO_QUERY );
Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW );
- xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
- xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) );
- xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) );
+ xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( m_xConnection.getTyped() ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, Any( m_nCommandType ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND, Any( m_sName ) );
Reference< XRowSet > xRowSet( xProp, UNO_QUERY );
xRowSet->execute();
}
@@ -317,23 +321,22 @@ bool ODatabaseImportExport::Read()
bool ORTFImportExport::Write()
{
ODatabaseImportExport::Write();
- m_pStream->WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RTF );
- m_pStream->WriteCharPtr(OOO_STRING_SVTOOLS_RTF_ANSI);
+ m_pStream->WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_RTF );
+ m_pStream->WriteOString(OOO_STRING_SVTOOLS_RTF_ANSI);
if (sal_uInt32 nCpg = rtl_getWindowsCodePageFromTextEncoding(m_eDestEnc); nCpg && nCpg != 65001)
{
- m_pStream->WriteCharPtr(OOO_STRING_SVTOOLS_RTF_ANSICPG).WriteUInt32AsString(nCpg);
+ m_pStream->WriteOString(OOO_STRING_SVTOOLS_RTF_ANSICPG).WriteNumberAsString(nCpg);
}
- m_pStream->WriteCharPtr(SAL_NEWLINE_STRING);
+ m_pStream->WriteOString(SAL_NEWLINE_STRING);
bool bBold = ( css::awt::FontWeight::BOLD == m_aFont.Weight );
bool bItalic = ( css::awt::FontSlant_ITALIC == m_aFont.Slant );
bool bUnderline = ( css::awt::FontUnderline::NONE != m_aFont.Underline );
bool bStrikeout = ( css::awt::FontStrikeout::NONE != m_aFont.Strikeout );
- sal_Int32 nColor = 0;
+ ::Color aColor;
if(m_xObject.is())
- m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
- ::Color aColor(nColor);
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= aColor;
OString aFonts(OUStringToOString(m_aFont.Name, RTL_TEXTENCODING_MS_1252));
if (aFonts.isEmpty())
@@ -342,44 +345,43 @@ bool ORTFImportExport::Write()
aFonts = OUStringToOString(aName, RTL_TEXTENCODING_MS_1252);
}
- m_pStream->WriteCharPtr( "{\\fonttbl" );
+ m_pStream->WriteOString( "{\\fonttbl" );
if (!aFonts.isEmpty())
{
sal_Int32 nIdx{0};
sal_Int32 nTok{-1}; // to compensate pre-increment
do {
- m_pStream->WriteCharPtr( "\\f" );
- m_pStream->WriteInt32AsString(++nTok);
- m_pStream->WriteCharPtr( "\\fcharset0\\fnil " );
- m_pStream->WriteOString( aFonts.getToken(0, ';', nIdx) );
+ m_pStream->WriteOString( "\\f" );
+ m_pStream->WriteNumberAsString(++nTok);
+ m_pStream->WriteOString( "\\fcharset0\\fnil " );
+ m_pStream->WriteOString( o3tl::getToken(aFonts, 0, ';', nIdx) );
m_pStream->WriteChar( ';' );
} while (nIdx>=0);
}
m_pStream->WriteChar( '}' ) ;
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
// write the rtf color table
- m_pStream->WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_COLORTBL ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RED );
- m_pStream->WriteUInt32AsString(aColor.GetRed());
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_GREEN );
- m_pStream->WriteUInt32AsString(aColor.GetGreen());
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_BLUE );
- m_pStream->WriteUInt32AsString(aColor.GetBlue());
+ m_pStream->WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_COLORTBL ).WriteOString( OOO_STRING_SVTOOLS_RTF_RED );
+ m_pStream->WriteNumberAsString(aColor.GetRed());
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_GREEN );
+ m_pStream->WriteNumberAsString(aColor.GetGreen());
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_BLUE );
+ m_pStream->WriteNumberAsString(aColor.GetBlue());
- m_pStream->WriteCharPtr( ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}" )
- .WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}" )
+ .WriteOString( SAL_NEWLINE_STRING );
static char const aCell1[] = "\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx";
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TRGAPH );
- m_pStream->WriteInt32AsString(40);
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteOString( OOO_STRING_SVTOOLS_RTF_TRGAPH );
+ m_pStream->WriteOString("40");
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
if(m_xObject.is())
{
Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
Reference<XNameAccess> xColumns = xColSup->getColumns();
Sequence< OUString> aNames(xColumns->getElementNames());
- const OUString* pIter = aNames.getConstArray();
sal_Int32 nCount = aNames.getLength();
bool bUseResultMetaData = false;
@@ -391,14 +393,14 @@ bool ORTFImportExport::Write()
for( sal_Int32 i=1; i<=nCount; ++i )
{
- m_pStream->WriteCharPtr( aCell1 );
- m_pStream->WriteInt32AsString(i*CELL_X);
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( aCell1 );
+ m_pStream->WriteNumberAsString(i*CELL_X);
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
}
// column description
- m_pStream->WriteChar( '{' ).WriteCharPtr( SAL_NEWLINE_STRING );
- m_pStream->WriteCharPtr( "\\trrh-270\\pard\\intbl" );
+ m_pStream->WriteChar( '{' ).WriteOString( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( "\\trrh-270\\pard\\intbl" );
std::unique_ptr<OString[]> pHorzChar(new OString[nCount]);
@@ -410,11 +412,10 @@ bool ORTFImportExport::Write()
sColumnName = m_xResultSetMetaData->getColumnName(i);
else
{
- sColumnName = *pIter;
+ sColumnName = aNames[i - 1];
Reference<XPropertySet> xColumn;
xColumns->getByName(sColumnName) >>= xColumn;
xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
- ++pIter;
}
const char* pChar;
@@ -428,52 +429,49 @@ bool ORTFImportExport::Write()
pHorzChar[i-1] = pChar; // to avoid to always rummage in the ITEMSET later on
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
m_pStream->WriteChar( '{' );
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QC ); // column header always centered
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_QC ); // column header always centered
- if ( bBold ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_B );
- if ( bItalic ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_I );
- if ( bUnderline ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_UL );
- if ( bStrikeout ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_STRIKE );
+ if ( bBold ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_B );
+ if ( bItalic ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_I );
+ if ( bUnderline ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_UL );
+ if ( bStrikeout ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_STRIKE );
- m_pStream->WriteCharPtr( "\\fs20\\f0\\cf0\\cb2" );
+ m_pStream->WriteOString( "\\fs20\\f0\\cf0\\cb2" );
m_pStream->WriteChar( ' ' );
RTFOutFuncs::Out_String(*m_pStream, sColumnName, m_eDestEnc);
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CELL );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
m_pStream->WriteChar( '}' );
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PARD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_INTBL );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( OOO_STRING_SVTOOLS_RTF_INTBL );
}
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ROW );
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING ).WriteChar( '}' );
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_ROW );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING ).WriteChar( '}' );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
sal_Int32 k=1;
sal_Int32 kk=0;
if ( m_aSelection.hasElements() )
{
- const Any* pSelIter = m_aSelection.getConstArray();
- const Any* pEnd = pSelIter + m_aSelection.getLength();
-
- bool bContinue = true;
- for( ; pSelIter != pEnd && bContinue; ++pSelIter )
+ for (auto& any : m_aSelection)
{
if ( m_bBookmarkSelection )
{
- bContinue = m_xRowLocate->moveToBookmark( *pSelIter );
+ if (!m_xRowLocate->moveToBookmark(any))
+ break;
}
else
{
sal_Int32 nPos = -1;
- OSL_VERIFY( *pSelIter >>= nPos );
- bContinue = ( m_xResultSet->absolute( nPos ) );
+ OSL_VERIFY(any >>= nPos);
+ if (!m_xResultSet->absolute(nPos))
+ break;
}
- if ( bContinue )
- appendRow( pHorzChar.get(), nCount, k, kk );
+ appendRow(pHorzChar.get(), nCount, k, kk);
}
}
else
@@ -486,7 +484,7 @@ bool ORTFImportExport::Write()
}
}
- m_pStream->WriteChar( '}' ).WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING );
m_pStream->WriteUChar( 0 );
return ((*m_pStream).GetError() == ERRCODE_NONE);
}
@@ -494,17 +492,17 @@ bool ORTFImportExport::Write()
void ORTFImportExport::appendRow(OString const * pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk)
{
++kk;
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TRGAPH );
- m_pStream->WriteInt32AsString(40);
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteOString( OOO_STRING_SVTOOLS_RTF_TRGAPH );
+ m_pStream->WriteOString("40");
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
static char const aCell2[] = "\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx";
for ( sal_Int32 i=1; i<=_nColumnCount; ++i )
{
- m_pStream->WriteCharPtr( aCell2 );
- m_pStream->WriteInt32AsString(i*CELL_X);
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( aCell2 );
+ m_pStream->WriteNumberAsString(i*CELL_X);
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
}
const bool bBold = ( css::awt::FontWeight::BOLD == m_aFont.Weight );
@@ -514,19 +512,19 @@ void ORTFImportExport::appendRow(OString const * pHorzChar,sal_Int32 _nColumnCou
Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
m_pStream->WriteChar( '{' );
- m_pStream->WriteCharPtr( "\\trrh-270\\pard\\intbl" );
+ m_pStream->WriteOString( "\\trrh-270\\pard\\intbl" );
for ( sal_Int32 i=1; i <= _nColumnCount; ++i )
{
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
m_pStream->WriteChar( '{' );
m_pStream->WriteOString( pHorzChar[i-1] );
- if ( bBold ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_B );
- if ( bItalic ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_I );
- if ( bUnderline ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_UL );
- if ( bStrikeout ) m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_STRIKE );
+ if ( bBold ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_B );
+ if ( bItalic ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_I );
+ if ( bUnderline ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_UL );
+ if ( bStrikeout ) m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_STRIKE );
- m_pStream->WriteCharPtr( "\\fs20\\f1\\cf0\\cb1 " );
+ m_pStream->WriteOString( "\\fs20\\f1\\cf0\\cb1 " );
try
{
@@ -541,12 +539,12 @@ void ORTFImportExport::appendRow(OString const * pHorzChar,sal_Int32 _nColumnCou
SAL_WARN("dbaccess.ui","RTF WRITE!");
}
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CELL );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
m_pStream->WriteChar( '}' );
- m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PARD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_INTBL );
+ m_pStream->WriteOString( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( OOO_STRING_SVTOOLS_RTF_INTBL );
}
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ROW ).WriteCharPtr( SAL_NEWLINE_STRING );
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_RTF_ROW ).WriteOString( SAL_NEWLINE_STRING );
m_pStream->WriteChar( '}' );
++k;
}
@@ -566,24 +564,9 @@ bool ORTFImportExport::Read()
return eState != SvParserState::Error;
}
-const sal_Int16 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 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";
-// Macros for HTML-Export
-#define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag )
-#define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, false )
-#define OUT_LF() m_pStream->WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( GetIndentStr() )
-#define TAG_ON_LF( tag ) (TAG_ON( tag ).WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( GetIndentStr() ))
-#define TAG_OFF_LF( tag ) (TAG_OFF( tag ).WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( GetIndentStr() ))
-
OHTMLImportExport::OHTMLImportExport(const svx::ODataAccessDescriptor& _aDataDescriptor,
const Reference< XComponentContext >& _rM,
const Reference< css::util::XNumberFormatter >& _rxNumberF)
@@ -594,8 +577,7 @@ OHTMLImportExport::OHTMLImportExport(const svx::ODataAccessDescriptor& _aDataDes
#endif
{
// set HTML configuration
- SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
- m_eDestEnc = rHtmlOptions.GetTextEncoding();
+ m_eDestEnc = RTL_TEXTENCODING_UTF8;
strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource)));
sIndent[0] = 0;
}
@@ -605,13 +587,13 @@ bool OHTMLImportExport::Write()
ODatabaseImportExport::Write();
if(m_xObject.is())
{
- m_pStream->WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype ).WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype40 ).WriteChar( '>' ).WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( SAL_NEWLINE_STRING );
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
+ m_pStream->WriteChar( '<' ).WriteOString( OOO_STRING_SVTOOLS_HTML_doctype ).WriteChar( ' ' ).WriteOString( OOO_STRING_SVTOOLS_HTML_doctype5 ).WriteChar( '>' ).WriteOString( SAL_NEWLINE_STRING ).WriteOString( SAL_NEWLINE_STRING );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_html).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
WriteHeader();
- OUT_LF();
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
WriteBody();
- OUT_LF();
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_html, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
return ((*m_pStream).GetError() == ERRCODE_NONE);
}
@@ -642,47 +624,53 @@ void OHTMLImportExport::WriteHeader()
xDocProps->setTitle(m_sName);
}
- IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head );
+ IncIndent(1);
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_head).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), OUString(),
- xDocProps, sIndent, osl_getThreadTextEncoding() );
- OUT_LF();
- IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head );
+ xDocProps, sIndent );
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ IncIndent(-1);
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_head, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
void OHTMLImportExport::WriteBody()
{
IncIndent(1);
- m_pStream->WriteCharPtr( "<" ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_style ).WriteCharPtr( " " ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_type ).WriteCharPtr( "=\"text/css\">" );
+ m_pStream->WriteOString( "<" ).WriteOString( OOO_STRING_SVTOOLS_HTML_style ).WriteOString( " " ).WriteOString( OOO_STRING_SVTOOLS_HTML_O_type ).WriteOString( "=\"text/css\">" );
- m_pStream->WriteCharPtr( "<!-- " ); OUT_LF();
- m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body ).WriteCharPtr( " { " ).WriteCharPtr( "font-family: " ).WriteChar( '"' ).WriteOString( OUStringToOString(m_aFont.Name, osl_getThreadTextEncoding()) ).WriteChar( '\"' );
+ m_pStream->WriteOString( "<!-- " );
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ m_pStream->WriteOString( OOO_STRING_SVTOOLS_HTML_body ).WriteOString( " { " ).WriteOString( "font-family: " ).WriteChar( '"' ).WriteOString( OUStringToOString(m_aFont.Name, osl_getThreadTextEncoding()) ).WriteChar( '\"' );
// TODO : think about the encoding of the font name
- m_pStream->WriteCharPtr( "; " ).WriteCharPtr( "font-size: " );
- m_pStream->WriteInt32AsString(m_aFont.Height);
+ m_pStream->WriteOString( "; " ).WriteOString( "font-size: " );
+ m_pStream->WriteNumberAsString(m_aFont.Height);
m_pStream->WriteChar( '}' );
- OUT_LF();
- m_pStream->WriteCharPtr( " -->" );
- IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style );
- OUT_LF();
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ m_pStream->WriteOString( " -->" );
+ IncIndent(-1);
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_style, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
// default Textcolour black
- m_pStream->WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body ).WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_text ).WriteChar( '=' );
- sal_Int32 nColor = 0;
+ m_pStream->WriteChar( '<' ).WriteOString( OOO_STRING_SVTOOLS_HTML_body ).WriteChar( ' ' ).WriteOString( OOO_STRING_SVTOOLS_HTML_O_text ).WriteChar( '=' );
+ ::Color aColor;
if(m_xObject.is())
- m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
- ::Color aColor(nColor);
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= aColor;
HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
- m_pStream->WriteCharPtr( " " OOO_STRING_SVTOOLS_HTML_O_bgcolor "=" );
+ m_pStream->WriteOString( " " OOO_STRING_SVTOOLS_HTML_O_bgcolor "=" );
HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
- m_pStream->WriteChar( '>' ); OUT_LF();
+ m_pStream->WriteChar( '>' );
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
WriteTables();
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_body, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
void OHTMLImportExport::WriteTables()
@@ -691,7 +679,7 @@ void OHTMLImportExport::WriteTables()
" "
OOO_STRING_SVTOOLS_HTML_frame
"="
- OOO_STRING_SVTOOLS_HTML_TF_void;
+ OOO_STRING_SVTOOLS_HTML_TF_void ""_ostr;
Sequence< OUString> aNames;
Reference<XNameAccess> xColumns;
@@ -705,8 +693,9 @@ void OHTMLImportExport::WriteTables()
{
sal_Int32 nCount = m_xResultSetMetaData->getColumnCount();
aNames.realloc(nCount);
+ auto aNamesRange = asNonConstRange(aNames);
for (sal_Int32 i= 0; i < nCount; ++i)
- aNames[i] = m_xResultSetMetaData->getColumnName(i+1);
+ aNamesRange[i] = m_xResultSetMetaData->getColumnName(i+1);
bUseResultMetaData = true;
}
}
@@ -728,27 +717,27 @@ void OHTMLImportExport::WriteTables()
"=1";
IncIndent(1);
- TAG_ON( aStrOut.getStr() );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, aStrOut);
FontOn();
- TAG_ON( OOO_STRING_SVTOOLS_HTML_caption );
- TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_caption);
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_bold);
m_pStream->WriteOString( OUStringToOString(m_sName, osl_getThreadTextEncoding()) );
// TODO : think about the encoding of the name
- TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
- TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_bold, false);
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_caption, false);
FontOff();
- OUT_LF();
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
// </FONT>
IncIndent(1);
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
IncIndent(1);
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
if(m_xObject.is())
{
@@ -761,10 +750,7 @@ void OHTMLImportExport::WriteTables()
m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight;
// 1. writing the column description
- const OUString* pIter = aNames.getConstArray();
- const OUString* pEnd = pIter + aNames.getLength();
-
- for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i )
+ for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
{
sal_Int32 nAlign = 0;
pFormat[i] = 0;
@@ -772,7 +758,7 @@ void OHTMLImportExport::WriteTables()
if ( !bUseResultMetaData )
{
Reference<XPropertySet> xColumn;
- xColumns->getByName(*pIter) >>= xColumn;
+ xColumns->getByName(aNames[i]) >>= xColumn;
xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY));
pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH));
@@ -788,26 +774,24 @@ void OHTMLImportExport::WriteTables()
if(i == aNames.getLength()-1)
IncIndent(-1);
- WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader);
+ WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],aNames[i],OOO_STRING_SVTOOLS_HTML_tableheader);
}
IncIndent(-1);
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
IncIndent(1);
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
// 2. and now the data
Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
- sal_Int32 kk=0;
m_xResultSet->beforeFirst(); // set back before the first row
while(m_xResultSet->next())
{
IncIndent(1);
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
- ++kk;
for(sal_Int32 i=1;i<=aNames.getLength();++i)
{
if(i == aNames.getLength())
@@ -830,21 +814,24 @@ void OHTMLImportExport::WriteTables()
}
WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,OOO_STRING_SVTOOLS_HTML_tabledata);
}
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
}
else
{
IncIndent(-1);
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
- TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
IncIndent(1);
- TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
- IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody );
- IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
+ IncIndent(-1);
+ m_pStream->WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
+ IncIndent(-1);
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_table, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal_Int32 nHeightPixel, const char* pChar,
@@ -872,7 +859,7 @@ void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal
"=" +
pChar;
- SvNumberFormatsSupplierObj* pSupplierImpl = m_xFormatter.is() ? comphelper::getUnoTunnelImplementation<SvNumberFormatsSupplierObj>(m_xFormatter->getNumberFormatsSupplier()) : nullptr;
+ SvNumberFormatsSupplierObj* pSupplierImpl = m_xFormatter.is() ? comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(m_xFormatter->getNumberFormatsSupplier()) : nullptr;
SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : nullptr;
if(pFormatter)
{
@@ -889,7 +876,7 @@ void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal
}
}
- TAG_ON( aStrTD.getStr() );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, aStrTD);
FontOn();
@@ -898,24 +885,24 @@ void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal
bool bUnderline = ( css::awt::FontUnderline::NONE != m_aFont.Underline );
bool bStrikeout = ( css::awt::FontStrikeout::NONE != m_aFont.Strikeout );
- if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
- if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic );
- if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline );
- if ( bStrikeout ) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike );
+ if ( bBold ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_bold);
+ if ( bItalic ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_italic);
+ if ( bUnderline ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_underline);
+ if ( bStrikeout ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_strike);
if ( rValue.isEmpty() )
- TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // no completely empty cell
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_linebreak); // no completely empty cell
else
- HTMLOutFuncs::Out_String( (*m_pStream), rValue ,m_eDestEnc);
+ HTMLOutFuncs::Out_String( (*m_pStream), rValue );
- if ( bStrikeout ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike );
- if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
- if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic );
- if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
+ if ( bStrikeout ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_strike, false);
+ if ( bUnderline ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_underline, false);
+ if ( bItalic ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_italic, false);
+ if ( bBold ) HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_bold, false);
FontOff();
- TAG_OFF_LF( pHtmlTag );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, pHtmlTag, false).WriteOString(SAL_NEWLINE_STRING).WriteOString(GetIndentStr());
}
void OHTMLImportExport::FontOn()
@@ -939,13 +926,12 @@ void OHTMLImportExport::FontOn()
"=";
m_pStream->WriteOString( aStrOut );
- sal_Int32 nColor = 0;
+ ::Color aColor;
if(m_xObject.is())
- m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
- ::Color aColor(nColor);
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= aColor;
HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
- m_pStream->WriteCharPtr( ">" );
+ m_pStream->WriteOString( ">" );
}
inline void OHTMLImportExport::FontOff()
@@ -953,7 +939,7 @@ inline void OHTMLImportExport::FontOff()
#if OSL_DEBUG_LEVEL > 0
OSL_ENSURE(m_bCheckFont,"No FontOn() called");
#endif
- TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
+ HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_font, false);
#if OSL_DEBUG_LEVEL > 0
m_bCheckFont = false;
#endif