? mylog ? mypatch ? output ? arse Index: writerhelper.hxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/Attic/writerhelper.hxx,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 writerhelper.hxx --- writerhelper.hxx 1 Jul 2003 13:17:26 -0000 1.1.2.3 +++ writerhelper.hxx 8 Jul 2003 16:03:59 -0000 @@ -64,6 +64,8 @@ #ifndef SW_WRITERHELPER #define SW_WRITERHELPER +#include + #ifndef WW_TYPESSW #include "typessw.hxx" #endif @@ -99,28 +101,35 @@ helper templates defined here */ + template const T &item_cast(const SfxPoolItem &rItem) + { + if (!rItem.IsA(STATICTYPE(T))) + throw std::bad_cast(); + return static_cast(rItem); + } + template const T & ItemGet(const SwCntntNode &rNode, sal_uInt16 eType) { - return static_cast(rNode.GetAttr(eType)); + return item_cast(rNode.GetAttr(eType)); } template const T & ItemGet(const SwFmt &rFmt, sal_uInt16 eType) { - return static_cast(rFmt.GetAttr(eType)); + return item_cast(rFmt.GetAttr(eType)); } template const T & ItemGet(const SfxItemSet &rSet, sal_uInt16 eType) { - return static_cast(rSet.Get(eType)); + return item_cast(rSet.Get(eType)); } template const T & DefaultItemGet(const SfxItemPool &rPool, sal_uInt16 eType) { - return static_cast(rPool.GetDefaultItem(eType)); + return item_cast(rPool.GetDefaultItem(eType)); } template const T & DefaultItemGet(const SwDoc &rDoc, @@ -128,6 +137,7 @@ { return DefaultItemGet(rDoc.GetAttrPool(), eType); } + } namespace hack Index: wrtw8nds.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtw8nds.cxx,v retrieving revision 1.51.4.4 diff -u -r1.51.4.4 wrtw8nds.cxx --- wrtw8nds.cxx 1 Jul 2003 13:17:27 -0000 1.51.4.4 +++ wrtw8nds.cxx 8 Jul 2003 16:04:00 -0000 @@ -220,6 +220,10 @@ #include #endif +#ifndef INCLUDED_I18NUTIL_UNICODE_HXX +#include +#endif + #ifndef SW_WRITERHELPER #include "writerhelper.hxx" #endif @@ -264,21 +268,6 @@ // Mit OutAttr() werden die Attribute an der angegebenen SwPos // ausgegeben. -class CurrentCharSet -{ -private: - const SwTxtAttr *mpPointer; - rtl_TextEncoding meCharSet; -public: - rtl_TextEncoding CharSet() const {return meCharSet;} - CurrentCharSet(const SwTxtAttr *pPointer, rtl_TextEncoding eCharSet) - : mpPointer(pPointer), meCharSet(eCharSet) {} - bool operator==(const CurrentCharSet &rSecond) const - { - return (mpPointer == rSecond.mpPointer); - } -}; - class swFlyFrm { public: @@ -294,18 +283,28 @@ { private: const SwTxtNode& rNd; - std::list maCharSets; - typedef std::list::iterator mychsiter; + + typedef std::pair CharSetEntry; + std::vector maCharSets; + typedef std::vector::iterator mychsiter; + mychsiter maCharSetIter; + rtl_TextEncoding meChrSet; + + typedef std::pair ScriptEntry; + std::vector maScripts; + typedef std::vector::iterator mysiter; + mysiter maScriptIter; + sal_uInt16 mnScript; + + const SwRedline* pCurRedline; xub_StrLen nAktSwPos; xub_StrLen nTmpSwPos; // fuer HasItem() USHORT nCurRedlinePos; - rtl_TextEncoding eNdChrSet; - USHORT nScript; - typedef std::pair Entry; - std::vector maDirChanges; - typedef std::vector::const_iterator myciter; + typedef std::pair DirEntry; + std::vector maDirChanges; + typedef std::vector::const_iterator myciter; myciter maBiDiIter; bool mbCharIsRTL; bool mbParaIsRTL; @@ -315,13 +314,13 @@ myflyiter maFlyIter; xub_StrLen SearchNext( xub_StrLen nStartPos ); - void SetCharSet(const SwTxtAttr& rTxtAttr, bool bStart); void FieldVanish( const String& rTxt ); void OutSwFmtINetFmt(const SwFmtINetFmt& rAttr, bool bStart); void OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool bStart); void OutSwTOXMark(const SwTOXMark& rAttr, bool bStart); void OutSwFmtRuby(const SwFmtRuby& rRuby, bool bStart); + sal_Int16 getScriptClass(sal_Unicode cChar) const; //No copying WW8_SwAttrIter(const WW8_SwAttrIter&); @@ -343,11 +342,9 @@ void OutFlys(xub_StrLen nSwPos); xub_StrLen WhereNext() const { return nAktSwPos; } - rtl_TextEncoding GetNextCharSet() const; - rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; } - - bool IsCharRTL() const {return mbCharIsRTL; } - bool IsParaRTL() const {return mbParaIsRTL; } + bool IsCharRTL() const { return mbCharIsRTL; } + bool IsParaRTL() const { return mbParaIsRTL; } + rtl_TextEncoding GetCharSet() const { return meChrSet; } }; class sortswflys : @@ -360,6 +357,26 @@ } }; +sal_Int16 WW8_SwAttrIter::getScriptClass(sal_Unicode cChar) const +{ + static ScriptTypeList aScripts[] = + { + { UnicodeScript_kBasicLatin, RTL_TEXTENCODING_MS_1252}, + { UnicodeScript_kLatin1Supplement, RTL_TEXTENCODING_MS_1252}, + { UnicodeScript_kLatinExtendedA, RTL_TEXTENCODING_MS_1250}, + { UnicodeScript_kLatinExtendedB, RTL_TEXTENCODING_MS_1257}, + { UnicodeScript_kGreek, RTL_TEXTENCODING_MS_1253}, + { UnicodeScript_kCyrillic, RTL_TEXTENCODING_MS_1251}, + { UnicodeScript_kHebrew, RTL_TEXTENCODING_MS_1255}, + { UnicodeScript_kArabic, RTL_TEXTENCODING_MS_1256}, + { UnicodeScript_kThai, RTL_TEXTENCODING_MS_1258}, + { UnicodeScript_kScriptCount, RTL_TEXTENCODING_MS_1252} + }; + + return unicode::getUnicodeScriptType(cChar, aScripts, + RTL_TEXTENCODING_MS_1252); +} + WW8_SwAttrIter::WW8_SwAttrIter(SwWW8Writer& rWr, const SwTxtNode& rTxtNd) : WW8_AttrIter(rWr), rNd(rTxtNd), pCurRedline(0), nAktSwPos(0), nTmpSwPos(0), nCurRedlinePos(USHRT_MAX), mbCharIsRTL(false) @@ -370,18 +387,19 @@ else mbParaIsRTL = false; - // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen - // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben - // werden. - eNdChrSet = ItemGet(rNd, RES_CHRATR_FONT).GetCharSet(); - eNdChrSet = GetExtendedTextEncoding(eNdChrSet); - const String &rTxt = rTxtNd.GetTxt(); - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType(rTxt, 0); + if (rTxt.Len() && pBreakIt->xBreak.is()) + mnScript = pBreakIt->xBreak->getScriptType(rTxt, 0); else - nScript = ScriptType::LATIN; + mnScript = ScriptType::LATIN; + + // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen + // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben + // werden. + meChrSet = ItemGet(rNd, + GetWhichOfScript(RES_CHRATR_FONT, mnScript)).GetCharSet(); + meChrSet = GetExtendedTextEncoding(meChrSet); if (rTxt.Len()) { @@ -411,12 +429,56 @@ The value for UBIDI_DEFAULT_LTR is even and the one for UBIDI_DEFAULT_RTL is odd */ - maDirChanges.push_back(Entry(nEnd, nCurrDir & 0x1)); + maDirChanges.push_back(DirEntry(nEnd, nCurrDir & 0x1)); nStart = nEnd; } ubidi_close(pBidi); + + //Split unicode text into plausable 8bit ranges for export to older + //non unicode aware format + if (!rWrt.bWrtWW8) + { + xub_StrLen nLen = rTxt.Len(); + xub_StrLen nPos = 0; + while (nPos != nLen) + { + sal_Int16 ScriptType = getScriptClass(rTxt.GetChar(nPos++)); + while ( + (nPos != nLen) && + (ScriptType == getScriptClass(rTxt.GetChar(nPos))) + ) + { + ++nPos; + } + + if (maCharSets.empty()) + meChrSet = ScriptType; + + maCharSets.push_back(CharSetEntry(nPos, ScriptType)); + } + } + + if (pBreakIt->xBreak.is()) + { + xub_StrLen nLen = rTxt.Len(); + xub_StrLen nPos = 0; + sal_uInt16 nScript = mnScript; + while (nPos < nLen) + { + sal_uInt32 nEnd = + pBreakIt->xBreak->endOfScript(rTxt, nPos, nScript); + if (nEnd == -1) + break; + nPos = nEnd; + maScripts.push_back(ScriptEntry(nPos, nScript)); + nScript = pBreakIt->xBreak->getScriptType(rTxt, nPos); + } + } + } maBiDiIter = maDirChanges.begin(); + maCharSetIter = maCharSets.begin(); + maScriptIter = maScripts.begin(); /* #i2916# @@ -460,13 +522,6 @@ nAktSwPos = SearchNext( 1 ); } -rtl_TextEncoding WW8_SwAttrIter::GetNextCharSet() const -{ - if (!maCharSets.empty()) - return maCharSets.back().CharSet(); - return eNdChrSet; -} - xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) { xub_StrLen nPos; @@ -513,8 +568,7 @@ } } - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if(const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { // kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs @@ -525,29 +579,20 @@ const SwTxtAttr* pHt = (*pTxtAttrs)[i]; nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen if( nPos >= nStartPos && nPos <= nMinPos ) - { nMinPos = nPos; - SetCharSet(*pHt, true); - } if( pHt->GetEnd() ) // Attr mit Ende { nPos = *pHt->GetEnd(); // gibt letztes Attr-Zeichen + 1 if( nPos >= nStartPos && nPos <= nMinPos ) - { nMinPos = nPos; - SetCharSet(*pHt, false); - } } else { // Attr ohne Ende Laenge 1 wegen CH_TXTATR im Text nPos = *pHt->GetStart() + 1; if( nPos >= nStartPos && nPos <= nMinPos ) - { nMinPos = nPos; - SetCharSet(*pHt, false); - } } } } @@ -562,6 +607,26 @@ } } + if (maCharSetIter != maCharSets.end()) + { + if (maCharSetIter->first <= nMinPos) + { + nMinPos = maCharSetIter->first; + meChrSet = maCharSetIter->second; + ++maCharSetIter; + } + } + + if (maScriptIter != maScripts.end()) + { + if (maScriptIter->first <= nMinPos) + { + nMinPos = maScriptIter->first; + mnScript = maScriptIter->second; + ++maScriptIter; + } + } + /* #i2916# Check to see if there are any graphics anchored to characters in this @@ -588,50 +653,20 @@ return nMinPos; } -void WW8_SwAttrIter::SetCharSet(const SwTxtAttr& rAttr, bool bStart) -{ - const SwTxtAttr* p = 0; - rtl_TextEncoding eChrSet(RTL_TEXTENCODING_DONTKNOW); - const SfxPoolItem& rItem = rAttr.GetAttr(); - switch(rItem.Which()) - { - case RES_CHRATR_FONT: - p = &rAttr; - eChrSet = ((const SvxFontItem&)rItem).GetCharSet(); - break; - case RES_TXTATR_CHARFMT: - { - const SfxPoolItem* pItem; - if( ((SwFmtCharFmt&)rItem).GetCharFmt() && SFX_ITEM_SET == - ((SwFmtCharFmt&)rItem).GetCharFmt()->GetItemState( - RES_CHRATR_FONT, true, &pItem )) - { - p = &rAttr; - eChrSet = ((const SvxFontItem*)pItem)->GetCharSet(); - } - } - break; - } - - if (p) - { - CurrentCharSet aEntry(p, GetExtendedTextEncoding(eChrSet)); - if (bStart) - maCharSets.push_back(aEntry); - else - { - mychsiter aIter = std::find(maCharSets.begin(), maCharSets.end(), - aEntry); - if (aIter != maCharSets.end()) - maCharSets.erase(aIter); - } - } -} - void WW8_SwAttrIter::OutAttr( xub_StrLen nSwPos ) { + sal_uInt16 nFontId = GetWhichOfScript(RES_CHRATR_FONT, mnScript); + const SvxFontItem &rFont = ItemGet(rNd, nFontId); + const SvxFontItem *pFont = &rFont; + if (rNd.GetpSwAttrSet()) - rWrt.Out_SfxItemSet(*rNd.GetpSwAttrSet(), false, true, nScript); + { + SfxItemSet aSet(rNd.GetSwAttrSet()); + const SvxFontItem &rFont = ItemGet(aSet, nFontId); + pFont = &rFont; + aSet.ClearItem(nFontId); + rWrt.Out_SfxItemSet(aSet, false, true, mnScript); + } if (rWrt.bWrtWW8 && IsCharRTL()) { @@ -640,15 +675,13 @@ rWrtWW8.pO->Insert((BYTE)1, rWrtWW8.pO->Count()); } - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { const SwModify* pOldMod = rWrt.pOutFmtNode; rWrt.pOutFmtNode = &rNd; nTmpSwPos = nSwPos; - register xub_StrLen i; - for( i = 0; i < pTxtAttrs->Count(); i++ ) + for (xub_StrLen i = 0; i < pTxtAttrs->Count(); ++i) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; const xub_StrLen* pEnd = pHt->GetEnd(); @@ -656,19 +689,40 @@ if( pEnd ? ( nSwPos >= *pHt->GetStart() && nSwPos < *pEnd ) : nSwPos == *pHt->GetStart() ) { - if (rWrt.CollapseScriptsforWordOk(nScript, + if (rWrt.CollapseScriptsforWordOk(mnScript, pHt->GetAttr().Which())) { - Out(aWW8AttrFnTab, pHt->GetAttr(), rWrt); + if (pHt->GetAttr().Which() == nFontId) + pFont = &(item_cast(pHt->GetAttr())); + else + Out(aWW8AttrFnTab, pHt->GetAttr(), rWrt); } } - else if( nSwPos < *pHt->GetStart() ) + else if (nSwPos < *pHt->GetStart()) break; } nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt rWrt.pOutFmtNode = pOldMod; } + + ASSERT(pFont, "must be *some* font associated with this txtnode"); + if (pFont) + { + SvxFontItem aFont(*pFont); + + /* + If we are a nonunicode aware format then we set the charset we want to + use for export of this range. If necessary this will generate a pseudo + font to use for this range. + */ + if (!rWrt.bWrtWW8) + aFont.GetCharSet() = meChrSet; + + if (rFont != aFont) + Out(aWW8AttrFnTab, aFont, rWrt); + } + OutRedlines(nSwPos); } @@ -698,8 +752,7 @@ bool WW8_SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) { // search for attrs without end position - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { register USHORT i; for( i = 0; i < pTxtAttrs->Count(); i++ ) @@ -755,10 +808,9 @@ rWrt.pO = &rItems; if (rNd.GetpSwAttrSet()) - rWrt.Out_SfxItemSet(*rNd.GetpSwAttrSet(), false, true, nScript); + rWrt.Out_SfxItemSet(*rNd.GetpSwAttrSet(), false, true, mnScript); - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { const SwModify* pOldMod = rWrt.pOutFmtNode; rWrt.pOutFmtNode = &rNd; @@ -1155,8 +1207,7 @@ bool WW8_SwAttrIter::OutAttrWithRange( xub_StrLen nPos ) { bool bRet = false; - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { nTmpSwPos = nPos; const xub_StrLen* pEnd; @@ -1435,7 +1486,7 @@ } WW8_SwAttrIter aAttrIter( rWW8Wrt, *pNd ); - rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet(); + rtl_TextEncoding eChrSet = aAttrIter.GetCharSet(); ASSERT( !pO->Count(), " pO ist am Zeilenanfang nicht leer" ); @@ -1456,7 +1507,6 @@ do { xub_StrLen nNextAttr = aAttrIter.WhereNext(); - rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet(); if( nNextAttr > nEnd ) nNextAttr = nEnd; @@ -1535,8 +1585,8 @@ } } nAktPos = nNextAttr; - eChrSet = eNextChrSet; aAttrIter.NextPos(); + eChrSet = aAttrIter.GetCharSet(); } while( nAktPos < nEnd ); @@ -2280,8 +2330,7 @@ void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ) { - const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if( pTxtAttrs ) + if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { for( USHORT n=0; n < pTxtAttrs->Count(); ++n ) { Index: wrtw8sty.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/wrtw8sty.cxx,v retrieving revision 1.24.36.3 diff -u -r1.24.36.3 wrtw8sty.cxx --- wrtw8sty.cxx 1 Jul 2003 12:14:36 -0000 1.24.36.3 +++ wrtw8sty.cxx 8 Jul 2003 16:04:00 -0000 @@ -77,6 +77,9 @@ #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include #endif +#ifndef _RTL_TENCINFO_H +#include +#endif #ifndef _HINTIDS_HXX #include @@ -743,7 +746,7 @@ if (RTL_TEXTENCODING_SYMBOL == eChrSet) maWW8_FFN[4] = 2; else - maWW8_FFN[4] = 0; + maWW8_FFN[4] = rtl_getBestWindowsCharsetFromTextEncoding(eChrSet); if (mbAlt) maWW8_FFN[5] = msFamilyNm.Len()+1;