summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-06-13 00:37:39 +0200
committerMichael Stahl <mstahl@redhat.com>2015-06-19 18:11:14 +0200
commit1bcd54e93245dfaea0a072493d8bab9e569bae93 (patch)
treed70216d2df91583f9c53d83ad7a1d2e33914f815
parent1b5dc145e4e73fb2b8eaab1af3cb18d48048a1f0 (diff)
tdf#88697: sw: make WW8 export of CITATION fields compatible with
... older versions of Word and LO. Based on a prototype patch by Yury <yury.tarasievich@gmail.com> The problem is that Word 2003 does not understand the new CITATION field added in commit 06f7d1a96eef5aa69d4872ff6d96eb5085296d09. Word 2010 does appear to at least recognize it as a field. Also fix the textual field type, which was omitted for CITATION fields, except when the document was imported from DOCX. Change-Id: I62b13a4f585dce535d587555b357ab7e4ef0e460 (cherry picked from commit f56289ac6d7f3da7fd45dd431ce4c540aadcad56)
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 40cfbc7f5d37..c5354b71ca5e 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1828,6 +1828,27 @@ WW8_WrPlcField* WW8Export::CurrentFieldPlc() const
void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
const OUString& rFieldCmd, sal_uInt8 nMode )
{
+ OUString sFieldCmd(rFieldCmd);
+ switch (eFieldType)
+ {
+ // map fields that are not supported in WW8 as of Word 2003
+ case ww::eBIBLIOGRPAHY:
+ eFieldType = ww::eQUOTE;
+ assert(rFieldCmd == FieldString(ww::eBIBLIOGRPAHY));
+ sFieldCmd = FieldString(ww::eQUOTE);
+ break;
+ case ww::eCITATION:
+ eFieldType = ww::eQUOTE;
+ assert(rFieldCmd.startsWith(FieldString(ww::eCITATION)));
+ sFieldCmd = rFieldCmd.replaceFirst(FieldString(ww::eCITATION),
+ FieldString(ww::eQUOTE));
+ break;
+ default:
+ break;
+ }
+
+ assert(eFieldType <= 0x5F); // 95 is the highest documented one
+
bool bUnicode = IsUnicode();
WW8_WrPlcField* pFieldP = CurrentFieldPlc();
@@ -1845,10 +1866,10 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
if (WRITEFIELD_CMD_START & nMode)
{
if (bUnicode)
- SwWW8Writer::WriteString16(Strm(), rFieldCmd, false);
+ SwWW8Writer::WriteString16(Strm(), sFieldCmd, false);
else
{
- SwWW8Writer::WriteString8(Strm(), rFieldCmd, false,
+ SwWW8Writer::WriteString8(Strm(), sFieldCmd, false,
RTL_TEXTENCODING_MS_1252);
}
// #i43956# - write hyperlink character including
@@ -1901,7 +1922,7 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
if( pField )
sOut = lcl_GetExpandedField(*pField);
else
- sOut = rFieldCmd;
+ sOut = sFieldCmd;
if( !sOut.isEmpty() )
{
if( bUnicode )
@@ -2902,8 +2923,15 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
break;
case RES_AUTHORITY:
{
- OUString const sRet(static_cast<SwAuthorityField const*>(pField)
+ OUString sRet(static_cast<SwAuthorityField const*>(pField)
->ExpandCitation(AUTH_FIELD_IDENTIFIER));
+ // FIXME: DomainMapper_Impl::CloseFieldCommand() stuffs fully formed
+ // field instructions in here, but if the field doesn't originate
+ // from those filters it won't have that
+ if (!sRet.trim().startsWith("CITATION"))
+ {
+ sRet = FieldString(ww::eCITATION) + " \"" + sRet + "\"";
+ }
GetExport().OutputField( pField, ww::eCITATION, sRet );
}
break;