Kaydet (Commit) 24077b2d authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: import paragraph color as fill attributes

In theory this is to be in sync with the ODF import. In practice the old
UNO property seems not to have a proper fallback to populate the doc
model with the fillattributes, so without this even if the import result
is visible, it would be lost on ODF export.

Additionally, this detected a bug in SwUnoCursorHelper::makeRedline(),
where paragraph format redline tried to use the map of a text portion
instead of a paragraph.

Change-Id: I026e38e1990ed2a460624a8d967a16ae3fb6c512
üst eaf1c5f8
......@@ -10,6 +10,7 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/text/FontEmphasis.hpp>
......@@ -631,9 +632,8 @@ DECLARE_OOXMLEXPORT_TEST(testEffectExtentMargin, "effectextent-margin.docx")
DECLARE_OOXMLEXPORT_TEST(testTdf88583, "tdf88583.odt")
{
if (xmlDocPtr pXmlDoc = parseExport())
// <w:pPr> had no <w:shd> child element, paragraph background was lost.
assertXPath(pXmlDoc, "//w:pPr/w:shd", "fill", "00CC00");
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x00cc00), getProperty<sal_Int32>(getParagraph(1), "FillColor"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1217,9 +1217,13 @@ void makeRedline( SwPaM& rPaM,
// Check if the value exists
if ( aRevertPropertiesValue >>= aRevertProperties )
{
// sw/source/core/unocore/unoport.cxx#83 is where it's decided what map gets used for a text portion
// so it's PROPERTY_MAP_TEXTPORTION_EXTENSIONS, unless it's a redline portion
SfxItemPropertySet const& rPropSet = (*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS));
int nMap = 0;
// Make sure that paragraph format gets its own map, otherwise e.g. fill attributes are not preserved.
if (eType == nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT)
nMap = PROPERTY_MAP_PARAGRAPH;
else
nMap = PROPERTY_MAP_TEXTPORTION_EXTENSIONS;
SfxItemPropertySet const& rPropSet = (*aSwMapProvider.GetPropertySet(nMap));
// Check if there are any properties
if (aRevertProperties.getLength())
......
......@@ -21,6 +21,7 @@
#include <ConversionHelper.hxx>
#include <TDefTableHandler.hxx>
#include <ooxml/resourceids.hxx>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/ShadingPattern.hpp>
#include <sal/macros.h>
#include <filter/msfilter/util.hxx>
......@@ -268,9 +269,14 @@ TablePropertyMapPtr CellColorHandler::getProperties()
pPropertyMap->Insert(PROP_CHAR_SHADING_VALUE, uno::makeAny( nShadingPattern ));
}
pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
: m_OutputFormat == Paragraph ? PROP_PARA_BACK_COLOR
: PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor ));
if (m_OutputFormat == Paragraph)
{
pPropertyMap->Insert(PROP_FILL_STYLE, uno::makeAny(drawing::FillStyle_SOLID));
pPropertyMap->Insert(PROP_FILL_COLOR, uno::makeAny(nApplyColor));
}
else
pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
: PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor ));
createGrabBag("originalColor", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nApplyColor, true))));
......
......@@ -401,6 +401,8 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_ROW_CNF_STYLE: sName = "RowCnfStyle"; break;
case PROP_CELL_HIDE_MARK: sName = "CellHideMark"; break;
case PROP_FOLLOW_TEXT_FLOW: sName = "IsFollowingTextFlow"; break;
case PROP_FILL_STYLE: sName = "FillStyle"; break;
case PROP_FILL_COLOR: sName = "FillColor"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
......
......@@ -373,6 +373,8 @@ enum PropertyIds
,PROP_ROW_CNF_STYLE
,PROP_CELL_HIDE_MARK
,PROP_FOLLOW_TEXT_FLOW
,PROP_FILL_STYLE
,PROP_FILL_COLOR
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment