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 | 39 ------- 7 files changed, 97 insertions(+), 73 deletions(-)
New commits: commit 809030c497d9c8280a14e4b5915228a329b323c6 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Apr 7 19:03:55 2023 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Apr 7 19:37:47 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 a5492545d74a..a7e10e44d364 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -395,6 +395,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 47e000b9289e0e37e1c2f5064064932ecd320152 Author: Andras Timar <andras.ti...@collabora.com> AuthorDate: Thu Nov 24 13:37:36 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Apr 7 19:37:17 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index d9ba3fcbb9ab..a5492545d74a 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> @@ -1478,6 +1479,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 cb00ec7cbfc7900c3a31e7fdc4916668a1fa4c11 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Apr 7 09:48:41 2023 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Apr 7 19:33:46 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 578e164f13b7..ae9aaae51138 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -30,6 +30,7 @@ #include <rtl/string.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/xmlencode.hxx> #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/supportsservice.hxx> #include <ucbhelper/content.hxx> @@ -566,39 +567,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( "<" ); - break; - case '>': - buf.append( ">" ); - break; - case '&': - buf.append( "&" ); - break; - case '\'': - buf.append( "'" ); - break; - case '\"': - buf.append( """ ); - 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) { @@ -651,7 +619,7 @@ OUString replaceOrigin( if (origin.isEmpty()) { // encode only once origin = OUStringToOString( - encodeForXml( url.copy( 0, url.lastIndexOf( '/' ) ) ), + rtl::encodeForXml( url.subView( 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("<"); + break; + case '>': + buf.append(">"); + break; + case '&': + buf.append("&"); + break; + case '\'': + buf.append("'"); + break; + case '\"': + buf.append("""); + 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 7b1efa7e14b5..5cc1a3ca32f5 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <rtl/xmlencode.hxx> #include <sal/log.hxx> #include <rtl/tencinfo.h> #include <comphelper/processfactory.hxx> @@ -287,10 +288,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 c401d95a788f..cbf98227a02d 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; @@ -1114,7 +1115,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 825d563a9f39..391331d6538d 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -21,6 +21,7 @@ #include <comphelper/string.hxx> #include <svtools/htmlkywd.hxx> #include <svtools/htmlout.hxx> +#include <rtl/xmlencode.hxx> #include <osl/diagnose.h> #include <fmtfld.hxx> #include <doc.hxx> @@ -512,7 +513,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 3e934a19825d..7b1927a65edf 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -47,6 +47,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> @@ -5192,43 +5193,11 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() return nOIObject; } -// formats the string for the XML stream -static void escapeStringXML( const OUString& rStr, OUString &rValue) +static void lcl_assignMeta(std::u16string_view aValue, OString& aMeta) { - const sal_Unicode* pUni = rStr.getStr(); - int nLen = rStr.getLength(); - for( ; nLen; nLen--, pUni++ ) + if (!aValue.empty()) { - switch( *pUni ) - { - case u'&': - rValue += "&"; - break; - case u'<': - rValue += "<"; - break; - case u'>': - rValue += ">"; - break; - case u'\'': - rValue += "'"; - break; - case u'"': - rValue += """; - break; - default: - rValue += OUStringChar( *pUni ); - break; - } - } -} - -static void lcl_assignMeta(const OUString& aValue, OString& aMeta) -{ - if (!aValue.isEmpty()) - { - OUString aTempString; - escapeStringXML(aValue, aTempString); + OUString aTempString = rtl::encodeForXml(aValue); aMeta = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8); } }