sw/inc/poolfmt.hxx                              |    1 +
 sw/inc/strings.hrc                              |    1 +
 sw/qa/python/check_styles.py                    |    2 +-
 sw/source/core/doc/DocumentStylePoolManager.cxx |   17 ++++++++++++++++-
 sw/source/core/doc/SwStyleNameMapper.cxx        |    1 +
 sw/source/uibase/app/docst.cxx                  |   14 ++------------
 6 files changed, 22 insertions(+), 14 deletions(-)

New commits:
commit a1dcbd1d1ce6071d48bb5df26d7839aeb21b75a8
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Oct 29 18:02:51 2024 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Nov 1 08:50:54 2024 +0100

    tdf#48459 sw inline heading: add Inline Heading frame style
    
    Add the new frame style Inline Heading with default variable
    width and anchoring as character to support UX better
    – and later, – interoperability.
    
    Note: the previous commit (7a35f3dc7419d833b8f47069c4df63e900ccb880)
    used the Formula style for inline headings.
    
    Note: adjust check_styles.py unit test according to the extended
    frame style list.
    
    Follow-up to commit 7a35f3dc7419d833b8f47069c4df63e900ccb880
    "tdf#48459 sw inline heading: apply it on the selected words".
    
    Change-Id: I615a53803d755acfbabb77fe53b0e5b60fa9fcc0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175834
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/inc/poolfmt.hxx b/sw/inc/poolfmt.hxx
index 7d82c0c02108..4823e8c47383 100644
--- a/sw/inc/poolfmt.hxx
+++ b/sw/inc/poolfmt.hxx
@@ -158,6 +158,7 @@ RES_POOLFRM_FORMEL,                                 ///< 
Formula.
 RES_POOLFRM_MARGINAL,                               ///< Marginalia.
 RES_POOLFRM_WATERSIGN,                              ///< Watermark.
 RES_POOLFRM_LABEL,                                  ///< Labels.
+RES_POOLFRM_INLINE_HEADING,                         ///< Inline Heading.
 
 RES_POOLFRM_END
 };
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index b14c7ab5daf3..88fa5c9ec865 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -71,6 +71,7 @@
 #define STR_POOLFRM_MARGINAL                    NC_("STR_POOLFRM_MARGINAL", 
"Marginalia")
 #define STR_POOLFRM_WATERSIGN                   NC_("STR_POOLFRM_WATERSIGN", 
"Watermark")
 #define STR_POOLFRM_LABEL                       NC_("STR_POOLFRM_LABEL", 
"Labels")
+#define STR_POOLFRM_INLINE_HEADING              NC_("STR_POOLFRM_MARGINAL", 
"Inline Heading")
 // Template names
 #define STR_POOLCOLL_STANDARD                   NC_("STR_POOLCOLL_STANDARD", 
"Default Paragraph Style")
 #define STR_POOLCOLL_TEXT                       NC_("STR_POOLCOLL_TEXT", "Body 
Text")
diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py
index 922e9093d0eb..5d5052143bd9 100644
--- a/sw/qa/python/check_styles.py
+++ b/sw/qa/python/check_styles.py
@@ -147,7 +147,7 @@ class CheckStyle(unittest.TestCase):
     def test_FrameFamily(self):
         xDoc = CheckStyle._uno.openEmptyWriterDoc()
         xFrameStyles = xDoc.StyleFamilies["FrameStyles"]
-        vEmptyDocStyles = ['Formula', 'Frame', 'Graphics', 'Labels', 
'Marginalia', 'OLE', 'Watermark']
+        vEmptyDocStyles = ['Formula', 'Frame', 'Graphics', 'Inline Heading', 
'Labels', 'Marginalia', 'OLE', 'Watermark']
         self.__test_StyleFamily(xFrameStyles, vEmptyDocStyles, "SwXStyle")
         self.__test_StyleFamilyIndex(xFrameStyles, vEmptyDocStyles, "SwXStyle")
         self.__test_StyleFamilyInsert(xDoc, xFrameStyles, vEmptyDocStyles, 
"com.sun.star.style.FrameStyle", "com.sun.star.style.CharacterStyle")
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx 
b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 03bcee46f1bf..09e7efe6f09c 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -500,7 +500,8 @@ const TranslateId STR_POOLFRM_ARY[] =
     STR_POOLFRM_FORMEL,
     STR_POOLFRM_MARGINAL,
     STR_POOLFRM_WATERSIGN,
-    STR_POOLFRM_LABEL
+    STR_POOLFRM_LABEL,
+    STR_POOLFRM_INLINE_HEADING
 };
 
 const TranslateId STR_POOLPAGE_ARY[] =
@@ -1695,10 +1696,24 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( 
sal_uInt16 nId )
         }
         break;
     case RES_POOLFRM_FORMEL:
+    case RES_POOLFRM_INLINE_HEADING:
         {
             aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
             aSet.Put( SwFormatVertOrient( 0, 
text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
             aSet.Put( SvxLRSpaceItem( 0, 0, 0, RES_LR_SPACE ) );
+
+            if ( RES_POOLFRM_INLINE_HEADING == nId )
+            {
+                // Set the default width to 0.5 cm, use the minimum value for 
the height
+                SwFormatFrameSize aSize(SwFrameSize::Variable,
+                                       o3tl::toTwips(5, o3tl::Length::mm),
+                                       o3tl::toTwips(1, o3tl::Length::mm));
+                // variable width of the inline heading frame follows its text 
content
+                aSize.SetWidthSizeType(SwFrameSize::Variable);
+                aSet.Put(aSize);
+            }
+            else
+                aSet.Put( SwFormatVertOrient( 0, 
text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
         }
         break;
     case RES_POOLFRM_MARGINAL:
diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx 
b/sw/source/core/doc/SwStyleNameMapper.cxx
index b375b5ab3ad0..b047782a4221 100644
--- a/sw/source/core/doc/SwStyleNameMapper.cxx
+++ b/sw/source/core/doc/SwStyleNameMapper.cxx
@@ -640,6 +640,7 @@ const std::vector<OUString>& 
SwStyleNameMapper::GetFrameFormatProgNameArray()
         u"Marginalia"_ustr,
         u"Watermark"_ustr,
         u"Labels"_ustr, // RES_POOLFRM_LABEL
+        u"Inline Heading"_ustr,
     };
     return s_aFrameFormatProgNameArray;
 }
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index e81ccb9aff8d..6bc5e0b56ae2 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1198,21 +1198,11 @@ bool SwDocShell::MakeInlineHeading(SwWrtShell *pSh, 
SwTextFormatColl* pColl, con
                 SfxCallMode::SYNCHRON|SfxCallMode::RECORD, { &aAnchor, 
&aSizeItem });
         if ( pSh->IsFrameSelected() )
         {
-            // use the borderless frame style "Formula"
-            // TODO add a new frame style "Inline Heading"
+            // use the associated borderless frame style "Inline Heading"
             SwDocStyleSheet* pStyle2 = static_cast<SwDocStyleSheet*>(
-                            m_xBasePool->Find( "Formula", 
SfxStyleFamily::Frame));
+                            m_xBasePool->Find( "Inline Heading", 
SfxStyleFamily::Frame));
             pSh->SetFrameFormat( pStyle2->GetFrameFormat() );
 
-            // set variable width frame to extend for the width of the text 
content
-            SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END - 1> 
aSet(pSh->GetAttrPool());
-            pSh->GetFlyFrameAttr( aSet );
-            SwTwips nMinWidth = 100;
-            SwFormatFrameSize aSize(SwFrameSize::Variable, nMinWidth, 
nMinWidth);
-            aSize.SetWidthSizeType(SwFrameSize::Variable);
-            aSet.Put(aSize);
-            pSh->SetFlyFrameAttr( aSet );
-
             // select the text content of the frame, and apply the paragraph 
style
             pSh->UnSelectFrame();
             pSh->LeaveSelFrameMode();

Reply via email to