[Libreoffice-commits] core.git: editeng/source oox/source sd/qa sw/qa sw/source xmloff/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Sun Feb 25 07:10:18 UTC 2018
editeng/source/uno/unonrule.cxx | 14 ++++++-----
oox/source/drawingml/textparagraphproperties.cxx | 6 ++--
oox/source/token/properties.txt | 2 -
sd/qa/unit/data/odp/BulletsAsImage.odp |binary
sd/qa/unit/export-tests-ooxml2.cxx | 28 +++++++++++++++++++++++
sw/qa/extras/odfexport/data/BulletAsImage.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 17 +++++++++++++
sw/source/core/unocore/unosett.cxx | 11 ++++-----
xmloff/source/style/xmlnumi.cxx | 21 ++++++++++-------
9 files changed, 76 insertions(+), 23 deletions(-)
New commits:
commit 4256ffa959f994f0964f7391fad70df8a9c884f0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed Feb 21 20:15:21 2018 +0900
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 at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
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
Binary files /dev/null and b/sd/qa/unit/data/odp/BulletsAsImage.odp 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
Binary files /dev/null and b/sw/qa/extras/odfexport/data/BulletAsImage.odt 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;
More information about the Libreoffice-commits
mailing list