summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-10-28 18:05:15 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-28 18:18:17 +0100
commitaf70016923b42940715c618caf01c78e892aa797 (patch)
treebc271f2d10fb3aba257cf5b4e672002736cefbbb /writerfilter
parentb2ad9eecf1cda725b1d7fcabd1ebd06895843d20 (diff)
DOCX import: store table style's pPr in InteropGrabBag
Change-Id: I0cecdc23053c0c03866ad808038d99a3bea3256e
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx27
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx13
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx13
5 files changed, 89 insertions, 0 deletions
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index a879115269c1..d6b5d379517a 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -122,6 +122,11 @@ public:
const std::map< sal_Int32, com::sun::star::uno::Any >& deferredCharacterProperties );
void setInTableStyleRunProps(bool bInTableStyleRunProps);
+ /// Enable storing of seen tokens in a named grab bag.
+ void enableInteropGrabBag(OUString aName);
+ /// Get the stored tokens and clear the internal storage.
+ beans::PropertyValue getInteropGrabBag();
+
private:
// Stream
virtual void lcl_startSectionGroup();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index ad74662202f6..97604039d252 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -977,6 +977,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Spacing_beforeLines:
break;
case NS_ooxml::LN_CT_Spacing_after:
+ m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
if (m_pImpl->GetTopContext())
// Don't overwrite NS_ooxml::LN_CT_Spacing_afterAutospacing.
m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
@@ -1008,6 +1009,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
}
if( nName == NS_ooxml::LN_CT_Spacing_line )
{
+ 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 );
@@ -1019,14 +1021,21 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
// exactly, atLeast, auto
if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_auto)
{
+ m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto");
aSpacing.Mode = style::LineSpacingMode::PROP;
//reinterpret the already set value
aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
}
else if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_atLeast)
+ {
+ m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "atLeast");
aSpacing.Mode = style::LineSpacingMode::MINIMUM;
+ }
else // NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_exact
+ {
+ m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "exact");
aSpacing.Mode = style::LineSpacingMode::FIX;
+ }
}
if (pTopContext)
pTopContext->Insert(PROP_PARA_LINE_SPACING, uno::makeAny( aSpacing ));
@@ -2987,6 +2996,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
m_pImpl->SetParaSectpr(true);
resolveSprmProps(*this, rSprm);
+ if (nSprmId == NS_ooxml::LN_CT_PPrBase_spacing)
+ m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", m_pImpl->m_aSubInteropGrabBag);
break;
case NS_ooxml::LN_EG_SectPrContents_footnotePr:
case NS_ooxml::LN_EG_SectPrContents_endnotePr:
@@ -4204,6 +4215,26 @@ bool DomainMapper::IsInHeaderFooter() const
return m_pImpl->IsInHeaderFooter();
}
+void DomainMapper::enableInteropGrabBag(OUString aName)
+{
+ m_pImpl->m_aInteropGrabBagName = aName;
+}
+
+beans::PropertyValue DomainMapper::getInteropGrabBag()
+{
+ beans::PropertyValue aRet;
+ aRet.Name = m_pImpl->m_aInteropGrabBagName;
+
+ uno::Sequence<beans::PropertyValue> aSeq(m_pImpl->m_aInteropGrabBag.size());
+ beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = m_pImpl->m_aInteropGrabBag.begin(); i != m_pImpl->m_aInteropGrabBag.end(); ++i)
+ *pSeq++ = *i;
+
+ m_pImpl->m_aInteropGrabBag.clear();
+ aRet.Value = uno::makeAny(aSeq);
+ return aRet;
+}
+
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0ae63e6309ae..289b83cfb46a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4115,6 +4115,33 @@ bool DomainMapper_Impl::IsNewDoc()
return m_bIsNewDoc;
}
+void DomainMapper_Impl::appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, OUString aKey, OUString aValue)
+{
+ if (m_aInteropGrabBagName.isEmpty())
+ return;
+ beans::PropertyValue aProperty;
+ aProperty.Name = aKey;
+ aProperty.Value = uno::makeAny(aValue);
+ rInteropGrabBag.push_back(aProperty);
+}
+
+void DomainMapper_Impl::appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, OUString aKey, std::vector<beans::PropertyValue>& rValue)
+{
+ if (m_aInteropGrabBagName.isEmpty())
+ return;
+ beans::PropertyValue aProperty;
+ aProperty.Name = aKey;
+
+ uno::Sequence<beans::PropertyValue> aSeq(rValue.size());
+ beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = rValue.begin(); i != rValue.end(); ++i)
+ *pSeq++ = *i;
+
+ rValue.clear();
+ aProperty.Value = uno::makeAny(aSeq);
+ rInteropGrabBag.push_back(aProperty);
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index fc2c7c220cb1..130ee1ab6a28 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -728,6 +728,19 @@ public:
bool m_bFrameBtLr; ///< Bottom to top, left to right text frame direction is requested for the current text frame.
/// Pending floating tables: they may be converted to text frames at the section end.
std::vector<FloatingTableInfo> m_aPendingFloatingTables;
+
+ /// Append a property to a sub-grabbag if necessary (e.g. 'lineRule', 'auto')
+ void appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, OUString aKey, OUString aValue);
+ void appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, OUString aKey, std::vector<beans::PropertyValue>& rValue);
+
+ /// Name of m_aInteropGrabBag.
+ OUString m_aInteropGrabBagName;
+
+ /// A toplevel dmapper grabbag, like 'pPr'.
+ std::vector<beans::PropertyValue> m_aInteropGrabBag;
+
+ /// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
+ std::vector<beans::PropertyValue> m_aSubInteropGrabBag;
};
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index b3a3cd747fce..ce5c16481ce4 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -749,7 +749,20 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
bool bTableStyleRunProps = m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE && nSprmId == NS_ooxml::LN_CT_Style_rPr;
if (bTableStyleRunProps)
m_pImpl->m_rDMapper.setInTableStyleRunProps(true);
+ if (m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+ {
+ if (nSprmId == NS_ooxml::LN_CT_Style_pPr)
+ m_pImpl->m_rDMapper.enableInteropGrabBag("pPr");
+ }
m_pImpl->m_rDMapper.sprmWithProps( rSprm, pProps );
+ if (m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+ {
+ if (nSprmId == NS_ooxml::LN_CT_Style_pPr)
+ {
+ TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
+ pTableEntry->AppendInteropGrabBag(m_pImpl->m_rDMapper.getInteropGrabBag());
+ }
+ }
if (bTableStyleRunProps)
m_pImpl->m_rDMapper.setInTableStyleRunProps(false);