drawinglayer/source/tools/primitive2dxmldump.cxx | 63 ++++++ editeng/source/items/textitem.cxx | 40 +++- include/editeng/memberids.h | 4 include/editeng/unoprnms.hxx | 1 include/editeng/unotext.hxx | 1 offapi/com/sun/star/style/CharacterProperties.idl | 8 schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng | 6 sd/qa/unit/data/transparent-text.fodg | 64 ++++++ sd/qa/unit/export-tests.cxx | 22 ++ svx/CppunitTest_svx_unit.mk | 7 svx/qa/unit/svdraw.cxx | 114 ++++++++++++ svx/source/svdraw/svdotextdecomposition.cxx | 9 xmloff/source/text/txtprmap.cxx | 4 13 files changed, 337 insertions(+), 6 deletions(-)
New commits: commit 7977532e76b7b47bf8201bc837d026bea78fbc1f Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 21 11:50:54 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 8 09:54:56 2020 +0200 xmloff: add ODF import/export for semi-transparent shape text Test this from sd, so that SdModelTestBase::saveAndReload() calls BootstrapFixture::validate() for us. Change-Id: I6c90a3a71a5603604e69f9b45137bc8e4388dc0f Reviewed-on: https://gerrit.libreoffice.org/83371 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 4dbb33a1c21948bebcf890c2f8ceb56b15a87936) diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng index 7b2b04c68a72..8e54c2c4bda1 100644 --- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng +++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng @@ -2029,6 +2029,12 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. <rng:ref name="string"/> </rng:attribute> </rng:optional> + <!-- TODO no proposal --> + <rng:optional> + <rng:attribute name="loext:opacity"> + <rng:ref name="zeroToHundredPercent"/> + </rng:attribute> + </rng:optional> </rng:define> <rng:define name="style-text-properties-attlist" combine="interleave"> diff --git a/sd/qa/unit/data/transparent-text.fodg b/sd/qa/unit/data/transparent-text.fodg new file mode 100644 index 000000000000..697f2a22b8c1 --- /dev/null +++ b/sd/qa/unit/data/transparent-text.fodg @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:office="urn:oas is:names:tc:opendocument:xmlns:office:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsd ="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.graphics"> + <office:font-face-decls> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Noto Sans" svg:font-family="'Noto Sans'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lucida Sans" svg:font-family="'Lucida Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Segoe UI" svg:font-family="'Segoe UI'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <draw:marker draw:name="Arrow" svg:viewBox="0 0 20 30" svg:d="M10 0l-10 30h20z"/> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:punctuation-wrap="simple" style:line-break="strict" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="24pt" fo:language="hu" fo:country="HU" style:font-name-asian="Segoe UI" style:font-size-asian="24pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Tahoma" style:font-size-complex="24pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:style style:name="standard" style:family="graphic"> + <style:graphic-properties draw:stroke="solid" svg:stroke-width="0cm" svg:stroke-color="#3465a4" draw:marker-start-width="0.2cm" draw:marker-start-center="false" draw:marker-end-width="0.2cm" draw:marker-end-center="false" draw:fill="solid" draw:fill-color="#729fcf" draw:textarea-horizontal-align="justify" fo:padding-top="0.125cm" fo:padding-bottom="0.125cm" fo:padding-left="0.25cm" fo:padding-right="0.25cm" draw:shadow="hidden" draw:shadow-offset-x="0.2cm" draw:shadow-offset-y="0.2cm" draw:shadow-color="#808080"> + </style:graphic-properties> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-indent="0cm"/> + <style:text-properties fo:font-variant="normal" fo:text-transform="none" style:use-window-font-color="true" loext:opacity="0%" style:text-outline="false" style:text-line-through-style="none" style:text-line-through-type="none" style:font-name="Liberation Sans" fo:font-family="'Liberation Sans'" style:font-family-generic="roman" style:font-pitch="variable" fo:font-size="18pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:letter-kerning="true" style:font-name-asian="Tahoma" style:font-family-asian="Tahoma" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="18pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-name-complex="Lucida Sans" style:font-family-complex="'Lucida Sans'" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="18pt" style:font-style-complex="normal" style :font-weight-complex="normal" style:text-emphasize="none" style:font-relief="none" style:text-overline-style="none" style:text-overline-color="font-color"/> + </style:style> + <style:style style:name="objectwithoutfill" style:family="graphic" style:parent-style-name="standard"/> + <style:style style:name="Text" style:family="graphic"> + <style:graphic-properties draw:stroke="solid" svg:stroke-color="#cccccc" draw:fill="solid" draw:fill-color="#eeeeee"/> + <style:text-properties style:font-name="Noto Sans" fo:font-family="'Noto Sans'" style:font-family-generic="roman" style:font-pitch="variable"/> + </style:style> + </office:styles> + <office:automatic-styles> + <style:page-layout style:name="PM0"> + <style:page-layout-properties fo:margin-top="1cm" fo:margin-bottom="1cm" fo:margin-left="1cm" fo:margin-right="1cm" fo:page-width="21.59cm" fo:page-height="27.94cm" style:print-orientation="portrait"/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="border" draw:fill="none"/> + </style:style> + <style:style style:name="dp2" style:family="drawing-page"/> + <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard"> + <style:graphic-properties draw:stroke="none" svg:stroke-color="#3465a4" draw:fill="none" draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="5.148cm" fo:min-width="7.491cm"/> + </style:style> + <style:style style:name="P1" style:family="paragraph"> + <loext:graphic-properties draw:fill="none"/> + <style:text-properties fo:color="#ff0000" loext:opacity="25%" fo:font-size="66pt" style:font-size-asian="18pt" style:font-size-complex="18pt"/> + </style:style> + <style:style style:name="T1" style:family="text"> + <style:text-properties fo:color="#ff0000" loext:opacity="25%" fo:font-size="66pt" style:font-size-asian="18pt" style:font-size-complex="18pt"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Default" style:page-layout-name="PM0" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:drawing> + <draw:page draw:name="page1" draw:style-name="dp2" draw:master-page-name="Default"> + <draw:custom-shape draw:name="Shape3" draw:style-name="gr1" draw:text-style-name="P1" draw:layer="layout" svg:width="7.991cm" svg:height="5.398cm" svg:x="6.43cm" svg:y="14.304cm"> + <text:p><text:span text:style-name="T1">asdf</text:span></text:p> + <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N"/> + </draw:custom-shape> + </draw:page> + </office:drawing> + </office:body> +</office:document> diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 57fe771339f1..9f15a20e47c4 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -57,6 +57,7 @@ public: void testTransparentBackground(); void testEmbeddedPdf(); void testEmbeddedText(); + void testTransparenText(); void testTdf98477(); void testAuthorField(); void testTdf50499(); @@ -88,6 +89,7 @@ public: CPPUNIT_TEST(testTransparentBackground); CPPUNIT_TEST(testEmbeddedPdf); CPPUNIT_TEST(testEmbeddedText); + CPPUNIT_TEST(testTransparenText); CPPUNIT_TEST(testTdf98477); CPPUNIT_TEST(testAuthorField); CPPUNIT_TEST(testTdf50499); @@ -824,6 +826,26 @@ void SdExportTest::testEmbeddedText() xShell->DoClose(); } +void SdExportTest::testTransparenText() +{ + sd::DrawDocShellRef xShell + = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/transparent-text.fodg"), FODG); + xShell = saveAndReload(xShell.get(), ODG); + + uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell); + uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY); + sal_Int16 nCharTransparence = 0; + xShape->getPropertyValue("CharTransparence") >>= nCharTransparence; + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 75 + // - Actual : 0 + // i.e. the 75% transparent text was turned into a "not transparent at all" text. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(75), nCharTransparence); + + xShell->DoClose(); +} + void SdExportTest::testTdf98477() { utl::TempFile tempFile; diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index e3597b7c6f50..4a28c3e6be23 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -135,6 +135,8 @@ XMLPropertyMapEntry const aXMLParaPropMap[] = // RES_CHRATR_COLOR MT_ED( "CharColor", FO, COLOR, XML_TYPE_COLORAUTO|MID_FLAG_MERGE_PROPERTY, 0 ), MT_ED( "CharColor", STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT @@ -476,6 +478,8 @@ XMLPropertyMapEntry const aXMLTextPropMap[] = // RES_CHRATR_COLOR MT_ED( "CharColor", FO, COLOR, XML_TYPE_COLORAUTO|MID_FLAG_MERGE_PROPERTY, 0 ), MT_ED( "CharColor", STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ), + MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT commit 686e36a6a46c90aa2f4739c53f27d90a9f05a97a Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Nov 20 16:15:39 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 8 09:54:27 2020 +0200 svx: add rendering for semi-transparent shape text The color's alpha is normally lost when we roundtrip SvxColorItem's tools Color via TextSimplePortionPrimitive2D's basegfx::BColor. One way would be to add an extra transparency member to the primitive, like BackgroundColorPrimitive2D does that. However, a much easier way is to go via UnifiedTransparencePrimitive2D, that way we handle transparency in drawinglayer::impBufferDevice::paint(), rather than platform-specific code like CairoTextRender::DrawTextLayout() in the Linux case. Change-Id: Ie7aebe77ad9ac776dd27fc50538a5045200c8010 Reviewed-on: https://gerrit.libreoffice.org/83307 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 81b0d5393ca4cf2ff0954e53b05928cde047c2e0) diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index c6c30138f4db..8514f438c8f0 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -9,7 +9,10 @@ $(eval $(call gb_CppunitTest_CppunitTest,svx_unit)) -$(eval $(call gb_CppunitTest_use_external,svx_unit,boost_headers)) +$(eval $(call gb_CppunitTest_use_externals,svx_unit,\ + boost_headers \ + libxml2 \ +)) $(eval $(call gb_CppunitTest_use_sdk_api,svx_unit)) @@ -22,6 +25,7 @@ $(eval $(call gb_CppunitTest_set_include,svx_unit,\ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ svx/qa/unit/svdraw/test_SdrTextObject \ svx/qa/unit/customshapes \ + svx/qa/unit/svdraw \ svx/qa/unit/unodraw \ svx/qa/unit/xoutdev \ svx/qa/unit/XTableImportExportTest \ @@ -29,6 +33,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ basegfx \ + drawinglayer \ sal \ sfx \ svxcore \ diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx new file mode 100644 index 000000000000..d702effe2dbe --- /dev/null +++ b/svx/qa/unit/svdraw.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> +#include <test/xmltesttools.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/text/XTextRange.hpp> + +#include <drawinglayer/tools/primitive2dxmldump.hxx> +#include <rtl/ustring.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <svx/sdr/contact/viewcontact.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <svx/sdrpagewindow.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdview.hxx> +#include <svx/unopage.hxx> +#include <vcl/virdev.hxx> + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for svx/source/svdraw/ code. +class SvdrawTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +{ +protected: + uno::Reference<lang::XComponent> mxComponent; + +public: + virtual void setUp() override + { + test::BootstrapFixture::setUp(); + mxDesktop.set(frame::Desktop::create(m_xContext)); + } + + virtual void tearDown() override + { + if (mxComponent.is()) + { + mxComponent->dispose(); + } + test::BootstrapFixture::tearDown(); + } + uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } +}; + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testSemiTransparentText) +{ + // Create a new Draw document with a rectangle. + getComponent() = loadFromDesktop("private:factory/sdraw"); + uno::Reference<lang::XMultiServiceFactory> xFactory(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); + xShape->setSize(awt::Size(10000, 10000)); + xShape->setPosition(awt::Point(1000, 1000)); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + xDrawPage->add(xShape); + + // Add semi-transparent text on the rectangle. + uno::Reference<text::XTextRange> xShapeText(xShape, uno::UNO_QUERY); + xShapeText->getText()->setString("hello"); + + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + xShapeProperties->setPropertyValue("CharColor", uno::makeAny(COL_RED)); + sal_Int16 nTransparence = 75; + xShapeProperties->setPropertyValue("CharTransparence", uno::makeAny(nTransparence)); + + // Generates drawinglayer primitives for the page. + auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get()); + CPPUNIT_ASSERT(pDrawPage); + SdrPage* pSdrPage = pDrawPage->GetSdrPage(); + ScopedVclPtrInstance<VirtualDevice> aVirtualDevice; + SdrView aSdrView(pSdrPage->getSdrModelFromSdrPage(), aVirtualDevice); + SdrPageView aSdrPageView(pSdrPage, aSdrView); + SdrPageWindow* pSdrPageWindow = aSdrPageView.GetPageWindow(0); + sdr::contact::ObjectContact& rObjectContactOfPageView = pSdrPageWindow->GetObjectContact(); + const sdr::contact::ViewObjectContact& rDrawPageVOContact + = pSdrPage->GetViewContact().GetViewObjectContact(rObjectContactOfPageView); + sdr::contact::DisplayInfo aDisplayInfo; + drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence + = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo); + + // Make sure the text is semi-transparent. + drawinglayer::tools::Primitive2dXmlDump aDumper; + xmlDocPtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//unifiedtransparence' number of nodes is incorrect + // i.e. the text was just plain red, not semi-transparent. + double fTransparence = getXPath(pDocument, "//unifiedtransparence", "transparence").toDouble(); + CPPUNIT_ASSERT_EQUAL(nTransparence, + static_cast<sal_Int16>(basegfx::fround(fTransparence * 100))); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 1cc2b8a1df37..ff3b839710b2 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -54,6 +54,7 @@ #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> #include <drawinglayer/primitive2d/graphicprimitive2d.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <svx/unoapi.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <editeng/outlobj.hxx> @@ -356,6 +357,14 @@ namespace aTextFillColor); } + if (aFontColor.GetTransparency() != 0) + { + // Handle semi-transparent text for both the decorated and simple case here. + pNewPrimitive = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( + drawinglayer::primitive2d::Primitive2DContainer{ pNewPrimitive }, + aFontColor.GetTransparency() / 255.0); + } + if(rInfo.mbEndOfBullet) { // embed in TextHierarchyBulletPrimitive2D commit adfc373e45dd598d1ad9482c4013ad934339ddf7 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Nov 20 10:18:37 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 8 09:54:27 2020 +0200 drawinglayer: handle more primitives in the xml dump In preparation of writing a test for semi-transparent shape text. Change-Id: I2dac94a6cd9da48de9a5e407ceab78fb8be933d7 Reviewed-on: https://gerrit.libreoffice.org/83264 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit b6d794e14e65697fbf47a5b425d9d264e26e0161) diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index 65170ae096f2..f94896e347f2 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -34,6 +34,7 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> using namespace drawinglayer::primitive2d; @@ -155,7 +156,7 @@ void Primitive2dXmlDump::decomposeAndWrite( if (!pBasePrimitive) continue; sal_uInt32 nId = pBasePrimitive->getPrimitive2DID(); - if (maFilter[nId]) + if (nId < maFilter.size() && maFilter[nId]) continue; OUString sCurrentElementTag = drawinglayer::primitive2d::idToString(nId); @@ -336,6 +337,66 @@ void Primitive2dXmlDump::decomposeAndWrite( break; + case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D: + { + // SdrRectanglePrimitive2D is private to us. + rWriter.startElement("sdrrectangle"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + + case PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D: + { + // SdrBlockTextPrimitive2D is private to us. + rWriter.startElement("sdrblocktext"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + + case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D: + { + // TextHierarchyBlockPrimitive2D. + rWriter.startElement("texthierarchyblock"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + + case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D: + { + // TextHierarchyParagraphPrimitive2D. + rWriter.startElement("texthierarchyparagraph"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + + case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D: + { + // TextHierarchyLinePrimitive2D. + rWriter.startElement("texthierarchyline"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + default: { rWriter.element(OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8)); commit be03be7acd1a6bebb72f08f55cc20aba6d44f391 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Nov 19 11:11:49 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 8 09:38:35 2020 +0200 editeng: add UNO API for semi-transparent text Keep the type internally as sal_uInt8, to be used as an alpha channel. Keep the type externally as sal_Int16, so it's consistent with the fill area transparency. Change-Id: I5138a6b73526f20a40f93df4cff4951e2b11bd6d Reviewed-on: https://gerrit.libreoffice.org/83179 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 6fafae4d109f5768621a11deb394b1b0c4dc5606) diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 313997fa246c..53c1baaa7223 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1449,7 +1449,8 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { case MID_COLOR_ALPHA: { - rVal <<= mColor.GetTransparency(); + auto fTransparency = static_cast<double>(mColor.GetTransparency()) * 100 / 255; + rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency)); break; } default: @@ -1472,7 +1473,8 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) bool bRet = rVal >>= nTransparency; if (bRet) { - mColor.SetTransparency(nTransparency); + auto fTransparency = static_cast<double>(nTransparency) * 255 / 100; + mColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency))); } return bRet; } diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index ca3b977afeee..c9952340519d 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -320,6 +320,7 @@ #define UNO_NAME_EDIT_CHAR_LOCALE_COMPLEX "CharLocaleComplex" #define UNO_NAME_EDIT_CHAR_COLOR "CharColor" +#define UNO_NAME_EDIT_CHAR_TRANSPARENCE "CharTransparence" #define UNO_NAME_EDIT_CHAR_CROSSEDOUT "CharCrossedOut" #define UNO_NAME_EDIT_CHAR_STRIKEOUT "CharStrikeout" #define UNO_NAME_EDIT_CHAR_CASEMAP "CharCaseMap" diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index aaf9cd18328f..05587600109b 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -87,6 +87,7 @@ struct SfxItemPropertySimpleEntry; { OUString(UNO_NAME_EDIT_CHAR_WEIGHT), EE_CHAR_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT }, \ { OUString(UNO_NAME_EDIT_CHAR_LOCALE), EE_CHAR_LANGUAGE, ::cppu::UnoType<css::lang::Locale>::get(),0, MID_LANG_LOCALE }, \ { OUString(UNO_NAME_EDIT_CHAR_COLOR), EE_CHAR_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, \ + { OUString(UNO_NAME_EDIT_CHAR_TRANSPARENCE),EE_CHAR_COLOR, ::cppu::UnoType<sal_Int16>::get(), 0, MID_COLOR_ALPHA }, \ { OUString("CharBackColor"), EE_CHAR_BKGCOLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, \ { OUString("CharBackTransparent"), EE_CHAR_BKGCOLOR, ::cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT }, \ { OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_ESC }, \ diff --git a/offapi/com/sun/star/style/CharacterProperties.idl b/offapi/com/sun/star/style/CharacterProperties.idl index 010dab9acb53..f213bf0c4f12 100644 --- a/offapi/com/sun/star/style/CharacterProperties.idl +++ b/offapi/com/sun/star/style/CharacterProperties.idl @@ -460,6 +460,14 @@ published service CharacterProperties */ [optional, property] short RubyPosition; + /** This is the transparency of the character text. + + @since LibreOffice 6.5 + + <p>The value 100 means entirely transparent, while 0 means not transparent at all.</p> + */ + [optional, property] short CharTransparence; + }; }; }; }; }; commit 570e650093928a795704777667e927bb12d4a567 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Nov 18 18:40:13 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 8 09:35:17 2020 +0200 editeng: add doc model for semi-transparent text tools Color can handle the alpha just fine, but add a separate member ID for transparency to be consistent with the existing border and fill color API. Change-Id: I8466da9fb40ab1d0c97b06a0594f89719ccc1959 Reviewed-on: https://gerrit.libreoffice.org/83116 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 543a0658f961f24db6804b90c5389aee15ba2ce4) diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index afd053da51e7..313997fa246c 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1442,15 +1442,45 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const return mColor == static_cast<const SvxColorItem&>( rAttr ).mColor; } -bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const +bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { - rVal <<= mColor; + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_COLOR_ALPHA: + { + rVal <<= mColor.GetTransparency(); + break; + } + default: + { + rVal <<= mColor; + break; + } + } return true; } -bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) +bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { - return (rVal >>= mColor); + nMemberId &= ~CONVERT_TWIPS; + switch(nMemberId) + { + case MID_COLOR_ALPHA: + { + sal_Int16 nTransparency = 0; + bool bRet = rVal >>= nTransparency; + if (bRet) + { + mColor.SetTransparency(nTransparency); + } + return bRet; + } + default: + { + return rVal >>= mColor; + } + } } SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index 5af872b705b3..bec53ca51002 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -176,6 +176,10 @@ // SvxShadowItem #define MID_SHADOW_TRANSPARENCE 1 +// SvxColorItem +#define MID_COLOR_RGB 0 +#define MID_COLOR_ALPHA 1 + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits