diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-05-18 15:28:50 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-05-18 15:28:50 +0000 |
commit | 28ba39eaf96c2c4d2c0233a0cfdd18c1573bd2e6 (patch) | |
tree | 5a4c6357b61dd09b837efe1a6f79c5b7bf25c535 /sc/inc | |
parent | d89a147ffff3d999f5b378c27a02a5fb7e77fdd2 (diff) |
CWS-TOOLING: integrate CWS calcmultiline
2009-05-13 18:05:10 +0200 nn r271868 : CWS-TOOLING: rebase CWS calcmultiline to trunk@271830 (milestone: DEV300:m48)
2009-03-15 00:59:24 +0100 erack r269502 : #i100205# SYLK import/export: treat embedded double quotes and semicolons correctly; changes ID;PSCALC3 to ID;PCALCOOO32 due to incompatibility
2009-03-10 17:54:33 +0100 er r269286 : #i35913# multiline (newlines) as formula results; contributed by William S Fulton <wsfulton>
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/cell.hxx | 3 | ||||
-rw-r--r-- | sc/inc/editutil.hxx | 5 | ||||
-rw-r--r-- | sc/inc/formularesult.hxx | 39 |
3 files changed, 44 insertions, 3 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index b8a228ddfd09..2d4bba295547 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -485,6 +485,9 @@ public: inline BOOL IsHyperLinkCell() const { return pCode && pCode->IsHyperLink(); } EditTextObject* CreateURLObject() ; void GetURLResult( String& rURL, String& rCellText ); + + /** Determines whether or not the result string contains more than one paragraph */ + bool IsMultilineResult(); }; // Iterator fuer Referenzen in einer Formelzelle diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 3e1573ac7c89..b61bdf72ef7b 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -63,8 +63,13 @@ class ScEditUtil public: static String ModifyDelimiters( const String& rOld ); + + /// Retrieves string with paragraphs delimited by spaces static String GetSpaceDelimitedString( const EditEngine& rEngine ); + /// Retrieves string with paragraphs delimited by new lines ('\n'). + static String GetMultilineString( const EditEngine& rEngine ); + public: ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ, const Point& rScrPosPixel, diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx index e227dd1b7995..c8f50a92cd0b 100644 --- a/sc/inc/formularesult.hxx +++ b/sc/inc/formularesult.hxx @@ -38,6 +38,11 @@ and memory consumption. */ class ScFormulaResult { + typedef unsigned char Multiline; + static const Multiline MULTILINE_UNKNOWN = 0; + static const Multiline MULTILINE_FALSE = 1; + static const Multiline MULTILINE_TRUE = 2; + union { double mfValue; // double result direct for performance and memory consumption @@ -47,6 +52,7 @@ class ScFormulaResult bool mbToken :1; // whether content of union is a token bool mbEmpty :1; // empty cell result bool mbEmptyDisplayedAsString :1; // only if mbEmpty + Multiline meMultiline :2; // result is multiline /** Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults prior to assigning other types */ @@ -69,12 +75,14 @@ public: /** Effectively type svUnknown. */ ScFormulaResult() : mpToken(NULL), mnError(0), mbToken(true), - mbEmpty(false), mbEmptyDisplayedAsString(false) {} + mbEmpty(false), mbEmptyDisplayedAsString(false), + meMultiline(MULTILINE_UNKNOWN) {} ScFormulaResult( const ScFormulaResult & r ) : mnError( r.mnError), mbToken( r.mbToken), mbEmpty( r.mbEmpty), - mbEmptyDisplayedAsString( r.mbEmptyDisplayedAsString) + mbEmptyDisplayedAsString( r.mbEmptyDisplayedAsString), + meMultiline( r.meMultiline) { if (mbToken) { @@ -99,7 +107,8 @@ public: /** Same comments as for SetToken() apply! */ explicit ScFormulaResult( const formula::FormulaToken* p ) : mnError(0), mbToken(false), - mbEmpty(false), mbEmptyDisplayedAsString(false) + mbEmpty(false), mbEmptyDisplayedAsString(false), + meMultiline(MULTILINE_UNKNOWN) { SetToken( p); } @@ -153,6 +162,10 @@ public: details instead. */ inline bool IsValue() const; + /** Determines whether or not the result is a string containing more than + one paragraph */ + inline bool IsMultiline() const; + /** Get error code if set or GetCellResultType() is formula::svError or svUnknown, else 0. */ inline USHORT GetResultError() const; @@ -211,6 +224,7 @@ inline void ScFormulaResult::ResetToDefaults() mnError = 0; mbEmpty = false; mbEmptyDisplayedAsString = false; + meMultiline = MULTILINE_UNKNOWN; } @@ -232,17 +246,20 @@ inline void ScFormulaResult::ResolveToken( const formula::FormulaToken * p ) mbToken = false; // set in case mnError is 0 now, which shouldn't happen but ... mfValue = 0.0; + meMultiline = MULTILINE_FALSE; break; case formula::svEmptyCell: mbEmpty = true; mbEmptyDisplayedAsString = static_cast<const ScEmptyCellToken*>(p)->IsDisplayedAsString(); p->DecRef(); mbToken = false; + meMultiline = MULTILINE_FALSE; break; case formula::svDouble: mfValue = p->GetDouble(); p->DecRef(); mbToken = false; + meMultiline = MULTILINE_FALSE; break; default: mpToken = p; @@ -270,6 +287,7 @@ inline void ScFormulaResult::Assign( const ScFormulaResult & r ) mbToken = false; mbEmpty = true; mbEmptyDisplayedAsString = r.mbEmptyDisplayedAsString; + meMultiline = r.meMultiline; } else if (r.mbToken) { @@ -352,6 +370,7 @@ inline void ScFormulaResult::SetDouble( double f ) mpToken->DecRef(); mfValue = f; mbToken = false; + meMultiline = MULTILINE_FALSE; } } @@ -404,6 +423,19 @@ inline bool ScFormulaResult::IsValue() const return sv == formula::svDouble || sv == formula::svError || sv == formula::svEmptyCell; } +inline bool ScFormulaResult::IsMultiline() const +{ + if (meMultiline == MULTILINE_UNKNOWN) + { + const String& rStr = GetString(); + if (rStr.Len() && rStr.Search( _LF ) != STRING_NOTFOUND) + const_cast<ScFormulaResult*>(this)->meMultiline = MULTILINE_TRUE; + else + const_cast<ScFormulaResult*>(this)->meMultiline = MULTILINE_FALSE; + } + return meMultiline == MULTILINE_TRUE; +} + inline USHORT ScFormulaResult::GetResultError() const { @@ -537,6 +569,7 @@ inline void ScFormulaResult::SetHybridDouble( double f ) { mfValue = f; mbToken = false; + meMultiline = MULTILINE_FALSE; } } |