[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - 4 commits - cui/qa cui/source cui/uiconfig include/svx oox/CppunitTest_oox_drawingml.mk oox/Module_oox.mk oox/qa oox/source sd/qa sd/source svx/source xmloff/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 25 13:19:40 UTC 2019
cui/qa/uitest/dialogs/chardlg.py | 49 +++++++++++
cui/source/inc/chardlg.hxx | 3
cui/source/tabpages/chardlg.cxx | 40 ++++++++-
cui/uiconfig/ui/effectspage.ui | 57 ++++++++++++-
include/svx/flagsdef.hxx | 1
oox/CppunitTest_oox_drawingml.mk | 45 ++++++++++
oox/Module_oox.mk | 1
oox/qa/unit/data/transparent-text.pptx |binary
oox/qa/unit/drawingml.cxx | 100 +++++++++++++++++++++++
oox/source/drawingml/textcharacterproperties.cxx | 10 ++
oox/source/export/drawingml.cxx | 12 ++
oox/source/token/properties.txt | 1
sd/qa/unit/data/transparent-text.fodg | 64 ++++++++++++++
sd/qa/unit/export-tests.cxx | 22 +++++
sd/source/ui/dlg/dlgchar.cxx | 2
svx/source/svdraw/svdotextdecomposition.cxx | 10 ++
xmloff/source/text/txtprmap.cxx | 4
17 files changed, 417 insertions(+), 4 deletions(-)
New commits:
commit 6dbb317ebec681d236c6ce354f581108fd814f7b
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Nov 22 17:12:04 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Nov 25 12:38:47 2019 +0100
cui: add UI for semi-transparent shape text
- Make font color only work with the RGB color, otherwise the preview
would be white for e.g. half-transparent red.
- Add label and widget to see already set transparency.
- Add a flag to show these only for Draw/Impress and leave Writer/Calc
unchanged.
- Update returned item set to contain transparency in case the widget
changes.
Conflicts:
cui/source/inc/chardlg.hxx
cui/source/tabpages/chardlg.cxx
cui/uiconfig/ui/effectspage.ui
Change-Id: If77771076ff4b10a4a5d468a6583809a94deb57e
diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py
new file mode 100644
index 000000000000..59cf10d18c29
--- /dev/null
+++ b/cui/qa/uitest/dialogs/chardlg.py
@@ -0,0 +1,49 @@
+#
+# 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/.
+#
+
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import select_pos
+
+# Test for cui/source/tabpages/chardlg.cxx.
+class Test(UITestCase):
+
+ def testSvxCharEffectsPage(self):
+ # Start Impress.
+ self.ui_test.create_doc_in_start_center("impress")
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("cancel"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+
+ # Now use Format -> Character.
+ self.ui_test.execute_dialog_through_command(".uno:FontDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontTransparency = xDialog.getChild("fonttransparencymtr")
+ for _ in range(5):
+ xFontTransparency.executeAction("UP", tuple())
+ self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))
+
+ # Verify the result.
+ component = self.ui_test.get_component()
+ drawPage = component.getDrawPages().getByIndex(0)
+ shape = drawPage.getByIndex(0)
+
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 100 != 5
+ # i.e. the dialog did not set transparency to 5%, instead it left the character color at
+ # COL_AUTO.
+ self.assertEqual(shape.CharTransparence, 5)
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index 1b99b60cc5ff..d7d98e89c39e 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -179,6 +179,8 @@ private:
Color m_aOrigFontColor;
VclPtr<FixedText> m_pFontColorFT;
VclPtr<SvxColorListBox> m_pFontColorLB;
+ VclPtr<FixedText> m_pFontTransparencyFT;
+ VclPtr<MetricField> m_pFontTransparencyMtr;
VclPtr<FixedText> m_pEffectsFT;
VclPtr<ListBox> m_pEffectsLB;
@@ -229,6 +231,7 @@ private:
DECL_LINK(TristClickHdl_Impl, Button*, void);
DECL_LINK(UpdatePreview_Impl, ListBox&, void);
DECL_LINK(ColorBoxSelectHdl_Impl, SvxColorListBox&, void);
+ DECL_LINK(ModifyFontTransparencyHdl_Impl, Edit&, void);
public:
virtual ~SvxCharEffectsPage() override;
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 667e09955298..22fa9004269d 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1340,6 +1340,8 @@ SvxCharEffectsPage::SvxCharEffectsPage( vcl::Window* pParent, const SfxItemSet&
{
get(m_pFontColorFT, "fontcolorft");
get(m_pFontColorLB, "fontcolorlb");
+ get(m_pFontTransparencyFT, "fonttransparencyft");
+ get(m_pFontTransparencyMtr, "fonttransparencymtr");
m_pFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
get(m_pEffectsFT, "effectsft");
get(m_pEffectsLB, "effectslb");
@@ -1393,6 +1395,8 @@ void SvxCharEffectsPage::dispose()
{
m_pFontColorFT.clear();
m_pFontColorLB.clear();
+ m_pFontTransparencyFT.clear();
+ m_pFontTransparencyMtr.clear();
m_pEffectsFT.clear();
m_pEffectsLB.clear();
m_pReliefFT.clear();
@@ -1438,6 +1442,8 @@ void SvxCharEffectsPage::Initialize()
}
m_pFontColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
+ m_pFontTransparencyMtr->SetModifyHdl(
+ LINK(this, SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl));
// handler
Link<ListBox&,void> aLink = LINK( this, SvxCharEffectsPage, SelectListBoxHdl_Impl );
@@ -1609,7 +1615,19 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
m_pPreviewWin->Invalidate();
- m_pFontColorLB->SelectEntry(aColor);
+ Color aRGBColor = aColor;
+ if (aRGBColor.GetTransparency())
+ {
+ aRGBColor.SetTransparency(0);
+ }
+ m_pFontColorLB->SelectEntry(aRGBColor);
+
+ if (m_pFontTransparencyMtr->IsVisible() && aColor != COL_AUTO)
+ {
+ double fTransparency = aColor.GetTransparency() * 100.0 / 255;
+ m_pFontTransparencyMtr->SetValue(basegfx::fround(fTransparency),
+ FUNIT_PERCENT);
+ }
m_aOrigFontColor = aColor;
m_bOrigFontColor = true;
@@ -1630,6 +1648,14 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
if (bChanged)
{
aSelectedColor = m_pFontColorLB->GetSelectEntryColor();
+
+ if (m_pFontTransparencyMtr->IsValueChangedFromSaved())
+ {
+ double fTransparency
+ = m_pFontTransparencyMtr->GetValue() * 255.0 / 100;
+ aSelectedColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
+ }
+
if (m_bOrigFontColor)
bChanged = aSelectedColor != m_aOrigFontColor;
if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR)
@@ -1711,6 +1737,11 @@ IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, SvxColorListBox&, rBox, vo
UpdatePreview_Impl();
}
+IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, Edit&, void)
+{
+ m_bNewFontColor = true;
+}
+
DeactivateRC SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet )
{
if ( _pSet )
@@ -2142,6 +2173,7 @@ void SvxCharEffectsPage::ChangesApplied()
m_pShadowBtn->SaveValue();
m_pBlinkingBtn->SaveValue();
m_pHiddenBtn->SaveValue();
+ m_pFontTransparencyMtr->SaveValue();
}
bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet )
@@ -2504,6 +2536,12 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet)
if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
// the writer uses SID_ATTR_BRUSH as font background
m_bPreviewBackgroundToCharacter = true;
+ if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY)
+ {
+ // Only show these in case client code explicitly wants this.
+ m_pFontTransparencyFT->Hide();
+ m_pFontTransparencyMtr->Hide();
+ }
}
}
diff --git a/cui/uiconfig/ui/effectspage.ui b/cui/uiconfig/ui/effectspage.ui
index bf80526b73e2..4824e4b5d2bc 100644
--- a/cui/uiconfig/ui/effectspage.ui
+++ b/cui/uiconfig/ui/effectspage.ui
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkAdjustment" id="adjustmentPercent">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
@@ -574,6 +579,56 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="fonttransparencyft">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Transparency:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">fonttransparencymtr</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">11</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="fonttransparencymtr:0%">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustmentPercent</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">12</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
diff --git a/include/svx/flagsdef.hxx b/include/svx/flagsdef.hxx
index 30b1ff401203..5c3f6947f3f2 100644
--- a/include/svx/flagsdef.hxx
+++ b/include/svx/flagsdef.hxx
@@ -67,6 +67,7 @@ namespace o3tl
#define SVX_RELATIVE_MODE 0x02
// flags for SvxCharEffectsPage
#define SVX_ENABLE_FLASH 0x04
+#define SVX_ENABLE_CHAR_TRANSPARENCY 0x08
// Default values for Number Format Category List and Preview
diff --git a/sd/source/ui/dlg/dlgchar.cxx b/sd/source/ui/dlg/dlgchar.cxx
index cb37af495eac..1d1ac701876a 100644
--- a/sd/source/ui/dlg/dlgchar.cxx
+++ b/sd/source/ui/dlg/dlgchar.cxx
@@ -61,6 +61,8 @@ void SdCharDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
}
else if (nId == mnCharEffects)
{
+ // Opt in for character transparency.
+ aSet.Put(SfxUInt32Item(SID_FLAG_TYPE, SVX_ENABLE_CHAR_TRANSPARENCY));
rPage.PageCreated(aSet);
}
else if (nId == mnCharBackground)
commit d71233b72327ee813f75dbd380f184130aeaa5a3
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Nov 21 17:53:35 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Nov 25 12:05:43 2019 +0100
oox: add PPTX import/export for semi-transparent shape text
And start a drawingml test suite in oox, so the test and the tested code
is close to each other (just like how it's done in chart2/ already).
(cherry picked from commit 1e64d9ebaa231caef5fb062009b8f76465e415f4)
Conflicts:
oox/Module_oox.mk
Change-Id: I9a2810691f12604d240e4394e6a5ff4e7f52f1c1
diff --git a/oox/CppunitTest_oox_drawingml.mk b/oox/CppunitTest_oox_drawingml.mk
new file mode 100644
index 000000000000..dd0288074e32
--- /dev/null
+++ b/oox/CppunitTest_oox_drawingml.mk
@@ -0,0 +1,45 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,oox_drawingml))
+
+$(eval $(call gb_CppunitTest_use_externals,oox_drawingml,\
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,oox_drawingml, \
+ oox/qa/unit/drawingml \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,oox_drawingml, \
+ comphelper \
+ cppu \
+ oox \
+ sal \
+ test \
+ unotest \
+ utl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,oox_drawingml))
+
+$(eval $(call gb_CppunitTest_use_ure,oox_drawingml))
+$(eval $(call gb_CppunitTest_use_vcl,oox_drawingml))
+
+$(eval $(call gb_CppunitTest_use_rdb,oox_drawingml,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,oox_drawingml,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,oox_drawingml))
+
+# vim: set noet sw=4 ts=4:
diff --git a/oox/Module_oox.mk b/oox/Module_oox.mk
index 4d7a79e3d60c..3ec5edafa5be 100644
--- a/oox/Module_oox.mk
+++ b/oox/Module_oox.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_Module_add_check_targets,oox,\
CppunitTest_oox_tokenmap \
CppunitTest_oox_vba_compression \
CppunitTest_oox_vba_encryption \
+ CppunitTest_oox_drawingml \
))
# vim: set noet sw=4 ts=4:
diff --git a/oox/qa/unit/data/transparent-text.pptx b/oox/qa/unit/data/transparent-text.pptx
new file mode 100644
index 000000000000..b7b3ede4dc3d
Binary files /dev/null and b/oox/qa/unit/data/transparent-text.pptx differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
new file mode 100644
index 000000000000..e3c455c04867
--- /dev/null
+++ b/oox/qa/unit/drawingml.cxx
@@ -0,0 +1,100 @@
+/* -*- 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 <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/tempfile.hxx>
+
+using namespace ::com::sun::star;
+
+/// oox drawingml tests.
+class OoxDrawingmlTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+ uno::Reference<uno::XComponentContext> mxComponentContext;
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ void setUp() override;
+ void tearDown() override;
+ uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ void loadAndReload(const OUString& rURL, const OUString& rFilterName);
+};
+
+void OoxDrawingmlTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void OoxDrawingmlTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void OoxDrawingmlTest::loadAndReload(const OUString& rURL, const OUString& rFilterName)
+{
+ mxComponent = loadFromDesktop(rURL);
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= rFilterName;
+ utl::TempFile aTempFile;
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ mxComponent->dispose();
+ validate(aTempFile.GetFileName(), test::OOXML);
+ mxComponent = loadFromDesktop(aTempFile.GetURL());
+}
+
+char const DATA_DIRECTORY[] = "/oox/qa/unit/data/";
+
+CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTransparentText)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "transparent-text.pptx";
+ loadAndReload(aURL, "Impress Office Open XML");
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParagraph(
+ xShape->createEnumeration()->nextElement(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPortion(xParagraph->createEnumeration()->nextElement(),
+ uno::UNO_QUERY);
+
+ sal_Int16 nTransparency = 0;
+ xPortion->getPropertyValue("CharTransparence") >>= nTransparency;
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 75
+ // - Actual : 0
+ // i.e. the transparency of the character color was lost on import/export.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(75), nTransparency);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
index 71046841c60c..8ad46ab327a4 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -104,7 +104,15 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil
}
if ( maFillProperties.moFillType.has() )
- rPropMap.setProperty( PROP_CharColor, maFillProperties.getBestSolidColor().getColor( rFilter.getGraphicHelper() ));
+ {
+ Color aColor = maFillProperties.getBestSolidColor();
+ rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper()));
+
+ if (aColor.hasTransparency())
+ {
+ rPropMap.setProperty(PROP_CharTransparence, aColor.getTransparency());
+ }
+ }
if( moLang.has() && !moLang.get().isEmpty() )
{
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index fef1316517b4..baa22718483a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1428,13 +1428,23 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
sal_uInt32 color = *o3tl::doAccess<sal_uInt32>(mAny);
SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO);
+ // WriteSolidFill() handles MAX_PERCENT as "no transparency".
+ sal_Int32 nTransparency = MAX_PERCENT;
+ if (rXPropSet->getPropertySetInfo()->hasPropertyByName("CharTransparence"))
+ {
+ rXPropSet->getPropertyValue("CharTransparence") >>= nTransparency;
+ // UNO scale is 0..100, OOXML scale is 0..100000; also UNO tracks transparency, OOXML
+ // tracks opacity.
+ nTransparency = MAX_PERCENT - (nTransparency * PER_PERCENT);
+ }
+
// tdf#104219 In LibreOffice and MS Office, there are two types of colors:
// Automatic and Fixed. OOXML is setting automatic color, by not providing color.
if( color != COL_AUTO )
{
color &= 0xffffff;
// TODO: special handle embossed/engraved
- WriteSolidFill( color );
+ WriteSolidFill(color, nTransparency);
}
}
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 52909147b9e1..bc8427500a2d 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -81,6 +81,7 @@ CharPostureComplex
CharShadowed
CharStrikeout
CharStyleName
+CharTransparence
CharUnderline
CharUnderlineColor
CharUnderlineHasColor
commit f82adbe3f613766a4f86ce31fc724f3243f39a97
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Nov 21 11:50:54 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Nov 25 11:54:54 2019 +0100
xmloff: add ODF import/export for semi-transparent shape text
Test this from sd, so that SdModelTestBase::saveAndReload() calls
BootstrapFixture::validate() for us.
(cherry picked from commit 4dbb33a1c21948bebcf890c2f8ceb56b15a87936)
Conflicts:
schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
sd/qa/unit/export-tests.cxx
Change-Id: I6c90a3a71a5603604e69f9b45137bc8e4388dc0f
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 10590131e939..075caa6d7540 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -94,6 +94,7 @@ public:
void testTransparentBackground();
void testEmbeddedPdf();
void testEmbeddedText();
+ void testTransparenText();
void testAuthorField();
void testTdf100926();
void testPageWithTransparentBackground();
@@ -114,6 +115,7 @@ public:
CPPUNIT_TEST(testTransparentBackground);
CPPUNIT_TEST(testEmbeddedPdf);
CPPUNIT_TEST(testEmbeddedText);
+ CPPUNIT_TEST(testTransparenText);
CPPUNIT_TEST(testAuthorField);
CPPUNIT_TEST(testTdf100926);
CPPUNIT_TEST(testPageWithTransparentBackground);
@@ -693,6 +695,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::testAuthorField()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/author_fixed.odp"), ODP);
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 9b42098a5698..484ccb8b0313 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -131,6 +131,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
@@ -473,6 +475,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 821424a48bb7e40d6cd75abe8f5cbf8a58e0ed8c
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 20 16:15:39 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Nov 25 11:45:58 2019 +0100
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.
(cherry picked from commit 81b0d5393ca4cf2ff0954e53b05928cde047c2e0)
Conflicts:
svx/CppunitTest_svx_unit.mk
svx/source/svdraw/svdotextdecomposition.cxx
Change-Id: Ie7aebe77ad9ac776dd27fc50538a5045200c8010
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index a05a428b6798..f8c312c133eb 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -49,6 +49,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>
@@ -380,6 +381,15 @@ 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
More information about the Libreoffice-commits
mailing list