2020-08-12 09:06:14 +02:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2022-11-03 11:42:17 +01:00
|
|
|
#include <test/unoapixml_test.hxx>
|
2020-08-12 09:06:14 +02:00
|
|
|
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
|
2022-01-13 13:26:25 +01:00
|
|
|
#include <com/sun/star/drawing/EnhancedCustomShapeMetalType.hpp>
|
2022-05-03 00:18:00 +02:00
|
|
|
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
|
|
|
|
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
|
2021-12-07 08:32:30 +01:00
|
|
|
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
|
|
|
|
#include <com/sun/star/drawing/XMasterPageTarget.hpp>
|
2021-12-14 13:51:14 +01:00
|
|
|
#include <com/sun/star/text/XTextRange.hpp>
|
|
|
|
#include <com/sun/star/text/XTextTable.hpp>
|
2022-08-29 09:23:22 +02:00
|
|
|
#include <com/sun/star/text/GraphicCrop.hpp>
|
2020-08-12 09:06:14 +02:00
|
|
|
|
2022-06-15 13:15:15 +02:00
|
|
|
#include <comphelper/propertyvalue.hxx>
|
|
|
|
#include <comphelper/sequence.hxx>
|
2022-11-23 20:22:00 +01:00
|
|
|
#include <comphelper/sequenceashashmap.hxx>
|
2020-08-12 09:06:14 +02:00
|
|
|
#include <unotools/tempfile.hxx>
|
2022-01-13 13:26:25 +01:00
|
|
|
#include <unotools/saveopt.hxx>
|
2022-08-29 09:23:22 +02:00
|
|
|
#include <svx/unopage.hxx>
|
|
|
|
#include <svx/svdpage.hxx>
|
|
|
|
#include <svx/svdomedia.hxx>
|
2023-05-08 14:09:00 +09:00
|
|
|
#include <docmodel/uno/UnoComplexColor.hxx>
|
2023-01-27 15:03:09 +09:00
|
|
|
#include <docmodel/uno/UnoTheme.hxx>
|
2023-02-25 19:12:23 +09:00
|
|
|
#include <docmodel/theme/Theme.hxx>
|
2020-08-12 09:06:14 +02:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
/// Covers xmloff/source/draw/ fixes.
|
2022-11-03 11:42:17 +01:00
|
|
|
class XmloffDrawTest : public UnoApiXmlTest
|
2020-08-12 09:06:14 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-10-24 16:56:28 +02:00
|
|
|
XmloffDrawTest();
|
2022-01-13 13:26:25 +01:00
|
|
|
uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex);
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
uno::Reference<beans::XPropertySet>
|
|
|
|
getShapeTextPortion(sal_uInt32 nIndex, uno::Reference<drawing::XShape> const& xShape)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xPortion;
|
|
|
|
|
|
|
|
uno::Reference<container::XEnumerationAccess> xEnumAccess(xShape, uno::UNO_QUERY);
|
|
|
|
if (!xEnumAccess->hasElements())
|
|
|
|
return xPortion;
|
|
|
|
uno::Reference<container::XEnumeration> xEnum(xEnumAccess->createEnumeration());
|
|
|
|
uno::Reference<text::XTextContent> xTextContent;
|
|
|
|
xEnum->nextElement() >>= xTextContent;
|
|
|
|
if (!xTextContent.is())
|
|
|
|
return xPortion;
|
|
|
|
|
|
|
|
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextContent, uno::UNO_QUERY);
|
|
|
|
uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
|
|
|
|
sal_uInt32 nCurrent = 0;
|
|
|
|
xPortion = uno::Reference<beans::XPropertySet>(xParaEnum->nextElement(), uno::UNO_QUERY);
|
|
|
|
while (nIndex != nCurrent)
|
|
|
|
{
|
|
|
|
++nCurrent;
|
|
|
|
xPortion
|
|
|
|
= uno::Reference<beans::XPropertySet>(xParaEnum->nextElement(), uno::UNO_QUERY);
|
|
|
|
}
|
|
|
|
return xPortion;
|
|
|
|
}
|
2020-08-12 09:06:14 +02:00
|
|
|
};
|
|
|
|
|
2022-10-24 16:56:28 +02:00
|
|
|
XmloffDrawTest::XmloffDrawTest()
|
2022-11-03 11:42:17 +01:00
|
|
|
: UnoApiXmlTest("/xmloff/qa/unit/data/")
|
2020-08-12 09:06:14 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-13 13:26:25 +01:00
|
|
|
uno::Reference<drawing::XShape> XmloffDrawTest::getShape(sal_uInt8 nShapeIndex)
|
|
|
|
{
|
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
|
|
|
|
uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
|
|
|
|
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(nShapeIndex),
|
|
|
|
uno::UNO_QUERY_THROW);
|
|
|
|
return xShape;
|
|
|
|
}
|
|
|
|
|
2020-08-12 09:06:14 +02:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss)
|
|
|
|
{
|
|
|
|
// Load a document that has a shape with a textbox in it. Save it to ODF and reload.
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"textbox-loss.docx");
|
2022-10-25 10:18:11 +02:00
|
|
|
saveAndReload("impress8");
|
2020-08-12 09:06:14 +02:00
|
|
|
|
|
|
|
// Make sure that the shape is still a textbox.
|
2022-10-24 16:56:28 +02:00
|
|
|
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
|
2020-08-12 09:06:14 +02:00
|
|
|
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
|
2022-03-02 14:08:14 +01:00
|
|
|
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
|
2020-08-12 09:06:14 +02:00
|
|
|
bool bTextBox = false;
|
|
|
|
xShape->getPropertyValue("TextBox") >>= bTextBox;
|
|
|
|
|
|
|
|
// Without the accompanying fix in place, this test would have failed, as the shape only had
|
2020-08-13 12:45:40 +02:00
|
|
|
// editeng text, losing the image part of the shape text.
|
2020-08-12 09:06:14 +02:00
|
|
|
CPPUNIT_ASSERT(bTextBox);
|
|
|
|
}
|
|
|
|
|
2021-03-28 18:21:04 +02:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle)
|
|
|
|
{
|
|
|
|
// Load a document that has a custom shape with extrusion direction as set by LO as its default.
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf141301_Extrusion_Skew.odg");
|
2021-03-28 18:21:04 +02:00
|
|
|
|
|
|
|
// Prepare use of XPath
|
2022-11-04 17:31:55 +01:00
|
|
|
save("draw8");
|
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2021-03-28 18:21:04 +02:00
|
|
|
|
|
|
|
// Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not
|
|
|
|
// default in ODF, but only default inside LO.
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-skew"_ostr, "50 -135");
|
2021-03-28 18:21:04 +02:00
|
|
|
}
|
|
|
|
|
2021-12-07 08:32:30 +01:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport)
|
|
|
|
{
|
|
|
|
// Create an Impress document which has a master page which has a theme associated with it.
|
2022-10-24 16:56:28 +02:00
|
|
|
mxComponent = loadFromDesktop("private:factory/simpress");
|
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
|
2021-12-07 08:32:30 +01:00
|
|
|
uno::Reference<drawing::XMasterPageTarget> xDrawPage(
|
|
|
|
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
|
|
|
uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
|
2023-01-27 15:03:09 +09:00
|
|
|
|
2023-02-25 19:12:23 +09:00
|
|
|
auto pTheme = std::make_shared<model::Theme>("mytheme");
|
2023-05-03 22:58:47 +09:00
|
|
|
auto pColorSet = std::make_shared<model::ColorSet>("mycolorscheme");
|
2023-01-27 15:03:09 +09:00
|
|
|
pColorSet->add(model::ThemeColorType::Dark1, 0x0);
|
|
|
|
pColorSet->add(model::ThemeColorType::Light1, 0x1);
|
|
|
|
pColorSet->add(model::ThemeColorType::Dark2, 0x2);
|
|
|
|
pColorSet->add(model::ThemeColorType::Light2, 0x3);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent1, 0x4);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent2, 0x5);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent3, 0x6);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent4, 0x7);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent5, 0x8);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent6, 0x9);
|
|
|
|
pColorSet->add(model::ThemeColorType::Hyperlink, 0xa);
|
|
|
|
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb);
|
2023-05-03 22:58:47 +09:00
|
|
|
pTheme->setColorSet(pColorSet);
|
2023-01-27 15:03:09 +09:00
|
|
|
|
2023-02-25 19:12:23 +09:00
|
|
|
uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme);
|
2023-01-27 15:03:09 +09:00
|
|
|
xMasterPage->setPropertyValue("Theme", uno::Any(xTheme));
|
2021-12-07 08:32:30 +01:00
|
|
|
|
|
|
|
// Export to ODP:
|
2022-11-04 17:31:55 +01:00
|
|
|
save("impress8");
|
2021-12-07 08:32:30 +01:00
|
|
|
|
|
|
|
// Check if the 12 colors are written in the XML:
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
|
2021-12-07 08:32:30 +01:00
|
|
|
// Without the accompanying fix in place, this test would have failed with:
|
|
|
|
// - Expected: 12
|
|
|
|
// - Actual : 0
|
|
|
|
// - XPath '//style:master-page/loext:theme/loext:color-table/loext:color' number of nodes is incorrect
|
|
|
|
// i.e. the theme was lost on exporting to ODF.
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//style:master-page/loext:theme/loext:theme-colors/loext:color"_ostr, 12);
|
2021-12-07 08:32:30 +01:00
|
|
|
}
|
|
|
|
|
2022-08-29 09:23:22 +02:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot)
|
|
|
|
{
|
|
|
|
// Execute ODP import:
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"video-snapshot.odp");
|
2022-10-24 16:56:28 +02:00
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
|
2022-08-29 09:23:22 +02:00
|
|
|
uno::UNO_QUERY_THROW);
|
|
|
|
CPPUNIT_ASSERT(xDrawPagesSupplier.is());
|
|
|
|
uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
|
|
|
|
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
|
|
|
|
CPPUNIT_ASSERT(xDrawPage.is());
|
|
|
|
auto pUnoPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get());
|
|
|
|
SdrPage* pSdrPage = pUnoPage->GetSdrPage();
|
|
|
|
auto pMedia = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0));
|
|
|
|
|
|
|
|
// Check that the preview was imported:
|
|
|
|
const avmedia::MediaItem& rItem = pMedia->getMediaProperties();
|
|
|
|
const Graphic& rGraphic = rItem.getGraphic();
|
|
|
|
CPPUNIT_ASSERT(!rGraphic.IsNone());
|
|
|
|
|
|
|
|
// Check that the crop was imported:
|
|
|
|
const text::GraphicCrop& rCrop = rItem.getCrop();
|
|
|
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rCrop.Top);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rCrop.Bottom);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Left);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Right);
|
|
|
|
|
|
|
|
// Execute ODP export:
|
2022-11-04 17:31:55 +01:00
|
|
|
save("impress8");
|
2022-08-29 09:23:22 +02:00
|
|
|
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2022-08-29 09:23:22 +02:00
|
|
|
// Check that the preview was exported:
|
|
|
|
// Without the accompanying fix in place, this test would have failed with:
|
|
|
|
// - Expected: 1
|
|
|
|
// - Actual : 0
|
|
|
|
// - XPath '//draw:frame[@draw:style-name='gr1']/draw:image' number of nodes is incorrect
|
|
|
|
// i.e. the preview wasn't exported to ODP.
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//draw:frame[@draw:style-name='gr1']/draw:image"_ostr, "href"_ostr,
|
2022-08-29 09:23:22 +02:00
|
|
|
"Pictures/MediaPreview1.png");
|
|
|
|
// Check that the crop was exported:
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//style:style[@style:name='gr1']/style:graphic-properties"_ostr,
|
|
|
|
"clip"_ostr, "rect(0cm, 1.356cm, 0cm, 1.356cm)");
|
2022-08-29 09:23:22 +02:00
|
|
|
}
|
|
|
|
|
2021-12-08 08:42:18 +01:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport)
|
|
|
|
{
|
|
|
|
// Given a document that has a master page with a theme associated:
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"theme.fodp");
|
2021-12-08 08:42:18 +01:00
|
|
|
|
|
|
|
// Then make sure the doc model has a master page with a theme:
|
2022-10-24 16:56:28 +02:00
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
|
2021-12-08 08:42:18 +01:00
|
|
|
uno::Reference<drawing::XMasterPageTarget> xDrawPage(
|
|
|
|
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
|
|
|
uno::Reference<beans::XPropertySet> xMasterpage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
|
2023-01-27 15:03:09 +09:00
|
|
|
|
|
|
|
uno::Reference<util::XTheme> xTheme;
|
|
|
|
xMasterpage->getPropertyValue("Theme") >>= xTheme;
|
|
|
|
|
|
|
|
// We expect the theme to be set on the master page
|
|
|
|
CPPUNIT_ASSERT(xTheme.is());
|
|
|
|
auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
|
|
|
|
CPPUNIT_ASSERT(pUnoTheme);
|
2023-02-25 19:12:23 +09:00
|
|
|
auto pTheme = pUnoTheme->getTheme();
|
|
|
|
CPPUNIT_ASSERT(pTheme);
|
2023-01-27 15:03:09 +09:00
|
|
|
|
2023-02-25 19:12:23 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), pTheme->GetName());
|
2023-05-25 13:15:41 +09:00
|
|
|
auto pColorSet = pTheme->getColorSet();
|
|
|
|
CPPUNIT_ASSERT(pColorSet);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(OUString("Office"), pColorSet->getName());
|
2023-01-27 15:03:09 +09:00
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(Color(0x954F72),
|
2023-05-25 13:15:41 +09:00
|
|
|
pColorSet->getColor(model::ThemeColorType::FollowedHyperlink));
|
2021-12-08 08:42:18 +01:00
|
|
|
}
|
|
|
|
|
2023-08-14 22:52:20 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void checkFillAndLineComplexColors(uno::Reference<drawing::XShape> const& xShape)
|
|
|
|
{
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
|
|
|
{
|
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans1.mnValue);
|
|
|
|
auto const& rTrans2 = aComplexColor.getTransformations()[1];
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("LineComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
|
|
|
|
auto const& rTrans2 = aComplexColor.getTransformations()[1];
|
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end anonymous ns
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testFillAndLineThemeColorExportImport)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"FillAndStrokeThemeColorTest.fodp");
|
2023-08-14 22:52:20 +02:00
|
|
|
|
|
|
|
checkFillAndLineComplexColors(getShape(0));
|
|
|
|
|
|
|
|
save("impress8");
|
|
|
|
|
|
|
|
load(maTempFile.GetURL());
|
|
|
|
|
|
|
|
checkFillAndLineComplexColors(getShape(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport)
|
2021-12-09 08:43:27 +01:00
|
|
|
{
|
|
|
|
// Given a document that refers to a theme color:
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"Reference-ThemeColors-TextAndFill.pptx");
|
2022-11-04 17:31:55 +01:00
|
|
|
save("impress8");
|
2021-12-09 08:43:27 +01:00
|
|
|
|
|
|
|
// Make sure the export result has the theme reference:
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2022-03-17 20:37:39 +01:00
|
|
|
|
2022-12-31 20:59:03 +09:00
|
|
|
// Text color
|
|
|
|
OString aStyle1(
|
2023-11-19 13:21:42 +01:00
|
|
|
"//style:style[@style:name='T2']/style:text-properties/loext:char-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "theme-type"_ostr, "accent3");
|
|
|
|
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "value"_ostr, "2000");
|
|
|
|
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "type"_ostr, "lumoff");
|
|
|
|
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "value"_ostr, "8000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
OString aStyle2(
|
2023-11-19 13:21:42 +01:00
|
|
|
"//style:style[@style:name='T3']/style:text-properties/loext:char-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aStyle2, "theme-type"_ostr, "accent3");
|
|
|
|
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "value"_ostr, "6000");
|
|
|
|
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "type"_ostr, "lumoff");
|
|
|
|
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "value"_ostr, "4000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
OString aStyle3(
|
2023-11-19 13:21:42 +01:00
|
|
|
"//style:style[@style:name='T4']/style:text-properties/loext:char-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aStyle3, "theme-type"_ostr, "accent3");
|
|
|
|
assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "value"_ostr, "5000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
// Shapes fill color
|
|
|
|
OString aShape1("//style:style[@style:name='gr1']/style:graphic-properties/"
|
2023-11-19 13:21:42 +01:00
|
|
|
"loext:fill-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aShape1, "theme-type"_ostr, "accent2");
|
|
|
|
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "value"_ostr, "2000");
|
|
|
|
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "type"_ostr, "lumoff");
|
|
|
|
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "value"_ostr, "8000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
OString aShape2("//style:style[@style:name='gr2']/style:graphic-properties/"
|
2023-11-19 13:21:42 +01:00
|
|
|
"loext:fill-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aShape2, "theme-type"_ostr, "accent2");
|
|
|
|
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "value"_ostr, "6000");
|
|
|
|
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "type"_ostr, "lumoff");
|
|
|
|
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "value"_ostr, "4000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
OString aShape3("//style:style[@style:name='gr3']/style:graphic-properties/"
|
2023-11-19 13:21:42 +01:00
|
|
|
"loext:fill-complex-color"_ostr);
|
|
|
|
assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme");
|
|
|
|
assertXPath(pXmlDoc, aShape3, "theme-type"_ostr, "accent2");
|
|
|
|
assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "type"_ostr, "lummod");
|
|
|
|
assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "value"_ostr, "5000");
|
2022-12-31 20:59:03 +09:00
|
|
|
|
|
|
|
// reload
|
|
|
|
load(maTempFile.GetURL());
|
|
|
|
|
|
|
|
// check fill color theme
|
|
|
|
{
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(0));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTrans2 = aComplexColor.getTransformations()[1];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(1));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTrans2 = aComplexColor.getTransformations()[1];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(2));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Char color theme
|
|
|
|
// Shape 4
|
|
|
|
{
|
|
|
|
// Check the first text portion properties
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(3));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
|
|
|
CPPUNIT_ASSERT(xPortion.is());
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTransforms = aComplexColor.getTransformations();
|
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), rTransforms.size());
|
|
|
|
auto const& rTrans1 = rTransforms[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTrans2 = rTransforms[1];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
// Shape 5
|
|
|
|
{
|
|
|
|
// Check the first text portion properties
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(4));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
|
|
|
CPPUNIT_ASSERT(xPortion.is());
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTransforms = aComplexColor.getTransformations();
|
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(2), rTransforms.size());
|
|
|
|
auto const& rTrans1 = rTransforms[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
|
2023-05-08 14:09:00 +09:00
|
|
|
auto const& rTrans2 = rTransforms[1];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
|
|
|
|
}
|
|
|
|
// Shape 6
|
|
|
|
{
|
|
|
|
// Check the first text portion properties
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(5));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
|
|
|
CPPUNIT_ASSERT(xPortion.is());
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
|
|
|
|
auto const& rTrans1 = aComplexColor.getTransformations()[0];
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColor_ShapeFill)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"ReferenceShapeFill.pptx");
|
2022-12-31 20:59:03 +09:00
|
|
|
save("impress8");
|
|
|
|
// reload
|
|
|
|
load(maTempFile.GetURL());
|
|
|
|
|
|
|
|
// check fill color theme
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(0));
|
|
|
|
CPPUNIT_ASSERT(xShape.is());
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
2023-05-08 14:09:00 +09:00
|
|
|
uno::Reference<util::XComplexColor> xComplexColor;
|
|
|
|
xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
|
|
|
|
CPPUNIT_ASSERT(xComplexColor.is());
|
|
|
|
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
|
2023-08-03 10:14:40 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getThemeColorType());
|
2023-05-08 14:09:00 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
|
2022-12-31 20:59:03 +09:00
|
|
|
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
|
2023-05-08 14:09:00 +09:00
|
|
|
aComplexColor.getTransformations()[0].meType);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), aComplexColor.getTransformations()[0].mnValue);
|
2021-12-09 08:43:27 +01:00
|
|
|
}
|
|
|
|
|
2021-12-14 13:51:14 +01:00
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape)
|
|
|
|
{
|
|
|
|
// Given a document with a shape with a "FrameX" parent style (starts with Frame, but is not
|
|
|
|
// Frame):
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"table-in-shape.fodt");
|
2021-12-14 13:51:14 +01:00
|
|
|
|
|
|
|
// Then make sure the table inside the shape is not lost:
|
2022-10-24 16:56:28 +02:00
|
|
|
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
|
2021-12-14 13:51:14 +01:00
|
|
|
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
|
|
|
|
uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
|
|
|
uno::Reference<container::XEnumerationAccess> xText(xShape->getText(), uno::UNO_QUERY);
|
|
|
|
uno::Reference<container::XEnumeration> xEnum = xText->createEnumeration();
|
|
|
|
uno::Reference<text::XTextTable> xTable(xEnum->nextElement(), uno::UNO_QUERY);
|
|
|
|
// Without the accompanying fix in place, this test would have crashed, as xTable was an empty
|
|
|
|
// reference, i.e. the table inside the shape was lost.
|
|
|
|
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(OUString("A1"), xCell->getString());
|
|
|
|
}
|
|
|
|
|
2022-01-13 13:26:25 +01:00
|
|
|
// Tests for save/load of new (LO 7.4) attribute loext:extrusion-metal-type
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void lcl_assertMetalProperties(std::string_view sInfo, uno::Reference<drawing::XShape>& rxShape)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProps(rxShape, uno::UNO_QUERY);
|
|
|
|
uno::Sequence<beans::PropertyValue> aGeoPropSeq;
|
|
|
|
xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq;
|
|
|
|
comphelper::SequenceAsHashMap aGeoPropMap(aGeoPropSeq);
|
|
|
|
uno::Sequence<beans::PropertyValue> aExtrusionSeq;
|
|
|
|
aGeoPropMap.getValue("Extrusion") >>= aExtrusionSeq;
|
|
|
|
comphelper::SequenceAsHashMap aExtrusionPropMap(aExtrusionSeq);
|
|
|
|
|
|
|
|
bool bIsMetal(false);
|
|
|
|
aExtrusionPropMap.getValue("Metal") >>= bIsMetal;
|
|
|
|
OString sMsg = OString::Concat(sInfo) + " Metal";
|
|
|
|
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), bIsMetal);
|
|
|
|
|
|
|
|
sal_Int16 nMetalType(-1);
|
|
|
|
aExtrusionPropMap.getValue("MetalType") >>= nMetalType;
|
|
|
|
sMsg = OString::Concat(sInfo) + " MetalType";
|
|
|
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
|
|
|
sMsg.getStr(), css::drawing::EnhancedCustomShapeMetalType::MetalMSCompatible, nMetalType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeExtended)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf145700_3D_metal_type_MSCompatible.doc");
|
2022-01-13 13:26:25 +01:00
|
|
|
// verify properties
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(0));
|
|
|
|
lcl_assertMetalProperties("from doc", xShape);
|
|
|
|
|
|
|
|
// Test, that new attribute is written with loext namespace. Adapt when attribute is added to ODF.
|
2022-11-04 17:31:55 +01:00
|
|
|
save("writer8");
|
2022-01-13 13:26:25 +01:00
|
|
|
|
|
|
|
// assert XML.
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, "true");
|
|
|
|
assertXPath(
|
|
|
|
pXmlDoc,
|
|
|
|
"//draw:enhanced-geometry[@loext:extrusion-metal-type='loext:MetalMSCompatible']"_ostr);
|
2022-01-13 13:26:25 +01:00
|
|
|
|
|
|
|
// reload
|
2022-11-04 17:31:55 +01:00
|
|
|
mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument");
|
2022-01-13 13:26:25 +01:00
|
|
|
// verify properties
|
|
|
|
uno::Reference<drawing::XShape> xShapeReload(getShape(0));
|
|
|
|
lcl_assertMetalProperties("from ODF 1.3 extended", xShapeReload);
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeStrict)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf145700_3D_metal_type_MSCompatible.doc");
|
2022-01-13 13:26:25 +01:00
|
|
|
|
|
|
|
// save ODF 1.3 strict and test, that new attribute is not written. Adapt when attribute is
|
|
|
|
// added to ODF.
|
|
|
|
const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion());
|
|
|
|
SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
|
2022-11-04 17:31:55 +01:00
|
|
|
save("writer8");
|
2022-01-13 13:26:25 +01:00
|
|
|
|
|
|
|
// assert XML.
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, "true");
|
|
|
|
assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-metal-type]"_ostr, 0);
|
2022-01-13 13:26:25 +01:00
|
|
|
|
|
|
|
SetODFDefaultVersion(nCurrentODFVersion);
|
|
|
|
}
|
|
|
|
|
2022-02-21 23:08:10 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void lcl_assertSpecularityProperty(std::string_view sInfo, uno::Reference<drawing::XShape>& rxShape)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProps(rxShape, uno::UNO_QUERY);
|
|
|
|
uno::Sequence<beans::PropertyValue> aGeoPropSeq;
|
|
|
|
xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq;
|
|
|
|
comphelper::SequenceAsHashMap aGeoPropMap(aGeoPropSeq);
|
|
|
|
uno::Sequence<beans::PropertyValue> aExtrusionSeq;
|
|
|
|
aGeoPropMap.getValue("Extrusion") >>= aExtrusionSeq;
|
|
|
|
comphelper::SequenceAsHashMap aExtrusionPropMap(aExtrusionSeq);
|
|
|
|
|
|
|
|
double fSpecularity(-1.0);
|
|
|
|
aExtrusionPropMap.getValue("Specularity") >>= fSpecularity;
|
|
|
|
OString sMsg = OString::Concat(sInfo) + "Specularity";
|
|
|
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMsg.getStr(), 122.0703125, fSpecularity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityExtended)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf147580_extrusion-specularity.doc");
|
2022-02-21 23:08:10 +01:00
|
|
|
// verify property
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(0));
|
|
|
|
lcl_assertSpecularityProperty("from doc", xShape);
|
|
|
|
|
|
|
|
// Test, that attribute is written in draw namespace with value 100% and in loext namespace with
|
|
|
|
// value 122.0703125%.
|
2022-11-04 17:31:55 +01:00
|
|
|
save("writer8");
|
2022-02-21 23:08:10 +01:00
|
|
|
|
|
|
|
// assert XML.
|
2022-11-04 17:31:55 +01:00
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, "//draw:enhanced-geometry[@draw:extrusion-specularity='100%']"_ostr);
|
2022-02-21 23:08:10 +01:00
|
|
|
assertXPath(pXmlDoc,
|
2023-11-19 13:21:42 +01:00
|
|
|
"//draw:enhanced-geometry[@loext:extrusion-specularity-loext='122.0703125%']"_ostr);
|
2022-02-21 23:08:10 +01:00
|
|
|
|
|
|
|
// reload and verify, that the loext value is used
|
2022-11-04 17:31:55 +01:00
|
|
|
mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument");
|
2022-02-21 23:08:10 +01:00
|
|
|
// verify properties
|
|
|
|
uno::Reference<drawing::XShape> xShapeReload(getShape(0));
|
|
|
|
lcl_assertSpecularityProperty("from ODF 1.3 extended", xShapeReload);
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularity)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf147580_extrusion-specularity.doc");
|
2022-02-21 23:08:10 +01:00
|
|
|
|
|
|
|
// The file has c3DSpecularAmt="80000" which results internally in specularity=122%.
|
|
|
|
// Save to ODF 1.3 strict and make sure it does not produce a validation error.
|
|
|
|
const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion());
|
|
|
|
SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
|
2022-11-04 17:31:55 +01:00
|
|
|
save("writer8");
|
2022-02-21 23:08:10 +01:00
|
|
|
|
|
|
|
SetODFDefaultVersion(nCurrentODFVersion);
|
|
|
|
}
|
|
|
|
|
2022-05-03 00:18:00 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
bool lcl_getShapeSegments(uno::Sequence<drawing::EnhancedCustomShapeSegment>& rSegments,
|
|
|
|
const uno::Reference<drawing::XShape>& xShape)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY_THROW);
|
|
|
|
uno::Any anotherAny = xShapeProps->getPropertyValue("CustomShapeGeometry");
|
|
|
|
uno::Sequence<beans::PropertyValue> aCustomShapeGeometry;
|
|
|
|
if (!(anotherAny >>= aCustomShapeGeometry))
|
|
|
|
return false;
|
|
|
|
uno::Sequence<beans::PropertyValue> aPathProps;
|
2024-01-27 15:42:54 +06:00
|
|
|
for (beans::PropertyValue const& rProp : aCustomShapeGeometry)
|
2022-05-03 00:18:00 +02:00
|
|
|
{
|
|
|
|
if (rProp.Name == "Path")
|
|
|
|
{
|
|
|
|
rProp.Value >>= aPathProps;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-27 15:42:54 +06:00
|
|
|
for (beans::PropertyValue const& rProp : aPathProps)
|
2022-05-03 00:18:00 +02:00
|
|
|
{
|
|
|
|
if (rProp.Name == "Segments")
|
|
|
|
{
|
|
|
|
rProp.Value >>= rSegments;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rSegments.getLength() > 2)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf148714_CurvedArrowsOld)
|
|
|
|
{
|
|
|
|
// Load a document with CurveArrow shapes with faulty path as written by older LO versions.
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf148714_CurvedArrowsOld.odp");
|
2022-05-03 00:18:00 +02:00
|
|
|
|
|
|
|
// Make sure, that the error has been corrected on opening.
|
|
|
|
for (sal_Int32 nShapeIndex = 0; nShapeIndex < 4; nShapeIndex++)
|
|
|
|
{
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(nShapeIndex));
|
|
|
|
uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
|
|
|
|
CPPUNIT_ASSERT(lcl_getShapeSegments(aSegments, xShape));
|
|
|
|
|
|
|
|
if (nShapeIndex == 0 || nShapeIndex == 3)
|
|
|
|
{
|
|
|
|
// curvedDownArrow or curvedLeftArrow. Segments should start with VW. Without fix it was
|
|
|
|
// V with count 2, which means VV.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(
|
|
|
|
sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC),
|
|
|
|
aSegments[0].Command);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments[0].Count);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(
|
|
|
|
sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO),
|
|
|
|
aSegments[1].Command);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments[1].Count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// curvedUpArrow or curvedRightArrow. Segments should start with BA. Without fix is was
|
|
|
|
// B with count 2, which means BB.
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::ARC),
|
|
|
|
aSegments[0].Command);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments[0].Count);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(drawing::EnhancedCustomShapeSegmentCommand::ARCTO),
|
|
|
|
aSegments[1].Command);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aSegments[1].Count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-15 13:15:15 +02:00
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextRotationPlusPre)
|
|
|
|
{
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf149551_verticalText.pptx");
|
2022-06-15 13:15:15 +02:00
|
|
|
// The file has a shape with attribute vert="vert" in <bodyPr> element. That generates a
|
|
|
|
// TextPreRotateAngle attribute in CustomShapeGeometry.
|
|
|
|
|
|
|
|
// Add a TextRotateAngle attribute.
|
|
|
|
uno::Reference<drawing::XShape> xShape(getShape(0));
|
|
|
|
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
|
|
|
|
uno::Sequence<beans::PropertyValue> aGeomSeq;
|
|
|
|
xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeomSeq;
|
|
|
|
auto aGeomVec(comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomSeq));
|
|
|
|
aGeomVec.push_back(comphelper::makePropertyValue("TextRotateAngle", sal_Int32(45)));
|
|
|
|
aGeomSeq = comphelper::containerToSequence(aGeomVec);
|
|
|
|
xShapeProps->setPropertyValue("CustomShapeGeometry", uno::Any(aGeomSeq));
|
|
|
|
|
|
|
|
// Save to ODF. Without the fix, a file format error was produced, because attribute
|
|
|
|
// draw:text-rotate-angle was written twice, one from TextPreRotateAngle and the other from
|
|
|
|
// TextRotateAngle.
|
|
|
|
// This should already catch the format error, but does not, see tdf#149567
|
|
|
|
// But reload catches it.
|
2022-10-25 10:18:11 +02:00
|
|
|
saveAndReload("writer8");
|
2022-06-15 13:15:15 +02:00
|
|
|
}
|
2023-08-29 22:18:29 +02:00
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport)
|
|
|
|
{
|
|
|
|
// It tests, that a theme is written to master page in Draw documents.
|
|
|
|
// Without fix for tdf#156975 it was not written at all.
|
|
|
|
// The test needs to be adapted, when themes are available in ODF.
|
|
|
|
|
|
|
|
mxComponent = loadFromDesktop("private:factory/sdraw");
|
|
|
|
// generate a theme to be sure we have got one and know the values
|
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
|
|
|
|
uno::Reference<drawing::XMasterPageTarget> xDrawPage(
|
|
|
|
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
|
|
|
uno::Reference<beans::XPropertySet> xMasterPageProps(xDrawPage->getMasterPage(),
|
|
|
|
uno::UNO_QUERY);
|
|
|
|
|
|
|
|
auto pTheme = std::make_shared<model::Theme>("Custom");
|
|
|
|
auto pColorSet = std::make_shared<model::ColorSet>("My Colors");
|
|
|
|
pColorSet->add(model::ThemeColorType::Dark1, 0x000000);
|
|
|
|
pColorSet->add(model::ThemeColorType::Light1, 0xffff11);
|
|
|
|
pColorSet->add(model::ThemeColorType::Dark2, 0x002200);
|
|
|
|
pColorSet->add(model::ThemeColorType::Light2, 0xff33ff);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent1, 0x440000);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent2, 0x005500);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent3, 0x000066);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent4, 0x777700);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent5, 0x880088);
|
|
|
|
pColorSet->add(model::ThemeColorType::Accent6, 0x009999);
|
|
|
|
pColorSet->add(model::ThemeColorType::Hyperlink, 0x0a0a0a);
|
|
|
|
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb0b0b0);
|
|
|
|
pTheme->setColorSet(pColorSet);
|
|
|
|
|
|
|
|
uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme);
|
|
|
|
xMasterPageProps->setPropertyValue("Theme", uno::Any(xTheme));
|
|
|
|
|
|
|
|
// save as odg
|
|
|
|
save("draw8");
|
|
|
|
|
|
|
|
// and check the markup.
|
|
|
|
xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
|
2023-10-19 10:30:42 +02:00
|
|
|
static constexpr OString sThemePath
|
|
|
|
= "//office:master-styles/style:master-page/loext:theme"_ostr;
|
2023-08-29 22:18:29 +02:00
|
|
|
assertXPath(pXmlDoc, sThemePath, 1);
|
|
|
|
assertXPath(pXmlDoc, sThemePath + "[@loext:name='Custom']");
|
|
|
|
|
|
|
|
const OString sThemeColorsPath = sThemePath + "/loext:theme-colors";
|
|
|
|
assertXPath(pXmlDoc, sThemeColorsPath, 1);
|
|
|
|
assertXPath(pXmlDoc, sThemeColorsPath + "[@loext:name='My Colors']");
|
|
|
|
|
|
|
|
const OString sThemeColorPath = sThemeColorsPath + "/loext:color";
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath, 12);
|
2023-11-19 13:21:42 +01:00
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[3]", "name"_ostr, "dark2");
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[3]", "color"_ostr, "#002200");
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[9]", "name"_ostr, "accent5");
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[9]", "color"_ostr, "#880088");
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[12]", "name"_ostr, "followed-hyperlink");
|
|
|
|
assertXPath(pXmlDoc, sThemeColorPath + "[12]", "color"_ostr, "#b0b0b0");
|
2023-08-29 22:18:29 +02:00
|
|
|
}
|
2023-08-31 01:15:26 +02:00
|
|
|
|
|
|
|
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf157018_ThemeImportDraw)
|
|
|
|
{
|
|
|
|
// Similar to testThemeImport but for Draw.
|
|
|
|
// Load document with custom color theme
|
2024-01-03 11:49:02 +06:00
|
|
|
loadFromFile(u"tdf157018_CustomTheme.fodg");
|
2023-08-31 01:15:26 +02:00
|
|
|
|
|
|
|
// First make sure the doc model has a master page with a theme:
|
|
|
|
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
|
|
|
|
uno::Reference<drawing::XMasterPageTarget> xDrawPage(
|
|
|
|
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
|
|
|
uno::Reference<beans::XPropertySet> xMasterpage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
|
|
|
|
|
|
|
|
uno::Reference<util::XTheme> xTheme;
|
|
|
|
xMasterpage->getPropertyValue("Theme") >>= xTheme;
|
|
|
|
CPPUNIT_ASSERT(xTheme.is());
|
|
|
|
|
|
|
|
// Then make sure it is the custom color theme
|
|
|
|
auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
|
|
|
|
CPPUNIT_ASSERT(pUnoTheme);
|
|
|
|
auto pTheme = pUnoTheme->getTheme();
|
|
|
|
CPPUNIT_ASSERT(pTheme);
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(OUString("Custom"), pTheme->GetName());
|
|
|
|
auto pColorSet = pTheme->getColorSet();
|
|
|
|
CPPUNIT_ASSERT(pColorSet);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(OUString("My Colors"), pColorSet->getName());
|
|
|
|
|
|
|
|
// and test some colors
|
|
|
|
CPPUNIT_ASSERT_EQUAL(Color(0xFFFF11), pColorSet->getColor(model::ThemeColorType::Light1));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(Color(0x0A0A0A), pColorSet->getColor(model::ThemeColorType::Hyperlink));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(Color(0x440000), pColorSet->getColor(model::ThemeColorType::Accent1));
|
|
|
|
}
|
2020-08-12 09:06:14 +02:00
|
|
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|