diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/charfmt.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/charborder.odt | bin | 0 -> 8042 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 50 | ||||
-rw-r--r-- | sw/source/filter/ww8/attributeoutputbase.hxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 37 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8attributeoutput.hxx | 3 |
10 files changed, 128 insertions, 6 deletions
diff --git a/sw/inc/charfmt.hxx b/sw/inc/charfmt.hxx index 06a865cd62e7..0bc2ff09032d 100644 --- a/sw/inc/charfmt.hxx +++ b/sw/inc/charfmt.hxx @@ -42,7 +42,7 @@ public: namespace CharFmt { - extern const SfxItemSet* GetItemSet( const SfxPoolItem& rAttr ); + SW_DLLPUBLIC extern const SfxItemSet* GetItemSet( const SfxPoolItem& rAttr ); extern const SfxPoolItem* GetItem( const SwTxtAttr& rAttr, sal_uInt16 nWhich ); extern bool IsItemIncluded( const sal_uInt16 nWhich, const SwTxtAttr *pAttr ); } diff --git a/sw/qa/extras/ooxmlexport/data/charborder.odt b/sw/qa/extras/ooxmlexport/data/charborder.odt Binary files differnew file mode 100644 index 000000000000..149abfc6ffe7 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/charborder.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 5dc83f5b2d1a..a2f7a55581b8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -116,6 +116,7 @@ public: void testFdo68418(); void testA4AndBorders(); void testFdo68787(); + void testCharacterBorder(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -208,6 +209,7 @@ void Test::run() {"fdo68418.docx", &Test::testFdo68418}, {"a4andborders.docx", &Test::testA4AndBorders}, {"fdo68787.docx", &Test::testFdo68787}, + {"charborder.odt", &Test::testCharacterBorder}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -1273,6 +1275,54 @@ void Test::testFdo68787() CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth")); } +void Test::testCharacterBorder() +{ + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); + // OOXML has just one border attribute(<w:bdr>) 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 (w:space) + { + 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 (w:shadow) + /* OOXML 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); + } + + // Also check shadow when it is in middle of the paragraph + // (problem can be during export with SwWW8AttrIter::HasTextItem()) + { + uno::Reference<beans::XPropertySet> xMiddleRun(getRun(getParagraph(2),2), uno::UNO_QUERY); + const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xMiddleRun, "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 c415d3c93e85..646030ada11f 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -68,6 +68,7 @@ class SvxTwoLinesItem; class SvxCharScaleWidthItem; class SvxCharReliefItem; class SvxCharHiddenItem; +class SvxBoxItem; class SwFmtINetFmt; class SwFmtCharFmt; class SwFmtFld; @@ -437,6 +438,9 @@ protected: /// Sfx item RES_CHRATR_HIDDEN virtual void CharHidden( const SvxCharHiddenItem& ) = 0; + /// Sfx item RES_CHRATR_BOX + virtual void CharBorder( const SvxBoxItem& rBox ) = 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 b7c528adace7..cddb20bed9cd 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4081,6 +4081,43 @@ 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 ) +{ + // 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 ); + } +} + void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink ) { const SwTxtINetFmt* pINetFmt = rLink.GetTxtINetFmt(); diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 5e297aab59c9..c217fb95ff61 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -472,6 +472,9 @@ protected: /// Sfx item RES_CHRATR_HIDDEN virtual void CharHidden( const SvxCharHiddenItem& rHidden ); + /// Sfx item RES_CHRATR_BOX + virtual void CharBorder( const SvxBoxItem& rBox ); + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFmtINetFmt& ); diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index ea115bfa1f02..b332dd31e7f8 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -312,6 +312,9 @@ protected: /// Sfx item RES_CHRATR_HIDDEN virtual void CharHidden( const SvxCharHiddenItem& rHidden ); + /// Sfx item RES_CHRATR_BOX + virtual void CharBorder( const SvxBoxItem& /*rBox*/ ){}; + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFmtINetFmt& ); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 4664938de76d..1df63f7e185e 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -463,6 +463,9 @@ void SwWW8AttrIter::OutAttr( xub_StrLen nSwPos, bool bRuby ) sw::PoolItems aExportItems; GetPoolItems( aExportSet, aExportItems, false ); + if( nSwPos == 0 ) + m_rExport.SetCurItemSet(&aExportSet); + sw::cPoolItemIter aEnd = aRangeItems.end(); for ( sw::cPoolItemIter aI = aRangeItems.begin(); aI != aEnd; ++aI ) { @@ -483,6 +486,9 @@ void SwWW8AttrIter::OutAttr( xub_StrLen nSwPos, bool bRuby ) m_rExport.pOutFmtNode = pOldMod; } + if( nSwPos == 0 ) + m_rExport.SetCurItemSet(0); + OSL_ENSURE( pFont, "must be *some* font associated with this txtnode" ); if ( pFont ) { @@ -584,7 +590,6 @@ const SfxPoolItem* SwWW8AttrIter::HasTextItem( sal_uInt16 nWhich ) const { const SfxPoolItem* pRet = 0; const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - if (pTxtAttrs && !m_rExport.m_aCurrentCharPropStarts.empty()) { xub_StrLen nTmpSwPos = m_rExport.m_aCurrentCharPropStarts.top(); @@ -594,11 +599,26 @@ const SfxPoolItem* SwWW8AttrIter::HasTextItem( sal_uInt16 nWhich ) const const SfxPoolItem* pItem = &pHt->GetAttr(); const xub_StrLen* pAtrEnd = 0; if( 0 != ( pAtrEnd = pHt->GetEnd() ) && // only Attr with an end - nWhich == pItem->Which() && nTmpSwPos >= *pHt->GetStart() && nTmpSwPos < *pAtrEnd ) { - pRet = pItem; // found it - break; + if ( nWhich == pItem->Which() ) + { + pRet = pItem; // found it + break; + } + else if( RES_TXTATR_INETFMT == pHt->Which() || + RES_TXTATR_CHARFMT == pHt->Which() || + RES_TXTATR_AUTOFMT == pHt->Which() ) + { + const SfxItemSet* pSet = CharFmt::GetItemSet( pHt->GetAttr() ); + const SfxPoolItem* pCharItem; + if ( pSet && + SFX_ITEM_SET == pSet->GetItemState( nWhich, pHt->Which() != RES_TXTATR_AUTOFMT, &pCharItem ) ) + { + pRet = pCharItem; // found it + break; + } + } } else if (nTmpSwPos < *pHt->GetStart()) break; // nothing more to come diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 188b99589073..fef7f4fd3351 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -287,7 +287,6 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool GetPoolItems( rSet, aItems, bExportParentItemSet ); if ( bChpFmt ) ExportPoolItemsToCHP(aItems, nScript); - if ( bPapFmt ) { sw::cPoolItemIter aEnd = aItems.end(); @@ -5149,6 +5148,9 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) case RES_CHRATR_HIDDEN: CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) ); break; + case RES_CHRATR_BOX: + CharBorder( static_cast< const SvxBoxItem& >( rHt ) ); + break; case RES_TXTATR_INETFMT: TextINetFormat( static_cast< const SwFmtINetFmt& >( rHt ) ); diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 3ffb2aa051a3..3ab2e799bb40 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -293,6 +293,9 @@ protected: /// Sfx item RES_CHRATR_HIDDEN virtual void CharHidden( const SvxCharHiddenItem& ); + /// Sfx item RES_CHRATR_BOX + virtual void CharBorder( const SvxBoxItem& /*rBox*/ ){}; + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFmtINetFmt& ); |