summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-06-19 13:55:12 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-06-22 12:14:53 +0000
commita99a8aa1f6ec95a578a34f92aeab3523f090176b (patch)
tree3267925c742195b9cd96c17c0613dff6c60d4d04 /sw/source/filter
parentbe0f5f5b66c55081849250ffad9f600cd61a00a1 (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. (cherry picked from commit f56289ac6d7f3da7fd45dd431ce4c540aadcad56) (cherry picked from commit 1bcd54e93245dfaea0a072493d8bab9e569bae93) Conflicts: sw/source/filter/ww8/ww8atr.cxx sw: remove the SwField::ExpandCitation disaster (cherry picked from commit 8ee3cb95638f25fea8dc85e2dc5eec89ea41fc38) (cherry picked from commit 1b5dc145e4e73fb2b8eaab1af3cb18d48048a1f0) Conflicts: sw/source/filter/ww8/ww8atr.cxx Change-Id: I62b13a4f585dce535d587555b357ab7e4ef0e460 Reviewed-on: https://gerrit.libreoffice.org/16410 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx4
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx37
2 files changed, 36 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 873d0f986ad2..8d378218646e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -91,6 +91,7 @@
#include <svl/whiter.hxx>
#include <docufld.hxx>
+#include <authfld.hxx>
#include <flddropdown.hxx>
#include <fmtclds.hxx>
#include <fmtinfmt.hxx>
@@ -1540,7 +1541,8 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
OUString sExpand;
if(rInfos.eType == ww::eCITATION)
{
- sExpand = rInfos.pField->ExpandCitation(AUTH_FIELD_TITLE);
+ sExpand = static_cast<SwAuthorityField const*>(rInfos.pField)
+ ->ExpandCitation(AUTH_FIELD_TITLE);
}
else
{
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index ea6998fb0fef..ce9ca5ef6f56 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1864,6 +1864,27 @@ WW8_WrPlcFld* WW8Export::CurrentFieldPlc() const
void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType,
const OUString& rFldCmd, sal_uInt8 nMode )
{
+ OUString sFieldCmd(rFldCmd);
+ switch (eFldType)
+ {
+ // map fields that are not supported in WW8 as of Word 2003
+ case ww::eBIBLIOGRPAHY:
+ eFldType = ww::eQUOTE;
+ assert(rFldCmd == FieldString(ww::eBIBLIOGRPAHY));
+ sFieldCmd = FieldString(ww::eQUOTE);
+ break;
+ case ww::eCITATION:
+ eFldType = ww::eQUOTE;
+ assert(rFldCmd.startsWith(FieldString(ww::eCITATION)));
+ sFieldCmd = rFldCmd.replaceFirst(FieldString(ww::eCITATION),
+ FieldString(ww::eQUOTE));
+ break;
+ default:
+ break;
+ }
+
+ assert(eFldType <= 0x5F); // 95 is the highest documented one
+
bool bUnicode = IsUnicode();
WW8_WrPlcFld* pFldP = CurrentFieldPlc();
@@ -1881,10 +1902,10 @@ void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType,
if (WRITEFIELD_CMD_START & nMode)
{
if (bUnicode)
- SwWW8Writer::WriteString16(Strm(), rFldCmd, false);
+ SwWW8Writer::WriteString16(Strm(), sFieldCmd, false);
else
{
- SwWW8Writer::WriteString8(Strm(), rFldCmd, false,
+ SwWW8Writer::WriteString8(Strm(), sFieldCmd, false,
RTL_TEXTENCODING_MS_1252);
}
// #i43956# - write hyperlink character including
@@ -1937,7 +1958,7 @@ void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType,
if( pFld )
sOut = lcl_GetExpandedField(*pFld);
else
- sOut = rFldCmd;
+ sOut = sFieldCmd;
if( !sOut.isEmpty() )
{
if( bUnicode )
@@ -2937,7 +2958,15 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
break;
case RES_AUTHORITY:
{
- OUString sRet(pFld->ExpandCitation(AUTH_FIELD_IDENTIFIER));
+ OUString sRet(static_cast<SwAuthorityField const*>(pFld)
+ ->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( pFld, ww::eCITATION, sRet );
}
break;