Kaydet (Commit) 4256ffa9 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

fix import of graphic bullets

When changing to use "GraphicBitmap" property instead of
"ImageURL", the import wasn't adapted and there was no test which
would warn of such an situation. This also changes the difference
between writer and impress where impress used "Graphic" and not
"GraphicBitmap" property.

Also adds missing tests for both writer and impress

Change-Id: Ieed629d2d37f7806d63e729b6ef23cd848593071
Reviewed-on: https://gerrit.libreoffice.org/50140Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 99223fc7
......@@ -22,6 +22,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx>
#include <vcl/graph.hxx>
......@@ -225,7 +226,7 @@ Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex(sal
pGraphic = pBrush->GetGraphic();
if (pGraphic)
{
uno::Reference<awt::XBitmap> xBitmap = VCLUnoHelper::CreateBitmap(pGraphic->GetBitmapEx());
uno::Reference<awt::XBitmap> xBitmap(pGraphic->GetXGraphic(), uno::UNO_QUERY);
aVal <<= xBitmap;
const beans::PropertyValue aGraphicProp("GraphicBitmap", -1, aVal, beans::PropertyState_DIRECT_VALUE);
......@@ -352,13 +353,14 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex(const Sequence<beans::Propert
continue;
}
}
else if ( rPropName == "Graphic" )
else if ( rPropName == "GraphicBitmap" )
{
Reference< awt::XBitmap > xBmp;
if( aVal >>= xBmp )
uno::Reference<awt::XBitmap> xBitmap;
if(aVal >>= xBitmap)
{
Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) );
SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH);
uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
Graphic aGraphic(xGraphic);
SvxBrushItem aBrushItem(aGraphic, GPOS_AREA, SID_ATTR_BRUSH);
aFmt.SetGraphicBrush( &aBrushItem );
continue;
}
......
......@@ -346,9 +346,9 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, P
}
if ( maGraphic.hasValue() )
{
Reference< css::awt::XBitmap > xBitmap( maGraphic, UNO_QUERY );
if ( xBitmap.is() )
rPropMap.setProperty( PROP_Graphic, xBitmap);
Reference<css::awt::XBitmap> xBitmap(maGraphic, UNO_QUERY);
if (xBitmap.is())
rPropMap.setProperty(PROP_GraphicBitmap, xBitmap);
}
if( mnSize.hasValue() )
rPropMap.setAnyProperty( PROP_BulletRelSize, mnSize);
......
......@@ -203,6 +203,7 @@ GenerateVbaEvents
Geometry3D
GradientName
Graphic
GraphicBitmap
GraphicColorMode
GraphicCrop
GraphicSize
......@@ -245,7 +246,6 @@ IgnoreBlankCells
IgnoreCase
IgnoreLeadingSpaces
ImagePosition
ImageURL
IncludeHiddenCells
InputMessage
InputTitle
......
......@@ -131,6 +131,7 @@ public:
void testFontScale();
void testTdf115394();
void testTdf115394Zero();
void testBulletsAsImage();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
......@@ -187,6 +188,7 @@ public:
CPPUNIT_TEST(testFontScale);
CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST(testTdf115394Zero);
CPPUNIT_TEST(testBulletsAsImage);
CPPUNIT_TEST_SUITE_END();
......@@ -1471,6 +1473,32 @@ void SdOOXMLExportTest2::testTdf115394Zero()
xDocShRef->DoClose();
}
void SdOOXMLExportTest2::testBulletsAsImage()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/BulletsAsImage.odp"), ODP);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProperties;
xLevels->getByIndex(0) >>= aProperties; // 1st level
uno::Reference<awt::XBitmap> xBitmap;
for (const beans::PropertyValue& rProperty : aProperties)
{
if (rProperty.Name == "GraphicBitmap")
{
xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
}
}
CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1918,6 +1918,23 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt")
}
}
DECLARE_ODFEXPORT_TEST(testBulletAsImage, "BulletAsImage.odt")
{
uno::Reference<text::XTextRange> xPara(getParagraph(1));
uno::Reference<beans::XPropertySet> xPropertySet(xPara, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xLevels;
xLevels.set(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProperties;
xLevels->getByIndex(0) >>= aProperties;
uno::Reference<awt::XBitmap> xBitmap;
for (int i = 0; i < aProperties.getLength(); ++i)
{
if (aProperties[i].Name == "GraphicBitmap")
xBitmap = aProperties[i].Value.get<uno::Reference<awt::XBitmap>>();
}
CPPUNIT_ASSERT(xBitmap.is());
}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -50,6 +50,7 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/style/LineNumberPosition.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <o3tl/any.hxx>
......@@ -1451,8 +1452,8 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat
pGraphic = pBrush->GetGraphic();
if(pGraphic)
{
uno::Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( pGraphic->GetBitmapEx() );
aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP, xBmp));
uno::Reference<awt::XBitmap> xBitmap(pGraphic->GetXGraphic(), uno::UNO_QUERY);
aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP, xBitmap));
}
Size aSize = rFormat.GetGraphicSize();
// #i101131#
......@@ -1959,9 +1960,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
}
BitmapEx aBmp = VCLUnoHelper::GetBitmap(xBitmap);
Graphic aNewGr(aBmp);
pSetBrush->SetGraphic( aNewGr );
uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
Graphic aGraphic(xGraphic);
pSetBrush->SetGraphic(aGraphic);
}
else
bWrongArg = true;
......
......@@ -29,6 +29,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <o3tl/any.hxx>
#include <o3tl/make_unique.hxx>
......@@ -528,23 +529,27 @@ Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties()
if( bImage )
{
OUString sStr( sImageURL );
if( !sImageURL.isEmpty() )
uno::Reference<graphic::XGraphic> xGraphic;
if (!sImageURL.isEmpty())
{
sStr = GetImport().ResolveGraphicObjectURL( sImageURL, false );
xGraphic = GetImport().loadGraphicByURL(sImageURL);
}
else if( xBase64Stream.is() )
{
sStr = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
xGraphic = GetImport().loadGraphicFromBase64(xBase64Stream);
}
if( !sStr.isEmpty() )
uno::Reference<awt::XBitmap> xBitmap;
if (xGraphic.is())
xBitmap.set(xGraphic, uno::UNO_QUERY);
if (xBitmap.is())
{
pProps[nPos].Name = "GraphicURL";
pProps[nPos++].Value <<= sStr;
pProps[nPos].Name = "GraphicBitmap";
pProps[nPos++].Value <<= xBitmap;
}
awt::Size aSize( nImageWidth, nImageHeight );
awt::Size aSize(nImageWidth, nImageHeight);
pProps[nPos].Name = "GraphicSize";
pProps[nPos++].Value <<= aSize;
......
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