Kaydet (Commit) e1a509f4 authored tarafından Eilidh McAdam's avatar Eilidh McAdam Kaydeden (comit) Noel Power

Apply shadow effect to graphics when importing from docx.

Graphical objects imported into a text document do not seem to support
differing X and Y distances for shadows, so the distance has been
approximated by using the average of the two components.

Change-Id: Ifd0c6d73b618cb2836837348d6f48c0efc0a9dc3
Reviewed-on: https://gerrit.libreoffice.org/703Reviewed-by: 's avatarNoel Power <noel.power@suse.com>
Tested-by: 's avatarNoel Power <noel.power@suse.com>
üst f0efecfb
......@@ -38,6 +38,7 @@
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <cppuhelper/implbase1.hxx>
#include <rtl/ustrbuf.hxx>
......@@ -220,6 +221,12 @@ public:
sal_Int32 nTopMargin;
sal_Int32 nBottomMargin;
bool bShadow;
sal_Int32 nShadowXDistance;
sal_Int32 nShadowYDistance;
sal_Int32 nShadowColor;
sal_Int32 nShadowTransparence;
sal_Int32 nContrast;
sal_Int32 nBrightness;
double fGamma;
......@@ -892,6 +899,15 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
aMediaProperties[0].Name = "URL";
aMediaProperties[0].Value <<= sUrl;
xShapeProps->getPropertyValue("Shadow") >>= m_pImpl->bShadow;
if (m_pImpl->bShadow)
{
xShapeProps->getPropertyValue("ShadowXDistance") >>= m_pImpl->nShadowXDistance;
xShapeProps->getPropertyValue("ShadowYDistance") >>= m_pImpl->nShadowYDistance;
xShapeProps->getPropertyValue("ShadowColor") >>= m_pImpl->nShadowColor;
xShapeProps->getPropertyValue("ShadowTransparence") >>= m_pImpl->nShadowTransparence;
}
m_xGraphicObject = createGraphicObject( aMediaProperties );
bUseShape = !m_xGraphicObject.is( );
......@@ -1310,6 +1326,36 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( aBorderProps[nBorder]), uno::makeAny(aBorderLine));
}
// setting graphic object shadow proerties
if (m_pImpl->bShadow)
{
// Shadow width is approximated by average of X and Y
table::ShadowFormat aShadow;
sal_Int32 nShadowColor = m_pImpl->nShadowColor;
sal_Int32 nShadowWidth = (abs(m_pImpl->nShadowXDistance)
+ abs(m_pImpl->nShadowYDistance)) / 2;
aShadow.ShadowWidth = nShadowWidth;
aShadow.Color = nShadowColor;
// Distances -ve for top and right, +ve for bottom and left
if (m_pImpl->nShadowXDistance > 0)
{
if (m_pImpl->nShadowYDistance > 0)
aShadow.Location = com::sun::star::table::ShadowLocation_BOTTOM_RIGHT;
else
aShadow.Location = com::sun::star::table::ShadowLocation_TOP_RIGHT;
}
else
{
if (m_pImpl->nShadowYDistance > 0)
aShadow.Location = com::sun::star::table::ShadowLocation_BOTTOM_LEFT;
else
aShadow.Location = com::sun::star::table::ShadowLocation_TOP_LEFT;
}
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aShadow));
}
// setting properties for all types
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_DESCRIPTION ),
uno::makeAny( m_pImpl->sAlternativeText ));
......
......@@ -319,6 +319,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_Z_ORDER: sName = "ZOrder"; break;
case PROP_EMBED_FONTS: sName = "EmbedFonts"; break;
case PROP_EMBED_SYSTEM_FONTS: sName = "EmbedSystemFonts"; break;
case PROP_SHADOW_FORMAT: sName = "ShadowFormat"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
......
......@@ -291,6 +291,7 @@ enum PropertyIds
,PROP_Z_ORDER
,PROP_EMBED_FONTS
,PROP_EMBED_SYSTEM_FONTS
,PROP_SHADOW_FORMAT
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment