summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPallavi Jadhav <pallavi.jadhav@synerzip.com>2014-07-11 14:27:52 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-18 08:06:15 +0000
commita5f9fb720daeb2df8325768b98b8b720abcc2b9b (patch)
tree53cec4e3f3dc993fdb90109270430b9e1648f9e9
parent92f74f6ccb5a55807724db85815f7ea0c49370e0 (diff)
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@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo80800.docxbin0 -> 13128 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx15
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx13
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx7
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx5
6 files changed, 23 insertions, 26 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo80800.docx b/sw/qa/extras/ooxmlexport/data/fdo80800.docx
new file mode 100644
index 000000000000..64ed7697f7d6
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo80800.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index eb81a06a2f0e..2ef916055926 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 f00745748bff..27bda6efe4ba 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 8243bf62fcc1..28e413ad2f1f 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 9d1716094bde..827995891d43 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 39cc15473bd9..d59306ac4d3b 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 );