diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-11-11 16:00:08 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-11-11 19:41:46 +0100 |
commit | be73c64d11fd330f76b08fc75354164aba3ecc88 (patch) | |
tree | e3f8a9732c44ecb36742c3574a5d9bbec7bb45ce /dbaccess/source | |
parent | ce64e3feb72dbe8f14a5b22a6a02722b02b391b0 (diff) |
Replace some macros in dbaccess part 7
Remove FIRST_USER_DEFINED_FEATURE and LAST_USER_DEFINED_FEATURE + GRANT_REVOKE_RIGHT
+ ALL_STRING + ALL_INT
+ NSQLAllocHandle + NSQLFreeHandle + NSQLSetEnvAttr + NSQLDataSources
+ LbText + LbPos + CHECK_INVARIANTS
+ OUT_LF + TAG_OFF_LF + TAG_ON_LF + TAG_OFF + TAG_ON
Change-Id: I07261ea0eafcc9f0630f92e47bf5c2f694661933
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125065
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/ui/browser/genericcontroller.cxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/control/TableGrantCtrl.cxx | 41 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/directsql.cxx | 48 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/odbcconfig.cxx | 16 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/queryfilter.cxx | 37 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/directsql.hxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/TokenWriter.cxx | 103 |
8 files changed, 155 insertions, 117 deletions
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 7798af401275..e317c2a3beeb 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -67,8 +67,6 @@ using namespace ::dbtools; using namespace ::comphelper; #define ALL_FEATURES -1 -#define FIRST_USER_DEFINED_FEATURE ( std::numeric_limits< sal_uInt16 >::max() - 1000 ) -#define LAST_USER_DEFINED_FEATURE ( std::numeric_limits< sal_uInt16 >::max() ) typedef std::unordered_map< sal_Int16, sal_Int16 > CommandHashMap; @@ -763,7 +761,8 @@ void OGenericUnoController::implDescribeSupportedFeature( const char* _pAsciiCom #ifdef DBG_UTIL OSL_ENSURE( m_bDescribingSupportedFeatures, "OGenericUnoController::implDescribeSupportedFeature: bad timing for this call!" ); #endif - OSL_PRECOND( _nFeatureId < FIRST_USER_DEFINED_FEATURE, "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" ); + OSL_PRECOND( _nFeatureId < ( std::numeric_limits< sal_uInt16 >::max() - 1000 ), // FIRST_USER_DEFINED_FEATURE + "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" ); ControllerFeature aFeature; aFeature.Command = OUString::createFromAscii( _pAsciiCommandURL ); @@ -841,7 +840,11 @@ URL OGenericUnoController::getURLForId(sal_Int32 _nId) const bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId ) { - return ( _nFeatureId >= FIRST_USER_DEFINED_FEATURE ) && ( _nFeatureId < LAST_USER_DEFINED_FEATURE ); + return + (_nFeatureId >= ( std::numeric_limits< sal_uInt16 >::max() - 1000 )) // test if >= FIRST_USER_DEFINED_FEATURE + && + ( _nFeatureId < (std::numeric_limits< sal_uInt16 >::max())) // test if < LAST_USER_DEFINED_FEATURE + ; } bool OGenericUnoController::isUserDefinedFeature( const OUString& _rFeatureURL ) const diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx index 49719e814113..f4826e96d281 100644 --- a/dbaccess/source/ui/control/TableGrantCtrl.cxx +++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx @@ -193,12 +193,6 @@ bool OTableGrantControl::IsTabAllowed(bool bForward) const return EditBrowseBox::IsTabAllowed(bForward); } -#define GRANT_REVOKE_RIGHT(what) \ - if (m_pCheckCell->GetBox().get_active()) \ - xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,what);\ - else \ - xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,what) - bool OTableGrantControl::SaveModified() { @@ -219,25 +213,46 @@ bool OTableGrantControl::SaveModified() switch( GetCurColumnId() ) { case COL_INSERT: - GRANT_REVOKE_RIGHT(Privilege::INSERT); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::INSERT); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::INSERT); break; case COL_DELETE: - GRANT_REVOKE_RIGHT(Privilege::DELETE); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::DELETE); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::DELETE); break; case COL_UPDATE: - GRANT_REVOKE_RIGHT(Privilege::UPDATE); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::UPDATE); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::UPDATE); break; case COL_ALTER: - GRANT_REVOKE_RIGHT(Privilege::ALTER); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::ALTER); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::ALTER); break; case COL_SELECT: - GRANT_REVOKE_RIGHT(Privilege::SELECT); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::SELECT); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::SELECT); break; case COL_REF: - GRANT_REVOKE_RIGHT(Privilege::REFERENCE); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::REFERENCE); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::REFERENCE); break; case COL_DROP: - GRANT_REVOKE_RIGHT(Privilege::DROP); + if (m_pCheckCell->GetBox().get_active()) + xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,Privilege::DROP); + else + xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,Privilege::DROP); break; } fillPrivilege(nRow); diff --git a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx index 41ed0e867c4b..df0d38e4ba87 100644 --- a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx +++ b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx @@ -11,9 +11,6 @@ #include <strings.hrc> #include <core_resource.hxx> -#define ALL_STRING DBA_RES(STR_QUERY_LIMIT_ALL) -#define ALL_INT -1 - namespace dbaui { @@ -27,7 +24,7 @@ QueryPropertiesDialog::QueryPropertiesDialog( m_xRB_Distinct->set_active(bDistinct); m_xRB_NonDistinct->set_active(!bDistinct); - m_xLB_Limit->append(OUString::number(ALL_INT), ALL_STRING); + m_xLB_Limit->append(OUString::number(-1), DBA_RES(STR_QUERY_LIMIT_ALL)); // ALL_INT and ALL_STRING /// Default values sal_Int64 const aDefLimitAry[] = { diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx index 709ac414fdfe..bcf8923abfaa 100644 --- a/dbaccess/source/ui/dlg/directsql.cxx +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -111,13 +111,25 @@ namespace dbaui sal_Int32 DirectSQLDialog::getHistorySize() const { - CHECK_INVARIANTS("DirectSQLDialog::getHistorySize"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::getHistorySize: " << pError); + } + #endif return m_aStatementHistory.size(); } void DirectSQLDialog::implEnsureHistoryLimit() { - CHECK_INVARIANTS("DirectSQLDialog::implEnsureHistoryLimit"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::implEnsureHistoryLimit: " << pError); + } + #endif if (getHistorySize() <= g_nHistoryLimit) // nothing to do @@ -134,7 +146,13 @@ namespace dbaui void DirectSQLDialog::implAddToStatementHistory(const OUString& _rStatement) { - CHECK_INVARIANTS("DirectSQLDialog::implAddToStatementHistory"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::implAddToStatementHistor: " << pError); + } + #endif // add the statement to the history m_aStatementHistory.push_back(_rStatement); @@ -171,7 +189,13 @@ namespace dbaui void DirectSQLDialog::implExecuteStatement(const OUString& _rStatement) { - CHECK_INVARIANTS("DirectSQLDialog::implExecuteStatement"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::implExecuteStatement: " << pError); + } + #endif ::osl::MutexGuard aGuard(m_aMutex); @@ -328,7 +352,13 @@ namespace dbaui void DirectSQLDialog::executeCurrent() { - CHECK_INVARIANTS("DirectSQLDialog::executeCurrent"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::executeCurrent: " << pError); + } + #endif OUString sStatement = m_xSQL->GetText(); @@ -343,7 +373,13 @@ namespace dbaui void DirectSQLDialog::switchToHistory(sal_Int32 _nHistoryPos) { - CHECK_INVARIANTS("DirectSQLDialog::switchToHistory"); + #ifdef DBG_UTIL + { + const char* pError = impl_CheckInvariants(); + if (pError) + SAL_WARN("dbaccess.ui", "DirectSQLDialog::switchToHistory: " << pError); + } + #endif if ((_nHistoryPos >= 0) && (_nHistoryPos < getHistorySize())) { diff --git a/dbaccess/source/ui/dlg/odbcconfig.cxx b/dbaccess/source/ui/dlg/odbcconfig.cxx index f3de8ba7037f..b2f3a45ff90d 100644 --- a/dbaccess/source/ui/dlg/odbcconfig.cxx +++ b/dbaccess/source/ui/dlg/odbcconfig.cxx @@ -61,10 +61,6 @@ typedef SQLRETURN (SQL_API* TSQLSetEnvAttr) (SQLHENV EnvironmentHandle, SQLINTEG typedef SQLRETURN (SQL_API* TSQLDataSources) (SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR* ServerName, SQLSMALLINT BufferLength1, SQLSMALLINT* NameLength1Ptr, SQLCHAR* Description, SQLSMALLINT BufferLength2, SQLSMALLINT* NameLength2Ptr); -#define NSQLAllocHandle(a,b,c) (*reinterpret_cast<TSQLAllocHandle>(m_pAllocHandle))(a,b,c) -#define NSQLFreeHandle(a,b) (*reinterpret_cast<TSQLFreeHandle>(m_pFreeHandle))(a,b) -#define NSQLSetEnvAttr(a,b,c,d) (*reinterpret_cast<TSQLSetEnvAttr>(m_pSetEnvAttr))(a,b,c,d) -#define NSQLDataSources(a,b,c,d,e,f,g,h) (*reinterpret_cast<TSQLDataSources>(m_pDataSources))(a,b,c,d,e,f,g,h) #endif // OOdbcLibWrapper @@ -164,12 +160,12 @@ bool OOdbcEnumeration::allocEnv() if (m_pImpl->hEnvironment) // nothing to do return true; - SQLRETURN nResult = NSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_pImpl->hEnvironment); + SQLRETURN nResult = (*reinterpret_cast<TSQLAllocHandle>(m_pAllocHandle))(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_pImpl->hEnvironment); if (SQL_SUCCESS != nResult) // can't do anything without environment return false; - NSQLSetEnvAttr(m_pImpl->hEnvironment, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), SQL_IS_INTEGER); + (*reinterpret_cast<TSQLSetEnvAttr>(m_pSetEnvAttr))(m_pImpl->hEnvironment, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3),SQL_IS_INTEGER); return true; #else return sal_False; @@ -180,7 +176,7 @@ void OOdbcEnumeration::freeEnv() { #ifdef HAVE_ODBC_SUPPORT if (m_pImpl->hEnvironment) - NSQLFreeHandle(SQL_HANDLE_ENV, m_pImpl->hEnvironment); + (*reinterpret_cast<TSQLFreeHandle>(m_pFreeHandle))(SQL_HANDLE_ENV, m_pImpl->hEnvironment); m_pImpl->hEnvironment = nullptr; #endif } @@ -206,9 +202,11 @@ void OOdbcEnumeration::getDatasourceNames(std::set<OUString>& _rNames) SQLRETURN nResult = SQL_SUCCESS; rtl_TextEncoding nTextEncoding = osl_getThreadTextEncoding(); - for ( nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_FIRST, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription); + for ( nResult = (*reinterpret_cast<TSQLDataSources>(m_pDataSources))(m_pImpl->hEnvironment, SQL_FETCH_FIRST, szDSN, + sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription); ; - nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_NEXT, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription) + nResult = (*reinterpret_cast<TSQLDataSources>(m_pDataSources))(m_pImpl->hEnvironment, SQL_FETCH_NEXT, szDSN, + sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription) ) { if (nResult != SQL_SUCCESS) diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index c5490bd959c1..2735acee5de4 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -180,9 +180,6 @@ DlgFilterCrit::~DlgFilterCrit() { } -#define LbText(x) ((x).get_active_text()) -#define LbPos(x) ((x).get_active()) - sal_Int32 DlgFilterCrit::GetOSQLPredicateType( std::u16string_view _rSelectedPredicate ) const { sal_Int32 nPredicateIndex = -1; @@ -512,7 +509,7 @@ void DlgFilterCrit::SelectField(weld::ComboBox& rBox, std::u16string_view rField void DlgFilterCrit::EnableLines() { // enabling/disabling of whole lines - if( LbPos(*m_xLB_WHEREFIELD1) == 0 ) + if( m_xLB_WHEREFIELD1->get_active() == 0 ) { m_xLB_WHEREFIELD2->set_sensitive(false); m_xLB_WHERECOND2->set_sensitive(false); @@ -537,7 +534,7 @@ void DlgFilterCrit::EnableLines() m_xET_WHEREVALUE3->set_sensitive(true); } - if( LbPos(*m_xLB_WHEREFIELD2) == 0 ) + if( m_xLB_WHEREFIELD2->get_active() == 0 ) { m_xLB_WHEREFIELD3->set_sensitive(false); m_xLB_WHERECOND3->set_sensitive(false); @@ -553,7 +550,7 @@ void DlgFilterCrit::EnableLines() } // comparison field equal to NOENTRY - if( LbPos(*m_xLB_WHEREFIELD1) == 0 ) + if( m_xLB_WHEREFIELD1->get_active() == 0 ) { m_xLB_WHERECOMP1->set_sensitive(false); m_xET_WHEREVALUE1->set_sensitive(false); @@ -565,7 +562,7 @@ void DlgFilterCrit::EnableLines() m_xET_WHEREVALUE1->set_sensitive(true); } - if( LbPos(*m_xLB_WHEREFIELD2) == 0 ) + if( m_xLB_WHEREFIELD2->get_active() == 0 ) { m_xLB_WHERECOND2->set_sensitive(false); m_xLB_WHERECOMP2->set_sensitive(false); @@ -579,7 +576,7 @@ void DlgFilterCrit::EnableLines() m_xET_WHEREVALUE2->set_sensitive(true); } - if( LbPos(*m_xLB_WHEREFIELD3) == 0 ) + if( m_xLB_WHEREFIELD3->get_active() == 0 ) { m_xLB_WHERECOND3->set_sensitive(false); m_xLB_WHERECOMP3->set_sensitive(false); @@ -596,18 +593,18 @@ void DlgFilterCrit::EnableLines() // comparison operator equal to ISNULL or ISNOTNULL if(m_xLB_WHERECOMP1->get_count() > 2 && - ((LbPos(*m_xLB_WHERECOMP1) == m_xLB_WHERECOMP1->get_count()-1) || - (LbPos(*m_xLB_WHERECOMP1) == m_xLB_WHERECOMP1->get_count()-2)) ) + ((m_xLB_WHERECOMP1->get_active() == m_xLB_WHERECOMP1->get_count()-1) || + (m_xLB_WHERECOMP1->get_active() == m_xLB_WHERECOMP1->get_count()-2)) ) m_xET_WHEREVALUE1->set_sensitive(false); if(m_xLB_WHERECOMP2->get_count() > 2 && - ((LbPos(*m_xLB_WHERECOMP2) == m_xLB_WHERECOMP2->get_count()-1) || - (LbPos(*m_xLB_WHERECOMP2) == m_xLB_WHERECOMP2->get_count()-2)) ) + ((m_xLB_WHERECOMP2->get_active() == m_xLB_WHERECOMP2->get_count()-1) || + (m_xLB_WHERECOMP2->get_active() == m_xLB_WHERECOMP2->get_count()-2)) ) m_xET_WHEREVALUE2->set_sensitive(false); if(m_xLB_WHERECOMP3->get_count() > 2 && - ((LbPos(*m_xLB_WHERECOMP3) == m_xLB_WHERECOMP3->get_count()-1) || - (LbPos(*m_xLB_WHERECOMP3) == m_xLB_WHERECOMP3->get_count()-2)) ) + ((m_xLB_WHERECOMP3->get_active() == m_xLB_WHERECOMP3->get_count()-1) || + (m_xLB_WHERECOMP3->get_active() == m_xLB_WHERECOMP3->get_count()-2)) ) m_xET_WHEREVALUE3->set_sensitive(false); } @@ -617,17 +614,17 @@ IMPL_LINK( DlgFilterCrit, ListSelectHdl, weld::ComboBox&, rListBox, void ) weld::ComboBox* pComp; if(&rListBox == m_xLB_WHEREFIELD1.get()) { - aName = LbText(*m_xLB_WHEREFIELD1); + aName = m_xLB_WHEREFIELD1->get_active_text(); pComp = m_xLB_WHERECOMP1.get(); } else if(&rListBox == m_xLB_WHEREFIELD2.get()) { - aName = LbText(*m_xLB_WHEREFIELD2); + aName = m_xLB_WHEREFIELD2->get_active_text(); pComp = m_xLB_WHERECOMP2.get(); } else { - aName = LbText(*m_xLB_WHEREFIELD3); + aName = m_xLB_WHEREFIELD3->get_active_text(); pComp = m_xLB_WHERECOMP3.get(); } @@ -677,7 +674,7 @@ void DlgFilterCrit::BuildWherePart() { Sequence<Sequence<PropertyValue> > aFilter(1),aHaving(1); - if( LbPos(*m_xLB_WHEREFIELD1) != 0 ) + if( m_xLB_WHEREFIELD1->get_active() != 0 ) { PropertyValue aValue; if ( getCondition(*m_xLB_WHEREFIELD1,*m_xLB_WHERECOMP1,*m_xET_WHEREVALUE1,aValue) ) @@ -690,7 +687,7 @@ void DlgFilterCrit::BuildWherePart() } } - if( LbPos(*m_xLB_WHEREFIELD2) != 0 ) + if( m_xLB_WHEREFIELD2->get_active() != 0 ) { PropertyValue aValue; Sequence<Sequence<PropertyValue> >& _rValues = aFilter; @@ -705,7 +702,7 @@ void DlgFilterCrit::BuildWherePart() pValues[nPos].getArray()[nAndPos] = aValue; } - if( LbPos(*m_xLB_WHEREFIELD3) != 0 ) + if( m_xLB_WHEREFIELD3->get_active() != 0 ) { PropertyValue aValue; Sequence<Sequence<PropertyValue> >& _rValues = aFilter; diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx index 12a613cb382b..23235824d4e4 100644 --- a/dbaccess/source/ui/inc/directsql.hxx +++ b/dbaccess/source/ui/inc/directsql.hxx @@ -109,17 +109,6 @@ namespace dbaui #endif }; -#ifdef DBG_UTIL -#define CHECK_INVARIANTS(methodname) \ - { \ - const char* pError = impl_CheckInvariants(); \ - if (pError) \ - SAL_WARN("dbaccess.ui", methodname ": " << pError); \ - } -#else -#define CHECK_INVARIANTS(methodname) -#endif - } // namespace dbaui /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index 615620ba6271..7b2ff6d8f6f7 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -569,13 +569,6 @@ bool ORTFImportExport::Read() 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) @@ -597,12 +590,12 @@ bool OHTMLImportExport::Write() if(m_xObject.is()) { m_pStream->WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype ).WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_doctype5 ).WriteChar( '>' ).WriteCharPtr( SAL_NEWLINE_STRING ).WriteCharPtr( SAL_NEWLINE_STRING ); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_html).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); WriteHeader(); - OUT_LF(); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); WriteBody(); - OUT_LF(); - TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html ); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_html, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); return ((*m_pStream).GetError() == ERRCODE_NONE); } @@ -633,12 +626,15 @@ 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).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(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 ); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + IncIndent(-1); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_head, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); } void OHTMLImportExport::WriteBody() @@ -646,17 +642,20 @@ 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->WriteCharPtr( "<!-- " ); OUT_LF(); + m_pStream->WriteCharPtr( "<!-- " ); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); m_pStream->WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body ).WriteCharPtr( " { " ).WriteCharPtr( "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->WriteChar( '}' ); - OUT_LF(); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); m_pStream->WriteCharPtr( " -->" ); - IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style ); - OUT_LF(); + IncIndent(-1); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_style, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); // default Textcolour black m_pStream->WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body ).WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_text ).WriteChar( '=' ); @@ -668,11 +667,12 @@ void OHTMLImportExport::WriteBody() m_pStream->WriteCharPtr( " " OOO_STRING_SVTOOLS_HTML_O_bgcolor "=" ); HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); - m_pStream->WriteChar( '>' ); OUT_LF(); + m_pStream->WriteChar( '>' ); + m_pStream->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); WriteTables(); - TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_body, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); } void OHTMLImportExport::WriteTables() @@ -719,27 +719,27 @@ void OHTMLImportExport::WriteTables() "=1"; IncIndent(1); - TAG_ON( aStrOut.getStr() ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, aStrOut.getStr()); 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->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); // </FONT> IncIndent(1); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); IncIndent(1); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); if(m_xObject.is()) { @@ -783,11 +783,11 @@ void OHTMLImportExport::WriteTables() } 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).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); IncIndent(1); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); // 2. and now the data Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY); @@ -796,7 +796,7 @@ void OHTMLImportExport::WriteTables() while(m_xResultSet->next()) { IncIndent(1); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tablerow).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); ++kk; for(sal_Int32 i=1;i<=aNames.getLength();++i) @@ -821,21 +821,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).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(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).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_thead, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); IncIndent(1); - TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(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->WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_tbody, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); + IncIndent(-1); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, OOO_STRING_SVTOOLS_HTML_table, false).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); } void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal_Int32 nHeightPixel, const char* pChar, @@ -880,7 +883,7 @@ void OHTMLImportExport::WriteCell( sal_Int32 nFormat, sal_Int32 nWidthPixel, sal } } - TAG_ON( aStrTD.getStr() ); + HTMLOutFuncs::Out_AsciiTag(*m_pStream, aStrTD.getStr()); FontOn(); @@ -889,24 +892,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); - 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).WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(GetIndentStr()); } void OHTMLImportExport::FontOn() @@ -943,7 +946,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 |