diff options
-rw-r--r-- | sc/source/ui/dbgui/imoptdlg.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/inc/imoptdlg.hxx | 19 |
3 files changed, 20 insertions, 24 deletions
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; }; |