2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-26 09:49:35 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 01:39:00 +00:00
|
|
|
|
2000-10-30 10:00:36 +00:00
|
|
|
#include <ctype.h>
|
2000-10-05 13:47:22 +00:00
|
|
|
#include "flat/ETable.hxx"
|
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
#include <com/sun/star/ucb/XContentAccess.hpp>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/converter.hxx>
|
2000-10-05 13:47:22 +00:00
|
|
|
#include "flat/EConnection.hxx"
|
|
|
|
#include "flat/EColumns.hxx"
|
|
|
|
#include <osl/thread.h>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/zforlist.hxx>
|
2003-03-19 15:38:50 +00:00
|
|
|
#include <rtl/math.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <stdio.h>
|
2001-03-15 08:02:28 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2000-10-11 09:48:50 +00:00
|
|
|
#include <comphelper/numbers.hxx>
|
2012-09-19 13:15:15 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2011-11-18 21:03:31 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#include <comphelper/string.hxx>
|
|
|
|
#include <comphelper/types.hxx>
|
2000-10-05 13:47:22 +00:00
|
|
|
#include "flat/EDriver.hxx"
|
|
|
|
#include <com/sun/star/util/NumberFormat.hpp>
|
2012-08-29 09:32:55 +02:00
|
|
|
#include <com/sun/star/util/NumberFormatter.hpp>
|
2012-12-04 13:18:35 +02:00
|
|
|
#include <com/sun/star/util/NumberFormatsSupplier.hpp>
|
2000-10-05 13:47:22 +00:00
|
|
|
#include <unotools/configmgr.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/languagetag.hxx>
|
2000-12-06 11:07:47 +00:00
|
|
|
#include "connectivity/dbconversion.hxx"
|
2006-06-20 00:28:52 +00:00
|
|
|
#include "file/quotedstring.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <unotools/syslocale.hxx>
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2001-05-18 07:33:49 +00:00
|
|
|
using namespace ::comphelper;
|
2000-10-05 13:47:22 +00:00
|
|
|
using namespace connectivity;
|
|
|
|
using namespace connectivity::flat;
|
|
|
|
using namespace connectivity::file;
|
2001-05-18 07:33:49 +00:00
|
|
|
using namespace ::cppu;
|
2000-10-19 10:56:36 +00:00
|
|
|
using namespace utl;
|
2000-10-05 13:47:22 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2012-12-04 13:18:35 +02:00
|
|
|
using namespace ::com::sun::star::util;
|
2013-05-19 13:20:51 +02:00
|
|
|
using std::vector;
|
|
|
|
using std::lower_bound;
|
2000-12-14 07:32:10 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-12-21 12:16:52 +00:00
|
|
|
void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
m_bNeedToReadLine = true; // we overwrite m_aCurrentLine, seek the stream, ...
|
|
|
|
m_pFileStream->Seek(0);
|
|
|
|
m_aCurrentLine = QuotedTokenizedString();
|
|
|
|
bool bRead = true;
|
|
|
|
|
|
|
|
const OFlatConnection* const pConnection = getFlatConnection();
|
|
|
|
const bool bHasHeaderLine = pConnection->isHeaderLine();
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2006-06-20 00:28:52 +00:00
|
|
|
QuotedTokenizedString aHeaderLine;
|
2013-05-19 13:20:51 +02:00
|
|
|
TRowPositionInFile rowPos(0, 0);
|
|
|
|
sal_Int32 rowNum(0);
|
2009-04-23 10:42:05 +00:00
|
|
|
if ( bHasHeaderLine )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
bRead = readLine(&rowPos.second, &rowPos.first, true);
|
|
|
|
if(bRead)
|
|
|
|
aHeaderLine = m_aCurrentLine;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
setRowPos(rowNum++, rowPos);
|
2000-10-05 13:47:22 +00:00
|
|
|
|
|
|
|
// read first row
|
2006-06-20 00:28:52 +00:00
|
|
|
QuotedTokenizedString aFirstLine;
|
2013-05-19 13:20:51 +02:00
|
|
|
if(bRead)
|
|
|
|
{
|
|
|
|
bRead = readLine(&rowPos.second, &rowPos.first, false);
|
|
|
|
if(bRead)
|
|
|
|
setRowPos(rowNum++, rowPos);
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2009-04-23 10:42:05 +00:00
|
|
|
if ( !bHasHeaderLine || !aHeaderLine.Len())
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
// use first non-empty row as headerline because we need the number of columns
|
|
|
|
while(bRead && m_aCurrentLine.Len() == 0)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
bRead = readLine(&rowPos.second, &rowPos.first, false);
|
|
|
|
if(bRead)
|
|
|
|
setRowPos(rowNum++, rowPos);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
aHeaderLine = m_aCurrentLine;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
// column count
|
2013-11-13 10:51:58 +00:00
|
|
|
const sal_Int32 nFieldCount = aHeaderLine.GetTokenCount(m_cFieldDelimiter,m_cStringDelimiter);
|
2001-08-24 05:19:41 +00:00
|
|
|
|
2010-10-15 12:10:06 -05:00
|
|
|
if(!m_aColumns.is())
|
2001-08-24 05:19:41 +00:00
|
|
|
m_aColumns = new OSQLColumns();
|
|
|
|
else
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aColumns->get().clear();
|
2001-08-24 05:19:41 +00:00
|
|
|
|
|
|
|
m_aTypes.clear();
|
|
|
|
m_aPrecisions.clear();
|
|
|
|
m_aScales.clear();
|
|
|
|
// reserve some space
|
2009-04-23 10:42:05 +00:00
|
|
|
m_aColumns->get().reserve(nFieldCount+1);
|
2010-11-25 08:51:07 +01:00
|
|
|
m_aTypes.assign(nFieldCount+1,DataType::SQLNULL);
|
|
|
|
m_aPrecisions.assign(nFieldCount+1,-1);
|
|
|
|
m_aScales.assign(nFieldCount+1,-1);
|
2001-08-24 05:19:41 +00:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
const bool bCase = m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers();
|
2013-05-21 16:22:38 +02:00
|
|
|
CharClass aCharClass( pConnection->getDriver()->getComponentContext(), LanguageTag( _aLocale));
|
2000-10-05 13:47:22 +00:00
|
|
|
// read description
|
2009-04-23 10:42:05 +00:00
|
|
|
const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
|
|
|
|
const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
|
2001-08-24 05:19:41 +00:00
|
|
|
::comphelper::UStringMixEqual aCase(bCase);
|
2013-05-19 13:20:51 +02:00
|
|
|
vector<OUString> aColumnNames;
|
2013-07-19 01:31:53 -05:00
|
|
|
vector<OUString> m_aTypeNames;
|
2010-11-25 08:51:07 +01:00
|
|
|
m_aTypeNames.resize(nFieldCount);
|
2010-11-25 11:23:27 +01:00
|
|
|
const sal_Int32 nMaxRowsToScan = pConnection->getMaxRowsToScan();
|
2010-11-25 08:51:07 +01:00
|
|
|
sal_Int32 nRowCount = 0;
|
2013-05-19 13:20:51 +02:00
|
|
|
|
2010-11-25 08:51:07 +01:00
|
|
|
do
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-06-29 23:57:38 -05:00
|
|
|
sal_Int32 nStartPosHeaderLine = 0; // use for efficient way to get the tokens
|
|
|
|
sal_Int32 nStartPosFirstLine = 0; // use for efficient way to get the tokens
|
|
|
|
sal_Int32 nStartPosFirstLine2 = 0;
|
2013-10-28 12:21:40 +02:00
|
|
|
for( sal_Int32 i = 0; i < nFieldCount; i++ )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( nRowCount == 0)
|
2003-09-04 07:27:04 +00:00
|
|
|
{
|
2013-11-30 11:55:03 +01:00
|
|
|
OUString aColumnName;
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( bHasHeaderLine )
|
|
|
|
{
|
2012-12-15 12:45:36 +00:00
|
|
|
aColumnName = aHeaderLine.GetTokenSpecial(nStartPosHeaderLine,m_cFieldDelimiter,m_cStringDelimiter);
|
2010-11-25 08:51:07 +01:00
|
|
|
}
|
2013-11-30 11:55:03 +01:00
|
|
|
if ( aColumnName.isEmpty() )
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
2013-01-20 10:51:58 +01:00
|
|
|
aColumnName = "C" + OUString::number(i+1);
|
2010-11-25 08:51:07 +01:00
|
|
|
}
|
|
|
|
aColumnNames.push_back(aColumnName);
|
2003-09-04 07:27:04 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
if(bRead)
|
2013-06-29 23:57:38 -05:00
|
|
|
{
|
|
|
|
impl_fillColumnInfo_nothrow(m_aCurrentLine, nStartPosFirstLine, nStartPosFirstLine2,
|
|
|
|
m_aTypes[i], m_aPrecisions[i], m_aScales[i], m_aTypeNames[i],
|
|
|
|
cDecimalDelimiter, cThousandDelimiter, aCharClass);
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2010-11-25 08:51:07 +01:00
|
|
|
++nRowCount;
|
2013-05-19 13:20:51 +02:00
|
|
|
bRead = readLine(&rowPos.second, &rowPos.first, false);
|
|
|
|
if(bRead)
|
|
|
|
setRowPos(rowNum++, rowPos);
|
2010-11-25 08:51:07 +01:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
while(nRowCount < nMaxRowsToScan && bRead);
|
2010-11-25 08:51:07 +01:00
|
|
|
|
2013-10-28 12:21:40 +02:00
|
|
|
for( sal_Int32 i = 0; i < nFieldCount; i++ )
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
|
|
|
// check if the columname already exists
|
2013-01-20 10:51:58 +01:00
|
|
|
OUString aAlias(aColumnNames[i]);
|
2010-11-25 08:51:07 +01:00
|
|
|
OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
|
|
|
|
sal_Int32 nExprCnt = 0;
|
|
|
|
while(aFind != m_aColumns->get().end())
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-01-20 10:51:58 +01:00
|
|
|
aAlias = aColumnNames[i] + OUString::number(++nExprCnt);
|
2010-11-25 08:51:07 +01:00
|
|
|
aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,m_aTypeNames[i],OUString(),OUString(),
|
2010-11-25 08:51:07 +01:00
|
|
|
ColumnValue::NULLABLE,
|
|
|
|
m_aPrecisions[i],
|
|
|
|
m_aScales[i],
|
|
|
|
m_aTypes[i],
|
2014-03-31 17:30:06 +02:00
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
2012-11-01 14:19:14 +01:00
|
|
|
bCase,
|
|
|
|
m_CatalogName, getSchema(), getName());
|
2010-11-25 08:51:07 +01:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
|
|
|
m_aColumns->get().push_back(xCol);
|
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
|
|
|
|
m_pFileStream->Seek(m_aRowPosToFilePos[0].second);
|
2010-11-25 08:51:07 +01:00
|
|
|
}
|
2013-06-29 23:57:38 -05:00
|
|
|
|
|
|
|
void OFlatTable::impl_fillColumnInfo_nothrow(QuotedTokenizedString& aFirstLine, sal_Int32& nStartPosFirstLine, sal_Int32& nStartPosFirstLine2,
|
2013-07-19 01:31:53 -05:00
|
|
|
sal_Int32& io_nType, sal_Int32& io_nPrecisions, sal_Int32& io_nScales, OUString& o_sTypeName,
|
2013-06-29 23:57:38 -05:00
|
|
|
const sal_Unicode cDecimalDelimiter, const sal_Unicode cThousandDelimiter, const CharClass& aCharClass)
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
|
|
|
if ( io_nType != DataType::VARCHAR )
|
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bool bNumeric = io_nType == DataType::SQLNULL || io_nType == DataType::DOUBLE || io_nType == DataType::DECIMAL || io_nType == DataType::INTEGER;
|
2011-02-07 16:04:02 +01:00
|
|
|
sal_uLong nIndex = 0;
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( bNumeric )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2010-11-25 08:51:07 +01:00
|
|
|
// first without fielddelimiter
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aField = aFirstLine.GetTokenSpecial(nStartPosFirstLine,m_cFieldDelimiter,'\0');
|
|
|
|
if (aField.isEmpty() ||
|
|
|
|
(m_cStringDelimiter && m_cStringDelimiter == aField[0]))
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = false;
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( m_cStringDelimiter != '\0' )
|
2012-12-15 12:45:36 +00:00
|
|
|
aField = aFirstLine.GetTokenSpecial(nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
|
2010-11-25 08:51:07 +01:00
|
|
|
else
|
|
|
|
nStartPosFirstLine2 = nStartPosFirstLine;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aField2;
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( m_cStringDelimiter != '\0' )
|
2012-12-15 12:45:36 +00:00
|
|
|
aField2 = aFirstLine.GetTokenSpecial(nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
|
2010-11-25 08:51:07 +01:00
|
|
|
else
|
|
|
|
aField2 = aField;
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-07-19 01:31:53 -05:00
|
|
|
if (aField2.isEmpty())
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = false;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2010-11-25 08:51:07 +01:00
|
|
|
else
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = true;
|
2013-11-13 10:51:58 +00:00
|
|
|
sal_Int32 nDot = 0;
|
|
|
|
sal_Int32 nDecimalDelCount = 0;
|
|
|
|
sal_Int32 nSpaceCount = 0;
|
2013-10-28 12:21:40 +02:00
|
|
|
for( sal_Int32 j = 0; j < aField2.getLength(); j++ )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
const sal_Unicode c = aField2[j];
|
2010-11-25 15:39:55 +01:00
|
|
|
if ( j == nSpaceCount && m_cFieldDelimiter != 32 && c == 32 )
|
|
|
|
{
|
|
|
|
++nSpaceCount;
|
2000-10-05 13:47:22 +00:00
|
|
|
continue;
|
2010-11-25 15:39:55 +01:00
|
|
|
}
|
2011-03-12 02:42:58 +01:00
|
|
|
// just digits, decimal- and thousands-delimiter?
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( ( !cDecimalDelimiter || c != cDecimalDelimiter ) &&
|
|
|
|
( !cThousandDelimiter || c != cThousandDelimiter ) &&
|
|
|
|
!aCharClass.isDigit(aField2,j) &&
|
|
|
|
( j != 0 || (c != '+' && c != '-' ) ) )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = false;
|
2000-10-05 13:47:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-11-25 08:51:07 +01:00
|
|
|
if (cDecimalDelimiter && c == cDecimalDelimiter)
|
|
|
|
{
|
|
|
|
io_nPrecisions = 15; // we have an decimal value
|
|
|
|
io_nScales = 2;
|
|
|
|
++nDecimalDelCount;
|
|
|
|
} // if (cDecimalDelimiter && c == cDecimalDelimiter)
|
|
|
|
if ( c == '.' )
|
|
|
|
++nDot;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nDecimalDelCount > 1 || nDot > 1 ) // if there is more than one dot it isn't a number
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = false;
|
2010-11-25 08:51:07 +01:00
|
|
|
if (bNumeric && cThousandDelimiter)
|
|
|
|
{
|
2011-03-12 02:42:58 +01:00
|
|
|
// Is the delimiter correct?
|
2013-07-19 01:31:53 -05:00
|
|
|
const OUString aValue = aField2.getToken(0,cDecimalDelimiter);
|
2013-10-28 12:21:40 +02:00
|
|
|
for( sal_Int32 j = aValue.getLength() - 4; j >= 0; j -= 4)
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
const sal_Unicode c = aValue[j];
|
2011-03-12 02:42:58 +01:00
|
|
|
// just digits, decimal- and thousands-delimiter?
|
2010-11-25 08:51:07 +01:00
|
|
|
if (c == cThousandDelimiter && j)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
2014-04-16 09:14:24 +02:00
|
|
|
bNumeric = false;
|
2010-11-25 08:51:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
// now also check for a date field
|
2010-11-25 08:51:07 +01:00
|
|
|
if (!bNumeric)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( io_nType == DataType::DATE || io_nType == DataType::TIMESTAMP || io_nType == DataType::TIME)
|
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aField = aFirstLine.GetTokenSpecial(nStartPosFirstLine,m_cFieldDelimiter,'\0');
|
|
|
|
if (aField.isEmpty() ||
|
|
|
|
(m_cStringDelimiter && m_cStringDelimiter == aField[0]))
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aField2;
|
2010-11-25 08:51:07 +01:00
|
|
|
if ( m_cStringDelimiter != '\0' )
|
2012-12-15 12:45:36 +00:00
|
|
|
aField2 = aFirstLine.GetTokenSpecial(nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
|
2010-11-25 08:51:07 +01:00
|
|
|
else
|
|
|
|
aField2 = aField;
|
2013-07-19 01:31:53 -05:00
|
|
|
if (!aField2.isEmpty() )
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2000-12-12 09:44:18 +00:00
|
|
|
try
|
|
|
|
{
|
2002-10-31 13:15:29 +00:00
|
|
|
nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
|
2000-12-12 09:44:18 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 nFlags = 0;
|
|
|
|
if (bNumeric)
|
|
|
|
{
|
|
|
|
if (cDecimalDelimiter)
|
|
|
|
{
|
2010-11-25 08:51:07 +01:00
|
|
|
if(io_nPrecisions)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::DECIMAL;
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sDECIMAL("DECIMAL");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sDECIMAL;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::DOUBLE;
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sDOUBLE("DOUBLE");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sDOUBLE;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-11-25 08:51:07 +01:00
|
|
|
{
|
|
|
|
io_nType = DataType::INTEGER;
|
|
|
|
io_nPrecisions = 0;
|
|
|
|
io_nScales = 0;
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
nFlags = ColumnSearch::BASIC;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-11 09:48:50 +00:00
|
|
|
switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex))
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
|
|
|
case NUMBERFORMAT_DATE:
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::DATE;
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sDATE("DATE");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sDATE;
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
break;
|
|
|
|
case NUMBERFORMAT_DATETIME:
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::TIMESTAMP;
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sTIMESTAMP("TIMESTAMP");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sTIMESTAMP;
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
break;
|
|
|
|
case NUMBERFORMAT_TIME:
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::TIME;
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sTIME("TIME");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sTIME;
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nType = DataType::VARCHAR;
|
2011-03-12 02:42:58 +01:00
|
|
|
io_nPrecisions = 0; // nyi: Data can be longer!
|
2010-11-25 08:51:07 +01:00
|
|
|
io_nScales = 0;
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sVARCHAR("VARCHAR");
|
2010-11-25 08:51:07 +01:00
|
|
|
o_sTypeName = s_sVARCHAR;
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
};
|
|
|
|
nFlags |= ColumnSearch::CHAR;
|
|
|
|
}
|
|
|
|
}
|
2010-11-25 15:39:55 +01:00
|
|
|
else
|
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aField = aFirstLine.GetTokenSpecial(nStartPosFirstLine,m_cFieldDelimiter,'\0');
|
|
|
|
if (aField.isEmpty() ||
|
|
|
|
(m_cStringDelimiter && m_cStringDelimiter == aField[0]))
|
2000-12-14 12:15:04 +00:00
|
|
|
{
|
2010-11-25 15:39:55 +01:00
|
|
|
if ( m_cStringDelimiter != '\0' )
|
2013-07-19 01:31:53 -05:00
|
|
|
aField = aFirstLine.GetTokenSpecial(nStartPosFirstLine2, m_cFieldDelimiter, m_cStringDelimiter);
|
2010-11-25 15:39:55 +01:00
|
|
|
else
|
|
|
|
nStartPosFirstLine2 = nStartPosFirstLine;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_cStringDelimiter != '\0' )
|
2013-07-19 01:31:53 -05:00
|
|
|
aFirstLine.GetTokenSpecial(nStartPosFirstLine2, m_cFieldDelimiter, m_cStringDelimiter);
|
2000-12-14 12:15:04 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2001-09-25 12:12:51 +00:00
|
|
|
OFlatTable::OFlatTable(sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& _Name,
|
|
|
|
const OUString& _Type,
|
|
|
|
const OUString& _Description ,
|
|
|
|
const OUString& _SchemaName,
|
|
|
|
const OUString& _CatalogName
|
2001-09-25 12:12:51 +00:00
|
|
|
) : OFlatTable_BASE(_pTables,_pConnection,_Name,
|
2000-10-05 13:47:22 +00:00
|
|
|
_Type,
|
|
|
|
_Description,
|
|
|
|
_SchemaName,
|
|
|
|
_CatalogName)
|
|
|
|
,m_nRowPos(0)
|
|
|
|
,m_nMaxRowCount(0)
|
2009-04-23 10:42:05 +00:00
|
|
|
,m_cStringDelimiter(_pConnection->getStringDelimiter())
|
|
|
|
,m_cFieldDelimiter(_pConnection->getFieldDelimiter())
|
|
|
|
,m_bNeedToReadLine(false)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
|
|
|
|
2002-10-08 07:26:17 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2002-10-08 07:26:17 +00:00
|
|
|
void OFlatTable::construct()
|
|
|
|
{
|
2008-03-05 15:31:20 +00:00
|
|
|
SvtSysLocale aLocale;
|
2012-11-23 23:06:10 +01:00
|
|
|
::com::sun::star::lang::Locale aAppLocale(aLocale.GetLanguageTag().getLocale());
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-05-21 16:22:38 +02:00
|
|
|
Reference< XNumberFormatsSupplier > xSupplier = NumberFormatsSupplier::createWithLocale( m_pConnection->getDriver()->getComponentContext(), aAppLocale );
|
|
|
|
m_xNumberFormatter.set( NumberFormatter::create( m_pConnection->getDriver()->getComponentContext()), UNO_QUERY_THROW);
|
2000-10-05 13:47:22 +00:00
|
|
|
m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier);
|
2009-04-23 10:42:05 +00:00
|
|
|
Reference<XPropertySet> xProp(xSupplier->getNumberFormatSettings(),UNO_QUERY);
|
2013-06-29 21:24:12 +02:00
|
|
|
xProp->getPropertyValue("NullDate") >>= m_aNullDate;
|
2000-10-05 13:47:22 +00:00
|
|
|
|
|
|
|
INetURLObject aURL;
|
2000-11-16 09:47:23 +00:00
|
|
|
aURL.SetURL(getEntry());
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
if(aURL.getExtension() != OUString(m_pConnection->getExtension()))
|
2000-10-05 13:47:22 +00:00
|
|
|
aURL.setExtension(m_pConnection->getExtension());
|
|
|
|
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
|
2000-11-16 09:47:23 +00:00
|
|
|
|
2001-07-17 11:37:19 +00:00
|
|
|
m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
|
2000-11-16 09:47:23 +00:00
|
|
|
|
|
|
|
if(!m_pFileStream)
|
2001-07-17 11:37:19 +00:00
|
|
|
m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2000-11-16 09:47:23 +00:00
|
|
|
if(m_pFileStream)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-04-11 20:00:14 +02:00
|
|
|
sal_uInt64 const nSize = m_pFileStream->remainingSize();
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2011-02-21 16:14:21 +01:00
|
|
|
// Buffersize is dependent on the file-size
|
2000-11-16 09:47:23 +00:00
|
|
|
m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
|
2000-10-05 13:47:22 +00:00
|
|
|
nSize > 100000 ? 16384 :
|
|
|
|
nSize > 10000 ? 4096 : 1024);
|
|
|
|
|
2005-12-21 12:16:52 +00:00
|
|
|
fillColumns(aAppLocale);
|
2000-10-05 13:47:22 +00:00
|
|
|
|
|
|
|
refreshColumns();
|
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString OFlatTable::getEntry()
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sURL;
|
2004-08-02 16:04:35 +00:00
|
|
|
try
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2004-08-02 16:04:35 +00:00
|
|
|
Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet();
|
|
|
|
Reference< XRow> xRow(xDir,UNO_QUERY);
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sName;
|
|
|
|
OUString sExt;
|
2004-08-02 16:04:35 +00:00
|
|
|
|
|
|
|
INetURLObject aURL;
|
|
|
|
xDir->beforeFirst();
|
2013-04-07 12:06:47 +02:00
|
|
|
static const OUString s_sSeparator("/");
|
2004-08-02 16:04:35 +00:00
|
|
|
while(xDir->next())
|
|
|
|
{
|
|
|
|
sName = xRow->getString(1);
|
|
|
|
aURL.SetSmartProtocol(INET_PROT_FILE);
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString sUrl = m_pConnection->getURL() + s_sSeparator + sName;
|
2004-08-02 16:04:35 +00:00
|
|
|
aURL.SetSmartURL( sUrl );
|
2000-12-10 18:30:10 +00:00
|
|
|
|
2004-08-02 16:04:35 +00:00
|
|
|
// cut the extension
|
|
|
|
sExt = aURL.getExtension();
|
2000-12-10 18:30:10 +00:00
|
|
|
|
2004-08-02 16:04:35 +00:00
|
|
|
// name and extension have to coincide
|
|
|
|
if ( m_pConnection->matchesExtension( sExt ) )
|
|
|
|
{
|
2011-12-14 23:13:36 -02:00
|
|
|
if ( !sExt.isEmpty() )
|
2013-07-19 01:31:53 -05:00
|
|
|
sName = sName.replaceAt(sName.getLength() - (sExt.getLength() + 1), sExt.getLength()+1, OUString());
|
2004-08-02 16:04:35 +00:00
|
|
|
if ( sName == m_Name )
|
|
|
|
{
|
|
|
|
Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY );
|
|
|
|
sURL = xContentAccess->queryContentIdentifierString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2004-08-02 16:04:35 +00:00
|
|
|
xDir->beforeFirst(); // move back to before first record
|
|
|
|
}
|
2012-06-12 13:40:45 +01:00
|
|
|
catch(const Exception&)
|
2004-08-02 16:04:35 +00:00
|
|
|
{
|
2014-01-28 19:56:39 +01:00
|
|
|
OSL_ASSERT(false);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2012-06-12 13:40:45 +01:00
|
|
|
return sURL;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-10-05 13:47:22 +00:00
|
|
|
void OFlatTable::refreshColumns()
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2001-05-02 11:57:37 +00:00
|
|
|
TStringVector aVector;
|
2008-12-30 13:32:01 +00:00
|
|
|
aVector.reserve(m_aColumns->get().size());
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter)
|
2000-10-05 13:47:22 +00:00
|
|
|
aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
|
|
|
|
|
|
|
|
if(m_pColumns)
|
2001-05-04 08:58:45 +00:00
|
|
|
m_pColumns->reFill(aVector);
|
|
|
|
else
|
|
|
|
m_pColumns = new OFlatColumns(this,m_aMutex,aVector);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-10-05 13:47:22 +00:00
|
|
|
void SAL_CALL OFlatTable::disposing(void)
|
|
|
|
{
|
|
|
|
OFileTable::disposing();
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2001-05-07 09:37:54 +00:00
|
|
|
m_aColumns = NULL;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Sequence< Type > SAL_CALL OFlatTable::getTypes( ) throw(RuntimeException, std::exception)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
|
|
|
Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
|
2013-05-19 13:20:51 +02:00
|
|
|
vector<Type> aOwnTypes;
|
2001-10-18 12:24:06 +00:00
|
|
|
aOwnTypes.reserve(aTypes.getLength());
|
2000-10-05 13:47:22 +00:00
|
|
|
const Type* pBegin = aTypes.getConstArray();
|
|
|
|
const Type* pEnd = pBegin + aTypes.getLength();
|
2001-05-31 05:11:58 +00:00
|
|
|
for(;pBegin != pEnd;++pBegin)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-05-22 23:19:05 +02:00
|
|
|
if(!(*pBegin == cppu::UnoType<XKeysSupplier>::get()||
|
|
|
|
*pBegin == cppu::UnoType<XRename>::get()||
|
|
|
|
*pBegin == cppu::UnoType<XIndexesSupplier>::get()||
|
|
|
|
*pBegin == cppu::UnoType<XAlterTable>::get()||
|
|
|
|
*pBegin == cppu::UnoType<XDataDescriptorFactory>::get()))
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2001-10-18 12:24:06 +00:00
|
|
|
aOwnTypes.push_back(*pBegin);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-08 15:21:22 +00:00
|
|
|
Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
|
|
|
|
return Sequence< Type >(pTypes, aOwnTypes.size());
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Any SAL_CALL OFlatTable::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2014-05-22 23:19:05 +02:00
|
|
|
if( rType == cppu::UnoType<XKeysSupplier>::get()||
|
|
|
|
rType == cppu::UnoType<XIndexesSupplier>::get()||
|
|
|
|
rType == cppu::UnoType<XRename>::get()||
|
|
|
|
rType == cppu::UnoType<XAlterTable>::get()||
|
|
|
|
rType == cppu::UnoType<XDataDescriptorFactory>::get())
|
2000-10-05 13:47:22 +00:00
|
|
|
return Any();
|
|
|
|
|
2001-08-24 05:19:41 +00:00
|
|
|
Any aRet = OTable_TYPEDEF::queryInterface(rType);
|
|
|
|
return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-10-05 13:47:22 +00:00
|
|
|
Sequence< sal_Int8 > OFlatTable::getUnoTunnelImplementationId()
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId * pId = 0;
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId aId;
|
|
|
|
pId = &aId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pId->getImplementationId();
|
|
|
|
}
|
|
|
|
|
|
|
|
// com::sun::star::lang::XUnoTunnel
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException, std::exception)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2012-08-05 19:01:37 +02:00
|
|
|
return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
|
2006-06-20 00:28:52 +00:00
|
|
|
? reinterpret_cast< sal_Int64 >( this )
|
|
|
|
: OFlatTable_BASE::getSomething(rId);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool OFlatTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool bIsTable, bool bRetrieveData)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
*(_rRow->get())[0] = m_nFilePos;
|
2000-10-05 13:47:22 +00:00
|
|
|
|
|
|
|
if (!bRetrieveData)
|
2014-04-16 09:14:24 +02:00
|
|
|
return true;
|
2013-05-19 13:20:51 +02:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool result = false;
|
2009-04-23 10:42:05 +00:00
|
|
|
if ( m_bNeedToReadLine )
|
|
|
|
{
|
|
|
|
m_pFileStream->Seek(m_nFilePos);
|
2013-05-19 13:20:51 +02:00
|
|
|
TRowPositionInFile rowPos(0, 0);
|
|
|
|
if(readLine(&rowPos.second, &rowPos.first))
|
|
|
|
{
|
|
|
|
setRowPos(m_nRowPos, rowPos);
|
|
|
|
m_bNeedToReadLine = false;
|
2014-04-16 09:14:24 +02:00
|
|
|
result = true;
|
2013-05-19 13:20:51 +02:00
|
|
|
}
|
|
|
|
// else let run through so that we set _rRow to all NULL
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
const OFlatConnection * const pConnection = getFlatConnection();
|
2009-04-23 10:42:05 +00:00
|
|
|
const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
|
|
|
|
const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
|
2011-02-21 16:14:21 +01:00
|
|
|
// Fields:
|
2013-06-29 23:57:38 -05:00
|
|
|
sal_Int32 nStartPos = 0;
|
2008-12-30 13:32:01 +00:00
|
|
|
OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
|
|
|
|
OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end();
|
2009-04-23 10:42:05 +00:00
|
|
|
const OValueRefVector::Vector::size_type nCount = _rRow->get().size();
|
2013-05-19 13:20:51 +02:00
|
|
|
for (OValueRefVector::Vector::size_type i = 1;
|
|
|
|
aIter != aEnd && i < nCount;
|
2006-06-20 00:28:52 +00:00
|
|
|
++aIter, i++)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
OUString aStr = m_aCurrentLine.GetTokenSpecial(nStartPos,m_cFieldDelimiter,m_cStringDelimiter);
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-07-19 01:31:53 -05:00
|
|
|
if (aStr.isEmpty())
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
(_rRow->get())[i]->setNull();
|
2013-07-19 01:31:53 -05:00
|
|
|
}
|
2001-07-30 07:53:02 +00:00
|
|
|
else
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2011-02-21 16:14:21 +01:00
|
|
|
// lengths depending on data-type:
|
2013-07-19 01:31:53 -05:00
|
|
|
sal_Int32 nLen;
|
|
|
|
sal_Int32 nType = 0;
|
2001-07-30 07:53:02 +00:00
|
|
|
if(bIsTable)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2007-09-26 13:29:25 +00:00
|
|
|
nLen = m_aPrecisions[i-1];
|
|
|
|
nType = m_aTypes[i-1];
|
2001-07-30 07:53:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference< XPropertySet> xColumn = *aIter;
|
|
|
|
xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
|
|
|
|
xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
|
|
|
|
}
|
|
|
|
switch(nType)
|
|
|
|
{
|
|
|
|
case DataType::TIMESTAMP:
|
|
|
|
case DataType::DATE:
|
|
|
|
case DataType::TIME:
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2001-07-30 07:53:02 +00:00
|
|
|
try
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
double nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr);
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2001-07-30 07:53:02 +00:00
|
|
|
switch(nType)
|
|
|
|
{
|
|
|
|
case DataType::DATE:
|
2009-04-23 10:42:05 +00:00
|
|
|
*(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,m_aNullDate));
|
2001-07-30 07:53:02 +00:00
|
|
|
break;
|
|
|
|
case DataType::TIMESTAMP:
|
2009-04-23 10:42:05 +00:00
|
|
|
*(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,m_aNullDate));
|
2001-07-30 07:53:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-30 13:32:01 +00:00
|
|
|
*(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes));
|
2001-07-30 07:53:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
(_rRow->get())[i]->setNull();
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2001-07-30 07:53:02 +00:00
|
|
|
} break;
|
|
|
|
case DataType::DOUBLE:
|
|
|
|
case DataType::INTEGER:
|
2011-02-21 16:14:21 +01:00
|
|
|
case DataType::DECIMAL:
|
2002-10-15 08:12:57 +00:00
|
|
|
case DataType::NUMERIC:
|
2000-10-05 13:47:22 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
|
2012-12-15 12:42:04 +00:00
|
|
|
OUString aStrConverted;
|
2009-04-23 10:42:05 +00:00
|
|
|
if ( DataType::INTEGER != nType )
|
|
|
|
{
|
2010-11-18 14:36:24 +00:00
|
|
|
OSL_ENSURE((cDecimalDelimiter && nType != DataType::INTEGER) ||
|
|
|
|
(!cDecimalDelimiter && nType == DataType::INTEGER),
|
2009-04-23 10:42:05 +00:00
|
|
|
"FalscherTyp");
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2013-07-19 01:31:53 -05:00
|
|
|
OUStringBuffer aBuf(aStr.getLength());
|
2011-02-21 16:14:21 +01:00
|
|
|
// convert to Standard-Notation (DecimalPOINT without thousands-comma):
|
2013-07-19 01:31:53 -05:00
|
|
|
for (sal_Int32 j = 0; j < aStr.getLength(); ++j)
|
2001-07-30 07:53:02 +00:00
|
|
|
{
|
2013-07-19 01:31:53 -05:00
|
|
|
const sal_Unicode cChar = aStr[j];
|
2009-04-23 10:42:05 +00:00
|
|
|
if (cDecimalDelimiter && cChar == cDecimalDelimiter)
|
2012-12-15 12:42:04 +00:00
|
|
|
aBuf.append('.');
|
2013-05-15 10:42:04 +03:00
|
|
|
else if ( cChar == '.' ) // special case, if decimal separator isn't '.' we have to put the string after it
|
2011-02-21 16:14:21 +01:00
|
|
|
continue;
|
2009-04-23 10:42:05 +00:00
|
|
|
else if (cThousandDelimiter && cChar == cThousandDelimiter)
|
|
|
|
{
|
2011-02-21 16:14:21 +01:00
|
|
|
// leave out
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
|
|
|
else
|
2012-12-15 12:42:04 +00:00
|
|
|
aBuf.append(cChar);
|
2013-07-19 01:31:53 -05:00
|
|
|
} // for (j = 0; j < aStr.getLength(); ++j)
|
2012-12-15 12:42:04 +00:00
|
|
|
aStrConverted = aBuf.makeStringAndClear();
|
2009-04-23 10:42:05 +00:00
|
|
|
} // if ( DataType::INTEGER != nType )
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( cThousandDelimiter )
|
2011-11-18 21:03:31 +00:00
|
|
|
aStrConverted = comphelper::string::remove(aStr, cThousandDelimiter);
|
|
|
|
else
|
|
|
|
aStrConverted = aStr;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2009-04-23 10:42:05 +00:00
|
|
|
const double nVal = ::rtl::math::stringToDouble(aStrConverted,'.',',',NULL,NULL);
|
2002-10-15 08:12:57 +00:00
|
|
|
|
|
|
|
// #99178# OJ
|
|
|
|
if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType )
|
2013-01-20 10:51:58 +01:00
|
|
|
*(_rRow->get())[i] = OUString::number(nVal);
|
2002-10-15 08:12:57 +00:00
|
|
|
else
|
2008-12-30 13:32:01 +00:00
|
|
|
*(_rRow->get())[i] = nVal;
|
2001-07-30 07:53:02 +00:00
|
|
|
} break;
|
2002-10-15 08:12:57 +00:00
|
|
|
|
2001-07-30 07:53:02 +00:00
|
|
|
default:
|
|
|
|
{
|
2011-02-21 16:14:21 +01:00
|
|
|
// Copy Value as String in Row-Variable
|
2008-12-30 13:32:01 +00:00
|
|
|
*(_rRow->get())[i] = ORowSetValue(aStr);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2001-07-30 07:53:02 +00:00
|
|
|
break;
|
2009-04-23 10:42:05 +00:00
|
|
|
} // switch(nType)
|
|
|
|
(_rRow->get())[i]->setTypeKind(nType);
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
return result;
|
2000-10-05 13:47:22 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
CWS-TOOLING: integrate CWS dba32e
2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected
2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte
2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name
2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard
2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus
2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up
2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up
2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct
2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0
2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected
2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string
2009-07-20 11:40:39 +0200 fs r274117 : removed unused include
2009-07-20 11:40:01 +0200 fs r274116 : class name corrected
2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path
2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst
2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar
2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well
2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths
2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality
2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52)
2009-07-01 21:41:50 +0200 fs r273614 : #i10000#
2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents
2009-07-01 12:10:31 +0200 fs r273562 : updated
2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names
2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays
2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder
2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb
2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d
2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions
2009-06-29 10:01:13 +0200 fs r273453 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays
2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899#
2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes
2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes
2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log
2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts
2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string
2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime
2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata
2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge
2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved
2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set
2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge
2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge
2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing
2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d
2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries?
2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed
2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix
2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section
2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox
2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop
2009-06-19 13:18:26 +0200 oj r273157 : remove unused param
2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50)
2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e
2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e
2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e
2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50
2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text
2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any
2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid
2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ...
2009-06-10 09:53:20 +0200 oj r272797 : add lic text
2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618
2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed
2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property
2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases
2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases
2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases
2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid
2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing
2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType
2009-06-08 13:51:20 +0200 oj r272730 : add tests
2009-06-05 14:38:01 +0200 oj r272686 : add dep
2009-06-05 14:35:00 +0200 oj r272684 : add new tests
2009-06-05 13:41:18 +0200 oj r272681 : code clean ups
2009-06-05 12:40:51 +0200 oj r272678 : code cleanup
2009-06-05 12:02:57 +0200 oj r272677 : code cleanup
2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML
2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard
2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
|
|
|
void OFlatTable::refreshHeader()
|
|
|
|
{
|
2013-06-15 01:56:13 +03:00
|
|
|
SAL_INFO( "connectivity.drivers", "flat lionel@mamane.lu OFlatTable::refreshHeader" );
|
2013-05-19 13:20:51 +02:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
namespace
|
|
|
|
{
|
2013-11-30 11:58:39 +01:00
|
|
|
template< typename Tp, typename Te> struct RangeBefore
|
2013-05-19 13:20:51 +02:00
|
|
|
{
|
2013-05-29 20:31:08 +02:00
|
|
|
bool operator() (const Tp &p, const Te &e)
|
|
|
|
{
|
2013-11-30 11:58:39 +01:00
|
|
|
assert(p.first <= p.second);
|
|
|
|
return p.second <= e;
|
2013-05-29 20:31:08 +02:00
|
|
|
}
|
|
|
|
};
|
CWS-TOOLING: integrate CWS dba32e
2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected
2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte
2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name
2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard
2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus
2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up
2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up
2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct
2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0
2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected
2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string
2009-07-20 11:40:39 +0200 fs r274117 : removed unused include
2009-07-20 11:40:01 +0200 fs r274116 : class name corrected
2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path
2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst
2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar
2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well
2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths
2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality
2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52)
2009-07-01 21:41:50 +0200 fs r273614 : #i10000#
2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents
2009-07-01 12:10:31 +0200 fs r273562 : updated
2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names
2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays
2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder
2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb
2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d
2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions
2009-06-29 10:01:13 +0200 fs r273453 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays
2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899#
2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes
2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes
2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log
2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts
2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string
2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime
2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata
2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge
2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved
2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set
2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge
2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge
2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing
2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d
2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries?
2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed
2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix
2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section
2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox
2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop
2009-06-19 13:18:26 +0200 oj r273157 : remove unused param
2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50)
2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e
2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e
2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e
2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50
2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text
2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any
2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid
2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ...
2009-06-10 09:53:20 +0200 oj r272797 : add lic text
2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618
2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed
2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property
2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases
2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases
2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases
2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid
2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing
2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType
2009-06-08 13:51:20 +0200 oj r272730 : add tests
2009-06-05 14:38:01 +0200 oj r272686 : add dep
2009-06-05 14:35:00 +0200 oj r272684 : add new tests
2009-06-05 13:41:18 +0200 oj r272681 : code clean ups
2009-06-05 12:40:51 +0200 oj r272678 : code cleanup
2009-06-05 12:02:57 +0200 oj r272677 : code cleanup
2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML
2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard
2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
|
2006-06-20 00:28:52 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
OSL_ENSURE(m_pFileStream,"OFlatTable::seekRow: FileStream is NULL!");
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-10-05 13:47:22 +00:00
|
|
|
|
2006-06-20 00:28:52 +00:00
|
|
|
switch(eCursorPosition)
|
|
|
|
{
|
|
|
|
case IResultSetHelper::FIRST:
|
2009-04-23 10:42:05 +00:00
|
|
|
m_nRowPos = 0;
|
2006-06-20 00:28:52 +00:00
|
|
|
// run through
|
|
|
|
case IResultSetHelper::NEXT:
|
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
assert(m_nRowPos >= 0);
|
2013-05-19 08:37:05 +02:00
|
|
|
if(m_nMaxRowCount != 0 && m_nRowPos > m_nMaxRowCount)
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2009-04-23 10:42:05 +00:00
|
|
|
++m_nRowPos;
|
2013-05-19 13:20:51 +02:00
|
|
|
if(m_aRowPosToFilePos.size() > static_cast< vector< TRowPositionInFile >::size_type >(m_nRowPos))
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
m_bNeedToReadLine = true;
|
|
|
|
m_nFilePos = m_aRowPosToFilePos[m_nRowPos].first;
|
|
|
|
nCurPos = m_aRowPosToFilePos[m_nRowPos].second;
|
|
|
|
}
|
2009-04-23 10:42:05 +00:00
|
|
|
else
|
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
assert(m_aRowPosToFilePos.size() == static_cast< vector< TRowPositionInFile >::size_type >(m_nRowPos));
|
|
|
|
const TRowPositionInFile &lastRowPos(m_aRowPosToFilePos.back());
|
|
|
|
// Our ResultSet is allowed to disagree with us only
|
|
|
|
// on the position of the first line
|
|
|
|
// (because of the special case of the header...)
|
|
|
|
assert(m_nRowPos == 1 || nCurPos == lastRowPos.second);
|
|
|
|
|
|
|
|
m_nFilePos = lastRowPos.second;
|
2009-04-23 10:42:05 +00:00
|
|
|
m_pFileStream->Seek(m_nFilePos);
|
2013-05-19 13:20:51 +02:00
|
|
|
|
|
|
|
TRowPositionInFile newRowPos;
|
|
|
|
if(!readLine(&newRowPos.second, &newRowPos.first, false))
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
m_nMaxRowCount = m_nRowPos - 1;
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 13:20:51 +02:00
|
|
|
}
|
2006-06-20 00:28:52 +00:00
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
nCurPos = newRowPos.second;
|
|
|
|
setRowPos(m_nRowPos, newRowPos);
|
2009-04-23 10:42:05 +00:00
|
|
|
}
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
2008-01-30 06:53:01 +00:00
|
|
|
|
2006-06-20 00:28:52 +00:00
|
|
|
break;
|
|
|
|
case IResultSetHelper::PRIOR:
|
2013-05-19 08:37:05 +02:00
|
|
|
assert(m_nRowPos >= 0);
|
|
|
|
|
|
|
|
if(m_nRowPos == 0)
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 08:37:05 +02:00
|
|
|
|
2006-06-20 00:28:52 +00:00
|
|
|
--m_nRowPos;
|
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
assert (m_nRowPos >= 0);
|
|
|
|
assert(m_aRowPosToFilePos.size() >= static_cast< vector< TRowPositionInFile >::size_type >(m_nRowPos));
|
|
|
|
const TRowPositionInFile &aPositions(m_aRowPosToFilePos[m_nRowPos]);
|
|
|
|
m_nFilePos = aPositions.first;
|
|
|
|
nCurPos = aPositions.second;
|
2009-04-23 10:42:05 +00:00
|
|
|
m_bNeedToReadLine = true;
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IResultSetHelper::LAST:
|
2013-05-19 13:20:51 +02:00
|
|
|
if (m_nMaxRowCount == 0)
|
2006-06-20 00:28:52 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
while(seekRow(IResultSetHelper::NEXT, 1, nCurPos)) ; // run through after last row
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
// m_nMaxRowCount can still be zero, but now it means there a genuinely zero rows in the table
|
|
|
|
return seekRow(IResultSetHelper::ABSOLUTE, m_nMaxRowCount, nCurPos);
|
2006-06-20 00:28:52 +00:00
|
|
|
break;
|
|
|
|
case IResultSetHelper::RELATIVE:
|
|
|
|
{
|
2013-05-19 08:37:05 +02:00
|
|
|
const sal_Int32 nNewRowPos = m_nRowPos + nOffset;
|
2013-05-19 13:20:51 +02:00
|
|
|
if (nNewRowPos < 0)
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 13:20:51 +02:00
|
|
|
// ABSOLUTE will take care of case nNewRowPos > nMaxRowCount
|
2013-05-19 08:37:05 +02:00
|
|
|
return seekRow(IResultSetHelper::ABSOLUTE, nNewRowPos, nCurPos);
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
|
|
|
case IResultSetHelper::ABSOLUTE:
|
|
|
|
{
|
|
|
|
if(nOffset < 0)
|
2013-05-19 08:37:05 +02:00
|
|
|
{
|
|
|
|
if (m_nMaxRowCount == 0)
|
|
|
|
{
|
|
|
|
if (!seekRow(IResultSetHelper::LAST, 0, nCurPos))
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 08:37:05 +02:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
// m_nMaxRowCount can still be zero, but now it means there a genuinely zero rows in the table
|
|
|
|
nOffset = m_nMaxRowCount + nOffset;
|
2013-05-19 08:37:05 +02:00
|
|
|
}
|
|
|
|
if(nOffset < 0)
|
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
seekRow(IResultSetHelper::ABSOLUTE, 0, nCurPos);
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 08:37:05 +02:00
|
|
|
}
|
|
|
|
if(m_nMaxRowCount && nOffset > m_nMaxRowCount)
|
|
|
|
{
|
|
|
|
m_nRowPos = m_nMaxRowCount + 1;
|
2013-05-19 13:20:51 +02:00
|
|
|
const TRowPositionInFile &lastRowPos(m_aRowPosToFilePos.back());
|
|
|
|
m_nFilePos = lastRowPos.second;
|
|
|
|
nCurPos = lastRowPos.second;
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 08:37:05 +02:00
|
|
|
}
|
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
assert(m_nRowPos >=0);
|
|
|
|
assert(m_aRowPosToFilePos.size() > static_cast< vector< TRowPositionInFile >::size_type >(m_nRowPos));
|
|
|
|
assert(nOffset >= 0);
|
|
|
|
if(m_aRowPosToFilePos.size() > static_cast< vector< TRowPositionInFile >::size_type >(nOffset))
|
2006-06-20 00:28:52 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
m_nFilePos = m_aRowPosToFilePos[nOffset].first;
|
|
|
|
nCurPos = m_aRowPosToFilePos[nOffset].second;
|
2013-05-19 08:37:05 +02:00
|
|
|
m_nRowPos = nOffset;
|
2009-04-23 10:42:05 +00:00
|
|
|
m_bNeedToReadLine = true;
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
assert(m_nRowPos < nOffset);
|
|
|
|
while(m_nRowPos < nOffset)
|
2006-06-20 00:28:52 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
if(!seekRow(IResultSetHelper::NEXT, 1, nCurPos))
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
assert(m_nRowPos == nOffset);
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IResultSetHelper::BOOKMARK:
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
vector< TRowPositionInFile >::const_iterator aFind = lower_bound(m_aRowPosToFilePos.begin(),
|
|
|
|
m_aRowPosToFilePos.end(),
|
|
|
|
nOffset,
|
2013-11-30 11:58:39 +01:00
|
|
|
RangeBefore< TRowPositionInFile, sal_Int32 >());
|
2013-05-19 13:20:51 +02:00
|
|
|
|
|
|
|
if(aFind == m_aRowPosToFilePos.end() || aFind->first != nOffset)
|
2013-05-19 08:37:05 +02:00
|
|
|
//invalid bookmark
|
2014-04-16 09:14:24 +02:00
|
|
|
return false;
|
2013-05-19 13:20:51 +02:00
|
|
|
|
2013-05-19 08:37:05 +02:00
|
|
|
m_bNeedToReadLine = true;
|
|
|
|
m_nFilePos = aFind->first;
|
|
|
|
nCurPos = aFind->second;
|
2013-05-19 13:20:51 +02:00
|
|
|
m_nRowPos = aFind - m_aRowPosToFilePos.begin();
|
2009-04-23 10:42:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
return true;
|
2006-06-20 00:28:52 +00:00
|
|
|
}
|
2013-05-19 13:20:51 +02:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
bool OFlatTable::readLine(sal_Int32 * const pEndPos, sal_Int32 * const pStartPos, const bool nonEmpty)
|
2008-01-30 06:53:01 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
|
2013-05-19 13:20:51 +02:00
|
|
|
m_aCurrentLine = QuotedTokenizedString();
|
|
|
|
do
|
2008-01-30 06:53:01 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
if (pStartPos)
|
2014-02-24 21:05:01 -06:00
|
|
|
*pStartPos = (sal_Int32)m_pFileStream->Tell();
|
2013-06-29 23:57:38 -05:00
|
|
|
m_pFileStream->ReadByteStringLine(m_aCurrentLine, nEncoding);
|
2013-05-19 13:20:51 +02:00
|
|
|
if (m_pFileStream->IsEof())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QuotedTokenizedString sLine = m_aCurrentLine; // check if the string continues on next line
|
|
|
|
while( (comphelper::string::getTokenCount(sLine.GetString(), m_cStringDelimiter) % 2) != 1 )
|
2008-01-30 06:53:01 +00:00
|
|
|
{
|
2013-05-19 13:20:51 +02:00
|
|
|
m_pFileStream->ReadByteStringLine(sLine,nEncoding);
|
|
|
|
if ( !m_pFileStream->IsEof() )
|
|
|
|
{
|
2013-06-29 23:57:38 -05:00
|
|
|
OUString aStr = m_aCurrentLine.GetString() + "\n" + sLine.GetString();
|
|
|
|
m_aCurrentLine.SetString(aStr);
|
2013-05-19 13:20:51 +02:00
|
|
|
sLine = m_aCurrentLine;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2008-01-30 06:53:01 +00:00
|
|
|
}
|
2013-07-19 01:31:53 -05:00
|
|
|
}
|
|
|
|
while(nonEmpty && m_aCurrentLine.Len() == 0);
|
2013-05-19 13:20:51 +02:00
|
|
|
|
|
|
|
if(pEndPos)
|
2014-02-24 21:05:01 -06:00
|
|
|
*pEndPos = (sal_Int32)m_pFileStream->Tell();
|
2013-05-19 13:20:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-05-19 13:20:51 +02:00
|
|
|
void OFlatTable::setRowPos(const vector<TRowPositionInFile>::size_type rowNum, const TRowPositionInFile &rowPos)
|
|
|
|
{
|
|
|
|
assert(m_aRowPosToFilePos.size() >= rowNum);
|
|
|
|
if(m_aRowPosToFilePos.size() == rowNum)
|
|
|
|
m_aRowPosToFilePos.push_back(rowPos);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN_IF(m_aRowPosToFilePos[rowNum] != rowPos,
|
|
|
|
"connectivity.flat",
|
|
|
|
"Setting position for row " << rowNum << " to (" << rowPos.first << ", " << rowPos.second << "), " <<
|
|
|
|
"but already had different position (" << m_aRowPosToFilePos[rowNum].first << ", " << m_aRowPosToFilePos[rowNum].second << ")");
|
|
|
|
m_aRowPosToFilePos[rowNum] = rowPos;
|
2008-01-30 06:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|