From 44ccce1e58ad84329f5d5d9f233c5ae844422218 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 11:27:09 -0400 Subject: #i3687# #i97416#: initial porting of patches from ooo-build. --- sc/source/ui/dbgui/asciiopt.cxx | 16 ++++ sc/source/ui/dbgui/asciiopt.hrc | 1 + sc/source/ui/dbgui/asciiopt.src | 17 ++-- sc/source/ui/dbgui/csvgrid.cxx | 3 +- sc/source/ui/dbgui/csvruler.cxx | 75 ++++++++++++++++ sc/source/ui/dbgui/scuiasciiopt.cxx | 166 +++++++++++++++++++++++++++++++++--- sc/source/ui/docshell/impex.cxx | 22 +++-- sc/source/ui/inc/asciiopt.hxx | 3 + sc/source/ui/inc/csvruler.hxx | 1 + sc/source/ui/inc/impex.hxx | 2 +- sc/source/ui/inc/scuiasciiopt.hxx | 2 + 11 files changed, 280 insertions(+), 28 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index a2a20a047a3e..fbe13bbd0370 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -56,6 +56,7 @@ ScAsciiOptions::ScAsciiOptions() : bFixedLen ( FALSE ), aFieldSeps ( ';' ), bMergeFieldSeps ( FALSE ), + bQuotedFieldAsText(false), cTextSep ( cDefaultTextSep ), eCharSet ( gsl_getSystemTextEncoding() ), bCharSetSystem ( FALSE ), @@ -71,6 +72,7 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : bFixedLen ( rOpt.bFixedLen ), aFieldSeps ( rOpt.aFieldSeps ), bMergeFieldSeps ( rOpt.bMergeFieldSeps ), + bQuotedFieldAsText(rOpt.bQuotedFieldAsText), cTextSep ( rOpt.cTextSep ), eCharSet ( rOpt.eCharSet ), bCharSetSystem ( rOpt.bCharSetSystem ), @@ -155,6 +157,7 @@ ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy ) bFixedLen = rCpy.bFixedLen; aFieldSeps = rCpy.aFieldSeps; bMergeFieldSeps = rCpy.bMergeFieldSeps; + bQuotedFieldAsText = rCpy.bQuotedFieldAsText; cTextSep = rCpy.cTextSep; eCharSet = rCpy.eCharSet; bCharSetSystem = rCpy.bCharSetSystem; @@ -169,6 +172,7 @@ BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const if ( bFixedLen == rCmp.bFixedLen && aFieldSeps == rCmp.aFieldSeps && bMergeFieldSeps == rCmp.bMergeFieldSeps && + bQuotedFieldAsText == rCmp.bQuotedFieldAsText && cTextSep == rCmp.cTextSep && eCharSet == rCmp.eCharSet && bCharSetSystem == rCmp.bCharSetSystem && @@ -286,6 +290,13 @@ void ScAsciiOptions::ReadFromString( const String& rString ) pColFormat = NULL; } } + + // Import quoted field as text. + if (nCount >= 6) + { + aToken = rString.GetToken(5, ','); + bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false; + } } @@ -357,6 +368,11 @@ String ScAsciiOptions::WriteToString() const aOutStr += String::CreateFromInt32(pColFormat[nInfo]); } + aOutStr += ','; + + // Import quoted field as text. + aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false"); + return aOutStr; } diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc index 29dca4596441..3177a1be7b78 100644 --- a/sc/source/ui/dbgui/asciiopt.hrc +++ b/sc/source/ui/dbgui/asciiopt.hrc @@ -56,4 +56,5 @@ #define FT_AT_ROW 59 #define NF_AT_ROW 60 #define CB_ASONCE 90 +#define CB_QUOTED_AS_TEXT 91 #define STR_TEXTTOCOLUMNS 100 diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src index b9854c175344..a510471bb799 100644 --- a/sc/source/ui/dbgui/asciiopt.src +++ b/sc/source/ui/dbgui/asciiopt.src @@ -34,24 +34,24 @@ ModalDialog RID_SCDLG_ASCII { OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 320 , 247 ) ; + Size = MAP_APPFONT ( 320 , 264 ) ; Text [ en-US ] = "Text Import" ; Moveable = TRUE ; FixedLine FL_WIDTH { - Pos = MAP_APPFONT ( 6 , 132 ) ; + Pos = MAP_APPFONT ( 6 , 147 ) ; Size = MAP_APPFONT ( 252 , 8 ) ; Text [ en-US ] = "Fields" ; }; FixedText FT_TYPE { - Pos = MAP_APPFONT ( 12 , 145 ) ; + Pos = MAP_APPFONT ( 12 , 160 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; Text [ en-US ] = "Column t~ype"; }; ListBox LB_TYPE1 { - Pos = MAP_APPFONT ( 76 , 143 ) ; + Pos = MAP_APPFONT ( 76 , 158 ) ; Size = MAP_APPFONT ( 60 , 68 ) ; TabStop = TRUE ; DropDown = TRUE ; @@ -194,7 +194,7 @@ ModalDialog RID_SCDLG_ASCII HelpId = HID_SC_ASCII_TABCTR ; Border = TRUE ; DialogControl = TRUE ; - Pos = MAP_APPFONT ( 12 , 159 ) ; + Pos = MAP_APPFONT ( 12 , 176 ) ; Size = MAP_APPFONT ( 243 , 82 ) ; }; CheckBox CB_ASONCE @@ -204,6 +204,13 @@ ModalDialog RID_SCDLG_ASCII TabStop = TRUE ; Text [ en-US ] = "Merge ~delimiters" ; }; + CheckBox CB_QUOTED_AS_TEXT + { + Pos = MAP_APPFONT ( 20 , 129 ) ; + Size = MAP_APPFONT ( 130 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Quoted field as text" ; + }; String STR_TEXTTOCOLUMNS { Text [ en-US ] = "Text to Columns" ; diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index ddbfb4426df8..5725645100d3 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -737,7 +737,8 @@ void ScCsvGrid::ImplSetTextLineSep( while( *pChar && (nColIx < sal::static_int_cast(CSV_MAXCOLCOUNT)) ) { // scan for next cell text - pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep ); + bool bIsQuoted = false; + pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted ); // update column width sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) ); diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index 6f97ecd4c9d9..90acf4a45358 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -37,8 +37,76 @@ #include "AccessibleCsvControl.hxx" +#include +#include +#include +#include "miscuno.hxx" + +using namespace rtl; +using namespace com::sun::star::uno; + + + +// ============================================================================ +#define SEP_PATH "Office.Calc/Dialogs/CSVImport" +#define FIXED_WIDTH_LIST "FixedWidthList" + + // ============================================================================ +static void load_FixedWidthList(ScCsvSplits &aSplits) +{ + String sSplits; + OUString sFixedWidthLists; + + SequenceaValues; + const Any *pProperties; + Sequence aNames(1); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getConstArray(); + + if( pProperties[0].hasValue() ) + { + aSplits.Clear(); + pProperties[0] >>= sFixedWidthLists; + + sSplits = String( sFixedWidthLists ); + + // String ends with a semi-colon so there is no 'int' after the last one. + for(int i=0;i aValues; + Any *pProperties; + Sequence aNames(1); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getArray(); + pProperties[0] <<= sFixedWidthLists; + + aItem.PutProperties(aNames, aValues); +} + ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) : ScCsvControl( rParent ), mnPosCursorLast( 1 ) @@ -48,6 +116,13 @@ ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) : InitSizeData(); maBackgrDev.SetFont( GetFont() ); maRulerDev.SetFont( GetFont() ); + + load_FixedWidthList( maSplits ); +} + +ScCsvRuler::~ScCsvRuler() +{ + save_FixedWidthList( maSplits ); } diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 6bc96c13d5b6..9d782347b5ea 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -44,6 +44,12 @@ // ause #include "editutil.hxx" +#include +#include +#include +#include "miscuno.hxx" + + //! TODO make dynamic #ifdef WIN const SCSIZE ASCIIDLG_MAXROWS = 10000; @@ -51,6 +57,20 @@ const SCSIZE ASCIIDLG_MAXROWS = 10000; const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT; #endif + +using namespace rtl; +using namespace com::sun::star::uno; + +// Defines - CSV Import Preserve Options +#define FIXED_WIDTH "FixedWidth" +#define FROM_ROW "FromRow" +#define CHAR_SET "CharSet" +#define SEPARATORS "Separators" +#define TEXT_SEPARATORS "TextSeparators" +#define MERGE_DELIMITERS "MergeDelimiters" +#define QUOTED_AS_TEXT "QuotedFieldAsText" +#define SEP_PATH "Office.Calc/Dialogs/CSVImport" + // ============================================================================ void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect ) @@ -98,11 +118,82 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) return c; } +static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, + bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth, + sal_Int32 &nFromRow, sal_Int32 &nCharSet ) +{ + SequenceaValues; + const Any *pProperties; + Sequence aNames(7); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS ); + pNames[1] = OUString::createFromAscii( SEPARATORS ); + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS ); + pNames[3] = OUString::createFromAscii( FIXED_WIDTH ); + pNames[4] = OUString::createFromAscii( FROM_ROW ); + pNames[5] = OUString::createFromAscii( CHAR_SET ); + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getConstArray(); + if( pProperties[1].hasValue() ) + pProperties[1] >>= sFieldSeparators; + + if( pProperties[2].hasValue() ) + pProperties[2] >>= sTextSeparators; + + if( pProperties[0].hasValue() ) + bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] ); + + if( pProperties[3].hasValue() ) + bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] ); + + if( pProperties[4].hasValue() ) + pProperties[4] >>= nFromRow; + + if( pProperties[5].hasValue() ) + pProperties[5] >>= nCharSet; + + if ( pProperties[6].hasValue() ) + pProperties[6] >>= bQuotedAsText; +} + +static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, + bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet ) +{ + OUString sFieldSeparators = OUString( maSeparators ); + OUString sTextSeparators = OUString( maTxtSep ); + Sequence aValues; + Any *pProperties; + Sequence aNames(7); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS ); + pNames[1] = OUString::createFromAscii( SEPARATORS ); + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS ); + pNames[3] = OUString::createFromAscii( FIXED_WIDTH ); + pNames[4] = OUString::createFromAscii( FROM_ROW ); + pNames[5] = OUString::createFromAscii( CHAR_SET ); + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getArray(); + pProperties[1] <<= sFieldSeparators; + pProperties[2] <<= sTextSeparators; + ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters ); + ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth ); + pProperties[4] <<= nFromRow; + pProperties[5] <<= nCharSet; + pProperties[6] <<= static_cast(bQuotedAsText); + + aItem.PutProperties(aNames, aValues); +} // ---------------------------------------------------------------------------- ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, - SvStream* pInStream, sal_Unicode cSep ) : + SvStream* pInStream, sal_Unicode /*cSep*/ ) : ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ), mpDatStream ( pInStream ), mnStreamPos( pInStream ? pInStream->Tell() : 0 ), @@ -128,6 +219,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbOther ( this, ScResId( CKB_OTHER ) ), aEdOther ( this, ScResId( ED_OTHER ) ), aCkbAsOnce ( this, ScResId( CB_ASONCE) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), @@ -146,14 +238,15 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aFldSepList ( ScResId( SCSTR_FIELDSEP ) ), aTextSepList( ScResId( SCSTR_TEXTSEP ) ), mcTextSep ( ScAsciiOptions::cDefaultTextSep ), - maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ) + maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ), + mbFileImport(true) { FreeResource(); + mbFileImport = aDatName.Len() > 0; String aName = GetText(); // aDatName is empty if invoked during paste from clipboard. - BOOL bClipboard = (aDatName.Len() == 0); - if (!bClipboard) + if (mbFileImport) { aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - [")); aName += aDatName; @@ -161,20 +254,51 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, } SetText( aName ); - switch(cSep) + + OUString sFieldSeparators; + OUString sTextSeparators; + bool bMergeDelimiters = false; + bool bFixedWidth = false; + bool bQuotedFieldAsText = true; + sal_Int32 nFromRow = 1; + sal_Int32 nCharSet = -1; + if (mbFileImport) + // load separators only when importing csv files. + load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, + bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet); + maFieldSeparators = String(sFieldSeparators); + + if( bMergeDelimiters ) + aCkbAsOnce.Check(); + if (bQuotedFieldAsText) + aCkbQuotedAsText.Check(); + if( bFixedWidth ) + aRbFixed.Check(); + if( nFromRow != 1 ) + aNfRow.SetValue( nFromRow ); + + ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252); + const sal_Char *aSep = bString.GetBuffer(); + int len = maFieldSeparators.Len(); + for (int i = 0; i < len; ++i) { - case '\t': aCkbTab.Check(); break; - case ';': aCkbSemicolon.Check(); break; - case ',': aCkbComma.Check(); break; - case ' ': aCkbSpace.Check(); break; - default: - aCkbOther.Check(); - aEdOther.SetText( cSep ); + switch( aSep[i] ) + { + case '\t': aCkbTab.Check(); break; + case ';': aCkbSemicolon.Check(); break; + case ',': aCkbComma.Check(); break; + case ' ': aCkbSpace.Check(); break; + default: + aCkbOther.Check(); + aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) ); + } } + + // Get Separators from the dialog maFieldSeparators = GetSeparators(); // Clipboard is always Unicode, else detect. - BOOL bPreselectUnicode = bClipboard; + bool bPreselectUnicode = !mbFileImport; // Sniff for Unicode / not if( !bPreselectUnicode && mpDatStream ) { @@ -210,6 +334,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, // *** Separator characters *** lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep ); + aCbTextSep.SetText( sTextSeparators ); Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl ); aCbTextSep.SetSelectHdl( aSeparatorHdl ); @@ -218,6 +343,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbSemicolon.SetClickHdl( aSeparatorHdl ); aCkbComma.SetClickHdl( aSeparatorHdl ); aCkbAsOnce.SetClickHdl( aSeparatorHdl ); + aCkbQuotedAsText.SetClickHdl( aSeparatorHdl ); aCkbSpace.SetClickHdl( aSeparatorHdl ); aCkbOther.SetClickHdl( aSeparatorHdl ); aEdOther.SetModifyHdl( aSeparatorHdl ); @@ -230,6 +356,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser ); aLbCharSet.SelectTextEncoding( bPreselectUnicode ? RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() ); + + if( nCharSet >= 0 ) + aLbCharSet.SelectEntryPos( nCharSet ); + SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); @@ -261,6 +391,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, ScImportAsciiDlg::~ScImportAsciiDlg() { + if (mbFileImport) + save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), + aCkbQuotedAsText.IsChecked(), aRbFixed.IsChecked(), + aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos()); delete[] mpRowPosArray; } @@ -346,6 +480,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetFieldSeps( GetSeparators() ); rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() ); + rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) ); } } @@ -357,6 +492,10 @@ void ScImportAsciiDlg::SetTextToColumnsMode() aLbCharSet.Disable(); aFtRow.Disable(); aNfRow.Disable(); + + // Quoted field as text option is not used for text to columns mode. + aCkbQuotedAsText.Check(false); + aCkbQuotedAsText.Disable(); } void ScImportAsciiDlg::SetSelectedCharSet() @@ -393,6 +532,7 @@ void ScImportAsciiDlg::SetupSeparatorCtrls() aCkbOther.Enable( bEnable ); aEdOther.Enable( bEnable ); aCkbAsOnce.Enable( bEnable ); + aCkbQuotedAsText.Enable( bEnable ); aFtTextSep.Enable( bEnable ); aCbTextSep.Enable( bEnable ); } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 67186f84a84a..a351c1f1b3fd 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -905,12 +905,10 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm ) // -bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, - const String& rStr, BYTE nColFormat, - ::utl::TransliterationWrapper& rTransliteration, - CalendarWrapper& rCalendar, - ::utl::TransliterationWrapper* pSecondTransliteration, - CalendarWrapper* pSecondCalendar ) +static bool lcl_PutString( + ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat, + ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar, + ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar ) { bool bMultiLine = false; if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) ) @@ -1281,7 +1279,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // SC_COL_SKIP. while (*p && nCol <= MAXCOL+1) { - p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge ); + bool bIsQuoted = false; + p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted ); BYTE nFmt = SC_COL_STANDARD; for ( i=nInfoStart; i MAXCOL) bOverflow = TRUE; // display warning on import else if (!bDetermineRange) + { + if (bIsQuoted && pExtOptions && pExtOptions->IsQuotedAsText()) + nFmt = SC_COL_TEXT; + bMultiLine |= lcl_PutString( pDoc, nCol, nRow, nTab, aCell, nFmt, aTransliteration, aCalendar, pEnglishTransliteration, pEnglishCalendar); + } ++nCol; } @@ -1375,11 +1379,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // static const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p, - String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps ) + String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted ) { + rbIsQuoted = false; rField.Erase(); if ( *p == cStr ) // String in Anfuehrungszeichen { + rbIsQuoted = true; const sal_Unicode* p1; p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE ); while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) ) diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx index a26929dc92ea..40c95f0f0702 100644 --- a/sc/source/ui/inc/asciiopt.hxx +++ b/sc/source/ui/inc/asciiopt.hxx @@ -65,6 +65,7 @@ private: BOOL bFixedLen; String aFieldSeps; BOOL bMergeFieldSeps; + bool bQuotedFieldAsText; sal_Unicode cTextSep; CharSet eCharSet; BOOL bCharSetSystem; @@ -93,6 +94,7 @@ public: BOOL GetCharSetSystem() const { return bCharSetSystem; } const String& GetFieldSeps() const { return aFieldSeps; } BOOL IsMergeSeps() const { return bMergeFieldSeps; } + bool IsQuotedAsText() const { return bQuotedFieldAsText; } sal_Unicode GetTextSep() const { return cTextSep; } BOOL IsFixedLen() const { return bFixedLen; } USHORT GetInfoCount() const { return nInfoCount; } @@ -105,6 +107,7 @@ public: void SetFixedLen( BOOL bSet ) { bFixedLen = bSet; } void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; } void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; } + void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } void SetTextSep( sal_Unicode c ) { cTextSep = c; } void SetStartRow( long nRow) { nStartRow= nRow; } diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx index cb79644f3aed..9c84f41368c8 100644 --- a/sc/source/ui/inc/csvruler.hxx +++ b/sc/source/ui/inc/csvruler.hxx @@ -71,6 +71,7 @@ private: // ------------------------------------------------------------------------ public: explicit ScCsvRuler( ScCsvControl& rParent ); + ~ScCsvRuler(); // common ruler handling -------------------------------------------------- public: diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx index fb4dcaa83958..c31094fd3fb8 100644 --- a/sc/source/ui/inc/impex.hxx +++ b/sc/source/ui/inc/impex.hxx @@ -110,7 +110,7 @@ public: static BOOL IsFormatSupported( ULONG nFormat ); static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p, - String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps ); + String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted ); static void WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE ); static void WriteUnicodeOrByteEndl( SvStream& rStrm ); static inline BOOL IsEndianSwap( const SvStream& rStrm ); diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 89b7ff9f8a0a..33bc48b7122a 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -64,6 +64,7 @@ class ScImportAsciiDlg : public ModalDialog CheckBox aCkbOther; Edit aEdOther; CheckBox aCkbAsOnce; + CheckBox aCkbQuotedAsText; FixedText aFtTextSep; ComboBox aCbTextSep; @@ -87,6 +88,7 @@ class ScImportAsciiDlg : public ModalDialog CharSet meCharSet; /// Selected char set. bool mbCharSetSystem; /// Is System char set selected? + bool mbFileImport; /// Is this dialog involked for csv file import ? public: ScImportAsciiDlg( -- cgit v1.2.3 From b559137b68a273ef543711995ebf4f140cfe9149 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 11:41:15 -0400 Subject: #i102141# initial port of patches from ooo-build, to implement a new HTML option dialog & associated changes in the core. --- sc/inc/column.hxx | 4 +- sc/inc/document.hxx | 4 +- sc/inc/filter.hxx | 8 ++- sc/inc/sc.hrc | 3 + sc/inc/scabstdlg.hxx | 11 ++++ sc/inc/stringutil.hxx | 56 +++++++++++++++++ sc/inc/table.hxx | 3 +- sc/source/core/data/column3.cxx | 103 +++++++++++++++++++++---------- sc/source/core/data/document.cxx | 5 +- sc/source/core/data/table2.cxx | 6 +- sc/source/core/tool/makefile.mk | 2 + sc/source/core/tool/stringutil.cxx | 101 +++++++++++++++++++++++++++++++ sc/source/filter/html/htmlimp.cxx | 10 ++-- sc/source/filter/inc/eeimport.hxx | 4 +- sc/source/filter/inc/ftools.hxx | 4 +- sc/source/filter/inc/htmlimp.hxx | 3 +- sc/source/filter/rtf/eeimpars.cxx | 9 +-- sc/source/ui/attrdlg/scdlgfact.cxx | 31 ++++++++++ sc/source/ui/attrdlg/scdlgfact.hxx | 10 ++++ sc/source/ui/dbgui/langchooser.cxx | 120 +++++++++++++++++++++++++++++++++++++ sc/source/ui/dbgui/langchooser.src | 112 ++++++++++++++++++++++++++++++++++ sc/source/ui/dbgui/makefile.mk | 5 +- sc/source/ui/docshell/docsh.cxx | 49 ++++++++++++++- sc/source/ui/docshell/impex.cxx | 2 +- sc/source/ui/inc/docsh.hxx | 1 + sc/source/ui/inc/langchooser.hrc | 42 +++++++++++++ sc/source/ui/inc/langchooser.hxx | 76 +++++++++++++++++++++++ sc/source/ui/unoobj/filtuno.cxx | 31 ++++++++-- sc/util/makefile.mk | 1 + 29 files changed, 758 insertions(+), 58 deletions(-) create mode 100644 sc/inc/stringutil.hxx create mode 100644 sc/source/core/tool/stringutil.cxx create mode 100644 sc/source/ui/dbgui/langchooser.cxx create mode 100644 sc/source/ui/dbgui/langchooser.src create mode 100644 sc/source/ui/inc/langchooser.hrc create mode 100644 sc/source/ui/inc/langchooser.hxx (limited to 'sc/source') diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index c66ecb960e7d..93861d7436cb 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -241,7 +241,9 @@ public: // TRUE = Zahlformat gesetzt BOOL SetString( SCROW nRow, SCTAB nTab, const String& rString, - formula::FormulaGrammar::AddressConvention conv = formula::FormulaGrammar::CONV_OOO ); + formula::FormulaGrammar::AddressConvention conv = formula::FormulaGrammar::CONV_OOO, + SvNumberFormatter* pFormatter = NULL, + bool bDetectNumberFormat = true ); void SetValue( SCROW nRow, const double& rVal); void SetError( SCROW nRow, const USHORT nError); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 17c3234a7723..ca56205d74a0 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -721,7 +721,9 @@ public: SC_DLLPUBLIC void PutCell(SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell, ULONG nFormatIndex, BOOL bForceTab = FALSE); // return TRUE = Zahlformat gesetzt - SC_DLLPUBLIC BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString ); + SC_DLLPUBLIC BOOL SetString( + SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString, + SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true ); SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal ); void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const USHORT nError); diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx index 157795db2a42..8284447f2f05 100644 --- a/sc/inc/filter.hxx +++ b/sc/inc/filter.hxx @@ -42,6 +42,7 @@ class SvStream; class ScAddress; class ScDocument; class ScRange; +class SvNumberFormatter; // Return-Werte Im-/Exportfilter (ULONG) @@ -92,7 +93,9 @@ class ScEEAbsImport { virtual ~ScEEAbsImport() {} virtual ULONG Read( SvStream& rStream, const String& rBaseURL ) = 0; virtual ScRange GetRange() = 0; - virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0 ) = 0; + virtual void WriteToDocument( + BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0, + SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0; }; class ScFormatFilterPlugin { @@ -109,7 +112,8 @@ class ScFormatFilterPlugin { virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos, const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, UINT32 nDifOption = SC_DIFOPT_EXCEL ) = 0; virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange ) = 0; - virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE ) = 0; + virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0, + BOOL bCalcWidthHeight = TRUE, SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0; // various import helpers virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ) = 0; diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 8fb6b929337b..ba3420f1d9c3 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1650,6 +1650,9 @@ #define MID_3 3 #define MID_4 4 +// Language chooser for text import filters. +#define RID_SCDLG_LANG_CHOOSER (SC_OOO_BUILD_START + 12) + #endif diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index f9895ff15ebb..89c33bcae13f 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -41,6 +41,7 @@ #include "sc.hrc" #include "global.hxx" #include "pivot.hxx" +#include "i18npool/lang.h" class ScAsciiOptions; class ScAutoFormat; @@ -289,6 +290,14 @@ class AbstractScImportOptionsDlg : public VclAbstractDialog //add for ScImportO public: virtual void GetImportOptions( ScImportOptions& rOptions ) const = 0; }; + +class AbstractScLangChooserDlg : public VclAbstractDialog //add for ScLangChooserDlg +{ +public: + virtual LanguageType GetLanguageType() const = 0; + virtual bool IsDateConversionSet() const = 0; +}; + //-------Scabstract fractory --------------------------- class ScAbstractDialogFactory { @@ -299,6 +308,8 @@ public: SvStream* pInStream, int nId, sal_Unicode cSep = '\t') = 0; + virtual AbstractScLangChooserDlg * CreateScLangChooserDlg( Window* pParent, int nId ) = 0; + virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx new file mode 100644 index 000000000000..c50c0d8cf156 --- /dev/null +++ b/sc/inc/stringutil.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: table.hxx,v $ + * $Revision: 1.35 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_STRINGUTIL_HXX +#define SC_STRINGUTIL_HXX + +#include "rtl/ustring.hxx" + +class ScStringUtil +{ +public: + /** + * Check if a given string is a simple decimal number (e.g. 12.345). We + * don't do any elaborate parsing here; we only check for the simplest + * case of decimal number format. + * + * @param rStr string to parse + * @param dsep decimal separator + * @param gsep group separator (aka thousands separator) + * @param rVal value of successfully parsed number + * + * @return true if the string is a valid number, false otherwise. + */ + static bool parseSimpleNumber( + const ::rtl::OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal); +}; + + +#endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 7d9bf90a3d81..fd1f806b688d 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -260,7 +260,8 @@ public: void PutCell( SCCOL nCol, SCROW nRow, ScBaseCell* pCell ); void PutCell(SCCOL nCol, SCROW nRow, ULONG nFormatIndex, ScBaseCell* pCell); // TRUE = Zahlformat gesetzt - BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString ); + BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString, + SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true ); void SetValue( SCCOL nCol, SCROW nRow, const double& rVal ); void SetError( SCCOL nCol, SCROW nRow, USHORT nError); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 5726862366cf..19768160c573 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -54,6 +54,13 @@ #include "markdata.hxx" #include "detfunc.hxx" // fuer Notizen bei DeleteRange #include "postit.hxx" +#include "stringutil.hxx" + +#include + +using ::com::sun::star::i18n::LocaleDataItem; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; // Err527 Workaround extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx @@ -1244,7 +1251,8 @@ void ScColumn::StartListeningInArea( SCROW nRow1, SCROW nRow2 ) // TRUE = Zahlformat gesetzt BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, - formula::FormulaGrammar::AddressConvention eConv ) + formula::FormulaGrammar::AddressConvention eConv, + SvNumberFormatter* pFormatter, bool bDetectNumberFormat ) { BOOL bNumFmtSet = FALSE; if (VALIDROW(nRow)) @@ -1256,7 +1264,8 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, double nVal; sal_uInt32 nIndex, nOldIndex = 0; sal_Unicode cFirstChar; - SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); + if (!pFormatter) + pFormatter = pDocument->GetFormatTable(); SfxObjectShell* pDocSh = pDocument->GetDocumentShell(); if ( pDocSh ) bIsLoading = pDocSh->IsLoading(); @@ -1323,46 +1332,78 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, if ( !bIsText ) nIndex = nOldIndex = pFormatter->GetStandardIndex(); } - if ( !bIsText && - pFormatter->IsNumberFormat(rString, nIndex, nVal) ) - { // Zahl - pNewCell = new ScValueCell( nVal ); - if ( nIndex != nOldIndex) + + do + { + if (bIsText) + break; + + if (bDetectNumberFormat) { - // #i22345# New behavior: Apply the detected number format only if - // the old one was the default number, date, time or boolean format. - // Exception: If the new format is boolean, always apply it. + if (!pFormatter->IsNumberFormat(rString, nIndex, nVal)) + break; - BOOL bOverwrite = FALSE; - const SvNumberformat* pOldFormat = pFormatter->GetEntry( nOldIndex ); - if ( pOldFormat ) + pNewCell = new ScValueCell( nVal ); + if ( nIndex != nOldIndex) { - short nOldType = pOldFormat->GetType() & ~NUMBERFORMAT_DEFINED; - if ( nOldType == NUMBERFORMAT_NUMBER || nOldType == NUMBERFORMAT_DATE || - nOldType == NUMBERFORMAT_TIME || nOldType == NUMBERFORMAT_LOGICAL ) + // #i22345# New behavior: Apply the detected number format only if + // the old one was the default number, date, time or boolean format. + // Exception: If the new format is boolean, always apply it. + + BOOL bOverwrite = FALSE; + const SvNumberformat* pOldFormat = pFormatter->GetEntry( nOldIndex ); + if ( pOldFormat ) { - if ( nOldIndex == pFormatter->GetStandardFormat( - nOldType, pOldFormat->GetLanguage() ) ) + short nOldType = pOldFormat->GetType() & ~NUMBERFORMAT_DEFINED; + if ( nOldType == NUMBERFORMAT_NUMBER || nOldType == NUMBERFORMAT_DATE || + nOldType == NUMBERFORMAT_TIME || nOldType == NUMBERFORMAT_LOGICAL ) { - bOverwrite = TRUE; // default of these types can be overwritten + if ( nOldIndex == pFormatter->GetStandardFormat( + nOldType, pOldFormat->GetLanguage() ) ) + { + bOverwrite = TRUE; // default of these types can be overwritten + } } } - } - if ( !bOverwrite && pFormatter->GetType( nIndex ) == NUMBERFORMAT_LOGICAL ) - { - bOverwrite = TRUE; // overwrite anything if boolean was detected - } + if ( !bOverwrite && pFormatter->GetType( nIndex ) == NUMBERFORMAT_LOGICAL ) + { + bOverwrite = TRUE; // overwrite anything if boolean was detected + } - if ( bOverwrite ) - { - ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT, - (UINT32) nIndex) ); - bNumFmtSet = TRUE; + if ( bOverwrite ) + { + ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT, + (UINT32) nIndex) ); + bNumFmtSet = TRUE; + } } } + else + { + // Only check if the string is a regular number. + const LocaleDataWrapper* pLocale = pFormatter->GetLocaleData(); + if (!pLocale) + break; + + LocaleDataItem aLocaleItem = pLocale->getLocaleItem(); + const OUString& rDecSep = aLocaleItem.decimalSeparator; + const OUString& rGroupSep = aLocaleItem.thousandSeparator; + if (rDecSep.getLength() != 1 || rGroupSep.getLength() != 1) + break; + + sal_Unicode dsep = rDecSep.getStr()[0]; + sal_Unicode gsep = rGroupSep.getStr()[0]; + + if (!ScStringUtil::parseSimpleNumber(rString, dsep, gsep, nVal)) + break; + + pNewCell = new ScValueCell(nVal); + } } - else // Text - pNewCell = new ScStringCell( rString ); + while (false); + + if (!pNewCell) + pNewCell = new ScStringCell(rString); } } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 90eb1597023d..34420b3cd639 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2343,10 +2343,11 @@ void ScDocument::PutCell( const ScAddress& rPos, ScBaseCell* pCell, BOOL bForceT } -BOOL ScDocument::SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString ) +BOOL ScDocument::SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString, + SvNumberFormatter* pFormatter, bool bDetectNumberFormat ) { if ( ValidTab(nTab) && pTab[nTab] ) - return pTab[nTab]->SetString( nCol, nRow, nTab, rString ); + return pTab[nTab]->SetString( nCol, nRow, nTab, rString, pFormatter, bDetectNumberFormat ); else return FALSE; } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index cf204765b3b0..2385ce67066c 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -846,10 +846,12 @@ void ScTable::PutCell( const ScAddress& rPos, ULONG nFormatIndex, ScBaseCell* pC } -BOOL ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rString ) +BOOL ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rString, + SvNumberFormatter* pFormatter, bool bDetectNumberFormat ) { if (ValidColRow(nCol,nRow)) - return aCol[nCol].SetString( nRow, nTabP, rString ); + return aCol[nCol].SetString( + nRow, nTabP, rString, pDocument->GetAddressConvention(), pFormatter, bDetectNumberFormat ); else return FALSE; } diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk index 8a4b1b44fd12..4e661abf14fc 100644 --- a/sc/source/core/tool/makefile.mk +++ b/sc/source/core/tool/makefile.mk @@ -107,6 +107,7 @@ SLOFILES = \ $(SLO)$/refupdat.obj \ $(SLO)$/scmatrix.obj \ $(SLO)$/sctictac.obj \ + $(SLO)$/stringutil.obj \ $(SLO)$/subtotal.obj \ $(SLO)$/token.obj \ $(SLO)$/unitconv.obj \ @@ -130,6 +131,7 @@ EXCEPTIONSFILES= \ $(SLO)$/lookupcache.obj \ $(SLO)$/prnsave.obj \ $(SLO)$/reftokenhelper.obj \ + $(SLO)$/stringutil.obj \ $(SLO)$/token.obj # [kh] POWERPC compiler problem diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx new file mode 100644 index 000000000000..e78c6edc88d7 --- /dev/null +++ b/sc/source/core/tool/stringutil.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: table.hxx,v $ + * $Revision: 1.35 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +// System - Includes ----------------------------------------------------- + +#include "stringutil.hxx" +#include "rtl/ustrbuf.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +bool ScStringUtil::parseSimpleNumber( + const OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal) +{ + OUStringBuffer aBuf; + sal_Int32 n = rStr.getLength(); + const sal_Unicode* p = rStr.getStr(); + sal_Int32 nPosDSep = -1, nPosGSep = -1; + for (sal_Int32 i = 0; i < n; ++i) + { + sal_Unicode c = p[i]; + if (sal_Unicode('0') <= c && c <= sal_Unicode('9')) + { + // this is a digit. + aBuf.append(c); + } + else if (c == dsep) + { + // this is a decimal separator. + + if (nPosDSep >= 0) + // a second decimal separator -> not a valid number. + return false; + if (nPosGSep >= 0 && i - nPosGSep != 4) + // the number has a group separator and the decimal sep is not + // positioned correctly. + return false; + + nPosDSep = i; + aBuf.append(c); + } + else if (c == gsep) + { + // this is a group (thousand) separator. + if (i == 0) + return false; + + if (nPosGSep >= 0 && i - nPosGSep != 4) + { + // this group separator is not positioned correctly relative + // to the last group separator. + return false; + } + + nPosGSep = i; + } + else if (c == sal_Unicode('-') || c == sal_Unicode('+')) + { + // A sign must be the first character if it's given. + if (i == 0) + aBuf.append(c); + else + return false; + } + else + return false; + } + + rVal = aBuf.makeStringAndClear().toDouble(); + return true; +} diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index 5591e8ec993e..781f8709a8b8 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -63,13 +63,14 @@ //------------------------------------------------------------------------ FltError ScFormatFilterPluginImpl::ScImportHTML( SvStream &rStream, const String& rBaseURL, ScDocument *pDoc, - ScRange& rRange, double nOutputFactor, BOOL bCalcWidthHeight ) + ScRange& rRange, double nOutputFactor, BOOL bCalcWidthHeight, SvNumberFormatter* pFormatter, + bool bConvertDate ) { ScHTMLImport aImp( pDoc, rBaseURL, rRange, bCalcWidthHeight ); FltError nErr = (FltError) aImp.Read( rStream, rBaseURL ); ScRange aR = aImp.GetRange(); rRange.aEnd = aR.aEnd; - aImp.WriteToDocument( TRUE, nOutputFactor ); + aImp.WriteToDocument( TRUE, nOutputFactor, pFormatter, bConvertDate ); return nErr; } @@ -137,9 +138,10 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const String& rName, const delete pRangeData; } -void ScHTMLImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor ) +void ScHTMLImport::WriteToDocument( + BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate ) { - ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor ); + ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, bConvertDate ); const ScHTMLParser* pParser = GetParser(); const ScHTMLTable* pGlobTable = pParser->GetGlobalTable(); diff --git a/sc/source/filter/inc/eeimport.hxx b/sc/source/filter/inc/eeimport.hxx index a601c7a20cbf..74c4e297e785 100644 --- a/sc/source/filter/inc/eeimport.hxx +++ b/sc/source/filter/inc/eeimport.hxx @@ -63,7 +63,9 @@ public: virtual ULONG Read( SvStream& rStream, const String& rBaseURL ); virtual ScRange GetRange() { return maRange; } virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, - double nOutputFactor = 1.0 ); + double nOutputFactor = 1.0, + SvNumberFormatter* pFormatter = NULL, + bool bConvertDate = true ); }; #endif diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx index 393775e721f7..3b9fac62ee92 100644 --- a/sc/source/filter/inc/ftools.hxx +++ b/sc/source/filter/inc/ftools.hxx @@ -522,7 +522,9 @@ class ScFormatFilterPluginImpl : public ScFormatFilterPlugin { virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos, const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, UINT32 nDifOption = SC_DIFOPT_EXCEL ); virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange ); - virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE ); + virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, + double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE, + SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ); virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ); virtual ScEEAbsImport *CreateHTMLImport( ScDocument* pDocP, const String& rBaseURL, const ScRange& rRange, BOOL bCalcWidthHeight ); diff --git a/sc/source/filter/inc/htmlimp.hxx b/sc/source/filter/inc/htmlimp.hxx index d50998ba295c..eb5b5e41a164 100644 --- a/sc/source/filter/inc/htmlimp.hxx +++ b/sc/source/filter/inc/htmlimp.hxx @@ -45,7 +45,8 @@ public: virtual ~ScHTMLImport(); const ScHTMLParser* GetParser() const { return (ScHTMLParser*)mpParser; } - virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0 ); + virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0, + SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ); static String GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrigName ); }; diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 9c28cf49d729..895ce471f53a 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -129,7 +129,7 @@ ULONG ScEEImport::Read( SvStream& rStream, const String& rBaseURL ) } -void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor ) +void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate ) { ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(), ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->Count() ); @@ -150,7 +150,8 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor ) nLastMergedRow = SCROW_MAX; BOOL bHasGraphics = FALSE; ScEEParseEntry* pE; - SvNumberFormatter* pFormatter = mpDoc->GetFormatTable(); + if (!pFormatter) + pFormatter = mpDoc->GetFormatTable(); bool bNumbersEnglishUS = (pFormatter->GetLanguage() != LANGUAGE_ENGLISH_US); if (bNumbersEnglishUS) { @@ -335,7 +336,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor ) else if ( !pE->aSel.HasRange() ) { // maybe ALT text of IMG or similar - mpDoc->SetString( nCol, nRow, nTab, pE->aAltText ); + mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, pFormatter ); // wenn SelRange komplett leer kann nachfolgender Text im gleichen Absatz liegen! } else @@ -380,7 +381,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor ) if (bNumbersEnglishUS && !bEnUsRecognized) mpDoc->PutCell( nCol, nRow, nTab, new ScStringCell( aStr)); else - mpDoc->SetString( nCol, nRow, nTab, aStr ); + mpDoc->SetString( nCol, nRow, nTab, aStr, pFormatter, bConvertDate ); } } else diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 60b101d482c0..9690470ebfc8 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -74,6 +74,7 @@ #include "validate.hxx" //add for ScValidationDlg #include "validate.hrc" //add for ScValidationDlg #include "sortdlg.hxx" //add for ScSortDlg +#include "langchooser.hxx" #include "opredlin.hxx" //add for ScRedlineOptionsTabPage #include "tpcalc.hxx" //add for ScTpCalcOptions #include "tpprint.hxx" //add for ScTpPrintOptions @@ -115,6 +116,7 @@ IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl); //add for ScNewScenarioDlg IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); //add for ScShowTabDlg IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); //add for ScStringInputDlg IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); //add for ScImportOptionsDlg +IMPL_ABSTDLG_BASE(AbstractScLangChooserDlg_Impl); IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg // AbstractTabDialog_Impl begin @@ -620,6 +622,20 @@ void AbstractScImportOptionsDlg_Impl::GetImportOptions( ScImportOptions& rOption pDlg->GetImportOptions(rOptions); } // add for AbstractScImportOptionsDlg_Impl end + +//add for AbstractScLangChooserDlg_Impl begin +LanguageType AbstractScLangChooserDlg_Impl::GetLanguageType() const +{ + return pDlg->getLanguageType(); +} + +bool AbstractScLangChooserDlg_Impl::IsDateConversionSet() const +{ + return pDlg->isDateConversionSet(); +} + +//add for AbstractScLangChooserDlg_Impl end + // =========================Factories for createdialog =================== //add for ScImportAsciiDlg begin @@ -642,6 +658,21 @@ AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg } // ScImportAsciiDlg end +AbstractScLangChooserDlg * ScAbstractDialogFactory_Impl::CreateScLangChooserDlg( Window* pParent, int nId ) +{ + ScLangChooserDlg* pDlg = NULL; + switch (nId) + { + case RID_SCDLG_LANG_CHOOSER: + pDlg = new ScLangChooserDlg(pParent); + break; + default: + ; + } + + return pDlg ? new AbstractScLangChooserDlg_Impl(pDlg) : NULL; +} + //add for ScAutoFormatDlg begin AbstractScAutoFormatDlg * ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 40f6d3bee976..dfdcbcced3e9 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -64,6 +64,7 @@ class ScStringInputDlg; class ScImportOptionsDlg; class SfxTabDialog; class ScSortWarningDlg; +class ScLangChooserDlg; #define DECL_ABSTDLG_BASE(Class,DialogClass) \ DialogClass* pDlg; \ @@ -343,6 +344,13 @@ class AbstractScImportOptionsDlg_Impl : public AbstractScImportOptionsDlg //add virtual void GetImportOptions( ScImportOptions& rOptions ) const; }; +class AbstractScLangChooserDlg_Impl : public AbstractScLangChooserDlg +{ + DECL_ABSTDLG_BASE( AbstractScLangChooserDlg_Impl, ScLangChooserDlg) + virtual LanguageType GetLanguageType() const; + virtual bool IsDateConversionSet() const; +}; + //add for ScAttrDlg , ScHFEditDlg, ScStyleDlg, ScSubTotalDlg, ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg class AbstractTabDialog_Impl : public SfxAbstractTabDialog { @@ -384,6 +392,8 @@ public: SvStream* pInStream, int nId, sal_Unicode cSep = '\t'); + virtual AbstractScLangChooserDlg * CreateScLangChooserDlg( Window* pParent, int nId ); + virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg ScAutoFormat* pAutoFormat, const ScAutoFormatData* pSelFormatData, diff --git a/sc/source/ui/dbgui/langchooser.cxx b/sc/source/ui/dbgui/langchooser.cxx new file mode 100644 index 000000000000..6640afc3bd3f --- /dev/null +++ b/sc/source/ui/dbgui/langchooser.cxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: langbox.hxx,v $ + * $Revision: 1.4.242.1 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + +//------------------------------------------------------------------------ + +#include "langchooser.hxx" +#include "langchooser.hrc" + +#include "scresid.hxx" +#include "vcl/window.hxx" +#include "vcl/msgbox.hxx" +#include "vcl/svapp.hxx" + +ScLangChooserDlg::ScLangChooserDlg(Window* pParent) : + ModalDialog(pParent, ScResId(RID_SCDLG_LANG_CHOOSER)), + + maBtnOk(this, ScResId(BTN_OK)), + maBtnCancel(this, ScResId(BTN_CANCEL)), + maBtnHelp(this, ScResId(BTN_HELP)), + maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)), + maRbAutomatic(this, ScResId(RB_AUTOMATIC)), + maRbCustom(this, ScResId(RB_CUSTOM)), + maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)), + maFlOption(this, ScResId(FL_OPTION)), + maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE)) +{ + init(); +} + +ScLangChooserDlg::~ScLangChooserDlg() +{ +} + +short ScLangChooserDlg::Execute() +{ + return ModalDialog::Execute(); +} + +LanguageType ScLangChooserDlg::getLanguageType() const +{ + if (maRbAutomatic.IsChecked()) + return LANGUAGE_SYSTEM; + + return maLbCustomLang.GetSelectLanguage(); +} + +bool ScLangChooserDlg::isDateConversionSet() const +{ + return maBtnConvertDate.IsChecked(); +} + +void ScLangChooserDlg::init() +{ + Link aLink = LINK( this, ScLangChooserDlg, OKHdl ); + maBtnOk.SetClickHdl(aLink); + aLink = LINK( this, ScLangChooserDlg, RadioHdl ); + maRbAutomatic.SetClickHdl(aLink); + maRbCustom.SetClickHdl(aLink); + + maRbAutomatic.Check(true); + + maLbCustomLang.SetLanguageList( + LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false); + + LanguageType eLang = Application::GetSettings().GetLanguage(); + maLbCustomLang.SelectLanguage(eLang); + maLbCustomLang.Disable(); +} + +IMPL_LINK( ScLangChooserDlg, OKHdl, OKButton*, EMPTYARG ) +{ + EndDialog(RET_OK); + return 0; +} + +IMPL_LINK( ScLangChooserDlg, RadioHdl, RadioButton*, pBtn ) +{ + if (pBtn == &maRbAutomatic) + { + maLbCustomLang.Disable(); + } + else if (pBtn == &maRbCustom) + { + maLbCustomLang.Enable(); + } + return 0; +} + diff --git a/sc/source/ui/dbgui/langchooser.src b/sc/source/ui/dbgui/langchooser.src new file mode 100644 index 000000000000..313084299aba --- /dev/null +++ b/sc/source/ui/dbgui/langchooser.src @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retypepassdlg.src,v $ + * $Revision: 1.1.2.3 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "langchooser.hrc" + +ModalDialog RID_SCDLG_LANG_CHOOSER +{ + Text [ en-US ] = "Select Language" ; + Size = MAP_APPFONT ( 190 , 101 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + OutputSize = TRUE ; + + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 135, 6 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + DefButton = TRUE ; + }; + + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 135, 23 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + }; + + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 135, 43 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + }; + + FixedLine FL_CHOOSE_LANG + { + Pos = MAP_APPFONT( 6, 3 ) ; + Size = MAP_APPFONT( 125, 14 ) ; + + Text [ en-US ] = "Select the language to use for import" ; + }; + + RadioButton RB_AUTOMATIC + { + Pos = MAP_APPFONT( 12, 20 ) ; + Size = MAP_APPFONT( 50, 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "Automatic" ; + }; + + RadioButton RB_CUSTOM + { + Pos = MAP_APPFONT( 12, 34 ) ; + Size = MAP_APPFONT( 50, 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "Custom" ; + }; + + ListBox LB_CUSTOM_LANG + { + Pos = MAP_APPFONT( 20, 50 ) ; + Size = MAP_APPFONT( 100, 55 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + Sort = TRUE ; + }; + + FixedLine FL_OPTION + { + Pos = MAP_APPFONT( 6, 70 ); + Size = MAP_APPFONT( 125, 14 ); + + Text [ en-US ] = "Options" ; + }; + + CheckBox BTN_CONVERT_DATE + { + Pos = MAP_APPFONT( 12, 86 ); + Size = MAP_APPFONT( 125, 10 ); + TabStop = TRUE ; + + Text [ en-US ] = "Detect special numbers (such as dates)." ; + }; +}; + diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk index 5d716552ca71..5bf847ef9a93 100644 --- a/sc/source/ui/dbgui/makefile.mk +++ b/sc/source/ui/dbgui/makefile.mk @@ -53,6 +53,7 @@ SLOFILES = \ $(SLO)$/pfiltdlg.obj \ $(SLO)$/dbnamdlg.obj \ $(SLO)$/expftext.obj \ + $(SLO)$/langchooser.obj \ $(SLO)$/subtdlg.obj \ $(SLO)$/tpsubt.obj \ $(SLO)$/fieldwnd.obj \ @@ -85,6 +86,7 @@ EXCEPTIONSFILES= \ SRS1NAME=$(TARGET) SRC1FILES = \ + langchooser.src \ pivot.src \ pvfundlg.src \ dpgroupdlg.src \ @@ -114,7 +116,8 @@ LIB1OBJFILES = \ $(SLO)$/csvruler.obj \ $(SLO)$/csvgrid.obj \ $(SLO)$/csvtablebox.obj \ - $(SLO)$/asciiopt.obj + $(SLO)$/asciiopt.obj \ + $(SLO)$/langchooser.obj # --- Tagets ------------------------------------------------------- diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index c62c2dc41fdf..ed7952db9695 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -129,6 +129,8 @@ #include using namespace com::sun::star; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; // STATIC DATA ----------------------------------------------------------- @@ -794,6 +796,34 @@ BOOL __EXPORT ScDocShell::LoadFrom( SfxMedium& rMedium ) return bRet; } +static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLang, bool& rDateConvert) +{ + OUStringBuffer aBuf; + OUString aTokens[2]; + sal_Int32 n = rOption.getLength(); + const sal_Unicode* p = rOption.getStr(); + sal_Int32 nTokenId = 0; + for (sal_Int32 i = 0; i < n; ++i) + { + const sal_Unicode c = p[i]; + if (c == sal_Unicode(' ')) + { + if (aBuf.getLength()) + aTokens[nTokenId++] = aBuf.makeStringAndClear(); + } + else + aBuf.append(c); + + if (nTokenId >= 2) + break; + } + + if (aBuf.getLength()) + aTokens[nTokenId] = aBuf.makeStringAndClear(); + + rLang = static_cast(aTokens[0].toInt32()); + rDateConvert = static_cast(aTokens[1].toInt32()); +} BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium ) { @@ -1167,12 +1197,24 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium ) SvStream* pInStream = rMedium.GetInStream(); if (pInStream) { + LanguageType eLang = LANGUAGE_SYSTEM; + bool bDateConvert = false; + SfxItemSet* pSet = rMedium.GetItemSet(); + const SfxPoolItem* pItem; + if ( pSet && SFX_ITEM_SET == + pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) ) + { + String aFilterOption = (static_cast(pItem))->GetValue(); + lcl_parseHtmlFilterOption(aFilterOption, eLang, bDateConvert); + } + pInStream->Seek( 0 ); ScRange aRange; // HTML macht eigenes ColWidth/RowHeight CalcOutputFactor(); + SvNumberFormatter aNumFormatter(aDocument.GetServiceManager(), eLang); eError = ScFormatFilter::Get().ScImportHTML( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange, - GetOutputFactor(), !bWebQuery ); + GetOutputFactor(), !bWebQuery, &aNumFormatter, bDateConvert ); if (eError != eERR_OK) { if (!GetError()) @@ -2149,6 +2191,11 @@ String ScDocShell::GetOwnFilterName() // static return String::CreateFromAscii(pFilterSc50); } +String ScDocShell::GetHtmlFilterName() +{ + return String::CreateFromAscii(pFilterHtml); +} + String ScDocShell::GetWebQueryFilterName() // static { return String::CreateFromAscii(pFilterHtmlWebQ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index a351c1f1b3fd..288ad755cb52 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -2044,7 +2044,7 @@ class ScFormatFilterMissing : public ScFormatFilterPlugin { virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress&, const CharSet, UINT32 ) RETURN_ERROR virtual FltError ScImportRTF( SvStream&, const String&, ScDocument*, ScRange& ) RETURN_ERROR - virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL ) RETURN_ERROR + virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL, SvNumberFormatter*, bool ) RETURN_ERROR virtual ScEEAbsImport *CreateRTFImport( ScDocument*, const ScRange& ) { return NULL; } virtual ScEEAbsImport *CreateHTMLImport( ScDocument*, const String&, const ScRange&, BOOL ) { return NULL; } diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index b8b8d10f0c6e..85903014aa39 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -405,6 +405,7 @@ public: static ScDocShell* GetShellByNum( USHORT nDocNo ); static String GetOwnFilterName(); + static String GetHtmlFilterName(); static String GetWebQueryFilterName(); static String GetAsciiFilterName(); static String GetLotusFilterName(); diff --git a/sc/source/ui/inc/langchooser.hrc b/sc/source/ui/inc/langchooser.hrc new file mode 100644 index 000000000000..93c554ef5c45 --- /dev/null +++ b/sc/source/ui/inc/langchooser.hrc @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retypepassdlg.src,v $ + * $Revision: 1.1.2.3 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 + +#define FL_CHOOSE_LANG 4 +#define RB_AUTOMATIC 5 +#define RB_CUSTOM 6 +#define LB_CUSTOM_LANG 7 +#define FL_OPTION 8 +#define BTN_CONVERT_DATE 9 diff --git a/sc/source/ui/inc/langchooser.hxx b/sc/source/ui/inc/langchooser.hxx new file mode 100644 index 000000000000..4ff849fc2bc0 --- /dev/null +++ b/sc/source/ui/inc/langchooser.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: langbox.hxx,v $ + * $Revision: 1.4.242.1 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_UI_LANGCHOOSER_HXX +#define SC_UI_LANGCHOOSER_HXX + +#include "vcl/dialog.hxx" +#include "vcl/button.hxx" +#include "vcl/fixed.hxx" +#include "i18npool/lang.h" +#include "svx/langbox.hxx" + +class ScLangChooserDlg : public ModalDialog +{ +public: + ScLangChooserDlg(Window* pParent); + virtual ~ScLangChooserDlg(); + + virtual short Execute(); + + LanguageType getLanguageType() const; + bool isDateConversionSet() const; + +private: + void init(); + +private: + OKButton maBtnOk; + CancelButton maBtnCancel; + HelpButton maBtnHelp; + + FixedLine maFlChooseLang; + + RadioButton maRbAutomatic; + RadioButton maRbCustom; + + SvxLanguageBox maLbCustomLang; + + FixedLine maFlOption; + + CheckBox maBtnConvertDate; + + DECL_LINK( OKHdl, OKButton* ); + + DECL_LINK( RadioHdl, RadioButton* ); +}; + + +#endif diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index eb415d1d3ff3..0fab38c8c1da 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -51,7 +51,12 @@ #include "sc.hrc" //CHINA001 #include "scabstdlg.hxx" //CHINA001 +#include "i18npool/lang.h" + +#include + using namespace ::com::sun::star; +using ::rtl::OUStringBuffer; //------------------------------------------------------------------------ @@ -146,6 +151,10 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL; String aFilterString( aFilterName ); + + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); + if ( !bExport && aFilterString == ScDocShell::GetAsciiFilterName() ) { // ascii import is special... @@ -164,8 +173,6 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) pInStream = utl::UcbStreamHelper::CreateStream( xInputStream ); //CHINA001 ScImportAsciiDlg* pDlg = new ScImportAsciiDlg( NULL, aPrivDatName, pInStream, cAsciiDel ); - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, RID_SCDLG_ASCII, cAsciiDel); DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 if ( pDlg->Execute() == RET_OK ) @@ -178,6 +185,24 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) delete pDlg; delete pInStream; } + else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() ) + { + // HTML import. + ::std::auto_ptr pDlg( + pFact->CreateScLangChooserDlg(NULL, RID_SCDLG_LANG_CHOOSER)); + + if (pDlg->Execute() == RET_OK) + { + LanguageType eLang = pDlg->GetLanguageType(); + OUStringBuffer aBuf; + + aBuf.append(String::CreateFromInt32(static_cast(eLang))); + aBuf.append(sal_Unicode(' ')); + aBuf.append(pDlg->IsDateConversionSet() ? sal_Unicode('1') : sal_Unicode('0')); + aFilterOptions = aBuf.makeStringAndClear(); + nRet = ui::dialogs::ExecutableDialogResults::OK; + } + } else { sal_Bool bMultiByte = sal_True; @@ -249,8 +274,6 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) //CHINA001 &aOptions, &aTitle, bMultiByte, bDBEnc, //CHINA001 !bExport ); //CHINA001 - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 AbstractScImportOptionsDlg* pDlg = pFact->CreateScImportOptionsDlg( NULL, RID_SCDLG_IMPORTOPT, bAscii, &aOptions, &aTitle, bMultiByte, bDBEnc, diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index 3fc0712cd996..a7c981a11a95 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -277,6 +277,7 @@ LIB8OBJFILES = \ $(SLO)$/dapidata.obj \ $(SLO)$/crdlg.obj \ $(SLO)$/scuiasciiopt.obj \ + $(SLO)$/langchooser.obj \ $(SLO)$/scuiautofmt.obj \ $(SLO)$/dpgroupdlg.obj \ $(SLO)$/editfield.obj -- cgit v1.2.3 From a1bfe5a5d9abacf9e68f7b87d9b213d65efdbb75 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 11:43:32 -0400 Subject: #i97416# initial porting of patches from ooo-build, to implement modified csv import option dialog. --- sc/source/core/tool/stringutil.cxx | 42 ++++++- sc/source/ui/dbgui/asciiopt.cxx | 38 +++++- sc/source/ui/dbgui/asciiopt.hrc | 72 ++++++----- sc/source/ui/dbgui/asciiopt.src | 231 +++++++++++++++++++++--------------- sc/source/ui/dbgui/scuiasciiopt.cxx | 65 ++++++++-- sc/source/ui/docshell/impex.cxx | 62 ++++++---- sc/source/ui/inc/asciiopt.hxx | 8 +- sc/source/ui/inc/scuiasciiopt.hxx | 9 ++ 8 files changed, 355 insertions(+), 172 deletions(-) (limited to 'sc/source') diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx index e78c6edc88d7..28a4bc6755c2 100644 --- a/sc/source/core/tool/stringutil.cxx +++ b/sc/source/core/tool/stringutil.cxx @@ -35,6 +35,7 @@ #include "stringutil.hxx" #include "rtl/ustrbuf.hxx" +#include "rtl/math.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -42,17 +43,28 @@ using ::rtl::OUStringBuffer; bool ScStringUtil::parseSimpleNumber( const OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal) { + if (gsep == 0x00A0) + // unicode space to ascii space + gsep = 0x0020; + OUStringBuffer aBuf; sal_Int32 n = rStr.getLength(); const sal_Unicode* p = rStr.getStr(); sal_Int32 nPosDSep = -1, nPosGSep = -1; + sal_uInt32 nDigitCount = 0; + for (sal_Int32 i = 0; i < n; ++i) { sal_Unicode c = p[i]; + if (c == 0x00A0) + // unicode space to ascii space + c = 0x0020; + if (sal_Unicode('0') <= c && c <= sal_Unicode('9')) { // this is a digit. aBuf.append(c); + ++nDigitCount; } else if (c == dsep) { @@ -61,28 +73,35 @@ bool ScStringUtil::parseSimpleNumber( if (nPosDSep >= 0) // a second decimal separator -> not a valid number. return false; + if (nPosGSep >= 0 && i - nPosGSep != 4) // the number has a group separator and the decimal sep is not // positioned correctly. return false; nPosDSep = i; + nPosGSep = -1; aBuf.append(c); + nDigitCount = 0; } else if (c == gsep) { // this is a group (thousand) separator. + if (i == 0) + // not allowed as the first character. return false; - if (nPosGSep >= 0 && i - nPosGSep != 4) - { - // this group separator is not positioned correctly relative - // to the last group separator. + if (nPosDSep >= 0) + // not allowed after the decimal separator. + return false; + + if (nPosGSep >= 0 && nDigitCount != 3) + // must be exactly 3 digits since the last group separator. return false; - } nPosGSep = i; + nDigitCount = 0; } else if (c == sal_Unicode('-') || c == sal_Unicode('+')) { @@ -96,6 +115,17 @@ bool ScStringUtil::parseSimpleNumber( return false; } - rVal = aBuf.makeStringAndClear().toDouble(); + // finished parsing the number. + + if (nPosGSep >= 0 && nDigitCount != 3) + // must be exactly 3 digits since the last group separator. + return false; + + rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok; + sal_Int32 nParseEnd = 0; + rVal = ::rtl::math::stringToDouble(aBuf.makeStringAndClear(), dsep, gsep, &eStatus, &nParseEnd); + if (eStatus != rtl_math_ConversionStatus_Ok) + return false; + return true; } diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index fbe13bbd0370..8af7e3e97b06 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -57,8 +57,10 @@ ScAsciiOptions::ScAsciiOptions() : aFieldSeps ( ';' ), bMergeFieldSeps ( FALSE ), bQuotedFieldAsText(false), + bDetectSpecialNumber(false), cTextSep ( cDefaultTextSep ), eCharSet ( gsl_getSystemTextEncoding() ), + eLang ( LANGUAGE_SYSTEM ), bCharSetSystem ( FALSE ), nStartRow ( 1 ), nInfoCount ( 0 ), @@ -73,8 +75,10 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : aFieldSeps ( rOpt.aFieldSeps ), bMergeFieldSeps ( rOpt.bMergeFieldSeps ), bQuotedFieldAsText(rOpt.bQuotedFieldAsText), + bDetectSpecialNumber(rOpt.bDetectSpecialNumber), cTextSep ( rOpt.cTextSep ), eCharSet ( rOpt.eCharSet ), + eLang ( rOpt.eLang ), bCharSetSystem ( rOpt.bCharSetSystem ), nStartRow ( rOpt.nStartRow ), nInfoCount ( rOpt.nInfoCount ) @@ -252,13 +256,20 @@ void ScAsciiOptions::ReadFromString( const String& rString ) eCharSet = ScGlobal::GetCharsetValue( aToken ); } + // Language + if (nCount >= 4) + { + aToken = rString.GetToken(3, ','); + eLang = static_cast(aToken.ToInt32()); + } + // // Startzeile // - if ( nCount >= 4 ) + if ( nCount >= 5 ) { - aToken = rString.GetToken(3,','); + aToken = rString.GetToken(4,','); nStartRow = aToken.ToInt32(); } @@ -266,12 +277,12 @@ void ScAsciiOptions::ReadFromString( const String& rString ) // Spalten-Infos // - if ( nCount >= 5 ) + if ( nCount >= 6 ) { delete[] pColStart; delete[] pColFormat; - aToken = rString.GetToken(4,','); + aToken = rString.GetToken(5,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) @@ -292,11 +303,18 @@ void ScAsciiOptions::ReadFromString( const String& rString ) } // Import quoted field as text. - if (nCount >= 6) + if (nCount >= 7) { - aToken = rString.GetToken(5, ','); + aToken = rString.GetToken(6, ','); bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false; } + + // Detect special nubmers. + if (nCount >= 8) + { + aToken = rString.GetToken(7, ','); + bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false; + } } @@ -347,6 +365,10 @@ String ScAsciiOptions::WriteToString() const aOutStr += ScGlobal::GetCharsetString( eCharSet ); aOutStr += ','; // Token-Ende + // Language + aOutStr += String::CreateFromInt32(eLang); + aOutStr += ','; + // // Startzeile // @@ -372,6 +394,10 @@ String ScAsciiOptions::WriteToString() const // Import quoted field as text. aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false"); + aOutStr += ','; + + // Detect special nubmers. + aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false"); return aOutStr; } diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc index 3177a1be7b78..0264fd0fb4ec 100644 --- a/sc/source/ui/dbgui/asciiopt.hrc +++ b/sc/source/ui/dbgui/asciiopt.hrc @@ -29,32 +29,46 @@ ************************************************************************/ #include "sc.hrc" //#define RID_SCDLG_ASCII 256 -#define RB_SEPARATED 1 -#define RB_FIXED 2 -#define FT_CHARSET 3 -#define LB_CHARSET 4 -#define FL_SEPOPT 5 -#define FT_FIELDSEP 6 -#define CB_FIELDSEP 7 -#define FT_TEXTSEP 8 -#define CB_TEXTSEP 9 -#define FL_FIELDOPT 10 -#define FT_TYPE 12 -#define FT_PREVIEW 13 -#define LB_TYPE1 23 -#define FL_WIDTH 30 -#define BTN_OK 31 -#define BTN_CANCEL 32 -#define BTN_HELP 33 -#define CTR_TABLEBOX 41 -#define CKB_TAB 51 -#define CKB_SPACE 52 -#define CKB_SEMICOLON 53 -#define CKB_COMMA 54 -#define CKB_OTHER 55 -#define ED_OTHER 56 -#define FT_AT_ROW 59 -#define NF_AT_ROW 60 -#define CB_ASONCE 90 -#define CB_QUOTED_AS_TEXT 91 -#define STR_TEXTTOCOLUMNS 100 +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 + +#define FL_FIELDOPT 4 +#define FT_CHARSET 5 +#define LB_CHARSET 6 +#define FT_CUSTOMLANG 7 +#define LB_CUSTOMLANG 8 +#define FT_AT_ROW 9 +#define NF_AT_ROW 10 + +#define FL_SEPOPT 11 +#define RB_FIXED 12 +#define RB_SEPARATED 13 +#define CKB_TAB 14 +#define CKB_COMMA 15 +#define CKB_OTHER 16 +#define ED_OTHER 17 +#define CKB_SEMICOLON 18 +#define CKB_SPACE 19 +#define CB_ASONCE 20 +#define CB_TEXTSEP 21 +#define FT_TEXTSEP 22 + +#define FL_OTHER_OPTIONS 23 +#define CB_QUOTED_AS_TEXT 24 +#define CB_DETECT_SPECIAL_NUMBER 25 + +#define FL_WIDTH 26 +#define FT_TYPE 27 +#define LB_TYPE1 28 +#define CTR_TABLEBOX 29 +#define STR_TEXTTOCOLUMNS 30 + + + + + + + + + diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src index a510471bb799..57c338f0f70d 100644 --- a/sc/source/ui/dbgui/asciiopt.src +++ b/sc/source/ui/dbgui/asciiopt.src @@ -34,55 +34,44 @@ ModalDialog RID_SCDLG_ASCII { OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 320 , 264 ) ; + Size = MAP_APPFONT ( 320 , 305 ) ; Text [ en-US ] = "Text Import" ; Moveable = TRUE ; - FixedLine FL_WIDTH - { - Pos = MAP_APPFONT ( 6 , 147 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Fields" ; - }; - FixedText FT_TYPE - { - Pos = MAP_APPFONT ( 12 , 160 ) ; - Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "Column t~ype"; - }; - ListBox LB_TYPE1 + + OKButton BTN_OK { - Pos = MAP_APPFONT ( 76 , 158 ) ; - Size = MAP_APPFONT ( 60 , 68 ) ; + Pos = MAP_APPFONT ( 264 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; - DropDown = TRUE ; + DefButton = TRUE ; }; - FixedLine FL_SEPOPT + CancelButton BTN_CANCEL { - Pos = MAP_APPFONT ( 6 , 48 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Separator options" ; + Pos = MAP_APPFONT ( 264 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; }; - RadioButton RB_FIXED + HelpButton BTN_HELP { - Pos = MAP_APPFONT ( 12 , 59 ) ; - Size = MAP_APPFONT ( 243 , 10 ) ; - Text [ en-US ] = "~Fixed width" ; + Pos = MAP_APPFONT ( 264 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; - RadioButton RB_SEPARATED + + FixedLine FL_FIELDOPT { - Pos = MAP_APPFONT ( 12 , 73 ) ; - Size = MAP_APPFONT ( 243 , 10 ) ; - Text [ en-US ] = "~Separated by" ; - TabStop = TRUE ; - Check = TRUE ; + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Import" ; }; + FixedText FT_CHARSET { Pos = MAP_APPFONT ( 12 , 16 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; Text [ en-US ] = "Ch~aracter set" ; }; + ListBox LB_CHARSET { Pos = MAP_APPFONT ( 76 , 14 ) ; @@ -91,75 +80,81 @@ ModalDialog RID_SCDLG_ASCII DropDown = TRUE ; Sort = TRUE; }; - FixedLine FL_FIELDOPT - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Import" ; - }; - FixedText FT_TEXTSEP + + FixedText FT_CUSTOMLANG { - Pos = MAP_APPFONT ( 156 , 114 ) ; + Pos = MAP_APPFONT ( 12 , 32 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "Te~xt delimiter" ; + Text [ en-US ] = "Language" ; }; - ComboBox CB_TEXTSEP + + ListBox LB_CUSTOMLANG { - Pos = MAP_APPFONT ( 218 , 112 ) ; - Size = MAP_APPFONT ( 37 , 94 ) ; + Pos = MAP_APPFONT ( 76 , 30 ) ; + Size = MAP_APPFONT ( 130 , 61 ) ; TabStop = TRUE ; DropDown = TRUE ; + Sort = TRUE; }; - OKButton BTN_OK + + FixedText FT_AT_ROW { - Pos = MAP_APPFONT ( 264 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; + Pos = MAP_APPFONT ( 12 , 48 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "From ro~w" ; }; - CancelButton BTN_CANCEL + + NumericField NF_AT_ROW { - Pos = MAP_APPFONT ( 264 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 76 , 46 ) ; + Size = MAP_APPFONT ( 30 , 12 ) ; TabStop = TRUE ; + Spin = TRUE ; + Repeat = TRUE ; + Minimum = 1 ; }; - HelpButton BTN_HELP + + FixedLine FL_SEPOPT { - Pos = MAP_APPFONT ( 264 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; + Pos = MAP_APPFONT ( 6 , 63 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Separator options" ; }; - CheckBox CKB_TAB + RadioButton RB_FIXED { - Pos = MAP_APPFONT ( 20 , 86 ) ; - Size = MAP_APPFONT ( 68 , 10 ) ; + Pos = MAP_APPFONT ( 12 , 75 ) ; + Size = MAP_APPFONT ( 243 , 10 ) ; + Text [ en-US ] = "~Fixed width" ; TabStop = TRUE ; - Text [ en-US ] = "~Tab" ; }; - CheckBox CKB_SEMICOLON + RadioButton RB_SEPARATED { - Pos = MAP_APPFONT ( 20 , 99 ) ; - Size = MAP_APPFONT ( 68 , 10 ) ; + Pos = MAP_APPFONT ( 12 , 89 ) ; + Size = MAP_APPFONT ( 243 , 10 ) ; + Text [ en-US ] = "~Separated by" ; TabStop = TRUE ; - Text [ en-US ] = "S~emicolon" ; + Check = TRUE ; }; - CheckBox CKB_COMMA + + CheckBox CKB_TAB { - Pos = MAP_APPFONT ( 92 , 86 ) ; + Pos = MAP_APPFONT ( 20 , 102 ) ; Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "~Comma" ; + Text [ en-US ] = "~Tab" ; }; - CheckBox CKB_SPACE + CheckBox CKB_COMMA { - Pos = MAP_APPFONT ( 92 , 99 ) ; + Pos = MAP_APPFONT ( 92 , 102 ) ; Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "S~pace" ; + Text [ en-US ] = "~Comma" ; }; CheckBox CKB_OTHER { - Pos = MAP_APPFONT ( 164 , 86 ) ; + Pos = MAP_APPFONT ( 164 , 102 ) ; Size = MAP_APPFONT ( 50 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Other" ; @@ -167,50 +162,100 @@ ModalDialog RID_SCDLG_ASCII Edit ED_OTHER { Border = TRUE ; - Pos = MAP_APPFONT ( 218 , 84 ) ; + Pos = MAP_APPFONT ( 218 , 100 ) ; Size = MAP_APPFONT ( 37 , 12 ) ; TabStop = TRUE ; MaxTextLength = 10 ; }; - FixedText FT_AT_ROW - { - Pos = MAP_APPFONT ( 12 , 32 ) ; - Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "From ro~w" ; - }; - NumericField NF_AT_ROW + + CheckBox CKB_SEMICOLON { - Border = TRUE ; - SVLook = TRUE ; - Pos = MAP_APPFONT ( 76 , 30 ) ; - Size = MAP_APPFONT ( 30 , 12 ) ; + Pos = MAP_APPFONT ( 20 , 115 ) ; + Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Spin = TRUE ; - Repeat = TRUE ; - Minimum = 1 ; + Text [ en-US ] = "S~emicolon" ; }; - Control CTR_TABLEBOX + CheckBox CKB_SPACE { - HelpId = HID_SC_ASCII_TABCTR ; - Border = TRUE ; - DialogControl = TRUE ; - Pos = MAP_APPFONT ( 12 , 176 ) ; - Size = MAP_APPFONT ( 243 , 82 ) ; + Pos = MAP_APPFONT ( 92 , 115 ) ; + Size = MAP_APPFONT ( 68 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "S~pace" ; }; + CheckBox CB_ASONCE { - Pos = MAP_APPFONT ( 20 , 114 ) ; + Pos = MAP_APPFONT ( 20 , 130 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Merge ~delimiters" ; }; + + ComboBox CB_TEXTSEP + { + Pos = MAP_APPFONT ( 218 , 128 ) ; + Size = MAP_APPFONT ( 37 , 94 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + FixedText FT_TEXTSEP + { + Pos = MAP_APPFONT ( 156 , 130 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Te~xt delimiter" ; + }; + + FixedLine FL_OTHER_OPTIONS + { + Pos = MAP_APPFONT ( 6 , 146 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Other options" ; + }; + CheckBox CB_QUOTED_AS_TEXT { - Pos = MAP_APPFONT ( 20 , 129 ) ; + Pos = MAP_APPFONT ( 20 , 158 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Quoted field as text" ; }; + + CheckBox CB_DETECT_SPECIAL_NUMBER + { + Pos = MAP_APPFONT ( 20 , 171 ) ; + Size = MAP_APPFONT ( 130 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Detect special numbers" ; + }; + + FixedLine FL_WIDTH + { + Pos = MAP_APPFONT ( 6 , 187 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Fields" ; + }; + FixedText FT_TYPE + { + Pos = MAP_APPFONT ( 12 , 200 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Column t~ype"; + }; + ListBox LB_TYPE1 + { + Pos = MAP_APPFONT ( 76 , 198 ) ; + Size = MAP_APPFONT ( 60 , 68 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + Control CTR_TABLEBOX + { + HelpId = HID_SC_ASCII_TABCTR ; + Border = TRUE ; + DialogControl = TRUE ; + Pos = MAP_APPFONT ( 12 , 216 ) ; + Size = MAP_APPFONT ( 243 , 82 ) ; + }; + String STR_TEXTTOCOLUMNS { Text [ en-US ] = "Text to Columns" ; diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 9d782347b5ea..0136e29ccc91 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -69,6 +69,8 @@ using namespace com::sun::star::uno; #define TEXT_SEPARATORS "TextSeparators" #define MERGE_DELIMITERS "MergeDelimiters" #define QUOTED_AS_TEXT "QuotedFieldAsText" +#define DETECT_SPECIAL_NUM "DetectSpecialNumbers" +#define LANGUAGE "Language" #define SEP_PATH "Office.Calc/Dialogs/CSVImport" // ============================================================================ @@ -119,12 +121,13 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) } static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, - bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth, - sal_Int32 &nFromRow, sal_Int32 &nCharSet ) + bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum, + bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet, + sal_Int32& nLanguage ) { SequenceaValues; const Any *pProperties; - Sequence aNames(7); + Sequence aNames(9); OUString* pNames = aNames.getArray(); ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); @@ -135,6 +138,8 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato pNames[4] = OUString::createFromAscii( FROM_ROW ); pNames[5] = OUString::createFromAscii( CHAR_SET ); pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM ); + pNames[8] = OUString::createFromAscii( LANGUAGE ); aValues = aItem.GetProperties( aNames ); pProperties = aValues.getConstArray(); if( pProperties[1].hasValue() ) @@ -157,16 +162,23 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato if ( pProperties[6].hasValue() ) pProperties[6] >>= bQuotedAsText; + + if ( pProperties[7].hasValue() ) + pProperties[7] >>= bDetectSpecialNum; + + if ( pProperties[8].hasValue() ) + pProperties[8] >>= nLanguage; } -static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, - bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet ) +static void save_Separators( + String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, + bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage ) { OUString sFieldSeparators = OUString( maSeparators ); OUString sTextSeparators = OUString( maTxtSep ); Sequence aValues; Any *pProperties; - Sequence aNames(7); + Sequence aNames(9); OUString* pNames = aNames.getArray(); ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); @@ -177,6 +189,8 @@ static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDe pNames[4] = OUString::createFromAscii( FROM_ROW ); pNames[5] = OUString::createFromAscii( CHAR_SET ); pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM ); + pNames[8] = OUString::createFromAscii( LANGUAGE ); aValues = aItem.GetProperties( aNames ); pProperties = aValues.getArray(); pProperties[1] <<= sFieldSeparators; @@ -186,6 +200,8 @@ static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDe pProperties[4] <<= nFromRow; pProperties[5] <<= nCharSet; pProperties[6] <<= static_cast(bQuotedAsText); + pProperties[7] <<= static_cast(bDetectSpecialNum); + pProperties[8] <<= nLanguage; aItem.PutProperties(aNames, aValues); } @@ -204,6 +220,8 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ), aFtCharSet ( this, ScResId( FT_CHARSET ) ), aLbCharSet ( this, ScResId( LB_CHARSET ) ), + aFtCustomLang( this, ScResId( FT_CUSTOMLANG ) ), + aLbCustomLang( this, ScResId( LB_CUSTOMLANG ) ), aFtRow ( this, ScResId( FT_AT_ROW ) ), aNfRow ( this, ScResId( NF_AT_ROW ) ), @@ -219,7 +237,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbOther ( this, ScResId( CKB_OTHER ) ), aEdOther ( this, ScResId( ED_OTHER ) ), aCkbAsOnce ( this, ScResId( CB_ASONCE) ), + aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), + aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), @@ -260,18 +281,22 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, bool bMergeDelimiters = false; bool bFixedWidth = false; bool bQuotedFieldAsText = true; + bool bDetectSpecialNum = false; sal_Int32 nFromRow = 1; sal_Int32 nCharSet = -1; + sal_Int32 nLanguage = 0; if (mbFileImport) // load separators only when importing csv files. load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, - bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet); + bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage); maFieldSeparators = String(sFieldSeparators); if( bMergeDelimiters ) aCkbAsOnce.Check(); if (bQuotedFieldAsText) aCkbQuotedAsText.Check(); + if (bDetectSpecialNum) + aCkbDetectNumber.Check(); if( bFixedWidth ) aRbFixed.Check(); if( nFromRow != 1 ) @@ -344,6 +369,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbComma.SetClickHdl( aSeparatorHdl ); aCkbAsOnce.SetClickHdl( aSeparatorHdl ); aCkbQuotedAsText.SetClickHdl( aSeparatorHdl ); + aCkbDetectNumber.SetClickHdl( aSeparatorHdl ); aCkbSpace.SetClickHdl( aSeparatorHdl ); aCkbOther.SetClickHdl( aSeparatorHdl ); aEdOther.SetModifyHdl( aSeparatorHdl ); @@ -363,6 +389,11 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); + aLbCustomLang.SetLanguageList( + LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false); + aLbCustomLang.InsertLanguage(LANGUAGE_SYSTEM); + aLbCustomLang.SelectLanguage(static_cast(nLanguage), true); + // *** column type ListBox *** xub_StrLen nCount = aColumnUser.GetTokenCount(); for (xub_StrLen i=0; i(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } @@ -473,6 +505,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetCharSet( meCharSet ); rOpt.SetCharSetSystem( mbCharSetSystem ); + rOpt.SetLanguage(aLbCustomLang.GetSelectLanguage()); rOpt.SetFixedLen( aRbFixed.IsChecked() ); rOpt.SetStartRow( (long)aNfRow.GetValue() ); maTableBox.FillColumnData( rOpt ); @@ -480,9 +513,11 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetFieldSeps( GetSeparators() ); rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() ); - rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) ); } + + rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); + rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked()); } void ScImportAsciiDlg::SetTextToColumnsMode() @@ -490,12 +525,19 @@ void ScImportAsciiDlg::SetTextToColumnsMode() SetText( maStrTextToColumns ); aFtCharSet.Disable(); aLbCharSet.Disable(); + aFtCustomLang.Disable(); + aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM); + aLbCustomLang.Disable(); aFtRow.Disable(); aNfRow.Disable(); - // Quoted field as text option is not used for text to columns mode. + // Quoted field as text option is not used for text-to-columns mode. aCkbQuotedAsText.Check(false); aCkbQuotedAsText.Disable(); + + // Always detect special numbers for text-to-columns mode. + aCkbDetectNumber.Check(); + aCkbDetectNumber.Disable(); } void ScImportAsciiDlg::SetSelectedCharSet() @@ -532,7 +574,6 @@ void ScImportAsciiDlg::SetupSeparatorCtrls() aCkbOther.Enable( bEnable ); aEdOther.Enable( bEnable ); aCkbAsOnce.Enable( bEnable ); - aCkbQuotedAsText.Enable( bEnable ); aFtTextSep.Enable( bEnable ); aCbTextSep.Enable( bEnable ); } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 288ad755cb52..5b70cf2f02ae 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -907,6 +907,7 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm ) static bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat, + SvNumberFormatter* pFormatter, bool bDetectNumFormat, ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar, ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar ) { @@ -924,10 +925,10 @@ static bool lcl_PutString( { //! SetString mit Extra-Flag ??? - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US); + SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable(); + sal_uInt32 nEnglish = pDocFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US); double fVal; - if ( pFormatter->IsNumberFormat( rStr, nEnglish, fVal ) ) + if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) ) { // Zahlformat wird nicht auf englisch gesetzt pDoc->SetValue( nCol, nRow, nTab, fVal ); @@ -1063,9 +1064,9 @@ static bool lcl_PutString( } } - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable(); if ( nYear < 100 ) - nYear = pFormatter->ExpandTwoDigitYear( nYear ); + nYear = pDocFormatter->ExpandTwoDigitYear( nYear ); CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar); sal_Int16 nNumMonths = pCalendar->getNumberOfMonthsInYear(); @@ -1101,7 +1102,7 @@ static bool lcl_PutString( pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli ); if ( pCalendar->isValid() ) { - double fDiff = DateTime(*pFormatter->GetNullDate()) - + double fDiff = DateTime(*pDocFormatter->GetNullDate()) - pCalendar->getEpochStart(); // #i14974# must use getLocalDateTime to get the same // date values as set above @@ -1113,10 +1114,10 @@ static bool lcl_PutString( LanguageType eDocLang = eLatin; //! which language for date formats? short nType = (nFound > 3 ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE); - ULONG nFormat = pFormatter->GetStandardFormat( nType, eDocLang ); + ULONG nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang ); // maybe there is a special format including seconds or milliseconds if (nFound > 5) - nFormat = pFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang); + nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang); pDoc->PutCell( nCol, nRow, nTab, new ScValueCell(fDays), nFormat, FALSE ); @@ -1128,7 +1129,7 @@ static bool lcl_PutString( // Standard or date not determined -> SetString / EditCell if( rStr.Search( _LF ) == STRING_NOTFOUND ) - pDoc->SetString( nCol, nRow, nTab, rStr ); + pDoc->SetString( nCol, nRow, nTab, rStr, pFormatter, bDetectNumFormat ); else { bMultiLine = true; @@ -1138,7 +1139,7 @@ static bool lcl_PutString( } -String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext ) +String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext, bool& rbIsQuoted ) { xub_StrLen nLen = rLine.Len(); if (nNext > nLen) @@ -1152,7 +1153,11 @@ String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext ) while ( nSpace > nStart && pStr[nSpace-1] == ' ' ) --nSpace; - return rLine.Copy( nStart, nSpace-nStart ); + rbIsQuoted = (pStr[nStart] == sal_Unicode('"') && pStr[nSpace-1] == sal_Unicode('"')); + if (rbIsQuoted) + return rLine.Copy(nStart+1, nSpace-nStart-2); + else + return rLine.Copy(nStart, nSpace-nStart); } BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) @@ -1185,9 +1190,9 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) const BYTE* pColFormat = pExtOptions->GetColFormat(); long nSkipLines = pExtOptions->GetStartRow(); - LanguageType eLatin, eCjk, eCtl; - pDoc->GetLanguage( eLatin, eCjk, eCtl ); - LanguageType eDocLang = eLatin; //! which language for date formats? + LanguageType eDocLang = pExtOptions->GetLanguage(); + SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eDocLang); + bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber(); // For date recognition ::utl::TransliterationWrapper aTransliteration( @@ -1229,6 +1234,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // survives the toggle of bDetermineRange down at the end of the do{} loop. bool bRangeIsDetermined = bDetermineRange; + bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText(); + ULONG nOriginalStreamPos = rStrm.Tell(); do @@ -1250,7 +1257,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // SC_COL_SKIP. for ( i=0; i MAXCOL) bOverflow = TRUE; // display warning on import @@ -1258,11 +1266,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) { xub_StrLen nStart = pColStart[i]; xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen; - aCell = lcl_GetFixed( aLine, nStart, nNext ); - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, - nTab, aCell, pColFormat[i], - aTransliteration, aCalendar, - pEnglishTransliteration, pEnglishCalendar); + bool bIsQuoted = false; + aCell = lcl_GetFixed( aLine, nStart, nNext, bIsQuoted ); + if (bIsQuoted && bQuotedAsText) + nFmt = SC_COL_TEXT; + + bMultiLine |= lcl_PutString( + pDoc, nCol, nRow, nTab, aCell, nFmt, + &aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar, + pEnglishTransliteration, pEnglishCalendar); } ++nCol; } @@ -1298,13 +1310,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) bOverflow = TRUE; // display warning on import else if (!bDetermineRange) { - if (bIsQuoted && pExtOptions && pExtOptions->IsQuotedAsText()) + if (bIsQuoted && bQuotedAsText) nFmt = SC_COL_TEXT; - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, - nTab, aCell, nFmt, aTransliteration, - aCalendar, pEnglishTransliteration, - pEnglishCalendar); + bMultiLine |= lcl_PutString( + pDoc, nCol, nRow, nTab, aCell, nFmt, + &aNumFormatter, bDetectNumFormat, aTransliteration, + aCalendar, pEnglishTransliteration, pEnglishCalendar); } ++nCol; } diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx index 40c95f0f0702..54885eae2ccd 100644 --- a/sc/source/ui/inc/asciiopt.hxx +++ b/sc/source/ui/inc/asciiopt.hxx @@ -55,7 +55,7 @@ #include #include #include "csvtablebox.hxx" - +#include "i18npool/lang.h" // ============================================================================ @@ -66,8 +66,10 @@ private: String aFieldSeps; BOOL bMergeFieldSeps; bool bQuotedFieldAsText; + bool bDetectSpecialNumber; sal_Unicode cTextSep; CharSet eCharSet; + LanguageType eLang; BOOL bCharSetSystem; long nStartRow; USHORT nInfoCount; @@ -95,12 +97,14 @@ public: const String& GetFieldSeps() const { return aFieldSeps; } BOOL IsMergeSeps() const { return bMergeFieldSeps; } bool IsQuotedAsText() const { return bQuotedFieldAsText; } + bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; } sal_Unicode GetTextSep() const { return cTextSep; } BOOL IsFixedLen() const { return bFixedLen; } USHORT GetInfoCount() const { return nInfoCount; } const xub_StrLen* GetColStart() const { return pColStart; } const BYTE* GetColFormat() const { return pColFormat; } long GetStartRow() const { return nStartRow; } + LanguageType GetLanguage() const { return eLang; } void SetCharSet( CharSet eNew ) { eCharSet = eNew; } void SetCharSetSystem( BOOL bSet ) { bCharSetSystem = bSet; } @@ -108,8 +112,10 @@ public: void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; } void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; } void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } + void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; } void SetTextSep( sal_Unicode c ) { cTextSep = c; } void SetStartRow( long nRow) { nStartRow= nRow; } + void SetLanguage(LanguageType e) { eLang = e; } void SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat ); void SetColumnInfo( const ScCsvExpDataVec& rDataVec ); diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 33bc48b7122a..82963d2904af 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -35,6 +35,8 @@ #include "asciiopt.hxx" +#include "svx/langbox.hxx" + // ============================================================================ class ScImportAsciiDlg : public ModalDialog @@ -49,6 +51,8 @@ class ScImportAsciiDlg : public ModalDialog FixedLine aFlFieldOpt; FixedText aFtCharSet; SvxTextEncodingBox aLbCharSet; + FixedText aFtCustomLang; + SvxLanguageBox aLbCustomLang; FixedText aFtRow; NumericField aNfRow; @@ -64,7 +68,12 @@ class ScImportAsciiDlg : public ModalDialog CheckBox aCkbOther; Edit aEdOther; CheckBox aCkbAsOnce; + + FixedLine aFlOtherOpt; + CheckBox aCkbQuotedAsText; + CheckBox aCkbDetectNumber; + FixedText aFtTextSep; ComboBox aCbTextSep; -- cgit v1.2.3 From 23d5998c325a7999f75448e70b315d12b639abc6 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 14:57:34 -0400 Subject: fixed build breakages. sc module is now buildable. --- sc/inc/optutil.hxx | 7 ++++--- sc/inc/sc.hrc | 6 ++---- sc/source/core/tool/optutil.cxx | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'sc/source') diff --git a/sc/inc/optutil.hxx b/sc/inc/optutil.hxx index a00b3495d766..15cc8ba79bb7 100644 --- a/sc/inc/optutil.hxx +++ b/sc/inc/optutil.hxx @@ -33,6 +33,7 @@ #include #include +#include "scdllapi.h" class ScOptionsUtil @@ -44,13 +45,13 @@ public: // ConfigItem for classes that use items from several sub trees -class ScLinkConfigItem : public utl::ConfigItem +class SC_DLLPUBLIC ScLinkConfigItem : public utl::ConfigItem { Link aCommitLink; public: - ScLinkConfigItem( const rtl::OUString rSubTree ); - ScLinkConfigItem( const rtl::OUString rSubTree, sal_Int16 nMode ); + ScLinkConfigItem( const rtl::OUString& rSubTree ); + ScLinkConfigItem( const rtl::OUString& rSubTree, sal_Int16 nMode ); void SetCommitLink( const Link& rLink ); virtual void Notify( const com::sun::star::uno::Sequence& aPropertyNames ); diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index ba3420f1d9c3..baf94c23748f 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1635,8 +1635,9 @@ #define RID_SCDLG_DOCPROTECTION (SC_DIALOGS_START + 149) #define RID_SCDLG_RETYPEPASS (SC_DIALOGS_START + 150) #define RID_SCDLG_RETYPEPASS_INPUT (SC_DIALOGS_START + 151) +#define RID_SCDLG_LANG_CHOOSER (SC_DIALOGS_START + 152) -#define SC_DIALOGS_END (SC_DIALOGS_START + 152) +#define SC_DIALOGS_END (SC_DIALOGS_START + 153) #ifndef STD_MASKCOLOR #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } @@ -1650,9 +1651,6 @@ #define MID_3 3 #define MID_4 4 -// Language chooser for text import filters. -#define RID_SCDLG_LANG_CHOOSER (SC_OOO_BUILD_START + 12) - #endif diff --git a/sc/source/core/tool/optutil.cxx b/sc/source/core/tool/optutil.cxx index 3f3d2886dfa7..1a6ce33a3c6d 100644 --- a/sc/source/core/tool/optutil.cxx +++ b/sc/source/core/tool/optutil.cxx @@ -54,12 +54,12 @@ BOOL ScOptionsUtil::IsMetricSystem() //------------------------------------------------------------------ -ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString rSubTree ) : +ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString& rSubTree ) : ConfigItem( rSubTree ) { } -ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString rSubTree, sal_Int16 nMode ) : +ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString& rSubTree, sal_Int16 nMode ) : ConfigItem( rSubTree, nMode ) { } -- cgit v1.2.3 From feeb99de89fc888b9397ddca882d121bdec2bef4 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 6 Aug 2009 14:58:06 -0400 Subject: Change the identity of the import option dialog. Change the identity of the import option dialog from lang chooser to text import options, since the dialog now contains more than just the language option. --- sc/inc/sc.hrc | 2 +- sc/inc/scabstdlg.hxx | 4 +- sc/source/ui/attrdlg/scdlgfact.cxx | 18 ++--- sc/source/ui/attrdlg/scdlgfact.hxx | 8 +-- sc/source/ui/dbgui/makefile.mk | 6 +- sc/source/ui/dbgui/textimportoptions.cxx | 120 +++++++++++++++++++++++++++++++ sc/source/ui/dbgui/textimportoptions.src | 112 +++++++++++++++++++++++++++++ sc/source/ui/inc/textimportoptions.hrc | 42 +++++++++++ sc/source/ui/inc/textimportoptions.hxx | 76 ++++++++++++++++++++ sc/source/ui/unoobj/filtuno.cxx | 4 +- sc/util/makefile.mk | 2 +- 11 files changed, 372 insertions(+), 22 deletions(-) create mode 100644 sc/source/ui/dbgui/textimportoptions.cxx create mode 100644 sc/source/ui/dbgui/textimportoptions.src create mode 100644 sc/source/ui/inc/textimportoptions.hrc create mode 100644 sc/source/ui/inc/textimportoptions.hxx (limited to 'sc/source') diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index baf94c23748f..df07ed7a6d4c 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1635,7 +1635,7 @@ #define RID_SCDLG_DOCPROTECTION (SC_DIALOGS_START + 149) #define RID_SCDLG_RETYPEPASS (SC_DIALOGS_START + 150) #define RID_SCDLG_RETYPEPASS_INPUT (SC_DIALOGS_START + 151) -#define RID_SCDLG_LANG_CHOOSER (SC_DIALOGS_START + 152) +#define RID_SCDLG_TEXT_IMPORT_OPTIONS (SC_DIALOGS_START + 152) #define SC_DIALOGS_END (SC_DIALOGS_START + 153) diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 89c33bcae13f..9dc272715bd8 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -291,7 +291,7 @@ public: virtual void GetImportOptions( ScImportOptions& rOptions ) const = 0; }; -class AbstractScLangChooserDlg : public VclAbstractDialog //add for ScLangChooserDlg +class AbstractScTextImportOptionsDlg : public VclAbstractDialog //add for ScLangChooserDlg { public: virtual LanguageType GetLanguageType() const = 0; @@ -308,7 +308,7 @@ public: SvStream* pInStream, int nId, sal_Unicode cSep = '\t') = 0; - virtual AbstractScLangChooserDlg * CreateScLangChooserDlg( Window* pParent, int nId ) = 0; + virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId ) = 0; virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg ScAutoFormat* pAutoFormat, diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 9690470ebfc8..f4aa89aaff1f 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -74,7 +74,7 @@ #include "validate.hxx" //add for ScValidationDlg #include "validate.hrc" //add for ScValidationDlg #include "sortdlg.hxx" //add for ScSortDlg -#include "langchooser.hxx" +#include "textimportoptions.hxx" #include "opredlin.hxx" //add for ScRedlineOptionsTabPage #include "tpcalc.hxx" //add for ScTpCalcOptions #include "tpprint.hxx" //add for ScTpPrintOptions @@ -116,7 +116,7 @@ IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl); //add for ScNewScenarioDlg IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); //add for ScShowTabDlg IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); //add for ScStringInputDlg IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); //add for ScImportOptionsDlg -IMPL_ABSTDLG_BASE(AbstractScLangChooserDlg_Impl); +IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl); IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg // AbstractTabDialog_Impl begin @@ -624,12 +624,12 @@ void AbstractScImportOptionsDlg_Impl::GetImportOptions( ScImportOptions& rOption // add for AbstractScImportOptionsDlg_Impl end //add for AbstractScLangChooserDlg_Impl begin -LanguageType AbstractScLangChooserDlg_Impl::GetLanguageType() const +LanguageType AbstractScTextImportOptionsDlg_Impl::GetLanguageType() const { return pDlg->getLanguageType(); } -bool AbstractScLangChooserDlg_Impl::IsDateConversionSet() const +bool AbstractScTextImportOptionsDlg_Impl::IsDateConversionSet() const { return pDlg->isDateConversionSet(); } @@ -658,19 +658,19 @@ AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg } // ScImportAsciiDlg end -AbstractScLangChooserDlg * ScAbstractDialogFactory_Impl::CreateScLangChooserDlg( Window* pParent, int nId ) +AbstractScTextImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScTextImportOptionsDlg( Window* pParent, int nId ) { - ScLangChooserDlg* pDlg = NULL; + ScTextImportOptionsDlg* pDlg = NULL; switch (nId) { - case RID_SCDLG_LANG_CHOOSER: - pDlg = new ScLangChooserDlg(pParent); + case RID_SCDLG_TEXT_IMPORT_OPTIONS: + pDlg = new ScTextImportOptionsDlg(pParent); break; default: ; } - return pDlg ? new AbstractScLangChooserDlg_Impl(pDlg) : NULL; + return pDlg ? new AbstractScTextImportOptionsDlg_Impl(pDlg) : NULL; } //add for ScAutoFormatDlg begin diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index dfdcbcced3e9..3b370f02d5df 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -64,7 +64,7 @@ class ScStringInputDlg; class ScImportOptionsDlg; class SfxTabDialog; class ScSortWarningDlg; -class ScLangChooserDlg; +class ScTextImportOptionsDlg; #define DECL_ABSTDLG_BASE(Class,DialogClass) \ DialogClass* pDlg; \ @@ -344,9 +344,9 @@ class AbstractScImportOptionsDlg_Impl : public AbstractScImportOptionsDlg //add virtual void GetImportOptions( ScImportOptions& rOptions ) const; }; -class AbstractScLangChooserDlg_Impl : public AbstractScLangChooserDlg +class AbstractScTextImportOptionsDlg_Impl : public AbstractScTextImportOptionsDlg { - DECL_ABSTDLG_BASE( AbstractScLangChooserDlg_Impl, ScLangChooserDlg) + DECL_ABSTDLG_BASE( AbstractScTextImportOptionsDlg_Impl, ScTextImportOptionsDlg) virtual LanguageType GetLanguageType() const; virtual bool IsDateConversionSet() const; }; @@ -392,7 +392,7 @@ public: SvStream* pInStream, int nId, sal_Unicode cSep = '\t'); - virtual AbstractScLangChooserDlg * CreateScLangChooserDlg( Window* pParent, int nId ); + virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId ); virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg ScAutoFormat* pAutoFormat, diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk index 5bf847ef9a93..e5b6bfd0c74b 100644 --- a/sc/source/ui/dbgui/makefile.mk +++ b/sc/source/ui/dbgui/makefile.mk @@ -53,7 +53,7 @@ SLOFILES = \ $(SLO)$/pfiltdlg.obj \ $(SLO)$/dbnamdlg.obj \ $(SLO)$/expftext.obj \ - $(SLO)$/langchooser.obj \ + $(SLO)$/textimportoptions.obj \ $(SLO)$/subtdlg.obj \ $(SLO)$/tpsubt.obj \ $(SLO)$/fieldwnd.obj \ @@ -86,7 +86,7 @@ EXCEPTIONSFILES= \ SRS1NAME=$(TARGET) SRC1FILES = \ - langchooser.src \ + textimportoptions.src \ pivot.src \ pvfundlg.src \ dpgroupdlg.src \ @@ -117,7 +117,7 @@ LIB1OBJFILES = \ $(SLO)$/csvgrid.obj \ $(SLO)$/csvtablebox.obj \ $(SLO)$/asciiopt.obj \ - $(SLO)$/langchooser.obj + $(SLO)$/textimportoptions.obj # --- Tagets ------------------------------------------------------- diff --git a/sc/source/ui/dbgui/textimportoptions.cxx b/sc/source/ui/dbgui/textimportoptions.cxx new file mode 100644 index 000000000000..d1e0f0949f64 --- /dev/null +++ b/sc/source/ui/dbgui/textimportoptions.cxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: langbox.hxx,v $ + * $Revision: 1.4.242.1 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + +//------------------------------------------------------------------------ + +#include "textimportoptions.hxx" +#include "textimportoptions.hrc" + +#include "scresid.hxx" +#include "vcl/window.hxx" +#include "vcl/msgbox.hxx" +#include "vcl/svapp.hxx" + +ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) : + ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)), + + maBtnOk(this, ScResId(BTN_OK)), + maBtnCancel(this, ScResId(BTN_CANCEL)), + maBtnHelp(this, ScResId(BTN_HELP)), + maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)), + maRbAutomatic(this, ScResId(RB_AUTOMATIC)), + maRbCustom(this, ScResId(RB_CUSTOM)), + maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)), + maFlOption(this, ScResId(FL_OPTION)), + maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE)) +{ + init(); +} + +ScTextImportOptionsDlg::~ScTextImportOptionsDlg() +{ +} + +short ScTextImportOptionsDlg::Execute() +{ + return ModalDialog::Execute(); +} + +LanguageType ScTextImportOptionsDlg::getLanguageType() const +{ + if (maRbAutomatic.IsChecked()) + return LANGUAGE_SYSTEM; + + return maLbCustomLang.GetSelectLanguage(); +} + +bool ScTextImportOptionsDlg::isDateConversionSet() const +{ + return maBtnConvertDate.IsChecked(); +} + +void ScTextImportOptionsDlg::init() +{ + Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl ); + maBtnOk.SetClickHdl(aLink); + aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl ); + maRbAutomatic.SetClickHdl(aLink); + maRbCustom.SetClickHdl(aLink); + + maRbAutomatic.Check(true); + + maLbCustomLang.SetLanguageList( + LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false); + + LanguageType eLang = Application::GetSettings().GetLanguage(); + maLbCustomLang.SelectLanguage(eLang); + maLbCustomLang.Disable(); +} + +IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG ) +{ + EndDialog(RET_OK); + return 0; +} + +IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn ) +{ + if (pBtn == &maRbAutomatic) + { + maLbCustomLang.Disable(); + } + else if (pBtn == &maRbCustom) + { + maLbCustomLang.Enable(); + } + return 0; +} + diff --git a/sc/source/ui/dbgui/textimportoptions.src b/sc/source/ui/dbgui/textimportoptions.src new file mode 100644 index 000000000000..fff3c4b40749 --- /dev/null +++ b/sc/source/ui/dbgui/textimportoptions.src @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retypepassdlg.src,v $ + * $Revision: 1.1.2.3 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "textimportoptions.hrc" + +ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS +{ + Text [ en-US ] = "Import Options" ; + Size = MAP_APPFONT ( 190 , 101 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + OutputSize = TRUE ; + + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 135, 6 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + DefButton = TRUE ; + }; + + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 135, 23 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + }; + + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 135, 43 ) ; + Size = MAP_APPFONT ( 50, 14 ) ; + }; + + FixedLine FL_CHOOSE_LANG + { + Pos = MAP_APPFONT( 6, 3 ) ; + Size = MAP_APPFONT( 125, 14 ) ; + + Text [ en-US ] = "Select the language to use for import" ; + }; + + RadioButton RB_AUTOMATIC + { + Pos = MAP_APPFONT( 12, 20 ) ; + Size = MAP_APPFONT( 50, 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "Automatic" ; + }; + + RadioButton RB_CUSTOM + { + Pos = MAP_APPFONT( 12, 34 ) ; + Size = MAP_APPFONT( 50, 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "Custom" ; + }; + + ListBox LB_CUSTOM_LANG + { + Pos = MAP_APPFONT( 20, 50 ) ; + Size = MAP_APPFONT( 100, 55 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + Sort = TRUE ; + }; + + FixedLine FL_OPTION + { + Pos = MAP_APPFONT( 6, 70 ); + Size = MAP_APPFONT( 125, 14 ); + + Text [ en-US ] = "Options" ; + }; + + CheckBox BTN_CONVERT_DATE + { + Pos = MAP_APPFONT( 12, 86 ); + Size = MAP_APPFONT( 125, 10 ); + TabStop = TRUE ; + + Text [ en-US ] = "Detect special numbers (such as dates)." ; + }; +}; + diff --git a/sc/source/ui/inc/textimportoptions.hrc b/sc/source/ui/inc/textimportoptions.hrc new file mode 100644 index 000000000000..93c554ef5c45 --- /dev/null +++ b/sc/source/ui/inc/textimportoptions.hrc @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: retypepassdlg.src,v $ + * $Revision: 1.1.2.3 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 + +#define FL_CHOOSE_LANG 4 +#define RB_AUTOMATIC 5 +#define RB_CUSTOM 6 +#define LB_CUSTOM_LANG 7 +#define FL_OPTION 8 +#define BTN_CONVERT_DATE 9 diff --git a/sc/source/ui/inc/textimportoptions.hxx b/sc/source/ui/inc/textimportoptions.hxx new file mode 100644 index 000000000000..bbb2bf6ebf09 --- /dev/null +++ b/sc/source/ui/inc/textimportoptions.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: langbox.hxx,v $ + * $Revision: 1.4.242.1 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_UI_IMPORTOPTIONS_HXX +#define SC_UI_IMPORTOPTIONS_HXX + +#include "vcl/dialog.hxx" +#include "vcl/button.hxx" +#include "vcl/fixed.hxx" +#include "i18npool/lang.h" +#include "svx/langbox.hxx" + +class ScTextImportOptionsDlg : public ModalDialog +{ +public: + ScTextImportOptionsDlg(Window* pParent); + virtual ~ScTextImportOptionsDlg(); + + virtual short Execute(); + + LanguageType getLanguageType() const; + bool isDateConversionSet() const; + +private: + void init(); + +private: + OKButton maBtnOk; + CancelButton maBtnCancel; + HelpButton maBtnHelp; + + FixedLine maFlChooseLang; + + RadioButton maRbAutomatic; + RadioButton maRbCustom; + + SvxLanguageBox maLbCustomLang; + + FixedLine maFlOption; + + CheckBox maBtnConvertDate; + + DECL_LINK( OKHdl, OKButton* ); + + DECL_LINK( RadioHdl, RadioButton* ); +}; + + +#endif diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index 0fab38c8c1da..c8248b754708 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -188,8 +188,8 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() ) { // HTML import. - ::std::auto_ptr pDlg( - pFact->CreateScLangChooserDlg(NULL, RID_SCDLG_LANG_CHOOSER)); + ::std::auto_ptr pDlg( + pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS)); if (pDlg->Execute() == RET_OK) { diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index a7c981a11a95..144c60731970 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -277,7 +277,7 @@ LIB8OBJFILES = \ $(SLO)$/dapidata.obj \ $(SLO)$/crdlg.obj \ $(SLO)$/scuiasciiopt.obj \ - $(SLO)$/langchooser.obj \ + $(SLO)$/textimportoptions.obj \ $(SLO)$/scuiautofmt.obj \ $(SLO)$/dpgroupdlg.obj \ $(SLO)$/editfield.obj -- cgit v1.2.3 From dd257f983673e133cde535235d7abdfcb83fbed5 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 7 Aug 2009 14:57:02 -0400 Subject: * removed several files from version control because they are no longer present on the file system. * hg claims two files are modified in solenv, but taking a diff turns up nothing. Well, I'll commit them anyway. --- sc/source/ui/dbgui/langchooser.cxx | 120 ------------------------------------- sc/source/ui/dbgui/langchooser.src | 112 ---------------------------------- sc/source/ui/inc/langchooser.hrc | 42 ------------- sc/source/ui/inc/langchooser.hxx | 76 ----------------------- 4 files changed, 350 deletions(-) delete mode 100644 sc/source/ui/dbgui/langchooser.cxx delete mode 100644 sc/source/ui/dbgui/langchooser.src delete mode 100644 sc/source/ui/inc/langchooser.hrc delete mode 100644 sc/source/ui/inc/langchooser.hxx (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/langchooser.cxx b/sc/source/ui/dbgui/langchooser.cxx deleted file mode 100644 index 6640afc3bd3f..000000000000 --- a/sc/source/ui/dbgui/langchooser.cxx +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: langbox.hxx,v $ - * $Revision: 1.4.242.1 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - -#undef SC_DLLIMPLEMENTATION - -//------------------------------------------------------------------------ - -#include "langchooser.hxx" -#include "langchooser.hrc" - -#include "scresid.hxx" -#include "vcl/window.hxx" -#include "vcl/msgbox.hxx" -#include "vcl/svapp.hxx" - -ScLangChooserDlg::ScLangChooserDlg(Window* pParent) : - ModalDialog(pParent, ScResId(RID_SCDLG_LANG_CHOOSER)), - - maBtnOk(this, ScResId(BTN_OK)), - maBtnCancel(this, ScResId(BTN_CANCEL)), - maBtnHelp(this, ScResId(BTN_HELP)), - maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)), - maRbAutomatic(this, ScResId(RB_AUTOMATIC)), - maRbCustom(this, ScResId(RB_CUSTOM)), - maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)), - maFlOption(this, ScResId(FL_OPTION)), - maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE)) -{ - init(); -} - -ScLangChooserDlg::~ScLangChooserDlg() -{ -} - -short ScLangChooserDlg::Execute() -{ - return ModalDialog::Execute(); -} - -LanguageType ScLangChooserDlg::getLanguageType() const -{ - if (maRbAutomatic.IsChecked()) - return LANGUAGE_SYSTEM; - - return maLbCustomLang.GetSelectLanguage(); -} - -bool ScLangChooserDlg::isDateConversionSet() const -{ - return maBtnConvertDate.IsChecked(); -} - -void ScLangChooserDlg::init() -{ - Link aLink = LINK( this, ScLangChooserDlg, OKHdl ); - maBtnOk.SetClickHdl(aLink); - aLink = LINK( this, ScLangChooserDlg, RadioHdl ); - maRbAutomatic.SetClickHdl(aLink); - maRbCustom.SetClickHdl(aLink); - - maRbAutomatic.Check(true); - - maLbCustomLang.SetLanguageList( - LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false); - - LanguageType eLang = Application::GetSettings().GetLanguage(); - maLbCustomLang.SelectLanguage(eLang); - maLbCustomLang.Disable(); -} - -IMPL_LINK( ScLangChooserDlg, OKHdl, OKButton*, EMPTYARG ) -{ - EndDialog(RET_OK); - return 0; -} - -IMPL_LINK( ScLangChooserDlg, RadioHdl, RadioButton*, pBtn ) -{ - if (pBtn == &maRbAutomatic) - { - maLbCustomLang.Disable(); - } - else if (pBtn == &maRbCustom) - { - maLbCustomLang.Enable(); - } - return 0; -} - diff --git a/sc/source/ui/dbgui/langchooser.src b/sc/source/ui/dbgui/langchooser.src deleted file mode 100644 index 313084299aba..000000000000 --- a/sc/source/ui/dbgui/langchooser.src +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: retypepassdlg.src,v $ - * $Revision: 1.1.2.3 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "langchooser.hrc" - -ModalDialog RID_SCDLG_LANG_CHOOSER -{ - Text [ en-US ] = "Select Language" ; - Size = MAP_APPFONT ( 190 , 101 ) ; - Moveable = TRUE ; - Closeable = TRUE ; - OutputSize = TRUE ; - - OKButton BTN_OK - { - Pos = MAP_APPFONT ( 135, 6 ) ; - Size = MAP_APPFONT ( 50, 14 ) ; - DefButton = TRUE ; - }; - - CancelButton BTN_CANCEL - { - Pos = MAP_APPFONT ( 135, 23 ) ; - Size = MAP_APPFONT ( 50, 14 ) ; - }; - - HelpButton BTN_HELP - { - Pos = MAP_APPFONT ( 135, 43 ) ; - Size = MAP_APPFONT ( 50, 14 ) ; - }; - - FixedLine FL_CHOOSE_LANG - { - Pos = MAP_APPFONT( 6, 3 ) ; - Size = MAP_APPFONT( 125, 14 ) ; - - Text [ en-US ] = "Select the language to use for import" ; - }; - - RadioButton RB_AUTOMATIC - { - Pos = MAP_APPFONT( 12, 20 ) ; - Size = MAP_APPFONT( 50, 10 ) ; - TabStop = TRUE ; - - Text [ en-US ] = "Automatic" ; - }; - - RadioButton RB_CUSTOM - { - Pos = MAP_APPFONT( 12, 34 ) ; - Size = MAP_APPFONT( 50, 10 ) ; - TabStop = TRUE ; - - Text [ en-US ] = "Custom" ; - }; - - ListBox LB_CUSTOM_LANG - { - Pos = MAP_APPFONT( 20, 50 ) ; - Size = MAP_APPFONT( 100, 55 ) ; - TabStop = TRUE ; - DropDown = TRUE ; - Sort = TRUE ; - }; - - FixedLine FL_OPTION - { - Pos = MAP_APPFONT( 6, 70 ); - Size = MAP_APPFONT( 125, 14 ); - - Text [ en-US ] = "Options" ; - }; - - CheckBox BTN_CONVERT_DATE - { - Pos = MAP_APPFONT( 12, 86 ); - Size = MAP_APPFONT( 125, 10 ); - TabStop = TRUE ; - - Text [ en-US ] = "Detect special numbers (such as dates)." ; - }; -}; - diff --git a/sc/source/ui/inc/langchooser.hrc b/sc/source/ui/inc/langchooser.hrc deleted file mode 100644 index 93c554ef5c45..000000000000 --- a/sc/source/ui/inc/langchooser.hrc +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: retypepassdlg.src,v $ - * $Revision: 1.1.2.3 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include - -#define BTN_OK 1 -#define BTN_CANCEL 2 -#define BTN_HELP 3 - -#define FL_CHOOSE_LANG 4 -#define RB_AUTOMATIC 5 -#define RB_CUSTOM 6 -#define LB_CUSTOM_LANG 7 -#define FL_OPTION 8 -#define BTN_CONVERT_DATE 9 diff --git a/sc/source/ui/inc/langchooser.hxx b/sc/source/ui/inc/langchooser.hxx deleted file mode 100644 index 4ff849fc2bc0..000000000000 --- a/sc/source/ui/inc/langchooser.hxx +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: langbox.hxx,v $ - * $Revision: 1.4.242.1 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_UI_LANGCHOOSER_HXX -#define SC_UI_LANGCHOOSER_HXX - -#include "vcl/dialog.hxx" -#include "vcl/button.hxx" -#include "vcl/fixed.hxx" -#include "i18npool/lang.h" -#include "svx/langbox.hxx" - -class ScLangChooserDlg : public ModalDialog -{ -public: - ScLangChooserDlg(Window* pParent); - virtual ~ScLangChooserDlg(); - - virtual short Execute(); - - LanguageType getLanguageType() const; - bool isDateConversionSet() const; - -private: - void init(); - -private: - OKButton maBtnOk; - CancelButton maBtnCancel; - HelpButton maBtnHelp; - - FixedLine maFlChooseLang; - - RadioButton maRbAutomatic; - RadioButton maRbCustom; - - SvxLanguageBox maLbCustomLang; - - FixedLine maFlOption; - - CheckBox maBtnConvertDate; - - DECL_LINK( OKHdl, OKButton* ); - - DECL_LINK( RadioHdl, RadioButton* ); -}; - - -#endif -- cgit v1.2.3 From 4a0c47d0942624da509588fba2e0f72feb0e0a28 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 19 Jan 2010 21:24:13 -0500 Subject: koheicsvimport: remove warning on Windows. --- sc/source/ui/dbgui/csvruler.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index 90acf4a45358..7c8211e642ff 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -77,7 +77,8 @@ static void load_FixedWidthList(ScCsvSplits &aSplits) sSplits = String( sFixedWidthLists ); // String ends with a semi-colon so there is no 'int' after the last one. - for(int i=0;i Date: Wed, 20 Jan 2010 09:41:47 -0500 Subject: koheicsvimport: more static_cast's to keep MSVC compiler happy. --- sc/source/ui/dbgui/scuiasciiopt.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 2b244d378197..40fc410ec47c 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -384,7 +384,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() ); if( nCharSet >= 0 ) - aLbCharSet.SelectEntryPos( nCharSet ); + aLbCharSet.SelectEntryPos( static_cast(nCharSet) ); SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); @@ -425,7 +425,9 @@ ScImportAsciiDlg::~ScImportAsciiDlg() if (mbFileImport) save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), - aRbFixed.IsChecked(), aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos(), + aRbFixed.IsChecked(), + static_cast(aNfRow.GetValue()), + static_cast(aLbCharSet.GetSelectEntryPos()), static_cast(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } -- cgit v1.2.3 From 83ccb404e2829cba98cf0bb1290da489fd1f4c6c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 25 Jan 2010 15:57:05 -0500 Subject: koheicsvimport: #i108645# Store the dialog parameters only when the OK is pressed. --- sc/inc/scabstdlg.hxx | 1 + sc/source/ui/attrdlg/scdlgfact.cxx | 5 +++++ sc/source/ui/attrdlg/scdlgfact.hxx | 1 + sc/source/ui/dbgui/scuiasciiopt.cxx | 21 ++++++++++++++------- sc/source/ui/inc/scuiasciiopt.hxx | 1 + sc/source/ui/unoobj/filtuno.cxx | 1 + 6 files changed, 23 insertions(+), 7 deletions(-) (limited to 'sc/source') diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 98ec2b6b5a71..824761804349 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -69,6 +69,7 @@ class AbstractScImportAsciiDlg : public VclAbstractDialog //add for ScImportAsc public: virtual void GetOptions( ScAsciiOptions& rOpt ) = 0; virtual void SetTextToColumnsMode() = 0; + virtual void SaveParameters() = 0; }; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index d52a1f653c5c..66abfa79116e 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -198,6 +198,11 @@ void AbstractScImportAsciiDlg_Impl::SetTextToColumnsMode() pDlg->SetTextToColumnsMode(); } +void AbstractScImportAsciiDlg_Impl::SaveParameters() +{ + pDlg->SaveParameters(); +} + // AbstractScImportAsciiDlg_Impl end //AbstractScAutoFormatDlg_Impl begin diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index f9d06360d36c..36b7d89cceba 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -120,6 +120,7 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg //add for DECL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl, ScImportAsciiDlg) virtual void GetOptions( ScAsciiOptions& rOpt ); virtual void SetTextToColumnsMode(); + virtual void SaveParameters(); }; class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg //add for ScAutoFormatDlg diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 40fc410ec47c..244b2e785a72 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -422,13 +422,6 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, ScImportAsciiDlg::~ScImportAsciiDlg() { - if (mbFileImport) - save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), - aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), - aRbFixed.IsChecked(), - static_cast(aNfRow.GetValue()), - static_cast(aLbCharSet.GetSelectEntryPos()), - static_cast(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } @@ -542,6 +535,20 @@ void ScImportAsciiDlg::SetTextToColumnsMode() aCkbDetectNumber.Disable(); } +void ScImportAsciiDlg::SaveParameters() +{ + if (!mbFileImport) + // We save parameters only for file import. + return; + + save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), + aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), + aRbFixed.IsChecked(), + static_cast(aNfRow.GetValue()), + static_cast(aLbCharSet.GetSelectEntryPos()), + static_cast(aLbCustomLang.GetSelectLanguage()) ); +} + void ScImportAsciiDlg::SetSelectedCharSet() { meCharSet = aLbCharSet.GetSelectTextEncoding(); diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 82963d2904af..73dac06a3ed8 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -107,6 +107,7 @@ public: void GetOptions( ScAsciiOptions& rOpt ); void SetTextToColumnsMode(); + void SaveParameters(); private: /** Sets the selected char set data to meCharSet and mbCharSetSystem. */ diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index c8248b754708..90c86bca0cfb 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -179,6 +179,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) { ScAsciiOptions aOptions; pDlg->GetOptions( aOptions ); + pDlg->SaveParameters(); aFilterOptions = aOptions.WriteToString(); nRet = ui::dialogs::ExecutableDialogResults::OK; } -- cgit v1.2.3 From cddec3b38e83480ba3d16644fb944c83134e5946 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 10:59:04 -0500 Subject: koheicsvimport: #i108754# Call FreeResources() in the ctor & remove textimportoptions from LIB1OBJFILES. --- sc/source/ui/dbgui/makefile.mk | 3 +-- sc/source/ui/dbgui/textimportoptions.cxx | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk index bc08eb671fe0..88a1c9817d4c 100644 --- a/sc/source/ui/dbgui/makefile.mk +++ b/sc/source/ui/dbgui/makefile.mk @@ -117,8 +117,7 @@ LIB1OBJFILES = \ $(SLO)$/csvruler.obj \ $(SLO)$/csvgrid.obj \ $(SLO)$/csvtablebox.obj \ - $(SLO)$/asciiopt.obj \ - $(SLO)$/textimportoptions.obj + $(SLO)$/asciiopt.obj # --- Tagets ------------------------------------------------------- diff --git a/sc/source/ui/dbgui/textimportoptions.cxx b/sc/source/ui/dbgui/textimportoptions.cxx index d1e0f0949f64..be918d2a0fbd 100644 --- a/sc/source/ui/dbgui/textimportoptions.cxx +++ b/sc/source/ui/dbgui/textimportoptions.cxx @@ -56,6 +56,7 @@ ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) : maFlOption(this, ScResId(FL_OPTION)), maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE)) { + FreeResource(); init(); } -- cgit v1.2.3 From a381cd8160f05c527bdea880aabc3aea0ab1c6c9 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 11:31:38 -0500 Subject: koheicsvimport: #i108755# Moved the new check boxes to the left by 9 pixels. They should be aligned with the "Separated by" radio button. --- sc/source/ui/dbgui/asciiopt.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src index 57c338f0f70d..63e17f0f60f0 100644 --- a/sc/source/ui/dbgui/asciiopt.src +++ b/sc/source/ui/dbgui/asciiopt.src @@ -214,7 +214,7 @@ ModalDialog RID_SCDLG_ASCII CheckBox CB_QUOTED_AS_TEXT { - Pos = MAP_APPFONT ( 20 , 158 ) ; + Pos = MAP_APPFONT ( 12 , 158 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Quoted field as text" ; @@ -222,7 +222,7 @@ ModalDialog RID_SCDLG_ASCII CheckBox CB_DETECT_SPECIAL_NUMBER { - Pos = MAP_APPFONT ( 20 , 171 ) ; + Pos = MAP_APPFONT ( 12 , 171 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Detect special numbers" ; -- cgit v1.2.3 From 2ba4d305871115cbc710663c865af29beafa40bc Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 12:19:10 -0500 Subject: koheicsvimport: #i108754# Make sure that the html options dialog won't get launched on export. BTW, with this change, the character set dialog gets launched on html export instead.... :-/ --- sc/source/ui/unoobj/filtuno.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sc/source') diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index 90c86bca0cfb..96b3d13322be 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -186,7 +186,9 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) delete pDlg; delete pInStream; } - else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() ) + else if ( !bExport && + (aFilterString == ScDocShell::GetWebQueryFilterName() || + aFilterString == ScDocShell::GetHtmlFilterName()) ) { // HTML import. ::std::auto_ptr pDlg( -- cgit v1.2.3 From 1cc1a271e652ccfc6078217b071a95db19b8a8fd Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 13:14:30 -0500 Subject: koheicsvimport: #i108754# Follow up to my previous commit. We need to ignore the execute() call when exporting to an html document. My previous change caused the character set dialog to show up during html export, which was not correct. --- sc/source/ui/unoobj/filtuno.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index 96b3d13322be..59f48c51dffa 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -186,24 +186,25 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) delete pDlg; delete pInStream; } - else if ( !bExport && - (aFilterString == ScDocShell::GetWebQueryFilterName() || - aFilterString == ScDocShell::GetHtmlFilterName()) ) + else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() ) { - // HTML import. - ::std::auto_ptr pDlg( - pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS)); - - if (pDlg->Execute() == RET_OK) + if (!bExport) { - LanguageType eLang = pDlg->GetLanguageType(); - OUStringBuffer aBuf; + // HTML import. + ::std::auto_ptr pDlg( + pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS)); - aBuf.append(String::CreateFromInt32(static_cast(eLang))); - aBuf.append(sal_Unicode(' ')); - aBuf.append(pDlg->IsDateConversionSet() ? sal_Unicode('1') : sal_Unicode('0')); - aFilterOptions = aBuf.makeStringAndClear(); - nRet = ui::dialogs::ExecutableDialogResults::OK; + if (pDlg->Execute() == RET_OK) + { + LanguageType eLang = pDlg->GetLanguageType(); + OUStringBuffer aBuf; + + aBuf.append(String::CreateFromInt32(static_cast(eLang))); + aBuf.append(sal_Unicode(' ')); + aBuf.append(pDlg->IsDateConversionSet() ? sal_Unicode('1') : sal_Unicode('0')); + aFilterOptions = aBuf.makeStringAndClear(); + nRet = ui::dialogs::ExecutableDialogResults::OK; + } } } else -- cgit v1.2.3 From 0deefb5d0a6eec79a49602fa02d3dce46231a90a Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 13:21:33 -0500 Subject: koheicsvimport: #i108756# Fixed the tab order of controls in the CSV options dialog. --- sc/source/ui/dbgui/scuiasciiopt.cxx | 5 +++-- sc/source/ui/inc/scuiasciiopt.hxx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 244b2e785a72..a2cf247fda84 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -239,11 +239,12 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbAsOnce ( this, ScResId( CB_ASONCE) ), aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ), - aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), - aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), + aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), + aFlWidth ( this, ScResId( FL_WIDTH ) ), aFtType ( this, ScResId( FT_TYPE ) ), aLbType ( this, ScResId( LB_TYPE1 ) ), diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 73dac06a3ed8..1a8086488043 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -71,12 +71,12 @@ class ScImportAsciiDlg : public ModalDialog FixedLine aFlOtherOpt; - CheckBox aCkbQuotedAsText; - CheckBox aCkbDetectNumber; - FixedText aFtTextSep; ComboBox aCbTextSep; + CheckBox aCkbQuotedAsText; + CheckBox aCkbDetectNumber; + FixedLine aFlWidth; FixedText aFtType; ListBox aLbType; -- cgit v1.2.3 From 0760ed43d7d8e9c8f29e94eba8a954d54ad2ef80 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 9 Feb 2010 11:36:22 -0500 Subject: koheicsvimport: #i102141# Use the global 'use US English' option only when the Automatic language option is selected. --- sc/source/filter/rtf/eeimpars.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sc/source') diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index cb9ba0a5195f..0e1bc54ed4cd 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -152,9 +152,10 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu ScEEParseEntry* pE; if (!pFormatter) pFormatter = mpDoc->GetFormatTable(); - bool bNumbersEnglishUS = (pFormatter->GetLanguage() != LANGUAGE_ENGLISH_US); - if (bNumbersEnglishUS) + bool bNumbersEnglishUS = false; + if (pFormatter->GetLanguage() == LANGUAGE_SYSTEM) { + // Automatic language option selected. Check for the global 'use US English' option. SvxHtmlOptions aOpt; bNumbersEnglishUS = aOpt.IsNumbersEnglishUS(); } -- cgit v1.2.3