[Libreoffice-commits] core.git: writerfilter/inc writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jan 27 09:00:33 PST 2014
writerfilter/inc/dmapper/DomainMapper.hxx | 1
writerfilter/inc/resourcemodel/LoggedResources.hxx | 2 +
writerfilter/inc/resourcemodel/WW8ResourceModel.hxx | 2 +
writerfilter/source/dmapper/DomainMapper.cxx | 5 +++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 -
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 4 +++
writerfilter/source/dmapper/GraphicImport.cxx | 23 +++++++++++++++---
writerfilter/source/dmapper/GraphicImport.hxx | 5 +++
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 11 ++++++++
writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 1
writerfilter/source/ooxml/factoryimpl_ns.xsl | 3 ++
writerfilter/source/ooxml/model.xml | 7 +++++
writerfilter/source/resourcemodel/LoggedResources.cxx | 14 ++++++++++
writerfilter/source/resourcemodel/resourcemodel.hxx | 1
14 files changed, 76 insertions(+), 5 deletions(-)
New commits:
commit 166af05c63598426c375544b5e1e01818aa13747
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jan 27 17:51:50 2014 +0100
DOCX import: handle wp14:pctWidth for Writer TextFrames
Change-Id: I721a1ddd8299ff9639fd5fe4a25852e9418c00e2
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 4a168d9..f7d6fcb 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -142,6 +142,7 @@ private:
virtual void lcl_text(const sal_uInt8 * data, size_t len);
virtual void lcl_utext(const sal_uInt8 * data, size_t len);
+ virtual void lcl_positivePercentage(const OUString& rText) SAL_OVERRIDE;
virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref);
virtual void lcl_table(Id name,
writerfilter::Reference<Table>::Pointer_t ref);
diff --git a/writerfilter/inc/resourcemodel/LoggedResources.hxx b/writerfilter/inc/resourcemodel/LoggedResources.hxx
index 419bde7..5eaa781 100644
--- a/writerfilter/inc/resourcemodel/LoggedResources.hxx
+++ b/writerfilter/inc/resourcemodel/LoggedResources.hxx
@@ -64,6 +64,7 @@ public:
void endShape();
void text(const sal_uInt8 * data, size_t len);
void utext(const sal_uInt8 * data, size_t len);
+ void positivePercentage(const OUString& rText);
void props(writerfilter::Reference<Properties>::Pointer_t ref);
void table(Id name, writerfilter::Reference<Table>::Pointer_t ref);
void substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref);
@@ -80,6 +81,7 @@ protected:
virtual void lcl_endShape() = 0;
virtual void lcl_text(const sal_uInt8 * data, size_t len) = 0;
virtual void lcl_utext(const sal_uInt8 * data, size_t len) = 0;
+ virtual void lcl_positivePercentage(const OUString& /*rText*/) { }
virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref) = 0;
virtual void lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ref) = 0;
virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) = 0;
diff --git a/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx b/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
index 886d2f6..01106ae 100644
--- a/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
+++ b/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
@@ -246,6 +246,8 @@ public:
*/
virtual void utext(const sal_uInt8 * data, size_t len) = 0;
+ virtual void positivePercentage(const OUString& rText) = 0;
+
/**
Receives properties of the current run of text.
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index d095df8..1a79129 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3293,6 +3293,11 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
}
}
+void DomainMapper::lcl_positivePercentage(const OUString& rText)
+{
+ m_pImpl->m_aPositivePercentages.push(rText);
+}
+
void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
{
OUString sText;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 74173fd..8b7dc2d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3762,7 +3762,7 @@ void DomainMapper_Impl::AddAnnotationPosition(
GraphicImportPtr DomainMapper_Impl::GetGraphicImport(GraphicImportType eGraphicImportType)
{
if(!m_pGraphicImport)
- m_pGraphicImport.reset( new GraphicImport( m_xComponentContext, m_xTextFactory, m_rDMapper, eGraphicImportType ) );
+ m_pGraphicImport.reset( new GraphicImport( m_xComponentContext, m_xTextFactory, m_rDMapper, eGraphicImportType, m_aPositivePercentages ) );
return m_pGraphicImport;
}
/*-------------------------------------------------------------------------
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index f5f1e97..c102506 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -29,6 +29,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <vector>
#include <stack>
+#include <queue>
#include <boost/optional.hpp>
#ifndef INCLUDED_RESOURCESIDS
@@ -738,6 +739,9 @@ public:
/// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
std::vector<beans::PropertyValue> m_aSubInteropGrabBag;
+
+ /// ST_PositivePercentage values we received
+ std::queue<OUString> m_aPositivePercentages;
};
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index b76da13..6087610 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -255,8 +255,9 @@ public:
OUString sName;
OUString sAlternativeText;
OUString title;
+ std::queue<OUString>& m_rPositivePercentages;
- GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper) :
+ GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper, std::queue<OUString>& rPositivePercentages) :
nXSize(0)
,bXSizeValid(false)
,nYSize(0)
@@ -309,6 +310,7 @@ public:
,bVertFlip(false)
,bSizeProtected(false)
,bPositionProtected(false)
+ ,m_rPositivePercentages(rPositivePercentages)
{}
void setXSize(sal_Int32 _nXSize)
@@ -413,11 +415,12 @@ public:
GraphicImport::GraphicImport(uno::Reference < uno::XComponentContext > xComponentContext,
uno::Reference< lang::XMultiServiceFactory > xTextFactory,
DomainMapper& rDMapper,
- GraphicImportType eImportType )
+ GraphicImportType eImportType,
+ std::queue<OUString>& rPositivePercentages)
: LoggedProperties(dmapper_logger, "GraphicImport")
, LoggedTable(dmapper_logger, "GraphicImport")
, LoggedStream(dmapper_logger, "GraphicImport")
-, m_pImpl( new GraphicImport_Impl( eImportType, rDMapper ))
+, m_pImpl( new GraphicImport_Impl( eImportType, rDMapper, rPositivePercentages ))
, m_xComponentContext( xComponentContext )
, m_xTextFactory( xTextFactory)
{
@@ -884,6 +887,20 @@ void GraphicImport::lcl_sprm(Sprm & rSprm)
}
}
break;
+ case NS_ooxml::LN_CT_SizeRelH_pctWidth:
+ if (m_xShape.is() && !m_pImpl->m_rPositivePercentages.empty())
+ {
+ sal_Int16 nPositivePercentage = m_pImpl->m_rPositivePercentages.front().toInt32() / 1000;
+ m_pImpl->m_rPositivePercentages.pop();
+
+ uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW);
+ if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RelativeWidth", uno::makeAny(nPositivePercentage));
+ }
+ }
+ break;
case 0x271b:
case 0x271c:
{
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index a979512..7e4cef2 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -19,6 +19,8 @@
#ifndef INCLUDED_GRAPHICIMPORT_HXX
#define INCLUDED_GRAPHICIMPORT_HXX
+#include <queue>
+
#include <resourcemodel/LoggedResources.hxx>
namespace com{ namespace sun { namespace star {
@@ -77,7 +79,8 @@ public:
explicit GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > xComponentContext,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory,
DomainMapper& rDomainMapper,
- GraphicImportType eGraphicImportType);
+ GraphicImportType eGraphicImportType,
+ std::queue<OUString>& rPositivePercentages);
virtual ~GraphicImport();
// BinaryObj
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index b1af30f..6cfb6d7 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -974,6 +974,17 @@ void OOXMLFastContextHandler::alignV(const OUString & sText)
::writerfilter::dmapper::PositionHandler::setAlignV( sText );
}
+void OOXMLFastContextHandler::positivePercentage(const OUString& rText)
+{
+#ifdef DEBUG_ELEMENT
+ debug_logger->startElement("positivePercentage");
+ debug_logger->chars(rText);
+ debug_logger->endElement();
+#endif
+ if (isForwardEvents())
+ mpStream->positivePercentage(rText);
+}
+
void OOXMLFastContextHandler::propagateCharacterProperties()
{
#ifdef DEBUG_CONTEXT_HANDLER
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index c5909bf..aa1048b 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -214,6 +214,7 @@ public:
void positionOffset(const OUString & sText);
void alignH(const OUString & sText);
void alignV(const OUString & sText);
+ void positivePercentage(const OUString& rText);
void startTxbxContent();
void endTxbxContent();
virtual void propagateCharacterProperties();
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.xsl b/writerfilter/source/ooxml/factoryimpl_ns.xsl
index 7105901..6e3e998 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.xsl
+++ b/writerfilter/source/ooxml/factoryimpl_ns.xsl
@@ -516,6 +516,9 @@ CreateElementMapPointer </xsl:text>
<xsl:when test="@action='positionOffset'">
pHandler->positionOffset(sText);
</xsl:when>
+ <xsl:when test="@action='positivePercentage'">
+ pHandler->positivePercentage(sText);
+ </xsl:when>
<xsl:when test="@action='alignH'">
pHandler->alignH(sText);
</xsl:when>
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index e899a43..b6b4597 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -4477,6 +4477,9 @@
<attribute name="val" tokenid="ooxml:CT_Percentage_val" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/>
</resource>
+ <resource name="ST_PositivePercentage" resource="Value">
+ <action name="characters" action="positivePercentage"/>
+ </resource>
<resource name="CT_PositivePercentage" resource="Value" generated="yes" tag="attribute">
<attribute name="val" tokenid="ooxml:CT_PositivePercentage_val" action="setValue"/>
</resource>
@@ -5243,6 +5246,9 @@
</choice>
</define>
<define name="CT_SizeRelH">
+ <element name="pctWidth">
+ <ref name="ST_PositivePercentage"/>
+ </element>
<attribute name="relativeFrom">
<ref name="ST_SizeRelFromH"/>
</attribute>
@@ -5262,6 +5268,7 @@
<value name="outsideMargin" tokenid="ooxml:ST_SizeRelFromH_outsideMargin">outsideMargin</value>
</resource>
<resource name="CT_SizeRelH" resource="Properties" tag="shape">
+ <element name="pctWidth" tokenid="ooxml:CT_SizeRelH_pctWidth"/>
<attribute name="relativeFrom" tokenid="ooxml:CT_SizeRelH_relativeFrom"/>
</resource>
<resource name="sizeRelH" resource="Properties" tag="shape">
diff --git a/writerfilter/source/resourcemodel/LoggedResources.cxx b/writerfilter/source/resourcemodel/LoggedResources.cxx
index f94bd92..0808fb8 100644
--- a/writerfilter/source/resourcemodel/LoggedResources.cxx
+++ b/writerfilter/source/resourcemodel/LoggedResources.cxx
@@ -202,6 +202,20 @@ void LoggedStream::utext(const sal_uInt8 * data, size_t len)
#endif
}
+void LoggedStream::positivePercentage(const OUString& rText)
+{
+#ifdef DEBUG_LOGGING
+ mHelper.startElement("positivePercentage");
+ mHelper.chars(rText);
+#endif
+
+ lcl_positivePercentage(rText);
+
+#ifdef DEBUG_LOGGING
+ mHelper.endElement("positivePercentage");
+#endif
+}
+
void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
{
#ifdef DEBUG_LOGGING
diff --git a/writerfilter/source/resourcemodel/resourcemodel.hxx b/writerfilter/source/resourcemodel/resourcemodel.hxx
index 2e0066d..ecaaac6 100644
--- a/writerfilter/source/resourcemodel/resourcemodel.hxx
+++ b/writerfilter/source/resourcemodel/resourcemodel.hxx
@@ -37,6 +37,7 @@ public:
virtual void endCharacterGroup();
virtual void text(const sal_uInt8 * data, size_t len);
virtual void utext(const sal_uInt8 * data, size_t len);
+ virtual void positivePercentage(const OUString& /*rText*/) { }
virtual void props(writerfilter::Reference<Properties>::Pointer_t ref);
virtual void table(Id name,
More information about the Libreoffice-commits
mailing list