[Libreoffice-commits] core.git: sc/source
Maxim Monastirsky
momonasmon at gmail.com
Thu Dec 19 06:17:46 PST 2013
sc/source/ui/dbgui/scuiasciiopt.cxx | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
New commits:
commit a4b5fdc2942d45c5c8aad5d77ca3346bd0862ec3
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Thu Dec 19 15:58:21 2013 +0200
Prefill correct settings for csv and tsv
Change-Id: I21f3109530bc79c6ca1dcc247da987ee4795d086
Reviewed-on: https://gerrit.libreoffice.org/7142
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 87aa28c..1cd49d6 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -288,6 +288,16 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,OUString aDatName,
SetText( aName );
}
+ // To be able to prefill the correct values based on the file extension
+ bool bIsCSV = false;
+ bool bIsTSV = false;
+
+ OUString aExtWithDot = aDatName.copy(aDatName.getLength() - 4); // All handled extensions (csv, tsv, tab) have length of 3
+ if ( aExtWithDot.equalsIgnoreAsciiCase(".tsv") || aExtWithDot.equalsIgnoreAsciiCase(".tab") )
+ bIsTSV = true;
+ else if ( aExtWithDot.equalsIgnoreAsciiCase(".csv") )
+ bIsCSV = true;
+
// Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
OUString sFieldSeparators(",;\t");
OUString sTextSeparators(mcTextSep);
@@ -303,19 +313,24 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,OUString aDatName,
// load from saved settings
maFieldSeparators = OUString(sFieldSeparators);
- if( bMergeDelimiters )
+ if( bMergeDelimiters && !bIsTSV )
pCkbAsOnce->Check();
if (bQuotedFieldAsText)
pCkbQuotedAsText->Check();
if (bDetectSpecialNum)
pCkbDetectNumber->Check();
- if( bFixedWidth )
+ if( bFixedWidth && !bIsTSV )
pRbFixed->Check();
- if( nFromRow != 1 )
+ if( nFromRow != 1 && !bIsTSV )
pNfRow->SetValue( nFromRow );
- // Set Separators in the dialog from maFieldSeparators (empty are not set)
- SetSeparators();
+ if ( bIsTSV )
+ pCkbTab->Check();
+ else
+ SetSeparators(); // Set Separators in the dialog from maFieldSeparators (empty are not set)
+
+ if ( bIsCSV )
+ pCkbComma->Check();
// Get Separators from the dialog (empty are set from default)
maFieldSeparators = GetSeparators();
@@ -574,7 +589,7 @@ void ScImportAsciiDlg::SetSeparators()
case ' ': pCkbSpace->Check(); break;
default:
pCkbOther->Check();
- pEdOther->SetText( pEdOther->GetText() + OUString( aSep[i] ) );
+ pEdOther->SetText( pEdOther->GetText() + OUString( aSep[i] ) );
}
}
}
More information about the Libreoffice-commits
mailing list