summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2020-11-17 12:43:12 +0300
committerGülşah Köse <gulsah.kose@collabora.com>2020-11-18 12:46:16 +0100
commit935c558a8d2edccca341515509a7e577aac58dc1 (patch)
treedc4999f1a19f506724c67b0ced8f76e6beedd08f /oox
parentac9099140eeea974c9746528eeb96203d248d1e0 (diff)
tdf#128213 Fix text camera z rotation import and export.
Text3DProperties is added to distinguish shape and text 3D effects. Before there was implementation error about text camera z rotation support. We were using shape effects for text. We already have not support shape 3D rotation but we have text camera z rotation. This patch includes import and export filter changes about text camera z rotation. Change-Id: I623392b82edf4585888d2f15ad91ffb2109d8f96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106033 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106047 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/scene3dcontext.hxx10
-rw-r--r--oox/inc/drawingml/shape3dproperties.hxx7
-rw-r--r--oox/inc/drawingml/textbody.hxx5
-rw-r--r--oox/source/drawingml/scene3dcontext.cxx33
-rw-r--r--oox/source/drawingml/shape.cxx20
-rw-r--r--oox/source/drawingml/shape3dproperties.cxx30
-rw-r--r--oox/source/drawingml/textbodypropertiescontext.cxx2
-rw-r--r--oox/source/export/drawingml.cxx28
-rw-r--r--oox/source/export/shapes.cxx12
9 files changed, 125 insertions, 22 deletions
diff --git a/oox/inc/drawingml/scene3dcontext.hxx b/oox/inc/drawingml/scene3dcontext.hxx
index 13b2a9e3fe70..7645139b47ef 100644
--- a/oox/inc/drawingml/scene3dcontext.hxx
+++ b/oox/inc/drawingml/scene3dcontext.hxx
@@ -49,6 +49,16 @@ private:
Shape3DProperties& mr3DProperties;
};
+class SceneText3DPropertiesContext final : public ::oox::core::ContextHandler2
+{
+public:
+ SceneText3DPropertiesContext( ::oox::core::ContextHandler2Helper const & rParent, Text3DProperties& rText3DProperties ) throw();
+ ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) override;
+
+private:
+ Text3DProperties& mr3DProperties;
+};
+
class Shape3DPropertiesContext : public ::oox::core::ContextHandler2
{
public:
diff --git a/oox/inc/drawingml/shape3dproperties.hxx b/oox/inc/drawingml/shape3dproperties.hxx
index e44d0468eeca..95115d101bba 100644
--- a/oox/inc/drawingml/shape3dproperties.hxx
+++ b/oox/inc/drawingml/shape3dproperties.hxx
@@ -49,7 +49,7 @@ struct BevelProperties
OptValue< sal_Int32 > mnHeight;
};
-struct Shape3DProperties
+struct Generic3DProperties
{
OptValue< sal_Int32 > mnPreset;
OptValue< float > mfFieldOfVision;
@@ -84,6 +84,11 @@ struct Shape3DProperties
const Color& rColor, const GraphicHelper& rGraphicHelper, ::Color rPhClr );
};
+struct Shape3DProperties : Generic3DProperties
+{};
+
+struct Text3DProperties : Generic3DProperties
+{};
} // namespace drawingml
} // namespace oox
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 38996abe03ea..8cc3a70b254a 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -23,6 +23,7 @@
#include <oox/drawingml/drawingmltypes.hxx>
#include <drawingml/textbodyproperties.hxx>
#include <drawingml/textliststyle.hxx>
+#include <drawingml/shape3dproperties.hxx>
namespace com { namespace sun { namespace star {
namespace text { class XText; }
@@ -54,6 +55,9 @@ public:
const TextBodyProperties& getTextProperties() const { return maTextProperties; }
TextBodyProperties& getTextProperties() { return maTextProperties; }
+ Text3DProperties& get3DProperties() { return ma3DProperties; }
+ const Text3DProperties& get3DProperties() const { return ma3DProperties; }
+
/** insert the text body at the text cursor */
void insertAt(
const ::oox::core::XmlFilterBase& rFilterBase,
@@ -73,6 +77,7 @@ protected:
TextParagraphVector maParagraphs;
TextBodyProperties maTextProperties;
TextListStyle maTextListStyle;
+ Text3DProperties ma3DProperties;
};
} }
diff --git a/oox/source/drawingml/scene3dcontext.cxx b/oox/source/drawingml/scene3dcontext.cxx
index f6e0ee38d5fc..267d0f24c8b2 100644
--- a/oox/source/drawingml/scene3dcontext.cxx
+++ b/oox/source/drawingml/scene3dcontext.cxx
@@ -68,6 +68,39 @@ ContextHandlerRef Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementT
return nullptr;
}
+SceneText3DPropertiesContext::SceneText3DPropertiesContext( ContextHandler2Helper const & rParent, Text3DProperties& r3DProperties ) throw()
+: ContextHandler2( rParent )
+, mr3DProperties( r3DProperties )
+{
+}
+
+ContextHandlerRef SceneText3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
+{
+ switch( aElementToken )
+ {
+ case A_TOKEN( camera ):
+ if( rAttribs.hasAttribute( XML_fov ) )
+ mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree
+ if( rAttribs.hasAttribute( XML_zoom ) )
+ mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0;
+ if( rAttribs.hasAttribute( XML_prst ) )
+ mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none );
+
+ return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maCameraRotation );
+
+ case A_TOKEN( lightRig ):
+ mr3DProperties.mnLightRigDirection = rAttribs.getToken( XML_dir, XML_none );
+ mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none );
+
+ return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maLightRigRotation );
+
+ case A_TOKEN( backdrop ):
+ case A_TOKEN( extLst ):
+ return nullptr; // TODO: later (backdrop is not supported by core anyway)
+ }
+ return nullptr;
+}
+
Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) throw()
: ContextHandler2( rParent )
, mr3DProperties( r3DProperties )
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 668c30a547b0..bf75f2e5f8df 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1379,6 +1379,24 @@ Reference< XShape > const & Shape::createAndInsert(
putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
}
+ if( bIsCustomShape && getTextBody())
+ {
+
+ Sequence< PropertyValue > aTextCamera3DEffects = getTextBody()->get3DProperties().getCameraAttributes();
+ Sequence< PropertyValue > aTextLightRig3DEffects = getTextBody()->get3DProperties().getLightRigAttributes();
+ Sequence< PropertyValue > aTextShape3DEffects = getTextBody()->get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
+ if( aTextCamera3DEffects.hasElements() || aTextLightRig3DEffects.hasElements() || aTextShape3DEffects.hasElements() )
+ {
+ uno::Sequence<beans::PropertyValue> aText3DEffectsGrabBag = comphelper::InitPropertySequence(
+ {
+ {"Camera", uno::makeAny(aTextCamera3DEffects)},
+ {"LightRig", uno::makeAny(aTextLightRig3DEffects)},
+ {"Shape3D", uno::makeAny(aTextShape3DEffects)}
+ });
+ putPropertyToGrabBag( "Text3DEffectProperties", Any( aText3DEffectsGrabBag ) );
+ }
+ }
+
// store bitmap artistic effects in the grab bag
if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
putPropertyToGrabBag( "ArtisticEffectProperties",
@@ -1405,7 +1423,7 @@ Reference< XShape > const & Shape::createAndInsert(
mpCustomShapePropertiesPtr->setMirroredY( true );
if( getTextBody() )
{
- sal_Int32 nTextCameraZRotation = static_cast< sal_Int32 >( get3DProperties().maCameraRotation.mnRevolution.get() );
+ sal_Int32 nTextCameraZRotation = static_cast< sal_Int32 >( getTextBody()->get3DProperties().maCameraRotation.mnRevolution.get() );
mpCustomShapePropertiesPtr->setTextCameraZRotateAngle( nTextCameraZRotation / 60000 );
sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
diff --git a/oox/source/drawingml/shape3dproperties.cxx b/oox/source/drawingml/shape3dproperties.cxx
index ac94f882d539..884a9285911b 100644
--- a/oox/source/drawingml/shape3dproperties.cxx
+++ b/oox/source/drawingml/shape3dproperties.cxx
@@ -41,7 +41,7 @@ using namespace ::com::sun::star::graphic;
namespace oox {
namespace drawingml {
-OUString Shape3DProperties::getCameraPrstName( sal_Int32 nElement )
+OUString Generic3DProperties::getCameraPrstName( sal_Int32 nElement )
{
switch( nElement )
{
@@ -108,11 +108,11 @@ OUString Shape3DProperties::getCameraPrstName( sal_Int32 nElement )
case XML_perspectiveRelaxed: return "perspectiveRelaxed";
case XML_perspectiveRelaxedModerately: return "perspectiveRelaxedModerately";
}
- SAL_WARN( "oox.drawingml", "Shape3DProperties::getCameraPrstName - unexpected prst type" );
+ SAL_WARN( "oox.drawingml", "Generic3DProperties::getCameraPrstName - unexpected prst type" );
return OUString();
}
-OUString Shape3DProperties::getLightRigName( sal_Int32 nElement )
+OUString Generic3DProperties::getLightRigName( sal_Int32 nElement )
{
switch( nElement )
{
@@ -144,11 +144,11 @@ OUString Shape3DProperties::getLightRigName( sal_Int32 nElement )
case XML_glow: return "glow";
case XML_brightRoom: return "brightRoom";
}
- SAL_WARN( "oox.drawingml", "Shape3DProperties::getLightRigName - unexpected token" );
+ SAL_WARN( "oox.drawingml", "Generic3DProperties::getLightRigName - unexpected token" );
return OUString();
}
-OUString Shape3DProperties::getLightRigDirName( sal_Int32 nElement )
+OUString Generic3DProperties::getLightRigDirName( sal_Int32 nElement )
{
switch( nElement )
{
@@ -161,11 +161,11 @@ OUString Shape3DProperties::getLightRigDirName( sal_Int32 nElement )
case XML_b: return "b";
case XML_br: return "br";
}
- SAL_WARN( "oox.drawingml", "Shape3DProperties::getLightRigDirName - unexpected token" );
+ SAL_WARN( "oox.drawingml", "Generic3DProperties::getLightRigDirName - unexpected token" );
return OUString();
}
-OUString Shape3DProperties::getBevelPresetTypeString( sal_Int32 nType )
+OUString Generic3DProperties::getBevelPresetTypeString( sal_Int32 nType )
{
switch (nType)
{
@@ -182,11 +182,11 @@ OUString Shape3DProperties::getBevelPresetTypeString( sal_Int32 nType )
case XML_hardEdge: return "hardEdge";
case XML_artDeco: return "artDeco";
}
- SAL_WARN( "oox.drawingml", "Shape3DProperties::getBevelPresetTypeString - unexpected token" );
+ SAL_WARN( "oox.drawingml", "Generic3DProperties::getBevelPresetTypeString - unexpected token" );
return OUString();
}
-OUString Shape3DProperties::getPresetMaterialTypeString( sal_Int32 nType )
+OUString Generic3DProperties::getPresetMaterialTypeString( sal_Int32 nType )
{
switch (nType)
{
@@ -207,11 +207,11 @@ OUString Shape3DProperties::getPresetMaterialTypeString( sal_Int32 nType )
case XML_softmetal: return "softmetal";
case XML_none: return "none";
}
- SAL_WARN( "oox.drawingml", "Shape3DProperties::getPresetMaterialTypeString - unexpected token" );
+ SAL_WARN( "oox.drawingml", "Generic3DProperties::getPresetMaterialTypeString - unexpected token" );
return OUString();
}
-css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getCameraAttributes()
+css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getCameraAttributes()
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(6);
sal_Int32 nSize = 0;
@@ -255,7 +255,7 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getCameraAttr
return aSeq;
}
-css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getLightRigAttributes()
+css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getLightRigAttributes()
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(5);
sal_Int32 nSize = 0;
@@ -293,7 +293,7 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getLightRigAt
return aSeq;
}
-css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getBevelAttributes( BevelProperties rProps )
+css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getBevelAttributes( BevelProperties rProps )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(3);
sal_Int32 nSize = 0;
@@ -319,7 +319,7 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getBevelAttri
return aSeq;
}
-css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getColorAttributes(
+css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getColorAttributes(
const Color& rColor, const GraphicHelper& rGraphicHelper, ::Color rPhClr )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(2);
@@ -343,7 +343,7 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getColorAttri
return aSeq;
}
-css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getShape3DAttributes(
+css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getShape3DAttributes(
const GraphicHelper& rGraphicHelper, ::Color rPhClr )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(8);
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index d696b4c3ac70..4f6b1b39f3a9 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -174,7 +174,7 @@ ContextHandlerRef TextBodyPropertiesContext::onCreateContext( sal_Int32 aElement
case A_TOKEN( scene3d ): // CT_Scene3D
{
if(mpShapePtr && mpShapePtr->getServiceName() == "com.sun.star.drawing.CustomShape")
- return new Scene3DPropertiesContext( *this, mpShapePtr->get3DProperties() );
+ return new SceneText3DPropertiesContext( *this, mpShapePtr->getTextBody()->get3DProperties() );
break;
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 977a1ccfa3b1..94e7da1f2aa7 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2988,6 +2988,9 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
mpFS->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit : XML_noAutofit));
}
}
+
+ WriteShape3DEffects( rXPropSet );
+
mpFS->endElementNS((nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr);
}
@@ -3925,12 +3928,12 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
// extract the relevant properties from the grab bag
Sequence< PropertyValue > aGrabBag, aEffectProps, aLightRigProps, aShape3DProps;
mAny >>= aGrabBag;
- auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
+ auto pShapeProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
[](const PropertyValue& rProp) { return rProp.Name == "3DEffectProperties"; });
- if (pProp != std::cend(aGrabBag))
+ if (pShapeProp != std::cend(aGrabBag))
{
Sequence< PropertyValue > a3DEffectProps;
- pProp->Value >>= a3DEffectProps;
+ pShapeProp->Value >>= a3DEffectProps;
for( const auto& r3DEffectProp : std::as_const(a3DEffectProps) )
{
if( r3DEffectProp.Name == "Camera" )
@@ -3941,6 +3944,25 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
r3DEffectProp.Value >>= aShape3DProps;
}
}
+
+ auto pTextProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag),
+ [](const PropertyValue& rProp) { return rProp.Name == "Text3DEffectProperties"; });
+
+ if (pTextProp != std::cend(aGrabBag))
+ {
+ Sequence< PropertyValue > a3DEffectProps;
+ pTextProp->Value >>= a3DEffectProps;
+ for( const auto& r3DEffectProp : std::as_const(a3DEffectProps) )
+ {
+ if( r3DEffectProp.Name == "Camera" )
+ r3DEffectProp.Value >>= aEffectProps;
+ else if( r3DEffectProp.Name == "LightRig" )
+ r3DEffectProp.Value >>= aLightRigProps;
+ else if( r3DEffectProp.Name == "Shape3D" )
+ r3DEffectProp.Value >>= aShape3DProps;
+ }
+ }
+
if( !aEffectProps.hasElements() && !aLightRigProps.hasElements() && !aShape3DProps.hasElements() )
return;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 9f69e316cbec..8e3305800c78 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1049,7 +1049,17 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
WriteFill( rXPropSet );
WriteOutline( rXPropSet );
WriteShapeEffects( rXPropSet );
- WriteShape3DEffects( rXPropSet );
+
+ bool bHas3DEffectinShape = false;
+ uno::Sequence<beans::PropertyValue> grabBag;
+ rXPropSet->getPropertyValue("InteropGrabBag") >>= grabBag;
+
+ for (auto const& it : std::as_const(grabBag))
+ if (it.Name == "3DEffectProperties")
+ bHas3DEffectinShape = true;
+
+ if( bHas3DEffectinShape)
+ WriteShape3DEffects( rXPropSet );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );