[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jan 16 16:45:08 UTC 2019
sc/source/ui/dbgui/imoptdlg.cxx | 7 ++++++-
sc/source/ui/docshell/docsh.cxx | 18 ++++++++++--------
sc/source/ui/inc/imoptdlg.hxx | 19 ++++---------------
3 files changed, 20 insertions(+), 24 deletions(-)
New commits:
commit 86501f577638b44042c35e601d13651992b64fd5
Author: Takeshi Abe <tabe at fixedpoint.jp>
AuthorDate: Mon Dec 24 02:46:29 2018 +0900
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Wed Jan 16 17:44:44 2019 +0100
tdf#106678 Implement CSV filter option's 8th token
... which decides whether number cells are stored as numbers
or quoted like strings, as documented in
<https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Token_8.2C_csv_export>
but long unimplemented.
Note that in this implementation the false value of the above token
is superseded and ignored if either "Fixed column width" (1st token)
or "Save cell content as shown" (9th token) option is on.
Change-Id: Ib4ff02a2be81a8590e1fc249725f02cd83e91118
Reviewed-on: https://gerrit.libreoffice.org/65604
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index a71eaee2feb3..efaf07d8585a 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -41,6 +41,7 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
eCharSet = RTL_TEXTENCODING_DONTKNOW;
bSaveAsShown = true; // "true" if not in string (after CSV import)
bQuoteAllText = false;
+ bSaveNumberAsSuch = true;
bSaveFormulas = false;
bRemoveSpace = false;
sal_Int32 nTokenCount = comphelper::string::getTokenCount(rStr, ',');
@@ -67,6 +68,8 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
// look at the same positions as in ScAsciiOptions
if ( nTokenCount >= 7 )
bQuoteAllText = rStr.getToken(6, ',') == "true";
+ if ( nTokenCount >= 8 )
+ bSaveNumberAsSuch = rStr.getToken(7, ',') == "true";
if ( nTokenCount >= 9 )
bSaveAsShown = rStr.getToken(8, ',') == "true";
if ( nTokenCount >= 10 )
@@ -89,7 +92,9 @@ OUString ScImportOptions::BuildString() const
// use the same string format as ScAsciiOptions:
",1,,0," + // first row, no column info, default language
OUString::boolean( bQuoteAllText ) + // same as "quoted field as text" in ScAsciiOptions
- ",true," + // "detect special numbers"
+ "," +
+ OUString::boolean( bSaveNumberAsSuch ) + // "save number as such": not in ScAsciiOptions
+ "," +
OUString::boolean( bSaveAsShown ) + // "save as shown": not in ScAsciiOptions
"," +
OUString::boolean( bSaveFormulas ) + // "save formulas": not in ScAsciiOptions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 7f45f9964084..7dbef7be7089 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1942,6 +1942,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
sal_Unicode cStrDelim = rAsciiOpt.nTextSepCode;
rtl_TextEncoding eCharSet = rAsciiOpt.eCharSet;
bool bFixedWidth = rAsciiOpt.bFixedWidth;
+ bool bSaveNumberAsSuch = rAsciiOpt.bSaveNumberAsSuch;
bool bSaveAsShown = rAsciiOpt.bSaveAsShown;
bool bShowFormulas = rAsciiOpt.bSaveFormulas;
@@ -2072,6 +2073,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
pProtAttr->GetHideFormula() ) )
eType = CELLTYPE_NONE; // hide
}
+ bool bForceQuotes = false;
bool bString;
switch ( eType )
{
@@ -2104,7 +2106,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
else
{
ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, &m_aDocument);
- bString = false;
+ bString = bForceQuotes = !bSaveNumberAsSuch;
}
}
else
@@ -2154,7 +2156,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
else
{
ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, &m_aDocument);
- bString = false;
+ bString = bForceQuotes = !bSaveNumberAsSuch;
}
}
break;
@@ -2197,10 +2199,10 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
escapeTextSep<OUString, OUStringBuffer>(
nPos, OUString(cStrDelim), aUniString);
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
write_uInt16s_FromOUString(rStream, aUniString);
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
}
else
@@ -2235,10 +2237,10 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
nPos, aStrDelimDecoded, aStrDec);
// write byte re-encoded
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
}
else
@@ -2254,11 +2256,11 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
nPos, aStrDelimEncoded, aStrEnc);
// write byte encoded
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteBytes(
aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
rStream.WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());
- if ( bNeedQuotes )
+ if ( bNeedQuotes || bForceQuotes )
rStream.WriteBytes(
aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
}
diff --git a/sc/source/ui/inc/imoptdlg.hxx b/sc/source/ui/inc/imoptdlg.hxx
index 1f8b946fac7e..bac941c2a377 100644
--- a/sc/source/ui/inc/imoptdlg.hxx
+++ b/sc/source/ui/inc/imoptdlg.hxx
@@ -31,23 +31,11 @@ public:
ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc )
: nFieldSepCode(nFieldSep), nTextSepCode(nTextSep),
- bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false), bSaveFormulas(false),
- bRemoveSpace(false)
+ bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false),
+ bSaveNumberAsSuch(true), bSaveFormulas(false), bRemoveSpace(false)
{ SetTextEncoding( nEnc ); }
- ScImportOptions& operator=( const ScImportOptions& rCpy )
- {
- nFieldSepCode = rCpy.nFieldSepCode;
- nTextSepCode = rCpy.nTextSepCode;
- aStrFont = rCpy.aStrFont;
- eCharSet = rCpy.eCharSet;
- bFixedWidth = rCpy.bFixedWidth;
- bSaveAsShown = rCpy.bSaveAsShown;
- bQuoteAllText = rCpy.bQuoteAllText;
- bSaveFormulas = rCpy.bSaveFormulas;
- bRemoveSpace = rCpy.bRemoveSpace;
- return *this;
- }
+ ScImportOptions& operator=( const ScImportOptions& rCpy ) = default;
OUString BuildString() const;
@@ -60,6 +48,7 @@ public:
bool bFixedWidth;
bool bSaveAsShown;
bool bQuoteAllText;
+ bool bSaveNumberAsSuch;
bool bSaveFormulas;
bool bRemoveSpace;
};
More information about the Libreoffice-commits
mailing list