[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Fri Jun 19 07:30:43 PDT 2015
sw/inc/authfld.hxx | 2 -
sw/inc/fldbas.hxx | 2 -
sw/source/core/fields/fldbas.cxx | 6 ----
sw/source/filter/ww8/docxattributeoutput.cxx | 4 ++
sw/source/filter/ww8/ww8atr.cxx | 37 ++++++++++++++++++++++++---
5 files changed, 37 insertions(+), 14 deletions(-)
New commits:
commit f56289ac6d7f3da7fd45dd431ce4c540aadcad56
Author: Michael Stahl <mstahl at redhat.com>
Date: Sat Jun 13 00:37:39 2015 +0200
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 at 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
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 616de7b..e669d79 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;
commit 8ee3cb95638f25fea8dc85e2dc5eec89ea41fc38
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jun 19 13:55:12 2015 +0200
sw: remove the SwField::ExpandCitation disaster
Change-Id: I3adf4182ad77bfd1af3737f640e9d3fe6db5dfc9
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx
index 11ce33e..73e1d09 100644
--- a/sw/inc/authfld.hxx
+++ b/sw/inc/authfld.hxx
@@ -155,7 +155,7 @@ public:
OUString ConditionalExpand(ToxAuthorityField eField) const;
//To handle Citation
- OUString ExpandCitation(ToxAuthorityField eField) const;
+ SW_DLLPUBLIC OUString ExpandCitation(ToxAuthorityField eField) const;
SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents);
SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle);
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 7447fdb..6406fae 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -319,8 +319,6 @@ public:
*/
OUString ExpandField(bool const bCached, ToxAuthorityField eField = AUTH_FIELD_IDENTIFIER) const;
- OUString ExpandCitation(ToxAuthorityField eField = AUTH_FIELD_IDENTIFIER) const;
-
/// @return name or content.
virtual OUString GetFieldName() const;
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 7f02e0a..40b96c2 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -435,12 +435,6 @@ OUString SwField::ExpandField(bool const bCached, ToxAuthorityField eField) cons
return Expand();
}
-OUString SwField::ExpandCitation(ToxAuthorityField eField) const
-{
- const SwAuthorityField* pAuthorityField = static_cast<const SwAuthorityField*>(this);
- return (pAuthorityField ? pAuthorityField->ExpandCitation(eField) : OUString());
-}
-
SwField * SwField::CopyField() const
{
SwField *const pNew = Copy();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 577fb3f..5211c1b 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>
@@ -1564,7 +1565,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.get())
+ ->ExpandCitation(AUTH_FIELD_TITLE);
}
else
{
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 37f2a10..616de7b 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2902,7 +2902,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
break;
case RES_AUTHORITY:
{
- OUString sRet(pField->ExpandCitation(AUTH_FIELD_IDENTIFIER));
+ OUString const sRet(static_cast<SwAuthorityField const*>(pField)
+ ->ExpandCitation(AUTH_FIELD_IDENTIFIER));
GetExport().OutputField( pField, ww::eCITATION, sRet );
}
break;
More information about the Libreoffice-commits
mailing list