diff options
author | Rohit Deshmukh <rohit.deshmukh@synerzip.com> | 2014-02-18 12:23:14 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-26 12:50:29 +0100 |
commit | 598d02d71f40901eab9275704c8bc0e1641b56e3 (patch) | |
tree | 9668886ad71e3566b07dfcfcbd843a8a9ad73624 | |
parent | 2cf9fe702310a2f3d69a543541582ea5fa191d58 (diff) |
fdo#75133: Preseved bibliography after round trip.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
writerfilter/source/dmapper/DomainMapper_Impl.hxx
Reviewed on:
https://gerrit.libreoffice.org/8124
Change-Id: Ieaea19600fbda3b536549a1a100f847f9ae3654b
-rw-r--r-- | sw/inc/toxe.hxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/FDO75133.docx | bin | 0 -> 16659 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/doctxm.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/fields.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/fields.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/inc/cnttab.hxx | 1 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/index/toxmgr.cxx | 25 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 48 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/FieldTypes.hxx | 5 |
16 files changed, 114 insertions, 17 deletions
diff --git a/sw/inc/toxe.hxx b/sw/inc/toxe.hxx index 7de90e2977c7..943a8e65a02b 100644 --- a/sw/inc/toxe.hxx +++ b/sw/inc/toxe.hxx @@ -41,7 +41,8 @@ enum TOXTypes TOX_ILLUSTRATIONS, TOX_OBJECTS, TOX_TABLES, - TOX_AUTHORITIES + TOX_AUTHORITIES, + TOX_BIBLIOGRAPHY }; // this enum contains all types of sources enum ToxAuthorityType diff --git a/sw/qa/extras/ooxmlexport/data/FDO75133.docx b/sw/qa/extras/ooxmlexport/data/FDO75133.docx Binary files differnew file mode 100644 index 000000000000..93170ddc6dc1 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/FDO75133.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 337a69b0528e..4d6e3b787b03 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3715,6 +3715,17 @@ DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_AutoColumn,"alphabeticalIndex_Aut assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr", 0); } +DECLARE_OOXMLEXPORT_TEST(testBibliography,"FDO75133.docx") +{ + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[3]/w:r[2]/w:instrText"); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)); + CPPUNIT_ASSERT(contents.match(" BIBLIOGRAPHY ")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index ad894dfe2b79..6ff26a535f86 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -463,6 +463,7 @@ const SwTOXBase* SwDoc::GetDefaultTOXBase( TOXTypes eTyp, bool bCreate ) case TOX_OBJECTS: prBase = &mpDefTOXBases->pObjBase; break; case TOX_ILLUSTRATIONS: prBase = &mpDefTOXBases->pIllBase; break; case TOX_AUTHORITIES: prBase = &mpDefTOXBases->pAuthBase; break; + case TOX_BIBLIOGRAPHY: prBase = &mpDefTOXBases->pBiblioBase; break; } if(!(*prBase) && bCreate) { @@ -485,6 +486,7 @@ void SwDoc::SetDefaultTOXBase(const SwTOXBase& rBase) case TOX_OBJECTS: prBase = &mpDefTOXBases->pObjBase; break; case TOX_ILLUSTRATIONS: prBase = &mpDefTOXBases->pIllBase; break; case TOX_AUTHORITIES: prBase = &mpDefTOXBases->pAuthBase; break; + case TOX_BIBLIOGRAPHY: prBase = &mpDefTOXBases->pBiblioBase; break; } if(*prBase) delete (*prBase); @@ -1087,7 +1089,9 @@ SwTxtFmtColl* SwTOXBaseSection::GetTxtFmtColl( sal_uInt16 nLevel ) case TOX_ILLUSTRATIONS: nPoolFmt = RES_POOLCOLL_TOX_ILLUSH; break; case TOX_OBJECTS: nPoolFmt = RES_POOLCOLL_TOX_OBJECTH; break; case TOX_TABLES: nPoolFmt = RES_POOLCOLL_TOX_TABLESH; break; - case TOX_AUTHORITIES: nPoolFmt = RES_POOLCOLL_TOX_AUTHORITIESH; break; + case TOX_AUTHORITIES: + case TOX_BIBLIOGRAPHY: + nPoolFmt = RES_POOLCOLL_TOX_AUTHORITIESH; break; case TOX_CONTENT: // There's a jump in the ContentArea! diff --git a/sw/source/core/inc/doctxm.hxx b/sw/source/core/inc/doctxm.hxx index d2e30a95d8bc..65cea1f1b7c3 100644 --- a/sw/source/core/inc/doctxm.hxx +++ b/sw/source/core/inc/doctxm.hxx @@ -100,6 +100,7 @@ struct SwDefTOXBase_Impl SwTOXBase* pObjBase; SwTOXBase* pIllBase; SwTOXBase* pAuthBase; + SwTOXBase* pBiblioBase; SwDefTOXBase_Impl() : pContBase(0), @@ -108,7 +109,8 @@ struct SwDefTOXBase_Impl pTblBase(0), pObjBase(0), pIllBase(0), - pAuthBase(0) + pAuthBase(0), + pBiblioBase(0) { } ~SwDefTOXBase_Impl() @@ -120,6 +122,7 @@ struct SwDefTOXBase_Impl delete pObjBase; delete pIllBase; delete pAuthBase; + delete pBiblioBase; } }; diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 55c0b6f25f85..75a493f3b78b 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -402,6 +402,7 @@ sal_uInt16 SwForm::GetFormMaxLevel( TOXTypes eTOXType ) case TOX_ILLUSTRATIONS: case TOX_OBJECTS : case TOX_TABLES : nRet = 2; break; + case TOX_BIBLIOGRAPHY : case TOX_AUTHORITIES : nRet = AUTH_TYPE_END + 1; break; } return nRet; diff --git a/sw/source/filter/ww8/fields.cxx b/sw/source/filter/ww8/fields.cxx index 039cbf853f12..94777aaa71e3 100644 --- a/sw/source/filter/ww8/fields.cxx +++ b/sw/source/filter/ww8/fields.cxx @@ -126,7 +126,8 @@ namespace ww /*92*/ "BIDIOUTLINE", /*93*/ "ADDRESSBLOCK", /*94*/ "GREETINGLINE", - /*95*/ "SHAPE" + /*95*/ "SHAPE", + /*96*/ "BIBLIOGRAPHY" }; size_t nIndex = static_cast<size_t>(eIndex); diff --git a/sw/source/filter/ww8/fields.hxx b/sw/source/filter/ww8/fields.hxx index d3f8bb0b4035..ce888085c73e 100644 --- a/sw/source/filter/ww8/fields.hxx +++ b/sw/source/filter/ww8/fields.hxx @@ -120,7 +120,8 @@ namespace ww eBIDIOUTLINE = 92, eADDRESSBLOCK = 93, eGREETINGLINE = 94, - eSHAPE = 95 + eSHAPE = 95, + eBIBLIOGRPAHY=96 }; /** Find the English Field Name from a winword index diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 7086f7e873fc..cf876021193e 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2106,7 +2106,6 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) } break; - // case TOX_AUTHORITIES: eCode = eTOA; sStr = ???; break; case TOX_ILLUSTRATIONS: case TOX_OBJECTS: case TOX_TABLES: @@ -2131,6 +2130,10 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) } break; + case TOX_AUTHORITIES: + eCode = ww::eBIBLIOGRPAHY; + sStr = FieldString(eCode); + break; // case TOX_USER: // case TOX_CONTENT: default: diff --git a/sw/source/ui/inc/cnttab.hxx b/sw/source/ui/inc/cnttab.hxx index 7ea8b42e1814..a1a6fae550a3 100644 --- a/sw/source/ui/inc/cnttab.hxx +++ b/sw/source/ui/inc/cnttab.hxx @@ -50,6 +50,7 @@ #define TO_USER 16 #define TO_OBJECT 32 #define TO_AUTHORITIES 64 +#define TO_BIBLIOGRAPHY 128 struct CurTOXType { diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 7906d5382c48..5d7a07b3d5b7 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -959,6 +959,7 @@ static long lcl_TOXTypesToUserData(CurTOXType eType) case TOX_OBJECTS : nRet = TO_OBJECT; break; case TOX_TABLES : nRet = TO_TABLE; break; case TOX_AUTHORITIES : nRet = TO_AUTHORITIES; break; + case TOX_BIBLIOGRAPHY : nRet = TO_BIBLIOGRAPHY; break; } return nRet; } @@ -992,6 +993,7 @@ static CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData) case TO_OBJECT : eRet.eType = TOX_OBJECTS; break; case TO_TABLE : eRet.eType = TOX_TABLES; break; case TO_AUTHORITIES : eRet.eType = TOX_AUTHORITIES; break; + case TO_BIBLIOGRAPHY : eRet.eType = TOX_BIBLIOGRAPHY; break; default: OSL_FAIL("what a type?"); } return eRet; @@ -1186,6 +1188,7 @@ void SwTOXSelectTabPage::FillTOXDescription() } break; case TOX_AUTHORITIES: + case TOX_BIBLIOGRAPHY : { if(m_pBracketLB->GetSelectEntryPos()) rDesc.SetAuthBrackets(m_pBracketLB->GetSelectEntry()); diff --git a/sw/source/ui/index/toxmgr.cxx b/sw/source/ui/index/toxmgr.cxx index abc2e370c280..4336fbf2c8fe 100644 --- a/sw/source/ui/index/toxmgr.cxx +++ b/sw/source/ui/index/toxmgr.cxx @@ -129,6 +129,30 @@ void SwTOXMgr::InsertTOXMark(const SwTOXMarkDescription& rDesc) pMark->SetAlternativeText(*rDesc.GetAltStr()); } break; + case TOX_BIBLIOGRAPHY: + { + pMark = new SwTOXMark(pSh->GetTOXType(TOX_BIBLIOGRAPHY, 0)); + + if( rDesc.GetPrimKey() && !rDesc.GetPrimKey()->isEmpty() ) + { + pMark->SetPrimaryKey( *rDesc.GetPrimKey() ); + if(rDesc.GetPhoneticReadingOfPrimKey()) + pMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() ); + + if( rDesc.GetSecKey() && !rDesc.GetSecKey()->isEmpty() ) + { + pMark->SetSecondaryKey( *rDesc.GetSecKey() ); + if(rDesc.GetPhoneticReadingOfSecKey()) + pMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() ); + } + } + if(rDesc.GetAltStr()) + pMark->SetAlternativeText(*rDesc.GetAltStr()); + if(rDesc.GetPhoneticReadingOfAltStr()) + pMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() ); + pMark->SetMainEntry(rDesc.IsMainEntry()); + } + break; default:; //prevent warning } pSh->StartAllAction(); @@ -352,6 +376,7 @@ sal_Bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc, case TOX_OBJECTS: case TOX_TABLES: case TOX_AUTHORITIES: + case TOX_BIBLIOGRAPHY: case TOX_ILLUSTRATIONS: { //Special handling for TOX_AUTHORITY diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c4e3a9f6f163..d5f251765efb 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2459,7 +2459,7 @@ void DomainMapper::data(const sal_uInt8* /*buf*/, size_t /*len*/, void DomainMapper::lcl_startSectionGroup() { - if (!m_pImpl->isInIndexContext()) + if (!m_pImpl->isInIndexContext() || !m_pImpl->isInBibliographyContext()) { m_pImpl->PushProperties(CONTEXT_SECTION); } @@ -2467,7 +2467,7 @@ void DomainMapper::lcl_startSectionGroup() void DomainMapper::lcl_endSectionGroup() { - if (!m_pImpl->isInIndexContext()) + if (!m_pImpl->isInIndexContext() || !m_pImpl->isInBibliographyContext()) { m_pImpl->CheckUnregisteredFrameConversion(); m_pImpl->ExecuteFrameConversion(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0d98781f5fa4..6e4d439a2204 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -148,6 +148,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bStartTOC(false), m_bStartedTOC(false), m_bStartIndex(false), + m_bStartBibliography(false), m_bTOCPageRef(false), m_pLastSectionContext( ), m_pLastCharacterContext(), @@ -174,6 +175,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_aAnnotationPositions(), m_xInsertTextRange(xInsertTextRange), m_bIsNewDoc(bIsNewDoc), + m_bBibliographyMarkerAdded(false), m_bInTableStyleRunProps(false), m_pSdtHelper(0), m_nTableDepth(0), @@ -1125,7 +1127,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP uno::Sequence< beans::PropertyValue > pValues = pPropertyMap->GetPropertyValues(/*bCharGrabBag=*/!m_bIsInComments); sal_Int32 len = pValues.getLength(); - if (m_bStartTOC || m_bStartIndex) + if (m_bStartTOC || m_bStartIndex || m_bStartBibliography) for( int i =0; i < len; ++i ) { if (pValues[i].Name == "CharHidden") @@ -1140,7 +1142,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP } else { - if (m_bStartTOC || m_bStartIndex) + if (m_bStartTOC || m_bStartIndex || m_bStartBibliography) { m_bStartedTOC = true; uno::Reference< text::XTextCursor > xTOCTextCursor; @@ -1148,7 +1150,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP xTOCTextCursor->gotoEnd(false); if (xTOCTextCursor.is()) { - if (m_bStartIndex) + if (m_bStartIndex || m_bStartBibliography) xTOCTextCursor->goLeft(1, false); xTextRange = xTextAppend->insertTextPortion(rString, pValues, xTOCTextCursor); xTOCTextCursor->gotoRange(xTextRange->getEnd(), true); @@ -2289,6 +2291,7 @@ if(!bFilled) {OUString("NUMPAGES"), "PageCount", "", FIELD_NUMPAGES}, {OUString("INDEX"), "com.sun.star.text.DocumentIndex", "", FIELD_INDEX}, {OUString("XE"), "com.sun.star.text.DocumentIndexMark", "", FIELD_XE}, + {OUString("BIBLIOGRAPHY"), "com.sun.star.text.Bibliography", "", FILED_BIBLIOGRAPHY}, // {OUString(""), "", "", FIELD_}, @@ -2826,6 +2829,29 @@ void DomainMapper_Impl::handleToc } } } + +void DomainMapper_Impl::handleBibliography + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + const OUString & sTOCServiceName) +{ + uno::Reference< beans::XPropertySet > xTOC; + m_bStartTOC = true; + m_bStartBibliography = true; + if (m_xTextFactory.is()) + xTOC.set( + m_xTextFactory->createInstance( + sTOCServiceName), + uno::UNO_QUERY_THROW); + if (xTOC.is()) + xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString())); + + pContext->SetTOC( xTOC ); + + uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY ); + appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() ); +} + void DomainMapper_Impl::handleIndex (FieldContextPtr pContext, PropertyNameSupplier& rPropNameSupplier, @@ -2901,6 +2927,7 @@ void DomainMapper_Impl::CloseFieldCommand() case FIELD_TOC: case FIELD_INDEX: case FIELD_XE: + case FILED_BIBLIOGRAPHY: case FIELD_TC: case FIELD_EQ: bCreateField = false; @@ -3386,6 +3413,10 @@ void DomainMapper_Impl::CloseFieldCommand() handleIndex(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties, OUString::createFromAscii(aIt->second.cFieldServiceName)); break; + case FILED_BIBLIOGRAPHY: + handleBibliography(pContext, rPropNameSupplier, + OUString::createFromAscii(aIt->second.cFieldServiceName)); + break; case FIELD_TOC: handleToc(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties, OUString::createFromAscii(aIt->second.cFieldServiceName)); @@ -3597,9 +3628,9 @@ void DomainMapper_Impl::PopFieldContext() uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY ); if( xToInsert.is() ) { - if(xTOCMarkerCursor.is() || m_bStartIndex) + if(xTOCMarkerCursor.is() || m_bStartIndex || m_bStartBibliography) { - if (m_bStartIndex) + if (m_bStartIndex || m_bStartBibliography) { if (mxTOCTextCursor.is()) { @@ -3616,20 +3647,21 @@ void DomainMapper_Impl::PopFieldContext() xTOCMarkerCursor->setString(OUString()); } } - if (m_bStartedTOC || m_bStartIndex) + if (m_bStartedTOC || m_bStartIndex || m_bStartBibliography) { m_bStartedTOC = false; m_aTextAppendStack.pop(); } m_bStartTOC = false; m_bStartIndex = false; + m_bStartBibliography = false; } else { xToInsert = uno::Reference< text::XTextContent >(pContext->GetTC(), uno::UNO_QUERY); - if( !xToInsert.is() && !m_bStartTOC && !m_bStartIndex ) + if( !xToInsert.is() && !m_bStartTOC && !m_bStartIndex && !m_bStartBibliography ) xToInsert = uno::Reference< text::XTextContent >(pContext->GetTextField(), uno::UNO_QUERY); - if( xToInsert.is() && !m_bStartTOC && !m_bStartIndex) + if( xToInsert.is() && !m_bStartTOC && !m_bStartIndex && !m_bStartBibliography) { uno::Sequence<beans::PropertyValue> aValues; // Character properties of the field show up here the diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 758dcaa5a9b6..b53cd341d455 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -316,6 +316,7 @@ private: /// If we got any text that is the pre-rendered result of the TOC field. bool m_bStartedTOC; bool m_bStartIndex; + bool m_bStartBibliography; bool m_bTOCPageRef; LineNumberSettings m_aLineNumberSettings; @@ -402,6 +403,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xInsertTextRange; private: bool m_bIsNewDoc; + bool m_bBibliographyMarkerAdded; public: DomainMapper_Impl( DomainMapper& rDMapper, @@ -590,6 +592,11 @@ public: uno::Reference< uno::XInterface > & xFieldInterface, uno::Reference< beans::XPropertySet > xFieldProperties, const OUString & sTOCServiceName); + + void handleBibliography + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + const OUString & sTOCServiceName); //the field command has to be closed (0x14 appeared) void CloseFieldCommand(); //the _current_ fields require a string type result while TOCs accept richt results @@ -755,6 +762,7 @@ public: /// ST_PositivePercentage values we received std::queue<OUString> m_aPositivePercentages; bool isInIndexContext() { return m_bStartIndex;} + bool isInBibliographyContext() { return m_bStartBibliography;} private: void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); diff --git a/writerfilter/source/dmapper/FieldTypes.hxx b/writerfilter/source/dmapper/FieldTypes.hxx index e61e31e04eea..2a54dfea2da6 100644 --- a/writerfilter/source/dmapper/FieldTypes.hxx +++ b/writerfilter/source/dmapper/FieldTypes.hxx @@ -293,7 +293,10 @@ enum FieldId /* Document alphabetical index marks */ ,FIELD_XE - + /** + * Bibliography + */ + ,FILED_BIBLIOGRAPHY }; }} |