[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at suse.cz
Tue Aug 13 08:35:39 PDT 2013


 sw/qa/extras/ooxmlexport/data/para-shadow.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx       |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx   |   16 ++++++++--------
 writerfilter/source/dmapper/DomainMapper.cxx   |    6 ++++++
 writerfilter/source/dmapper/PropertyIds.cxx    |    1 +
 writerfilter/source/dmapper/PropertyIds.hxx    |    1 +
 writerfilter/source/dmapper/PropertyMap.cxx    |   22 ++++++++++++++--------
 writerfilter/source/dmapper/PropertyMap.hxx    |    2 ++
 8 files changed, 44 insertions(+), 16 deletions(-)

New commits:
commit 65afb07d56e8faf0cf020de784747046cbcb9d0e
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Aug 13 15:20:24 2013 +0200

    DOCX export of paragraph border drop shadow
    
    Instead of passing over shadow location only in case of page borders, do
    the same for paragraph borders as well.
    
    Change-Id: I311638fe0f41ef47ae351f7d199bfbc8b8aabfbe

diff --git a/sw/qa/extras/ooxmlexport/data/para-shadow.docx b/sw/qa/extras/ooxmlexport/data/para-shadow.docx
new file mode 100755
index 0000000..d35d5f9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/para-shadow.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0b4003e..fc55bb9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -106,6 +106,7 @@ public:
     void testFdo65718();
     void testFdo64350();
     void testFdo67013();
+    void testParaShadow();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -188,6 +189,7 @@ void Test::run()
         {"fdo65718.docx", &Test::testFdo65718},
         {"fdo64350.docx", &Test::testFdo64350},
         {"fdo67013.docx", &Test::testFdo67013},
+        {"para-shadow.docx", &Test::testParaShadow},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -1134,6 +1136,16 @@ void Test::testFdo67013()
     CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aFooterTopBorder.OuterLineWidth);
 }
 
+void Test::testParaShadow()
+{
+    // The problem was that in w:pBdr, child elements had a w:shadow attribute, but that was ignored.
+    table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
+    CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
+    CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
+    // w:sz="48" is in eights of a point, 1 pt is 20 twips.
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(24/8*20)), aShadow.ShadowWidth);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 55de9c9..51caae9 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5125,6 +5125,14 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
 
 
     OutputBorderOptions aOutputBorderOptions = lcl_getBoxBorderOptions();
+    // Check if there is a shadow item
+    const SfxPoolItem* pItem = GetExport().HasItem( RES_SHADOW );
+    if ( pItem )
+    {
+        const SvxShadowItem* pShadowItem = (const SvxShadowItem*)pItem;
+        aOutputBorderOptions.aShadowLocation = pShadowItem->GetLocation();
+    }
+
 
     if ( m_bOpenedSectPr && GetWritingHeaderFooter() == false)
     {
@@ -5133,14 +5141,6 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
         // Check if the distance is larger than 31 points
         aOutputBorderOptions.bCheckDistanceSize = true;
 
-        // Check if there is a shadow item
-        const SfxPoolItem* pItem = GetExport().HasItem( RES_SHADOW );
-        if ( pItem )
-        {
-            const SvxShadowItem* pShadowItem = (const SvxShadowItem*)pItem;
-            aOutputBorderOptions.aShadowLocation = pShadowItem->GetLocation();
-        }
-
         impl_borders( m_pSerializer, rBox, aOutputBorderOptions, &m_pageMargins );
 
         // Special handling for pgBorder
commit 590751d98e10867609c45fff93edae53dfaef3a8
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Aug 13 15:09:12 2013 +0200

    DOCX import of paragraph border drop shadow
    
    Change-Id: I566c491d65b65def65b78afb583624d8272027e0

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index ee863fa..51f43c7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -29,6 +29,7 @@
 #include <ooxml/OOXMLFastTokens.hxx>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
@@ -1797,6 +1798,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
                         rContext->Insert( eBorderId, uno::makeAny( pBorderHandler->getBorderLine()) , true);
                     if(eBorderDistId)
                         rContext->Insert(eBorderDistId, uno::makeAny( pBorderHandler->getLineDistance()), true);
+                    if (nSprmId == NS_sprm::LN_PBrcRight && pBorderHandler->getShadow())
+                    {
+                        table::ShadowFormat aFormat = rContext->getShadowFromBorder(pBorderHandler->getBorderLine());
+                        rContext->Insert(PROP_PARA_SHADOW_FORMAT, uno::makeAny(aFormat));
+                    }
                 }
             }
             else
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index cee68ea..34a0017 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -330,6 +330,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_FIRST_IS_SHARED : sName = "FirstIsShared"; break;
             case PROP_MIRROR_INDENTS : sName = "MirrorIndents"; break;
             case PROP_SURROUND_TEXT_WRAP_SMALL: sName = "SurroundTextWrapSmall"; break;
+            case PROP_PARA_SHADOW_FORMAT: sName = "ParaShadowFormat"; 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 2a6b764..de53e7d 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -301,6 +301,7 @@ enum PropertyIds
         ,PROP_FIRST_IS_SHARED
         ,PROP_MIRROR_INDENTS
         ,PROP_SURROUND_TEXT_WRAP_SMALL
+        ,PROP_PARA_SHADOW_FORMAT
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 257ec94..ccb0506 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -533,14 +533,7 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
 
     if (m_bBorderShadows[BORDER_RIGHT])
     {
-        // In Word UI, shadow is a boolean property, in OOXML, it's a boolean
-        // property of each 4 border type, finally in Writer the border is a
-        // property of the page style, with shadow location, distance and
-        // color. See SwWW8ImplReader::SetShadow().
-        table::ShadowFormat aFormat;
-        aFormat.Color = COL_BLACK;
-        aFormat.Location = table::ShadowLocation_BOTTOM_RIGHT;
-        aFormat.ShadowWidth = m_pBorderLines[BORDER_RIGHT]->LineWidth;
+        table::ShadowFormat aFormat = getShadowFromBorder(*m_pBorderLines[BORDER_RIGHT]);
         if (xFirst.is())
             xFirst->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
         if (xSecond.is())
@@ -548,6 +541,19 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
     }
 }
 
+table::ShadowFormat PropertyMap::getShadowFromBorder(table::BorderLine2 aBorder)
+{
+    // In Word UI, shadow is a boolean property, in OOXML, it's a boolean
+    // property of each 4 border type, finally in Writer the border is a
+    // property of the page style, with shadow location, distance and
+    // color. See SwWW8ImplReader::SetShadow().
+    table::ShadowFormat aFormat;
+    aFormat.Color = COL_BLACK;
+    aFormat.Location = table::ShadowLocation_BOTTOM_RIGHT;
+    aFormat.ShadowWidth = aBorder.LineWidth;
+    return aFormat;
+}
+
 void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet > xStyle,
         PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth )
 {
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index ed0f6cb..da59728 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -48,6 +48,7 @@ namespace com{namespace sun{namespace star{
     }
     namespace table{
         struct BorderLine2;
+        struct ShadowFormat;
     }
 }}}
 
@@ -123,6 +124,7 @@ public:
 #if OSL_DEBUG_LEVEL > 1
     virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
 #endif
+    static com::sun::star::table::ShadowFormat getShadowFromBorder(com::sun::star::table::BorderLine2 aBorder);
 
 };
 typedef boost::shared_ptr<PropertyMap>  PropertyMapPtr;


More information about the Libreoffice-commits mailing list