diff options
author | Caolán McNamara <cmc@openoffice.org> | 2002-07-25 17:00:16 +0000 |
---|---|---|
committer | Caolán McNamara <cmc@openoffice.org> | 2002-07-25 17:00:16 +0000 |
commit | 2165e74081cd71d862b922546da8af96fc04b12c (patch) | |
tree | bd70ac0f1f71ddb64bd613a8643b9f19d116427d | |
parent | 462cf1d867b8de4dcf41e68025668c238babf690 (diff) |
#101615# Phase 5 im/ex BiDi Support for sections/page descriptors/tables/paragraph styles/frames and paragraph settings with regard to conversion of environmental to explicit direction on export and how that requires explicit left/right adjustment to be set if direction is also set!
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 121 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 135 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 32 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 91 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 58 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 21 |
10 files changed, 336 insertions, 165 deletions
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 45df87a4f42a..1d6dd1325864 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtw8esh.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: cmc $ $Date: 2002-07-16 15:30:18 $ + * last change: $Author: cmc $ $Date: 2002-07-25 17:59:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -399,7 +399,8 @@ bool PlcDrawObj::Append(SwWW8Writer& rWrt, WW8_CP nCp, const SwFrmFmt& rFmt, } if (bRet) - maDrawObjs.push_back(DrawObj(rFmt,nCp,rNdTopLeft)); + maDrawObjs.push_back( + DrawObj(rFmt,nCp,rNdTopLeft,rWrt.TrueFrameDirection(rFmt))); return bRet; } @@ -1070,6 +1071,7 @@ class SwEscherEx : public EscherEx { private: SvULongs aFollowShpIds; + std::vector<short> maDirections; SvPtrarr aSortFmts; SwWW8Writer& rWrt; EscherExHostAppData aHostData; @@ -1095,8 +1097,9 @@ private: INT32 DrawModelToEmu( INT32 nVal ) const { return BigMulDiv( nVal, nEmuMul, nEmuDiv ); } - INT32 WriteFlyFrm(const SwFrmFmt& rFmt,UINT32 &rShapeId); - INT32 WriteTxtFlyFrame(const SwFrmFmt& rFmt,UINT32 nShapeId,UINT32 nTxtBox); + INT32 WriteFlyFrm(const SwFrmFmt& rFmt,UINT32 &rShapeId, short nDirection); + INT32 WriteTxtFlyFrame(const SwFrmFmt& rFmt,UINT32 nShapeId, + UINT32 nTxtBox, short nDirection); INT32 WriteGrfFlyFrame(const SwFrmFmt& rFmt,UINT32 nShapeId); INT32 WriteOLEFlyFrame(const SwFrmFmt& rFmt,UINT32 nShapeId); INT32 WriteFlyFrameAttr(const SwFrmFmt& rFmt,MSO_SPT eShapeType, @@ -1221,9 +1224,9 @@ SwEscherEx::SwEscherEx( SvStream* pStrm, SwWW8Writer& rWW8Wrt ) for( USHORT n = 0; n < aSortFmts.Count(); ++n ) { INT32 nBorderThick=0; - const SwFrmFmt& rFmt = *(SwFrmFmt*)aSortFmts[ n ]; + const SwFrmFmt& rFmt = *(const SwFrmFmt*)aSortFmts[n]; if (RES_FLYFRMFMT == rFmt.Which()) - nBorderThick = WriteFlyFrm( rFmt, nShapeId ); + nBorderThick = WriteFlyFrm(rFmt, nShapeId, maDirections[n]); else if (rFmt.FindRealSdrObject()->GetObjInventor() == FmFormInventor) { @@ -1852,7 +1855,8 @@ void SwEscherEx::WriteFrmExtraData( const SwFrmFmt& rFmt ) aWinwordAnchoring.WriteData(*this); } -INT32 SwEscherEx::WriteFlyFrm( const SwFrmFmt& rFmt, UINT32 &rShapeId ) +INT32 SwEscherEx::WriteFlyFrm(const SwFrmFmt& rFmt, UINT32 &rShapeId, + short nDirection) { // check for textflyframe and if it is the first in a Chain INT32 nBorderThick = 0; @@ -1869,52 +1873,50 @@ INT32 SwEscherEx::WriteFlyFrm( const SwFrmFmt& rFmt, UINT32 &rShapeId ) nBorderThick = WriteOLEFlyFrame( rFmt, rShapeId = GetShapeID() ); break; default: + if (const SdrObject* pObj = rFmt.FindRealSdrObject()) { - const SdrObject* pObj = rFmt.FindRealSdrObject(); - if( pObj ) + // check for the first in a Chain + UINT32 nTxtId; + USHORT nOff = 0; + const SwFrmFmt* pFmt = &rFmt, *pPrev; + while( 0 != ( pPrev = pFmt->GetChain().GetPrev() )) { - // check for the first in a Chain - UINT32 nTxtId; - USHORT nOff = 0; - const SwFrmFmt* pFmt = &rFmt, *pPrev; - while( 0 != ( pPrev = pFmt->GetChain().GetPrev() )) - { - ++nOff; - pFmt = pPrev; - } + ++nOff; + pFmt = pPrev; + } - rShapeId = GetFlyShapeId( rFmt ); - if( !nOff ) + rShapeId = GetFlyShapeId( rFmt ); + if( !nOff ) + { + void* p = (void*)pObj; + nTxtId = pTxtBxs->GetPos( p ); + if( USHRT_MAX == nTxtId ) { - void* p = (void*)pObj; - nTxtId = pTxtBxs->GetPos( p ); - if( USHRT_MAX == nTxtId ) - { - pTxtBxs->Append( *pObj, rShapeId ); - nTxtId = pTxtBxs->Count(); - } - else - ++nTxtId; + pTxtBxs->Append( *pObj, rShapeId ); + nTxtId = pTxtBxs->Count(); } else + ++nTxtId; + } + else + { + const SdrObject* pPrevObj = pFmt->FindRealSdrObject(); + void* p = (void*)pPrevObj; + nTxtId = pTxtBxs->GetPos( p ); + if( USHRT_MAX == nTxtId ) { - const SdrObject* pPrevObj = pFmt->FindRealSdrObject(); - void* p = (void*)pPrevObj; - nTxtId = pTxtBxs->GetPos( p ); - if( USHRT_MAX == nTxtId ) - { - UINT32 nPrevShapeId = GetFlyShapeId( *pFmt ); - pTxtBxs->Append( *pPrevObj, nPrevShapeId ); - nTxtId = pTxtBxs->Count(); - } - else - ++nTxtId; + UINT32 nPrevShapeId = GetFlyShapeId( *pFmt ); + pTxtBxs->Append( *pPrevObj, nPrevShapeId ); + nTxtId = pTxtBxs->Count(); } - nTxtId *= 0x10000; - nTxtId += nOff; - - nBorderThick = WriteTxtFlyFrame( rFmt, rShapeId, nTxtId ); + else + ++nTxtId; } + nTxtId *= 0x10000; + nTxtId += nOff; + + nBorderThick = WriteTxtFlyFrame(rFmt, rShapeId, nTxtId, + nDirection); } } } @@ -1922,7 +1924,7 @@ INT32 SwEscherEx::WriteFlyFrm( const SwFrmFmt& rFmt, UINT32 &rShapeId ) } INT32 SwEscherEx::WriteTxtFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId, - UINT32 nTxtBox) + UINT32 nTxtBox, short nDirection) { INT32 nBorderThick=0; OpenContainer( ESCHER_SpContainer ); @@ -1939,20 +1941,10 @@ INT32 SwEscherEx::WriteTxtFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId, } nBorderThick = WriteFlyFrameAttr( rFmt, mso_sptTextBox, aPropOpt ); - const SvxFrameDirectionItem &rDirection = - (const SvxFrameDirectionItem &)rFmt.GetAttr(RES_FRAMEDIR); - MSO_TextFlow nFlow=mso_txflHorzN; - switch (rDirection.GetValue()) + MSO_TextFlow nFlow; + + switch (nDirection) { - case FRMDIR_ENVIRONMENT: - if (const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx()) - { - SwPosition aPos(*pNdIdx); - aPos.nNode = pNdIdx->GetIndex() + 1; - if (rWrt.pDoc->IsInVerticalText(aPos)) - nFlow=mso_txflTtoBA; - } - break; default: ASSERT(0,"unknown direction type"); case FRMDIR_HORI_LEFT_TOP: @@ -2406,27 +2398,30 @@ INT32 SwEscherEx::WriteFlyFrameAttr( const SwFrmFmt& rFmt, MSO_SPT eShapeType, void SwEscherEx::MakeZOrderArrAndFollowIds( const ::std::vector<DrawObj>& rSrcArr) { - if( aSortFmts.Count() ) + if (aSortFmts.Count()) aSortFmts.Remove( 0, aSortFmts.Count() ); USHORT n, nPos, nCnt = rSrcArr.size(); SvULongsSort aSort( 255 < nCnt ? 255 : nCnt, 255 ); + ASSERT(maDirections.empty(), "Impossible"); + maDirections.resize(nCnt); for( n = 0; n < nCnt; ++n ) { ULONG nOrdNum = rWrt.GetSdrOrdNum(rSrcArr[n].mrCntnt); aSort.Insert( nOrdNum, nPos ); void* p = (void *)(&(rSrcArr[n].mrCntnt)); aSortFmts.Insert( p, nPos ); + maDirections[nPos] = rSrcArr[n].mnDirection; } - if( aFollowShpIds.Count() ) - aFollowShpIds.Remove( 0, aFollowShpIds.Count() ); + if (aFollowShpIds.Count()) + aFollowShpIds.Remove(0, aFollowShpIds.Count()); ULONG nShapeId; const SwFmtChain* pChain; for( n = 0; n < nCnt; ++n ) { - const SwFrmFmt* pFmt = (SwFrmFmt*)aSortFmts[ n ]; + const SwFrmFmt* pFmt = (const SwFrmFmt*)aSortFmts[ n ]; if( RES_FLYFRMFMT == pFmt->Which() && ( ( pChain = &pFmt->GetChain())->GetPrev() || diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index e28ed4ee8713..a977d5e7331d 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtw8nds.cxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.32 $ * - * last change: $Author: cmc $ $Date: 2002-07-23 16:47:56 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,6 +102,10 @@ #ifndef _SVX_BRKITEM_HXX //autogen #include <svx/brkitem.hxx> #endif +#ifndef _SVX_FRMDIRITEM_HXX +#include <svx/frmdiritem.hxx> +#endif + #ifndef _TOOLS_TENCCVT_HXX #include <tools/tenccvt.hxx> #endif @@ -256,7 +260,8 @@ private: std::vector<Entry> maDirChanges; typedef std::vector<Entry>::const_iterator myciter; myciter aIter; - bool mbIsRTL; + bool mbCharIsRTL; + bool mbParaIsRTL; xub_StrLen SearchNext( xub_StrLen nStartPos ); void SetCharSet( const SwTxtAttr& rTxtAttr, BOOL bStart ); @@ -289,15 +294,21 @@ public: rtl_TextEncoding GetNextCharSet() const; rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; } - bool IsRTL() const {return mbIsRTL; } + bool IsCharRTL() const {return mbCharIsRTL; } + bool IsParaRTL() const {return mbParaIsRTL; } }; WW8_SwAttrIter::WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rTxtNd ) : WW8_AttrIter( rWr ), rNd( rTxtNd ), nAktSwPos( 0 ), nTmpSwPos( 0 ), aTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 ), nCurRedlinePos( USHRT_MAX ), - /*watch mbIsRTL this if we need to have an envionmental rtl in the future*/ - pCurRedline(0), mbIsRTL(false) + pCurRedline(0), mbCharIsRTL(false) { + SwPosition aPos(rTxtNd); + if (FRMDIR_HORI_RIGHT_TOP == rWr.pDoc->GetTextDirection(aPos)) + mbParaIsRTL = true; + else + mbParaIsRTL = false; + // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben // werden. @@ -314,9 +325,7 @@ WW8_SwAttrIter::WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rTxtNd ) if (rTxt.Len()) { - //Watch nDefaultDir later on, when section and table support are in - //may need to make this environmental like vertical text. - const BYTE nDefaultDir = UBIDI_LTR; + const BYTE nDefaultDir = mbParaIsRTL ? UBIDI_RTL : UBIDI_LTR; UErrorCode nError = U_ZERO_ERROR; UBiDi* pBidi = ubidi_openSized(rTxt.Len(), 0, &nError); ubidi_setPara(pBidi, rTxt.GetBuffer(), rTxt.Len(), nDefaultDir, NULL, @@ -346,10 +355,8 @@ WW8_SwAttrIter::WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rTxtNd ) nStart = nEnd; } ubidi_close(pBidi); - - aIter = maDirChanges.begin(); - } + aIter = maDirChanges.begin(); if( rWrt.pDoc->GetRedlineTbl().Count() ) { @@ -456,7 +463,7 @@ xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) if (aIter->first <= nMinPos) { nMinPos = aIter->first; - mbIsRTL = aIter->second; + mbCharIsRTL = aIter->second; ++aIter; } } @@ -512,7 +519,7 @@ void WW8_SwAttrIter::OutAttr( xub_StrLen nSwPos ) if (rNd.GetpSwAttrSet()) rWrt.Out_SfxItemSet(*rNd.GetpSwAttrSet(), FALSE, TRUE, nScript); - if (IsRTL()) + if (IsCharRTL()) { SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; rWrtWW8.InsUInt16(0x85a); @@ -1127,6 +1134,55 @@ void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos ) /* */ +short SwWW8Writer::GetCurrentPageDirection() const +{ + const SwFrmFmt &rFmt = pAktPageDesc + ? pAktPageDesc->GetMaster() + : pDoc->GetPageDesc(0).GetMaster(); + const SvxFrameDirectionItem* pItem = &rFmt.GetFrmDir(); + + if (!pItem) + { + pItem = (const SvxFrameDirectionItem*) + &pDoc->GetAttrPool().GetDefaultItem(RES_FRAMEDIR); + } + return pItem->GetValue(); +} + +short SwWW8Writer::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const +{ + const SwFrmFmt *pFlyFmt = &rFlyFmt; + const SvxFrameDirectionItem* pItem = 0; + while (pFlyFmt) + { + pItem = &pFlyFmt->GetFrmDir(); + if (FRMDIR_ENVIRONMENT == pItem->GetValue()) + { + pItem = 0; + const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); + if( FLY_PAGE != pAnchor->GetAnchorId() && + pAnchor->GetCntntAnchor() ) + { + pFlyFmt = pAnchor->GetCntntAnchor()->nNode. + GetNode().GetFlyFmt(); + } + else + pFlyFmt = 0; + } + else + pFlyFmt = 0; + } + + short nRet; + if (pItem) + nRet = pItem->GetValue(); + else + nRet = GetCurrentPageDirection(); + + ASSERT(nRet != FRMDIR_ENVIRONMENT, "leaving with environment direction"); + return nRet; +} + Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) { SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; @@ -1350,12 +1406,30 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) } } else - pTmpSet->ClearItem( RES_PARATR_NUMRULE ); + pTmpSet->ClearItem(RES_PARATR_NUMRULE); pTmpSet->Put( aLR ); SwWW8Writer::CorrTabStopInSet( *pTmpSet, pFmt->GetAbsLSpace() ); } + /* + If a given para is using the FRMDIR_ENVIRONMENT direction we + cannot export that, its its ltr then that's ok as thats word's + default. Otherwise we must add a RTL attribute to our export list + */ + const SvxFrameDirectionItem* pItem = (const SvxFrameDirectionItem*) + pNd->GetSwAttrSet().GetItem(RES_FRAMEDIR); + if ( + (!pItem || pItem->GetValue() == FRMDIR_ENVIRONMENT) && + aAttrIter.IsParaRTL() + ) + { + if (pTmpSet == pNd->GetpSwAttrSet()) + pTmpSet = new SfxItemSet(pNd->GetSwAttrSet()); + + pTmpSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP)); + } + if( pTmpSet ) { // Para-Attrs rWW8Wrt.pStyAttr = &pNd->GetAnyFmtColl().GetAttrSet(); @@ -1469,14 +1543,18 @@ Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode ) { SwWW8Writer & rWW8Wrt = (SwWW8Writer&)rWrt; SwTable& rTbl = rNode.GetTable(); - rWW8Wrt.Out_SfxBreakItems( rTbl.GetFrmFmt()->GetAttrSet(), rNode ); + const SwFrmFmt *pFmt = rTbl.GetFrmFmt(); + ASSERT(pFmt,"Impossible"); + if (!pFmt) + return rWrt; + rWW8Wrt.Out_SfxBreakItems(pFmt->GetAttrSet(), rNode); SwTwips nPageSize = 0, nTblOffset = 0; { Point aPt; - SwRect aRect( rTbl.GetFrmFmt()->FindLayoutRect( FALSE, &aPt )); - if( aRect.IsEmpty() ) + SwRect aRect(pFmt->FindLayoutRect(FALSE, &aPt)); + if (aRect.IsEmpty()) { // dann besorge mal die Seitenbreite ohne Raender !! const SwFrmFmt* pFmt = rWW8Wrt.pFlyFmt ? rWW8Wrt.pFlyFmt : @@ -1486,8 +1564,8 @@ Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode ) if( 0 == ( nPageSize = aRect.Width() )) { const SvxLRSpaceItem& rLR = pFmt->GetLRSpace(); - nPageSize = pFmt->GetFrmSize().GetWidth() - - rLR.GetLeft() - rLR.GetRight(); + nPageSize = pFmt->GetFrmSize().GetWidth() - rLR.GetLeft() - + rLR.GetRight(); } } else @@ -1496,11 +1574,10 @@ Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode ) /*ALWAYS relativ (nPageSize + ( nPageSize / 10 )) < nTblSz*/; BOOL bRelBoxSize = TRUE; - SwTwips nTblSz = rTbl.GetFrmFmt()->GetFrmSize().GetWidth(); + SwTwips nTblSz = pFmt->GetFrmSize().GetWidth(); WW8Bytes aAt( 128, 128 ); // Attribute fuer's Tabellen-Zeilenende - USHORT nStdAtLen = rWW8Wrt.StartTableFromFrmFmt(aAt,rTbl.GetFrmFmt(), - nTblOffset); - static BYTE __READONLY_DATA aNullBytes[] = { 0, 0, 0, 0 }; + USHORT nStdAtLen = rWW8Wrt.StartTableFromFrmFmt(aAt, pFmt, nTblOffset); + static const BYTE aNullBytes[] = { 0, 0, 0, 0 }; SwWriteTable* pTableWrt; const SwHTMLTableLayout *pLayout = rTbl.GetHTMLTableLayout(); @@ -1618,6 +1695,16 @@ Writer& OutWW8_SwTblNode( Writer& rWrt, SwTableNode & rNode ) aAt.Insert( 185, aAt.Count() ); aAt.Insert( (BYTE)1, aAt.Count() ); + + if (rWW8Wrt.bWrtWW8) + { + if (rWW8Wrt.TrueFrameDirection(*pFmt) == FRMDIR_HORI_RIGHT_TOP) + { + SwWW8Writer::InsUInt16(aAt, 0x560B); + SwWW8Writer::InsUInt16(aAt, 1); + } + } + // Inhalt der Boxen ausgeben for( nBox = 0, nRealBox = 0; nBox < nColCnt; ++nBox ) { diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 31706e6802a7..0b741cd85f40 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtw8sty.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: cmc $ $Date: 2002-07-01 13:55:11 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,6 +101,10 @@ #ifndef _SVX_FMGLOB_HXX #include <svx/fmglob.hxx> #endif +#ifndef _SVX_FRMDIRITEM_HXX +#include <svx/frmdiritem.hxx> +#endif + #ifndef _WRTWW8_HXX #include <wrtww8.hxx> #endif @@ -450,6 +454,8 @@ void WW8WrtStyle::SkipOdd() // Ruecke zu gerader Adresse vor void WW8WrtStyle::Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap ) { + const SwModify* pOldMod = rWrt.pOutFmtNode; + rWrt.pOutFmtNode = &rFmt; BOOL aFlags[ RES_FRMATR_END - RES_CHRATR_BEGIN ]; USHORT nStt, nEnd, n; if( bPap ) @@ -472,8 +478,6 @@ void WW8WrtStyle::Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap ) { aFlags[ RES_CHRATR_FONTSIZE - RES_CHRATR_BEGIN ] = 1; aFlags[ RES_CHRATR_LANGUAGE - RES_CHRATR_BEGIN ] = 1; - //Winword default is auto, OOo default is black - aFlags[ RES_CHRATR_COLOR - RES_CHRATR_BEGIN] = 1; } const SfxItemSet* pOldI = rWrt.GetCurItemSet(); @@ -487,7 +491,7 @@ void WW8WrtStyle::Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap ) //If we are a character property then see if it is one of the //western/asian ones that must be collapsed together for export to //word. If so default to the western varient. - if ( !bPap && rWrt.CollapseScriptsforWordOk( + if ( bPap || rWrt.CollapseScriptsforWordOk( ::com::sun::star::i18n::ScriptType::LATIN, n) ) { Out(aWW8AttrFnTab, rFmt.GetAttr(n, TRUE), rWrt); @@ -496,6 +500,7 @@ void WW8WrtStyle::Set1StyleDefaults( const SwFmt& rFmt, BOOL bPap ) } rWrt.SetCurItemSet( pOldI ); + rWrt.pOutFmtNode = pOldMod; } void WW8WrtStyle::BuildUpx( const SwFmt* pFmt, BOOL bPap, USHORT nPos, @@ -1288,6 +1293,23 @@ BOOL WW8_WrPlcSepx::WriteKFTxt( SwWW8Writer& rWrt ) const SfxItemSet* pOldI = rWrt.pISet; rWrt.pISet = &aSet; Out_SfxItemSet( aWW8AttrFnTab, rWrt, aSet, TRUE ); + + //Cannot export as normal page framedir, as continous sections + //cannot contain any grid settings like proper sections + if (rWrt.bWrtWW8) + { + BYTE nDir; + SwWW8Writer::InsUInt16(*pO, 0x3228); + if (FRMDIR_HORI_RIGHT_TOP == + rWrt.TrueFrameDirection(*rSepInfo.pSectionFmt)) + { + nDir = 1; + } + else + nDir = 0; + pO->Insert( nDir, pO->Count() ); + } + rWrt.pISet = pOldI; bOutPgDscSet = FALSE; diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 29f509f81dce..8367c356ad5a 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtww8.hxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.32 $ * - * last change: $Author: cmc $ $Date: 2002-07-16 15:30:21 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -341,10 +341,11 @@ public: const SwFrmFmt &mrCntnt; // SwFrmFmt Point maParentPos; // Points INT32 mnThick; // Border Thicknesses + short mnDirection; // If BiDi or not - DrawObj(const SwFrmFmt &rCntnt, WW8_CP nCp, Point aParentPos) + DrawObj(const SwFrmFmt &rCntnt, WW8_CP nCp, Point aParentPos, short nDir) : mnCp(nCp), mnShapeId(0), mrCntnt(rCntnt), maParentPos(aParentPos), - mnThick(0) {} + mnThick(0), mnDirection(nDir) {} }; class PlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes @@ -535,6 +536,8 @@ public: void WriteKFTxt1( const SwFmtCntnt& rCntnt ); void WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pO = 0 ); void WritePostItBegin( WW8Bytes* pO = 0 ); + short TrueFrameDirection(const SwFrmFmt &rFlyFmt) const; + short GetCurrentPageDirection() const; void OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ); void OutWW8FlyFrm( const SwFrmFmt& rFlyFrmFmt, const Point& rNdTopLeft ); void OutFlyFrms( const SwCntntNode& rNode ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 8cff45c29cec..5f5c359eb8c6 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8atr.cxx,v $ * - * $Revision: 1.46 $ + * $Revision: 1.47 $ * - * last change: $Author: cmc $ $Date: 2002-07-24 15:06:35 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -250,6 +250,9 @@ #ifndef _DOC_HXX #include <doc.hxx> // Doc fuer Fussnoten #endif +#ifndef _PAM_HXX +#include <pam.hxx> +#endif #ifndef _PARATR_HXX #include <paratr.hxx> #endif @@ -476,8 +479,20 @@ void SwWW8Writer::Out_SfxItemSet( const SfxItemSet& rSet, BOOL bPapFmt, pISet = &rSet; // fuer Doppel-Attribute - // first the NumRule and than the LRSpace, so will W97 understand it - // and move away the paragraph from the left side + //If frame dir is set, but not adjust, then force adjust as well + if (bPapFmt && SFX_ITEM_SET == rSet.GetItemState(RES_FRAMEDIR, + FALSE, &pItem )) + { + //No explicit adjust set ? + if (SFX_ITEM_SET != rSet.GetItemState(RES_PARATR_ADJUST, FALSE)) + { + pItem = rSet.GetItem(RES_PARATR_ADJUST); + // then set the adjust used by the parent format + pOut = aWW8AttrFnTab[ RES_PARATR_ADJUST - RES_CHRATR_BEGIN ]; + (*pOut)( *this, *pItem ); + } + } + if( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, FALSE, &pItem )) { @@ -3862,22 +3877,24 @@ static Writer& OutWW8_SvxAdjust(Writer& rWrt, const SfxPoolItem& rHt) bool bBiDiSwap=false; if (rWrtWW8.pOutFmtNode) { - const SvxFrameDirectionItem *pItem = 0; + short nDirection = FRMDIR_HORI_LEFT_TOP; if (rWrtWW8.pOutFmtNode->ISA(SwTxtNode)) { - const SwCntntNode* pTxtNd = - (const SwCntntNode*)rWrtWW8.pOutFmtNode; - pItem = (const SvxFrameDirectionItem*) - &(pTxtNd->GetAttr(RES_FRAMEDIR)); + SwPosition aPos(*(const SwCntntNode*)rWrtWW8.pOutFmtNode); + nDirection = rWrtWW8.pDoc->GetTextDirection(aPos); } else if (rWrtWW8.pOutFmtNode->ISA(SwTxtFmtColl)) { const SwTxtFmtColl* pC = (const SwTxtFmtColl*)rWrtWW8.pOutFmtNode; - pItem = (const SvxFrameDirectionItem*) - &(pC->GetAttr(RES_FRAMEDIR)); + if (const SvxFrameDirectionItem *pItem = + (const SvxFrameDirectionItem*) + &(pC->GetAttr(RES_FRAMEDIR))) + { + nDirection = pItem->GetValue(); + } } - if (pItem && pItem->GetValue() == FRMDIR_HORI_RIGHT_TOP) + if (nDirection == FRMDIR_HORI_RIGHT_TOP) bBiDiSwap=true; } @@ -3904,10 +3921,38 @@ static Writer& OutWW8_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt ) const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rHt; UINT16 nTextFlow=0; BOOL bBiDi=FALSE; - switch (rItem.GetValue()) + short nDir = rItem.GetValue(); + + if (nDir == FRMDIR_ENVIRONMENT) + { + if (rWrtWW8.bOutPageDescs) + nDir = rWrtWW8.GetCurrentPageDirection(); + else if (rWrtWW8.pOutFmtNode) + { + if (rWrtWW8.bOutFlyFrmAttrs) //frame + { + nDir = rWrtWW8.TrueFrameDirection( + *(const SwFrmFmt*)rWrtWW8.pOutFmtNode); + } + else if (rWrtWW8.pOutFmtNode->ISA(SwCntntNode)) //pagagraph + { + const SwCntntNode* pNd = + (const SwCntntNode*)rWrtWW8.pOutFmtNode; + SwPosition aPos(*pNd); + nDir = rWrt.pDoc->GetTextDirection(aPos); + } + else if (rWrtWW8.pOutFmtNode->ISA(SwTxtFmtColl)) + nDir = FRMDIR_HORI_LEFT_TOP; //what else can we do :-( + } + + if (nDir == FRMDIR_ENVIRONMENT) + nDir = FRMDIR_HORI_LEFT_TOP; //Set something + } + + switch (nDir) { default: - //Don't know about inheriting direction yet. A ToDo. + //Can't get an unknown type here ASSERT(0,"Unknown frame direction"); case FRMDIR_HORI_LEFT_TOP: nTextFlow = 0; @@ -3933,24 +3978,6 @@ static Writer& OutWW8_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt ) { rWrtWW8.InsUInt16(0x2441); rWrtWW8.pO->Insert(bBiDi, rWrtWW8.pO->Count() ); - - if (rWrtWW8.pOutFmtNode && - rWrtWW8.pOutFmtNode->ISA(SwTxtFmtColl)) - { - const SwTxtFmtColl* pC = - (const SwTxtFmtColl*)rWrtWW8.pOutFmtNode; - - /* - If we are setting the frame direction but - have not or will not set the adjust then we need - to force that to happen because the default thing - that word does when seeing rtl is to right align - those paragraphs, while we retain a default of - left align - */ - if (SFX_ITEM_SET != pC->GetItemState(RES_PARATR_ADJUST, TRUE)) - OutWW8_SvxAdjust(rWrt, pC->GetAttr(RES_PARATR_ADJUST)); - } } return rWrt; } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index a8e2f2b664a1..7e21e7875180 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8par.cxx,v $ * - * $Revision: 1.73 $ + * $Revision: 1.74 $ * - * last change: $Author: cmc $ $Date: 2002-07-23 12:39:46 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2272,6 +2272,7 @@ SwWW8ImplReader::SwWW8ImplReader( BYTE nVersionPara, SvStorage* pStorage, nLFOPosition = USHRT_MAX; nListLevel = nWW8MaxListLevel; + mbRTLPgn = false; eHardCharSet = RTL_TEXTENCODING_DONTKNOW; pPageDesc = 0; diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 2dbdf729a0a1..c90a70f4d210 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8par.hxx,v $ * - * $Revision: 1.83 $ + * $Revision: 1.84 $ * - * last change: $Author: cmc $ $Date: 2002-07-24 15:06:36 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -779,6 +779,7 @@ friend class WW8FormulaControl; BYTE nListLevel; BYTE nNfcPgn; // Formatting of PageNum + bool mbRTLPgn; // Direction of page BYTE nPgChpDelim; // ChapterDelim from PageNum BYTE nPgChpLevel; // ChapterLevel of Heading from PageNum diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 38b8ee988e8b..00c7e130ac4b 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8par2.cxx,v $ * - * $Revision: 1.62 $ + * $Revision: 1.63 $ * - * last change: $Author: cmc $ $Date: 2002-07-23 17:06:06 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,6 +112,9 @@ #ifndef _SVX_HYZNITEM_HXX //autogen #include <svx/hyznitem.hxx> #endif +#ifndef _SVX_FRMDIRITEM_HXX +#include <svx/frmdiritem.hxx> +#endif #ifndef _PAM_HXX #include <pam.hxx> // fuer SwPam @@ -279,6 +282,7 @@ class WW8TabDesc BOOL bHeader; BOOL bClaimLineFmt; SwHoriOrient eOri; + bool bIsBiDi; // 2. allgemeine Verwaltungsinfo short nAktRow; short nAktBandRow; // SW: in dieser Zeile des akt. Bandes bin ich @@ -1545,14 +1549,16 @@ WW8TabDesc::WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp ) pTabBox( 0 ), pMergeGroups( 0 ), pAktWWCell( 0 ), nRows( 0 ), nDefaultSwCols( 0 ), nBands( 0 ), nMinLeft( 0 ), nConvertedLeft(0), nMaxRight( 0 ), nSwWidth( 0 ), bOk( TRUE ), bHeader( FALSE ), - bClaimLineFmt( FALSE ), eOri( HORI_NONE ), nAktRow( 0 ), + bClaimLineFmt( FALSE ), eOri( HORI_NONE ), bIsBiDi(false), nAktRow( 0 ), nAktBandRow( 0 ), nAktCol( 0 ), pParentPos(0), pFlyFmt(0), aItemSet(pIo->rDoc.GetAttrPool(),RES_FRMATR_BEGIN,RES_FRMATR_END-1) { pIo->bAktAND_fNumberAcross = FALSE; - static SwHoriOrient aOriArr[] = { - HORI_LEFT, HORI_CENTER, HORI_RIGHT, HORI_CENTER }; + static const SwHoriOrient aOriArr[] = + { + HORI_LEFT, HORI_CENTER, HORI_RIGHT, HORI_CENTER + }; BOOL bVer67 = pIo->bVer67; BOOL bComplex = pIo->pWwFib->fComplex; @@ -1629,6 +1635,9 @@ WW8TabDesc::WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp ) eOri = aOriArr[ *pParams & 0x3 ]; } break; + case 0x560B: + bIsBiDi = SVBT16ToShort(pParams) ? true : false; + break; case 184: case 0x9602: { @@ -2163,6 +2172,10 @@ void WW8TabDesc::CreateSwTable() aItemSet.Put(SwFmtFrmSize(ATT_FIX_SIZE, nSwWidth)); } + SvxFrameDirectionItem aDirection( + bIsBiDi ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP ); + aItemSet.Put(aDirection); + if (HORI_LEFT_AND_WIDTH == eOri) { if (pIo->bApo && pIo->nTable == 0 && pIo->pSFlyPara->pFlyFmt && @@ -3754,7 +3767,7 @@ void WW8RStyle::ScanStyles() // untersucht Style-Abhaengigkeiten void WW8RStyle::Import() { pIo->pDfltTxtFmtColl = pIo->rDoc.GetDfltTxtFmtColl(); - pIo->pStandardFmtColl = pIo->rDoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ); + pIo->pStandardFmtColl = pIo->rDoc.GetTxtCollFromPool(RES_POOLCOLL_STANDARD); if( pIo->nIniFlags & WW8FL_NO_STYLES ) return; @@ -3799,18 +3812,31 @@ void WW8RStyle::Import() // set Hyphenation flag on BASIC para-style - if( pIo->mbNewDoc - && pIo->pWDop->fAutoHyphen - && pIo->pStandardFmtColl - && SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState( - RES_PARATR_HYPHENZONE, FALSE ) ) + if (pIo->mbNewDoc && pIo->pStandardFmtColl) { - SvxHyphenZoneItem aAttr( TRUE ); - aAttr.GetMinLead() = 2; - aAttr.GetMinTrail() = 2; - aAttr.GetMaxHyphens() = 0; + if (pIo->pWDop->fAutoHyphen + && SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState( + RES_PARATR_HYPHENZONE, FALSE ) ) + { + SvxHyphenZoneItem aAttr( TRUE ); + aAttr.GetMinLead() = 2; + aAttr.GetMinTrail() = 2; + aAttr.GetMaxHyphens() = 0; + + pIo->pStandardFmtColl->SetAttr( aAttr ); + } - pIo->pStandardFmtColl->SetAttr( aAttr ); + /* + Word defaults to ltr not from environment like writer. Regardless of + the page/sections rtl setting the standard style lack of rtl still + means ltr + */ + if (SFX_ITEM_SET != pIo->pStandardFmtColl->GetItemState(RES_FRAMEDIR, + FALSE)) + { + pIo->pStandardFmtColl->SetAttr( + SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP)); + } } // wir sind jetzt nicht mehr beim Style einlesen: diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 1583aca19fdb..bbbb2cfd9585 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8par6.cxx,v $ * - * $Revision: 1.101 $ + * $Revision: 1.102 $ * - * last change: $Author: cmc $ $Date: 2002-07-24 15:06:37 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -419,8 +419,6 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrmFmt &rFmt,const WW8PLCFx_SEPX* pSep) if (bVer67) return; - //sprmSFBiDi - BYTE bIsBiDi = ReadBSprm(pSep, 0x3228, 0); SvxFrameDirection eDir=FRMDIR_HORI_LEFT_TOP; //sprmSTextFlow @@ -453,7 +451,7 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrmFmt &rFmt,const WW8PLCFx_SEPX* pSep) break; } } - if ((eDir == FRMDIR_HORI_LEFT_TOP) && bIsBiDi) + if ((eDir == FRMDIR_HORI_LEFT_TOP) && mbRTLPgn) eDir = FRMDIR_HORI_RIGHT_TOP; rFmt.SetAttr(SvxFrameDirectionItem(eDir)); @@ -1128,6 +1126,9 @@ void SwWW8ImplReader::InsertSectionWithWithoutCols(SwPaM& rMyPaM, if( pCol ) aSet.Put( *pCol ); + aSet.Put(SvxFrameDirectionItem( + mbRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP)); + if( 2 == pWDop->fpc ) aSet.Put( SwFmtFtnAtTxtEnd( FTNEND_ATTXTEND )); if( 0 == pWDop->epc ) @@ -1395,6 +1396,11 @@ void SwWW8ImplReader::CreateSep(const long nTxtPos, BOOL bMustHaveBreak) if (nNfcPgn > 4) nNfcPgn = 0; + // sprmSFBiDi + bool bLastRTLPgn = mbRTLPgn; + if (!bVer67) + mbRTLPgn = ReadBSprm(pSep, 0x3228, 0); + /* Pruefen, ob wir uns den neuen Abschnitt schenken koennen, da kein Umbruch erforderlich ist. @@ -1427,7 +1433,7 @@ void SwWW8ImplReader::CreateSep(const long nTxtPos, BOOL bMustHaveBreak) bEqual = (bSectionHasATitlePage == bLastSectionHadATitlePage) && (nCorrIhdt == nLastSectionCorrIhdt) && (nCorrIhdt == (nCorrIhdt & nJustCopyHdFt)) - && (nNfcPgn == nLastNfcPgn); + && (nNfcPgn == nLastNfcPgn) && (mbRTLPgn == bLastRTLPgn); } if (bEqual) //Give continious breaks leniency. @@ -2744,7 +2750,9 @@ WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM, if (rReader.bVerticalEnviron) Put(SwFmtVertOrient(0, VERT_CHAR_CENTER,REL_CHAR)); else - Put( SwFmtVertOrient( 0, VERT_TOP, FRAME )); + Put(SwFmtVertOrient(0, VERT_TOP, FRAME)); + + Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP)); short aSizeArray[5]={0}; /* diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index c217905f5797..1b3497623ef4 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ww8scan.cxx,v $ * - * $Revision: 1.63 $ + * $Revision: 1.64 $ * - * last change: $Author: cmc $ $Date: 2002-07-23 17:06:08 $ + * last change: $Author: cmc $ $Date: 2002-07-25 18:00:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -176,11 +176,12 @@ public: template<class C> const C *wwSortedArray<C>::search(C aSrch) const { - const C *pIter = - ::std::lower_bound(mpWwSprmTab, mpWwSprmTab + mnNoElems, aSrch); - if (pIter == mpWwSprmTab + mnNoElems || *pIter < aSrch) - pIter=0; - return pIter; + std::pair<const C *, const C *> aPair = + std::equal_range(mpWwSprmTab, mpWwSprmTab + mnNoElems, aSrch); + if (aPair.first != aPair.second) + return aPair.first; + else + return 0; } bool operator==(const SprmInfo &rFirst, const SprmInfo &rSecond) @@ -3348,9 +3349,9 @@ const wwSprmSequence* WW8PLCFx_SEPX::GetWW8IgnoredSprms() { static sal_uInt16 aSprmIds[] = { - 0x3005, 0x3006, 0x3009, 0x300E, 0x3013, 0x3019, 0x3229, - 0x500B, 0x5015, 0x501B, 0x5026, 0x703A, 0x900C, 0x9016, - 0x9023, 0x9024, 0xB017, 0xB018, 0xF203, 0xF204 + 0x3005, 0x3006, 0x3009, 0x300E, 0x3013, 0x3019, 0x3228, + 0x3229, 0x500B, 0x5015, 0x501B, 0x5026, 0x703A, 0x900C, + 0x9016, 0x9023, 0x9024, 0xB017, 0xB018, 0xF203, 0xF204 }; static wwSprmSequence aWWSprmIds(aSprmIds, |