sw/source/filter/ww8/docxattributeoutput.cxx |   29 ++++++++++++++++-----------
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 -
 sw/source/ui/dialog/swdlgfact.cxx            |    5 ++++
 sw/source/ui/dialog/swdlgfact.hxx            |    1 
 sw/source/ui/dialog/uiregionsw.cxx           |    9 ++++++--
 sw/source/uibase/dialog/regionsw.cxx         |   16 ++++++++------
 sw/source/uibase/inc/regionsw.hxx            |    1 
 sw/uiconfig/swriter/ui/editsectiondialog.ui  |    2 -
 vcl/jsdialog/enabled.cxx                     |    1 
 9 files changed, 44 insertions(+), 22 deletions(-)

New commits:
commit 165a3995d396455eaf0482f407211f7e9ba61923
Author:     Méven Car <[email protected]>
AuthorDate: Wed Jan 10 10:26:38 2024 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Jan 15 20:08:56 2024 +0100

    sw Edit Sections: hide Link section in LOK case
    
    In the LibreOfficeKit case the section does not make sense as the
    application has only restricted access to files, so hide it.
    
    Test: In Writer new document, insert a section, right click on section,
    Edit section..., Link section is visible.
    
    In LOK case the Link section is not present.
    
    Change-Id: I7aab8b384909d25e52f5fca2bf54f86e5c662b54
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161878
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit f9546a5e9e204fc058365aaddfb0dfa8f9a26418)

diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index fd61903a0068..f1499b6a28ca 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -357,6 +357,7 @@ SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, 
SwWrtShell& rWrtSh)
     , m_xOptionsPB(m_xBuilder->weld_button("options"))
     , m_xDismiss(m_xBuilder->weld_button("remove"))
     , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
+    , m_xLinkFrame(m_xBuilder->weld_frame("linkframe"))
 {
     m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
     m_xFileCB->set_state(TRISTATE_FALSE);
@@ -418,6 +419,7 @@ SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, 
SwWrtShell& rWrtSh)
 
     if(comphelper::LibreOfficeKit::isActive())
     {
+        m_xLinkFrame->hide();
         m_xDDECB->hide();
         m_xDDECommandFT->hide();
         m_xFileNameFT->hide();
diff --git a/sw/source/uibase/inc/regionsw.hxx 
b/sw/source/uibase/inc/regionsw.hxx
index 410b9d6db8a7..ad425df898e5 100644
--- a/sw/source/uibase/inc/regionsw.hxx
+++ b/sw/source/uibase/inc/regionsw.hxx
@@ -77,6 +77,7 @@ class SwEditRegionDlg final : public SfxDialogController
     std::unique_ptr<weld::Button> m_xOptionsPB;
     std::unique_ptr<weld::Button> m_xDismiss;
     std::unique_ptr<weld::Widget> m_xHideFrame;
+    std::unique_ptr<weld::Frame> m_xLinkFrame;
 
     void    RecurseList(const SwSectionFormat* pFormat, const weld::TreeIter* 
pIter);
     size_t  FindArrPos(const SwSectionFormat* pFormat);
diff --git a/sw/uiconfig/swriter/ui/editsectiondialog.ui 
b/sw/uiconfig/swriter/ui/editsectiondialog.ui
index 3a571100684f..2c358fa69fa5 100644
--- a/sw/uiconfig/swriter/ui/editsectiondialog.ui
+++ b/sw/uiconfig/swriter/ui/editsectiondialog.ui
@@ -237,7 +237,7 @@
                 <property name="row_spacing">12</property>
                 <property name="column_spacing">12</property>
                 <child>
-                  <object class="GtkFrame" id="frame2">
+                  <object class="GtkFrame" id="linkframe">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="hexpand">True</property>
commit 85ab8d8c6c138fe2f28a65d682b38205d124c7ef
Author:     Méven Car <[email protected]>
AuthorDate: Tue Jan 9 15:15:23 2024 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Jan 15 20:08:10 2024 +0100

    cool#1770 sw: make Edit Sections dialog async and mark it a jsdialog
    
    We want our dialogs to be async so they don't lock documents when opened
    and to allow concurrent edition.
    
    In SwEditRegionDlg, we need to make sure the reference to the SwWrtShell
    isn't read from 'this' after `response()`, as it is now the dialog is 
disposed of earlier in the async case.
    
    How to test: Create a new Writer document, insert a section, right-click 
inside the section, pick the 'edit section' menu item to trigger this dialog.
    
    Change-Id: Ibafca69542f13d16beef5a8fca006428cbcfe5c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161828
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index daf0dd6ff3f1..fbe9d4a5d9ed 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -307,6 +307,11 @@ short AbstractEditRegionDlg_Impl::Execute()
     return m_xDlg->run();
 }
 
+bool AbstractEditRegionDlg_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+    return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractInsertSectionTabDialog_Impl::Execute()
 {
     return m_xDlg->run();
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index d5c1c43806d8..c2c043bb3eb6 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -663,6 +663,7 @@ public:
     {
     }
     virtual short Execute() override;
+    virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void    SelectSection(const OUString& rSectionName) override;
 };
 
diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index f0318a4cafe3..fd61903a0068 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -818,12 +818,15 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, 
void)
 
     aOrigArray.clear();
 
+    SwWrtShell& rSh = m_rSh;
+
     // response must be called ahead of EndAction's end,
     // otherwise ScrollError can occur.
     m_xDialog->response(RET_OK);
 
-    m_rSh.EndUndo();
-    m_rSh.EndAllAction();
+    // accessing 'this' after response isn't safe, as the callback might cause 
the dialog to be disposed
+    rSh.EndUndo();
+    rSh.EndAllAction();
 }
 
 // Toggle protect
diff --git a/sw/source/uibase/dialog/regionsw.cxx 
b/sw/source/uibase/dialog/regionsw.cxx
index 9eaa64c89456..71f0c165b458 100644
--- a/sw/source/uibase/dialog/regionsw.cxx
+++ b/sw/source/uibase/dialog/regionsw.cxx
@@ -217,15 +217,17 @@ void SwBaseShell::EditRegionDialog(SfxRequest const & 
rReq)
         case FN_EDIT_CURRENT_REGION:
         {
             weld::Window* pParentWin = GetView().GetFrameWeld();
+
+            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+            VclPtr<AbstractEditRegionDlg> 
pEditRegionDlg(pFact->CreateEditRegionDlg(pParentWin, rWrtShell));
+
+            if(auto pStringItem = dynamic_cast< const SfxStringItem *>( pItem 
))
             {
-                SwAbstractDialogFactory* pFact = 
SwAbstractDialogFactory::Create();
-                ScopedVclPtr<AbstractEditRegionDlg> 
pEditRegionDlg(pFact->CreateEditRegionDlg(pParentWin, rWrtShell));
-                if(auto pStringItem = dynamic_cast< const SfxStringItem *>( 
pItem ))
-                {
-                    pEditRegionDlg->SelectSection(pStringItem->GetValue());
-                }
-                pEditRegionDlg->Execute();
+                pEditRegionDlg->SelectSection(pStringItem->GetValue());
             }
+            pEditRegionDlg->StartExecuteAsync([pEditRegionDlg](sal_Int32 
/*nResult */){
+                pEditRegionDlg->disposeOnce();
+            });
         }
         break;
     }
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 058880a97835..c8ed0d73efad 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -178,6 +178,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
         || rUIFile == u"modules/swriter/ui/contentcontrollistitemdlg.ui"
         || rUIFile == u"modules/swriter/ui/dropcapspage.ui"
         || rUIFile == u"modules/swriter/ui/dropdownfielddialog.ui"
+        || rUIFile == u"modules/swriter/ui/editsectiondialog.ui"
         || rUIFile == u"modules/swriter/ui/endnotepage.ui"
         || rUIFile == u"modules/swriter/ui/footendnotedialog.ui"
         || rUIFile == u"modules/swriter/ui/footnoteareapage.ui"
commit b3de15a0b56ea59095d564678dd83eb07918c723
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Wed Jan 3 19:32:25 2024 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Jan 15 20:00:40 2024 +0100

    sw: search for alternative weights when embeding on docx
    
    Sometimes a docx document might come whith a font with niether normal
    or bold weight embedded as regular, so when embedding a font in docx
    search for alternative weights if neither a normal or bold matching
    font has been found.
    
    Change-Id: I95cf2634c392cec6e97e5dd12a90de6e50228ac1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161596
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Ashod Nakashian <[email protected]>
    (cherry picked from commit 96d52b9e6879df3ab9697a7c0322cda5e08eb9af)

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index d84549d43066..2bd25dba7b5e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7354,10 +7354,16 @@ void DocxAttributeOutput::EmbedFont( 
std::u16string_view name, FontFamily family
 {
     if( !m_rExport.m_rDoc.getIDocumentSettingAccess().get( 
DocumentSettingId::EMBED_FONTS ))
         return; // no font embedding with this document
-    EmbedFontStyle( name, XML_embedRegular, family, ITALIC_NONE, 
WEIGHT_NORMAL, pitch );
-    EmbedFontStyle( name, XML_embedBold, family, ITALIC_NONE, WEIGHT_BOLD, 
pitch );
-    EmbedFontStyle( name, XML_embedItalic, family, ITALIC_NORMAL, 
WEIGHT_NORMAL, pitch );
-    EmbedFontStyle( name, XML_embedBoldItalic, family, ITALIC_NORMAL, 
WEIGHT_BOLD, pitch );
+    bool foundFont
+        = EmbedFontStyle(name, XML_embedRegular, family, ITALIC_NONE, 
WEIGHT_NORMAL, pitch);
+    foundFont
+        = EmbedFontStyle(name, XML_embedBold, family, ITALIC_NONE, 
WEIGHT_BOLD, pitch) || foundFont;
+    foundFont = EmbedFontStyle(name, XML_embedItalic, family, ITALIC_NORMAL, 
WEIGHT_NORMAL, pitch)
+                || foundFont;
+    foundFont = EmbedFontStyle(name, XML_embedBoldItalic, family, 
ITALIC_NORMAL, WEIGHT_BOLD, pitch)
+                || foundFont;
+    if (!foundFont)
+        EmbedFontStyle(name, XML_embedRegular, family, ITALIC_NONE, 
WEIGHT_DONTKNOW, pitch);
 }
 
 static char toHexChar( int value )
@@ -7365,21 +7371,21 @@ static char toHexChar( int value )
     return value >= 10 ? value + 'A' - 10 : value + '0';
 }
 
-void DocxAttributeOutput::EmbedFontStyle( std::u16string_view name, int tag, 
FontFamily family, FontItalic italic,
-    FontWeight weight, FontPitch pitch )
+bool DocxAttributeOutput::EmbedFontStyle(std::u16string_view name, int tag, 
FontFamily family,
+                                         FontItalic italic, FontWeight weight, 
FontPitch pitch)
 {
     // Embed font if at least viewing is allowed (in which case the opening 
app must check
     // the font license rights too and open either read-only or not use the 
font for editing).
     OUString fontUrl = EmbeddedFontsHelper::fontFileUrl( name, family, italic, 
weight, pitch,
         EmbeddedFontsHelper::FontRights::ViewingAllowed );
     if( fontUrl.isEmpty())
-        return;
+        return false;
     // TODO IDocumentSettingAccess::EMBED_SYSTEM_FONTS
     if( !m_FontFilesMap.count( fontUrl ))
     {
         osl::File file( fontUrl );
         if( file.open( osl_File_OpenFlag_Read ) != osl::File::E_None )
-            return;
+            return false;
         uno::Reference< css::io::XOutputStream > xOutStream = 
m_rExport.GetFilter().openFragmentStream(
             "word/fonts/font" + OUString::number(m_nextFontId) + ".odttf",
             "application/vnd.openxmlformats-officedocument.obfuscatedFont" );
@@ -7398,7 +7404,7 @@ void DocxAttributeOutput::EmbedFontStyle( 
std::u16string_view name, int tag, Fon
         {
             SAL_WARN( "sw.ww8", "Font file size too small (" << fontUrl << ")" 
);
             xOutStream->closeOutput();
-            return;
+            return false;
         }
         for( int i = 0;
              i < 16;
@@ -7415,7 +7421,7 @@ void DocxAttributeOutput::EmbedFontStyle( 
std::u16string_view name, int tag, Fon
             {
                 SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
                 xOutStream->closeOutput();
-                return;
+                return false;
             }
             if( eof )
                 break;
@@ -7423,7 +7429,7 @@ void DocxAttributeOutput::EmbedFontStyle( 
std::u16string_view name, int tag, Fon
             {
                 SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
                 xOutStream->closeOutput();
-                return;
+                return false;
             }
             if( readSize == 0 )
                 break;
@@ -7443,6 +7449,7 @@ void DocxAttributeOutput::EmbedFontStyle( 
std::u16string_view name, int tag, Fon
     m_pSerializer->singleElementNS( XML_w, tag,
         FSNS( XML_r, XML_id ), m_FontFilesMap[ fontUrl ].relId,
         FSNS( XML_w, XML_fontKey ), m_FontFilesMap[ fontUrl ].fontKey );
+    return true;
 }
 
 OString DocxAttributeOutput::TransHighlightColor( sal_uInt8 nIco )
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 28eb32caf884..10f39debc2a0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -512,7 +512,7 @@ private:
     void WriteFFData( const FieldInfos& rInfos );
     void WritePendingPlaceholder();
 
-    void EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, 
FontItalic italic, FontWeight weight,
+    bool EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, 
FontItalic italic, FontWeight weight,
         FontPitch pitch );
 
     /**

Reply via email to