[Libreoffice-commits] .: writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 26 12:32:59 PDT 2012


 writerfilter/source/dmapper/GraphicImport.cxx |   46 ++++++++++++++++++++++++++
 writerfilter/source/dmapper/PropertyIds.cxx   |    1 
 writerfilter/source/dmapper/PropertyIds.hxx   |    1 
 3 files changed, 48 insertions(+)

New commits:
commit e1a509f4a362d21248b439c99e3b55f4fa9ba1bd
Author: Eilidh McAdam <eilidh at lanedo.com>
Date:   Wed Sep 26 12:36:08 2012 +0100

    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/703
    Reviewed-by: Noel Power <noel.power at suse.com>
    Tested-by: Noel Power <noel.power at suse.com>

diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 48cdf6c..cbd59f9 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -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 ));
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index f6e6f69..1fbf3d1 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -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 ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 5f21ee1..b29d760 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -291,6 +291,7 @@ enum PropertyIds
         ,PROP_Z_ORDER
         ,PROP_EMBED_FONTS
         ,PROP_EMBED_SYSTEM_FONTS
+        ,PROP_SHADOW_FORMAT
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier


More information about the Libreoffice-commits mailing list