Files
libreoffice/dbaccess/source/ui/misc/RtfReader.cxx
Norbert Thiebaud 256f6ca67d Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
* commit 'ooo/DEV300_m101': (76 commits)
  masterfix DEV300: #i10000# usage of L10N build_type
  removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw
  hr75: #i116747#: remove obsolete copyright notices
  gnumake3: remove comphelper version; fix including extract.hxx
  removetooltypes01: #i112600# Replace missing tools types replacement
  removetooltypes01: #i112600# remove tooltypes from reportdesign
  removetooltypes01: #i112600# remove tooltypes from dbaccess
  undoapi: don't use deprecated JUnit API, this seems to fail now (but didn't before the rebase)
  undoapi: those two classes do not belong into JAVATESTFILES, but JAVAFILES only
  undoapi: (I|Sfx)UndoManager now working with size_t instead of USHORT
  gridsort: give the UnoControl(Model/Base) classes a ctor taking a service factory, so we have access to the factory which created us, and don't need to resort to the process'es service factory
  dba34b: #109956# notify column value in correct order
  dba34b: #i114309# set default values for bit boolean and reset when we are on the insertrow
  undoapi: assert unknown slots in ImplInvalidateFeature
  dba34b: #i110907# check if design handle event
  dba34b: #i109956# notify column values when row is refreshed
  dba34b: #i115753# add test again
  undoapi: renamed Undo.* to RptUndo.*, to not confuse a certain IDE with different same-named files in the source tree ...
  undoapi: migrated report designer to use an own, model-bound UndoManager, instead of the UndoManager formerly bound to the controller
  undoapi: split OSingleDocumentController into DBSubComponentController (which the report design's controller will be derived from) and the still-so-named OSingleDocumentController. Module reportdesign does not compile with this change, this is yet to come.
  ...

Conflicts:
	dbaccess/inc/IEnvironment.hxx
	dbaccess/inc/dataview.hxx
	dbaccess/qa/complex/dbaccess/RowSet.java
	dbaccess/source/core/api/CacheSet.cxx
	dbaccess/source/core/api/KeySet.hxx
	dbaccess/source/core/api/OptimisticSet.hxx
	dbaccess/source/core/api/RowSet.cxx
	dbaccess/source/core/api/RowSetCache.cxx
	dbaccess/source/ext/adabas/Acomponentmodule.cxx
	dbaccess/source/ext/adabas/Aservices.cxx
	dbaccess/source/filter/migration/cfgimport.cxx
	dbaccess/source/filter/migration/cfgimport.hxx
	dbaccess/source/filter/migration/cfgservices.cxx
	dbaccess/source/filter/migration/makefile.mk
	dbaccess/source/inc/cfg_reghelper.hxx
	dbaccess/source/sdbtools/misc/sdbt_services.cxx
	dbaccess/source/shared/cfg_reghelper.cxx
	dbaccess/source/shared/cfgstrings.cxx
	dbaccess/source/shared/registrationhelper.cxx
	dbaccess/source/ui/app/AppController.cxx
	dbaccess/source/ui/app/AppDetailPageHelper.cxx
	dbaccess/source/ui/app/AppDetailPageHelper.hxx
	dbaccess/source/ui/app/AppDetailView.cxx
	dbaccess/source/ui/app/AppIconControl.cxx
	dbaccess/source/ui/app/AppSwapWindow.cxx
	dbaccess/source/ui/browser/brwctrlr.cxx
	dbaccess/source/ui/browser/dataview.cxx
	dbaccess/source/ui/browser/unodatbr.cxx
	dbaccess/source/ui/control/dbtreelistbox.cxx
	dbaccess/source/ui/control/opendoccontrols.cxx
	dbaccess/source/ui/control/tabletree.cxx
	dbaccess/source/ui/dlg/ConnectionHelper.cxx
	dbaccess/source/ui/dlg/ConnectionPage.src
	dbaccess/source/ui/dlg/ExtensionNotPresent.cxx
	dbaccess/source/ui/dlg/ExtensionNotPresent.hrc
	dbaccess/source/ui/dlg/ExtensionNotPresent.src
	dbaccess/source/ui/dlg/TablesSingleDlg.cxx
	dbaccess/source/ui/dlg/adodatalinks.hxx
	dbaccess/source/ui/dlg/dbadmin2.src
	dbaccess/source/ui/dlg/dbadminsetup.src
	dbaccess/source/ui/dlg/dlgattr.cxx
	dbaccess/source/ui/dlg/dlgsize.src
	dbaccess/source/ui/dlg/makefile.mk
	dbaccess/source/ui/dlg/sqlmessage.cxx
	dbaccess/source/ui/inc/ExtensionNotPresent.hxx
	dbaccess/source/ui/inc/TokenWriter.hxx
	dbaccess/source/ui/inc/imageprovider.hxx
	dbaccess/source/ui/misc/DExport.cxx
	dbaccess/source/ui/misc/HtmlReader.cxx
	dbaccess/source/ui/misc/RowSetDrop.cxx
	dbaccess/source/ui/misc/RtfReader.cxx
	dbaccess/source/ui/misc/TokenWriter.cxx
	dbaccess/source/ui/misc/imageprovider.cxx
	dbaccess/source/ui/misc/linkeddocuments.cxx
	dbaccess/source/ui/misc/singledoccontroller.cxx
	dbaccess/source/ui/querydesign/ConnectionData.hxx
	dbaccess/source/ui/querydesign/JoinTableView.cxx
	dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
	dbaccess/source/ui/querydesign/TableConnectionData.cxx
	dbaccess/source/ui/querydesign/TableWindowListBox.cxx
	dbaccess/source/ui/relationdesign/RelationController.cxx
	dbaccess/source/ui/relationdesign/RelationTableView.cxx
	dbaccess/source/ui/tabledesign/table.src
	reportdesign/inc/RptPage.hxx
	reportdesign/qa/complex/reportdesign/ReportDesignerTest.java
	reportdesign/source/core/api/ReportDefinition.cxx
	reportdesign/source/core/sdr/ReportUndoFactory.cxx
	reportdesign/source/core/sdr/UndoEnv.cxx
	reportdesign/source/filter/xml/xmlservices.cxx
	reportdesign/source/ui/dlg/GroupsSorting.cxx
	reportdesign/source/ui/dlg/Navigator.cxx
	reportdesign/source/ui/inspection/metadata.cxx
	reportdesign/source/ui/misc/RptUndo.cxx
	reportdesign/source/ui/misc/UITools.cxx
	reportdesign/source/ui/misc/rptuiservices.cxx
	reportdesign/source/ui/report/DesignView.cxx
	reportdesign/source/ui/report/FixedTextColor.cxx
	reportdesign/source/ui/report/ReportController.cxx
	reportdesign/source/ui/report/ReportSection.cxx
	reportdesign/source/ui/report/SectionView.cxx
	reportdesign/source/ui/report/SectionWindow.cxx
	reportdesign/source/ui/report/StartMarker.cxx
	reportdesign/source/ui/report/ViewsWindow.cxx
	reportdesign/source/ui/report/dlgedfunc.cxx
	reportdesign/source/ui/report/report.src
2011-03-09 23:17:51 -06:00

376 lines
14 KiB
C++
Raw Blame History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
#include "RtfReader.hxx"
#include <tools/debug.hxx>
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/sdbcx/XAppend.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontStrikeout.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/util/NumberFormat.hpp>
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#include "dbustrings.hrc"
#include <svtools/rtftoken.h>
#include "dbu_misc.hrc"
#include <vcl/msgbox.hxx>
#include <connectivity/dbconversion.hxx>
#include <connectivity/dbtools.hxx>
#include <comphelper/extract.hxx>
#include <tools/color.hxx>
#include "WExtendPages.hxx"
#include "moduledbu.hxx"
#include "QEnumTypes.hxx"
#include "UITools.hxx"
#include <vcl/svapp.hxx>
#include <rtl/logfile.hxx>
using namespace dbaui;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::awt;
DBG_NAME(ORTFReader)
// ==========================================================================
// ORTFReader
// ==========================================================================
ORTFReader::ORTFReader( SvStream& rIn,
const SharedConnection& _rxConnection,
const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
const TColumnVector* pList,
const OTypeInfoMap* _pInfoMap)
:SvRTFParser(rIn)
,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
DBG_CTOR(ORTFReader,NULL);
m_bAppendFirstLine = false;
}
// ---------------------------------------------------------------------------
ORTFReader::ORTFReader(SvStream& rIn,
sal_Int32 nRows,
const TPositions &_rColumnPositions,
const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
const TColumnVector* pList,
const OTypeInfoMap* _pInfoMap,
sal_Bool _bAutoIncrementEnabled)
:SvRTFParser(rIn)
,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
DBG_CTOR(ORTFReader,NULL);
m_bAppendFirstLine = false;
}
// ---------------------------------------------------------------------------
ORTFReader::~ORTFReader()
{
DBG_DTOR(ORTFReader,NULL);
}
// ---------------------------------------------------------------------------
SvParserState ORTFReader::CallParser()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CallParser" );
DBG_CHKTHIS(ORTFReader,NULL);
rInput.Seek(STREAM_SEEK_TO_BEGIN);
rInput.ResetError();
SvParserState eParseState = SvRTFParser::CallParser();
SetColumnTypes(m_pColumnList,m_pInfoMap);
return m_bFoundTable ? eParseState : SVPAR_ERROR;
}
// ---------------------------------------------------------------------------
void ORTFReader::NextToken( int nToken )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::NextToken" );
DBG_CHKTHIS(ORTFReader,NULL);
if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
return;
if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
{
switch(nToken)
{
case RTF_COLORTBL:
{
int nTmpToken2 = GetNextToken();
do
{
Color aColor;
do
{
switch(nTmpToken2)
{
case RTF_RED: aColor.SetRed((sal_uInt8)nTokenValue); break;
case RTF_BLUE: aColor.SetBlue((sal_uInt8)nTokenValue); break;
case RTF_GREEN: aColor.SetGreen((sal_uInt8)nTokenValue); break;
default: break;
}
nTmpToken2 = GetNextToken();
}
while(aToken.GetChar(0) != ';' && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
m_vecColor.push_back(aColor.GetRGBColor());
nTmpToken2 = GetNextToken();
}
while(nTmpToken2 == RTF_RED && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
SkipToken();
}
break;
case RTF_DEFLANG:
case RTF_LANG: // Sprache abfragen
m_nDefToken = (rtl_TextEncoding)nTokenValue;
break;
case RTF_TROWD:
{
bool bInsertRow = true;
if ( !m_xTable.is() ) // erste Zeile als Header verwenden
{
sal_uInt32 nTell = rInput.Tell(); // ver<65>ndert vielleicht die Position des Streams
m_bError = !CreateTable(nToken);
bInsertRow = m_bAppendFirstLine;
if ( m_bAppendFirstLine )
{
rInput.Seek(nTell);
rInput.ResetError();
}
}
if ( bInsertRow && !m_bError)
{
try
{
m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
}
catch(SQLException& e)
// UpdateFehlerbehandlung
{
showErrorDialog(e);
}
}
}
break;
case RTF_INTBL:
if(m_bInTbl)
{
eraseTokens();
}
m_bInTbl = sal_True; // jetzt befinden wir uns in einer Tabellenbeschreibung
break;
case RTF_TEXTTOKEN:
case RTF_SINGLECHAR:
if(m_bInTbl) // wichtig, da wir sonst auch die Namen der Fonts bekommen
m_sTextToken += aToken;
break;
case RTF_CELL:
{
try
{
insertValueIntoColumn();
}
catch(SQLException& e)
// UpdateFehlerbehandlung
{
showErrorDialog(e);
}
m_nColumnPos++;
eraseTokens();
}
break;
case RTF_ROW:
// es kann vorkommen, da<64> die letzte Celle nicht mit \cell abgeschlossen ist
try
{
insertValueIntoColumn();
m_nRowCount++;
if(m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
m_pUpdateHelper->updateInt(1,m_nRowCount);
m_pUpdateHelper->insertRow();
}
catch(SQLException& e)
//////////////////////////////////////////////////////////////////////
// UpdateFehlerbehandlung
{
showErrorDialog(e);
}
m_nColumnPos = 0;
break;
}
}
else // Zweig nur f"ur Typpr"ufung g"ultig
{
switch(nToken)
{
case RTF_TROWD:
// Der Spalten Kopf z"ahlt nicht mit
if(m_bHead)
{
do
{}
while(GetNextToken() != RTF_ROW && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
m_bHead = sal_False;
}
break;
case RTF_INTBL:
m_bInTbl = sal_True;
break;
case RTF_TEXTTOKEN:
case RTF_SINGLECHAR:
if(m_bInTbl)
m_sTextToken += aToken;
break;
case RTF_CELL:
adjustFormat();
m_nColumnPos++;
break;
case RTF_ROW:
adjustFormat();
m_nColumnPos = 0;
m_nRows--;
break;
}
}
}
// ---------------------------------------------------------------------------
sal_Bool ORTFReader::CreateTable(int nToken)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CreateTable" );
DBG_CHKTHIS(ORTFReader,NULL);
String aTableName(ModuleRes(STR_TBL_TITLE));
aTableName = aTableName.GetToken(0,' ');
aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
int nTmpToken2 = nToken;
String aColumnName;
FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
do
{
switch(nTmpToken2)
{
case RTF_UNKNOWNCONTROL:
case RTF_UNKNOWNDATA:
m_bInTbl = sal_False;
aColumnName.Erase();
break;
case RTF_INTBL:
if(m_bInTbl)
aColumnName.Erase();
m_bInTbl = sal_True;
break;
case RTF_TEXTTOKEN:
case RTF_SINGLECHAR:
if(m_bInTbl)
aColumnName += aToken;
break;
case RTF_CELL:
{
aColumnName.EraseLeadingChars();
aColumnName.EraseTrailingChars();
if (!aColumnName.Len() || m_bAppendFirstLine )
aColumnName = String(ModuleRes(STR_COLUMN_NAME));
CreateDefaultColumn(aColumnName);
aColumnName.Erase();
}
break;
case RTF_CF:
break;
case RTF_B:
aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
break;
case RTF_I:
aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
break;
case RTF_UL:
aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
break;
case RTF_STRIKE:
aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
break;
}
}
while((nTmpToken2 = GetNextToken()) != RTF_TROWD && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
sal_Bool bOk = !m_vDestVector.empty();
if(bOk)
{
if ( aColumnName.Len() )
{
if ( m_bAppendFirstLine )
aColumnName = String(ModuleRes(STR_COLUMN_NAME));
CreateDefaultColumn(aColumnName);
}
m_bInTbl = sal_False;
m_bFoundTable = sal_True;
if ( isCheckEnabled() )
return sal_True;
Any aTextColor;
if(!m_vecColor.empty())
aTextColor <<= m_vecColor[0];
bOk = !executeWizard(aTableName,aTextColor,aFont) && m_xTable.is();
}
return bOk;
}
// -----------------------------------------------------------------------------
void ORTFReader::release()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::release" );
DBG_CHKTHIS(ORTFReader,NULL);
ReleaseRef();
}
// -----------------------------------------------------------------------------
TypeSelectionPageFactory ORTFReader::getTypeSelectionPageFactory()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::getTypeSelectionPageFactory" );
DBG_CHKTHIS(ORTFReader,NULL);
return &OWizRTFExtend::Create;
}
// -----------------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */