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

Pallavi Jadhav pallavi.jadhav at synerzip.com
Fri Jul 18 01:06:47 PDT 2014


 sw/qa/extras/ooxmlexport/data/fdo80800.docx              |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                 |   15 +++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx             |   13 ++++++++-----
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    9 ---------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx        |    7 -------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx        |    5 -----
 6 files changed, 23 insertions(+), 26 deletions(-)

New commits:
commit a5f9fb720daeb2df8325768b98b8b720abcc2b9b
Author: Pallavi Jadhav <pallavi.jadhav at synerzip.com>
Date:   Fri Jul 11 14:27:52 2014 +0530

    fdo#80800 : DOCX: Preservation of Direct Formatting for non first Table Cells
    
    	Issue :
    	- Direct Formatting for non-first Table cells was not getting preserved.
    	- In issue file, a table with multiple cells have Line Sapcing = 1.5 lines.
    	  But LO was importing only First Table cell with Line Spacing = 1.5 lines
    	  whereas for remaining cells LO was applying Line Spacing = Single.
    	  LO was overriding value from styles.xml
    	- Issue was due to at line : http://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/DomainMapper.cxx#399
    	  here LO sets only a boolean value for all cells and
    	  here : http://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/DomainMapperTableHandler.cxx#769
              we set DirectFormatting to False.
    	  So we have processed only one cell, hence for remaining cells Direct Formatting is not getting applied.
    	- So in order to have Direct Formatting for multiple Table Cells, we need to preserve Direct Fomatting property
    	  for respective cells.
    	  And with present code structure it is not happening as there is only a bool variable we are considering.
    
    	Implementation :
    	- Saved Direct Formatting information in DomainMapper itself.
    	- Hence when DomainMapperTableHandler::endTableGetCellProperties() gets called,
    	  Table cells already have correct value stored in it.
    	  We no more need to erase Default Formatting as Default formatting is not
    	  present instead it's actual values are now available.
            - This has conditionally reverted : https://gerrit.libreoffice.org/#/c/9560/
    
    Change-Id: Ie1c82069cd84e9662f33e734bda3ef69c5169e83
    Reviewed-on: https://gerrit.libreoffice.org/10216
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo80800.docx b/sw/qa/extras/ooxmlexport/data/fdo80800.docx
new file mode 100644
index 0000000..64ed769
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo80800.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index eb81a06..2ef9160 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3311,6 +3311,21 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80898, "fdo80898.docx")
                 "/word/embeddings/oleObject1.doc");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTableCellWithDirectFormatting, "fdo80800.docx")
+{
+    // Issue was Direct Foramatting for non-first Table cells was not getting preserved.
+
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+       return;
+
+    // Ensure that for Third Table cell Direct Formatting is preserved.
+    // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines"
+    // For Line Spacing "1.5 lines" w:line equals 360
+    assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360");
+
+}
+
 DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx")
 {
     // Header was lost on export when the document had multiple columns.
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f007457..27bda6e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -393,17 +393,20 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             }
             if( nName == NS_ooxml::LN_CT_Spacing_line )
             {
-                if( m_pImpl->getTableManager().isInCell() )
-                {
-                    // direct formatting is applied for table cell data
-                    m_pImpl->SetIsTableHasDirectFormatting(true);
-                }
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "line", OUString::number(nIntValue));
                 //now set the value depending on the Mode
                 if( aSpacing.Mode == style::LineSpacingMode::PROP )
                     aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / SINGLE_LINE_SPACING );
                 else
                     aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nIntValue ));
+
+                if( m_pImpl->getTableManager().isInCell() )
+                {
+                    // direct formatting is applied for table cell data
+                    TablePropertyMapPtr pTblCellWithDirectFormatting(new TablePropertyMap);
+                    pTblCellWithDirectFormatting->insert(std::pair< PropertyIds, PropValue >(PROP_PARA_LINE_SPACING, uno::makeAny( aSpacing )));
+                    m_pImpl->getTableManager().cellProps(pTblCellWithDirectFormatting);
+                }
             }
             else //NS_ooxml::LN_CT_Spacing_lineRule:
             {
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 8243bf6..28e413a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -759,15 +759,6 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
                 if ( aDefaultRepeatIt != pAllCellProps->end( ) )
                     pAllCellProps->erase( aDefaultRepeatIt );
 
-                if( m_rDMapper_Impl.GetIsTableHasDirectFormatting() )
-                {
-                    // Bug#78883 : direct formatting is applied for table cell data
-                    // so we can erase para line spacing property from style.xml
-                    aDefaultRepeatIt = pAllCellProps->find(PROP_PARA_LINE_SPACING);
-                    if ( aDefaultRepeatIt != pAllCellProps->end( ) )
-                        pAllCellProps->erase( aDefaultRepeatIt );
-                    m_rDMapper_Impl.SetIsTableHasDirectFormatting(false);
-                }
 
                 aDefaultRepeatIt = pAllCellProps->find(PROP_TBL_HEADER);
                 if ( aDefaultRepeatIt != pAllCellProps->end( ) )
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9d17160..8279958 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -195,7 +195,6 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bSdt(false),
         m_bIsFirstRun(false),
         m_bIsOutsideAParagraph(true),
-        m_bIsTableHasDirectFormatting(false),
         m_xAnnotationField(),
         m_nAnnotationId( -1 ),
         m_aAnnotationPositions(),
@@ -445,12 +444,6 @@ void DomainMapper_Impl::SetSdt(bool bSdt)
 }
 
 
-void DomainMapper_Impl::SetIsTableHasDirectFormatting(bool bIsTableHasDirectFormatting)
-{
-    m_bIsTableHasDirectFormatting = bIsTableHasDirectFormatting;
-}
-
-
 
 void    DomainMapper_Impl::PushProperties(ContextType eId)
 {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 39cc154..d59306a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -399,7 +399,6 @@ private:
     bool                            m_bSdt;
     bool                            m_bIsFirstRun;
     bool                            m_bIsOutsideAParagraph;
-    bool                            m_bIsTableHasDirectFormatting;
 
     css::uno::Reference< css::text::XTextCursor > xTOCMarkerCursor;
     css::uno::Reference< css::text::XTextCursor > mxTOCTextCursor;
@@ -487,10 +486,6 @@ public:
     void SetSdt(bool bSdt);
     /// Getter method for m_bSdt.
     bool GetSdt() { return m_bSdt;}
-    /// Getter method for m_bIsTableHasDirectFormatting
-    bool GetIsTableHasDirectFormatting() { return m_bIsTableHasDirectFormatting;}
-    /// Setter method for m_bIsTableHasDirectFormatting
-    void SetIsTableHasDirectFormatting(bool bIsTableHasDirectFormatting);
     bool GetParaChanged() { return m_bParaChanged;}
 
     void deferBreak( BreakType deferredBreakType );


More information about the Libreoffice-commits mailing list