diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-14 00:32:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-14 09:54:09 +0100 |
commit | 79dc19fcbdb1e6aa9a8958a8b3d1fbf0451646cf (patch) | |
tree | 79f7d3f5490aa81fd24f14c3232465592ff71b50 /sw | |
parent | 98ae11bcd4b24c5616a4aefd4b865fcbe87814ef (diff) |
ByteString->rtl::OStringBuffer
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/htmlfldw.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/html/htmlfly.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 138 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 2 |
4 files changed, 89 insertions, 81 deletions
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 0a4638d5c1ff..10f4c0b9c7fc 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -458,8 +458,9 @@ Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt ) rWrt.Strm() << '/'; // TODO: HTML-Tags are written without entitities, that for, characters // not contained in the destination encoding are lost! - ByteString sTmp( rTxt, ((SwHTMLWriter&)rWrt).eDestEnc ); - rWrt.Strm() << sTmp.GetBuffer() << '>'; + rtl::OString sTmp(rtl::OUStringToOString(rTxt, + ((SwHTMLWriter&)rWrt).eDestEnc)); + rWrt.Strm() << sTmp.getStr() << '>'; } else if( RES_POSTITFLD == pFldTyp->Which() ) { @@ -480,8 +481,9 @@ Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt ) sComment.ConvertLineEnd( GetSystemLineEnd() ); // TODO: HTML-Tags are written without entitities, that for, // characters not contained in the destination encoding are lost! - ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc ); - rWrt.Strm() << sTmp.GetBuffer(); + rtl::OString sTmp(rtl::OUStringToOString(sComment, + ((SwHTMLWriter&)rWrt).eDestEnc)); + rWrt.Strm() << sTmp.getStr(); bWritten = sal_True; } else if( rComment.Len() >= 7 && @@ -496,8 +498,9 @@ Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt ) // TODO: HTML-Tags are written without entitities, that for, // characters not contained in the destination encoding are // lost! - ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc ); - rWrt.Strm() << sTmp.GetBuffer(); + rtl::OString sTmp(rtl::OUStringToOString(sComment, + ((SwHTMLWriter&)rWrt).eDestEnc)); + rWrt.Strm() << sTmp.getStr(); bWritten = sal_True; } @@ -505,15 +508,14 @@ Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt ) if( !bWritten ) { - ByteString sOut( '<' ); - String sComment( rComment ); sComment.ConvertLineEnd( GetSystemLineEnd() ); + rtl::OStringBuffer sOut; // TODO: ??? - (((sOut += OOO_STRING_SVTOOLS_HTML_comment) += ' ') - += ByteString( sComment, ((SwHTMLWriter&)rWrt).eDestEnc )) - += " -->"; - rWrt.Strm() << sOut.GetBuffer(); + sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_comment) + .append(' ').append(rtl::OUStringToOString(sComment, + ((SwHTMLWriter&)rWrt).eDestEnc)).append(" -->"); + rWrt.Strm() << sOut.getStr(); } } else if( RES_SCRIPTFLD == pFldTyp->Which() ) diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index b3dade824c9b..8907a74914ab 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -955,8 +955,8 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrmFmt &rFrmFmt, if( rHTMLWrt.bLFPossible ) { rHTMLWrt.OutNewLine( sal_True ); - rHTMLWrt.GetIndentString( aIndMap ); - rHTMLWrt.GetIndentString( aIndArea, 1 ); + aIndMap = rHTMLWrt.GetIndentString(); + aIndArea = rHTMLWrt.GetIndentString(1); #if defined(UNX) aLF[0] = SwHTMLWriter::sNewLine; pLF = aLF; diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index f21a82358006..9817e8fd17eb 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -178,8 +178,8 @@ sal_uLong SwHTMLWriter::WriteStream() const sal_Char *pHelpHack = getenv( "HelpEx" ); if( pHelpHack ) { - ByteString aTmp( pHelpHack ); - if( aTmp.EqualsIgnoreCaseAscii( "Hilfe" ) ) + rtl::OString aTmp(pHelpHack); + if (aTmp.equalsIgnoreAsciiCase("Hilfe")) nHTMLMode |= HTMLMODE_NO_BR_AT_PAREND; } @@ -269,7 +269,7 @@ sal_uLong SwHTMLWriter::WriteStream() GetNumInfo().Clear(); pNextNumRuleInfo = 0; - ByteString aStartTags; + rtl::OString aStartTags; // Tabellen und Bereiche am Doc.-Anfang beachten { @@ -305,13 +305,12 @@ sal_uLong SwHTMLWriter::WriteStream() pSNd->GetSection().GetSectionName(), aName, eDestEnc, &aNonConvertableCharacters ); - ByteString sOut( '<' ); - (((((((sOut += OOO_STRING_SVTOOLS_HTML_division) - += ' ') += OOO_STRING_SVTOOLS_HTML_O_id) += "=\"") - += aName) += '\"') - += '>') += aStartTags; - - aStartTags = sOut; + rtl::OStringBuffer sOut; + sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division) + .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_id) + .append("=\"").append(aName).append('\"').append('>') + .append(aStartTags); + aStartTags = sOut.makeStringAndClear(); } // FindSectionNode() an einem SectionNode liefert den selben! pSNd = pSNd->StartOfSectionNode()->FindSectionNode(); @@ -335,8 +334,8 @@ sal_uLong SwHTMLWriter::WriteStream() // Formulare, die nur HiddenControls enthalten ausgeben. OutHiddenForms(); - if( aStartTags.Len() ) - Strm() << aStartTags.GetBuffer(); + if( !aStartTags.isEmpty() ) + Strm() << aStartTags.getStr(); const SfxPoolItem *pItem; const SfxItemSet& rPageItemSet = pCurrPageDesc->GetMaster().GetAttrSet(); @@ -850,9 +849,9 @@ static void OutBodyColor( const sal_Char *pTag, const SwFmt *pFmt, if( pColorItem ) { - ByteString sOut( ' ' ); - (sOut += pTag) += '='; - rHWrt.Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append(' ').append(pTag).append('='); + rHWrt.Strm() << sOut.makeStringAndClear().getStr(); Color aColor( pColorItem->GetValue() ); if( COL_AUTO == aColor.GetColor() ) aColor.SetColor( COL_BLACK ); @@ -906,11 +905,12 @@ sal_uInt16 SwHTMLWriter::OutHeaderAttrs() const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) { - ByteString sOut( OOO_STRING_SVTOOLS_HTML_doctype ); - (sOut += ' ') += - (HTML_CFG_HTML32==nExportMode ? OOO_STRING_SVTOOLS_HTML_doctype32 - : OOO_STRING_SVTOOLS_HTML_doctype40); - HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.GetBuffer() ); + rtl::OStringBuffer sOut; + sOut.append(OOO_STRING_SVTOOLS_HTML_doctype).append(' ') + .append(HTML_CFG_HTML32==nExportMode ? + OOO_STRING_SVTOOLS_HTML_doctype32 : + OOO_STRING_SVTOOLS_HTML_doctype40); + HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() ); // baue den Vorspann OutNewLine(); @@ -922,12 +922,12 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) IncIndentLevel(); // Inhalt von <HEAD> einruecken // DokumentInfo - ByteString sIndent; - GetIndentString( sIndent ); + rtl::OString sIndent = GetIndentString(); using namespace ::com::sun::star; uno::Reference<document::XDocumentProperties> xDocProps; SwDocShell *pDocShell(pDoc->GetDocShell()); - if (pDocShell) { + if (pDocShell) + { uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW); xDocProps.set(xDPS->getDocumentProperties()); @@ -935,7 +935,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) // xDocProps may be null here (when copying) SfxFrameHTMLWriter::Out_DocInfo( Strm(), GetBaseURL(), xDocProps, - sIndent.GetBuffer(), eDestEnc, + sIndent.getStr(), eDestEnc, &aNonConvertableCharacters ); // Kommentare und Meta-Tags des ersten Absatzes @@ -945,31 +945,31 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) const SwPageDesc *pPageDesc = 0; - // In Nicht-HTML-Dokumenten wird die erste gesetzte Seitenvorlage - // exportiert und wenn keine gesetzt ist die Standard-Vorlage - sal_uLong nNodeIdx = pCurPam->GetPoint()->nNode.GetIndex(); + // In Nicht-HTML-Dokumenten wird die erste gesetzte Seitenvorlage + // exportiert und wenn keine gesetzt ist die Standard-Vorlage + sal_uLong nNodeIdx = pCurPam->GetPoint()->nNode.GetIndex(); - while( nNodeIdx < pDoc->GetNodes().Count() ) + while( nNodeIdx < pDoc->GetNodes().Count() ) + { + SwNode *pNd = pDoc->GetNodes()[ nNodeIdx ]; + if( pNd->IsCntntNode() ) { - SwNode *pNd = pDoc->GetNodes()[ nNodeIdx ]; - if( pNd->IsCntntNode() ) - { - pPageDesc = ((const SwFmtPageDesc &)pNd->GetCntntNode() - ->GetAttr(RES_PAGEDESC)).GetPageDesc(); - break; - } - else if( pNd->IsTableNode() ) - { - pPageDesc = pNd->GetTableNode()->GetTable().GetFrmFmt() - ->GetPageDesc().GetPageDesc(); - break; - } - - nNodeIdx++; + pPageDesc = ((const SwFmtPageDesc &)pNd->GetCntntNode() + ->GetAttr(RES_PAGEDESC)).GetPageDesc(); + break; + } + else if( pNd->IsTableNode() ) + { + pPageDesc = pNd->GetTableNode()->GetTable().GetFrmFmt() + ->GetPageDesc().GetPageDesc(); + break; } - if( !pPageDesc ) - pPageDesc = &const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 ); + nNodeIdx++; + } + + if( !pPageDesc ) + pPageDesc = &const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 ); // und nun ... das Style-Sheet!!! if( bCfgOutStyles ) @@ -987,10 +987,8 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) // der Body wird nicht eingerueckt, weil sonst alles eingerueckt waere! OutNewLine(); - sOut = '<'; - sOut += OOO_STRING_SVTOOLS_HTML_body; - Strm() << sOut.GetBuffer(); - sOut.Erase(); + sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_body); + Strm() << sOut.makeStringAndClear().getStr(); // language OutLanguage( eLang ); @@ -1031,9 +1029,10 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs ) void SwHTMLWriter::OutAnchor( const String& rName ) { - ByteString sOut( '<' ); - (((sOut += OOO_STRING_SVTOOLS_HTML_anchor) += ' ') += OOO_STRING_SVTOOLS_HTML_O_name) += "=\""; - Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_anchor).append(' ') + .append(OOO_STRING_SVTOOLS_HTML_O_name).append("=\""); + Strm() << sOut.makeStringAndClear().getStr(); HTMLOutFuncs::Out_String( Strm(), rName, eDestEnc, &aNonConvertableCharacters ) << "\">"; HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_anchor, sal_False ); } @@ -1134,9 +1133,9 @@ void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, /// only checking, if transparency is not set. if( rBackColor.GetColor() != COL_TRANSPARENT ) { - ByteString sOut( ' ' ); - (sOut += OOO_STRING_SVTOOLS_HTML_O_bgcolor) += '='; - Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append('='); + Strm() << sOut.makeStringAndClear().getStr(); HTMLOutFuncs::Out_Color( Strm(), rBackColor, eDestEnc); } @@ -1183,10 +1182,11 @@ void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, if( pLink ) { - ByteString sOut( ' ' ); String s( URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), *pLink)); - (sOut += OOO_STRING_SVTOOLS_HTML_O_background) += "=\""; - Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_background) + .append("=\""); + Strm() << sOut.makeStringAndClear(); HTMLOutFuncs::Out_String( Strm(), s, eDestEnc, &aNonConvertableCharacters ) << '\"'; } } @@ -1224,9 +1224,10 @@ void SwHTMLWriter::OutLanguage( LanguageType nLang ) { if( LANGUAGE_DONTKNOW != nLang ) { - ByteString sOut( ' ' ); - (sOut += OOO_STRING_SVTOOLS_HTML_O_lang) += "=\""; - Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_lang) + .append("=\""); + Strm() << sOut.makeStringAndClear().getStr(); HTMLOutFuncs::Out_String( Strm(), MsLangId::convertLanguageToIsoString(nLang), eDestEnc, &aNonConvertableCharacters ) << '"'; } @@ -1272,23 +1273,28 @@ void SwHTMLWriter::OutDirection( sal_uInt16 nDir ) } if( pValue != 0 ) { - ByteString sOut( ' ' ); - (((sOut += OOO_STRING_SVTOOLS_HTML_O_dir) += "=\"") += pValue) += '\"'; - Strm() << sOut.GetBuffer(); + rtl::OStringBuffer sOut; + sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_dir) + .append("=\"").append(pValue).append('\"'); + Strm() << sOut.makeStringAndClear().getStr(); } } -void SwHTMLWriter::GetIndentString( ByteString& rStr, sal_uInt16 nIncLvl ) +rtl::OString SwHTMLWriter::GetIndentString(sal_uInt16 nIncLvl) { + rtl::OString sRet; + // etwas umstaendlich, aber wir haben nur einen Indent-String! sal_uInt16 nLevel = nIndentLvl + nIncLvl; if( nLevel && nLevel <= MAX_INDENT_LEVEL) { sIndentTabs[nLevel] = 0; - rStr = sIndentTabs; + sRet = sIndentTabs; sIndentTabs[nLevel] = '\t'; } + + return sRet; } void SwHTMLWriter::OutNewLine( sal_Bool bCheck ) diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 9e7fe5e22b20..b96b24e431bc 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -421,7 +421,7 @@ public: void IncIndentLevel() { nIndentLvl++; } void DecIndentLevel() { if ( nIndentLvl ) nIndentLvl--; } - void GetIndentString( ByteString& rStr, sal_uInt16 nIncLvl=0 ); + rtl::OString GetIndentString(sal_uInt16 nIncLvl = 0); xub_StrLen GetLineLen() { return (xub_StrLen)(Strm().Tell()-nLastLFPos); } void OutNewLine( sal_Bool bCheck=sal_False ); |