cui/source/options/optfltr.cxx | 19 cui/source/options/optfltr.hxx | 3 cui/uiconfig/ui/optfltrembedpage.ui | 94 +++ dev/null |binary filter/source/msfilter/util.cxx | 42 + include/filter/msfilter/util.hxx | 9 include/svl/grabbagitem.hxx | 5 include/unotools/fltrcfg.hxx | 5 include/xmloff/txtprmap.hxx | 2 officecfg/registry/schema/org/openoffice/Office/Common.xcs | 7 sw/qa/extras/globalfilter/data/char_background.odt |binary sw/qa/extras/globalfilter/data/char_background_editing.docx |binary sw/qa/extras/globalfilter/data/char_highlight.docx |binary sw/qa/extras/globalfilter/globalfilter.cxx | 311 +++++++++++- sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 49 - sw/qa/extras/rtfexport/data/fdo79599.rtf | 38 - sw/qa/extras/rtfexport/rtfexport.cxx | 9 sw/qa/extras/rtfimport/data/fdo79599.rtf | 38 - sw/qa/extras/rtfimport/rtfimport.cxx | 56 -- sw/source/filter/ww8/attributeoutputbase.hxx | 1 sw/source/filter/ww8/docxattributeoutput.cxx | 42 - sw/source/filter/ww8/docxattributeoutput.hxx | 6 sw/source/filter/ww8/rtfattributeoutput.cxx | 11 sw/source/filter/ww8/rtfattributeoutput.hxx | 2 sw/source/filter/ww8/rtfexport.cxx | 19 sw/source/filter/ww8/wrtww8.cxx | 2 sw/source/filter/ww8/wrtww8.hxx | 2 sw/source/filter/ww8/wrtww8gr.cxx | 2 sw/source/filter/ww8/ww8atr.cxx | 94 +-- sw/source/filter/ww8/ww8attributeoutput.hxx | 2 sw/source/filter/ww8/ww8par6.cxx | 17 sw/source/ui/envelp/envfmt.cxx | 2 sw/source/uibase/app/docst.cxx | 4 sw/source/uibase/inc/uitool.hxx | 3 sw/source/uibase/shells/textsh1.cxx | 56 ++ sw/source/uibase/utlui/uitool.cxx | 55 +- unotools/source/config/fltrcfg.cxx | 33 + writerfilter/source/dmapper/DomainMapper.cxx | 22 writerfilter/source/dmapper/DomainMapper.hxx | 2 writerfilter/source/dmapper/PropertyIds.cxx | 1 writerfilter/source/dmapper/PropertyIds.hxx | 1 xmloff/source/text/txtexppr.cxx | 19 xmloff/source/text/txtprmap.cxx | 8 43 files changed, 781 insertions(+), 312 deletions(-)
New commits: commit cfbb1f47acfbf3318071d20c73c44df8916a51fa Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Sat Mar 21 13:38:27 2015 +0100 Avoid C style cast in sw_globalfilter test Change-Id: I8d05a73728875ccd51cb9e5f9c7ad9f60677bf67 diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 9680a67..c0c5191 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -60,7 +60,7 @@ void Test::testSwappedOutImageExport() // Set cache size to a very small value to make sure one of the images is swapped out std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch); + officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(static_cast<sal_Int32>(1), batch); batch->commit(); if (mxComponent.is()) @@ -182,7 +182,7 @@ void Test::testLinkedGraphicRT() const GraphicObject& rGraphicObj = pGrfNode->GetGrfObj(true); CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut()); CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetType()); - CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), static_cast<sal_uLong>(864900), rGraphicObj.GetSizeBytes()); bImageFound = true; } } @@ -204,7 +204,7 @@ void Test::testImageWithSpecialID() // Trigger swap out mechanism to test swapped state factor too. std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch); + officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(static_cast<sal_Int32>(1), batch); batch->commit(); for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) @@ -285,7 +285,7 @@ void Test::testGraphicShape() // Trigger swap out mechanism to test swapped state factor too. std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch); + officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(static_cast<sal_Int32>(1), batch); batch->commit(); for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) @@ -421,7 +421,7 @@ void Test::testCharHighlightBody() if( strcmp(aFilterNames[nFilter], "writer8") == 0 ) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharBackColor")); } else // MS filters @@ -436,21 +436,21 @@ void Test::testCharHighlightBody() const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); if( strcmp(aFilterNames[nFilter], "writer8") == 0 ) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor")); } else { - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); } } // Only background { const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,19), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); } } } commit 3e03767906c9a283ba0c65114f58f38276902c63 Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 15:23:58 2015 +0100 Char highlight: convert LO character background to MSO highlighting DOC export has a good approximating algorithm for that so use it everywhere. In RTF case use the default color table which is added also by MSO Word. With that highlight colors are also added to the table. Change-Id: Ie4827a933c316d4dc0c0c7a32d8cf319477d1bf9 diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 958f0b8..9031a77 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -12,6 +12,7 @@ #include <unotools/fontcvt.hxx> #include <unotools/fontdefs.hxx> #include <vcl/svapp.hxx> +#include <vcl/salbtype.hxx> #include <filter/msfilter/util.hxx> #include <boost/scoped_ptr.hpp> #include <unordered_map> @@ -1350,6 +1351,47 @@ bool HasTextBoxContent(sal_uInt32 nShapeType) return true; } } + +sal_uInt8 TransColToIco( const Color& rCol ) +{ + sal_uInt8 nCol = 0; // ->Auto + switch( rCol.GetColor() ) + { + case COL_BLACK: nCol = 1; break; + case COL_BLUE: nCol = 9; break; + case COL_GREEN: nCol = 11; break; + case COL_CYAN: nCol = 10; break; + case COL_RED: nCol = 13; break; + case COL_MAGENTA: nCol = 12; break; + case COL_BROWN: nCol = 14; break; + case COL_GRAY: nCol = 15; break; + case COL_LIGHTGRAY: nCol = 16; break; + case COL_LIGHTBLUE: nCol = 2; break; + case COL_LIGHTGREEN: nCol = 4; break; + case COL_LIGHTCYAN: nCol = 3; break; + case COL_LIGHTRED: nCol = 6; break; + case COL_LIGHTMAGENTA: nCol = 5; break; + case COL_YELLOW: nCol = 7; break; + case COL_WHITE: nCol = 8; break; + case COL_AUTO: nCol = 0; break; + + default: + static const ColorData aColArr[ 16 ] = { + COL_BLACK, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_LIGHTGREEN, + COL_LIGHTMAGENTA,COL_LIGHTRED, COL_YELLOW, COL_WHITE, + COL_BLUE, COL_CYAN, COL_GREEN, COL_MAGENTA, + COL_RED, COL_BROWN, COL_GRAY, COL_LIGHTGRAY + }; + BitmapPalette aBmpPal(16); + for( sal_uInt16 i = 0; i < 16; ++i ) + aBmpPal[i] = Color( aColArr[ i ] ); + + nCol = static_cast< sal_uInt8 >(aBmpPal.GetBestIndex( rCol ) + 1); + break; + } + return nCol; +} + } } diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx index c1bb36d..1164889 100644 --- a/include/filter/msfilter/util.hxx +++ b/include/filter/msfilter/util.hxx @@ -146,6 +146,15 @@ MSFILTER_DLLPUBLIC MSO_SPT GETVMLShapeType(const OString& aType); */ MSFILTER_DLLPUBLIC bool HasTextBoxContent(sal_uInt32 nShapeType); +/** + * Convert the input color value to an ico value (0..16) + * + * @param[in] rCol input color for conversion + * + * @return ico value [0..16] +**/ +MSFILTER_DLLPUBLIC sal_uInt8 TransColToIco( const Color& rCol ); + } } diff --git a/sw/qa/extras/globalfilter/data/char_background.odt b/sw/qa/extras/globalfilter/data/char_background.odt new file mode 100644 index 0000000..d2dcea0 Binary files /dev/null and b/sw/qa/extras/globalfilter/data/char_background.odt differ diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 888985b..9680a67 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -32,6 +32,7 @@ public: void testCharHighlight(); void testCharHighlightBody(); void testMSCharBackgroundEditing(); + void testCharBackgroundToHighlighting(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testSwappedOutImageExport); @@ -40,6 +41,7 @@ public: CPPUNIT_TEST(testGraphicShape); CPPUNIT_TEST(testCharHighlight); CPPUNIT_TEST(testMSCharBackgroundEditing); + CPPUNIT_TEST(testCharBackgroundToHighlighting); CPPUNIT_TEST_SUITE_END(); }; @@ -580,6 +582,77 @@ void Test::testMSCharBackgroundEditing() } } +void Test::testCharBackgroundToHighlighting() +{ + // MSO highlighting has less kind of values so let's see how LO character background is converted + // to these values + + const char* aFilterNames[] = { + "Rich Text Format", + "MS Word 97", + "Office Open XML Text", + }; + + for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) + { + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_background.odt"), + "com.sun.star.text.TextDocument"); + + const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + + + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + rOpt.SetCharBackground2Highlighting(); + + // Export the document and import again for a check + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString::createFromAscii(aFilterNames[nFilter]); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY); + xComponent->dispose(); + mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + + // Check highlight color + const uno::Reference< text::XTextRange > xPara = getParagraph(1); + for( int nRun = 1; nRun <= 20; ++nRun ) + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); + sal_Int32 nHighlightColor = 0; + switch( nRun ) + { + case 1: nHighlightColor = 0x000000; break; //black + case 2: nHighlightColor = 0xffff00; break; //yellow + case 3: nHighlightColor = 0xff00ff; break; //magenta + case 4: nHighlightColor = 0x00ffff; break; //cyan + case 5: nHighlightColor = 0xffff00; break; //yellow + case 6: nHighlightColor = 0xff0000; break; //red + case 7: nHighlightColor = 0x0000ff; break; //blue + case 8: nHighlightColor = 0x00ff00; break; //green + case 9: nHighlightColor = 0x008000; break; //dark green + case 10: nHighlightColor = 0x800080; break; //dark magenta + case 11: nHighlightColor = 0x000080; break; //dark blue + case 12: nHighlightColor = 0x000000; break; //black + case 13: nHighlightColor = 0x808000; break; //dark yellow + case 14: nHighlightColor = 0x808080; break; //dark gray + case 15: nHighlightColor = 0x000000; break; //white + case 16: nHighlightColor = 0xff0000; break; //red + case 17: nHighlightColor = 0xC0C0C0; break; //light gray + case 18: nHighlightColor = 0x800000; break; //dark red + case 19: nHighlightColor = 0x008080; break; //dark cyan + case 20: nHighlightColor = 0xffffff; break; //white + } + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + } + } +} + 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 2068e54..b3cc593 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5786,26 +5786,26 @@ void DocxAttributeOutput::EmbedFontStyle( const OUString& name, int tag, FontFam FSEND ); } -OString DocxAttributeOutput::TransHighlightColor( const Color& rColor ) -{ - switch (rColor.GetColor()) - { - case 0x000000: return OString("black"); break; - case 0x0000ff: return OString("blue"); break; - case 0x00ffff: return OString("cyan"); break; - case 0x00ff00: return OString("green"); break; - case 0xff00ff: return OString("magenta"); break; - case 0xff0000: return OString("red"); break; - case 0xffff00: return OString("yellow"); break; - case 0xffffff: return OString("white"); break; - case 0x000080: return OString("darkBlue"); break; - case 0x008080: return OString("darkCyan"); break; - case 0x008000: return OString("darkGreen"); break; - case 0x800080: return OString("darkMagenta"); break; - case 0x800000: return OString("darkRed"); break; - case 0x808000: return OString("darkYellow"); break; - case 0x808080: return OString("darkGray"); break; - case 0xC0C0C0: return OString("lightGray"); break; +OString DocxAttributeOutput::TransHighlightColor( sal_uInt8 nIco ) +{ + switch (nIco) + { + case 1: return OString("black"); break; + case 2: return OString("blue"); break; + case 3: return OString("cyan"); break; + case 4: return OString("green"); break; + case 5: return OString("magenta"); break; + case 6: return OString("red"); break; + case 7: return OString("yellow"); break; + case 8: return OString("white"); break; + case 9: return OString("darkBlue"); break; + case 10: return OString("darkCyan"); break; + case 11: return OString("darkGreen"); break; + case 12: return OString("darkMagenta"); break; + case 13: return OString("darkRed"); break; + case 14: return OString("darkYellow"); break; + case 15: return OString("darkGray"); break; + case 16: return OString("lightGray"); break; default: return OString(); break; } } @@ -6411,7 +6411,7 @@ void DocxAttributeOutput::CharBorder( void DocxAttributeOutput::CharHighlight( const SvxBrushItem& rHighlight ) { - const OString sColor = TransHighlightColor( rHighlight.GetColor() ); + const OString sColor = TransHighlightColor( msfilter::util::TransColToIco(rHighlight.GetColor()) ); if ( !sColor.isEmpty() ) { m_pSerializer->singleElementNS( XML_w, XML_highlight, diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 58c89c8..bcbf38e 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -440,13 +440,13 @@ private: FontPitch pitch, rtl_TextEncoding encoding ); /** - * Translate a color object to the corresponding HighlightColorValues enumaration item + * Translate an ico value to the corresponding HighlightColorValues enumaration item * - * @param[in] rColor a color object to translate + * @param[in] nIco ico value [0..16] * @return color name (e.g. "red"), if color is inside the enumeration's range * empty string, otherwise **/ - OString TransHighlightColor( const Color& rColor ); + static OString TransHighlightColor( sal_uInt8 nIco ); protected: /// Output frames - the implementation. diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index ad3cf5e..d8d8742 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2475,7 +2475,7 @@ void RtfAttributeOutput::CharHighlight(const SvxBrushItem& rBrush) if (!rBrush.GetColor().GetTransparency()) { m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HIGHLIGHT); - m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor())); + m_aStyles.append(static_cast<sal_Int32>(msfilter::util::TransColToIco(rBrush.GetColor()))); } } diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 8b1ae6d..8130678 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -931,6 +931,7 @@ void RtfExport::InsColorLine(const SvxBoxItem& rBox) if (rBox.GetRight() && pLine != rBox.GetRight()) InsColor(rBox.GetRight()->GetColor()); } + void RtfExport::OutColorTable() { // Build the table from rPool since the colors provided to @@ -938,6 +939,24 @@ void RtfExport::OutColorTable() sal_uInt32 nMaxItem; const SfxItemPool& rPool = pDoc->GetAttrPool(); + // MSO Word uses a default color table with 16 colors (which is used e.g. for highlighting) + InsColor(COL_BLACK); + InsColor(COL_LIGHTBLUE); + InsColor(COL_LIGHTCYAN); + InsColor(COL_LIGHTGREEN); + InsColor(COL_LIGHTMAGENTA); + InsColor(COL_LIGHTRED); + InsColor(COL_YELLOW); + InsColor(COL_WHITE); + InsColor(COL_BLUE); + InsColor(COL_CYAN); + InsColor(COL_GREEN); + InsColor(COL_MAGENTA); + InsColor(COL_RED); + InsColor(COL_BROWN); + InsColor(COL_GRAY); + InsColor(COL_LIGHTGRAY); + // char color { const SvxColorItem* pCol = static_cast<const SvxColorItem*>(GetDfltAttr(RES_CHRATR_COLOR)); @@ -976,7 +995,7 @@ void RtfExport::OutColorTable() // background color static const sal_uInt16 aBrushIds[] = { - RES_BACKGROUND, RES_CHRATR_BACKGROUND, RES_CHRATR_HIGHLIGHT, 0 + RES_BACKGROUND, RES_CHRATR_BACKGROUND, 0 }; for (const sal_uInt16* pIds = aBrushIds; *pIds; ++pIds) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index ca6e5e1..b61b8da 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3471,7 +3471,6 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM , mpTopNodeOfHdFtPage(0) , pBkmks(0) , pRedlAuthors(0) - , pBmpPal(0) , pOLEExp(0) , pOCXExp(0) , mpTableInfo(new ww8::WW8TableInfo()) @@ -3539,7 +3538,6 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM MSWordExportBase::~MSWordExportBase() { - delete pBmpPal; delete pOLEExp; delete pOCXExp; } diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index ee318b6..bc0c12f 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -463,7 +463,6 @@ public: std::stack< sal_Int32 > m_aCurrentCharPropStarts; ///< To remember the position in a run. WW8_WrtBookmarks* pBkmks; WW8_WrtRedlineAuthor* pRedlAuthors; - BitmapPalette* pBmpPal; boost::shared_ptr<NfKeywordTable> pKeyMap; SvxMSExportOLEObjects* pOLEExp; SwMSConvertControls* pOCXExp; @@ -1096,7 +1095,6 @@ public: void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox ); void Out_CellRangeBorders(const SvxBoxItem * pBox, sal_uInt8 nStart, sal_uInt8 nLimit); - sal_uInt8 TransCol( const Color& rCol ); bool TransBrush(const Color& rCol, WW8_SHD& rShd); WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine, sal_uInt16 nDist, bool bShadow); diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index eb1a1c5..1bb47ec 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -584,7 +584,7 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, { WW8_BRCVer9 aBrc90 = rWrt.TranslateBorderLine( *pLn, pBox->GetDistance( aLnArr[ i ] ), bShadow ); - sal_uInt8 ico = rWrt.TransCol(msfilter::util::BGRToRGB( + sal_uInt8 ico = msfilter::util::TransColToIco(msfilter::util::BGRToRGB( aBrc90.cv())); aBrc = WW8_BRC(aBrc90.dptLineWidth(), aBrc90.brcType(), ico, aBrc90.dptSpace(), aBrc90.fShadow(), aBrc90.fFrame()); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 6e77450..70283f27 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1286,7 +1286,7 @@ void WW8AttributeOutput::CharHighlight( const SvxBrushItem& rBrush ) { if( m_rWW8Export.bWrtWW8 && rBrush.GetColor() != COL_TRANSPARENT ) { - sal_uInt8 nColor = m_rWW8Export.TransCol( rBrush.GetColor() ); + sal_uInt8 nColor = msfilter::util::TransColToIco( rBrush.GetColor() ); // sprmCHighlight m_rWW8Export.InsUInt16( NS_sprm::LN_CHighlight ); m_rWW8Export.pO->push_back( nColor ); @@ -1605,54 +1605,6 @@ void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisM } } -// TransCol uebersetzt SW-Farben in WW. Heraus kommt die bei WW fuer -// Text- und Hintergrundfarbe benutzte Codierung. -// Gibt es keine direkte Entsprechung, dann wird versucht, eine moeglichst -// aehnliche WW-Farbe zu finden. -// return: 5-Bit-Wert ( 0..16 ) -sal_uInt8 WW8Export::TransCol( const Color& rCol ) -{ - sal_uInt8 nCol = 0; // ->Auto - switch( rCol.GetColor() ) - { - case COL_BLACK: nCol = 1; break; - case COL_BLUE: nCol = 9; break; - case COL_GREEN: nCol = 11; break; - case COL_CYAN: nCol = 10; break; - case COL_RED: nCol = 13; break; - case COL_MAGENTA: nCol = 12; break; - case COL_BROWN: nCol = 14; break; - case COL_GRAY: nCol = 15; break; - case COL_LIGHTGRAY: nCol = 16; break; - case COL_LIGHTBLUE: nCol = 2; break; - case COL_LIGHTGREEN: nCol = 4; break; - case COL_LIGHTCYAN: nCol = 3; break; - case COL_LIGHTRED: nCol = 6; break; - case COL_LIGHTMAGENTA: nCol = 5; break; - case COL_YELLOW: nCol = 7; break; - case COL_WHITE: nCol = 8; break; - case COL_AUTO: nCol = 0; break; - - default: - if( !pBmpPal ) - { - pBmpPal = new BitmapPalette( 16 ); - static const ColorData aColArr[ 16 ] = { - COL_BLACK, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_LIGHTGREEN, - COL_LIGHTMAGENTA,COL_LIGHTRED, COL_YELLOW, COL_WHITE, - COL_BLUE, COL_CYAN, COL_GREEN, COL_MAGENTA, - COL_RED, COL_BROWN, COL_GRAY, COL_LIGHTGRAY - }; - - for( sal_uInt16 i = 0; i < 16; ++i ) - pBmpPal->operator[]( i ) = Color( aColArr[ i ] ); - } - nCol = static_cast< sal_uInt8 >(pBmpPal->GetBestIndex( rCol ) + 1); - break; - } - return nCol; -} - // TransBrush uebersetzt SW-Brushes in WW. Heraus kommt WW8_SHD. // Nicht-Standardfarben des SW werden noch nicht in die // Misch-Werte ( 0 .. 95% ) vom WW uebersetzt. @@ -1666,7 +1618,7 @@ bool WW8Export::TransBrush(const Color& rCol, WW8_SHD& rShd) else { rShd.SetFore( 0); - rShd.SetBack( TransCol( rCol ) ); + rShd.SetBack( msfilter::util::TransColToIco( rCol ) ); rShd.SetStyle( bWrtWW8, 0 ); } return !rCol.GetTransparency(); @@ -1686,7 +1638,7 @@ void WW8AttributeOutput::CharColor( const SvxColorItem& rColor ) else m_rWW8Export.pO->push_back( 98 ); - sal_uInt8 nColor = m_rWW8Export.TransCol( rColor.GetValue() ); + sal_uInt8 nColor = msfilter::util::TransColToIco( rColor.GetValue() ); m_rWW8Export.pO->push_back( nColor ); if ( m_rWW8Export.bWrtWW8 && nColor ) @@ -4388,7 +4340,7 @@ void WW8Export::Out_BorderLine(ww::bytes& rO, const SvxBorderLine* pLine, if( pLine && pLine->GetBorderLineStyle() != table::BorderLineStyle::NONE ) { aBrcVer9 = TranslateBorderLine( *pLine, nDist, bShadow ); - sal_uInt8 ico = TransCol( msfilter::util::BGRToRGB(aBrcVer9.cv()) ); + sal_uInt8 ico = msfilter::util::TransColToIco( msfilter::util::BGRToRGB(aBrcVer9.cv()) ); aBrcVer8 = WW8_BRC( aBrcVer9.dptLineWidth(), aBrcVer9.brcType(), ico, aBrcVer9.dptSpace(), aBrcVer9.fShadow(), aBrcVer9.fFrame() ); } commit 1d1f757f574aa609bdaa375bb8cdfa7f7941887d Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Sun Mar 15 21:12:39 2015 +0100 Char highlight: test related to editing of MSO background attributes Change-Id: I39828754284b0e3d43d043a9695f81d404b4e0aa diff --git a/sw/qa/extras/globalfilter/data/char_background_editing.docx b/sw/qa/extras/globalfilter/data/char_background_editing.docx new file mode 100644 index 0000000..3e3302d Binary files /dev/null and b/sw/qa/extras/globalfilter/data/char_background_editing.docx differ diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index f62b231..888985b 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -31,6 +31,7 @@ public: void testGraphicShape(); void testCharHighlight(); void testCharHighlightBody(); + void testMSCharBackgroundEditing(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testSwappedOutImageExport); @@ -38,6 +39,7 @@ public: CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testGraphicShape); CPPUNIT_TEST(testCharHighlight); + CPPUNIT_TEST(testMSCharBackgroundEditing); CPPUNIT_TEST_SUITE_END(); }; @@ -463,6 +465,121 @@ void Test::testCharHighlight() testCharHighlightBody(); } +void Test::testMSCharBackgroundEditing() +{ + // Simulate the editing process of imported MSO character background attributes + // and check how export behaves. + + const char* aFilterNames[] = { + "writer8", + "Rich Text Format", + "MS Word 97", + "Office Open XML Text", + }; + + for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) + { + if (mxComponent.is()) + mxComponent->dispose(); + + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_background_editing.docx"), + "com.sun.star.text.TextDocument"); + + const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + + // Check whether import was done on the right way + uno::Reference< text::XTextRange > xPara = getParagraph(1); + { + uno::Reference<beans::XPropertySet> xRun(getRun(xPara,1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor")); + + xRun.set(getRun(xPara,2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0x0000ff), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + + xRun.set(getRun(xPara,3), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0x0000ff), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor")); + + xRun.set(getRun(xPara,4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Simulate editing + for( int i = 1; i <= 4; ++i ) + { + uno::Reference<beans::XPropertySet> xRun(getRun(xPara,i), uno::UNO_QUERY); + // Change background + sal_Int32 nBackColor = 0; + switch( i ) + { + case 1: nBackColor = 0x000000; break; //black + case 2: nBackColor = 0x00ffff; break; //cyan + case 3: nBackColor = 0x00ff00; break; //green + case 4: nBackColor = 0xff00ff; break; //magenta + } + xRun->setPropertyValue("CharBackColor", uno::makeAny(static_cast<sal_Int32>(nBackColor))); + // Remove highlighting + xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(COL_TRANSPARENT))); + // Remove shading marker + uno::Sequence<beans::PropertyValue> aGrabBag = getProperty<uno::Sequence<beans::PropertyValue> >(xRun,"CharInteropGrabBag"); + for (int j = 0; j < aGrabBag.getLength(); ++j) + { + beans::PropertyValue& rProp = aGrabBag[j]; + if (rProp.Name == "CharShadingMarker") + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), true, rProp.Value.get<bool>()); + rProp.Value = uno::makeAny(false); + } + } + xRun->setPropertyValue("CharInteropGrabBag", uno::makeAny(aGrabBag)); + } + + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + rOpt.SetCharBackground2Highlighting(); + + // Export the document and import again for a check + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString::createFromAscii(aFilterNames[nFilter]); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY); + xComponent->dispose(); + mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + + // Check whether background was exported as highlighting + xPara.set(getParagraph(1)); + for( int i = 1; i <= 4; ++i ) + { + sal_Int32 nBackColor = 0; + switch( i ) + { + case 1: nBackColor = 0x000000; break; //black + case 2: nBackColor = 0x00ffff; break; //cyan + case 3: nBackColor = 0x00ff00; break; //green + case 4: nBackColor = 0xff00ff; break; //magenta + } + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,i), uno::UNO_QUERY); + if( strcmp(aFilterNames[nFilter], "writer8") == 0 ) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(nBackColor), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + else + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(nBackColor), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + } + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 08cfbbaca2d23727bc95912082ae46b8f8a37f03 Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Sun Mar 15 15:31:09 2015 +0100 Char highlight: editing by "Highlighting" button Change-Id: I9581da0631643199a9c076990bf689d54dbadf8c diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 3cab3dd..b25456a 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -28,6 +28,7 @@ #include <editeng/langitem.hxx> #include <svtools/langtab.hxx> #include <svl/slstitm.hxx> +#include <svl/grabbagitem.hxx> #include <string.h> #include <svl/stritem.hxx> #include <sfx2/htmlmode.hxx> @@ -1178,6 +1179,26 @@ void SwTextShell::Execute(SfxRequest &rReq) SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND); aBrushItem.SetColor(aSet); rWrtSh.SetAttrItem( aBrushItem ); + + // Remove MS specific highlight when background is set + rWrtSh.SetAttrItem( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); + + // Remove shading marker + SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG ); + rWrtSh.GetCurAttr( aCoreSet ); + + const SfxPoolItem *pTmpItem; + if( SfxItemState::SET == aCoreSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) ) + { + SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem)); + std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + auto aIterator = rMap.find("CharShadingMarker"); + if( aIterator != rMap.end() ) + { + aIterator->second = uno::makeAny(false); + } + rWrtSh.SetAttrItem( aGrabBag ); + } } else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) { @@ -1210,6 +1231,26 @@ void SwTextShell::Execute(SfxRequest &rReq) { rWrtSh.SetAttrItem( SvxBrushItem( rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) ); + + // Remove MS specific highlight when background is set + rWrtSh.SetAttrItem( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); + + // Remove shading marker + SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG ); + rWrtSh.GetCurAttr( aCoreSet ); + + const SfxPoolItem *pTmpItem; + if( SfxItemState::SET == aCoreSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) ) + { + SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem)); + std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + auto aIterator = rMap.find("CharShadingMarker"); + if( aIterator != rMap.end() ) + { + aIterator->second = uno::makeAny(false); + } + rWrtSh.SetAttrItem( aGrabBag ); + } } else rWrtSh.SetAttrItem( @@ -1540,10 +1581,19 @@ void SwTextShell::GetState( SfxItemSet &rSet ) break; case SID_ATTR_CHAR_COLOR_BACKGROUND: { + // Always use the visible background SfxItemSet aSet( GetPool() ); rSh.GetCurAttr( aSet ); - const SvxBrushItem& aBrushItem = static_cast< const SvxBrushItem& >( aSet.Get(RES_CHRATR_BACKGROUND) ); - rSet.Put( SvxColorItem(aBrushItem.GetColor(), nWhich) ); + const SvxBrushItem& aBrushItem = static_cast< const SvxBrushItem& >( aSet.Get(RES_CHRATR_HIGHLIGHT) ); + if( aBrushItem.GetColor() != COL_TRANSPARENT ) + { + rSet.Put( SvxColorItem(aBrushItem.GetColor(), nWhich) ); + } + else + { + const SvxBrushItem& aBrushItem2 = static_cast< const SvxBrushItem& >( aSet.Get(RES_CHRATR_BACKGROUND) ); + rSet.Put( SvxColorItem(aBrushItem2.GetColor(), nWhich) ); + } } break; case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: commit 587315ebd5e4417e85eb3ffafd978fcddb09b19f Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 15:19:46 2015 +0100 Char shading: use a marker for character background imported from MSO shading * So MSO format export filters can recognize that it should be exported as shading. * Editing in LO removes this shading marker, so from that point there will be an LO character background. Change-Id: I853b952f0395b33d36bb2934a6d910f2182cc1d9 diff --git a/include/svl/grabbagitem.hxx b/include/svl/grabbagitem.hxx index c02edaa..6454d2c 100644 --- a/include/svl/grabbagitem.hxx +++ b/include/svl/grabbagitem.hxx @@ -35,6 +35,11 @@ public: return m_aMap; } + std::map<OUString, com::sun::star::uno::Any>& GetGrabBag() + { + return m_aMap; + } + virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE; virtual SfxPoolItem* Clone(SfxItemPool* pPool = 0) const SAL_OVERRIDE; diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index a741037..f62b231 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -30,6 +30,7 @@ public: void testImageWithSpecialID(); void testGraphicShape(); void testCharHighlight(); + void testCharHighlightBody(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testSwappedOutImageExport); @@ -353,7 +354,7 @@ void Test::testGraphicShape() } } -void Test::testCharHighlight() +void Test::testCharHighlightBody() { // MS Word has two kind of character backgrounds called character shading and highlighting // MS filters handle these attributes separately, but ODF export merges them into one background attribute @@ -365,9 +366,6 @@ void Test::testCharHighlight() "Office Open XML Text", }; - SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - rOpt.SetCharBackground2Shading(); - for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) { if (mxComponent.is()) @@ -453,6 +451,18 @@ void Test::testCharHighlight() } } +void Test::testCharHighlight() +{ + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + rOpt.SetCharBackground2Shading(); + + testCharHighlightBody(); + + rOpt.SetCharBackground2Highlighting(); + + testCharHighlightBody(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 1bd05c8..6e77450 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5636,15 +5636,28 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTxt void AttributeOutputBase::CharBackgroundBase( const SvxBrushItem& rBrush ) { - const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - if( rOpt.IsCharBackground2Highlighting() ) + bool bConvertToShading = SvtFilterOptions::Get().IsCharBackground2Shading(); + bool bHasShadingMarker = false; + + // Check shading marker { - CharHighlight(rBrush); + const SfxGrabBagItem& aGrabBag = static_cast< const SfxGrabBagItem& >( GetExport().GetItem( RES_CHRATR_GRABBAG ) ); + const std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + auto aIterator = rMap.find("CharShadingMarker"); + if( aIterator != rMap.end() ) + { + aIterator->second >>= bHasShadingMarker; + } } - else + + if( bConvertToShading || bHasShadingMarker ) { CharBackground(rBrush); } + else + { + CharHighlight(rBrush); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 8428573..8911d36 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -19,6 +19,7 @@ #include <stdlib.h> #include <svl/itemiter.hxx> +#include <svl/grabbagitem.hxx> #include <rtl/tencinfo.h> #include <hintids.hxx> @@ -3799,6 +3800,12 @@ void SwWW8ImplReader::Read_CharShadow( sal_uInt16, const sal_uInt8* pData, shor SwWW8Shade aSh( bVer67, aSHD ); NewAttr( SvxBrushItem( aSh.aColor, RES_CHRATR_BACKGROUND )); + + // Add a marker to the grabbag indicating that character background was imported from MSO shading + SfxGrabBagItem aGrabBag = *(static_cast<const SfxGrabBagItem*>(GetFmtAttr(RES_CHRATR_GRABBAG))); + std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + rMap.insert(std::pair<OUString, com::sun::star::uno::Any>("CharShadingMarker",uno::makeAny(true))); + NewAttr(aGrabBag); } } @@ -3815,6 +3822,12 @@ void SwWW8ImplReader::Read_TxtBackColor(sal_uInt16, const sal_uInt8* pData, shor return; Color aColour(ExtractColour(pData, bVer67)); NewAttr(SvxBrushItem(aColour, RES_CHRATR_BACKGROUND)); + + // Add a marker to the grabbag indicating that character background was imported from MSO shading + SfxGrabBagItem aGrabBag = *(static_cast<const SfxGrabBagItem*>(GetFmtAttr(RES_CHRATR_GRABBAG))); + std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + rMap.insert(std::pair<OUString, com::sun::star::uno::Any>("CharShadingMarker",uno::makeAny(true))); + NewAttr(aGrabBag); } } diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index ee77182..996a39d 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -265,7 +265,7 @@ IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton ) if (pDlg->Execute() == RET_OK) { SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() ); - ::ConvertAttrGenToChar(aOutputSet, CONV_ATTR_ENV); + ::ConvertAttrGenToChar(aOutputSet, aTmpSet, CONV_ATTR_ENV); pCollSet->Put(aOutputSet); } } diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index c33689c..638d0fc 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -573,7 +573,7 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl) SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() ); if( SFX_STYLE_FAMILY_CHAR == m_nFamily ) { - ::ConvertAttrGenToChar(aTmpSet, CONV_ATTR_STD); + ::ConvertAttrGenToChar(aTmpSet, m_xTmp->GetItemSet(), CONV_ATTR_STD); } m_xTmp->SetItemSet( aTmpSet ); @@ -823,7 +823,7 @@ sal_uInt16 SwDocShell::Edit( ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() ); else { - ::ConvertAttrGenToChar(xTmp->GetItemSet(), CONV_ATTR_STD); + ::ConvertAttrGenToChar(xTmp->GetItemSet(), xTmp->GetItemSet(), CONV_ATTR_STD); } if(SFX_STYLE_FAMILY_PAGE == nFamily) mpView->InvalidateRulerPos(); diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx index 765087f..fe7aebc 100644 --- a/sw/source/uibase/inc/uitool.hxx +++ b/sw/source/uibase/inc/uitool.hxx @@ -59,9 +59,10 @@ SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode); * This method is used after executed a character dialog. * * @param[in,out] rSet the set in which character attributes are stored + * @param[in] rOrigSet original itemset used as input for the dialog * @param[in] nMode specify the dialog which was called before **/ -SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode); +SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, const sal_uInt8 nMode); // SfxItemSets <-> PageDesc void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index b474ede..3cab3dd 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -202,7 +202,7 @@ void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const if ( pSet) { SfxItemSet aTmpSet( *pSet ); - ::ConvertAttrGenToChar(aTmpSet, CONV_ATTR_STD); + ::ConvertAttrGenToChar(aTmpSet, aCoreSet, CONV_ATTR_STD); const SfxPoolItem* pSelectionItem; bool bInsert = false; diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index a105aae..be0a045 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -25,6 +25,7 @@ #include <unotools/collatorwrapper.hxx> #include <svl/urihelper.hxx> #include <svl/stritem.hxx> +#include <svl/grabbagitem.hxx> #include <unotools/syslocale.hxx> #include <sfx2/app.hxx> #include <IDocumentStylePoolAccess.hxx> @@ -175,20 +176,33 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) } } -void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode) +void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, const sal_uInt8 nMode) { // Background / highlighting { - const SfxPoolItem *pTmpBrush; - if( SfxItemState::SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpBrush ) ) + const SfxPoolItem *pTmpItem; + if( SfxItemState::SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpItem ) ) { - SvxBrushItem aTmpBrush( *static_cast<const SvxBrushItem*>(pTmpBrush) ); + SvxBrushItem aTmpBrush( *static_cast<const SvxBrushItem*>(pTmpItem) ); aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); rSet.Put( aTmpBrush ); // Highlight is an MS specific thing, so remove it at the first time when LO modifies // this part of the imported document. rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); + + // Remove shading marker + if( SfxItemState::SET == rOrigSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) ) + { + SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem)); + std::map<OUString, com::sun::star::uno::Any>& rMap = aGrabBag.GetGrabBag(); + auto aIterator = rMap.find("CharShadingMarker"); + if( aIterator != rMap.end() ) + { + aIterator->second = uno::makeAny(false); + } + rSet.Put( aGrabBag ); + } } rSet.ClearItem( RES_BACKGROUND ); } diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9894651..b64e216 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1662,6 +1662,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) pCellColorHandler->setOutputFormat( CellColorHandler::Character ); pProperties->resolve(*pCellColorHandler); rContext->InsertProps(pCellColorHandler->getProperties()); + m_pImpl->GetTopContext()->Insert(PROP_CHAR_SHADING_MARKER, uno::makeAny(true), true, CHAR_GRAB_BAG ); } break; } diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index f380c45..53d101c 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -349,6 +349,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_GRAPHIC_URL: sName = "GraphicURL"; break; case PROP_GRAPHIC_BITMAP: sName = "GraphicBitmap"; break; case PROP_CHAR_SHADING_VALUE: sName = "CharShadingValue"; break; + case PROP_CHAR_SHADING_MARKER: sName = "CharShadingMarker"; break; case PROP_LABEL_CATEGORY: sName = "LabelCategory"; break; case PROP_FIRST_IS_SHARED : sName = "FirstIsShared"; break; case PROP_MIRROR_INDENTS : sName = "MirrorIndents"; break; diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index cd52d48..618d02d 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -320,6 +320,7 @@ enum PropertyIds ,PROP_GRAPHIC_URL ,PROP_GRAPHIC_BITMAP ,PROP_CHAR_SHADING_VALUE + ,PROP_CHAR_SHADING_MARKER ,PROP_FIRST_IS_SHARED ,PROP_MIRROR_INDENTS ,PROP_SURROUND_TEXT_WRAP_SMALL commit 8519d51b3a06a84d0d6418651e66e9bb534f1788 Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 10:31:11 2015 +0100 Char highlight: export character background to MSO formats based on settings Change-Id: Iaaf9e7ee5e61cfabb0d675b83fa71776dece87e2 diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 71d2ada..a741037 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -18,6 +18,7 @@ #include <doc.hxx> #include <ndgrf.hxx> #include <drawdoc.hxx> +#include <unotools/fltrcfg.hxx> class Test : public SwModelTestBase { @@ -364,6 +365,9 @@ void Test::testCharHighlight() "Office Open XML Text", }; + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + rOpt.SetCharBackground2Shading(); + for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) { if (mxComponent.is()) diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 5b8d268..58a226a 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -414,6 +414,7 @@ protected: virtual void CharAnimatedText( const SvxBlinkItem& ) = 0; /// Sfx item RES_CHRATR_BACKGROUND + void CharBackgroundBase( const SvxBrushItem& ); virtual void CharBackground( const SvxBrushItem& ) = 0; /// Sfx item RES_CHRATR_CJK_FONT diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index c52e9c3..1bd05c8 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -134,6 +134,7 @@ #include "fields.hxx" #include <vcl/outdev.hxx> #include <i18nlangtag/languagetag.hxx> +#include <unotools/fltrcfg.hxx> using ::editeng::SvxBorderLine; using namespace ::com::sun::star; @@ -5310,7 +5311,7 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) CharAnimatedText( static_cast< const SvxBlinkItem& >( rHt ) ); break; case RES_CHRATR_BACKGROUND: - CharBackground( static_cast< const SvxBrushItem& >( rHt ) ); + CharBackgroundBase( static_cast< const SvxBrushItem& >( rHt ) ); break; case RES_CHRATR_CJK_FONT: @@ -5633,4 +5634,17 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTxt return NULL; } +void AttributeOutputBase::CharBackgroundBase( const SvxBrushItem& rBrush ) +{ + const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + if( rOpt.IsCharBackground2Highlighting() ) + { + CharHighlight(rBrush); + } + else + { + CharBackground(rBrush); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 89399a6ba7c1817dfdc7676603f3fa1106d398c5 Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 10:30:18 2015 +0100 Char highlight: option about export LO character background to MSO formats Export as highlighting or shading. Highlighting is the default. Change-Id: Ib2a38e4cd0d49317288bb565383b690d4222c8ed diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx index 800f028..1f2fb44 100644 --- a/cui/source/options/optfltr.cxx +++ b/cui/source/options/optfltr.cxx @@ -140,6 +140,10 @@ OfaMSFilterTabPage2::OfaMSFilterTabPage2( vcl::Window* pParent, const SfxItemSet pCheckButtonData(0) { get(m_pCheckLBContainer, "checklbcontainer"); + + get( aHighlightingRB, "highlighting"); + get( aShadingRB, "shading" ); + Size aControlSize(248, 55); aControlSize = LogicToPixel(aControlSize, MAP_APPFONT); m_pCheckLBContainer->set_width_request(aControlSize.Width()); @@ -220,6 +224,14 @@ bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* ) } } + if( aHighlightingRB->IsValueChangedFromSaved() ) + { + if( aHighlightingRB->IsChecked() ) + rOpt.SetCharBackground2Highlighting(); + else + rOpt.SetCharBackground2Shading(); + } + return true; } @@ -279,6 +291,13 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* ) } } m_pCheckLB->SetUpdateMode( true ); + + if (rOpt.IsCharBackground2Highlighting()) + aHighlightingRB->Check(true); + else + aShadingRB->Check(true); + + aHighlightingRB->SaveValue(); } void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, sal_IntPtr _nType ) diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx index d5e43d3..38d280b 100644 --- a/cui/source/options/optfltr.hxx +++ b/cui/source/options/optfltr.hxx @@ -83,6 +83,9 @@ class OfaMSFilterTabPage2 : public SfxTabPage sChgToFromSmartArt; SvLBoxButtonData* pCheckButtonData; + RadioButton* aHighlightingRB; + RadioButton* aShadingRB; + OfaMSFilterTabPage2( vcl::Window* pParent, const SfxItemSet& rSet ); virtual ~OfaMSFilterTabPage2(); diff --git a/cui/uiconfig/ui/optfltrembedpage.ui b/cui/uiconfig/ui/optfltrembedpage.ui index c7439b1..2b0cb04 100644 --- a/cui/uiconfig/ui/optfltrembedpage.ui +++ b/cui/uiconfig/ui/optfltrembedpage.ui @@ -92,5 +92,99 @@ <property name="height">1</property> </packing> </child> + <child> + <object class="GtkFrame" id="frame2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">18</property> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Export as:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButtonBox" id="buttonbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">start</property> + <child> + <object class="GtkRadioButton" id="highlighting"> + <property name="label" translatable="yes">Highlighting</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="shading"> + <property name="label" translatable="yes">Shading</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Character Background</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> </object> </interface> diff --git a/include/unotools/fltrcfg.hxx b/include/unotools/fltrcfg.hxx index c64ce01..8ae33d1 100644 --- a/include/unotools/fltrcfg.hxx +++ b/include/unotools/fltrcfg.hxx @@ -87,6 +87,11 @@ public: bool IsEnableCalcPreview() const; bool IsEnableWordPreview() const; + bool IsCharBackground2Highlighting() const; + bool IsCharBackground2Shading() const; + void SetCharBackground2Highlighting(); + void SetCharBackground2Shading(); + static SvtFilterOptions& Get(); }; diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 6b010d7..b613d3f 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -4082,6 +4082,13 @@ </info> <value>false</value> </prop> + <prop oor:name="CharBackgroundToHighlighting" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Specifies if character background is exported as highlighting + (and not as shading) when saving to Word document</desc> + </info> + <value>true</value> + </prop> </group> </group> <group oor:name="Graphic"> diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx index 3139ce5..84806e4 100644 --- a/unotools/source/config/fltrcfg.cxx +++ b/unotools/source/config/fltrcfg.cxx @@ -51,6 +51,7 @@ using namespace com::sun::star::uno; #define FILTERCFG_USE_ENHANCED_FIELDS 0x100000 #define FILTERCFG_WORD_WBCTBL 0x200000 #define FILTERCFG_SMARTART_SHAPE_LOAD 0x400000 +#define FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING 0x8000000 class SvtAppFilterOptions_Impl : public utl::ConfigItem { @@ -251,7 +252,8 @@ struct SvtFilterOptions_Impl FILTERCFG_IMPRESS_LOAD | FILTERCFG_IMPRESS_SAVE | FILTERCFG_USE_ENHANCED_FIELDS | - FILTERCFG_SMARTART_SHAPE_LOAD; + FILTERCFG_SMARTART_SHAPE_LOAD | + FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING; Load(); } @@ -322,7 +324,7 @@ const Sequence<OUString>& SvtFilterOptions::GetPropertyNames() static Sequence<OUString> aNames; if(!aNames.getLength()) { - int nCount = 13; + int nCount = 14; aNames.realloc(nCount); static const char* aPropNames[] = { @@ -338,7 +340,8 @@ const Sequence<OUString>& SvtFilterOptions::GetPropertyNames() "Export/EnableExcelPreview", // 9 "Export/EnableWordPreview", // 10 "Import/ImportWWFieldsAsEnhancedFields", // 11 - "Import/SmartArtToShapes" // 12 + "Import/SmartArtToShapes", // 12 + "Export/CharBackgroundToHighlighting" // 13 }; OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -365,6 +368,7 @@ static sal_uLong lcl_GetFlag(sal_Int32 nProp) case 10: nFlag = FILTERCFG_ENABLE_WORD_PREVIEW; break; case 11: nFlag = FILTERCFG_USE_ENHANCED_FIELDS; break; case 12: nFlag = FILTERCFG_SMARTART_SHAPE_LOAD; break; + case 13: nFlag = FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING; break; default: OSL_FAIL("illegal value"); } @@ -634,4 +638,27 @@ bool SvtFilterOptions::IsEnableWordPreview() const return pImp->IsFlag( FILTERCFG_ENABLE_WORD_PREVIEW ); } + +bool SvtFilterOptions::IsCharBackground2Highlighting() const +{ + return pImp->IsFlag( FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING ); +} + +bool SvtFilterOptions::IsCharBackground2Shading() const +{ + return !pImp->IsFlag( FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING ); +} + +void SvtFilterOptions::SetCharBackground2Highlighting() +{ + pImp->SetFlag( FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING, true ); + SetModified(); +} + +void SvtFilterOptions::SetCharBackground2Shading() +{ + pImp->SetFlag( FILTERCFG_CHAR_BACKGROUND_TO_HIGHLIGHTING, false ); + SetModified(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 15931deb7e4689cd885ff05439bab381f0478b2f Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 10:27:56 2015 +0100 Char highlight: editing by Character Properties dialog Modify character highlight using character dialog's "Background" tab. Change-Id: I693aebe1915e6b77af9919acf223fb2c87608516 diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index 86a9cb1..a105aae 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -122,17 +122,32 @@ void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) { - // Background + // Background / highlight { + // Always use the visible background const SfxPoolItem *pTmpBrush; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, true, &pTmpBrush ) ) + bool bUseHighlight = false; + if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_HIGHLIGHT, true, &pTmpBrush ) ) { SvxBrushItem aTmpBrush( *static_cast<const SvxBrushItem*>(pTmpBrush) ); - aTmpBrush.SetWhich( RES_BACKGROUND ); - rSet.Put( aTmpBrush ); + if( aTmpBrush.GetColor() != COL_TRANSPARENT ) + { + aTmpBrush.SetWhich( RES_BACKGROUND ); + rSet.Put( aTmpBrush ); + bUseHighlight = true; + } + } + if( !bUseHighlight ) + { + if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, true, &pTmpBrush ) ) + { + SvxBrushItem aTmpBrush( *static_cast<const SvxBrushItem*>(pTmpBrush) ); + aTmpBrush.SetWhich( RES_BACKGROUND ); + rSet.Put( aTmpBrush ); + } + else + rSet.ClearItem(RES_BACKGROUND); } - else - rSet.ClearItem(RES_BACKGROUND); } if( nMode == CONV_ATTR_STD ) @@ -162,7 +177,7 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode) { - // Background + // Background / highlighting { const SfxPoolItem *pTmpBrush; if( SfxItemState::SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpBrush ) ) @@ -170,6 +185,10 @@ void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode) SvxBrushItem aTmpBrush( *static_cast<const SvxBrushItem*>(pTmpBrush) ); aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); rSet.Put( aTmpBrush ); + + // Highlight is an MS specific thing, so remove it at the first time when LO modifies + // this part of the imported document. + rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); } rSet.ClearItem( RES_BACKGROUND ); } commit f880962f5bf26bfaef06bd3f9e67e2d901a2e74c Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 10:25:05 2015 +0100 Char highlight: ODT filters Export merges the two background attribute. Change-Id: I882321fbd5a7d24991fb01b8dc9d2cc0bd294051 diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx index a08915f..2562abb 100644 --- a/include/xmloff/txtprmap.hxx +++ b/include/xmloff/txtprmap.hxx @@ -196,6 +196,8 @@ #define CTF_CHARBOTTOMBORDER (XML_TEXT_CTF_START + 167) #define CTF_RELWIDTHREL (XML_TEXT_CTF_START + 168) #define CTF_RELHEIGHTREL (XML_TEXT_CTF_START + 169) +#define CTF_CHAR_BACKGROUND (XML_TEXT_CTF_START + 170) +#define CTF_CHAR_HIGHLIGHT (XML_TEXT_CTF_START + 171) enum class TextPropMap { diff --git a/sw/qa/extras/globalfilter/data/char_highlight.docx b/sw/qa/extras/globalfilter/data/char_highlight.docx index 841fc3e..e601bac 100644 Binary files a/sw/qa/extras/globalfilter/data/char_highlight.docx and b/sw/qa/extras/globalfilter/data/char_highlight.docx differ diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 6c3e94e..71d2ada 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -355,10 +355,10 @@ void Test::testGraphicShape() void Test::testCharHighlight() { // MS Word has two kind of character backgrounds called character shading and highlighting - // Now we support these two background attributes colors both in import and export code + // MS filters handle these attributes separately, but ODF export merges them into one background attribute const char* aFilterNames[] = { -// "writer8", + "writer8", "Rich Text Format", "MS Word 97", "Office Open XML Text", @@ -412,20 +412,37 @@ void Test::testCharHighlight() case 15: nHighlightColor = 0x808080; break; //dark gray case 16: nHighlightColor = 0xC0C0C0; break; //light gray } - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + + if( strcmp(aFilterNames[nFilter], "writer8") == 0 ) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + } + else // MS filters + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + } } // Only highlight { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); + if( strcmp(aFilterNames[nFilter], "writer8") == 0 ) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + else + { + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } } // Only background { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,19), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); } diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index 7e3cfc4..1300c3b 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/awt/FontUnderline.hpp> #include <com/sun/star/text/XChapterNumberingSupplier.hpp> #include <tools/debug.hxx> +#include <tools/color.hxx> #include <xmloff/txtprmap.hxx> #include <xmloff/xmlexp.hxx> #include <xmloff/maptype.hxx> @@ -658,6 +659,10 @@ void XMLTextExportPropertySetMapper::ContextFilter( XMLPropertyState* pRepeatOffsetX = NULL; XMLPropertyState* pRepeatOffsetY = NULL; + // character background and highlight + XMLPropertyState* pCharBackground = NULL; + XMLPropertyState* pCharHighlight = NULL; + bool bNeedsAnchor = false; for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); @@ -816,6 +821,9 @@ void XMLTextExportPropertySetMapper::ContextFilter( propertyState->mnIndex = -1; } break; + + case CTF_CHAR_BACKGROUND: pCharBackground = propertyState; break; + case CTF_CHAR_HIGHLIGHT: pCharHighlight = propertyState; break; } } @@ -1118,6 +1126,17 @@ void XMLTextExportPropertySetMapper::ContextFilter( if( pClipState != NULL && pClip11State != NULL ) pClip11State->mnIndex = -1; + // When both background attributes are available export the visible one + if( pCharHighlight && pCharBackground ) + { + sal_uInt32 nColor = COL_TRANSPARENT; + pCharHighlight->maValue >>= nColor; + if( nColor == COL_TRANSPARENT ) + pCharHighlight->mnIndex = -1; + else + pCharBackground->mnIndex = -1; + } + SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet); } diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 3806625..19979c9 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -191,7 +191,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] = // RES_CHRATR_NOLINEBREAK // TODO: not used? // RES_CHRATR_BACKGROUND - MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ), + MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, CTF_CHAR_BACKGROUND ), MT_E( "CharBackTransparent", FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ), MT_E( "CharBackColor", FO, TEXT_BACKGROUND_COLOR, XML_TYPE_COLOR|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_OLDTEXTBACKGROUND ), // RES_CHRATR_CJK_FONT @@ -291,6 +291,8 @@ XMLPropertyMapEntry aXMLParaPropMap[] = // RES_CHRATR_SHADOW MAP_EXT( "CharShadowFormat", XML_NAMESPACE_LO_EXT, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ), MAP_EXT_I( "CharShadowFormat", XML_NAMESPACE_STYLE, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ), + // RES_CHRATR_HIGHLIGHT + MT_E( "CharHighlight", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY| MID_FLAG_NO_PROPERTY_IMPORT, CTF_CHAR_HIGHLIGHT ), // RES_TXTATR_INETFMT // TODO // RES_TXTATR_REFMARK @@ -531,7 +533,7 @@ XMLPropertyMapEntry aXMLTextPropMap[] = // RES_CHRATR_NOLINEBREAK // TODO: not used? // RES_CHRATR_BACKGROUND - MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ), + MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, CTF_CHAR_BACKGROUND ), MT_E( "CharBackTransparent", FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ), { "CharShadingValue", sizeof("CharShadingValue")-1, XML_NAMESPACE_LO_EXT, XML_CHAR_SHADING_VALUE, XML_TYPE_NUMBER|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_012_EXT_COMPAT, false }, MT_E( "CharBackColor", FO, TEXT_BACKGROUND_COLOR, XML_TYPE_COLOR|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_OLDTEXTBACKGROUND ), @@ -634,6 +636,8 @@ XMLPropertyMapEntry aXMLTextPropMap[] = // RES_CHRATR_SHADOW MAP_EXT( "CharShadowFormat", XML_NAMESPACE_LO_EXT, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ), MAP_EXT_I( "CharShadowFormat", XML_NAMESPACE_STYLE, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ), + // RES_CHRATR_HIGHLIGHT + MT_E( "CharHighlight", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_NO_PROPERTY_IMPORT, CTF_CHAR_HIGHLIGHT ), // RES_TXTATR_INETFMT MT_E( "HyperLinkURL", TEXT, XMLNS, XML_TYPE_STRING|MID_FLAG_NO_PROPERTY_IMPORT, CTF_HYPERLINK_URL ), // RES_TXTATR_REFMARK commit dba637ad230d132be0c8f69a630d0dfdfafc105f Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Sat Feb 21 10:37:54 2015 +0100 Char highlight: DOC filters Change-Id: Ia609425f6753796091d4dfdfae8e621c062e0c15 diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index e136665..6c3e94e 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -360,7 +360,7 @@ void Test::testCharHighlight() const char* aFilterNames[] = { // "writer8", "Rich Text Format", -// "MS Word 97", + "MS Word 97", "Office Open XML Text", }; @@ -371,6 +371,8 @@ void Test::testCharHighlight() mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_highlight.docx"), "com.sun.star.text.TextDocument"); + const OString sFailedMessage = OString("Failed on filter: ") + aFilterNames[nFilter]; + // Export the document and import again for a check uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); @@ -410,22 +412,22 @@ void Test::testCharHighlight() case 15: nHighlightColor = 0x808080; break; //dark gray case 16: nHighlightColor = 0xC0C0C0; break; //light gray } - CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); } // Only highlight { const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); } // Only background { const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); } } } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 95b0010..c52e9c3 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1281,6 +1281,17 @@ void WW8AttributeOutput::CharBorder( const SvxBorderLine* pAllBorder, const sal_ m_rWW8Export.Out_BorderLine( *m_rWW8Export.pO, pAllBorder, 0, NS_sprm::LN_CBrc80, NS_sprm::LN_CBrc, bShadow ); } +void WW8AttributeOutput::CharHighlight( const SvxBrushItem& rBrush ) +{ + if( m_rWW8Export.bWrtWW8 && rBrush.GetColor() != COL_TRANSPARENT ) + { + sal_uInt8 nColor = m_rWW8Export.TransCol( rBrush.GetColor() ); + // sprmCHighlight + m_rWW8Export.InsUInt16( NS_sprm::LN_CHighlight ); + m_rWW8Export.pO->push_back( nColor ); + } +} + void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) { if ( m_rWW8Export.bWrtWW8 ) diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 5b92a0f..eb3c64f 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -309,7 +309,7 @@ protected: virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow ) SAL_OVERRIDE; /// Sfx item RES_CHRATR_HIGHLIGHT - virtual void CharHighlight( const SvxBrushItem& ) SAL_OVERRIDE {}; + virtual void CharHighlight( const SvxBrushItem& ) SAL_OVERRIDE; /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFmtINetFmt& ) SAL_OVERRIDE; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 7e3148c..8428573 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -3822,7 +3822,7 @@ void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, const sal_uInt8* pData, sho { if( nLen <= 0 ) { - pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND ); + pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_HIGHLIGHT ); } else { @@ -3832,7 +3832,7 @@ void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, const sal_uInt8* pData, sho b = 0; // Auto -> Black Color aCol(GetCol(b)); - NewAttr( SvxBrushItem( aCol , RES_CHRATR_BACKGROUND )); + NewAttr( SvxBrushItem( aCol , RES_CHRATR_HIGHLIGHT )); } } commit caf653c03b9152a93c3e5959921fe98adfb7d639 Author: Zolnai Tamás <zolnaitamas2...@gmail.com> Date: Wed Mar 18 10:22:51 2015 +0100 Char highlight: RTF filters Handle \highlightN and \chcbpatN separately. Change-Id: I20546bd4c26154e8b1168f87dcb4ab44a192ad83 diff --git a/sw/qa/extras/ooxmlexport/data/char_highlight.docx b/sw/qa/extras/globalfilter/data/char_highlight.docx similarity index 100% rename from sw/qa/extras/ooxmlexport/data/char_highlight.docx rename to sw/qa/extras/globalfilter/data/char_highlight.docx diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index ae87472..e136665 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -28,12 +28,14 @@ public: void testLinkedGraphicRT(); void testImageWithSpecialID(); void testGraphicShape(); + void testCharHighlight(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testSwappedOutImageExport); CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testGraphicShape); + CPPUNIT_TEST(testCharHighlight); CPPUNIT_TEST_SUITE_END(); }; @@ -350,6 +352,84 @@ void Test::testGraphicShape() } } +void Test::testCharHighlight() +{ + // MS Word has two kind of character backgrounds called character shading and highlighting + // Now we support these two background attributes colors both in import and export code + + const char* aFilterNames[] = { +// "writer8", + "Rich Text Format", +// "MS Word 97", + "Office Open XML Text", + }; + + for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) + { + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_highlight.docx"), + "com.sun.star.text.TextDocument"); + + // Export the document and import again for a check + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString::createFromAscii(aFilterNames[nFilter]); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY); + xComponent->dispose(); + mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + + const uno::Reference< text::XTextRange > xPara = getParagraph(1); + // Both highlight and background + const sal_Int32 nBackColor(0x4F81BD); + for( int nRun = 1; nRun <= 16; ++nRun ) + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); + sal_Int32 nHighlightColor = 0; + switch( nRun ) + { + case 1: nHighlightColor = 0x000000; break; //black + case 2: nHighlightColor = 0x0000ff; break; //blue + case 3: nHighlightColor = 0x00ffff; break; //cyan + case 4: nHighlightColor = 0x00ff00; break; //green + case 5: nHighlightColor = 0xff00ff; break; //magenta + case 6: nHighlightColor = 0xff0000; break; //red + case 7: nHighlightColor = 0xffff00; break; //yellow + case 8: nHighlightColor = 0xffffff; break; //white + case 9: nHighlightColor = 0x000080; break;//dark blue + case 10: nHighlightColor = 0x008080; break; //dark cyan + case 11: nHighlightColor = 0x008000; break; //dark green + case 12: nHighlightColor = 0x800080; break; //dark magenta + case 13: nHighlightColor = 0x800000; break; //dark red + case 14: nHighlightColor = 0x808000; break; //dark yellow + case 15: nHighlightColor = 0x808080; break; //dark gray + case 16: nHighlightColor = 0xC0C0C0; break; //light gray + } + CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only highlight + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only background + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 0036db9..19c079e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -469,55 +469,6 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name } - -DECLARE_OOXMLEXPORT_TEST(testCharHighlight, "char_highlight.docx") -{ - const uno::Reference< text::XTextRange > xPara = getParagraph(1); - // Both highlight and background - const sal_Int32 nBackColor(0x4F81BD); - for( int nRun = 1; nRun <= 16; ++nRun ) - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); - sal_Int32 nHighlightColor = 0; - switch( nRun ) - { - case 1: nHighlightColor = 0x000000; break; //black - case 2: nHighlightColor = 0x0000ff; break; //blue - case 3: nHighlightColor = 0x00ffff; break; //cyan - case 4: nHighlightColor = 0x00ff00; break; //green - case 5: nHighlightColor = 0xff00ff; break; //magenta - case 6: nHighlightColor = 0xff0000; break; //red - case 7: nHighlightColor = 0xffff00; break; //yellow - case 8: nHighlightColor = 0xffffff; break; //white - case 9: nHighlightColor = 0x000080; break;//dark blue - case 10: nHighlightColor = 0x008080; break; //dark cyan - case 11: nHighlightColor = 0x008000; break; //dark green - case 12: nHighlightColor = 0x800080; break; //dark magenta - case 13: nHighlightColor = 0x800000; break; //dark red - case 14: nHighlightColor = 0x808000; break; //dark yellow - case 15: nHighlightColor = 0x808080; break; //dark gray - case 16: nHighlightColor = 0xC0C0C0; break; //light gray - } - CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only highlight - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only background - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); - } -} - - DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx") { // Check no empty font name is exported diff --git a/sw/qa/extras/rtfexport/data/fdo79599.rtf b/sw/qa/extras/rtfexport/data/fdo79599.rtf deleted file mode 100644 index f908709..0000000 --- a/sw/qa/extras/rtfexport/data/fdo79599.rtf +++ /dev/null @@ -1,38 +0,0 @@ -{\rtf1\deff0 -{\fonttbl -{\f000 Courier New;} -} -{\colortbl; -\red0\green0\blue0; -\red255\green255\blue0; -\red0\green255\blue0; -\red0\green255\blue255; -\red255\green0\blue255; -\red0\green0\blue255; -\red255\green0\blue0; -\red0\green0\blue128; -\red0\green128\blue128; -\red0\green128\blue0; -\red128\green0\blue128; -\red128\green0\blue0; -\red128\green128\blue0; -\red128\green128\blue128; -\red192\green192\blue192; -} -\highlight0 Should be ignored\par -\highlight2 #FFFF00 = Yellow\par -\highlight3 #00FF00 = Green\par -\highlight4 #00FFFF = Cyan\par -\highlight5 #FF00FF = Magenta\par -\highlight6 #0000FF = Blue\par -\highlight7 #FF0000 = Red\par -\highlight8 #000080 = Dark blue\par -\highlight9 #008080 = Dark cyan\par -\highlight10 #008000 = Dark green\par -\highlight11 #800080 = Dark magenta\par -\highlight12 #800000 = Dark red\par -\highlight13 #808000 = Dark yellow\par -\highlight14 #808080 = Dark gray\par -\highlight15 #C0C0C0 = Light gray\par -\highlight1 #000000 = Black\par -} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index de571a2..3ef2f13 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -670,15 +670,6 @@ DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf") CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName")); } -DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf") -{ - // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) - - // test \highlight11 = dark magenta - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(11),1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor")); -} - DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf") { // Problem was that after export, the page break was missing, so this was 1. diff --git a/sw/qa/extras/rtfimport/data/fdo79599.rtf b/sw/qa/extras/rtfimport/data/fdo79599.rtf deleted file mode 100644 index f908709..0000000 --- a/sw/qa/extras/rtfimport/data/fdo79599.rtf +++ /dev/null @@ -1,38 +0,0 @@ -{\rtf1\deff0 -{\fonttbl -{\f000 Courier New;} -} -{\colortbl; -\red0\green0\blue0; -\red255\green255\blue0; -\red0\green255\blue0; -\red0\green255\blue255; -\red255\green0\blue255; -\red0\green0\blue255; -\red255\green0\blue0; -\red0\green0\blue128; -\red0\green128\blue128; -\red0\green128\blue0; -\red128\green0\blue128; -\red128\green0\blue0; -\red128\green128\blue0; -\red128\green128\blue128; -\red192\green192\blue192; -} -\highlight0 Should be ignored\par -\highlight2 #FFFF00 = Yellow\par -\highlight3 #00FF00 = Green\par -\highlight4 #00FFFF = Cyan\par -\highlight5 #FF00FF = Magenta\par -\highlight6 #0000FF = Blue\par -\highlight7 #FF0000 = Red\par -\highlight8 #000080 = Dark blue\par -\highlight9 #008080 = Dark cyan\par -\highlight10 #008000 = Dark green\par -\highlight11 #800080 = Dark magenta\par -\highlight12 #800000 = Dark red\par -\highlight13 #808000 = Dark yellow\par -\highlight14 #808080 = Dark gray\par -\highlight15 #C0C0C0 = Light gray\par -\highlight1 #000000 = Black\par -} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 766ade9..5cffa27 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -604,59 +604,6 @@ DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); } -DECLARE_RTFIMPORT_TEST(testFdo79599, "fdo79599.rtf") -{ - // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) - - // ignore \highlight0 - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); - - // test \highlight2 = yellow - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty<sal_uInt32>(getRun(getParagraph(2), 1), "CharBackColor")); - - // test \highlight3 = green - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty<sal_uInt32>(getRun(getParagraph(3), 1), "CharBackColor")); - - // test \highlight4 = cyan - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty<sal_uInt32>(getRun(getParagraph(4), 1), "CharBackColor")); - - // test \highlight5 = magenta - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty<sal_uInt32>(getRun(getParagraph(5), 1), "CharBackColor")); - - // test \highlight6 = blue - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty<sal_uInt32>(getRun(getParagraph(6), 1), "CharBackColor")); - - // test \highlight7 = red - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty<sal_uInt32>(getRun(getParagraph(7), 1), "CharBackColor")); - - // test \highlight8 = dark blue - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty<sal_uInt32>(getRun(getParagraph(8), 1), "CharBackColor")); - - // test \highlight9 = dark cyan - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty<sal_uInt32>(getRun(getParagraph(9), 1), "CharBackColor")); - - // test \highlight10 = dark green - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty<sal_uInt32>(getRun(getParagraph(10), 1), "CharBackColor")); - - // test \highlight11 = dark magenta - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(getRun(getParagraph(11), 1), "CharBackColor")); - - // test \highlight12 = dark red - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty<sal_uInt32>(getRun(getParagraph(12), 1), "CharBackColor")); - - // test \highlight13 = dark yellow - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty<sal_uInt32>(getRun(getParagraph(13), 1), "CharBackColor")); - - // test \highlight14 = dark gray - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty<sal_uInt32>(getRun(getParagraph(14), 1), "CharBackColor")); - - // test \highlight15 = light gray - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty<sal_uInt32>(getRun(getParagraph(15), 1), "CharBackColor")); - - // test \highlight1 = black - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty<sal_uInt32>(getRun(getParagraph(16), 1), "CharBackColor")); -} - DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf") { // Access the second run, which is a textfield @@ -1211,8 +1158,7 @@ DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf") uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); // Was the Writer default font. CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName")); - // It is white (0xFFFFFF) in document - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty<sal_uInt32>(xTextRange, "CharBackColor")); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf") diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 83ef2ba..ad3cf5e 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2305,7 +2305,7 @@ void RtfAttributeOutput::CharBackground(const SvxBrushItem& rBrush) { if (!rBrush.GetColor().GetTransparency()) { - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HIGHLIGHT); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT); m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor())); } } @@ -2470,6 +2470,15 @@ void RtfAttributeOutput::CharBorder(const SvxBorderLine* pAllBorder, const sal_u m_aStyles.append(OutBorderLine(m_rExport, pAllBorder, OOO_STRING_SVTOOLS_RTF_CHBRDR, nDist, bShadow ? SVX_SHADOW_BOTTOMRIGHT : SVX_SHADOW_NONE)); } +void RtfAttributeOutput::CharHighlight(const SvxBrushItem& rBrush) +{ + if (!rBrush.GetColor().GetTransparency()) + { + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HIGHLIGHT); + m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor())); + } +} + void RtfAttributeOutput::TextINetFormat(const SwFmtINetFmt& rURL) { if (!rURL.GetValue().isEmpty()) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 20b76a2..a307885d 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -328,7 +328,7 @@ protected: virtual void CharBorder(const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow) SAL_OVERRIDE; /// Sfx item RES_CHRATR_HIGHLIGHT - virtual void CharHighlight(const SvxBrushItem&) SAL_OVERRIDE {}; + virtual void CharHighlight(const SvxBrushItem&) SAL_OVERRIDE; /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat(const SwFmtINetFmt&) SAL_OVERRIDE; diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index a8b991b..8b1ae6d 100644 ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits