[Libreoffice-commits] core.git: 2 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Thu May 30 03:34:50 PDT 2013
sw/qa/extras/ooxmlimport/data/page-border-shadow.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 +++++++++
writerfilter/source/dmapper/BorderHandler.cxx | 9 ++++++-
writerfilter/source/dmapper/BorderHandler.hxx | 2 +
writerfilter/source/dmapper/DomainMapper.cxx | 2 -
writerfilter/source/dmapper/PageBordersHandler.cxx | 6 +++-
writerfilter/source/dmapper/PageBordersHandler.hxx | 1
writerfilter/source/dmapper/PropertyMap.cxx | 23 +++++++++++++++++-
writerfilter/source/dmapper/PropertyMap.hxx | 3 +-
9 files changed, 52 insertions(+), 6 deletions(-)
New commits:
commit 1727b268645ae4f7328ed00135abe1e316311ba8
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu May 30 12:18:30 2013 +0200
bnc#817956 page border shadow testcase
Change-Id: I1ded79d89dcceb3bae5926a2f217cde8bf6aa830
diff --git a/sw/qa/extras/ooxmlimport/data/page-border-shadow.docx b/sw/qa/extras/ooxmlimport/data/page-border-shadow.docx
new file mode 100755
index 0000000..65a2273
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/page-border-shadow.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 36fc883..5a268e4 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -115,6 +115,7 @@ public:
void testIndentation();
void testPageBackground();
void testWatermark();
+ void testPageBorderShadow();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -198,6 +199,7 @@ void Test::run()
{"indentation.docx", &Test::testIndentation},
{"page-background.docx", &Test::testPageBackground},
{"watermark.docx", &Test::testWatermark},
+ {"page-border-shadow.docx", &Test::testPageBorderShadow},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1418,6 +1420,16 @@ void Test::testWatermark()
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
}
+void Test::testPageBorderShadow()
+{
+ // The problem was that in w:pgBorders, child elements had a w:shadow attribute, but that was ignored.
+ table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "ShadowFormat");
+ 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(48/8*20)), aShadow.ShadowWidth);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 59db0cb6752f269893e2697bf561643aec92bdf1
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu May 30 11:55:37 2013 +0200
bnc#817956 DOCX import of page border shadow
See the comment in SectionPropertyMap::ApplyBorderToPageStyles() on what and
how is mapped. The control flow is like this: BorderHandler::lcl_attribute()
notices w:shadow, then PageBordersHandler::lcl_sprm() gets it, passes it to
SectionPropertyMap::SetBorder(), finally
SectionPropertyMap::ApplyBorderToPageStyles() uses the UNO API.
Change-Id: Ib0aef3245f58c62655769357f1f4dd07eef77f62
diff --git a/writerfilter/source/dmapper/BorderHandler.cxx b/writerfilter/source/dmapper/BorderHandler.cxx
index 068c210..c219d39 100644
--- a/writerfilter/source/dmapper/BorderHandler.cxx
+++ b/writerfilter/source/dmapper/BorderHandler.cxx
@@ -39,6 +39,7 @@ m_nLineWidth(15), // Word default, in twips
m_nLineType(0),
m_nLineColor(0),
m_nLineDistance(0),
+m_bShadow(false),
m_bOOXML( bOOXML )
{
const int nBorderCount(BORDER_COUNT);
@@ -83,7 +84,8 @@ void BorderHandler::lcl_attribute(Id rName, Value & rVal)
m_nLineDistance = ConversionHelper::convertTwipToMM100( nIntValue * 20 );
break;
case NS_rtf::LN_FSHADOW: // 0x2875
- //if 1 then line has shadow - unsupported
+ m_bShadow = nIntValue;
+ break;
case NS_rtf::LN_FFRAME: // 0x2876
case NS_rtf::LN_UNUSED2_15: // 0x2877
// ignored
@@ -173,6 +175,11 @@ table::BorderLine2 BorderHandler::getBorderLine()
return aBorderLine;
}
+bool BorderHandler::getShadow()
+{
+ return m_bShadow;
+}
+
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/BorderHandler.hxx b/writerfilter/source/dmapper/BorderHandler.hxx
index 7a6eec9..3d43c4a 100644
--- a/writerfilter/source/dmapper/BorderHandler.hxx
+++ b/writerfilter/source/dmapper/BorderHandler.hxx
@@ -50,6 +50,7 @@ private:
sal_Int32 m_nLineType;
sal_Int32 m_nLineColor;
sal_Int32 m_nLineDistance;
+ bool m_bShadow;
bool m_bOOXML;
bool m_aFilledLines[BORDER_COUNT];
@@ -66,6 +67,7 @@ public:
::boost::shared_ptr<PropertyMap> getProperties();
::com::sun::star::table::BorderLine2 getBorderLine();
sal_Int32 getLineDistance() const { return m_nLineDistance;}
+ bool getShadow();
};
typedef boost::shared_ptr< BorderHandler > BorderHandlerPtr;
}}
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index cfc7c1a..47c332b 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2674,7 +2674,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
BORDER_BOTTOM,
BORDER_RIGHT
};
- pSectionContext->SetBorder( aPositions[nSprmId - NS_sprm::LN_SBrcTop], nLineDistance, aBorderLine );
+ pSectionContext->SetBorder( aPositions[nSprmId - NS_sprm::LN_SBrcTop], nLineDistance, aBorderLine, /*bShadow =*/ false );
}
}
break;
diff --git a/writerfilter/source/dmapper/PageBordersHandler.cxx b/writerfilter/source/dmapper/PageBordersHandler.cxx
index 9ce4269..471a85a 100644
--- a/writerfilter/source/dmapper/PageBordersHandler.cxx
+++ b/writerfilter/source/dmapper/PageBordersHandler.cxx
@@ -28,7 +28,8 @@ namespace dmapper {
_PgBorder::_PgBorder( ) :
m_nDistance( 0 ),
- m_ePos( BORDER_RIGHT )
+ m_ePos( BORDER_RIGHT ),
+ m_bShadow(false)
{
}
@@ -123,6 +124,7 @@ void PageBordersHandler::lcl_sprm( Sprm& rSprm )
aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
aPgBorder.m_ePos = ePos;
+ aPgBorder.m_bShadow = pBorderHandler->getShadow();
m_aBorders.push_back( aPgBorder );
}
}
@@ -136,7 +138,7 @@ void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
for ( int i = 0, length = m_aBorders.size( ); i < length; i++ )
{
_PgBorder aBorder = m_aBorders[i];
- pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine );
+ pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine, aBorder.m_bShadow );
}
}
diff --git a/writerfilter/source/dmapper/PageBordersHandler.hxx b/writerfilter/source/dmapper/PageBordersHandler.hxx
index 7d5af39..b6aebf5 100644
--- a/writerfilter/source/dmapper/PageBordersHandler.hxx
+++ b/writerfilter/source/dmapper/PageBordersHandler.hxx
@@ -40,6 +40,7 @@ public:
com::sun::star::table::BorderLine2 m_rLine;
sal_Int32 m_nDistance;
BorderPosition m_ePos;
+ bool m_bShadow;
_PgBorder( );
~_PgBorder( );
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 2ab0ff5..9de69fc 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/style/PageStyleLayout.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
@@ -285,7 +286,10 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
nSectionNumber = nNumber++;
memset(&m_pBorderLines, 0x00, sizeof(m_pBorderLines));
for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
+ {
m_nBorderDistances[ nBorder ] = -1;
+ m_bBorderShadows[nBorder] = false;
+ }
//todo: set defaults in ApplyPropertiesToPageStyles
//initialize defaults
PaperInfo aLetter(PAPER_LETTER);
@@ -405,11 +409,12 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle(
}
-void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine2& rBorderLine )
+void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine2& rBorderLine, bool bShadow )
{
delete m_pBorderLines[ePos];
m_pBorderLines[ePos] = new table::BorderLine2( rBorderLine );
m_nBorderDistances[ePos] = nLineDistance;
+ m_bBorderShadows[ePos] = bShadow;
}
@@ -502,6 +507,22 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
}
}
+
+ 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;
+ if (xFirst.is())
+ xFirst->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
+ if (xSecond.is())
+ xSecond->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
+ }
}
void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet > xStyle,
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index cc2821f..e48c5c5 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -149,6 +149,7 @@ class SectionPropertyMap : public PropertyMap
::com::sun::star::table::BorderLine2* m_pBorderLines[4];
sal_Int32 m_nBorderDistances[4];
sal_Int32 m_nBorderParams;
+ bool m_bBorderShadows[4];
bool m_bTitlePage;
sal_Int16 m_nColumnCount;
@@ -219,7 +220,7 @@ public:
const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xTextFactory,
bool bFirst );
- void SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const ::com::sun::star::table::BorderLine2& rBorderLine );
+ void SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const ::com::sun::star::table::BorderLine2& rBorderLine, bool bShadow );
void SetBorderParams( sal_Int32 nSet ) { m_nBorderParams = nSet; }
void SetColumnCount( sal_Int16 nCount ) { m_nColumnCount = nCount; }
More information about the Libreoffice-commits
mailing list