Rebased ref, commits from common ancestor:
commit d3cb87d9e82dbd34601293f3535f3a409046bb96
Author:     Khaled Hosny <[email protected]>
AuthorDate: Mon Mar 2 01:24:26 2026 +0200
Commit:     Khaled Hosny <[email protected]>
CommitDate: Mon Mar 2 01:40:21 2026 +0200

    tdf#153368: Support optical size for variable fonts, part 7
    
    Enable by default for new documents in Draw/Impress.
    
    Change-Id: Icdfa639836efeb7ae8baa9ffadef35b6ccf28646

diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index 33662cf3ac9f..b5d354d695bf 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -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;
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 37e82293dbb3..65824411a0bd 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -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 \
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 386b42fcdf3f..836d97527479 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -2558,6 +2558,74 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, 
testTableBordersTransparancy)
                          Color(ColorTransparency, aBorderLine.Color));
 }
 
+// CharOpticalSizing
+CPPUNIT_TEST_FIXTURE(SdExportTest, testOpticalSizing)
+{
+    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> xNewShape(
+        xFactory->createInstance(u"com.sun.star.drawing.TextShape"_ustr), 
uno::UNO_QUERY_THROW);
+    xShapes->add(xNewShape);
+
+    uno::Reference<text::XText> xText(xNewShape, uno::UNO_QUERY_THROW);
+    xText->setString(u"test"_ustr);
+
+    uno::Reference<beans::XPropertySet> xNewShapeProps(xNewShape, 
uno::UNO_QUERY_THROW);
+    uno::Reference<text::XTextRange> const 
xNewParagraph(getParagraphFromShape(0, xNewShapeProps));
+    uno::Reference<text::XTextRange> xNewRun(getRunFromParagraph(0, 
xNewParagraph));
+    uno::Reference<beans::XPropertySet> xNewRunProps(xNewRun, 
uno::UNO_QUERY_THROW);
+
+    // it should be true by default for new documents
+    CPPUNIT_ASSERT_EQUAL(true,
+                         
xNewRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
+
+    //XXXX
+
+    // Setting it manually should set it in contents
+    xNewRunProps->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);
+
+    xNewRunProps->setPropertyValue(u"CharOpticalSizing"_ustr, uno::Any(true));
+    save(TestFilter::ODP);
+    pXmlDoc = parseExport(u"content.xml"_ustr);
+    assertXPath(pXmlDoc, 
"//style:style/style:text-properties[@loext:font-optical-sizing='auto']",
+                1);
+
+    saveAndReload(TestFilter::ODP);
+    uno::Reference<beans::XPropertySet> xNewShapeProps2(getShapeFromPage(0, 
1));
+    uno::Reference<text::XTextRange> const xNewParagraph2(
+        getParagraphFromShape(0, xNewShapeProps2));
+    uno::Reference<text::XTextRange> xNewRun2(getRunFromParagraph(0, 
xNewParagraph2));
+    uno::Reference<beans::XPropertySet> xNewRunProps2(xNewRun2, 
uno::UNO_QUERY_THROW);
+    // and it should be true after save-and-reload
+    CPPUNIT_ASSERT_EQUAL(true,
+                         
xNewRunProps2->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);
+
+    dispose();
+
+    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);
+    // but it should be false by default for old documents
+    CPPUNIT_ASSERT_EQUAL(false, 
xRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index 772507eb04b9..9401c3277e5b 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -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);
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 7316a8f6a547..e85e60a89787 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -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!" 
);

Reply via email to