summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogeshBharate <yogesh.bharate@synerzip.com>2014-04-04 15:56:03 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-04-10 08:15:54 +0000
commita7bc9c1e4977bd3430df69287fa0a8377a686c58 (patch)
treefa9ebadf62faeaf12f63381115be1cca3e3e74ca
parent1d25e1de0b9498e469cb052b2d86bf7f7ae6adae (diff)
fdo#77051: Preservation of Index field flag '\f'.
Problem Description: - In LibreOffice, the index field flag '\f' was not getting preserved after roundtrip as there was no support for it. - '\f' field flag is used for Specific Entry Type. ex. In our case it is "Syn" Implementation: - Provided import & export support for Index field flag '\f' and added UT for the same. Change-Id: I97c2456dd73c8bdf89ab105f8cac71bf7e2ad164 Reviewed-on: https://gerrit.libreoffice.org/8839 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/inc/tox.hxx19
-rw-r--r--sw/inc/unomap.hxx1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docxbin0 -> 15781 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx11
-rw-r--r--sw/source/core/tox/tox.cxx7
-rw-r--r--sw/source/core/unocore/unoidx.cxx25
-rw-r--r--sw/source/core/unocore/unomap.cxx1
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx8
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
12 files changed, 86 insertions, 0 deletions
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index 360f1d44b383..859374fc29af 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -67,6 +67,7 @@ class SW_DLLPUBLIC SwTOXMark
sal_uInt16 nLevel;
OUString m_aBookmarkName;
+ OUString m_aEntryTypeName; // stored specific entry type name for INDEX field \f
sal_Bool bAutoGenerated : 1; // generated using a concordance file
sal_Bool bMainEntry : 1; // main entry emphasized by character style
@@ -107,6 +108,8 @@ public:
inline sal_uInt16 GetLevel() const;
inline void SetBookmarkName( const OUString& bName);
inline OUString GetBookmarkName() const;
+ inline void SetEntryTypeName( const OUString& sName);
+ inline OUString GetEntryTypeName() const;
// for alphabetical index only
inline void SetPrimaryKey(const OUString& rStr );
@@ -394,6 +397,7 @@ namespace nsSwTOXElement
const SwTOXElement TOX_BOOKMARK = 1024;
const SwTOXElement TOX_NEWLINE = 2048;
const SwTOXElement TOX_PARAGRAPH_OUTLINE_LEVEL = 4096;
+ const SwTOXElement TOX_INDEX_ENTRY_TYPE = 8192;
}
typedef sal_uInt16 SwTOIOptions;
@@ -438,6 +442,7 @@ class SW_DLLPUBLIC SwTOXBase : public SwClient
OUString aName; // unique name
OUString aTitle; // title
OUString m_aBookmarkName; //Bookmark Name
+ OUString m_aEntryTypeName; // Type name
OUString sMainEntryCharStyle; // name of the character style applied to main index entries
@@ -507,6 +512,10 @@ public:
OUString GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
void SetMainEntryCharStyle(const OUString& rSet) {sMainEntryCharStyle = rSet;}
+ // for record the Index field expression of MS Word
+ OUString GetEntryTypeName() const;
+ void SetEntryTypeName(const OUString& sName);
+
// content index only
inline void SetLevel(sal_uInt16); // consider outline level
inline sal_uInt16 GetLevel() const;
@@ -584,6 +593,9 @@ inline OUString SwTOXMark::GetAlternativeText() const
inline OUString SwTOXMark::GetBookmarkName() const
{ return m_aBookmarkName; }
+inline OUString SwTOXMark::GetEntryTypeName() const
+ { return m_aEntryTypeName; }
+
inline const SwTOXType* SwTOXMark::GetTOXType() const
{ return (SwTOXType*)GetRegisteredIn(); }
@@ -600,6 +612,10 @@ inline void SwTOXMark::SetBookmarkName(const OUString& bName)
m_aBookmarkName = bName;
}
+inline void SwTOXMark::SetEntryTypeName(const OUString& sName)
+{
+ m_aEntryTypeName = sName;
+}
inline void SwTOXMark::SetLevel( sal_uInt16 nLvl )
{
SAL_WARN_IF( GetTOXType() && GetTOXType()->GetType() == TOX_INDEX, "sw", "Wrong type");
@@ -730,6 +746,9 @@ inline OUString SwTOXBase::GetTitle() const
inline OUString SwTOXBase::GetBookmarkName() const
{ return m_aBookmarkName; }
+inline OUString SwTOXBase::GetEntryTypeName() const
+ { return m_aEntryTypeName; }
+
inline OUString SwTOXBase::GetTypeName() const
{ return GetTOXType()->GetTypeName(); }
diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx
index 93c3fc5a7f95..cdd60de72939 100644
--- a/sw/inc/unomap.hxx
+++ b/sw/inc/unomap.hxx
@@ -220,6 +220,7 @@
#define WID_TOC_BOOKMARK 1061
#define WID_TOC_NEWLINE 1062
#define WID_TOC_PARAGRAPH_OUTLINE_LEVEL 1063
+#define WID_INDEX_ENTRY_TYPE 1064
// Text document
#define WID_DOC_CHAR_COUNT 1000
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index be90c9dd37b6..63dfe4abaa32 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -531,6 +531,7 @@
#define UNO_NAME_FOOTER_USER_DEFINED_ATTRIBUTES "FooterUserDefinedAttributes"
#define UNO_NAME_PARA_SHADOW_FORMAT "ParaShadowFormat"
#define UNO_NAME_CONTOUR_POLY_POLYGON "ContourPolyPolygon"
+#define UNO_NAME_INDEX_ENTRY_TYPE "IndexEntryType"
#define UNO_NAME_IS_PIXEL_CONTOUR "IsPixelContour"
#define UNO_NAME_IS_AUTOMATIC_CONTOUR "IsAutomaticContour"
diff --git a/sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docx b/sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docx
new file mode 100644
index 000000000000..2c7d36527111
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index aa48fda87959..2d184538cfbf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2660,6 +2660,17 @@ DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_AutoColumn,"alphabeticalIndex_Aut
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr", 0);
}
+DECLARE_OOXMLEXPORT_TEST(testIndexFieldFlagF,"IndexFieldFlagF.docx")
+{
+ // This test case is to verify the Index field flag '\f' with some
+ // Specific Entry Type (ex. "Syn" in our case).
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ // We check the Index field flag '\f'.
+ assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[4]/w:r[2]/w:instrText[1]", " INDEX \\c \"2\"\\f \"Syn\" \" \\e \"");
+}
+
DECLARE_OOXMLEXPORT_TEST(testBibliography,"FDO75133.docx")
{
xmlDocPtr pXmlDoc = parseExport();
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 1fac01fe4771..4567345e9acb 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -533,6 +533,7 @@ SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource )
aTitle = rSource.aTitle;
aForm = rSource.aForm;
m_aBookmarkName = rSource.m_aBookmarkName;
+ m_aEntryTypeName = rSource.m_aEntryTypeName ;
bProtected = rSource.bProtected;
bFromChapter = rSource.bFromChapter;
bFromObjectNames = rSource.bFromObjectNames;
@@ -576,12 +577,18 @@ void SwTOXBase::SetBookmarkName(const OUString& bName)
m_aBookmarkName = bName;
}
+void SwTOXBase::SetEntryTypeName(const OUString& sName)
+{
+ m_aEntryTypeName = sName ;
+}
+
SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
{
aForm = rSource.aForm;
aName = rSource.aName;
aTitle = rSource.aTitle;
m_aBookmarkName = rSource.m_aBookmarkName;
+ m_aEntryTypeName = rSource.m_aEntryTypeName ;
sMainEntryCharStyle = rSource.sMainEntryCharStyle;
for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
aStyleNames[nLevel] = rSource.aStyleNames[nLevel];
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 2a1722152f4f..7d0787e373d3 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -656,6 +656,13 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
rTOXBase.SetCreate(nCreate);
}
break;
+ case WID_INDEX_ENTRY_TYPE:
+ {
+ rTOXBase.SetEntryTypeName(lcl_AnyToString(rValue));
+ nCreate = nsSwTOXElement::TOX_INDEX_ENTRY_TYPE;
+ rTOXBase.SetCreate(nCreate);
+ }
+ break;
case WID_CREATE_FROM_MARKS:
lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK);
break;
@@ -977,6 +984,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
case WID_TOC_BOOKMARK :
aRet <<= OUString(pTOXBase->GetBookmarkName());
break;
+ case WID_INDEX_ENTRY_TYPE :
+ aRet <<= OUString(pTOXBase->GetEntryTypeName());
+ break;
case WID_CREATE_FROM_MARKS:
lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK);
break;
@@ -1547,6 +1557,7 @@ public:
sal_Bool m_bMainEntry;
sal_uInt16 m_nLevel;
OUString m_aBookmarkName;
+ OUString m_aEntryTypeName;
OUString m_sAltText;
OUString m_sPrimaryKey;
OUString m_sSecondaryKey;
@@ -2151,6 +2162,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case WID_TOC_BOOKMARK :
aMark.SetBookmarkName(lcl_AnyToString(rValue));
break;
+ case WID_INDEX_ENTRY_TYPE :
+ aMark.SetEntryTypeName(lcl_AnyToString(rValue));
+ break;
case WID_PRIMARY_KEY :
aMark.SetPrimaryKey(lcl_AnyToString(rValue));
break;
@@ -2210,6 +2224,11 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
m_pImpl->m_aBookmarkName = lcl_AnyToString(rValue);
}
break;
+ case WID_INDEX_ENTRY_TYPE :
+ {
+ m_pImpl->m_aEntryTypeName = lcl_AnyToString(rValue);
+ }
+ break;
case WID_PRIMARY_KEY:
m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue);
break;
@@ -2289,6 +2308,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
case WID_TOC_BOOKMARK :
aRet <<= OUString(m_pImpl->m_pTOXMark->GetBookmarkName());
break;
+ case WID_INDEX_ENTRY_TYPE :
+ aRet <<= OUString(m_pImpl->m_pTOXMark->GetEntryTypeName());
+ break;
case WID_PRIMARY_KEY :
aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey());
break;
@@ -2333,6 +2355,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
case WID_TOC_BOOKMARK :
aRet <<= m_pImpl->m_aBookmarkName;
break;
+ case WID_INDEX_ENTRY_TYPE :
+ aRet <<= m_pImpl->m_aEntryTypeName;
+ break;
case WID_PRIMARY_KEY:
aRet <<= m_pImpl->m_sPrimaryKey;
break;
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index efe34b1f5d0c..660d8effa623 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1454,6 +1454,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ OUString(UNO_NAME_IS_RELATIVE_TABSTOPS), WID_IS_RELATIVE_TABSTOPS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_LOCALE), WID_IDX_LOCALE, cppu::UnoType<css::lang::Locale>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_SORT_ALGORITHM), WID_IDX_SORT_ALGORITHM, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
+ { OUString(UNO_NAME_INDEX_ENTRY_TYPE), WID_INDEX_ENTRY_TYPE, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0},
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
aMapEntriesArr[nPropertyId] = aTOXIndexMap_Impl;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5579be46be7c..839d70cb0565 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2132,6 +2132,17 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
sStr += "\\h \"A\" ";
+ if(nsSwTOXElement::TOX_INDEX_ENTRY_TYPE & pTOX->GetCreateType())
+ {
+ sStr += "\\f ";
+ OUString sName = pTOX->GetEntryTypeName();
+ if(!sName.isEmpty())
+ {
+ sStr += sName;
+ sStr += sEntryEnd;
+ }
+ }
+
if (!pTOX->GetTOXForm().IsCommaSeparated())
{
// In case of Run-in style no separators are added.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index e9b350c25d0d..68926652b9b4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2984,6 +2984,8 @@ void DomainMapper_Impl::handleIndex
m_bStartTOC = true;
m_bStartIndex = true;
OUString sValue;
+ OUString sIndexEntryType = "I"; // Default value for field flag '\f' is 'I'.
+
if (m_xTextFactory.is())
xTOC.set(
@@ -3002,6 +3004,12 @@ void DomainMapper_Impl::handleIndex
{
xTOC->setPropertyValue("UseAlphabeticalSeparators", uno::makeAny(true));
}
+ if( lcl_FindInCommand( pContext->GetCommand(), 'f', sValue ))
+ {
+ if(!sValue.isEmpty())
+ sIndexEntryType = sValue ;
+ xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_INDEX_ENTRY_TYPE ), uno::makeAny(sIndexEntryType));
+ }
}
pContext->SetTOC( xTOC );
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 1aa4252a21f8..ac7fc4364c32 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -388,6 +388,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_CHAR_STYLISTICSETS_TEXT_EFFECT : sName = "CharStylisticSetsTextEffect"; break;
case PROP_CHAR_CNTXTALTS_TEXT_EFFECT : sName = "CharCntxtAltsTextEffect"; break;
case PROP_SDTPR : sName = "SdtPr"; break;
+ case PROP_INDEX_ENTRY_TYPE : sName = "IndexEntryType"; break;
case PROP_CELL_INTEROP_GRAB_BAG : sName = "CellInteropGrabBag"; break;
case PROP_TABLE_INTEROP_GRAB_BAG : sName = "TableInteropGrabBag"; break;
}
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 88d1c89587c7..9153c29e9960 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -362,6 +362,7 @@ enum PropertyIds
,PROP_SDTPR
,PROP_CELL_INTEROP_GRAB_BAG
,PROP_TABLE_INTEROP_GRAB_BAG
+ ,PROP_INDEX_ENTRY_TYPE
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier