1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #include "TokenWriter.hxx" 27cdf0e10cSrcweir #include <tools/debug.hxx> 28cdf0e10cSrcweir #include <tools/diagnose_ex.h> 29cdf0e10cSrcweir #include "RtfReader.hxx" 30cdf0e10cSrcweir #include "HtmlReader.hxx" 31cdf0e10cSrcweir #include "dbustrings.hrc" 32cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 33cdf0e10cSrcweir #include <comphelper/types.hxx> 34cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 35cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 36cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> 37cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp> 38cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 39cdf0e10cSrcweir #include <com/sun/star/sdb/XQueriesSupplier.hpp> 40cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 41cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp> 42cdf0e10cSrcweir #include <com/sun/star/awt/FontStrikeout.hpp> 43cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp> 44cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp> 45cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 46cdf0e10cSrcweir #include <svtools/htmlkywd.hxx> 47cdf0e10cSrcweir #include <svtools/rtfkeywd.hxx> 48cdf0e10cSrcweir #include <tools/color.hxx> 49cdf0e10cSrcweir #include <svtools/htmlout.hxx> 50cdf0e10cSrcweir #include <sfx2/frmhtmlw.hxx> 51cdf0e10cSrcweir #include <svl/numuno.hxx> 52cdf0e10cSrcweir #include <vcl/svapp.hxx> 53cdf0e10cSrcweir #include "UITools.hxx" 54cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 55cdf0e10cSrcweir #include <vcl/outdev.hxx> 56cdf0e10cSrcweir #include <svtools/rtfout.hxx> 57cdf0e10cSrcweir #include <svtools/htmlcfg.hxx> 58cdf0e10cSrcweir #include <connectivity/formattedcolumnvalue.hxx> 59cdf0e10cSrcweir #include <unotools/syslocale.hxx> 60cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 61cdf0e10cSrcweir #include <rtl/logfile.hxx> 62cdf0e10cSrcweir 63cdf0e10cSrcweir using namespace dbaui; 64cdf0e10cSrcweir using namespace dbtools; 65cdf0e10cSrcweir using namespace svx; 66cdf0e10cSrcweir using namespace ::com::sun::star; 67cdf0e10cSrcweir using namespace ::com::sun::star::uno; 68cdf0e10cSrcweir using namespace ::com::sun::star::beans; 69cdf0e10cSrcweir using namespace ::com::sun::star::container; 70cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 71cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 72cdf0e10cSrcweir using namespace ::com::sun::star::frame; 73cdf0e10cSrcweir using namespace ::com::sun::star::lang; 74cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 75cdf0e10cSrcweir using namespace ::com::sun::star::awt; 76cdf0e10cSrcweir using namespace ::com::sun::star::util; 77cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 78cdf0e10cSrcweir 79cdf0e10cSrcweir #if defined(UNX) 80cdf0e10cSrcweir const char __FAR_DATA ODatabaseImportExport::sNewLine = '\012'; 81cdf0e10cSrcweir #else 82cdf0e10cSrcweir const char __FAR_DATA ODatabaseImportExport::sNewLine[] = "\015\012"; 83cdf0e10cSrcweir #endif 84cdf0e10cSrcweir 85cdf0e10cSrcweir const static char __FAR_DATA sMyBegComment[] = "<!-- "; 86cdf0e10cSrcweir const static char __FAR_DATA sMyEndComment[] = " -->"; 87cdf0e10cSrcweir const static char __FAR_DATA sFontFamily[] = "font-family: "; 88cdf0e10cSrcweir const static char __FAR_DATA sFontSize[] = "font-size: "; 89cdf0e10cSrcweir 90cdf0e10cSrcweir #define SBA_FORMAT_SELECTION_COUNT 4 91cdf0e10cSrcweir #define CELL_X 1437 92cdf0e10cSrcweir 93cdf0e10cSrcweir DBG_NAME(ODatabaseImportExport) 94cdf0e10cSrcweir //====================================================================== 95cdf0e10cSrcweir ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor, 96cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _rM, 97cdf0e10cSrcweir const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, 98cdf0e10cSrcweir const String& rExchange) 99cdf0e10cSrcweir :m_bBookmarkSelection( sal_False ) 100cdf0e10cSrcweir ,m_xFormatter(_rxNumberF) 101cdf0e10cSrcweir ,m_xFactory(_rM) 102cdf0e10cSrcweir ,m_nCommandType(CommandType::TABLE) 103cdf0e10cSrcweir ,m_bNeedToReInitialize(sal_False) 104cdf0e10cSrcweir ,m_pReader(NULL) 105cdf0e10cSrcweir ,m_pRowMarker(NULL) 106cdf0e10cSrcweir ,m_bInInitialize(sal_False) 107cdf0e10cSrcweir ,m_bCheckOnly(sal_False) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" ); 110cdf0e10cSrcweir DBG_CTOR(ODatabaseImportExport,NULL); 111cdf0e10cSrcweir 112cdf0e10cSrcweir m_eDestEnc = osl_getThreadTextEncoding(); 113cdf0e10cSrcweir 114cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 115cdf0e10cSrcweir impl_initFromDescriptor( _aDataDescriptor, false ); 116cdf0e10cSrcweir 117cdf0e10cSrcweir xub_StrLen nCount = rExchange.GetTokenCount(char(11)); 118cdf0e10cSrcweir if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len()) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir m_pRowMarker = new sal_Int32[nCount-SBA_FORMAT_SELECTION_COUNT]; 121cdf0e10cSrcweir for(xub_StrLen i=SBA_FORMAT_SELECTION_COUNT;i<nCount;++i) 122cdf0e10cSrcweir m_pRowMarker[i-SBA_FORMAT_SELECTION_COUNT] = rExchange.GetToken(i,char(11)).ToInt32(); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir // ----------------------------------------------------------------------------- 127cdf0e10cSrcweir // import data 128cdf0e10cSrcweir ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection, 129cdf0e10cSrcweir const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM ) 130cdf0e10cSrcweir :m_bBookmarkSelection( sal_False ) 131cdf0e10cSrcweir ,m_xConnection(_rxConnection) 132cdf0e10cSrcweir ,m_xFormatter(_rxNumberF) 133cdf0e10cSrcweir ,m_xFactory(_rM) 134cdf0e10cSrcweir ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE) 135cdf0e10cSrcweir ,m_bNeedToReInitialize(sal_False) 136cdf0e10cSrcweir ,m_pReader(NULL) 137cdf0e10cSrcweir ,m_pRowMarker(NULL) 138cdf0e10cSrcweir ,m_bInInitialize(sal_False) 139cdf0e10cSrcweir ,m_bCheckOnly(sal_False) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" ); 142cdf0e10cSrcweir DBG_CTOR(ODatabaseImportExport,NULL); 143cdf0e10cSrcweir m_eDestEnc = osl_getThreadTextEncoding(); 144cdf0e10cSrcweir try 145cdf0e10cSrcweir { 146cdf0e10cSrcweir SvtSysLocale aSysLocale; 147cdf0e10cSrcweir m_aLocale = aSysLocale.GetLocaleData().getLocale(); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir catch(Exception&) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir } 152cdf0e10cSrcweir } 153cdf0e10cSrcweir //------------------------------------------------------------------- 154cdf0e10cSrcweir ODatabaseImportExport::~ODatabaseImportExport() 155cdf0e10cSrcweir { 156cdf0e10cSrcweir DBG_DTOR(ODatabaseImportExport,NULL); 157cdf0e10cSrcweir acquire(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir dispose(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir if(m_pReader) 162cdf0e10cSrcweir m_pReader->release(); 163cdf0e10cSrcweir delete m_pRowMarker; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166cdf0e10cSrcweir void ODatabaseImportExport::dispose() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" ); 169cdf0e10cSrcweir DBG_CHKTHIS(ODatabaseImportExport,NULL); 170cdf0e10cSrcweir // remove me as listener 171cdf0e10cSrcweir Reference< XComponent > xComponent(m_xConnection, UNO_QUERY); 172cdf0e10cSrcweir if (xComponent.is()) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY); 175cdf0e10cSrcweir xComponent->removeEventListener(xEvt); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir m_xConnection.clear(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir ::comphelper::disposeComponent(m_xRow); 180cdf0e10cSrcweir 181cdf0e10cSrcweir m_xObject.clear(); 182cdf0e10cSrcweir m_xResultSetMetaData.clear(); 183cdf0e10cSrcweir m_xResultSet.clear(); 184cdf0e10cSrcweir m_xRow.clear(); 185cdf0e10cSrcweir m_xRowLocate.clear(); 186cdf0e10cSrcweir m_xFormatter.clear(); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir // ----------------------------------------------------------------------------- 189cdf0e10cSrcweir void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" ); 192cdf0e10cSrcweir DBG_CHKTHIS(ODatabaseImportExport,NULL); 193cdf0e10cSrcweir Reference<XConnection> xCon(Source.Source,UNO_QUERY); 194cdf0e10cSrcweir if(m_xConnection.is() && m_xConnection == xCon) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir m_xConnection.clear(); 197cdf0e10cSrcweir dispose(); 198cdf0e10cSrcweir m_bNeedToReInitialize = true; 199cdf0e10cSrcweir //if(!m_bInInitialize) 200cdf0e10cSrcweir // initialize(); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir } 203cdf0e10cSrcweir // ----------------------------------------------------------------------------- 204cdf0e10cSrcweir void ODatabaseImportExport::initialize( const ODataAccessDescriptor& _aDataDescriptor ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" ); 207cdf0e10cSrcweir impl_initFromDescriptor( _aDataDescriptor, true ); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir // ----------------------------------------------------------------------------- 211cdf0e10cSrcweir void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initFromDescriptor" ); 214cdf0e10cSrcweir DBG_CHKTHIS(ODatabaseImportExport,NULL); 215cdf0e10cSrcweir if ( !_bPlusDefaultInit ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir m_sDataSourceName = _aDataDescriptor.getDataSource(); 218cdf0e10cSrcweir _aDataDescriptor[daCommandType] >>= m_nCommandType; 219cdf0e10cSrcweir _aDataDescriptor[daCommand] >>= m_sName; 220cdf0e10cSrcweir // some additonal information 221cdf0e10cSrcweir if(_aDataDescriptor.has(daConnection)) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir Reference< XConnection > xPureConn( _aDataDescriptor[daConnection], UNO_QUERY ); 224cdf0e10cSrcweir m_xConnection.reset( xPureConn, SharedConnection::NoTakeOwnership ); 225cdf0e10cSrcweir Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY); 226cdf0e10cSrcweir Reference< XComponent > xComponent(m_xConnection, UNO_QUERY); 227cdf0e10cSrcweir if (xComponent.is() && xEvt.is()) 228cdf0e10cSrcweir xComponent->addEventListener(xEvt); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir if ( _aDataDescriptor.has( daSelection ) ) 232cdf0e10cSrcweir _aDataDescriptor[ daSelection ] >>= m_aSelection; 233cdf0e10cSrcweir 234cdf0e10cSrcweir if ( _aDataDescriptor.has( daBookmarkSelection ) ) 235cdf0e10cSrcweir _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection; 236cdf0e10cSrcweir 237cdf0e10cSrcweir if ( _aDataDescriptor.has( daCursor ) ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir _aDataDescriptor[ daCursor ] >>= m_xResultSet; 240cdf0e10cSrcweir m_xRowLocate.set( m_xResultSet, UNO_QUERY ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir if ( m_aSelection.getLength() != 0 ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir if ( !m_xResultSet.is() ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" ); 248cdf0e10cSrcweir m_aSelection.realloc( 0 ); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir if ( m_aSelection.getLength() != 0 ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir if ( m_bBookmarkSelection && !m_xRowLocate.is() ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" ); 257cdf0e10cSrcweir m_aSelection.realloc( 0 ); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261cdf0e10cSrcweir else 262cdf0e10cSrcweir initialize(); 263cdf0e10cSrcweir 264cdf0e10cSrcweir try 265cdf0e10cSrcweir { 266cdf0e10cSrcweir SvtSysLocale aSysLocale; 267cdf0e10cSrcweir m_aLocale = aSysLocale.GetLocaleData().getLocale(); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir catch(Exception&) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir } 272cdf0e10cSrcweir } 273cdf0e10cSrcweir // ----------------------------------------------------------------------------- 274cdf0e10cSrcweir void ODatabaseImportExport::initialize() 275cdf0e10cSrcweir { 276cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" ); 277cdf0e10cSrcweir DBG_CHKTHIS(ODatabaseImportExport,NULL); 278cdf0e10cSrcweir m_bInInitialize = sal_True; 279cdf0e10cSrcweir m_bNeedToReInitialize = false; 280cdf0e10cSrcweir 281cdf0e10cSrcweir if ( !m_xConnection.is() ) 282cdf0e10cSrcweir { // we need a connection 283cdf0e10cSrcweir OSL_ENSURE(m_sDataSourceName.getLength(),"There must be a datsource name!"); 284cdf0e10cSrcweir Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(m_xFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); 285cdf0e10cSrcweir Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY); 286cdf0e10cSrcweir 287cdf0e10cSrcweir Reference< XConnection > xConnection; 288cdf0e10cSrcweir SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xFactory, xEvt, xConnection ); 289cdf0e10cSrcweir m_xConnection.reset( xConnection ); 290cdf0e10cSrcweir 291cdf0e10cSrcweir if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION) 292cdf0e10cSrcweir throw *static_cast<const SQLException*>(aInfo); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir Reference<XNameAccess> xNameAccess; 296cdf0e10cSrcweir switch(m_nCommandType) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir case CommandType::TABLE: 299cdf0e10cSrcweir { 300cdf0e10cSrcweir // only for tables 301cdf0e10cSrcweir Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY); 302cdf0e10cSrcweir if(xSup.is()) 303cdf0e10cSrcweir xNameAccess = xSup->getTables(); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir break; 306cdf0e10cSrcweir case CommandType::QUERY: 307cdf0e10cSrcweir { 308cdf0e10cSrcweir Reference<XQueriesSupplier> xSup(m_xConnection,UNO_QUERY); 309cdf0e10cSrcweir if(xSup.is()) 310cdf0e10cSrcweir xNameAccess = xSup->getQueries(); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir break; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir if(xNameAccess.is() && xNameAccess->hasByName(m_sName)) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir Reference<XPropertySet> xSourceObject; 317cdf0e10cSrcweir xNameAccess->getByName(m_sName) >>= m_xObject; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir if(m_xObject.is()) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir try 323cdf0e10cSrcweir { 324cdf0e10cSrcweir if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT)) 325cdf0e10cSrcweir m_xObject->getPropertyValue(PROPERTY_FONT) >>= m_aFont; 326cdf0e10cSrcweir 327cdf0e10cSrcweir // the result set may be already set with the datadescriptor 328cdf0e10cSrcweir if ( !m_xResultSet.is() ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.RowSet" ) ), UNO_QUERY ); 331cdf0e10cSrcweir Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW ); 332cdf0e10cSrcweir xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) ); 333cdf0e10cSrcweir xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) ); 334cdf0e10cSrcweir xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) ); 335cdf0e10cSrcweir Reference< XRowSet > xRowSet( xProp, UNO_QUERY ); 336cdf0e10cSrcweir xRowSet->execute(); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir impl_initializeRowMember_throw(); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir catch(Exception& ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir m_xRow = NULL; 343cdf0e10cSrcweir m_xResultSetMetaData = NULL; 344cdf0e10cSrcweir ::comphelper::disposeComponent(m_xResultSet); 345cdf0e10cSrcweir throw; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } 348cdf0e10cSrcweir if ( !m_aFont.Name.getLength() ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir Font aApplicationFont = OutputDevice::GetDefaultFont( 351cdf0e10cSrcweir DEFAULTFONT_SANS_UNICODE, 352cdf0e10cSrcweir Application::GetSettings().GetUILanguage(), 353cdf0e10cSrcweir DEFAULTFONT_FLAGS_ONLYONE 354cdf0e10cSrcweir ); 355cdf0e10cSrcweir m_aFont = VCLUnoHelper::CreateFontDescriptor( aApplicationFont ); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir m_bInInitialize = sal_False; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir // ----------------------------------------------------------------------------- 361cdf0e10cSrcweir sal_Bool ODatabaseImportExport::Write() 362cdf0e10cSrcweir { 363cdf0e10cSrcweir if ( m_bNeedToReInitialize ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir if ( !m_bInInitialize ) 366cdf0e10cSrcweir initialize(); 367cdf0e10cSrcweir } // if ( m_bNeedToReInitialize ) 368cdf0e10cSrcweir return sal_True; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir // ----------------------------------------------------------------------------- 371cdf0e10cSrcweir sal_Bool ODatabaseImportExport::Read() 372cdf0e10cSrcweir { 373cdf0e10cSrcweir if ( m_bNeedToReInitialize ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir if ( !m_bInInitialize ) 376cdf0e10cSrcweir initialize(); 377cdf0e10cSrcweir } // if ( m_bNeedToReInitialize ) 378cdf0e10cSrcweir return sal_True; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir // ----------------------------------------------------------------------------- 381cdf0e10cSrcweir void ODatabaseImportExport::impl_initializeRowMember_throw() 382cdf0e10cSrcweir { 383cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" ); 384cdf0e10cSrcweir if ( !m_xRow.is() && m_xResultSet.is() ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir m_xRow.set( m_xResultSet, UNO_QUERY ); 387cdf0e10cSrcweir m_xRowLocate.set( m_xResultSet, UNO_QUERY ); 388cdf0e10cSrcweir m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData(); 389cdf0e10cSrcweir Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW); 390cdf0e10cSrcweir m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir } 393cdf0e10cSrcweir //====================================================================== 394cdf0e10cSrcweir sal_Bool ORTFImportExport::Write() 395cdf0e10cSrcweir { 396cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Write" ); 397cdf0e10cSrcweir ODatabaseImportExport::Write(); 398cdf0e10cSrcweir (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_RTF; 399cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ANSI << ODatabaseImportExport::sNewLine; 400cdf0e10cSrcweir rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252; 401cdf0e10cSrcweir 402cdf0e10cSrcweir /* 403cdf0e10cSrcweir // Access RTF Export Beispiel 404cdf0e10cSrcweir {\rtf1\ansi 405cdf0e10cSrcweir {\colortbl\red0\green0\blue0;\red255\green255\blue255;\red192\green192\blue192;} 406cdf0e10cSrcweir {\fonttbl\f0\fcharset0\fnil MS Sans Serif;\f1\fcharset0\fnil Arial;\f2\fcharset0\fnil Arial;} 407cdf0e10cSrcweir \trowd\trgaph40 408cdf0e10cSrcweir \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx1437 409cdf0e10cSrcweir \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx2874 410cdf0e10cSrcweir { 411cdf0e10cSrcweir \trrh-270\pard\intbl 412cdf0e10cSrcweir {\qc\fs20\b\f1\cf0\cb2 text\cell} 413cdf0e10cSrcweir \pard\intbl 414cdf0e10cSrcweir {\qc\fs20\b\f1\cf0\cb2 datum\cell} 415cdf0e10cSrcweir \pard\intbl\row 416cdf0e10cSrcweir } 417cdf0e10cSrcweir \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 418cdf0e10cSrcweir {\trrh-270\pard\intbl 419cdf0e10cSrcweir {\ql\fs20\f2\cf0\cb1 heute\cell} 420cdf0e10cSrcweir \pard\intbl 421cdf0e10cSrcweir {\qr\fs20\f2\cf0\cb1 10.11.98\cell} 422cdf0e10cSrcweir \pard\intbl\row 423cdf0e10cSrcweir } 424cdf0e10cSrcweir \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 425cdf0e10cSrcweir {\trrh-270\pard\intbl 426cdf0e10cSrcweir {\ql\fs20\f2\cf0\cb1 morgen\cell} 427cdf0e10cSrcweir \pard\intbl 428cdf0e10cSrcweir {\qr\fs20\f2\cf0\cb1 11.11.98\cell} 429cdf0e10cSrcweir \pard\intbl\row 430cdf0e10cSrcweir } 431cdf0e10cSrcweir \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 432cdf0e10cSrcweir {\trrh-270\pard\intbl 433cdf0e10cSrcweir {\ql\fs20\f2\cf0\cb1 bruder\cell} 434cdf0e10cSrcweir \pard\intbl 435cdf0e10cSrcweir {\qr\fs20\f2\cf0\cb1 21.04.98\cell} 436cdf0e10cSrcweir \pard\intbl\row 437cdf0e10cSrcweir } 438cdf0e10cSrcweir \trowd\trgaph40 439cdf0e10cSrcweir \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx 440cdf0e10cSrcweir \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874 441cdf0e10cSrcweir {\trrh-270\pard\intbl 442cdf0e10cSrcweir {\ql\fs20\f2\cf0\cb1 vater\cell} 443cdf0e10cSrcweir \pard\intbl 444cdf0e10cSrcweir {\qr\fs20\f2\cf0\cb1 28.06.98\cell} 445cdf0e10cSrcweir \pard\intbl\row 446cdf0e10cSrcweir } 447cdf0e10cSrcweir } 448cdf0e10cSrcweir */ 449cdf0e10cSrcweir 450cdf0e10cSrcweir sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight ); 451cdf0e10cSrcweir sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant ); 452cdf0e10cSrcweir sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline ); 453cdf0e10cSrcweir sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout ); 454cdf0e10cSrcweir 455cdf0e10cSrcweir sal_Int32 nColor = 0; 456cdf0e10cSrcweir if(m_xObject.is()) 457cdf0e10cSrcweir m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; 458cdf0e10cSrcweir ::Color aColor(nColor); 459cdf0e10cSrcweir 460cdf0e10cSrcweir ByteString aFonts(String(m_aFont.Name),eDestEnc); 461cdf0e10cSrcweir if(!aFonts.Len()) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir String aName = Application::GetSettings().GetStyleSettings().GetAppFont().GetName(); 464cdf0e10cSrcweir aFonts = ByteString (aName,eDestEnc); 465cdf0e10cSrcweir } 466cdf0e10cSrcweir ::rtl::OString aFormat("\\fcharset0\\fnil "); 467cdf0e10cSrcweir ByteString aFontNr; 468cdf0e10cSrcweir 469cdf0e10cSrcweir (*m_pStream) << "{\\fonttbl"; 470cdf0e10cSrcweir xub_StrLen nTokenCount = aFonts.GetTokenCount(); 471cdf0e10cSrcweir for(xub_StrLen j=0;j<nTokenCount;++j) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir (*m_pStream) << "\\f"; 474cdf0e10cSrcweir m_pStream->WriteNumber(j); 475cdf0e10cSrcweir (*m_pStream) << aFormat; 476cdf0e10cSrcweir (*m_pStream) << aFonts.GetToken(j).GetBuffer(); 477cdf0e10cSrcweir (*m_pStream) << ';'; 478cdf0e10cSrcweir } 479cdf0e10cSrcweir (*m_pStream) << '}' ; 480cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 481cdf0e10cSrcweir // write the rtf color table 482cdf0e10cSrcweir (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL << OOO_STRING_SVTOOLS_RTF_RED; 483cdf0e10cSrcweir m_pStream->WriteNumber(aColor.GetRed()); 484cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_GREEN; 485cdf0e10cSrcweir m_pStream->WriteNumber(aColor.GetGreen()); 486cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_BLUE; 487cdf0e10cSrcweir m_pStream->WriteNumber(aColor.GetBlue()); 488cdf0e10cSrcweir 489cdf0e10cSrcweir (*m_pStream) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}" 490cdf0e10cSrcweir << ODatabaseImportExport::sNewLine; 491cdf0e10cSrcweir 492cdf0e10cSrcweir ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl"); 493cdf0e10cSrcweir ::rtl::OString aFS("\\fs20\\f0\\cf0\\cb2"); 494cdf0e10cSrcweir ::rtl::OString aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx"); 495cdf0e10cSrcweir 496cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH; 497cdf0e10cSrcweir m_pStream->WriteNumber(40); 498cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 499cdf0e10cSrcweir 500cdf0e10cSrcweir if(m_xObject.is()) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY); 503cdf0e10cSrcweir Reference<XNameAccess> xColumns = xColSup->getColumns(); 504cdf0e10cSrcweir Sequence< ::rtl::OUString> aNames(xColumns->getElementNames()); 505cdf0e10cSrcweir const ::rtl::OUString* pIter = aNames.getConstArray(); 506cdf0e10cSrcweir 507cdf0e10cSrcweir sal_Int32 nCount = aNames.getLength(); 508cdf0e10cSrcweir sal_Bool bUseResultMetaData = sal_False; 509cdf0e10cSrcweir if ( !nCount ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir nCount = m_xResultSetMetaData->getColumnCount(); 512cdf0e10cSrcweir bUseResultMetaData = sal_True; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir for( sal_Int32 i=1; i<=nCount; ++i ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir (*m_pStream) << aCell1; 518cdf0e10cSrcweir m_pStream->WriteNumber(i*CELL_X); 519cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 520cdf0e10cSrcweir } 521cdf0e10cSrcweir 522cdf0e10cSrcweir // Spaltenbeschreibung 523cdf0e10cSrcweir (*m_pStream) << '{' << ODatabaseImportExport::sNewLine; 524cdf0e10cSrcweir (*m_pStream) << aTRRH; 525cdf0e10cSrcweir 526cdf0e10cSrcweir 527cdf0e10cSrcweir ::rtl::OString* pHorzChar = new ::rtl::OString[nCount]; 528cdf0e10cSrcweir 529cdf0e10cSrcweir for ( sal_Int32 i=1; i <= nCount; ++i ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir sal_Int32 nAlign = 0; 532cdf0e10cSrcweir ::rtl::OUString sColumnName; 533cdf0e10cSrcweir if ( bUseResultMetaData ) 534cdf0e10cSrcweir sColumnName = m_xResultSetMetaData->getColumnName(i); 535cdf0e10cSrcweir else 536cdf0e10cSrcweir { 537cdf0e10cSrcweir sColumnName = *pIter; 538cdf0e10cSrcweir Reference<XPropertySet> xColumn; 539cdf0e10cSrcweir xColumns->getByName(sColumnName) >>= xColumn; 540cdf0e10cSrcweir xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; 541cdf0e10cSrcweir ++pIter; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir const char* pChar; 545cdf0e10cSrcweir switch( nAlign ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir case 1: pChar = OOO_STRING_SVTOOLS_RTF_QC; break; 548cdf0e10cSrcweir case 2: pChar = OOO_STRING_SVTOOLS_RTF_QR; break; 549cdf0e10cSrcweir case 0: 550cdf0e10cSrcweir default:pChar = OOO_STRING_SVTOOLS_RTF_QL; break; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir pHorzChar[i-1] = pChar; // um sp"ater nicht immer im ITEMSET zuw"uhlen 554cdf0e10cSrcweir 555cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 556cdf0e10cSrcweir (*m_pStream) << '{'; 557cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_QC; // column header always centered 558cdf0e10cSrcweir 559cdf0e10cSrcweir if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B; 560cdf0e10cSrcweir if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I; 561cdf0e10cSrcweir if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL; 562cdf0e10cSrcweir if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE; 563cdf0e10cSrcweir 564cdf0e10cSrcweir (*m_pStream) << aFS; 565cdf0e10cSrcweir (*m_pStream) << ' '; 566cdf0e10cSrcweir RTFOutFuncs::Out_String(*m_pStream,sColumnName,eDestEnc); 567cdf0e10cSrcweir 568cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL; 569cdf0e10cSrcweir (*m_pStream) << '}'; 570cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 571cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW; 575cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine << '}'; 576cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 577cdf0e10cSrcweir 578cdf0e10cSrcweir ::comphelper::ComponentContext aContext(m_xFactory); 579cdf0e10cSrcweir Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY); 580cdf0e10cSrcweir sal_Int32 k=1; 581cdf0e10cSrcweir sal_Int32 kk=0; 582cdf0e10cSrcweir if ( m_aSelection.getLength() ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir const Any* pSelIter = m_aSelection.getConstArray(); 585cdf0e10cSrcweir const Any* pEnd = pSelIter + m_aSelection.getLength(); 586cdf0e10cSrcweir 587cdf0e10cSrcweir sal_Bool bContinue = sal_True; 588cdf0e10cSrcweir for( ; pSelIter != pEnd && bContinue; ++pSelIter ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir if ( m_bBookmarkSelection ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir bContinue = m_xRowLocate->moveToBookmark( *pSelIter ); 593cdf0e10cSrcweir } 594cdf0e10cSrcweir else 595cdf0e10cSrcweir { 596cdf0e10cSrcweir sal_Int32 nPos = -1; 597cdf0e10cSrcweir OSL_VERIFY( *pSelIter >>= nPos ); 598cdf0e10cSrcweir bContinue = ( m_xResultSet->absolute( nPos ) ); 599cdf0e10cSrcweir } 600cdf0e10cSrcweir 601cdf0e10cSrcweir if ( bContinue ) 602cdf0e10cSrcweir appendRow( pHorzChar, nCount, k, kk ); 603cdf0e10cSrcweir } 604cdf0e10cSrcweir } 605cdf0e10cSrcweir else 606cdf0e10cSrcweir { 607cdf0e10cSrcweir m_xResultSet->beforeFirst(); // set back before the first row 608cdf0e10cSrcweir while(m_xResultSet->next()) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir appendRow(pHorzChar,nCount,k,kk); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir delete [] pHorzChar; 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir (*m_pStream) << '}' << ODatabaseImportExport::sNewLine; 617cdf0e10cSrcweir (*m_pStream) << (sal_uInt8) 0; 618cdf0e10cSrcweir return ((*m_pStream).GetError() == SVSTREAM_OK); 619cdf0e10cSrcweir } 620cdf0e10cSrcweir // ----------------------------------------------------------------------------- 621cdf0e10cSrcweir void ORTFImportExport::appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir if(!m_pRowMarker || m_pRowMarker[kk] == k) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir ++kk; 626cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH; 627cdf0e10cSrcweir m_pStream->WriteNumber(40); 628cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 629cdf0e10cSrcweir 630cdf0e10cSrcweir static const ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx"); 631cdf0e10cSrcweir static const ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl"); 632cdf0e10cSrcweir 633cdf0e10cSrcweir for ( sal_Int32 i=1; i<=_nColumnCount; ++i ) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir (*m_pStream) << aCell2; 636cdf0e10cSrcweir m_pStream->WriteNumber(i*CELL_X); 637cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir const sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight ); 641cdf0e10cSrcweir const sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant ); 642cdf0e10cSrcweir const sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline ); 643cdf0e10cSrcweir const sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout ); 644cdf0e10cSrcweir static const ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1"); 645cdf0e10cSrcweir ::comphelper::ComponentContext aContext(m_xFactory); 646cdf0e10cSrcweir Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY); 647cdf0e10cSrcweir 648cdf0e10cSrcweir (*m_pStream) << '{'; 649cdf0e10cSrcweir (*m_pStream) << aTRRH; 650cdf0e10cSrcweir for ( sal_Int32 i=1; i <= _nColumnCount; ++i ) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 653cdf0e10cSrcweir (*m_pStream) << '{'; 654cdf0e10cSrcweir (*m_pStream) << pHorzChar[i-1]; 655cdf0e10cSrcweir 656cdf0e10cSrcweir if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B; 657cdf0e10cSrcweir if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I; 658cdf0e10cSrcweir if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL; 659cdf0e10cSrcweir if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE; 660cdf0e10cSrcweir 661cdf0e10cSrcweir (*m_pStream) << aFS2; 662cdf0e10cSrcweir (*m_pStream) << ' '; 663cdf0e10cSrcweir 664cdf0e10cSrcweir try 665cdf0e10cSrcweir { 666cdf0e10cSrcweir Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW); 667cdf0e10cSrcweir dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn); 668cdf0e10cSrcweir ::rtl::OUString sValue = aFormatedValue.getFormattedValue(); 669cdf0e10cSrcweir // m_xRow->getString(i); 670cdf0e10cSrcweir //if (!m_xRow->wasNull()) 671cdf0e10cSrcweir if ( sValue.getLength() ) 672cdf0e10cSrcweir RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc); 673cdf0e10cSrcweir } 674cdf0e10cSrcweir catch (Exception&) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir OSL_ENSURE(0,"RTF WRITE!"); 677cdf0e10cSrcweir } 678cdf0e10cSrcweir 679cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL; 680cdf0e10cSrcweir (*m_pStream) << '}'; 681cdf0e10cSrcweir (*m_pStream) << ODatabaseImportExport::sNewLine; 682cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL; 683cdf0e10cSrcweir } 684cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine; 685cdf0e10cSrcweir (*m_pStream) << '}'; 686cdf0e10cSrcweir } 687cdf0e10cSrcweir ++k; 688cdf0e10cSrcweir } 689cdf0e10cSrcweir //------------------------------------------------------------------- 690cdf0e10cSrcweir sal_Bool ORTFImportExport::Read() 691cdf0e10cSrcweir { 692cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Read" ); 693cdf0e10cSrcweir ODatabaseImportExport::Read(); 694cdf0e10cSrcweir SvParserState eState = SVPAR_ERROR; 695cdf0e10cSrcweir if ( m_pStream ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir m_pReader = new ORTFReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory); 698cdf0e10cSrcweir ((ORTFReader*)m_pReader)->AddRef(); 699cdf0e10cSrcweir if ( isCheckEnabled() ) 700cdf0e10cSrcweir m_pReader->enableCheckOnly(); 701cdf0e10cSrcweir eState = ((ORTFReader*)m_pReader)->CallParser(); 702cdf0e10cSrcweir m_pReader->release(); 703cdf0e10cSrcweir m_pReader = NULL; 704cdf0e10cSrcweir } 705cdf0e10cSrcweir 706cdf0e10cSrcweir return eState != SVPAR_ERROR; 707cdf0e10cSrcweir } 708cdf0e10cSrcweir //------------------------------------------------------------------- 709cdf0e10cSrcweir //=================================================================== 710cdf0e10cSrcweir const sal_Int16 __FAR_DATA OHTMLImportExport::nDefaultFontSize[SBA_HTML_FONTSIZES] = 711cdf0e10cSrcweir { 712cdf0e10cSrcweir HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT, 713cdf0e10cSrcweir HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT 714cdf0e10cSrcweir }; 715cdf0e10cSrcweir 716cdf0e10cSrcweir sal_Int16 OHTMLImportExport::nFontSize[SBA_HTML_FONTSIZES] = { 0 }; 717cdf0e10cSrcweir 718cdf0e10cSrcweir const sal_Int16 OHTMLImportExport::nCellSpacing = 0; 719cdf0e10cSrcweir 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"; 720cdf0e10cSrcweir 721cdf0e10cSrcweir //======================================================================== 722cdf0e10cSrcweir // Makros fuer HTML-Export 723cdf0e10cSrcweir //======================================================================== 724cdf0e10cSrcweir #define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine) 725cdf0e10cSrcweir #define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag ) 726cdf0e10cSrcweir #define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, sal_False ) 727cdf0e10cSrcweir #define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str ) 728cdf0e10cSrcweir #define OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine << GetIndentStr() 729cdf0e10cSrcweir #define lcl_OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine 730cdf0e10cSrcweir #define TAG_ON_LF( tag ) (TAG_ON( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr()) 731cdf0e10cSrcweir #define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr()) 732cdf0e10cSrcweir #define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule ) 733cdf0e10cSrcweir #define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine << GetIndentStr()) 734cdf0e10cSrcweir #define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine) 735cdf0e10cSrcweir 736cdf0e10cSrcweir //------------------------------------------------------------------- 737cdf0e10cSrcweir OHTMLImportExport::OHTMLImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor, 738cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _rM, 739cdf0e10cSrcweir const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF, 740cdf0e10cSrcweir const String& rExchange) 741cdf0e10cSrcweir : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange) 742cdf0e10cSrcweir ,m_nIndent(0) 743cdf0e10cSrcweir #ifdef DBG_UTIL 744cdf0e10cSrcweir ,m_bCheckFont(sal_False) 745cdf0e10cSrcweir #endif 746cdf0e10cSrcweir { 747cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::OHTMLImportExport" ); 748cdf0e10cSrcweir // set HTML configuration 749cdf0e10cSrcweir SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); 750cdf0e10cSrcweir m_eDestEnc = pHtmlOptions->GetTextEncoding(); 751cdf0e10cSrcweir strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource))); 752cdf0e10cSrcweir sIndent[0] = 0; 753cdf0e10cSrcweir } 754cdf0e10cSrcweir //------------------------------------------------------------------- 755cdf0e10cSrcweir sal_Bool OHTMLImportExport::Write() 756cdf0e10cSrcweir { 757cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Write" ); 758cdf0e10cSrcweir ODatabaseImportExport::Write(); 759cdf0e10cSrcweir if(m_xObject.is()) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_doctype << ' ' << OOO_STRING_SVTOOLS_HTML_doctype32 << '>' << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine; 762cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html ); 763cdf0e10cSrcweir WriteHeader(); 764cdf0e10cSrcweir OUT_LF(); 765cdf0e10cSrcweir WriteBody(); 766cdf0e10cSrcweir OUT_LF(); 767cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html ); 768cdf0e10cSrcweir 769cdf0e10cSrcweir return ((*m_pStream).GetError() == SVSTREAM_OK); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir return sal_False; 772cdf0e10cSrcweir } 773cdf0e10cSrcweir //------------------------------------------------------------------- 774cdf0e10cSrcweir sal_Bool OHTMLImportExport::Read() 775cdf0e10cSrcweir { 776cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Read" ); 777cdf0e10cSrcweir ODatabaseImportExport::Read(); 778cdf0e10cSrcweir SvParserState eState = SVPAR_ERROR; 779cdf0e10cSrcweir if ( m_pStream ) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir m_pReader = new OHTMLReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory); 782cdf0e10cSrcweir ((OHTMLReader*)m_pReader)->AddRef(); 783cdf0e10cSrcweir if ( isCheckEnabled() ) 784cdf0e10cSrcweir m_pReader->enableCheckOnly(); 785cdf0e10cSrcweir //dyf add 20070601 786cdf0e10cSrcweir m_pReader->SetTableName(m_sDefaultTableName); 787cdf0e10cSrcweir //dyf add end 788cdf0e10cSrcweir eState = ((OHTMLReader*)m_pReader)->CallParser(); 789cdf0e10cSrcweir m_pReader->release(); 790cdf0e10cSrcweir m_pReader = NULL; 791cdf0e10cSrcweir } 792cdf0e10cSrcweir 793cdf0e10cSrcweir return eState != SVPAR_ERROR; 794cdf0e10cSrcweir } 795cdf0e10cSrcweir //------------------------------------------------------------------- 796cdf0e10cSrcweir void OHTMLImportExport::WriteHeader() 797cdf0e10cSrcweir { 798cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteHeader" ); 799cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps( 800cdf0e10cSrcweir m_xFactory->createInstance(::rtl::OUString::createFromAscii( 801cdf0e10cSrcweir "com.sun.star.document.DocumentProperties")), 802cdf0e10cSrcweir uno::UNO_QUERY); 803cdf0e10cSrcweir if (xDocProps.is()) { 804cdf0e10cSrcweir xDocProps->setTitle(m_sName); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head ); 808cdf0e10cSrcweir 809cdf0e10cSrcweir SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), String(), 810cdf0e10cSrcweir xDocProps, sIndent ); 811cdf0e10cSrcweir OUT_LF(); 812cdf0e10cSrcweir IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head ); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir //----------------------------------------------------------------------- 815cdf0e10cSrcweir void OHTMLImportExport::WriteBody() 816cdf0e10cSrcweir { 817cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteBody" ); 818cdf0e10cSrcweir 819cdf0e10cSrcweir IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style ); 820cdf0e10cSrcweir 821cdf0e10cSrcweir (*m_pStream) << sMyBegComment; OUT_LF(); 822cdf0e10cSrcweir (*m_pStream) << OOO_STRING_SVTOOLS_HTML_body << " { " << sFontFamily << '\"' << ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(), gsl_getSystemTextEncoding()) << '\"'; 823cdf0e10cSrcweir // TODO : think about the encoding of the font name 824cdf0e10cSrcweir (*m_pStream) << "; " << sFontSize; 825cdf0e10cSrcweir m_pStream->WriteNumber(m_aFont.Height); 826cdf0e10cSrcweir (*m_pStream) << '}'; 827cdf0e10cSrcweir 828cdf0e10cSrcweir OUT_LF(); 829cdf0e10cSrcweir (*m_pStream) << sMyEndComment; 830cdf0e10cSrcweir IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style ); 831cdf0e10cSrcweir OUT_LF(); 832cdf0e10cSrcweir 833cdf0e10cSrcweir // default Textfarbe schwarz 834cdf0e10cSrcweir (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_body << ' ' << OOO_STRING_SVTOOLS_HTML_O_text << '='; 835cdf0e10cSrcweir sal_Int32 nColor = 0; 836cdf0e10cSrcweir if(m_xObject.is()) 837cdf0e10cSrcweir m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; 838cdf0e10cSrcweir ::Color aColor(nColor); 839cdf0e10cSrcweir HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); 840cdf0e10cSrcweir 841cdf0e10cSrcweir ::rtl::OString sOut( ' ' ); 842cdf0e10cSrcweir sOut = sOut + OOO_STRING_SVTOOLS_HTML_O_bgcolor; 843cdf0e10cSrcweir sOut = sOut + "="; 844cdf0e10cSrcweir (*m_pStream) << sOut; 845cdf0e10cSrcweir HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); 846cdf0e10cSrcweir 847cdf0e10cSrcweir (*m_pStream) << '>'; OUT_LF(); 848cdf0e10cSrcweir 849cdf0e10cSrcweir WriteTables(); 850cdf0e10cSrcweir 851cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body ); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir //----------------------------------------------------------------------- 854cdf0e10cSrcweir void OHTMLImportExport::WriteTables() 855cdf0e10cSrcweir { 856cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteTables" ); 857cdf0e10cSrcweir ::rtl::OString aStrOut = OOO_STRING_SVTOOLS_HTML_table; 858cdf0e10cSrcweir aStrOut = aStrOut + " "; 859cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_frame; 860cdf0e10cSrcweir aStrOut = aStrOut + "="; 861cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_TF_void; 862cdf0e10cSrcweir 863cdf0e10cSrcweir Sequence< ::rtl::OUString> aNames; 864cdf0e10cSrcweir Reference<XNameAccess> xColumns; 865cdf0e10cSrcweir sal_Bool bUseResultMetaData = sal_False; 866cdf0e10cSrcweir if(m_xObject.is()) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY); 869cdf0e10cSrcweir xColumns = xColSup->getColumns(); 870cdf0e10cSrcweir aNames = xColumns->getElementNames(); 871cdf0e10cSrcweir if ( !aNames.getLength() ) 872cdf0e10cSrcweir { 873cdf0e10cSrcweir sal_Int32 nCount = m_xResultSetMetaData->getColumnCount(); 874cdf0e10cSrcweir aNames.realloc(nCount); 875cdf0e10cSrcweir for (sal_Int32 i= 0; i < nCount; ++i) 876cdf0e10cSrcweir aNames[i] = m_xResultSetMetaData->getColumnName(i+1); 877cdf0e10cSrcweir bUseResultMetaData = sal_True; 878cdf0e10cSrcweir } 879cdf0e10cSrcweir } 880cdf0e10cSrcweir 881cdf0e10cSrcweir aStrOut = aStrOut + " "; 882cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_align; 883cdf0e10cSrcweir aStrOut = aStrOut + "="; 884cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_AL_left; 885cdf0e10cSrcweir aStrOut = aStrOut + " "; 886cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cellspacing; 887cdf0e10cSrcweir aStrOut = aStrOut + "="; 888cdf0e10cSrcweir aStrOut = aStrOut + ::rtl::OString::valueOf((sal_Int32)nCellSpacing); 889cdf0e10cSrcweir aStrOut = aStrOut + " "; 890cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cols; 891cdf0e10cSrcweir aStrOut = aStrOut + "="; 892cdf0e10cSrcweir aStrOut = aStrOut + ::rtl::OString::valueOf(aNames.getLength()); 893cdf0e10cSrcweir aStrOut = aStrOut + " "; 894cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_border; 895cdf0e10cSrcweir aStrOut = aStrOut + "=1"; 896cdf0e10cSrcweir 897cdf0e10cSrcweir IncIndent(1); 898cdf0e10cSrcweir TAG_ON( aStrOut ); 899cdf0e10cSrcweir 900cdf0e10cSrcweir FontOn(); 901cdf0e10cSrcweir 902cdf0e10cSrcweir TAG_ON( OOO_STRING_SVTOOLS_HTML_caption ); 903cdf0e10cSrcweir TAG_ON( OOO_STRING_SVTOOLS_HTML_bold ); 904cdf0e10cSrcweir 905cdf0e10cSrcweir (*m_pStream) << ::rtl::OString(m_sName,m_sName.getLength(), gsl_getSystemTextEncoding()); 906cdf0e10cSrcweir // TODO : think about the encoding of the name 907cdf0e10cSrcweir TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold ); 908cdf0e10cSrcweir TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption ); 909cdf0e10cSrcweir 910cdf0e10cSrcweir FontOff(); 911cdf0e10cSrcweir OUT_LF(); 912cdf0e10cSrcweir // </FONT> 913cdf0e10cSrcweir 914cdf0e10cSrcweir IncIndent(1); 915cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead ); 916cdf0e10cSrcweir 917cdf0e10cSrcweir IncIndent(1); 918cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); 919cdf0e10cSrcweir 920cdf0e10cSrcweir if(m_xObject.is()) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir sal_Int32* pFormat = new sal_Int32[aNames.getLength()]; 923cdf0e10cSrcweir 924cdf0e10cSrcweir const char **pHorJustify = new const char*[aNames.getLength()]; 925cdf0e10cSrcweir sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()]; 926cdf0e10cSrcweir 927cdf0e10cSrcweir 928cdf0e10cSrcweir sal_Int32 nHeight = 0; 929cdf0e10cSrcweir m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight; 930cdf0e10cSrcweir 931cdf0e10cSrcweir // 1. die Spaltenbeschreibung rauspusten 932cdf0e10cSrcweir const ::rtl::OUString* pIter = aNames.getConstArray(); 933cdf0e10cSrcweir const ::rtl::OUString* pEnd = pIter + aNames.getLength(); 934cdf0e10cSrcweir 935cdf0e10cSrcweir for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i ) 936cdf0e10cSrcweir { 937cdf0e10cSrcweir sal_Int32 nAlign = 0; 938cdf0e10cSrcweir pFormat[i] = 0; 939cdf0e10cSrcweir pColWidth[i] = 100; 940cdf0e10cSrcweir if ( !bUseResultMetaData ) 941cdf0e10cSrcweir { 942cdf0e10cSrcweir Reference<XPropertySet> xColumn; 943cdf0e10cSrcweir xColumns->getByName(*pIter) >>= xColumn; 944cdf0e10cSrcweir xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign; 945cdf0e10cSrcweir pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY)); 946cdf0e10cSrcweir pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH)); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir 949cdf0e10cSrcweir switch( nAlign ) 950cdf0e10cSrcweir { 951cdf0e10cSrcweir case 1: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_center; break; 952cdf0e10cSrcweir case 2: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_right; break; 953cdf0e10cSrcweir default: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_left; break; 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir if(i == aNames.getLength()-1) 957cdf0e10cSrcweir IncIndent(-1); 958cdf0e10cSrcweir 959cdf0e10cSrcweir WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader); 960cdf0e10cSrcweir } 961cdf0e10cSrcweir 962cdf0e10cSrcweir IncIndent(-1); 963cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); 964cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead ); 965cdf0e10cSrcweir 966cdf0e10cSrcweir IncIndent(1); 967cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody ); 968cdf0e10cSrcweir 969cdf0e10cSrcweir // 2. und jetzt die Daten 970cdf0e10cSrcweir ::comphelper::ComponentContext aContext(m_xFactory); 971cdf0e10cSrcweir Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY); 972cdf0e10cSrcweir sal_Int32 j=1; 973cdf0e10cSrcweir sal_Int32 kk=0; 974cdf0e10cSrcweir m_xResultSet->beforeFirst(); // set back before the first row 975cdf0e10cSrcweir while(m_xResultSet->next()) 976cdf0e10cSrcweir { 977cdf0e10cSrcweir IncIndent(1); 978cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); 979cdf0e10cSrcweir 980cdf0e10cSrcweir if(!m_pRowMarker || m_pRowMarker[kk] == j) 981cdf0e10cSrcweir { 982cdf0e10cSrcweir ++kk; 983cdf0e10cSrcweir for(sal_Int32 i=1;i<=aNames.getLength();++i) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir if(i == aNames.getLength()) 986cdf0e10cSrcweir IncIndent(-1); 987cdf0e10cSrcweir 988cdf0e10cSrcweir String aValue; 989cdf0e10cSrcweir try 990cdf0e10cSrcweir { 991cdf0e10cSrcweir Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW); 992cdf0e10cSrcweir dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn); 993cdf0e10cSrcweir ::rtl::OUString sValue = aFormatedValue.getFormattedValue(); 994cdf0e10cSrcweir if (sValue.getLength()) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir aValue = sValue; 997cdf0e10cSrcweir } 998cdf0e10cSrcweir } 999cdf0e10cSrcweir catch( const Exception& ) 1000cdf0e10cSrcweir { 1001cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,OOO_STRING_SVTOOLS_HTML_tabledata); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir ++j; 1007cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir delete [] pFormat; 1011cdf0e10cSrcweir delete [] pHorJustify; 1012cdf0e10cSrcweir delete [] pColWidth; 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir else 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir IncIndent(-1); 1017cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); 1018cdf0e10cSrcweir TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead ); 1019cdf0e10cSrcweir 1020cdf0e10cSrcweir IncIndent(1); 1021cdf0e10cSrcweir TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody ); 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody ); 1025cdf0e10cSrcweir IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table ); 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir //----------------------------------------------------------------------- 1028cdf0e10cSrcweir void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar, 1029cdf0e10cSrcweir const String& rValue,const char* pHtmlTag) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteCell" ); 1032cdf0e10cSrcweir ::rtl::OString aStrTD = pHtmlTag; 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir nWidthPixel = nWidthPixel ? nWidthPixel : 86; 1035cdf0e10cSrcweir nHeightPixel = nHeightPixel ? nHeightPixel : 17; 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig, 1038cdf0e10cSrcweir // da die nicht von Netscape beachtet werden.. 1039cdf0e10cSrcweir // Spaltenbreite 1040cdf0e10cSrcweir aStrTD = aStrTD + " "; 1041cdf0e10cSrcweir aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_width; 1042cdf0e10cSrcweir aStrTD = aStrTD + "="; 1043cdf0e10cSrcweir aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nWidthPixel); 1044cdf0e10cSrcweir // Zeilenhoehe 1045cdf0e10cSrcweir aStrTD = aStrTD + " "; 1046cdf0e10cSrcweir aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_height; 1047cdf0e10cSrcweir aStrTD = aStrTD + "="; 1048cdf0e10cSrcweir aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nHeightPixel); 1049cdf0e10cSrcweir 1050cdf0e10cSrcweir aStrTD = aStrTD + " "; 1051cdf0e10cSrcweir aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_align; 1052cdf0e10cSrcweir aStrTD = aStrTD + "="; 1053cdf0e10cSrcweir aStrTD = aStrTD + pChar; 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir double fVal = 0.0; 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier(); 1058cdf0e10cSrcweir SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); 1059cdf0e10cSrcweir SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL; 1060cdf0e10cSrcweir if(pFormatter) 1061cdf0e10cSrcweir { 1062cdf0e10cSrcweir try 1063cdf0e10cSrcweir { 1064cdf0e10cSrcweir fVal = m_xFormatter->convertStringToNumber(nFormat,rValue); 1065cdf0e10cSrcweir ByteString aTmpString(aStrTD); 1066cdf0e10cSrcweir HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter ); 1067cdf0e10cSrcweir } 1068cdf0e10cSrcweir catch(Exception&) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir ByteString aTmpString(aStrTD); 1071cdf0e10cSrcweir HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter ); 1072cdf0e10cSrcweir } 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir TAG_ON( aStrTD ); 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir FontOn(); 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight ); 1080cdf0e10cSrcweir sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant ); 1081cdf0e10cSrcweir sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline ); 1082cdf0e10cSrcweir sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout ); 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold ); 1085cdf0e10cSrcweir if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic ); 1086cdf0e10cSrcweir if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline ); 1087cdf0e10cSrcweir if ( bStrikeout ) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike ); 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir if ( !rValue.Len() ) 1090cdf0e10cSrcweir TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // #42573# keine komplett leere Zelle 1091cdf0e10cSrcweir else 1092cdf0e10cSrcweir HTMLOutFuncs::Out_String( (*m_pStream), rValue ,m_eDestEnc); 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir if ( bStrikeout ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike ); 1096cdf0e10cSrcweir if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline ); 1097cdf0e10cSrcweir if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic ); 1098cdf0e10cSrcweir if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold ); 1099cdf0e10cSrcweir 1100cdf0e10cSrcweir FontOff(); 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir TAG_OFF_LF( pHtmlTag ); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir //----------------------------------------------------------------------- 1105cdf0e10cSrcweir void OHTMLImportExport::FontOn() 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOn" ); 1108cdf0e10cSrcweir #ifdef DBG_UTIL 1109cdf0e10cSrcweir m_bCheckFont = sal_True; 1110cdf0e10cSrcweir #endif 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir // <FONT FACE="xxx"> 1113cdf0e10cSrcweir ::rtl::OString aStrOut = "<"; 1114cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_font; 1115cdf0e10cSrcweir aStrOut = aStrOut + " "; 1116cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_face; 1117cdf0e10cSrcweir aStrOut = aStrOut + "="; 1118cdf0e10cSrcweir aStrOut = aStrOut + "\""; 1119cdf0e10cSrcweir aStrOut = aStrOut + ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(),gsl_getSystemTextEncoding()); 1120cdf0e10cSrcweir // TODO : think about the encoding of the font name 1121cdf0e10cSrcweir aStrOut = aStrOut + "\""; 1122cdf0e10cSrcweir aStrOut = aStrOut + " "; 1123cdf0e10cSrcweir aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_color; 1124cdf0e10cSrcweir aStrOut = aStrOut + "="; 1125cdf0e10cSrcweir (*m_pStream) << aStrOut; 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir sal_Int32 nColor = 0; 1128cdf0e10cSrcweir if(m_xObject.is()) 1129cdf0e10cSrcweir m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor; 1130cdf0e10cSrcweir ::Color aColor(nColor); 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir HTMLOutFuncs::Out_Color( (*m_pStream), aColor ); 1133cdf0e10cSrcweir (*m_pStream) << ">"; 1134cdf0e10cSrcweir } 1135cdf0e10cSrcweir //----------------------------------------------------------------------- 1136cdf0e10cSrcweir inline void OHTMLImportExport::FontOff() 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOff" ); 1139cdf0e10cSrcweir DBG_ASSERT(m_bCheckFont,"Kein FontOn() gerufen"); 1140cdf0e10cSrcweir TAG_OFF( OOO_STRING_SVTOOLS_HTML_font ); 1141cdf0e10cSrcweir #ifdef DBG_UTIL 1142cdf0e10cSrcweir m_bCheckFont = sal_False; 1143cdf0e10cSrcweir #endif 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir //----------------------------------------------------------------------- 1146cdf0e10cSrcweir void OHTMLImportExport::IncIndent( sal_Int16 nVal ) 1147cdf0e10cSrcweir { 1148cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::IncIndent" ); 1149cdf0e10cSrcweir sIndent[m_nIndent] = '\t'; 1150cdf0e10cSrcweir m_nIndent = m_nIndent + nVal; 1151cdf0e10cSrcweir if ( m_nIndent < 0 ) 1152cdf0e10cSrcweir m_nIndent = 0; 1153cdf0e10cSrcweir else if ( m_nIndent > nIndentMax ) 1154cdf0e10cSrcweir m_nIndent = nIndentMax; 1155cdf0e10cSrcweir sIndent[m_nIndent] = 0; 1156cdf0e10cSrcweir } 1157cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1158