summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-09-08 10:46:12 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-09-08 11:23:46 +0200
commit05e1439107deacb8416c9aee1b6fb2c72a171eaf (patch)
tree333dc102d1faf5144b859e964b4a534f25e2f508 /sw
parentcfc64c7e895d990023400573d8416ce80cf0da29 (diff)
CharBrd 9.3: RTF filters
-Use sprm:CBrc attribute for all MS filter (for ooxml too). -Extract general code to FormatCharBorder() method, it selects the border side and decides whether add shadow to the border. -RTF export has a color table, which must be filled with border colors before the actual export.temp Change-Id: Ic3ceae6e19ddc2ed5aaa8de85617f9a592289b4f
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/charborder.odtbin8042 -> 8052 bytes
-rw-r--r--sw/qa/extras/rtfexport/data/charborder.odtbin0 -> 8052 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx40
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx5
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx39
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx11
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx13
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx4
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx39
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx2
12 files changed, 113 insertions, 44 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/charborder.odt b/sw/qa/extras/ooxmlexport/data/charborder.odt
index 149abfc6ffe7..67dd89b099e0 100644
--- a/sw/qa/extras/ooxmlexport/data/charborder.odt
+++ b/sw/qa/extras/ooxmlexport/data/charborder.odt
Binary files differ
diff --git a/sw/qa/extras/rtfexport/data/charborder.odt b/sw/qa/extras/rtfexport/data/charborder.odt
new file mode 100644
index 000000000000..bea79c147153
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/charborder.odt
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 81340e43af36..2cd5cfa4dbf5 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -68,6 +68,7 @@ public:
void testTextframeTable();
void testFdo66682();
void testParaShadow();
+ void testCharacterBorder();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -125,6 +126,7 @@ void Test::run()
{"textframe-table.rtf", &Test::testTextframeTable},
{"fdo66682.rtf", &Test::testFdo66682},
{"para-shadow.rtf", &Test::testParaShadow},
+ {"charborder.odt", &Test::testCharacterBorder},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -633,6 +635,44 @@ void Test::testParaShadow()
CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(60)), aShadow.ShadowWidth);
}
+void Test::testCharacterBorder()
+{
+ uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
+ // RTF has just one border attribute(chbrdr) for text border so all side has
+ // the same border with the same padding
+ // Border
+ {
+ const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
+ CPPUNIT_ASSERT_EQUAL_BORDER(table::BorderLine2(16737792,0,318,0,0,318), aTopBorder);
+ CPPUNIT_ASSERT_EQUAL_BORDER(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
+ CPPUNIT_ASSERT_EQUAL_BORDER(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
+ CPPUNIT_ASSERT_EQUAL_BORDER(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
+ }
+
+ // Padding (brsp)
+ {
+ const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance");
+ // In the original odt file it is 150, but the unit conversion round it down.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
+ CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
+ }
+
+ // Shadow (brdrsh)
+ /* RTF use just one bool value for shadow so the next conversions
+ are made during an export-import round
+ color: any -> black
+ location: any -> bottom-right
+ width: any -> border width */
+ {
+ const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
+ CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
+ CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 646030ada11f..259503cbe94c 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -118,6 +118,8 @@ class SwLineNumberInfo;
class SwNumRule;
class wwFont;
+using ::editeng::SvxBorderLine;
+
class String;
namespace rtl { class OUString; }
@@ -439,7 +441,8 @@ protected:
virtual void CharHidden( const SvxCharHiddenItem& ) = 0;
/// Sfx item RES_CHRATR_BOX
- virtual void CharBorder( const SvxBoxItem& rBox ) = 0;
+ void FormatCharBorder( const SvxBoxItem& rBox );
+ virtual void CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow ) = 0;
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index cddb20bed9cd..c5b78ff8a578 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -112,8 +112,6 @@
#include <stdio.h>
#endif
-using ::editeng::SvxBorderLine;
-
using namespace oox;
using namespace docx;
using namespace sax_fastparser;
@@ -4081,41 +4079,10 @@ void DocxAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
m_pSerializer->singleElementNS( XML_w, XML_vanish, FSNS( XML_w, XML_val ), "false", FSEND );
}
-void DocxAttributeOutput::CharBorder( const SvxBoxItem& rBox )
+void DocxAttributeOutput::CharBorder(
+ const SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow )
{
- // Get one of the borders (if there is any border then in docx also will be)
- const SvxBorderLine* pBorderLine = 0;
- sal_uInt16 nDist = 0;
- if( rBox.GetTop() )
- {
- pBorderLine = rBox.GetTop();
- nDist = rBox.GetDistance( BOX_LINE_TOP );
- }
- else if( rBox.GetLeft() )
- {
- pBorderLine = rBox.GetLeft();
- nDist = rBox.GetDistance( BOX_LINE_LEFT );
- }
- else if( rBox.GetBottom() )
- {
- pBorderLine = rBox.GetBottom();
- nDist = rBox.GetDistance( BOX_LINE_BOTTOM );
- }
- else if( rBox.GetRight() )
- {
- pBorderLine = rBox.GetRight();
- nDist = rBox.GetDistance( BOX_LINE_RIGHT );
- }
-
- if( pBorderLine )
- {
- const SfxPoolItem* pItem = GetExport().HasItem( RES_CHRATR_SHADOW );
- const bool bShadow =
- pItem &&
- static_cast<const SvxShadowItem*>(pItem)->GetLocation() != SVX_SHADOW_NONE;
-
- impl_borderLine( m_pSerializer, XML_bdr, pBorderLine, nDist, bShadow );
- }
+ impl_borderLine( m_pSerializer, XML_bdr, pAllBorder, nDist, bShadow );
}
void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink )
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index c217fb95ff61..8333517f031d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -473,7 +473,7 @@ protected:
virtual void CharHidden( const SvxCharHiddenItem& rHidden );
/// Sfx item RES_CHRATR_BOX
- virtual void CharBorder( const SvxBoxItem& rBox );
+ virtual void CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow );
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 065278c807f0..c4d3b29289cf 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -101,7 +101,6 @@
#include <com/sun/star/i18n/ScriptType.hpp>
-using ::editeng::SvxBorderLine;
using namespace nsSwDocInfoSubType;
using namespace nsFieldFlags;
using namespace sw::util;
@@ -2361,6 +2360,16 @@ void RtfAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
m_aStyles.append((sal_Int32)0);
}
+void RtfAttributeOutput::CharBorder(
+ const SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow )
+{
+ SAL_INFO("sw.rtf", OSL_THIS_FUNC);
+
+ m_aStyles.append(
+ OutBorderLine(m_rExport, pAllBorder, OOO_STRING_SVTOOLS_RTF_CHBRDR,
+ nDist, bShadow ? SVX_SHADOW_BOTTOMRIGHT : SVX_SHADOW_NONE));
+}
+
void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index b332dd31e7f8..51fdcef6e17e 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -313,7 +313,7 @@ protected:
virtual void CharHidden( const SvxCharHiddenItem& rHidden );
/// Sfx item RES_CHRATR_BOX
- virtual void CharBorder( const SvxBoxItem& /*rBox*/ ){};
+ virtual void CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow );
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 0787f37acb11..87dd8d3034f6 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1005,7 +1005,20 @@ void RtfExport::OutColorTable()
{
if( 0 != (pBox = (const SvxBoxItem*)rPool.GetItem2( RES_BOX, n ) ))
InsColorLine( *pBox );
+ }
}
+
+ {
+ const SvxBoxItem* pCharBox;
+ if( 0 != ( pCharBox = (const SvxBoxItem*)rPool.GetPoolDefaultItem(
+ RES_CHRATR_BOX ) ))
+ InsColorLine( *pCharBox );
+ nMaxItem = rPool.GetItemCount2(RES_CHRATR_BOX);
+ for (sal_uInt32 n = 0; n < nMaxItem; ++n)
+ {
+ if( 0 != (pCharBox = (const SvxBoxItem*)rPool.GetItem2( RES_CHRATR_BOX, n ) ))
+ InsColorLine( *pCharBox );
+ }
}
for (size_t n = 0; n < m_aColTbl.size(); ++n)
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 1df63f7e185e..0c34fc72403e 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -463,7 +463,7 @@ void SwWW8AttrIter::OutAttr( xub_StrLen nSwPos, bool bRuby )
sw::PoolItems aExportItems;
GetPoolItems( aExportSet, aExportItems, false );
- if( nSwPos == 0 )
+ if( rNd.GetpSwpHints() == 0 )
m_rExport.SetCurItemSet(&aExportSet);
sw::cPoolItemIter aEnd = aRangeItems.end();
@@ -486,7 +486,7 @@ void SwWW8AttrIter::OutAttr( xub_StrLen nSwPos, bool bRuby )
m_rExport.pOutFmtNode = pOldMod;
}
- if( nSwPos == 0 )
+ if( rNd.GetpSwpHints() == 0 )
m_rExport.SetCurItemSet(0);
OSL_ENSURE( pFont, "must be *some* font associated with this txtnode" );
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index fef7f4fd3351..b504ccfb75ed 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5149,7 +5149,7 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) );
break;
case RES_CHRATR_BOX:
- CharBorder( static_cast< const SvxBoxItem& >( rHt ) );
+ FormatCharBorder( static_cast< const SvxBoxItem& >( rHt ) );
break;
case RES_TXTATR_INETFMT:
@@ -5318,4 +5318,41 @@ void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, sal_Bool b
}
}
+void AttributeOutputBase::FormatCharBorder( const SvxBoxItem& rBox )
+{
+ // Get one of the borders (if there is any border then in docx also will be)
+ const SvxBorderLine* pBorderLine = 0;
+ sal_uInt16 nDist = 0;
+ if( rBox.GetTop() )
+ {
+ pBorderLine = rBox.GetTop();
+ nDist = rBox.GetDistance( BOX_LINE_TOP );
+ }
+ else if( rBox.GetLeft() )
+ {
+ pBorderLine = rBox.GetLeft();
+ nDist = rBox.GetDistance( BOX_LINE_LEFT );
+ }
+ else if( rBox.GetBottom() )
+ {
+ pBorderLine = rBox.GetBottom();
+ nDist = rBox.GetDistance( BOX_LINE_BOTTOM );
+ }
+ else if( rBox.GetRight() )
+ {
+ pBorderLine = rBox.GetRight();
+ nDist = rBox.GetDistance( BOX_LINE_RIGHT );
+ }
+
+ if( pBorderLine )
+ {
+ const SfxPoolItem* pItem = GetExport().HasItem( RES_CHRATR_SHADOW );
+ const bool bShadow =
+ pItem &&
+ static_cast<const SvxShadowItem*>(pItem)->GetLocation() != SVX_SHADOW_NONE;
+
+ CharBorder( pBorderLine, nDist, bShadow );
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 3ab2e799bb40..d5483efbbee4 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -294,7 +294,7 @@ protected:
virtual void CharHidden( const SvxCharHiddenItem& );
/// Sfx item RES_CHRATR_BOX
- virtual void CharBorder( const SvxBoxItem& /*rBox*/ ){};
+ virtual void CharBorder( const SvxBorderLine* /*pAllBorder*/, const sal_uInt16 /*nDist*/, const bool /*bShadow*/ ){};
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );