diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/inc/cell.hxx DEV300_m16/sc/inc/cell.hxx --- DEV300_m16-original/sc/inc/cell.hxx 2008-04-10 19:15:24.000000000 +0100 +++ DEV300_m16/sc/inc/cell.hxx 2008-08-12 19:28:39.000000000 +0100 @@ -428,6 +428,9 @@ 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 -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/inc/editutil.hxx DEV300_m16/sc/inc/editutil.hxx --- DEV300_m16-original/sc/inc/editutil.hxx 2008-04-10 19:31:47.000000000 +0100 +++ DEV300_m16/sc/inc/editutil.hxx 2008-08-01 21:11:36.000000000 +0100 @@ -63,8 +63,13 @@ 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 -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/inc/formularesult.hxx DEV300_m16/sc/inc/formularesult.hxx --- DEV300_m16-original/sc/inc/formularesult.hxx 2008-04-10 19:34:58.000000000 +0100 +++ DEV300_m16/sc/inc/formularesult.hxx 2008-08-12 23:40:21.000000000 +0100 @@ -38,6 +38,12 @@ and memory consumption. */ class ScFormulaResult { + enum Multiline + { + MULTILINE_UNKNOWN = 0, + MULTILINE_FALSE, + MULTILINE_TRUE + }; union { double mfValue; // double result direct for performance and memory consumption @@ -47,6 +53,7 @@ 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 +76,14 @@ /** 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 +108,8 @@ /** Same comments as for SetToken() apply! */ explicit ScFormulaResult( const ScToken* p ) : mnError(0), mbToken(false), - mbEmpty(false), mbEmptyDisplayedAsString(false) + mbEmpty(false), mbEmptyDisplayedAsString(false), + meMultiline(MULTILINE_UNKNOWN) { SetToken( p); } @@ -153,6 +163,10 @@ details instead. */ inline bool IsValue() const; + /** Determines whether or not the result is a string containing more than + one paragraph */ + inline bool IsMultiline(); + /** Get error code if set or GetCellResultType() is svError or svUnknown, else 0. */ inline USHORT GetResultError() const; @@ -211,6 +225,7 @@ mnError = 0; mbEmpty = false; mbEmptyDisplayedAsString = false; + meMultiline = MULTILINE_UNKNOWN; } @@ -232,10 +247,12 @@ mbToken = false; // set in case mnError is 0 now, which shouldn't happen but ... mfValue = 0.0; + meMultiline = MULTILINE_FALSE; break; case svEmptyCell: mbEmpty = true; mbEmptyDisplayedAsString = static_cast(p)->IsDisplayedAsString(); + meMultiline = MULTILINE_FALSE; p->DecRef(); mbToken = false; break; @@ -243,6 +260,7 @@ mfValue = p->GetDouble(); p->DecRef(); mbToken = false; + meMultiline = MULTILINE_FALSE; break; default: mpToken = p; @@ -270,6 +288,7 @@ mbToken = false; mbEmpty = true; mbEmptyDisplayedAsString = r.mbEmptyDisplayedAsString; + meMultiline = r.meMultiline; } else if (r.mbToken) { @@ -352,6 +371,7 @@ mpToken->DecRef(); mfValue = f; mbToken = false; + meMultiline = MULTILINE_FALSE; } } @@ -404,6 +424,19 @@ return sv == svDouble || sv == svError || sv == svEmptyCell; } +inline bool ScFormulaResult::IsMultiline() +{ + if (meMultiline == MULTILINE_UNKNOWN) + { + const String& rStr = GetString(); + if (rStr.Len() && rStr.Search( _LF ) != STRING_NOTFOUND) + meMultiline = MULTILINE_TRUE; + else + meMultiline = MULTILINE_FALSE; + } + return meMultiline == MULTILINE_TRUE; +} + inline USHORT ScFormulaResult::GetResultError() const { @@ -537,6 +570,7 @@ { mfValue = f; mbToken = false; + meMultiline = MULTILINE_FALSE; } } diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/data/cell2.cxx DEV300_m16/sc/source/core/data/cell2.cxx --- DEV300_m16-original/sc/source/core/data/cell2.cxx 2008-05-14 10:50:24.000000000 +0100 +++ DEV300_m16/sc/source/core/data/cell2.cxx 2008-08-01 21:11:36.000000000 +0100 @@ -162,7 +162,7 @@ // auch Text von URL-Feldern, Doc-Engine ist eine ScFieldEditEngine EditEngine& rEngine = pDoc->GetEditEngine(); rEngine.SetText( *pData ); - rString = ScEditUtil::GetSpaceDelimitedString(rEngine); // space between paragraphs + rString = ScEditUtil::GetMultilineString(rEngine); // string with line separators between paragraphs // kurze Strings fuer Formeln merken if ( rString.Len() < MAXSTRLEN ) ((ScEditCell*)this)->pString = new String( rString ); //! non-const diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/data/cell.cxx DEV300_m16/sc/source/core/data/cell.cxx --- DEV300_m16-original/sc/source/core/data/cell.cxx 2008-05-14 10:50:09.000000000 +0100 +++ DEV300_m16/sc/source/core/data/cell.cxx 2008-08-12 22:03:13.000000000 +0100 @@ -1832,6 +1832,13 @@ } } +BOOL ScFormulaCell::IsMultilineResult() +{ + if (!IsValue()) + return aResult.IsMultiline(); + return false; +} + EditTextObject* ScFormulaCell::CreateURLObject() { String aCellText; diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/data/column2.cxx DEV300_m16/sc/source/core/data/column2.cxx --- DEV300_m16-original/sc/source/core/data/column2.cxx 2008-04-10 20:20:05.000000000 +0100 +++ DEV300_m16/sc/source/core/data/column2.cxx 2008-08-01 21:11:36.000000000 +0100 @@ -793,9 +793,12 @@ } BOOL bAddMargin = TRUE; - BOOL bEditEngine = ( pCell->GetCellType() == CELLTYPE_EDIT || + CellType eCellType = pCell->GetCellType(); + + BOOL bEditEngine = ( eCellType == CELLTYPE_EDIT || eOrient == SVX_ORIENTATION_STACKED || - IsAmbiguousScript( nScript ) ); + IsAmbiguousScript( nScript ) || + ((eCellType == CELLTYPE_FORMULA) && ((ScFormulaCell*)pCell)->IsMultilineResult()) ); if (!bEditEngine) // direkte Ausgabe { diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/data/column3.cxx DEV300_m16/sc/source/core/data/column3.cxx --- DEV300_m16-original/sc/source/core/data/column3.cxx 2008-04-10 20:20:27.000000000 +0100 +++ DEV300_m16/sc/source/core/data/column3.cxx 2008-08-14 07:36:16.000000000 +0100 @@ -887,8 +887,17 @@ String aString; pForm->GetString(aString); if ( aString.Len() ) - pNew = new ScStringCell(aString); - // #33224# LeerStrings nicht kopieren + { + if ( pForm->IsMultilineResult() ) + { + pNew = new ScEditCell( aString, pDestDoc ); + } + else + { + pNew = new ScStringCell(aString); + // #33224# LeerStrings nicht kopieren + } + } } } if ( pNew && pSource->GetNotePtr() && ( nFlags & IDF_NOTE ) ) diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/data/column.cxx DEV300_m16/sc/source/core/data/column.cxx --- DEV300_m16-original/sc/source/core/data/column.cxx 2008-04-10 20:19:38.000000000 +0100 +++ DEV300_m16/sc/source/core/data/column.cxx 2008-08-01 21:11:36.000000000 +0100 @@ -2264,8 +2264,10 @@ while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : FALSE ) { ScBaseCell* pCell = pItems[nIndex].pCell; - if ( pCell->GetCellType() == CELLTYPE_EDIT || - IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab, pCell) ) ) + CellType eCellType = pCell->GetCellType(); + if ( eCellType == CELLTYPE_EDIT || + IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab, pCell) ) || + ((eCellType == CELLTYPE_FORMULA) && ((ScFormulaCell*)pCell)->IsMultilineResult()) ) { rFirst = nRow; return TRUE; diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/core/tool/editutil.cxx DEV300_m16/sc/source/core/tool/editutil.cxx --- DEV300_m16-original/sc/source/core/tool/editutil.cxx 2008-04-10 20:52:15.000000000 +0100 +++ DEV300_m16/sc/source/core/tool/editutil.cxx 2008-08-01 21:11:36.000000000 +0100 @@ -82,6 +82,19 @@ return aRet; } +String ScEditUtil::GetMultilineString( const EditEngine& rEngine ) +{ + String aRet; + USHORT nParCount = rEngine.GetParagraphCount(); + for (USHORT nPar=0; nPar 0) + aRet += '\n'; + aRet += rEngine.GetText( nPar ); + } + return aRet; +} + String ScEditUtil::GetSpaceDelimitedString( const EditEngine& rEngine ) { String aRet; diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/filter/excel/xestyle.cxx DEV300_m16/sc/source/filter/excel/xestyle.cxx --- DEV300_m16-original/sc/source/filter/excel/xestyle.cxx 2008-04-10 21:14:39.000000000 +0100 +++ DEV300_m16/sc/source/filter/excel/xestyle.cxx 2008-08-12 07:11:25.000000000 +0100 @@ -1965,9 +1965,9 @@ return InsertCellXF( pPattern, nScript, NUMBERFORMAT_ENTRY_NOT_FOUND, nForceXclFont, bForceLineBreak ); } -sal_uInt32 XclExpXFBuffer::InsertWithNumFmt( const ScPatternAttr* pPattern, sal_Int16 nScript, ULONG nForceScNumFmt ) +sal_uInt32 XclExpXFBuffer::InsertWithNumFmt( const ScPatternAttr* pPattern, sal_Int16 nScript, ULONG nForceScNumFmt, bool bForceLineBreak ) { - return InsertCellXF( pPattern, nScript, nForceScNumFmt, EXC_FONT_NOTFOUND, false ); + return InsertCellXF( pPattern, nScript, nForceScNumFmt, EXC_FONT_NOTFOUND, bForceLineBreak ); } sal_uInt32 XclExpXFBuffer::InsertStyle( const SfxStyleSheetBase* pStyleSheet ) diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/filter/excel/xetable.cxx DEV300_m16/sc/source/filter/excel/xetable.cxx --- DEV300_m16-original/sc/source/filter/excel/xetable.cxx 2008-04-10 21:15:04.000000000 +0100 +++ DEV300_m16/sc/source/filter/excel/xetable.cxx 2008-08-12 07:14:55.000000000 +0100 @@ -760,13 +760,15 @@ // #i41420# find script type according to result type (always latin for numeric results) sal_Int16 nScript = ApiScriptType::LATIN; + bool bForceLineBreak = false; if( nFormatType == NUMBERFORMAT_TEXT ) { String aResult; mrScFmlaCell.GetString( aResult ); + bForceLineBreak = mrScFmlaCell.IsMultilineResult(); nScript = XclExpStringHelper::GetLeadingScriptType( rRoot, aResult ); } - SetXFId( rRoot.GetXFBuffer().InsertWithNumFmt( pPattern, nScript, nAltScNumFmt ) ); + SetXFId( rRoot.GetXFBuffer().InsertWithNumFmt( pPattern, nScript, nAltScNumFmt, bForceLineBreak ) ); } // *** Convert the formula token array *** -------------------------------- diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/filter/inc/xestyle.hxx DEV300_m16/sc/source/filter/inc/xestyle.hxx --- DEV300_m16-original/sc/source/filter/inc/xestyle.hxx 2008-04-10 21:46:20.000000000 +0100 +++ DEV300_m16/sc/source/filter/inc/xestyle.hxx 2008-08-12 07:11:25.000000000 +0100 @@ -617,10 +617,13 @@ @param nXFFlags Additional flags allowing to control the creation of an XF. @param nForceScNumFmt The number format to be exported, e.g. formula result type. This format will always overwrite the cell's number format. + @param bForceLineBreak true = Set line break flag unconditionally. + This is required for cells that contain multi-line text. @return A unique XF record ID. */ sal_uInt32 InsertWithNumFmt( const ScPatternAttr* pPattern, sal_Int16 nScript, - ULONG nForceScNumFmt ); + ULONG nForceScNumFmt, + bool bForceLineBreak ); /** Inserts the passed cell style. Creates a style XF record and a STYLE record. @return A unique XF record ID. */ sal_uInt32 InsertStyle( const SfxStyleSheetBase* pStyleSheet ); diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/ui/app/transobj.cxx DEV300_m16/sc/source/ui/app/transobj.cxx --- DEV300_m16-original/sc/source/ui/app/transobj.cxx 2008-04-18 12:34:38.000000000 +0100 +++ DEV300_m16/sc/source/ui/app/transobj.cxx 2008-08-14 19:21:46.000000000 +0100 @@ -815,7 +815,10 @@ { String aStr; pFCell->GetString(aStr); - pNew = new ScStringCell( aStr ); + if ( pFCell->IsMultilineResult() ) + pNew = new ScEditCell( aStr, pDestDoc ); + else + pNew = new ScStringCell( aStr ); } pDestDoc->PutCell( nCol,nRow,nDestTab, pNew ); diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/ui/docshell/impex.cxx DEV300_m16/sc/source/ui/docshell/impex.cxx --- DEV300_m16-original/sc/source/ui/docshell/impex.cxx 2008-05-14 10:57:21.000000000 +0100 +++ DEV300_m16/sc/source/ui/docshell/impex.cxx 2008-08-17 13:26:07.000000000 +0100 @@ -1606,6 +1606,7 @@ BOOL ScImportExport::Doc2Sylk( SvStream& rStrm ) { + const String SYLK_LF = String::CreateFromAscii("\x1b :"); SCCOL nCol; SCROW nRow; SCCOL nStartCol = aRange.aStart.Col(); @@ -1660,6 +1661,7 @@ case CELLTYPE_EDIT: hasstring: pDoc->GetString( nCol, nRow, aRange.aStart.Tab(), aCellStr ); + aCellStr.SearchAndReplaceAll( _LF, SYLK_LF ); aBufStr.AssignAscii(RTL_CONSTASCII_STRINGPARAM( "C;X" )); aBufStr += String::CreateFromInt32( c ); diff -Naur --exclude='unxlngi6.*' --exclude='*.swp' DEV300_m16-original/sc/source/ui/view/output2.cxx DEV300_m16/sc/source/ui/view/output2.cxx --- DEV300_m16-original/sc/source/ui/view/output2.cxx 2008-04-11 02:34:35.000000000 +0100 +++ DEV300_m16/sc/source/ui/view/output2.cxx 2008-08-01 21:11:36.000000000 +0100 @@ -1427,11 +1427,13 @@ } if (bDoCell && !bNeedEdit) { - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + BOOL bFormulaCell = (pCell->GetCellType() == CELLTYPE_FORMULA ); + if ( bFormulaCell ) lcl_CreateInterpretProgress( bProgress, pDoc, (ScFormulaCell*)pCell ); if ( aVars.SetText(pCell) ) pOldPattern = NULL; - bNeedEdit = aVars.HasEditCharacters(); + bNeedEdit = aVars.HasEditCharacters() || + (bFormulaCell && ((ScFormulaCell*)pCell)->IsMultilineResult()); } if (bDoCell && !bNeedEdit) {