[Libreoffice-commits] core.git: 4 commits - writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Oct 24 04:09:23 PDT 2013
writerfilter/source/dmapper/MeasureHandler.cxx | 35 +++++++++++
writerfilter/source/dmapper/MeasureHandler.hxx | 6 +
writerfilter/source/dmapper/StyleSheetTable.cxx | 52 ++++++++++++++++-
writerfilter/source/dmapper/StyleSheetTable.hxx | 5 +
writerfilter/source/dmapper/TablePropertiesHandler.cxx | 10 +++
writerfilter/source/dmapper/TablePropertiesHandler.hxx | 3
writerfilter/source/dmapper/TblStylePrHandler.cxx | 15 ++++
writerfilter/source/dmapper/TblStylePrHandler.hxx | 2
8 files changed, 127 insertions(+), 1 deletion(-)
New commits:
commit 5a50bb1701b44c6c765acd80aa38dc13e7ab9eed
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 24 13:05:21 2013 +0200
writerfilter: implement MeasureHandler::getInteropGrabBag()
This allows e.g. storing a table style's w:tblPr -> w:tblInd -> w:type.
Change-Id: I653edc8912ce4e61c703bfffc6e3dcf322295b6f
diff --git a/writerfilter/source/dmapper/MeasureHandler.cxx b/writerfilter/source/dmapper/MeasureHandler.cxx
index 783ebdc..57ffec5 100644
--- a/writerfilter/source/dmapper/MeasureHandler.cxx
+++ b/writerfilter/source/dmapper/MeasureHandler.cxx
@@ -53,9 +53,25 @@ void MeasureHandler::lcl_attribute(Id rName, Value & rVal)
{
case NS_rtf::LN_unit:
case NS_ooxml::LN_CT_TblWidth_type:// = 90668;
+ {
//can be: NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
// NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
m_nUnit = nIntValue;
+
+ if (!m_aInteropGrabBagName.isEmpty())
+ {
+ beans::PropertyValue aValue;
+ aValue.Name = "type";
+ switch (nIntValue)
+ {
+ case NS_ooxml::LN_Value_ST_TblWidth_nil: aValue.Value = uno::makeAny(OUString("nil")); break;
+ case NS_ooxml::LN_Value_ST_TblWidth_pct: aValue.Value = uno::makeAny(OUString("pct")); break;
+ case NS_ooxml::LN_Value_ST_TblWidth_dxa: aValue.Value = uno::makeAny(OUString("dxa")); break;
+ case NS_ooxml::LN_Value_ST_TblWidth_auto: aValue.Value = uno::makeAny(OUString("auto")); break;
+ }
+ m_aInteropGrabBag.push_back(aValue);
+ }
+ }
break;
case NS_ooxml::LN_CT_Height_hRule: // 90666;
{
@@ -105,6 +121,25 @@ sal_Int32 MeasureHandler::getMeasureValue() const
return nRet;
}
+void MeasureHandler::enableInteropGrabBag(OUString aName)
+{
+ m_aInteropGrabBagName = aName;
+}
+
+beans::PropertyValue MeasureHandler::getInteropGrabBag()
+{
+ beans::PropertyValue aRet;
+ aRet.Name = m_aInteropGrabBagName;
+
+ uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
+ beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i)
+ *pSeq++ = *i;
+
+ aRet.Value = uno::makeAny(aSeq);
+ return aRet;
+}
+
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/MeasureHandler.hxx b/writerfilter/source/dmapper/MeasureHandler.hxx
index 0155614..b1e7c57 100644
--- a/writerfilter/source/dmapper/MeasureHandler.hxx
+++ b/writerfilter/source/dmapper/MeasureHandler.hxx
@@ -22,6 +22,7 @@
#include <WriterFilterDllApi.hxx>
#include <resourcemodel/LoggedResources.hxx>
#include <boost/shared_ptr.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
namespace writerfilter {
namespace dmapper
@@ -36,6 +37,9 @@ class WRITERFILTER_DLLPRIVATE MeasureHandler : public LoggedProperties
sal_Int32 m_nUnit;
sal_Int16 m_nRowHeightSizeType; //table row height type
+ OUString m_aInteropGrabBagName;
+ std::vector<beans::PropertyValue> m_aInteropGrabBag;
+
// Properties
virtual void lcl_attribute(Id Name, Value & val);
virtual void lcl_sprm(Sprm & sprm);
@@ -50,6 +54,8 @@ public:
sal_Int32 getUnit() const { return m_nUnit; }
sal_Int16 GetRowHeightSizeType() const { return m_nRowHeightSizeType;}
+ void enableInteropGrabBag(OUString aName);
+ beans::PropertyValue getInteropGrabBag();
};
typedef boost::shared_ptr
< MeasureHandler > MeasureHandlerPtr;
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 9168fa6e..cf3a15a 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -262,13 +262,11 @@ namespace dmapper {
if (pProperties.get())
{
MeasureHandlerPtr pHandler(new MeasureHandler);
+ if (m_pCurrentInteropGrabBag)
+ pHandler->enableInteropGrabBag("tblInd");
pProperties->resolve( *pHandler );
if (m_pCurrentInteropGrabBag)
- {
- beans::PropertyValue aValue;
- aValue.Name = "tblInd";
- m_pCurrentInteropGrabBag->push_back(aValue);
- }
+ m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag());
TablePropertyMapPtr pTblIndMap(new TablePropertyMap);
sal_uInt32 nTblInd = pHandler->getMeasureValue();
pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd);
commit 10b12c965d29a91a4fda7b684caaf1ec738daa91
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 24 12:51:17 2013 +0200
writerfilter: implement TablePropertiesHandler::SetInteropGrabBag
This allows to store keys in table style's tblPr (no contents yet).
Change-Id: I2aa80c8bee3f76a7c0090407f97156e3e3061a1d
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 8153df2..9168fa6e 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -38,6 +38,7 @@ namespace writerfilter {
namespace dmapper {
TablePropertiesHandler::TablePropertiesHandler( bool bOOXML ) :
+ m_pCurrentInteropGrabBag(0),
m_pTableManager( NULL ),
m_bOOXML( bOOXML )
{
@@ -262,6 +263,12 @@ namespace dmapper {
{
MeasureHandlerPtr pHandler(new MeasureHandler);
pProperties->resolve( *pHandler );
+ if (m_pCurrentInteropGrabBag)
+ {
+ beans::PropertyValue aValue;
+ aValue.Name = "tblInd";
+ m_pCurrentInteropGrabBag->push_back(aValue);
+ }
TablePropertyMapPtr pTblIndMap(new TablePropertyMap);
sal_uInt32 nTblInd = pHandler->getMeasureValue();
pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd);
@@ -278,6 +285,11 @@ namespace dmapper {
return bRet;
}
+
+ void TablePropertiesHandler::SetInteropGrabBag(std::vector<beans::PropertyValue>& rValue)
+ {
+ m_pCurrentInteropGrabBag = &rValue;
+ }
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.hxx b/writerfilter/source/dmapper/TablePropertiesHandler.hxx
index 4c30569..6ce9b36 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.hxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.hxx
@@ -42,6 +42,7 @@ class TablePropertiesHandler
private:
vector< PropertyMapPtr > m_rPropertiesStack;
PropertyMapPtr m_pCurrentProperties;
+ std::vector<beans::PropertyValue>* m_pCurrentInteropGrabBag;
DomainMapperTableManager_Base_t *m_pTableManager;
bool m_bOOXML;
@@ -61,6 +62,8 @@ public:
m_pCurrentProperties = pProperties;
};
+ void SetInteropGrabBag(std::vector<beans::PropertyValue>& rValue);
+
private:
inline void cellProps( TablePropertyMapPtr pProps )
diff --git a/writerfilter/source/dmapper/TblStylePrHandler.cxx b/writerfilter/source/dmapper/TblStylePrHandler.cxx
index 4ef5fa0..7884cbc 100644
--- a/writerfilter/source/dmapper/TblStylePrHandler.cxx
+++ b/writerfilter/source/dmapper/TblStylePrHandler.cxx
@@ -83,6 +83,7 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
default:
// Tables specific properties have to handled here
m_pTablePropsHandler->SetProperties( m_pProperties );
+ m_pTablePropsHandler->SetInteropGrabBag(m_aInteropGrabBag);
bool bRet = m_pTablePropsHandler->sprm( rSprm );
if ( !bRet )
@@ -110,6 +111,13 @@ beans::PropertyValue TblStylePrHandler::getInteropGrabBag(OUString aName)
{
beans::PropertyValue aRet;
aRet.Name = aName;
+
+ uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
+ beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i)
+ *pSeq++ = *i;
+
+ aRet.Value = uno::makeAny(aSeq);
return aRet;
}
diff --git a/writerfilter/source/dmapper/TblStylePrHandler.hxx b/writerfilter/source/dmapper/TblStylePrHandler.hxx
index b607565..6b74a76 100644
--- a/writerfilter/source/dmapper/TblStylePrHandler.hxx
+++ b/writerfilter/source/dmapper/TblStylePrHandler.hxx
@@ -58,6 +58,7 @@ private:
TblStyleType m_nType;
PropertyMapPtr m_pProperties;
+ std::vector<beans::PropertyValue> m_aInteropGrabBag;
// Properties
virtual void lcl_attribute(Id Name, Value & val);
commit 8189fb2bf236abf047c00216c3b3b9d64663baf8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 24 12:37:04 2013 +0200
writerfilter: implement TblStylePrHandler::getInteropGrabBag
With this, we can store tblPr (itself, not yet its child elements)
inside table styles.
Change-Id: I7e9008fec566e73c50c4ccfc565fd0e8a3293998
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 6a19538..1dfac15 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -177,9 +177,21 @@ beans::PropertyValue TableStyleSheetEntry::GetInteropGrabBag()
{
beans::PropertyValue aRet;
aRet.Name = sStyleName;
+
+ uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
+ beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i)
+ *pSeq++ = *i;
+
+ aRet.Value = uno::makeAny(aSeq);
return aRet;
}
+void TableStyleSheetEntry::AppendInteropGrabBag(beans::PropertyValue aValue)
+{
+ m_aInteropGrabBag.push_back(aValue);
+}
+
void lcl_mergeProps( PropertyMapPtr pToFill, PropertyMapPtr pToAdd, TblStyleType nStyleId )
{
static const PropertyIds pPropsToCheck[] =
@@ -560,16 +572,21 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
PropertyMapPtr pProps = pTblStylePrHandler->getProperties( );
StyleSheetEntry * pEntry = m_pImpl->m_pCurrentEntry.get();
+ TableStyleSheetEntry * pTableEntry = dynamic_cast<TableStyleSheetEntry*>( pEntry );
if (nType == TBL_STYLE_UNKNOWN)
{
pEntry->pProperties->InsertProps(pProps);
}
else
{
- TableStyleSheetEntry * pTableEntry = dynamic_cast<TableStyleSheetEntry*>( pEntry );
if (pTableEntry != NULL)
pTableEntry->AddTblStylePr( nType, pProps );
}
+
+ if (nSprmId == NS_ooxml::LN_CT_Style_tblPr)
+ {
+ pTableEntry->AppendInteropGrabBag(pTblStylePrHandler->getInteropGrabBag("tblPr"));
+ }
}
break;
}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index c415ec3..cb6b9af 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -124,6 +124,8 @@ private:
StyleSheetTable* m_pStyleSheet;
TblStylePrs m_aStyles;
+ std::vector<beans::PropertyValue> m_aInteropGrabBag;
+
public:
short m_nColBandSize;
@@ -141,6 +143,7 @@ public:
// @param pStack already processed StyleSheetEntries
PropertyMapPtr GetProperties( sal_Int32 nMask, StyleSheetEntryDequePtr pStack = StyleSheetEntryDequePtr());
+ void AppendInteropGrabBag(beans::PropertyValue aValue);
beans::PropertyValue GetInteropGrabBag();
TableStyleSheetEntry( StyleSheetEntry& aEntry, StyleSheetTable* pStyles );
diff --git a/writerfilter/source/dmapper/TblStylePrHandler.cxx b/writerfilter/source/dmapper/TblStylePrHandler.cxx
index dd13110..4ef5fa0 100644
--- a/writerfilter/source/dmapper/TblStylePrHandler.cxx
+++ b/writerfilter/source/dmapper/TblStylePrHandler.cxx
@@ -106,6 +106,13 @@ void TblStylePrHandler::resolveSprmProps(Sprm & rSprm)
pProperties->resolve(*this);
}
+beans::PropertyValue TblStylePrHandler::getInteropGrabBag(OUString aName)
+{
+ beans::PropertyValue aRet;
+ aRet.Name = aName;
+ return aRet;
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/TblStylePrHandler.hxx b/writerfilter/source/dmapper/TblStylePrHandler.hxx
index f44c685..b607565 100644
--- a/writerfilter/source/dmapper/TblStylePrHandler.hxx
+++ b/writerfilter/source/dmapper/TblStylePrHandler.hxx
@@ -69,6 +69,7 @@ public:
inline PropertyMapPtr getProperties() { return m_pProperties; };
inline TblStyleType getType() { return m_nType; };
+ beans::PropertyValue getInteropGrabBag(OUString aName);
private:
commit 195ca828bb0ce5ce0e545eb6deb90f0c25f06fd9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 24 11:40:36 2013 +0200
writerfilter: preserve names of table styles
And also add a method stub where contents will be preserved as well.
Change-Id: Ide52102d1bdf6bf9d73b84ed6760f2b1e086a805
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index ab07e89..6a19538 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -173,6 +173,13 @@ PropertyMapPtr TableStyleSheetEntry::GetProperties( sal_Int32 nMask, StyleSheetE
return pProps;
}
+beans::PropertyValue TableStyleSheetEntry::GetInteropGrabBag()
+{
+ beans::PropertyValue aRet;
+ aRet.Name = sStyleName;
+ return aRet;
+}
+
void lcl_mergeProps( PropertyMapPtr pToFill, PropertyMapPtr pToAdd, TblStyleType nStyleId )
{
static const PropertyIds pPropsToCheck[] =
@@ -795,6 +802,7 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
if(xCharStyles.is() && xParaStyles.is())
{
+ std::vector<beans::PropertyValue> aTableStylesVec;
std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin();
while( aIt != m_pImpl->m_aStyleSheetEntries.end() )
{
@@ -1046,8 +1054,33 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle) );
}
}
+ else if(pEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+ {
+ // If this is a table style, save its contents as-is for roundtrip purposes.
+ TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(pEntry.get());
+ aTableStylesVec.push_back(pTableEntry->GetInteropGrabBag());
+ }
++aIt;
}
+
+ if (!aTableStylesVec.empty())
+ {
+ // If we had any table styles, add a new document-level InteropGrabBag entry for them.
+ uno::Reference<beans::XPropertySet> xPropertySet(m_pImpl->m_xTextDocument, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
+ sal_Int32 nLength = aGrabBag.getLength();
+ aGrabBag.realloc(nLength + 1);
+ aGrabBag[nLength].Name = "tableStyles";
+
+ uno::Sequence<beans::PropertyValue> aTableStyles(aTableStylesVec.size());
+ beans::PropertyValue* pTableStyles = aTableStyles.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = aTableStylesVec.begin(); i != aTableStylesVec.end(); ++i)
+ *pTableStyles++ = *i;
+
+ aGrabBag[nLength].Value = uno::makeAny(aTableStyles);
+ xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag));
+ }
}
}
catch( const uno::Exception& rException )
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index 2811653..c415ec3 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -141,6 +141,8 @@ public:
// @param pStack already processed StyleSheetEntries
PropertyMapPtr GetProperties( sal_Int32 nMask, StyleSheetEntryDequePtr pStack = StyleSheetEntryDequePtr());
+ beans::PropertyValue GetInteropGrabBag();
+
TableStyleSheetEntry( StyleSheetEntry& aEntry, StyleSheetTable* pStyles );
virtual ~TableStyleSheetEntry( );
More information about the Libreoffice-commits
mailing list