diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-09-07 19:50:25 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-09-08 11:23:46 +0200 |
commit | aa2faee4b3954b57a613963b501ecf611b3a14ca (patch) | |
tree | 63615779cb7c1f421f49ad3ae744d9eeda6a831d | |
parent | 05e1439107deacb8416c9aee1b6fb2c72a171eaf (diff) |
CharBrd 9.4: DOC filters
-WW8 filter is the only MS filter which ignores padding
of character border.
Change-Id: I17973d8d2ae624d68356729334c701864fe0a10d
-rw-r--r-- | sw/qa/extras/ww8export/data/charborder.odt | bin | 0 -> 8053 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8attributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 60 |
7 files changed, 102 insertions, 17 deletions
diff --git a/sw/qa/extras/ww8export/data/charborder.odt b/sw/qa/extras/ww8export/data/charborder.odt Binary files differnew file mode 100644 index 000000000000..0829c0348fbf --- /dev/null +++ b/sw/qa/extras/ww8export/data/charborder.odt diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index e94dc30f2df5..bde2f6cded7c 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -11,6 +11,7 @@ #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> #include <swmodeltestbase.hxx> @@ -25,6 +26,7 @@ public: void test56513(); void testNewPageStylesTable(); void testFdo42144(); + void testCharacterBorder(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -47,6 +49,7 @@ void Test::run() {"fdo56513.doc", &Test::test56513}, {"new-page-styles.doc", &Test::testNewPageStylesTable}, {"fdo42144.odt", &Test::testFdo42144}, + {"charborder.odt", &Test::testCharacterBorder}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -144,6 +147,42 @@ void Test::testFdo42144() CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xStyle, "FooterIsOn"))); } +void Test::testCharacterBorder() +{ + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); + // WW8 has just one border attribute sprmCBrc for text border so all side has + // the same border + // Border + { + const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder"); + CPPUNIT_ASSERT_EQUAL_BORDER(table::BorderLine2(16711680,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 (dptSpace) it is constant 0 + { + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharTopBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharLeftBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharBottomBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,"CharRightBorderDistance")); + } + + // Shadow (fShadow) + /* WW8 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/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index b082755a57c7..7bef91db78fd 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -950,8 +950,6 @@ private: static void BuildAnlvBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen, const SwNumRule& rRul, const SwNumFmt& rFmt, sal_uInt8 nSwLevel ); - void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine, - sal_uInt16 nDist, sal_uInt16 nSprmNo, bool bShadow); /// Output the numbering table. virtual void WriteNumbering(); @@ -1050,6 +1048,9 @@ public: const SwFmtPageDesc* pNewPgDescFmt = 0, const SwPageDesc* pNewPgDesc = 0 ); + void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine, + sal_uInt16 nDist, sal_uInt16 nSprmNo, bool bShadow); + void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow); void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox ); sal_uInt8 TransCol( const Color& rCol ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index b504ccfb75ed..6cd123ca6bfe 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1204,6 +1204,11 @@ void WW8AttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden ) OutputWW8Attribute( 7, rHidden.GetValue() ); } +void WW8AttributeOutput::CharBorder( const SvxBorderLine* pAllBorder, const sal_uInt16 /*nDist*/, const bool bShadow ) +{ + m_rWW8Export.Out_BorderLine( *m_rWW8Export.pO, pAllBorder, 0, NS_sprm::LN_CBrc, bShadow ); +} + void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) { if ( m_rWW8Export.bWrtWW8 ) @@ -5347,9 +5352,10 @@ void AttributeOutputBase::FormatCharBorder( const SvxBoxItem& rBox ) if( pBorderLine ) { const SfxPoolItem* pItem = GetExport().HasItem( RES_CHRATR_SHADOW ); + const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem); const bool bShadow = - pItem && - static_cast<const SvxShadowItem*>(pItem)->GetLocation() != SVX_SHADOW_NONE; + pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE && + pShadowItem->GetWidth() > 0; CharBorder( pBorderLine, nDist, bShadow ); } diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index d5483efbbee4..c1e0c2779895 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 SvxBorderLine* /*pAllBorder*/, const sal_uInt16 /*nDist*/, const bool /*bShadow*/ ){}; + 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/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 5c74252d50f5..56bfa43cf1d0 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1369,7 +1369,7 @@ private: void GetBorderDistance(const WW8_BRC* pbrc, Rectangle& rInnerDist) const; sal_uInt16 GetParagraphAutoSpace(bool fDontUseHTMLAutoSpacing); bool SetShadow(SvxShadowItem& rShadow, const short *pSizeArray, - const WW8_BRC *pbrc) const; + const WW8_BRC& aRightBrc) const; //returns true is a shadow was set bool SetFlyBordersShadow(SfxItemSet& rFlySet, const WW8_BRC *pbrc, short *SizeArray=0) const; @@ -1673,6 +1673,7 @@ public: // eigentlich private, geht aber leider nur public void Read_BoolItem( sal_uInt16 nId, const sal_uInt8*, short nLen ); void Read_Border( sal_uInt16 nId, const sal_uInt8* pData, short nLen ); + void Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, short nLen ); void Read_Tab( sal_uInt16 nId, const sal_uInt8* pData, short nLen ); void Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen); void Read_FldVanish( sal_uInt16 nId, const sal_uInt8* pData, short nLen ); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index e8766e0cb720..28ca3db10130 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -1290,14 +1290,14 @@ void GetLineIndex(SvxBoxItem &rBox, short nLineThickness, short nSpace, sal_uInt } void Set1Border(bool bVer67, SvxBoxItem &rBox, const WW8_BRC& rBor, - sal_uInt16 nOOIndex, sal_uInt16 nWWIndex, short *pSize=0) + sal_uInt16 nOOIndex, sal_uInt16 nWWIndex, short *pSize, const bool bIgnoreSpace) { sal_uInt8 nCol; short nSpace, nIdx; short nLineThickness = rBor.DetermineBorderProperties(bVer67,&nSpace,&nCol, &nIdx); - GetLineIndex(rBox, nLineThickness, nSpace, nCol, nIdx, nOOIndex, nWWIndex, pSize ); + GetLineIndex(rBox, nLineThickness, bIgnoreSpace ? 0 : nSpace, nCol, nIdx, nOOIndex, nWWIndex, pSize ); } @@ -1365,7 +1365,7 @@ bool SwWW8ImplReader::SetBorder(SvxBoxItem& rBox, const WW8_BRC* pbrc, const WW8_BRC& rB = pbrc[ aIdArr[ i ] ]; if( !rB.IsEmpty(bVer67)) { - Set1Border(bVer67, rBox, rB, aIdArr[i+1], aIdArr[i], pSizeArray); + Set1Border(bVer67, rBox, rB, aIdArr[i+1], aIdArr[i], pSizeArray, false); bChange = true; } else if ( nSetBorders & (1 << aIdArr[i]) ) @@ -1389,18 +1389,18 @@ bool SwWW8ImplReader::SetBorder(SvxBoxItem& rBox, const WW8_BRC* pbrc, bool SwWW8ImplReader::SetShadow(SvxShadowItem& rShadow, const short *pSizeArray, - const WW8_BRC *pbrc) const + const WW8_BRC& aRightBrc) const { bool bRet = ( - ( bVer67 ? (pbrc[WW8_RIGHT].aBits1[ 0 ] & 0x20 ) - : (pbrc[WW8_RIGHT].aBits2[ 1 ] & 0x20 ) ) + ( bVer67 ? (aRightBrc.aBits1[ 0 ] & 0x20 ) + : (aRightBrc.aBits2[ 1 ] & 0x20 ) ) && (pSizeArray && pSizeArray[WW8_RIGHT]) ); if (bRet) { rShadow.SetColor(Color(COL_BLACK)); //i120718 - short nVal = pbrc[WW8_RIGHT].DetermineBorderProperties(bVer67); + short nVal = aRightBrc.DetermineBorderProperties(bVer67); //End if (nVal < 0x10) nVal = 0x10; @@ -1445,7 +1445,7 @@ bool SwWW8ImplReader::SetFlyBordersShadow(SfxItemSet& rFlySet, // fShadow SvxShadowItem aShadow( RES_SHADOW ); - if( SetShadow( aShadow, pSizeArray, pbrc )) + if( SetShadow( aShadow, pSizeArray, pbrc[WW8_RIGHT] )) { bShadowed = true; rFlySet.Put( aShadow ); @@ -4648,7 +4648,7 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67) return aShade.aColor.GetColor(); } -void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8* , short nLen) +void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen) { if( nLen < 0 ) { @@ -4715,13 +4715,51 @@ void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8* , short nLen) NewAttr( aBox ); SvxShadowItem aS(RES_SHADOW); - if( SetShadow( aS, &aSizeArray[0], aBrcs ) ) + if( SetShadow( aS, &aSizeArray[0], aBrcs[WW8_RIGHT] ) ) NewAttr( aS ); } } } } +void SwWW8ImplReader::Read_CharBorder(sal_uInt16 /*nId*/, const sal_uInt8* pData, short nLen ) +{ + //Ignore this old border type + if (!bVer67 && pPlcxMan && pPlcxMan->GetChpPLCF()->HasSprm(0xCA72)) + return; + + if( nLen < 0 ) + { + pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BOX ); + pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_SHADOW ); + } + else + { + const SvxBoxItem* pBox + = (const SvxBoxItem*)GetFmtAttr( RES_CHRATR_BOX ); + if( pBox ) + { + SvxBoxItem aBoxItem(RES_CHRATR_BOX); + aBoxItem = *pBox; + WW8_BRC aBrc; + _SetWW8_BRC(bVer67, aBrc, pData); + + Set1Border(bVer67, aBoxItem, aBrc, BOX_LINE_TOP, 0, 0, true); + Set1Border(bVer67, aBoxItem, aBrc, BOX_LINE_BOTTOM, 0, 0, true); + Set1Border(bVer67, aBoxItem, aBrc, BOX_LINE_LEFT, 0, 0, true); + Set1Border(bVer67, aBoxItem, aBrc, BOX_LINE_RIGHT, 0, 0, true); + NewAttr( aBoxItem ); + + short aSizeArray[WW8_RIGHT+1]={0}; aSizeArray[WW8_RIGHT] = 1; + SvxShadowItem aShadowItem(RES_CHRATR_SHADOW); + if( SetShadow( aShadowItem, &aSizeArray[0], aBrc ) ) + NewAttr( aShadowItem ); + } + } + + +} + void SwWW8ImplReader::Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, short nLen ) { // set Hyphenation flag @@ -5802,7 +5840,7 @@ const wwSprmDispatcher *GetWW8SprmDispatcher() //sttbRMark;short; {0x6864, 0}, //"sprmCDttmRMarkDel" //chp.dttmRMarkDel;DTTM;long; - {0x6865, 0}, //"sprmCBrc" chp.brc;BRC;long; + {0x6865, &SwWW8ImplReader::Read_CharBorder}, //"sprmCBrc" chp.brc;BRC;long; {0x4866, &SwWW8ImplReader::Read_CharShadow}, //"sprmCShd" chp.shd;SHD;short; {0x4867, 0}, //"sprmCIdslRMarkDel" //chp.idslRMReasonDel;an index |