desktop/source/deployment/registry/configuration/dp_configuration.cxx |   36 
------
 include/rtl/xmlencode.hxx                                             |   55 
++++++++++
 sd/source/filter/html/htmlex.cxx                                      |    5 
 sw/source/filter/html/css1atr.cxx                                     |    3 
 sw/source/filter/html/htmlfldw.cxx                                    |    3 
 sw/source/ui/dialog/uiregionsw.cxx                                    |   29 
+++++
 vcl/source/gdi/pdfwriter_impl.cxx                                     |   50 
+--------
 7 files changed, 100 insertions(+), 81 deletions(-)

New commits:
commit 1a5423d3b04ba540229f8532d386cca637f5ce57
Author:     Szymon Kłos <[email protected]>
AuthorDate: Fri Apr 7 19:03:55 2023 +0200
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Apr 7 19:59:14 2023 +0200

    lok: Hide file linking in section
    
    this is followup for 6f56317
    
    Change-Id: I87227b3e665a6d15378ee294556bcd2f95801e6b

diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index 8480ba52b680..44ce60cd531f 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -402,6 +402,19 @@ SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, 
SwWrtShell& rWrtSh)
 
     m_xTree->show();
     bDontCheckPasswd = false;
+
+    if(comphelper::LibreOfficeKit::isActive())
+    {
+        m_xBuilder->weld_label("label8")->hide(); // Link
+        m_xFileCB->hide();
+        m_xDDECB->hide();
+        m_xDDECommandFT->hide();
+        m_xFileNameFT->hide();
+        m_xFileNameED->hide();
+        m_xFilePB->hide();
+        m_xSubRegionFT->hide();
+        m_xSubRegionED->hide();
+    }
 }
 
 bool SwEditRegionDlg::CheckPasswd(weld::ToggleButton* pBox)
commit d6d5b73af9bc353bbacda51943b4cbb66ee7baba
Author:     Andras Timar <[email protected]>
AuthorDate: Thu Nov 24 13:37:36 2022 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Apr 7 19:59:00 2023 +0200

    Disallow linking files as Writer sections in Online
    
    Change-Id: I9e4971c72db44ca8216ac468240dd52d46e0b680
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143225
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Henry Castro <[email protected]>

diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index e4147262859e..8480ba52b680 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -34,6 +34,7 @@
 #include <sfx2/filedlghelper.hxx>
 #include <editeng/sizeitem.hxx>
 #include <svtools/htmlcfg.hxx>
+#include <comphelper/lok.hxx>
 
 #include <uitool.hxx>
 #include <IMark.hxx>
@@ -1509,6 +1510,21 @@ 
SwInsertSectionTabPage::SwInsertSectionTabPage(weld::Container* pPage, weld::Dia
     m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
     ChangeProtectHdl(*m_xProtectCB);
     m_xSubRegionED->set_entry_completion(true, true);
+
+    // Hide Link section. In general it makes no sense to insert a file from 
the jail,
+    // because it does not contain any usable files (documents).
+    if(comphelper::LibreOfficeKit::isActive())
+    {
+        m_xBuilder->weld_label("label1")->hide(); // Link
+        m_xFileCB->hide();
+        m_xDDECB->hide();
+        m_xDDECommandFT->hide();
+        m_xFileNameFT->hide();
+        m_xFileNameED->hide();
+        m_xFilePB->hide();
+        m_xSubRegionFT->hide();
+        m_xSubRegionED->hide();
+    }
 }
 
 SwInsertSectionTabPage::~SwInsertSectionTabPage()
commit ba096ccb16f7b0e801dd7dc2d0910f3e25c6977f
Author:     Szymon Kłos <[email protected]>
AuthorDate: Fri Apr 7 09:48:41 2023 +0200
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Apr 7 19:51:32 2023 +0200

    Make encodeForXml accessible for other modules
    
    and share similar code
    
    Change-Id: I7729a46d40845893f577c273c1ab340f69ebb51b

diff --git 
a/desktop/source/deployment/registry/configuration/dp_configuration.cxx 
b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index 40d0ee9c8b3c..241d466c5fd9 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -33,6 +33,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/uri.hxx>
 #include <osl/file.hxx>
+#include <rtl/xmlencode.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <ucbhelper/content.hxx>
 #include <unotools/ucbhelper.hxx>
@@ -554,39 +555,6 @@ BackendImpl::PackageImpl::isRegistered_(
 }
 
 
-OUString encodeForXml( OUString const & text )
-{
-    // encode conforming xml:
-    sal_Int32 len = text.getLength();
-    OUStringBuffer buf;
-    for ( sal_Int32 pos = 0; pos < len; ++pos )
-    {
-        sal_Unicode c = text[ pos ];
-        switch (c) {
-        case '<':
-            buf.append( "&lt;" );
-            break;
-        case '>':
-            buf.append( "&gt;" );
-            break;
-        case '&':
-            buf.append( "&amp;" );
-            break;
-        case '\'':
-            buf.append( "&apos;" );
-            break;
-        case '\"':
-            buf.append( "&quot;" );
-            break;
-        default:
-            buf.append( c );
-            break;
-        }
-    }
-    return buf.makeStringAndClear();
-}
-
-
 OUString replaceOrigin(
     OUString const & url, OUString const & destFolder, Reference< 
XCommandEnvironment > const & xCmdEnv, Reference< XComponentContext > const & 
xContext, bool & out_replaced)
 {
@@ -639,7 +607,7 @@ OUString replaceOrigin(
             if (origin.isEmpty()) {
                 // encode only once
                 origin = OUStringToOString(
-                    encodeForXml( url.copy( 0, url.lastIndexOf( '/' ) ) ),
+                    rtl::encodeForXml( url.copy( 0, url.lastIndexOf( '/' ) ) ),
                     // xxx todo: encode always for UTF-8? => lookup doc-header?
                     RTL_TEXTENCODING_UTF8 );
             }
diff --git a/include/rtl/xmlencode.hxx b/include/rtl/xmlencode.hxx
new file mode 100644
index 000000000000..487c4ee94749
--- /dev/null
+++ b/include/rtl/xmlencode.hxx
@@ -0,0 +1,55 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_RTL_XMLENCODE_HXX
+#define INCLUDED_RTL_XMLENCODE_HXX
+
+#include "rtl/ustring.hxx"
+
+namespace rtl
+{
+inline OUString encodeForXml(std::u16string_view rStr)
+{
+    // encode conforming xml:
+    sal_Int32 len = rStr.length();
+    OUStringBuffer buf;
+    for (sal_Int32 pos = 0; pos < len; ++pos)
+    {
+        sal_Unicode c = rStr[pos];
+        switch (c)
+        {
+            case '<':
+                buf.append("&lt;");
+                break;
+            case '>':
+                buf.append("&gt;");
+                break;
+            case '&':
+                buf.append("&amp;");
+                break;
+            case '\'':
+                buf.append("&apos;");
+                break;
+            case '\"':
+                buf.append("&quot;");
+                break;
+            default:
+                buf.append(c);
+                break;
+        }
+    }
+
+    return buf.makeStringAndClear();
+}
+
+} /* Namespace */
+
+#endif // INCLUDED_RTL_XMLENCODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index ad8e2a97eae6..db04442f9830 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
 
+#include <rtl/xmlencode.hxx>
 #include <sal/log.hxx>
 #include <rtl/tencinfo.h>
 #include <comphelper/processfactory.hxx>
@@ -281,10 +282,10 @@ OUString HtmlState::SetLink( const OUString& aLink, const 
OUString& aTarget )
 
     if (!aLink.isEmpty())
     {
-        aStr += "<a href=\"" + aLink;
+        aStr += "<a href=\"" + rtl::encodeForXml(aLink);
         if (!aTarget.isEmpty())
         {
-            aStr += "\" target=\"" + aTarget;
+            aStr += "\" target=\"" + rtl::encodeForXml(aTarget);
         }
         aStr += "\">";
         mbLink = true;
diff --git a/sw/source/filter/html/css1atr.cxx 
b/sw/source/filter/html/css1atr.cxx
index 62b0071e13c3..26abd886e42f 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -93,6 +93,7 @@
 #include <o3tl/typed_flags_set.hxx>
 
 #include <rtl/strbuf.hxx>
+#include <rtl/xmlencode.hxx>
 
 using namespace css;
 using editeng::SvxBorderLine;
@@ -1099,7 +1100,7 @@ void SwHTMLWriter::PrepareFontList( const SvxFontItem& 
rFontItem,
         while( nStrPos != -1 )
         {
             OUString aName = rName.getToken( 0, ';', nStrPos );
-            aName = comphelper::string::strip(aName, ' ');
+            aName = rtl::encodeForXml(comphelper::string::strip(aName, ' '));
             if( aName.isEmpty() )
                 continue;
 
diff --git a/sw/source/filter/html/htmlfldw.cxx 
b/sw/source/filter/html/htmlfldw.cxx
index 2f153fdd3b79..e93499799a74 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -23,6 +23,7 @@
 #include <svtools/htmlkywd.hxx>
 #include <svtools/htmlout.hxx>
 #include <svtools/htmltokn.h>
+#include <rtl/xmlencode.hxx>
 #include <osl/diagnose.h>
 #include <fmtfld.hxx>
 #include <doc.hxx>
@@ -513,7 +514,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const 
SfxPoolItem& rHt )
             OString sOut =
                 "<" OOO_STRING_SVTOOLS_HTML_comment
                 " " +
-                OUStringToOString(sComment, 
static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
+                OUStringToOString(rtl::encodeForXml(sComment), 
static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
                 " -->";
             rWrt.Strm().WriteOString( sOut );
         }
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 1d10f377c0d0..5d2fbf6a6b13 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -45,6 +45,7 @@
 #include <osl/thread.h>
 #include <rtl/digest.h>
 #include <rtl/ustrbuf.hxx>
+#include <rtl/xmlencode.hxx>
 #include <sal/log.hxx>
 #include <svl/urihelper.hxx>
 #include <tools/fract.hxx>
@@ -5325,37 +5326,6 @@ sal_Int32 PDFWriterImpl::emitOutputIntent()
     return nOIObject;
 }
 
-// formats the string for the XML stream
-static void escapeStringXML( const OUString& rStr, OUString &rValue)
-{
-    const sal_Unicode* pUni = rStr.getStr();
-    int nLen = rStr.getLength();
-    for( ; nLen; nLen--, pUni++ )
-    {
-        switch( *pUni )
-        {
-        case u'&':
-            rValue += "&amp;";
-        break;
-        case u'<':
-            rValue += "&lt;";
-        break;
-        case u'>':
-            rValue += "&gt;";
-        break;
-        case u'\'':
-            rValue += "&apos;";
-        break;
-        case u'"':
-            rValue += "&quot;";
-        break;
-        default:
-            rValue += OUStringChar( *pUni );
-            break;
-        }
-    }
-}
-
 // emits the document metadata
 sal_Int32 PDFWriterImpl::emitDocumentMetadata()
 {
@@ -5404,8 +5374,7 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
                 aMetadataStream.append( "   <dc:title>\n" );
                 aMetadataStream.append( "    <rdf:Alt>\n" );
                 aMetadataStream.append( "     <rdf:li xml:lang=\"x-default\">" 
);
-                OUString aTitle;
-                escapeStringXML( m_aContext.DocumentInfo.Title, aTitle );
+                OUString aTitle = rtl::encodeForXml( 
m_aContext.DocumentInfo.Title );
                 aMetadataStream.append( OUStringToOString( aTitle, 
RTL_TEXTENCODING_UTF8 )  );
                 aMetadataStream.append( "</rdf:li>\n" );
                 aMetadataStream.append( "    </rdf:Alt>\n" );
@@ -5416,8 +5385,7 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
                 aMetadataStream.append( "   <dc:creator>\n" );
                 aMetadataStream.append( "    <rdf:Seq>\n" );
                 aMetadataStream.append( "     <rdf:li>" );
-                OUString aAuthor;
-                escapeStringXML( m_aContext.DocumentInfo.Author, aAuthor );
+                OUString aAuthor = rtl::encodeForXml( 
m_aContext.DocumentInfo.Author );
                 aMetadataStream.append( OUStringToOString( aAuthor , 
RTL_TEXTENCODING_UTF8 )  );
                 aMetadataStream.append( "</rdf:li>\n" );
                 aMetadataStream.append( "    </rdf:Seq>\n" );
@@ -5429,8 +5397,7 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
                 aMetadataStream.append( "   <dc:description>\n" );
                 aMetadataStream.append( "    <rdf:Alt>\n" );
                 aMetadataStream.append( "     <rdf:li xml:lang=\"x-default\">" 
);
-                OUString aSubject;
-                escapeStringXML( m_aContext.DocumentInfo.Subject, aSubject );
+                OUString aSubject = rtl::encodeForXml( 
m_aContext.DocumentInfo.Subject );
                 aMetadataStream.append( OUStringToOString( aSubject , 
RTL_TEXTENCODING_UTF8 )  );
                 aMetadataStream.append( "</rdf:li>\n" );
                 aMetadataStream.append( "    </rdf:Alt>\n" );
@@ -5448,16 +5415,14 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
             if( !m_aContext.DocumentInfo.Producer.isEmpty() )
             {
                 aMetadataStream.append( "   <pdf:Producer>" );
-                OUString aProducer;
-                escapeStringXML( m_aContext.DocumentInfo.Producer, aProducer );
+                OUString aProducer = rtl::encodeForXml( 
m_aContext.DocumentInfo.Producer );
                 aMetadataStream.append( OUStringToOString( aProducer , 
RTL_TEXTENCODING_UTF8 )  );
                 aMetadataStream.append( "</pdf:Producer>\n" );
             }
             if( !m_aContext.DocumentInfo.Keywords.isEmpty() )
             {
                 aMetadataStream.append( "   <pdf:Keywords>" );
-                OUString aKeywords;
-                escapeStringXML( m_aContext.DocumentInfo.Keywords, aKeywords );
+                OUString aKeywords = rtl::encodeForXml( 
m_aContext.DocumentInfo.Keywords );
                 aMetadataStream.append( OUStringToOString( aKeywords , 
RTL_TEXTENCODING_UTF8 )  );
                 aMetadataStream.append( "</pdf:Keywords>\n" );
             }
@@ -5469,8 +5434,7 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
         if( !m_aContext.DocumentInfo.Creator.isEmpty() )
         {
             aMetadataStream.append( "   <xmp:CreatorTool>" );
-            OUString aCreator;
-            escapeStringXML( m_aContext.DocumentInfo.Creator, aCreator );
+            OUString aCreator = rtl::encodeForXml( 
m_aContext.DocumentInfo.Creator );
             aMetadataStream.append( OUStringToOString( aCreator , 
RTL_TEXTENCODING_UTF8 )  );
             aMetadataStream.append( "</xmp:CreatorTool>\n" );
         }

Reply via email to