[Libreoffice-commits] core.git: sw/inc sw/qa sw/source writerfilter/source

YogeshBharate yogesh.bharate at synerzip.com
Thu Apr 10 01:16:21 PDT 2014


 sw/inc/tox.hxx                                     |   19 +++++++++++++++
 sw/inc/unomap.hxx                                  |    1 
 sw/inc/unoprnms.hxx                                |    1 
 sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |   11 +++++++++
 sw/source/core/tox/tox.cxx                         |    7 +++++
 sw/source/core/unocore/unoidx.cxx                  |   25 +++++++++++++++++++++
 sw/source/core/unocore/unomap.cxx                  |    1 
 sw/source/filter/ww8/ww8atr.cxx                    |   11 +++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |    8 ++++++
 writerfilter/source/dmapper/PropertyIds.cxx        |    1 
 writerfilter/source/dmapper/PropertyIds.hxx        |    1 
 12 files changed, 86 insertions(+)

New commits:
commit a7bc9c1e4977bd3430df69287fa0a8377a686c58
Author: YogeshBharate <yogesh.bharate at synerzip.com>
Date:   Fri Apr 4 15:56:03 2014 +0530

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index 360f1d4..859374f 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 93c3fc5..cdd60de 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 be90c9d..63dfe4a 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 0000000..2c7d365
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/IndexFieldFlagF.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index aa48fda..2d18453 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 1fac01f..4567345 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 2a17221..7d0787e 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 efe34b1..660d8ef 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 5579be4..839d70c 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 e9b350c..6892665 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 1aa4252..ac7fc43 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 88d1c89..9153c29 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


More information about the Libreoffice-commits mailing list