View | Details | Raw Unified | Return to issue 101045
Collapse All | Expand All

(-)sc/source/core/data/column3.cxx (-4 / +10 lines)
Lines 1871-1880 xub_StrLen ScColumn::GetMaxNumberStringLen( USHORT& nPrecision, Link Here
1871
				if ( nLen )
1871
				if ( nLen )
1872
				{
1872
				{
1873
					if ( nFormat )
1873
					if ( nFormat )
1874
					{	// more decimals than standard?
1874
					{
1875
						USHORT nPrec = pNumFmt->GetFormatPrecision( nFormat );
1875
                        const SvNumberformat* pEntry = pNumFmt->GetEntry( nFormat );
1876
						if ( nPrec > nPrecision )
1876
                        if (pEntry)
1877
							nPrecision = nPrec;
1877
                        {
1878
                            BOOL bThousand, bNegRed;
1879
                            USHORT nLeading;
1880
                            pEntry->GetFormatSpecialInfo(bThousand, bNegRed, nPrecision, nLeading);
1881
                        }
1882
                        else
1883
                            nPrecision = pNumFmt->GetFormatPrecision( nFormat );
1878
					}
1884
					}
1879
					if ( nPrecision )
1885
					if ( nPrecision )
1880
					{	// less than nPrecision in string => widen it
1886
					{	// less than nPrecision in string => widen it
(-)sc/source/ui/docshell/docsh8.cxx (-1 / +59 lines)
Lines 80-87 Link Here
80
#include "dbdocutl.hxx"
80
#include "dbdocutl.hxx"
81
#include "dociter.hxx"
81
#include "dociter.hxx"
82
#include "globstr.hrc"
82
#include "globstr.hrc"
83
#include "svtools/zformat.hxx"
84
#include "svtools/intitem.hxx"
85
#include "patattr.hxx"
86
#include "scitems.hxx"
87
#include "docpool.hxx"
88
89
#include <vector>
83
90
84
using namespace com::sun::star;
91
using namespace com::sun::star;
92
using ::std::vector;
85
93
86
// -----------------------------------------------------------------------
94
// -----------------------------------------------------------------------
87
95
Lines 193-198 BOOL ScDocShell::IsDocument( const INetURLObject& rURL ) Link Here
193
201
194
// -----------------------------------------------------------------------
202
// -----------------------------------------------------------------------
195
203
204
static void lcl_setScalesToColumns(ScDocument& rDoc, const vector<long>& rScales)
205
{
206
    SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
207
    if (!pFormatter)
208
        return;
209
210
    SCCOL nColCount = static_cast<SCCOL>(rScales.size());
211
    for (SCCOL i = 0; i < nColCount; ++i)
212
    {
213
        if (rScales[i] < 0)
214
            continue;
215
216
        sal_uInt32 nOldFormat;
217
        rDoc.GetNumberFormat(static_cast<SCCOL>(i), 0, 0, nOldFormat);
218
        const SvNumberformat* pOldEntry = pFormatter->GetEntry(nOldFormat);
219
        if (!pOldEntry)
220
            continue;
221
222
        LanguageType eLang = pOldEntry->GetLanguage();
223
        BOOL bThousand, bNegRed;
224
        USHORT nPrecision, nLeading;
225
        pOldEntry->GetFormatSpecialInfo(bThousand, bNegRed, nPrecision, nLeading);
226
227
        nPrecision = static_cast<USHORT>(rScales[i]);
228
        String aNewPicture;
229
        pFormatter->GenerateFormat(aNewPicture, nOldFormat, eLang,
230
                                   bThousand, bNegRed, nPrecision, nLeading);
231
232
        sal_uInt32 nNewFormat = pFormatter->GetEntryKey(aNewPicture, eLang);
233
        if (nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
234
        {
235
            xub_StrLen nErrPos = 0;
236
            short nNewType = 0;
237
            bool bOk = pFormatter->PutEntry(
238
                aNewPicture, nErrPos, nNewType, nNewFormat, eLang);
239
240
            if (!bOk)
241
                continue;
242
        }
243
244
        ScPatternAttr aNewAttrs( rDoc.GetPool() );
245
        SfxItemSet& rSet = aNewAttrs.GetItemSet();
246
        rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) );
247
        rDoc.ApplyPatternAreaTab(static_cast<SCCOL>(i), 0, static_cast<SCCOL>(i), MAXROW, 0, aNewAttrs);
248
    }
249
}
250
196
ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
251
ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
197
								BOOL bSimpleColWidth[MAXCOLCOUNT] )
252
								BOOL bSimpleColWidth[MAXCOLCOUNT] )
198
{
253
{
Lines 308-313 ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, Link Here
308
		//	read column names
363
		//	read column names
309
		//!	add type descriptions
364
		//!	add type descriptions
310
365
366
        vector<long> aScales(nColCount, -1);
311
		for (i=0; i<nColCount; i++)
367
		for (i=0; i<nColCount; i++)
312
		{
368
		{
313
			String aHeader = xMeta->getColumnLabel( i+1 );
369
			String aHeader = xMeta->getColumnLabel( i+1 );
Lines 337-342 ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, Link Here
337
										nPrec, nScale ) );
393
										nPrec, nScale ) );
338
						aHeader += ',';
394
						aHeader += ',';
339
						aHeader += String::CreateFromInt32( nScale );
395
						aHeader += String::CreateFromInt32( nScale );
396
                        aScales[i] = nScale;
340
					}
397
					}
341
					break;
398
					break;
342
			}
399
			}
Lines 344-349 ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, Link Here
344
			aDocument.SetString( static_cast<SCCOL>(i), 0, 0, aHeader );
401
			aDocument.SetString( static_cast<SCCOL>(i), 0, 0, aHeader );
345
		}
402
		}
346
403
404
        lcl_setScalesToColumns(aDocument, aScales);
405
347
		SCROW nRow = 1;		// 0 is column titles
406
		SCROW nRow = 1;		// 0 is column titles
348
		BOOL bEnd = FALSE;
407
		BOOL bEnd = FALSE;
349
		while ( !bEnd && xRowSet->next() )
408
		while ( !bEnd && xRowSet->next() )
Lines 470-476 void lcl_GetColumnTypes( ScDocShell& rDocShell, Link Here
470
						break;
529
						break;
471
					case 'N' :
530
					case 'N' :
472
						nDbType = sdbc::DataType::DECIMAL;
531
						nDbType = sdbc::DataType::DECIMAL;
473
						bTypeDefined = TRUE;
474
						break;
532
						break;
475
				}
533
				}
476
				if ( bTypeDefined && !nFieldLen && nToken > 2 )
534
				if ( bTypeDefined && !nFieldLen && nToken > 2 )

Return to issue 101045