summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-21 20:15:21 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-25 08:09:56 +0100
commit4256ffa959f994f0964f7391fad70df8a9c884f0 (patch)
treebf4bf55fa48f0e6af3093edf43d82c13a7f56615
parent99223fc736c55cc1eb319ae1576b3998771e6b6f (diff)
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/50140 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--editeng/source/uno/unonrule.cxx14
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx6
-rw-r--r--oox/source/token/properties.txt2
-rw-r--r--sd/qa/unit/data/odp/BulletsAsImage.odpbin0 -> 11475 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx28
-rw-r--r--sw/qa/extras/odfexport/data/BulletAsImage.odtbin0 -> 9856 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx17
-rw-r--r--sw/source/core/unocore/unosett.cxx11
-rw-r--r--xmloff/source/style/xmlnumi.cxx21
9 files changed, 76 insertions, 23 deletions
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 50fcd053ebcd..a682132c5b01 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -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;
}
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 8f4e635db48c..807a2deff54f 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -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);
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index e90bd9c58912..b4da0cb63439 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -203,6 +203,7 @@ GenerateVbaEvents
Geometry3D
GradientName
Graphic
+GraphicBitmap
GraphicColorMode
GraphicCrop
GraphicSize
@@ -245,7 +246,6 @@ IgnoreBlankCells
IgnoreCase
IgnoreLeadingSpaces
ImagePosition
-ImageURL
IncludeHiddenCells
InputMessage
InputTitle
diff --git a/sd/qa/unit/data/odp/BulletsAsImage.odp b/sd/qa/unit/data/odp/BulletsAsImage.odp
new file mode 100644
index 000000000000..21d10e494829
--- /dev/null
+++ b/sd/qa/unit/data/odp/BulletsAsImage.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 9fc5302f0325..ed282a6e787b 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -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();
diff --git a/sw/qa/extras/odfexport/data/BulletAsImage.odt b/sw/qa/extras/odfexport/data/BulletAsImage.odt
new file mode 100644
index 000000000000..85e0c0735487
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/BulletAsImage.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index ae5ae1735e35..de1399620fea 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -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();
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index fbcafd56637a..ce39098a3bd2 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -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;
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 2003144946b9..7c0a4665b611 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -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;