tdf#153368: Support optical size for variable fonts, part 7

Enable by default for new documents in Draw/Impress.

Change-Id: I07d306c744703b01958e8bb86101e112c8ad9b0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200741
Tested-by: Jenkins
Reviewed-by: Khaled Hosny <khaled@libreoffice.org>
This commit is contained in:
Khaled Hosny
2026-03-02 21:46:01 +01:00
committed by Khaled Hosny
parent 3fb0c4e15f
commit 059b717535
5 changed files with 120 additions and 1 deletions
+1
View File
@@ -319,6 +319,7 @@ inline constexpr OUString UNO_NAME_EDIT_CHAR_FONTCHARSET = u"CharFontCharSet"_us
inline constexpr OUString UNO_NAME_EDIT_CHAR_FONTPITCH = u"CharFontPitch"_ustr;
inline constexpr OUString UNO_NAME_EDIT_CHAR_POSTURE = u"CharPosture"_ustr;
inline constexpr OUString UNO_NAME_EDIT_CHAR_WEIGHT = u"CharWeight"_ustr;
inline constexpr OUString UNO_NAME_EDIT_CHAR_OPTICALSIZING = u"CharOpticalSizing"_ustr;
inline constexpr OUString UNO_NAME_EDIT_CHAR_LOCALE = u"CharLocale"_ustr;
inline constexpr OUString UNO_NAME_EDIT_CHAR_HEIGHT_ASIAN = u"CharHeightAsian"_ustr;
+2 -1
View File
@@ -137,7 +137,8 @@ struct SfxItemPropertyMapEntry;
{ UNO_NAME_EDIT_CHAR_RUBY_TEXT, EE_CHAR_RUBY, ::cppu::UnoType<OUString>::get(), 0, MID_RUBY_TEXT }, \
{ UNO_NAME_EDIT_CHAR_RUBY_ADJUST, EE_CHAR_RUBY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_RUBY_ADJUST }, \
{ UNO_NAME_EDIT_CHAR_RUBY_POSITION, EE_CHAR_RUBY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_RUBY_POSITION }, \
{ UNO_NAME_EDIT_CHAR_SCRIPT_HINT, EE_CHAR_SCRIPT_HINT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_SCRIPTHINT }
{ UNO_NAME_EDIT_CHAR_SCRIPT_HINT, EE_CHAR_SCRIPT_HINT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_SCRIPTHINT }, \
{ UNO_NAME_EDIT_CHAR_OPTICALSIZING, EE_CHAR_OPTICALSIZING, ::cppu::UnoType<bool>::get(), 0, 0 }
#define SVX_UNOEDIT_FONT_PROPERTIES \
+100
View File
@@ -2558,6 +2558,106 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTableBordersTransparancy)
Color(ColorTransparency, aBorderLine.Color));
}
// CharOpticalSizing should be enabled by default for new documents
CPPUNIT_TEST_FIXTURE(SdExportTest, testOpticalSizing1)
{
createSdImpressDoc();
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->insertNewByIndex(0),
uno::UNO_SET_THROW);
uno::Reference<drawing::XShapes> xShapes(xDrawPage, uno::UNO_QUERY_THROW);
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape(
xFactory->createInstance(u"com.sun.star.drawing.TextShape"_ustr), uno::UNO_QUERY_THROW);
xShapes->add(xShape);
uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY_THROW);
xText->setString(u"test"_ustr);
{
// It should be true by default for new documents
uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps));
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(true,
xRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
// and it should survive save-and-reload
saveAndReload(TestFilter::ODP);
uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1));
uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2));
uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2));
uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(true,
xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
}
{
// Setting it manually should set it in contents
uno::Reference<beans::XPropertySet> xProps(getShapeFromPage(0, 1));
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps));
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW);
xRunProps->setPropertyValue(u"CharOpticalSizing"_ustr, uno::Any(true));
save(TestFilter::ODP);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc,
"//style:style/style:text-properties[@loext:font-optical-sizing='auto']", 1);
// and it should survive save-and-reload
saveAndReload(TestFilter::ODP);
uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1));
uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2));
uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2));
uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(true,
xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc,
"//style:style/style:text-properties[@loext:font-optical-sizing='auto']", 1);
}
{
// It can also be disabled
uno::Reference<beans::XPropertySet> xProps(getShapeFromPage(0, 1));
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps));
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW);
xRunProps->setPropertyValue(u"CharOpticalSizing"_ustr, uno::Any(false));
save(TestFilter::ODP);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc,
"//style:style/style:text-properties[@loext:font-optical-sizing='none']", 1);
// and it should survive save-and-reload
saveAndReload(TestFilter::ODP);
uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1));
uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2));
uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2));
uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(false,
xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc,
"//style:style/style:text-properties[@loext:font-optical-sizing='none']", 1);
}
}
// CharOpticalSizing should be disabled by default for old documents
CPPUNIT_TEST_FIXTURE(SdExportTest, testOpticalSizing2)
{
createSdImpressDoc("odp/transparent_background.odp");
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0));
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(false, xRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+4
View File
@@ -78,6 +78,7 @@
#include <editeng/udlnitem.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/emphasismarkitem.hxx>
#include <editeng/opticalsizingitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/cmapitem.hxx>
@@ -275,6 +276,9 @@ void SdDrawDocument::CreateLayoutTemplates()
// #i16874# enable kerning by default but only for new documents
rISet.Put(SvxAutoKernItem(true, EE_CHAR_PAIRKERNING));
// tdf#153368 Optical sizing by default but only for new documents
rISet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
// Bullet
// BulletItem and BulletFont for title and outline
SvxBulletItem aBulletItem(EE_PARA_BULLET);
+13
View File
@@ -41,6 +41,7 @@
#include <editeng/ulspitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/cmapitem.hxx>
#include <editeng/opticalsizingitem.hxx>
#include <svl/hint.hxx>
#include <editeng/charreliefitem.hxx>
#include <editeng/emphasismarkitem.hxx>
@@ -249,6 +250,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
rSet.Put( makeSdrTextAutoGrowHeightItem(false) );
// #i16874# enable kerning by default but only for new documents
rSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
// tdf#153368 Optical sizing by default but only for new documents
rSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
vcl::Font f( GetBulletFont() );
PutNumBulletItem( pSheet, f );
@@ -359,6 +362,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
// #i16874# enable kerning by default but only for new documents
rTitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
// tdf#153368 Optical sizing by default but only for new documents
rTitleSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
aBulletFont.SetFontSize(Size(0,1552)); // 44 pt
PutNumBulletItem( pSheet, aBulletFont );
@@ -405,6 +410,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
// #i16874# enable kerning by default but only for new documents
rSubtitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
// tdf#153368 Optical sizing by default but only for new documents
rSubtitleSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
aSvxLRSpaceItem.SetTextLeft(SvxIndentValue::zero());
rSubtitleSet.Put(aSvxLRSpaceItem);
@@ -454,6 +461,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
SvxIndentValue::twips(-600.0), EE_PARA_LRSPACE));
// #i16874# enable kerning by default but only for new documents
rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
// tdf#153368 Optical sizing by default but only for new documents
rNotesSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
/* #i35937# */
@@ -479,6 +488,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
// #i16874# enable kerning by default but only for new documents
rBackgroundObjectsSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
// tdf#153368 Optical sizing by default but only for new documents
rBackgroundObjectsSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
}
/**************************************************************************
@@ -498,6 +509,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
rBackgroundSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
// #i16874# enable kerning by default but only for new documents
rBackgroundSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
// tdf#153368 Optical sizing by default but only for new documents
rBackgroundSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING));
}
DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" );