Index: sc/source/core/tool/interpr1.cxx =================================================================== RCS file: /cvs/sc/sc/source/core/tool/interpr1.cxx,v retrieving revision 1.40 diff -u -r1.40 interpr1.cxx --- sc/source/core/tool/interpr1.cxx 4 Aug 2006 11:34:02 -0000 1.40 +++ sc/source/core/tool/interpr1.cxx 26 Oct 2006 13:15:58 -0000 @@ -81,6 +81,7 @@ ScErrorStack* ScInterpreter::pGlobalErrorStack = NULL; BOOL ScInterpreter::bGlobalStackInUse = FALSE; +SvxCellHorJustify ContentJust(const String& aStr); //----------------------------------------------------------------------------- // Funktionen @@ -1748,6 +1749,11 @@ switch( pJustAttr->GetValue() ) { case SVX_HOR_JUSTIFY_STANDARD: + if (ContentJust(pCell->GetStringData()) == SVX_HOR_JUSTIFY_RIGHT) + aResult = '"'; + else + aResult = '\''; + break; case SVX_HOR_JUSTIFY_LEFT: case SVX_HOR_JUSTIFY_BLOCK: aResult = '\''; break; case SVX_HOR_JUSTIFY_CENTER: aResult = '^'; break; Index: sc/source/filter/excel/excel.cxx =================================================================== RCS file: /cvs/sc/sc/source/filter/excel/excel.cxx,v retrieving revision 1.24 diff -u -r1.24 excel.cxx --- sc/source/filter/excel/excel.cxx 21 Jul 2006 11:47:43 -0000 1.24 +++ sc/source/filter/excel/excel.cxx 26 Oct 2006 13:15:59 -0000 @@ -81,7 +81,7 @@ #include "imp_op.hxx" #include "excimp8.hxx" #include "exp_op.hxx" - +#include FltError ScImportExcel( SfxMedium& r, ScDocument* p ) { @@ -191,8 +191,24 @@ } eRet = xFilter.get() ? xFilter->Read() : eERR_INTERN; + /* For i37905: : + During import, create an array of text cells whose text dir should be modified to LTR. This is necessary if: + a) there is Hebrew in the text + b) the first letter of the text is not Hebrew + Here we can go through the textCells, and if the text direction is "ENVIRONMENT" set it to LTR */ + for( ScAddress* pAddr = xFilter->CellIDList.First(); pAddr; pAddr = xFilter->CellIDList.Next() ) + { + const SvxFrameDirectionItem* pItem = static_cast< const SvxFrameDirectionItem* >( + pDocument->GetAttr( pAddr->Col(), pAddr->Row(), pAddr->Tab(), ATTR_WRITINGDIR ) ); + SvxFrameDirection eCellDir = (SvxFrameDirection)pItem->GetValue(); + if (eCellDir == FRMDIR_ENVIRONMENT) + pDocument->ApplyAttr( pAddr->Col(), pAddr->Row(), pAddr->Tab(), + SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, ATTR_WRITINGDIR ) ); + } + } + return eRet; } Index: sc/source/filter/excel/excimp8.cxx =================================================================== RCS file: /cvs/sc/sc/source/filter/excel/excimp8.cxx,v retrieving revision 1.114 diff -u -r1.114 excimp8.cxx --- sc/source/filter/excel/excimp8.cxx 25 Jul 2006 09:56:55 -0000 1.114 +++ sc/source/filter/excel/excimp8.cxx 26 Oct 2006 13:15:59 -0000 @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -283,10 +284,35 @@ ScAddress aScPos( ScAddress::UNINITIALIZED ); if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) ) { - GetXFRangeBuffer().SetXF( aScPos, nXF ); - pColRowBuff->Used( aScPos ); - if( ScBaseCell* pCell = GetSst().CreateCell( nSst, nXF ) ) - GetDoc().PutCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pCell ); + GetXFRangeBuffer().SetXF( aScPos, nXF ); + pColRowBuff->Used( aScPos ); + if( ScBaseCell* pCell = GetSst().CreateCell( nSst, nXF ) ) + { + GetDoc().PutCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pCell ); + + // For i37905 : + // If a) text contains Hebrew b) first letter is not Hebrew, + // add the cell position to a list. + // Check after import if text dir is "ENVIRONMENT". If so, change its direction to LTR. + + #define IS_HEBREW(x) (x >= 0x590) && (x <= 0x5FF) + + const sal_Unicode *p = pCell->GetStringData().GetBuffer(); + BOOL bFirstCharHebrew = IS_HEBREW(*p); + BOOL bHasHebrew = bFirstCharHebrew; + for (int i = 1; (i < pCell->GetStringData().Len()) && (!bHasHebrew); i++) + { + p++; + if (IS_HEBREW(*p)) + bHasHebrew = TRUE; + } + BOOL bAddToList = bHasHebrew && !bFirstCharHebrew; + if (bAddToList) + { + ScAddress* aScPosCopy = new ScAddress(aScPos); + CellIDList.Append( aScPosCopy ); + } + } } } Index: sc/source/filter/inc/imp_op.hxx =================================================================== RCS file: /cvs/sc/sc/source/filter/inc/imp_op.hxx,v retrieving revision 1.38 diff -u -r1.38 imp_op.hxx --- sc/source/filter/inc/imp_op.hxx 25 Jul 2006 09:59:12 -0000 1.38 +++ sc/source/filter/inc/imp_op.hxx 26 Oct 2006 13:15:59 -0000 @@ -70,7 +70,6 @@ #include "excdefs.hxx" #endif - class SfxItemSet; class SvStream; @@ -85,6 +84,8 @@ class ValueFormBuffer; class ExcelToSc; +typedef ScfDelList< ScAddress > XclBaseScAddressList; + class ImportTyp { @@ -271,6 +272,8 @@ virtual ~ImportExcel( void ); virtual FltError Read( void ); + + XclBaseScAddressList CellIDList; }; #endif Index: sc/source/ui/view/output2.cxx =================================================================== RCS file: /cvs/sc/sc/source/ui/view/output2.cxx,v retrieving revision 1.50.26.1 diff -u -r1.50.26.1 output2.cxx --- sc/source/ui/view/output2.cxx 10 Aug 2006 14:10:09 -0000 1.50.26.1 +++ sc/source/ui/view/output2.cxx 26 Oct 2006 13:16:02 -0000 @@ -1217,6 +1217,14 @@ #endif } +SvxCellHorJustify ContentJust(const String& aStr) +{ + const sal_Unicode *p = aStr.GetBuffer(); + BOOL bHebrew = ((*p >= 0x590) && (*p <= 0x5FF)) ; + return bHebrew ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT; +} + + void ScOutputData::DrawStrings( BOOL bPixelToLogic ) { DBG_ASSERT( pDev == pRefDevice || @@ -1437,7 +1445,7 @@ eOutHorJust = ( aVars.GetHorJust() != SVX_HOR_JUSTIFY_STANDARD ) ? aVars.GetHorJust() : - ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT ); + ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : ContentJust(pCell->GetStringData())); if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT ) eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented @@ -2162,7 +2170,7 @@ SvxCellHorJustify eOutHorJust = ( eHorJust != SVX_HOR_JUSTIFY_STANDARD ) ? eHorJust : - ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT ); + ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : ContentJust(pCell->GetStringData())); if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT ) eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented @@ -2308,7 +2316,8 @@ switch (eHorJust) { case SVX_HOR_JUSTIFY_STANDARD: - eSvxAdjust = bCellIsValue ? SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT; + eSvxAdjust = (bCellIsValue || (ContentJust(pCell->GetStringData()) == SVX_HOR_JUSTIFY_RIGHT)) + ? SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT; break; case SVX_HOR_JUSTIFY_LEFT: case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert @@ -3494,7 +3503,9 @@ else { // bei gedrehtem Text ist Standard zentriert - if (eHorJust==SVX_HOR_JUSTIFY_RIGHT) + if ((eHorJust==SVX_HOR_JUSTIFY_RIGHT) || + ((eHorJust==SVX_HOR_JUSTIFY_STANDARD) && + (ContentJust(pCell->GetStringData()) == SVX_HOR_JUSTIFY_RIGHT))) aLogicStart.X() += nAvailWidth - nEngineWidth; else if (eHorJust==SVX_HOR_JUSTIFY_CENTER || eHorJust==SVX_HOR_JUSTIFY_STANDARD)