diff options
author | Sourav <sourav.mahajan@synerzip.com> | 2014-06-25 12:32:59 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-11 10:12:42 +0200 |
commit | f021524aadfe1aa1a07f4600bcb89e7c69ccfdb0 (patch) | |
tree | 9ecf35893d8163b084be35b4e643cc98206a3c3c | |
parent | 17ec028be46545c7d67742d7fafe38926fb2dbd5 (diff) |
fdo#76279 Invalid Citation on RoundTrip
Reviewed on:
https://gerrit.libreoffice.org/9898
Change-Id: Idfe39761180ae1eeb0066ae3aac13de6ac6df0b9
-rw-r--r-- | sw/inc/authfld.hxx | 3 | ||||
-rw-r--r-- | sw/inc/fldbas.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/fields/authfld.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/fields/fldbas.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 |
8 files changed, 41 insertions, 15 deletions
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx index e2b006be4449..6e3926b72b73 100644 --- a/sw/inc/authfld.hxx +++ b/sw/inc/authfld.hxx @@ -153,6 +153,9 @@ public: /// For internal use only, in general continue using ExpandField() instead. OUString ConditionalExpand(ToxAuthorityField eField) const; + //To handle Citation + OUString ExpandCitation(ToxAuthorityField eField) const; + SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents); SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle); virtual ~SwAuthorityField(); diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 0d1724f542e3..f6893e8ed700 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -319,6 +319,8 @@ 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/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 4c48e95efb12..76c3fb982ce1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3000,14 +3000,8 @@ DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx") xmlDocPtr pXmlDoc = parseExport(); if (!pXmlDoc) return; - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc,"/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT(pXmlNodes != 0); - CPPUNIT_ASSERT(pXmlNodes->nodeNr > 0); - xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; - OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)); - CPPUNIT_ASSERT(contents.match(" CITATION [Kra06]")); - xmlXPathFreeObject(pXmlObj); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText", " CITATION Kra06 \\l 1033 "); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[5]/w:t", "(Kramer & Chen, 2006)"); } DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx") diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 4cfaf6aa1aa8..2eff387c12a6 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -569,6 +569,28 @@ OUString SwAuthorityField::ConditionalExpand(ToxAuthorityField eField) const return sRet; } +OUString SwAuthorityField::ExpandCitation(ToxAuthorityField eField) const +{ + SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); + OUString sRet; + + if( pAuthType->IsSequence() ) + { + if(!pAuthType->GetDoc()->IsExpFldsLocked()) + m_nTempSequencePos = pAuthType->GetSequencePos( m_nHandle ); + if( m_nTempSequencePos >= 0 ) + sRet += OUString::number( m_nTempSequencePos ); + } + else + { + const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle(m_nHandle); + //TODO: Expand to: identifier, number sequence, ... + if(pEntry) + sRet += pEntry->GetAuthorField(eField); + } + return sRet; +} + SwField* SwAuthorityField::Copy() const { SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 90600e2edf9e..0827a7f3630c 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -405,6 +405,12 @@ 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 168fa9de5a45..b6d64afee0ed 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1430,7 +1430,7 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos ) OUString sExpand; if(rInfos.eType == ww::eCITATION) { - sExpand = rInfos.pField->ExpandField( false , AUTH_FIELD_TITLE); + sExpand = rInfos.pField->ExpandCitation(AUTH_FIELD_TITLE); } else { diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 83fd5d86fb1e..44c433cca14b 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2923,9 +2923,8 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField ) break; case RES_AUTHORITY: { - const OUString sStr = " CITATION " - + lcl_GetExpandedField(*pFld); - GetExport().OutputField( pFld, ww::eCITATION, sStr ); + OUString sRet(pFld->ExpandCitation(AUTH_FIELD_IDENTIFIER)); + GetExport().OutputField( pFld, ww::eCITATION, sRet ); } break; case RES_POSTITFLD: diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index edd30e548b08..e74383ee4629 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3801,12 +3801,12 @@ void DomainMapper_Impl::CloseFieldCommand() OUString::createFromAscii(aIt->second.cFieldServiceName)); uno::Reference< beans::XPropertySet > xTC(xFieldInterface, uno::UNO_QUERY_THROW); - - if( !sFirstParam.isEmpty()){ + OUString sCmd(pContext->GetCommand());//sCmd is the entire instrText inclusing the index e.g. CITATION Kra06 \l 1033 + if( !sCmd.isEmpty()){ uno::Sequence<com::sun::star::beans::PropertyValue> aValues(1); com::sun::star::beans::PropertyValue propertyVal; propertyVal.Name = "Identifier"; - propertyVal.Value = uno::makeAny(sFirstParam); + propertyVal.Value = uno::makeAny(sCmd); aValues[0] = propertyVal; xTC->setPropertyValue("Fields", uno::makeAny(aValues)); |