summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-02 16:39:06 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-03 09:59:18 +0200
commit3e9d9b073f1b8fd934e00c8cff69fb0f9ef40781 (patch)
tree69dabaae819794676cf757e397ca169704e91702
parenta3efbb5d33f5c6928141fd3e7aa7c6d3bdc6a087 (diff)
oox: Preserve table style.
Table style is a property that defines a set of background and line attributes for cells. These attributes depend on theme settings (e.g. theme colors). We added a grabbag to the table object to save the table style name. We detect that name on export and write it back to the document. Finally, modified an existing unit test to check this attribute too. TODO: To get the table style working properly after a roundtrip, we must preserve it and also check that its values are not being overwritten by different cell or table properties. Change-Id: Id0e022a389561960c21ab874db33649499735024
-rw-r--r--offapi/com/sun/star/text/TextTable.idl10
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx4
-rw-r--r--sw/source/core/bastyp/init.cxx1
-rw-r--r--sw/source/core/unocore/unomap.cxx1
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx16
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx11
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
9 files changed, 46 insertions, 0 deletions
diff --git a/offapi/com/sun/star/text/TextTable.idl b/offapi/com/sun/star/text/TextTable.idl
index c637fe02d402..9771210095a0 100644
--- a/offapi/com/sun/star/text/TextTable.idl
+++ b/offapi/com/sun/star/text/TextTable.idl
@@ -211,6 +211,16 @@ published service TextTable
*/
[optional, property] boolean CollapsingBorders;
+ /** Grab bag of table properties, used as a string-any map for interim interop purposes.
+
+ @since LibreOffice 4.3
+
+ <p>This property is intentionally not handled by the ODF filter. Any
+ member that should be handled there should be first moved out from this grab
+ bag to a separate property.</p>
+ */
+ [optional, property] sequence<com::sun::star::beans::PropertyValue> TableInteropGrabBag;
+
};
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 280c7e40f12c..be90c9dd37b6 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -840,6 +840,7 @@
#define UNO_NAME_CHAR_INTEROP_GRAB_BAG "CharInteropGrabBag"
#define UNO_NAME_TEXT_VERT_ADJUST "TextVerticalAdjust"
#define UNO_NAME_CELL_INTEROP_GRAB_BAG "CellInteropGrabBag"
+#define UNO_NAME_TABLE_INTEROP_GRAB_BAG "TableInteropGrabBag"
#endif
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 04f474c4ff0c..15a5ddf859ab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1953,6 +1953,10 @@ DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, "table-theme-preservation.d
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFill", "accent6");
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillShade", "80");
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillTint", "");
+
+ // check table style has been preserved
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tblPr/w:tblStyle", "val", "Sombreadoclaro-nfasis1");
+
}
DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx")
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index af7660230109..fce0a3b74508 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -195,6 +195,7 @@ sal_uInt16 aTableSetRange[] = {
RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS,
// <-- collapsing
RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ RES_FRMATR_GRABBAG, RES_FRMATR_GRABBAG,
0
};
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 7e0a059f68d9..efe34b1f5d0c 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1100,6 +1100,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
// #i29550#
{ OUString(UNO_NAME_COLLAPSING_BORDERS), RES_COLLAPSING_BORDERS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
_REDLINE_NODE_PROPERTIES
+ { OUString(UNO_NAME_TABLE_INTEROP_GRAB_BAG), RES_FRMATR_GRABBAG, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), PROPERTY_NONE, 0 },
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d7cc220ba362..dd8ee9357547 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2672,6 +2672,22 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
FSNS( XML_w, XML_type ), widthType,
FSEND );
+ // Look for the table style property in the table grab bag
+ const SfxPoolItem *pI = NULL;
+ std::map<OUString, com::sun::star::uno::Any> aGrabBag;
+ if ( SFX_ITEM_ON == pTblFmt->GetAttrSet().GetItemState( RES_FRMATR_GRABBAG, false, &pI ) )
+ aGrabBag = dynamic_cast<const SfxGrabBagItem *>(pI)->GetGrabBag();
+
+ // Write table style property if it exists
+ std::map<OUString, com::sun::star::uno::Any>::iterator aGrabBagElement = aGrabBag.find("TableStyleName");
+ if( aGrabBagElement != aGrabBag.end() )
+ {
+ OString sStyleName = OUStringToOString( aGrabBagElement->second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
+ m_pSerializer->singleElementNS( XML_w, XML_tblStyle,
+ FSNS( XML_w, XML_val ), sStyleName.getStr(),
+ FSEND );
+ }
+
// Output the table alignement
const char* pJcVal;
sal_Int32 nIndent = 0;
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index a9a4221cf408..7ed56aa38700 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -340,6 +340,8 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
PropertyMap::iterator aTableStyleIter =
m_aTableProperties->find(META_PROP_TABLE_STYLE_NAME);
+ uno::Sequence< beans::PropertyValue > aGrabBag( 1 );
+ sal_Int32 nGrabBagSize = 0;
if(aTableStyleIter != m_aTableProperties->end())
{
// Apply table style properties recursively
@@ -350,6 +352,10 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
m_aTableProperties->erase( aTableStyleIter );
+ aGrabBag[0].Name = "TableStyleName";
+ aGrabBag[0].Value = uno::makeAny( sTableStyleName );
+ nGrabBagSize++;
+
if( pStyleSheet )
{
// First get the style properties, then the table ones
@@ -394,6 +400,11 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
dmapper_logger->endElement();
#endif
+ if( nGrabBagSize > 0 )
+ {
+ m_aTableProperties->Insert( PROP_TABLE_INTEROP_GRAB_BAG, uno::makeAny( aGrabBag ) );
+ }
+
m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf );
m_aTableProperties->getValue( TablePropertyMap::LEFT_MARGIN, nLeftMargin );
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 24e523be35de..1aa4252a21f8 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -389,6 +389,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_CHAR_CNTXTALTS_TEXT_EFFECT : sName = "CharCntxtAltsTextEffect"; break;
case PROP_SDTPR : sName = "SdtPr"; break;
case PROP_CELL_INTEROP_GRAB_BAG : sName = "CellInteropGrabBag"; break;
+ case PROP_TABLE_INTEROP_GRAB_BAG : sName = "TableInteropGrabBag"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index ab6f92f5c12e..88d1c89587c7 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -361,6 +361,7 @@ enum PropertyIds
,PROP_CHAR_CNTXTALTS_TEXT_EFFECT
,PROP_SDTPR
,PROP_CELL_INTEROP_GRAB_BAG
+ ,PROP_TABLE_INTEROP_GRAB_BAG
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier