RTF import: handle the pictureContrast and pictureBrightness shape props
Map it to (the UNO API of) GraphicDrawMode::Watermark, similar to what the binary import does in SvxMSDffManager::ImportGraphic() and how the drawingML import does it in oox::drawingml::GraphicProperties::pushToPropMap(). Change-Id: I8023aa8fcbd086d4c7a30729e3ca615a7356da4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128515 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
{\rtf1
|
||||
{\header\pard\plain
|
||||
{\shp
|
||||
{\*\shpinst\shpleft0\shptop0\shpright9359\shpbottom9359\shpfhdr1\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz1\shplid2050
|
||||
{\sp
|
||||
{\sn shapeType}
|
||||
{\sv 75}
|
||||
}
|
||||
{\sp
|
||||
{\sn pib}
|
||||
{\sv
|
||||
{\pict\picscalex914\picscaley914\piccropl0\piccropr0\piccropt0\piccropb0\picw1806\pich1806\picwgoal1024\pichgoal1024\pngblip\bliptag133373369
|
||||
89504e470d0a1a0a0000000d49484452000000400000004008040000000060b9550000000467414d410000b18f0bfc6105000000017352474200aece1ce90000
|
||||
00206348524d00007a26000080840000fa00000080e8000075300000ea6000003a98000017709cba513c00000002624b47440000aa8d2332000000096f464673
|
||||
0000000600000000000c7355d3000000097048597300000dd700000dd70142289b7800000009767041670000004c00000040009d31381b000001cd4944415468
|
||||
deedd93d4fc24018c0f17f89c6cdc44940e3e222be2c0e7e0417e3a8113571707632514012a320c6f84d34be2c2ec2b750f40be8e6e4a00113cfe14a5b69b108
|
||||
f4589ee71652eefafce0b9f42e3d7063822aaac3f641d173a75d3efee85b6582c0c8749c5eb7332cfb4e6f213d336ed29807304477b1c7a94db80ae9e9c934d0
|
||||
fcdd12e7ffcefcc9168f9a0059143b8cb0d2de581f609854073fbecc220f60b18722479d0d14abed8c8cb5d3293ce2949903b0d8a7047cb1c98541008cba840c
|
||||
a736e1d2200046b967567f740961d3b197008873cf74835002eaac7363100009ca0d4296121675d2dc1a0440d2256428625163ed2f42cf011e8245d621b42c44
|
||||
0400485261a699706d1000092fa100d4490713220240dc25e438b1090185880ca09f8ece5c28d9843b009e82471ca25069d5cb785529bd007fdbfb8541b65b2f
|
||||
531100947a51530d42c1d92f9829818e31ca4ce9421c70e427440e80712a7a89b7c8fb0906003046a5311df31cf501a01f4d0ee1b80f00bd4c398558ee0340ff
|
||||
0b939a30df17002459f05d330a080a0108400002108000042000010840000210800004200001f8ce0ddf798e30dd7b38e0ce7ea16d2abc25a819cbda225337c7
|
||||
f7ff69bf8eef7f0084e08d42bdf8a03e00000025744558746372656174652d6461746500323031302d31322d32305431373a30383a33362b30313a30307ae51b1c00000025744558746d6f646966792d6461746500323031302d31322d32305431373a30383a33372b30313a30308323669c0000000049454e44ae426082}
|
||||
}
|
||||
}
|
||||
{\sp
|
||||
{\sn pictureContrast}
|
||||
{\sv 19661}
|
||||
}
|
||||
{\sp
|
||||
{\sn pictureBrightness}
|
||||
{\sv 22938}
|
||||
}
|
||||
{\sp
|
||||
{\sn posh}
|
||||
{\sv 2}
|
||||
}
|
||||
{\sp
|
||||
{\sn posv}
|
||||
{\sv 2}
|
||||
}
|
||||
}
|
||||
}
|
||||
\par
|
||||
}
|
||||
\pard\plain\par
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
|
||||
#include <com/sun/star/drawing/ColorMode.hpp>
|
||||
#include <com/sun/star/text/TextContentAnchorType.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
@@ -64,6 +65,28 @@ CPPUNIT_TEST_FIXTURE(Test, testPictureInTextframe)
|
||||
// on import.
|
||||
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eAnchorType);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testWatermark)
|
||||
{
|
||||
// Given a document with a picture watermark, and the "washout" checkbox is ticked on the Word
|
||||
// UI:
|
||||
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "watermark.rtf";
|
||||
|
||||
// When loading that document:
|
||||
getComponent() = loadFromDesktop(aURL);
|
||||
|
||||
// Then make sure the watermark effect is not lost on import:
|
||||
uno::Reference<drawing::XDrawPageSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
|
||||
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPagesSupplier->getDrawPage();
|
||||
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
||||
drawing::ColorMode eMode{};
|
||||
xShape->getPropertyValue("GraphicColorMode") >>= eMode;
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - Expected: 3
|
||||
// - Actual : 0
|
||||
// i.e. the color mode was STANDARD, not WATERMARK.
|
||||
CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, eMode);
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <com/sun/star/drawing/LineStyle.hpp>
|
||||
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
|
||||
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
|
||||
#include <com/sun/star/drawing/ColorMode.hpp>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/table/BorderLine2.hpp>
|
||||
#include <com/sun/star/text/HoriOrientation.hpp>
|
||||
@@ -396,6 +397,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
||||
OUString aFontFamily = "";
|
||||
float nFontSize = 1.0;
|
||||
|
||||
sal_Int32 nContrast = 0x10000;
|
||||
sal_Int16 nBrightness = 0;
|
||||
|
||||
bool bCustom(false);
|
||||
int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
|
||||
|
||||
@@ -855,6 +859,26 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
||||
obFlipH = rProperty.second.toInt32() == 1;
|
||||
else if (rProperty.first == "fFlipV")
|
||||
obFlipV = rProperty.second.toInt32() == 1;
|
||||
else if (rProperty.first == "pictureContrast")
|
||||
{
|
||||
// Gain / contrast.
|
||||
nContrast = rProperty.second.toInt32();
|
||||
if (nContrast < 0x10000)
|
||||
{
|
||||
nContrast *= 101; // 100 + 1 to round
|
||||
nContrast /= 0x10000;
|
||||
nContrast -= 100;
|
||||
}
|
||||
}
|
||||
else if (rProperty.first == "pictureBrightness")
|
||||
{
|
||||
// Blacklevel / brightness.
|
||||
nBrightness = rProperty.second.toInt32();
|
||||
if (nBrightness != 0)
|
||||
{
|
||||
nBrightness /= 327;
|
||||
}
|
||||
}
|
||||
else
|
||||
SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'"
|
||||
<< rProperty.second << "'");
|
||||
@@ -879,6 +903,13 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
||||
if (!m_aParents.empty() && m_aParents.top().is() && !m_bTextFrame)
|
||||
m_aParents.top()->add(xShape);
|
||||
|
||||
if (nContrast == -70 && nBrightness == 70 && xPropertySet.is())
|
||||
{
|
||||
// Map MSO 'washout' to our watermark colormode.
|
||||
xPropertySet->setPropertyValue("GraphicColorMode",
|
||||
uno::makeAny(drawing::ColorMode_WATERMARK));
|
||||
}
|
||||
|
||||
if (bPib)
|
||||
{
|
||||
m_rImport.resolvePict(false, xShape);
|
||||
|
||||
Reference in New Issue
Block a user