summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/docsh.cxx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-12-24 02:46:29 +0900
committerEike Rathke <erack@redhat.com>2019-01-16 17:44:44 +0100
commit86501f577638b44042c35e601d13651992b64fd5 (patch)
tree15937c639c2104d12474b69aaee7dbb7537d50cf /sc/source/ui/docshell/docsh.cxx
parent2cf3b1709203931dc6defd5af67e3feecda4895a (diff)
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@redhat.com>
Diffstat (limited to 'sc/source/ui/docshell/docsh.cxx')
-rw-r--r--sc/source/ui/docshell/docsh.cxx18
1 files changed, 10 insertions, 8 deletions
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());
}