summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-13 10:26:00 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-08-13 11:02:19 +0200
commit774b6899172b2f803898655103d6653ef2261cfd (patch)
tree7e86ef4a9f77d1f897ff669bd576ef0781a419c0 /writerfilter
parent48a1b767b183acdc703cd7e5a4c6d492da237daa (diff)
RTF import: handle rotation on groupshapes
Change-Id: I7892224a118b6566e26b3ffc472c88f3c7f58620
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/Library_writerfilter.mk1
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx13
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx3
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx20
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.hxx2
5 files changed, 32 insertions, 7 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk
index 0f3bdb13f4f8..58c891aa2a71 100644
--- a/writerfilter/Library_writerfilter.mk
+++ b/writerfilter/Library_writerfilter.mk
@@ -63,6 +63,7 @@ $(eval $(call gb_Library_use_libraries,writerfilter,\
sfx \
sot \
svt \
+ svxcore \
tl \
utl \
vcl \
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 49fe9649a718..1aa781465815 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3931,6 +3931,12 @@ int RTFDocumentImpl::popState()
aState.aShape.aProperties.back().second = m_aStates.top().aDestinationText.makeStringAndClear();
if (m_aStates.top().bHadShapeText)
m_pSdrImport->append(aState.aShape.aProperties.back().first, aState.aShape.aProperties.back().second);
+ else if (aState.bInShapeGroup && !aState.bInShape && aState.aShape.aProperties.back().first == "rotation")
+ {
+ // Rotation should be applied on the groupshape itself, not on each shape.
+ aState.aShape.aGroupProperties.push_back(aState.aShape.aProperties.back());
+ aState.aShape.aProperties.pop_back();
+ }
}
break;
case DESTINATION_PICPROP:
@@ -3938,6 +3944,13 @@ int RTFDocumentImpl::popState()
// Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself.
if (!m_bObject && !aState.bInListpicture && !aState.bHadShapeText && !(aState.bInShapeGroup && !aState.bInShape))
m_pSdrImport->resolve(m_aStates.top().aShape, true);
+ else if (aState.bInShapeGroup && !aState.bInShape)
+ {
+ // End of a groupshape, as we're in shapegroup, but not in a real shape.
+ for (std::vector< std::pair<OUString, OUString> >::iterator i = aState.aShape.aGroupProperties.begin(); i != aState.aShape.aGroupProperties.end(); ++i)
+ m_pSdrImport->appendGroupProperty(i->first, i->second);
+ aState.aShape.aGroupProperties.clear();
+ }
break;
case DESTINATION_BOOKMARKSTART:
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 0f5e9d8ed059..276ca933a6c5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -94,7 +94,8 @@ namespace writerfilter {
{
public:
RTFShape();
- std::vector< std::pair<OUString, OUString> > aProperties;
+ std::vector< std::pair<OUString, OUString> > aProperties; ///< Properties of a single shape.
+ std::vector< std::pair<OUString, OUString> > aGroupProperties; ///< Properties applied on the groupshape.
sal_Int32 nLeft;
sal_Int32 nTop;
sal_Int32 nRight;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 147675eac3af..b51ba64d821b 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -27,6 +27,7 @@
#include <ooxml/resourceids.hxx> // NS_ooxml namespace
#include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/util.hxx>
+#include <svx/svdtrans.hxx>
#include <dmapper/DomainMapper.hxx>
#include "../dmapper/GraphicHelpers.hxx"
@@ -184,6 +185,13 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
obFitShapeToText.reset(aValue.toInt32() == 1);
else if (aKey == "fFilled")
bFilled = aValue.toInt32() == 1;
+ else if (aKey == "rotation")
+ {
+ // See DffPropertyReader::Fix16ToAngle(): in RTF, positive rotation angles are clockwise, we have them as counter-clockwise.
+ // Additionally, RTF type is 0..360*2^16, our is 0..360*100.
+ sal_Int32 nRotation = aValue.toInt32()*100/65536;
+ xPropertySet->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(NormAngle360(nRotation * -1))));
+ }
if (nHoriOrient != 0)
xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
@@ -321,11 +329,6 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
aAny <<= uno::makeAny(sal_uInt32(opacity));
xPropertySet->setPropertyValue("FillTransparence", aAny);
}
- else if (i->first == "rotation" && xPropertySet.is())
- {
- aAny <<= i->second.toInt32()*100/65536;
- xPropertySet->setPropertyValue("RotateAngle", aAny);
- }
else if (i->first == "lineWidth")
aLineWidth <<= i->second.toInt32()/360;
else if ( i->first == "pVerticies" )
@@ -492,7 +495,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
else if (i->first == "shadowOffsetX")
// EMUs to points
aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
- else if (i->first == "posh" || i->first == "posv" || i->first == "fFitShapeToText" || i->first == "fFilled")
+ else if (i->first == "posh" || i->first == "posv" || i->first == "fFitShapeToText" || i->first == "fFilled" || i->first == "rotation")
applyProperty(xShape, i->first, i->second);
else if (i->first == "posrelh")
{
@@ -699,6 +702,11 @@ void RTFSdrImport::append(OUString aKey, OUString aValue)
applyProperty(m_xShape, aKey, aValue);
}
+void RTFSdrImport::appendGroupProperty(OUString aKey, OUString aValue)
+{
+ applyProperty(uno::Reference<drawing::XShape>(m_aParents.top(), uno::UNO_QUERY), aKey, aValue);
+}
+
} // namespace rtftok
} // namespace writerfilter
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 735f24b7e5cf..333927dd827c 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -26,6 +26,8 @@ namespace writerfilter {
void resolve(RTFShape& rShape, bool bClose);
void close();
void append(OUString aKey, OUString aValue);
+ /// Append property on the current parent.
+ void appendGroupProperty(OUString aKey, OUString aValue);
void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder);
void resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nFLine);
/**