[Libreoffice-commits] core.git: sax/source

2023-10-20 Thread Stephan Bergmann (via logerrit)
 sax/source/fastparser/legacyfastparser.cxx |4 ++--
 sax/source/tools/fastserializer.cxx|2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 68486cc18e3b7fcfa97b472184ede43a76c2be15
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:24 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 09:16:44 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: sax

Change-Id: I16c763164567293b096e132650c509cfc32fd407
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158215
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/fastparser/legacyfastparser.cxx 
b/sax/source/fastparser/legacyfastparser.cxx
index 62e7b8a57a88..e7afc55d9327 100644
--- a/sax/source/fastparser/legacyfastparser.cxx
+++ b/sax/source/fastparser/legacyfastparser.cxx
@@ -131,8 +131,8 @@ private:
 OUString getNamespacePrefixFromToken( sal_Int32 nToken );
 OUString getNameFromToken( sal_Int32 nToken );
 
-static constexpr OUStringLiteral aDefaultNamespace = u"";
-static constexpr OUStringLiteral aNamespaceSeparator = u":";
+static constexpr OUString aDefaultNamespace = u""_ustr;
+static constexpr OUString aNamespaceSeparator = u":"_ustr;
 
 public:
 CallbackDocumentHandler( Reference< XDocumentHandler > const & 
xDocumentHandler,
diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 50408e4dc284..0a5c227b7210 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -47,7 +47,7 @@ using ::com::sun::star::io::XOutputStream;
 
 const char sClosingBracket[] = ">";
 const char sSlashAndClosingBracket[] = "/>";
-constexpr OStringLiteral sColon = ":";
+constexpr OString sColon = ":"_ostr;
 const char sOpeningBracket[] = "<";
 const char sOpeningBracketAndSlash[] = "

[Libreoffice-commits] core.git: sax/source

2023-04-12 Thread Bayram Çiçek (via logerrit)
 sax/source/tools/converter.cxx |   34 --
 1 file changed, 4 insertions(+), 30 deletions(-)

New commits:
commit 9bee4cec215e2694f6e6e1aa4a463b47b69cc1ff
Author: Bayram Çiçek 
AuthorDate: Tue Apr 11 22:46:12 2023 +0300
Commit: Mike Kaganski 
CommitDate: Wed Apr 12 14:45:51 2023 +0200

tdf#39593: remove trim(), use o3tl::trim() instead

trim(std::u16string_view in) and trim(std::string_view in)
functions were removed and replaced with
o3tl::trim(rString) function

Change-Id: I29b2274422dbfe9dc26177c3e1dbf20786c811d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150245
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index e9ef4494c5de..818d04a9bd1a 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -913,32 +913,6 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
 rBuffer.append( 'S');
 }
 
-static std::u16string_view trim(std::u16string_view in) {
-  auto left = in.begin();
-  for (;; ++left) {
-if (left == in.end())
-  return std::u16string_view();
-if (!isspace(*left))
-  break;
-  }
-  auto right = in.end() - 1;
-  for (; right > left && isspace(*right); --right);
-  return std::u16string_view(&*left, std::distance(left, right) + 1);
-}
-
-static std::string_view trim(std::string_view in) {
-  auto left = in.begin();
-  for (;; ++left) {
-if (left == in.end())
-  return std::string_view();
-if (!isspace(*left))
-  break;
-  }
-  auto right = in.end() - 1;
-  for (; right > left && isspace(*right); --right);
-  return std::string_view(&*left, std::distance(left, right) + 1);
-}
-
 /** helper function of Converter::convertDuration */
 template
 static bool convertDurationHelper(double& rfTime, V pStr)
@@ -1068,7 +1042,7 @@ static bool convertDurationHelper(double& rfTime, V pStr)
 bool Converter::convertDuration(double& rfTime,
 std::string_view rString)
 {
-std::string_view aTrimmed = trim(rString);
+std::string_view aTrimmed = o3tl::trim(rString);
 const char* pStr = aTrimmed.data();
 
 return convertDurationHelper(rfTime, pStr);
@@ -1429,14 +1403,14 @@ static bool convertDurationHelper(util::Duration& 
rDuration, V string)
 bool Converter::convertDuration(util::Duration& rDuration,
 std::u16string_view rString)
 {
-return convertDurationHelper(rDuration, trim(rString));
+return convertDurationHelper(rDuration, o3tl::trim(rString));
 }
 
 /** convert ISO8601 "duration" string to util::Duration */
 bool Converter::convertDuration(util::Duration& rDuration,
 std::string_view rString)
 {
-return convertDurationHelper(rDuration, trim(rString));
+return convertDurationHelper(rDuration, o3tl::trim(rString));
 }
 
 static void
@@ -1824,7 +1798,7 @@ static bool lcl_parseDateTime(
 {
 bool bSuccess = true;
 
-string = trim(string);
+string = o3tl::trim(string);
 
 bool isNegative(false);
 sal_Int32 nYear(0);


[Libreoffice-commits] core.git: sax/source sdext/source sd/source starmath/source stoc/source svl/source svtools/source svx/source sw/source

2023-02-16 Thread Gabor Kelemen (via logerrit)
 sax/source/expatwrap/sax_expat.cxx  |3 +--
 sax/source/expatwrap/saxwriter.cxx  |1 -
 sd/source/console/PresenterBitmapContainer.cxx  |1 -
 sd/source/console/PresenterTheme.cxx|7 +++
 sd/source/ui/dlg/RemoteDialog.cxx   |1 -
 sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx|1 -
 sd/source/ui/unoidl/DrawController.cxx  |1 -
 sd/source/ui/view/frmview.cxx   |1 -
 sdext/source/minimizer/impoptimizer.cxx |5 ++---
 starmath/source/unomodel.cxx|3 +--
 stoc/source/invocation_adapterfactory/iafactory.cxx |3 +--
 stoc/source/security/access_controller.cxx  |7 +++
 stoc/source/security/permissions.cxx|3 +--
 svl/source/numbers/zforlist.cxx |1 -
 svtools/source/control/scriptedtext.cxx |   13 ++---
 svx/source/items/customshapeitem.cxx|1 -
 sw/source/core/unocore/unoportenum.cxx  |1 -
 sw/source/filter/xml/xmlimp.cxx |1 -
 sw/source/ui/config/optcomp.cxx |1 -
 sw/source/uibase/utlui/content.cxx  |   11 +--
 20 files changed, 23 insertions(+), 43 deletions(-)

New commits:
commit 79176694ddc7bce40ce2b82d3f332be8642a5167
Author: Gabor Kelemen 
AuthorDate: Tue Feb 14 23:34:19 2023 +0100
Commit: Gabor Kelemen 
CommitDate: Thu Feb 16 08:14:21 2023 +

Drop 'using namespace ::std' in dirs s*

Change-Id: If3119a1f2274aac0bf70576458e3adb4505a2a45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147076
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index 146a8c4193db..d6d63fb654bd 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -45,7 +45,6 @@
 
 #include 
 
-using namespace ::std;
 using namespace ::osl;
 using namespace ::cppu;
 using namespace ::com::sun::star::lang;
@@ -160,7 +159,7 @@ public: // module scope
 rtl::Reference < comphelper::AttributeList > rAttrList;
 
 // External entity stack
-vector   vecEntity;
+std::vector   vecEntity;
 void pushEntity( Entity &&entity )
 { vecEntity.push_back( std::move(entity) ); }
 void popEntity()
diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index e19a31211d98..708efc573983 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -41,7 +41,6 @@
 #include 
 #include 
 
-using namespace ::std;
 using namespace ::osl;
 using namespace ::cppu;
 using namespace ::com::sun::star::uno;
diff --git a/sd/source/console/PresenterBitmapContainer.cxx 
b/sd/source/console/PresenterBitmapContainer.cxx
index e435c8dbac69..b25dacdf1101 100644
--- a/sd/source/console/PresenterBitmapContainer.cxx
+++ b/sd/source/console/PresenterBitmapContainer.cxx
@@ -27,7 +27,6 @@
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
-using namespace ::std;
 
 namespace sdext::presenter {
 
diff --git a/sd/source/console/PresenterTheme.cxx 
b/sd/source/console/PresenterTheme.cxx
index 59c340d8627a..4ea59a5fa8cd 100644
--- a/sd/source/console/PresenterTheme.cxx
+++ b/sd/source/console/PresenterTheme.cxx
@@ -30,7 +30,6 @@
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
-using namespace ::std;
 
 namespace sdext::presenter {
 
@@ -51,7 +50,7 @@ public:
 sal_Int32 mnRight;
 sal_Int32 mnBottom;
 
-vector ToVector()
+std::vector ToVector()
 {
 return
 {
@@ -199,7 +198,7 @@ public:
 OUString GetStyleName (const OUString& rsResourceName) const;
 
 private:
-typedef map StyleAssociations;
+typedef std::map StyleAssociations;
 StyleAssociations maStyleAssociations;
 
 void ProcessStyleAssociation(
@@ -227,7 +226,7 @@ public:
 StyleAssociationContainer maStyleAssociations;
 Reference mxThemeRoot;
 std::shared_ptr mpIconContainer;
-typedef map FontContainer;
+typedef std::map FontContainer;
 FontContainer maFontContainer;
 
 SharedPaneStyle GetPaneStyle (const OUString& rsStyleName) const;
diff --git a/sd/source/ui/dlg/RemoteDialog.cxx 
b/sd/source/ui/dlg/RemoteDialog.cxx
index e28f57ecdecc..411e4ea621bc 100644
--- a/sd/source/ui/dlg/RemoteDialog.cxx
+++ b/sd/source/ui/dlg/RemoteDialog.cxx
@@ -11,7 +11,6 @@
 #include 
 
 using namespace ::sd;
-using namespace ::std;
 
 RemoteDialog::RemoteDialog(weld::Window* pWindow)
 : GenericDialogController(pWindow, "modules/simpress/ui/remotedialog.ui", 
"RemoteDialog")
diff --git a/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx 
b/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx
index 268658823423..8e3fcff143a4 100644
--- a/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx
+++ b/sd/source/ui/sidebar/Recently

[Libreoffice-commits] core.git: sax/source

2022-10-20 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit a2b404871d609cf0c36cc9f204b5aeaa214eb2d0
Author: Noel Grandin 
AuthorDate: Thu Oct 20 14:20:33 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 20 17:48:49 2022 +0200

remove comment

that no longer makes sense after
commit 25a7b268555d73248594b9d485b69cd0e4cf34cf (HEAD -> master)
Author: Noel Grandin 
Date:   Thu Oct 20 12:47:39 2022 +0200
SAL_WARN->SAL_INFO in sax

Change-Id: I298df432d61f90e558251cd1c0e8d3c220423c5d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141561
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 3d89d048b68f..aae3c1162d47 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1320,7 +1320,6 @@ void FastSaxParserImpl::addUnknownElementWithPrefix(const 
xmlChar **attributes,
 OString aQualifiedName = (rPrefix.isEmpty())? rLocalName : rPrefix + ":" + 
rLocalName;
 xAttributes->addUnknown( aNamespaceURI, aQualifiedName,
 OString( XML_CAST( attributes[ i + 3 ] ), attributes[ i + 4 ] - 
attributes[ i + 3 ] ));
-// ignore an element that otherwise generates a lot of noise in the logs
 SAL_INFO("xmloff", "unknown element " << aQualifiedName << " " << 
aNamespaceURI);
 }
 


[Libreoffice-commits] core.git: sax/source

2022-10-20 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 40753d5524d07f6bf2fbefdf90ceb3c8bd0910df
Author: Noel Grandin 
AuthorDate: Thu Oct 20 12:47:39 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 20 13:47:26 2022 +0200

SAL_WARN->SAL_INFO in sax

This does not provide any value during normal debugging

Change-Id: I6797183e64a3e7e90e1cc6b5ecdb92faa53d01d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141554
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index daf51f4ea1ee..3d89d048b68f 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1321,7 +1321,7 @@ void FastSaxParserImpl::addUnknownElementWithPrefix(const 
xmlChar **attributes,
 xAttributes->addUnknown( aNamespaceURI, aQualifiedName,
 OString( XML_CAST( attributes[ i + 3 ] ), attributes[ i + 4 ] - 
attributes[ i + 3 ] ));
 // ignore an element that otherwise generates a lot of noise in the logs
-SAL_WARN_IF(aQualifiedName != "x14ac:dyDescent", "xmloff", "unknown 
element " << aQualifiedName << " " << aNamespaceURI);
+SAL_INFO("xmloff", "unknown element " << aQualifiedName << " " << 
aNamespaceURI);
 }
 
 void FastSaxParserImpl::callbackEndElement()


[Libreoffice-commits] core.git: sax/source

2022-09-28 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b47733e5f0a16f3fc1bdaad5c3ec171f2fc35d02
Author: Noel Grandin 
AuthorDate: Wed Sep 28 08:54:35 2022 +0200
Commit: Noel Grandin 
CommitDate: Wed Sep 28 11:03:09 2022 +0200

avoid some ref-counting in a hot path

Change-Id: Ibae87fc4e2fbe11d52cd89134a253ac2215134a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140690
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 155cf656a00d..daf51f4ea1ee 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -435,7 +435,7 @@ void Entity::startElement( Event const *pEvent )
 
 try
 {
-Reference< XFastAttributeList > xAttr( pEvent->mxAttributes );
+const Reference< XFastAttributeList > & xAttr( pEvent->mxAttributes );
 Reference< XFastContextHandler > xContext;
 
 if ( mxNamespaceHandler.is() )


[Libreoffice-commits] core.git: sax/source

2022-08-18 Thread Liu Hao (via logerrit)
 sax/source/tools/converter.cxx |  168 ++---
 1 file changed, 10 insertions(+), 158 deletions(-)

New commits:
commit bef0cfcf2a6d0a70adb6ddc5558d5a888edb718c
Author: Liu Hao 
AuthorDate: Thu Aug 18 15:40:47 2022 +0800
Commit: Michael Stahl 
CommitDate: Thu Aug 18 10:55:59 2022 +0200

tdf#39593 Ruduce copy/paste code in Converter::converterDuration

Change-Id: Ic1b82b244ff614c8d5ab44f32bdc728deee24165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138465
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index b19add9c616a..ef043abd4d7d 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1267,11 +1267,9 @@ readDurationComponent(V rString,
 return true;
 }
 
-/** convert ISO8601 "duration" string to util::Duration */
-bool Converter::convertDuration(util::Duration& rDuration,
-std::u16string_view rString)
+template 
+static bool convertDurationHelper(util::Duration& rDuration, V string)
 {
-std::u16string_view string = trim(rString);
 size_t nPos(0);
 
 bool bIsNegativeDuration(false);
@@ -1429,162 +1427,16 @@ bool Converter::convertDuration(util::Duration& 
rDuration,
 
 /** convert ISO8601 "duration" string to util::Duration */
 bool Converter::convertDuration(util::Duration& rDuration,
-std::string_view rString)
+std::u16string_view rString)
 {
-std::string_view string = trim(rString);
-size_t nPos(0);
-
-bool bIsNegativeDuration(false);
-if (!string.empty() && ('-' == string[0]))
-{
-bIsNegativeDuration = true;
-++nPos;
-}
-
-if (nPos < string.size()
-&& string[nPos] != 'P' && string[nPos] != 'p') // duration must start 
with "P"
-{
-return false;
-}
-
-++nPos;
-
-/// last read number; -1 == no valid number! always reset after using!
-sal_Int32 nTemp(-1);
-bool bTimePart(false); // have we read 'T'?
-bool bSuccess(false);
-sal_Int32 nYears(0);
-sal_Int32 nMonths(0);
-sal_Int32 nDays(0);
-sal_Int32 nHours(0);
-sal_Int32 nMinutes(0);
-sal_Int32 nSeconds(0);
-sal_Int32 nNanoSeconds(0);
-
-bTimePart = readDurationT(string, nPos);
-bSuccess = (R_SUCCESS == readUnsignedNumber(string, nPos, nTemp));
-
-if (!bTimePart && bSuccess)
-{
-bSuccess = readDurationComponent(string, nPos, nTemp, bTimePart,
- nYears, 'y', 'Y');
-}
-
-if (!bTimePart && bSuccess)
-{
-bSuccess = readDurationComponent(string, nPos, nTemp, bTimePart,
- nMonths, 'm', 'M');
-}
-
-if (!bTimePart && bSuccess)
-{
-bSuccess = readDurationComponent(string, nPos, nTemp, bTimePart,
- nDays, 'd', 'D');
-}
-
-if (bTimePart)
-{
-if (-1 == nTemp) // a 'T' must be followed by a component
-{
-bSuccess = false;
-}
-
-if (bSuccess)
-{
-bSuccess = readDurationComponent(string, nPos, nTemp, bTimePart,
- nHours, 'h', 'H');
-}
-
-if (bSuccess)
-{
-bSuccess = readDurationComponent(string, nPos, nTemp, bTimePart,
- nMinutes, 'm', 'M');
-}
-
-// eeek! seconds are icky.
-if ((nPos < string.size()) && bSuccess)
-{
-if (string[nPos] == '.' ||
-string[nPos] == ',')
-{
-++nPos;
-if (-1 != nTemp)
-{
-nSeconds = nTemp;
-nTemp = -1;
-const sal_Int32 nStart(nPos);
-bSuccess = readUnsignedNumberMaxDigits(9, string, nPos, 
nTemp) == R_SUCCESS;
-if ((nPos < string.size()) && bSuccess)
-{
-if (-1 != nTemp)
-{
-nNanoSeconds = nTemp;
-sal_Int32 nDigits = nPos - nStart;
-assert(nDigits >= 0);
-for (; nDigits < 9; ++nDigits)
-{
-nNanoSeconds *= 10;
-}
-nTemp=-1;
-if ('S' == string[nPos] || 's' == string[nPos])
-{
-++nPos;
-}
-else
-{
-bSuccess = false;
-}
-}
-else
-{
-bSuccess = false;
-}
-}
-}
-

[Libreoffice-commits] core.git: sax/source

2022-05-08 Thread Noel Grandin (via logerrit)
 sax/source/expatwrap/sax_expat.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit cdf8e971d5d46df4bcab35a99c4254df9459213f
Author: Noel Grandin 
AuthorDate: Sun May 8 13:06:00 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun May 8 20:50:34 2022 +0200

osl::Mutex->std::mutex in SaxExpatParser

Change-Id: I9d99497dfbc67cd4dd690da9db58aab0db114d36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134021
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index a50fb9e024a7..78b7e2252da0 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -146,7 +147,7 @@ constexpr OUStringLiteral gsCDATA = u"CDATA";
 class SaxExpatParser_Impl
 {
 public: // module scope
-Mutex   aMutex;
+std::mutex aMutex;
 bool m_bEnableDoS; // fdo#60471 thank you Adobe Illustrator
 
 css::uno::Reference< XDocumentHandler >   rDocumentHandler;
@@ -378,7 +379,7 @@ SaxExpatParser::initialize(css::uno::Sequence< 
css::uno::Any > const& rArguments
 OUString str;
 if ((rArguments[0] >>= str) && "DoSmeplease" == str)
 {
-MutexGuard guard( m_pImpl->aMutex );
+std::unique_lock guard( m_pImpl->aMutex );
 m_pImpl->m_bEnableDoS = true;
 }
 }
@@ -412,7 +413,7 @@ public:
 void SaxExpatParser::parseStream(   const InputSource& structSource)
 {
 // Only one text at one time
-MutexGuard guard( m_pImpl->aMutex );
+std::unique_lock guard( m_pImpl->aMutex );
 
 
 struct Entity entity;


[Libreoffice-commits] core.git: sax/source

2022-05-03 Thread Stephan Bergmann (via logerrit)
 sax/source/expatwrap/sax_expat.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ae8f735965678680835e2408494c2b226047f755
Author: Stephan Bergmann 
AuthorDate: Wed May 4 06:59:24 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Wed May 4 08:23:12 2022 +0200

Just use Any ctor instead of makeAny in sax

Change-Id: I3aec9eecc35eeabd2be61c73a57cff220843c9b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133791
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index b580970f68f3..a50fb9e024a7 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -91,7 +91,7 @@ namespace {
 catch( const css::uno::Exception &e ) {\
 pThis->bExceptionWasThrown = true; \
 pThis->bRTExceptionWasThrown = true; \
-pImpl->rtexception = WrappedTargetRuntimeException("Non-runtime 
UNO exception caught during parse", e.Context, makeAny(e)); \
+pImpl->rtexception = WrappedTargetRuntimeException("Non-runtime 
UNO exception caught during parse", e.Context, css::uno::Any(e)); \
 }\
 }\
 ((void)0)


[Libreoffice-commits] core.git: sax/source

2022-03-18 Thread Noel Grandin (via logerrit)
 sax/source/tools/CachedOutputStream.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a717a1bab852656d2e220754632eff384138f735
Author: Noel Grandin 
AuthorDate: Fri Mar 18 11:08:26 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri Mar 18 12:53:08 2022 +0100

tdf#133603 increase cache size in CachedOutputStream

modern devices require bigger chunks of data to keep them busy

Change-Id: I356327718fc20d937364b6ee726b0e94b4199e0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131734
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/tools/CachedOutputStream.hxx 
b/sax/source/tools/CachedOutputStream.hxx
index c3f442f9d93d..7d9e514c345c 100644
--- a/sax/source/tools/CachedOutputStream.hxx
+++ b/sax/source/tools/CachedOutputStream.hxx
@@ -30,7 +30,7 @@ public:
 class CachedOutputStream
 {
 /// When buffer hits this size, it's written to mxOutputStream
-static const sal_Int32 mnMaximumSize = 0x1;
+static const sal_Int32 mnMaximumSize = 0x10; // 1Mbyte
 
 /// ForMerge structure is used for sorting elements in Writer
 std::shared_ptr< ForMergeBase > mpForMerge;


[Libreoffice-commits] core.git: sax/source

2022-03-03 Thread Caolán McNamara (via logerrit)
 sax/source/fastparser/fastparser.cxx |   10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

New commits:
commit 94bdee6bf24965fab957c73a2c38e34c115a030e
Author: Caolán McNamara 
AuthorDate: Thu Mar 3 10:20:04 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 3 16:29:15 2022 +0100

crashtesting: assert that !rtl::isAscii in xmlError message

probably detected since:

commit 089ce740f9f97f9c7b13e37a31acfc94984e9a3e
Date:   Thu Feb 24 17:45:18 2022 +0300

Deduplicate rtl_*String_newConcat*L

or similar

Change-Id: I389d0875463f2ac59fda9266b168bdc35c82de95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130917
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 71b316378e01..2a4961737f9e 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -581,14 +581,8 @@ OUString lclGetErrorMessage( xmlParserCtxtPtr ctxt, 
std::u16string_view sSystemI
 pMessage = error->message;
 else
 pMessage = "unknown error";
-OUStringBuffer aBuffer( 128 );
-aBuffer.append( "[" );
-aBuffer.append( sSystemId );
-aBuffer.append( " line " );
-aBuffer.append( nLine );
-aBuffer.append( "]: " );
-aBuffer.appendAscii( pMessage );
-return aBuffer.makeStringAndClear();
+return OUString::Concat("[") + sSystemId + " line " + 
OUString::number(nLine) + "]: " +
+   OUString(pMessage, strlen(pMessage), RTL_TEXTENCODING_ASCII_US);
 }
 
 // throw an exception, but avoid callback if


[Libreoffice-commits] core.git: sax/source

2022-03-01 Thread Hossein (via logerrit)
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d1cfe4228316322d0ae9f3b8020036e5140fc32b
Author: Hossein 
AuthorDate: Tue Mar 1 14:33:33 2022 +0100
Commit: Hossein 
CommitDate: Wed Mar 2 02:11:23 2022 +0100

Remove 'const' from for loop variable

In the commit f63a6f2e396fa41ed1338dcec874e06159cafa9f, a for loop is
converted into a range-based for loop. The pointer is used to change
the nodes using xmlUnlinkNode() and xmlFreeNode(), thus the 'const'
should have not been used.

The reinterpret_cast does not change the constness, thus I have
removed the const from the loop variable, and it will no longer be a
const reference.

Change-Id: If4c61017ea77f464230bb5802f6fc928acc7a7e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130792
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index beb30443ba02..71b316378e01 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -674,7 +674,7 @@ FastSaxParserImpl::~FastSaxParserImpl()
 {
 if( mxDocumentLocator.is() )
 mxDocumentLocator->dispose();
-for (const auto& entity : m_TemporalEntities)
+for (auto& entity : m_TemporalEntities)
 {
 if (!entity)
 continue;


[Libreoffice-commits] core.git: sax/source

2022-03-01 Thread Deep17 (via logerrit)
 sax/source/fastparser/fastparser.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit f63a6f2e396fa41ed1338dcec874e06159cafa9f
Author: Deep17 
AuthorDate: Sun Feb 27 14:55:58 2022 -0500
Commit: Ilmari Lauhakangas 
CommitDate: Tue Mar 1 13:03:05 2022 +0100

tdf#145538 - Use range based for loops

Change-Id: I489a13330501ddfa1556a523f8334460505c0e61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130658
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 9effb82c348c..beb30443ba02 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -674,11 +674,11 @@ FastSaxParserImpl::~FastSaxParserImpl()
 {
 if( mxDocumentLocator.is() )
 mxDocumentLocator->dispose();
-for ( size_t i = 0; i < m_TemporalEntities.size(); ++i )
+for (const auto& entity : m_TemporalEntities)
 {
-if (!m_TemporalEntities[i])
+if (!entity)
 continue;
-xmlNodePtr pPtr = reinterpret_cast(m_TemporalEntities[i]);
+xmlNodePtr pPtr = reinterpret_cast(entity);
 xmlUnlinkNode(pPtr);
 xmlFreeNode(pPtr);
 }


[Libreoffice-commits] core.git: sax/source

2022-02-04 Thread Stephan Bergmann (via logerrit)
 sax/source/tools/fastserializer.cxx |   11 +++
 1 file changed, 11 insertions(+)

New commits:
commit 84b79376d7bc57a3967d7203a7d51466625588e8
Author: Stephan Bergmann 
AuthorDate: Thu Feb 3 13:50:55 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Feb 4 09:25:31 2022 +0100

Add a clarifying comment regarding the use of UTF-8

...justifying that 2f3a0bfbfe110c0837b3c7e04f9ad0969d6e56e4 "tdf#147088: 
Also
handle U+FFFE, U+ invalid XML 1.0 characters" added code that assumes
`string` is UTF-8 while carelessly removing the "assuming we're writing 
UTF-8"
disclaimer comment that had been added with
8b25b67d5268abbb260da968cc23b6f6c8dd31af "escape invalid XML characters with
_x_ when writing escaped"

Change-Id: I0866da2bbbc536b2feb977c35b164459b745d918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129422
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 8dcc308a836e..f4763dfa7c5d 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -106,6 +106,17 @@ namespace sax_fastparser {
 
 /** Characters not allowed in XML 1.0
 XML 1.1 would exclude only U+
+
+This assumes that `string` is UTF-8, but which appears to generally be 
the case:  The only
+user of this FastSaxSerializer code is FastSerializerHelper, and when 
its constructor
+(sax/source/tools/fshelper.cxx) is called with bWriteHeader being 
true, it calls
+FastSaxSerializer::startDocument, which writes sXmlHeader claiming 
encoding="UTF-8".  The
+only place that appears to construct FastSerializerHelper appears to be
+XmlFilterBase::openFragmentStreamWithSerializer 
(oox/source/core/xmlfilterbase.cxx), and it
+only passes false for bWriteHeader when the given rMediaType contains 
"vml" but not "+xml"
+(see 

+"XLSX VML Export fixes", stating "Don't write xml headers for vml 
files").  But lets assume
+that even such Vector Markup Language files are written as UTF-8.
  */
 template static std::optional> 
invalidChar(
 char const * string, Int length, Int index )


[Libreoffice-commits] core.git: sax/source

2022-02-01 Thread Stephan Bergmann (via logerrit)
 sax/source/tools/fastserializer.cxx |   54 +++-
 1 file changed, 35 insertions(+), 19 deletions(-)

New commits:
commit 2f3a0bfbfe110c0837b3c7e04f9ad0969d6e56e4
Author: Stephan Bergmann 
AuthorDate: Tue Feb 1 15:47:07 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Feb 1 23:36:55 2022 +0100

tdf#147088: Also handle U+FFFE, U+ invalid XML 1.0 characters

Change-Id: Ieec81fcde41e3508c6a9aa4250d7050db2fbb442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129296
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index de035f4717fd..8dcc308a836e 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -25,8 +25,11 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
+#include 
 
 #if OSL_DEBUG_LEVEL > 0
 #include 
@@ -104,19 +107,33 @@ namespace sax_fastparser {
 /** Characters not allowed in XML 1.0
 XML 1.1 would exclude only U+
  */
-static bool invalidChar( char c )
+template static std::optional> 
invalidChar(
+char const * string, Int length, Int index )
 {
-if (static_cast(c) >= 0x20)
-return false;
+assert(index < length);
+auto const c = string[index];
+
+if (static_cast(c) >= 0x20 && c != '\xEF')
+return {};
 
 switch (c)
 {
 case 0x09:
 case 0x0a:
 case 0x0d:
-return false;
+return {};
+case '\xEF': // U+FFFE, U+:
+if (length - index >= 3 && string[index + 1] == '\xBF') {
+switch (string[index + 2]) {
+case '\xBE':
+return std::pair(0xFFFE, 3);
+case '\xBF':
+return std::pair(0x, 3);
+}
+}
+return {};
 }
-return true;
+return std::pair(static_cast(c), 1);
 }
 
 static bool isHexDigit( char c )
@@ -139,7 +156,7 @@ namespace sax_fastparser {
 const sal_Int32 kXescapeLen = 7;
 char bufXescape[kXescapeLen+1];
 sal_Int32 nNextXescape = 0;
-for (sal_Int32 i = 0; i < nLen; ++i)
+for (sal_Int32 i = 0; i < nLen;)
 {
 char c = pStr[ i ];
 switch( c )
@@ -250,24 +267,19 @@ namespace sax_fastparser {
 break;
 }
 }
-if (invalidChar(c))
+if (auto const inv = invalidChar(pStr, nLen, 
i))
 {
 snprintf( bufXescape, kXescapeLen+1, 
"_x%04x_",
-static_cast(static_cast(c)));
+inv->first);
 writeBytes( bufXescape, kXescapeLen);
-break;
+i += inv->second;
+continue;
 }
-/* TODO: also U+FFFE and U+ are not allowed
- * in XML 1.0, assuming we're writing UTF-8
- * those should be escaped as well to be
- * conformant. Likely that would involve
- * scanning for both encoded sequences and
- * write as _x_? */
 }
 #if OSL_DEBUG_LEVEL > 0
 else
 {
-if (bGood && invalidChar(pStr[i]))
+if (bGood && invalidChar(pStr, nLen, i))
 {
 bGood = false;
 // The SAL_WARN() for the single character 
is
@@ -279,6 +291,7 @@ namespace sax_fastparser {
 writeBytes( &c, 1 );
 break;
 }
+++i;
 }
 SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << 
OString(pStr,std::min(nLen,42)) << "'");
 }
@@ -671,14 +684,17 @@ namespace sax_fastparser {
 #if OSL_DEBUG_LEVEL > 0
 {
 bool bGood = true;
-for (size_t i=0; i < nLen; ++i)
+for (size_t i=0; i < nLen;)
 {
-if (invalidChar(pStr[i]))
+if (auto const inv = invalidChar(pStr, nLen, i))
 {
 bGood = false;
 SAL_WARN("sax", "FastSaxSerializer::writeBytes - illegal 
XML character 0x" <<
-std::hex << int(static_cast(pStr[i])));
+

[Libreoffice-commits] core.git: sax/source

2022-01-03 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |   30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 146ea5360e7ce60693a1c80f1774856520b83cd4
Author: Noel Grandin 
AuthorDate: Mon Dec 20 18:49:50 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Jan 4 07:07:20 2022 +0100

osl::Mutex->std::mutex in FastSaxParserImpl

Change-Id: I3bb067a0aafe8d7ca1171ab7119acbf94323725c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127915
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index cc7dd91b82ab..f6fe5ee43bec 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -153,7 +153,7 @@ struct Entity : public ParserData
 std::optional mxProducedEvents;
 std::queue maPendingEvents;
 std::queue maUsedEvents;
-osl::Mutex maEventProtector;
+std::mutex maEventProtector;
 
 static const size_t mnEventLowWater = 4;
 static const size_t mnEventHighWater = 8;
@@ -537,12 +537,12 @@ EventList& Entity::getEventList()
 {
 if (!mxProducedEvents)
 {
-osl::ClearableMutexGuard aGuard(maEventProtector);
+std::unique_lock aGuard(maEventProtector);
 if (!maUsedEvents.empty())
 {
 mxProducedEvents = std::move(maUsedEvents.front());
 maUsedEvents.pop();
-aGuard.clear(); // unlock
+aGuard.unlock(); // unlock
 mnProducedEventsSize = 0;
 }
 if (!mxProducedEvents)
@@ -856,7 +856,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 rEntity.maConsumeResume.wait();
 rEntity.maConsumeResume.reset();
 
-osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
+std::unique_lock aGuard(rEntity.maEventProtector);
 while (!rEntity.maPendingEvents.empty())
 {
 if (rEntity.maPendingEvents.size() <= Entity::mnEventLowWater)
@@ -864,16 +864,16 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 
 EventList aEventList = 
std::move(rEntity.maPendingEvents.front());
 rEntity.maPendingEvents.pop();
-aGuard.clear(); // unlock
+aGuard.unlock(); // unlock
 
 if (!consume(aEventList))
 done = true;
 
-aGuard.reset(); // lock
+aGuard.lock(); // lock
 
 if ( rEntity.maPendingEvents.size() <= Entity::mnEventLowWater 
)
 {
-aGuard.clear();
+aGuard.unlock();
 for (auto& rEvent : aEventList.maEvents)
 {
 if (rEvent.mxAttributes.is())
@@ -884,7 +884,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 }
 aEventList.mbIsAttributesEmpty = true;
 }
-aGuard.reset();
+aGuard.lock();
 }
 
 rEntity.maUsedEvents.push(std::move(aEventList));
@@ -973,7 +973,7 @@ void FastSaxParserImpl::setCustomEntityNames(
 void FastSaxParserImpl::deleteUsedEvents()
 {
 Entity& rEntity = getEntity();
-osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
+std::unique_lock aGuard(rEntity.maEventProtector);
 
 while (!rEntity.maUsedEvents.empty())
 {
@@ -981,10 +981,10 @@ void FastSaxParserImpl::deleteUsedEvents()
 EventList aEventList = std::move(rEntity.maUsedEvents.front());
 rEntity.maUsedEvents.pop();
 
-aGuard.clear(); // unlock
+aGuard.unlock(); // unlock
 }
 
-aGuard.reset(); // lock
+aGuard.lock(); // lock
 }
 }
 
@@ -995,21 +995,21 @@ void FastSaxParserImpl::produce( bool bForceFlush )
 rEntity.mnProducedEventsSize >= Entity::mnEventListSize))
 return;
 
-osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
+std::unique_lock aGuard(rEntity.maEventProtector);
 
 while (rEntity.maPendingEvents.size() >= Entity::mnEventHighWater)
 { // pause parsing for a bit
-aGuard.clear(); // unlock
+aGuard.unlock(); // unlock
 rEntity.maProduceResume.wait();
 rEntity.maProduceResume.reset();
-aGuard.reset(); // lock
+aGuard.lock(); // lock
 }
 
 rEntity.maPendingEvents.push(std::move(*rEntity.mxProducedEvents));
 rEntity.mxProducedEvents.reset();
 assert(!rEntity.mxProducedEvents);
 
-aGuard.clear(); // unlock
+aGuard.unlock(); // unlock
 
 rEntity.maConsumeResume.set();
 }


[Libreoffice-commits] core.git: sax/source

2022-01-03 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit bc613dc5dba6a9fc2ad2bdb3fbd160ba7615788f
Author: Noel Grandin 
AuthorDate: Mon Dec 20 18:50:35 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Jan 4 07:06:52 2022 +0100

osl::Mutex->std::mutex in FastSaxParserImpl

Change-Id: I5f93c3d1373f8d5a95d8069b1f8381c45e11a875
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127916
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 97435e2219ea..cc7dd91b82ab 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -286,7 +286,7 @@ private:
 void DefineNamespace( const OString& rPrefix, const OUString& namespaceURL 
);
 
 private:
-osl::Mutex maMutex; ///< Protecting whole parseStream() execution
+std::mutex maMutex; ///< Protecting whole parseStream() execution
 ::rtl::Reference< FastLocatorImpl > mxDocumentLocator;
 NamespaceMapmaNamespaceMap;
 
@@ -825,7 +825,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 xmlInitParser();
 
 // Only one text at one time
-MutexGuard guard( maMutex );
+std::unique_lock guard( maMutex );
 
 pushEntity(maData, rStructSource);
 Entity& rEntity = getEntity();


[Libreoffice-commits] core.git: sax/source

2021-08-12 Thread Caolán McNamara (via logerrit)
 sax/source/fastparser/fastparser.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 25b4e39309814325224193f3192e6e2d83e5f141
Author: Caolán McNamara 
AuthorDate: Thu Aug 12 10:38:47 2021 +0100
Commit: Caolán McNamara 
CommitDate: Thu Aug 12 13:22:37 2021 +0200

include optional header for std::optional

Change-Id: I5e2c42498691d1fccf5122720e56bf44462ce21d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120382
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 2ffd008c6df6..ce8d8cc16054 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 


[Libreoffice-commits] core.git: sax/source

2021-07-31 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit f146cb69eb2a2cc0bffb0e76dbccbcdf942d5f7e
Author: Noel Grandin 
AuthorDate: Sat Jul 31 18:31:25 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Jul 31 20:13:09 2021 +0200

osl::Mutex->std::mutex in Entity

Change-Id: Ia9201dc4998a592ef4adaa39666f67a0935e8161
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119745
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index aa3bb66c18f8..980c092c796e 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -173,7 +174,7 @@ struct Entity : public ParserData
 // resource leaks), therefore any exception thrown by a UNO callback
 // must be saved somewhere until the C-XmlParser is stopped.
 css::uno::Any   maSavedException;
-osl::Mutex maSavedExceptionMutex;
+std::mutex  maSavedExceptionMutex;
 void saveException( const Any & e );
 // Thread-safe check if maSavedException has value
 bool hasException();
@@ -600,7 +601,7 @@ void Entity::throwException( const ::rtl::Reference< 
FastLocatorImpl > &xDocumen
 // Error during parsing !
 Any savedException;
 {
-osl::MutexGuard g(maSavedExceptionMutex);
+std::lock_guard g(maSavedExceptionMutex);
 if (maSavedException.hasValue())
 {
 savedException.setValue(&maSavedException, 
cppu::UnoType::get());
@@ -642,7 +643,7 @@ void Entity::saveException( const Any & e )
 // unexpectedly some 'startElements' produce a UNO_QUERY_THROW
 // for XComponent; and yet expect to continue parsing.
 SAL_WARN("sax", "Unexpected exception from XML parser " << 
exceptionToString(e));
-osl::MutexGuard g(maSavedExceptionMutex);
+std::lock_guard g(maSavedExceptionMutex);
 if (maSavedException.hasValue())
 {
 SAL_INFO("sax.fastparser", "discarding exception, already have one");
@@ -655,7 +656,7 @@ void Entity::saveException( const Any & e )
 
 bool Entity::hasException()
 {
-osl::MutexGuard g(maSavedExceptionMutex);
+std::lock_guard g(maSavedExceptionMutex);
 return maSavedException.hasValue();
 }
 


[Libreoffice-commits] core.git: sax/source vcl/README.lifecycle vcl/source

2021-03-24 Thread Andrea Gelmini (via logerrit)
 sax/source/fastparser/fastparser.cxx |2 +-
 vcl/README.lifecycle |2 +-
 vcl/source/filter/jpeg/transupp.c|2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit b6632bd41b56a2485dc6dd67a19d930c9654f835
Author: Andrea Gelmini 
AuthorDate: Tue Mar 23 20:23:59 2021 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Wed Mar 24 12:47:08 2021 +0100

Revert "Fix typo"

This reverts commit 4550b35781c6d9407da29f64f9b02b9201bf953b.

Change-Id: I279bb86bb876179d470a736f638446ffeaac9508
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112959
Tested-by: Adolfo Jayme Barrientos 
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 8cec8284abce..f35e56e8ab7f 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -467,7 +467,7 @@ void Entity::startElement( Event const *pEvent )
 if( xContext.is() )
 xContext->startFastElement( nElementToken, xAttr );
 }
-// swap the reference we own in to avoid referencing trash.
+// swap the reference we own in to avoid referencing thrash.
 maContextStack.top().mxContext = std::move( xContext );
 }
 catch (...)
diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle
index 0c44fb6a14d8..a309b65ef9ea 100644
--- a/vcl/README.lifecycle
+++ b/vcl/README.lifecycle
@@ -42,7 +42,7 @@ to lingering pointers to freed objects.
To fix this situation we now have a VclPtr - which is a smart
reference-counting pointer (include/vcl/vclptr.hxx) which is
designed to look and behave -very- much like a normal pointer
-   to reduce code-trash. VclPtr is used to wrap all OutputDevice
+   to reduce code-thrash. VclPtr is used to wrap all OutputDevice
derived classes thus:
 
VclPtr pDialog( new Dialog( ... ), SAL_NO_ACQUIRE );
diff --git a/vcl/source/filter/jpeg/transupp.c 
b/vcl/source/filter/jpeg/transupp.c
index 318b28d790c1..d26cb9510009 100644
--- a/vcl/source/filter/jpeg/transupp.c
+++ b/vcl/source/filter/jpeg/transupp.c
@@ -60,7 +60,7 @@ jdiv_round_up (long a, long b)
  * arrays are always written in normal scan order (top to bottom) because
  * the virtual array manager expects this.  The source arrays will be scanned
  * in the corresponding order, which means multiple passes through the source
- * arrays for most of the transforms.  That could result in much trashing
+ * arrays for most of the transforms.  That could result in much thrashing
  * if the image is larger than main memory.
  *
  * If cropping or trimming is involved, the destination arrays may be smaller
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source vcl/README.lifecycle vcl/source

2021-03-18 Thread Andrea Gelmini (via logerrit)
 sax/source/fastparser/fastparser.cxx |2 +-
 vcl/README.lifecycle |2 +-
 vcl/source/filter/jpeg/transupp.c|2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4550b35781c6d9407da29f64f9b02b9201bf953b
Author: Andrea Gelmini 
AuthorDate: Thu Mar 18 17:15:58 2021 +0100
Commit: Andrea Gelmini 
CommitDate: Fri Mar 19 07:53:41 2021 +0100

Fix typo

Change-Id: Icc75dc0f0d7434233b83fb72aadb4832ea47493e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112694
Reviewed-by: Julien Nabet 
Tested-by: Jenkins

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index f35e56e8ab7f..8cec8284abce 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -467,7 +467,7 @@ void Entity::startElement( Event const *pEvent )
 if( xContext.is() )
 xContext->startFastElement( nElementToken, xAttr );
 }
-// swap the reference we own in to avoid referencing thrash.
+// swap the reference we own in to avoid referencing trash.
 maContextStack.top().mxContext = std::move( xContext );
 }
 catch (...)
diff --git a/vcl/README.lifecycle b/vcl/README.lifecycle
index a309b65ef9ea..0c44fb6a14d8 100644
--- a/vcl/README.lifecycle
+++ b/vcl/README.lifecycle
@@ -42,7 +42,7 @@ to lingering pointers to freed objects.
To fix this situation we now have a VclPtr - which is a smart
reference-counting pointer (include/vcl/vclptr.hxx) which is
designed to look and behave -very- much like a normal pointer
-   to reduce code-thrash. VclPtr is used to wrap all OutputDevice
+   to reduce code-trash. VclPtr is used to wrap all OutputDevice
derived classes thus:
 
VclPtr pDialog( new Dialog( ... ), SAL_NO_ACQUIRE );
diff --git a/vcl/source/filter/jpeg/transupp.c 
b/vcl/source/filter/jpeg/transupp.c
index d26cb9510009..318b28d790c1 100644
--- a/vcl/source/filter/jpeg/transupp.c
+++ b/vcl/source/filter/jpeg/transupp.c
@@ -60,7 +60,7 @@ jdiv_round_up (long a, long b)
  * arrays are always written in normal scan order (top to bottom) because
  * the virtual array manager expects this.  The source arrays will be scanned
  * in the corresponding order, which means multiple passes through the source
- * arrays for most of the transforms.  That could result in much thrashing
+ * arrays for most of the transforms.  That could result in much trashing
  * if the image is larger than main memory.
  *
  * If cropping or trimming is involved, the destination arrays may be smaller
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2021-02-24 Thread Caolán McNamara (via logerrit)
 sax/source/tools/converter.cxx |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit e2c9ac71cec0f205b1d4864538e8158c22558296
Author: Caolán McNamara 
AuthorDate: Wed Feb 24 11:37:05 2021 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 24 16:38:38 2021 +0100

ofz#30767 Build-Failure

afl++ build crashes for some obscure reason with attached bt. Tweaking
the code like so gets it to squeak by and continue the build.

 clang-12: /usr/local/include/llvm/IR/Constants.h:661: llvm::StringRef 
llvm::ConstantDataSequential::getAsString() const: Assertion `isString() && 
"Not a string"' failed.
 Stack dump:
 0. Program arguments: /usr/local/bin/clang-12 -cc1 -triple 
x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free 
-disable-llvm-verifier -discard-value-names -main-file-name converter.cxx 
-mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition 
-mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases 
-munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining 
-debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb 
-ffunction-sections -fdata-sections -D BOOST_ERROR_CODE_HEADER_ONLY -D 
BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D DISABLE_DYNLOADING -D LINUX -D 
NDEBUG -D OSL_DEBUG_LEVEL=0 -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT 
-D SAX_DLLIMPLEMENTATION -D FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -D 
EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -D __AFL_HAVE_MANUAL_CONTROL=1 -D 
__AFL_COMPILER=1 -D FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -D 
"__AFL_FUZZ_INIT()=int __afl_sharedmem_fuzzing = 1;extern unsign
 ed int *__afl_fuzz_len;extern unsigned char *__afl_fuzz_ptr;unsigned char 
__afl_fuzz_alt[1048576];unsigned char *__afl_fuzz_alt_ptr = __afl_fuzz_alt;" -D 
"__AFL_COVERAGE()=int __afl_selective_coverage = 1;extern \"C\" void 
__afl_coverage_discard();extern \"C\" void __afl_coverage_skip();extern \"C\" 
void __afl_coverage_on();extern \"C\" void __afl_coverage_off();" -D 
"__AFL_COVERAGE_START_OFF()=int __afl_selective_coverage_start_off = 1;" -D 
__AFL_COVERAGE_ON()=__afl_coverage_on() -D 
__AFL_COVERAGE_OFF()=__afl_coverage_off() -D 
__AFL_COVERAGE_DISCARD()=__afl_coverage_discard() -D 
__AFL_COVERAGE_SKIP()=__afl_coverage_skip() -D 
"__AFL_FUZZ_TESTCASE_BUF=(__afl_fuzz_ptr ? __afl_fuzz_ptr : 
__afl_fuzz_alt_ptr)" -D "__AFL_FUZZ_TESTCASE_LEN=(__afl_fuzz_ptr ? 
*__afl_fuzz_len : (*__afl_fuzz_len = read(0, __afl_fuzz_alt_ptr, 1048576)) == 
0x ? 0 : *__afl_fuzz_len)" -D "__AFL_LOOP(_A)=({ static volatile char 
*_B __attribute__((used));  _B = (char*)\"##SIG_AFL_PERSISTENT##\"; __attribute_
 _((visibility(\"default\"))) int _L(unsigned int) 
__asm__(\"__afl_persistent_loop\"); _L(_A); })" -D "__AFL_INIT()=do { static 
volatile char *_A __attribute__((used));  _A = 
(char*)\"##SIG_AFL_DEFER_FORKSRV##\"; __attribute__((visibility(\"default\"))) 
void _I(void) __asm__(\"__afl_manual_init\"); _I(); } while (0)" -O1 
-Wno-unused-command-line-argument -Wall -Wno-missing-braces -Wnon-virtual-dtor 
-Wendif-labels -Wextra -Wundef -Wunreachable-code -Wunused-macros 
-Wembedded-directive -Wdeprecated-copy-dtor -Wimplicit-fallthrough 
-Wunused-exception-parameter -Wrange-loop-analysis -Wshadow 
-Woverloaded-virtual -Wno-unused-command-line-argument -std=c++17 
-fdeprecated-macro -ferror-limit 19 -fvisibility hidden 
-fvisibility-inlines-hidden -fsanitize=address 
-fsanitize-blacklist=/src/libreoffice/bin/sanitize-excludelist.txt 
-fsanitize-system-blacklist=/usr/local/lib/clang/12.0.0/share/asan_blacklist.txt
 -fsanitize-address-use-after-scope -fno-assume-sane-operator-new 
-funroll-loops -pthre
 ad -stack-protector 2 -fgnuc-version=4.2.1 -fno-inline -fcxx-exceptions 
-fexceptions -fcolor-diagnostics -load /src/aflplusplus/afl-llvm-dict2file.so 
-load /src/aflplusplus/cmplog-routines-pass.so -load 
/src/aflplusplus/cmplog-instructions-pass.so -load 
/src/aflplusplus/split-switches-pass.so -load 
/src/aflplusplus/SanitizerCoveragePCGUARD.so -faddrsig -x c++ 
converter-773998.cpp
 1.  parser at end of file
 2. Per-module optimization passes
 3. Running pass 'afl++ dict2file instrumentation pass' on module 
'converter-773998.cpp'.
  #0 0x01719ae3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/usr/local/bin/clang-12+0x1719ae3)
  #1 0x01717a4e llvm::sys::RunSignalHandlers() 
(/usr/local/bin/clang-12+0x1717a4e)
  #2 0x01719f8f SignalHandler(int) 
(/usr/local/bin/clang-12+0x1719f8f)
  #3 0x7f3e317b2980 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
  #4 0x7f3e306abfb7 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3efb7)
  #5 0x7f3e306ad921 abort (/lib/x86_64-linux-gnu/libc.so.6+0x40921)
  #6 0x7f3e3069d48a (/lib/x86_64-linux-gnu/libc.so.6+0x3048a)
  #7 0x7f3e3069d502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
  #8 0x7f3e30464810 (anonym

[Libreoffice-commits] core.git: sax/source

2021-02-17 Thread Bayram Çiçek (via logerrit)
 sax/source/tools/converter.cxx |  139 -
 1 file changed, 14 insertions(+), 125 deletions(-)

New commits:
commit bc817c2fb26ebbfcc7b6868fbcabb13772ddb90e
Author: Bayram Çiçek 
AuthorDate: Wed Feb 17 02:33:23 2021 +0300
Commit: Michael Stahl 
CommitDate: Wed Feb 17 12:33:05 2021 +0100

tdf#39593: reduce copy/paste in Converter::convertDuration

Change-Id: I520e10ef96c677be9f80bba510fe9c89295d416c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111008
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 18731b45ac77..f4f6dccb8ddc 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -921,13 +921,10 @@ static std::string_view trim(std::string_view in) {
   return std::string_view(&*left, std::distance(left, right) + 1);
 }
 
-/** convert ISO "duration" string to double; negative durations allowed */
-bool Converter::convertDuration(double& rfTime,
-std::u16string_view rString)
+/** helper function of Converter::convertDuration */
+template
+static bool convertDurationHelper(double& rfTime, V pStr)
 {
-std::u16string_view aTrimmed = trim(rString);
-const sal_Unicode* pStr = aTrimmed.data();
-
 // negative time duration?
 bool bIsNegativeDuration = false;
 if ( '-' == (*pStr) )
@@ -1049,6 +1046,16 @@ bool Converter::convertDuration(double& rfTime,
 return bSuccess;
 }
 
+/** convert ISO "duration" string to double; negative durations allowed */
+bool Converter::convertDuration(double& rfTime,
+std::u16string_view rString)
+{
+std::u16string_view aTrimmed = trim(rString);
+const sal_Unicode* pStr = aTrimmed.data();
+
+return convertDurationHelper(rfTime, pStr);
+}
+
 /** convert ISO "duration" string to double; negative durations allowed */
 bool Converter::convertDuration(double& rfTime,
 std::string_view rString)
@@ -1056,125 +1063,7 @@ bool Converter::convertDuration(double& rfTime,
 std::string_view aTrimmed = trim(rString);
 const char* pStr = aTrimmed.data();
 
-// negative time duration?
-bool bIsNegativeDuration = false;
-if ( '-' == (*pStr) )
-{
-bIsNegativeDuration = true;
-pStr++;
-}
-
-if ( *pStr != 'P' && *pStr != 'p' )// duration must start with 
"P"
-return false;
-pStr++;
-
-OUStringBuffer sDoubleStr;
-bool bSuccess = true;
-bool bDone = false;
-bool bTimePart = false;
-bool bIsFraction = false;
-sal_Int32 nDays  = 0;
-sal_Int32 nHours = 0;
-sal_Int32 nMins  = 0;
-sal_Int32 nSecs  = 0;
-sal_Int32 nTemp = 0;
-
-while ( bSuccess && !bDone )
-{
-sal_Unicode c = *(pStr++);
-if ( !c )   // end
-bDone = true;
-else if ( '0' <= c && '9' >= c )
-{
-if ( nTemp >= SAL_MAX_INT32 / 10 )
-bSuccess = false;
-else
-{
-if ( !bIsFraction )
-{
-nTemp *= 10;
-nTemp += (c - u'0');
-}
-else
-{
-sDoubleStr.append(c);
-}
-}
-}
-else if ( bTimePart )
-{
-if ( c == 'H' || c == 'h' )
-{
-nHours = nTemp;
-nTemp = 0;
-}
-else if ( c == 'M' || c == 'm')
-{
-nMins = nTemp;
-nTemp = 0;
-}
-else if ( (c == ',') || (c == '.') )
-{
-nSecs = nTemp;
-nTemp = 0;
-bIsFraction = true;
-sDoubleStr = "0.";
-}
-else if ( c == 'S' || c == 's' )
-{
-if ( !bIsFraction )
-{
-nSecs = nTemp;
-nTemp = 0;
-sDoubleStr = "0.0";
-}
-}
-else
-bSuccess = false;   // invalid character
-}
-else
-{
-if ( c == 'T' || c == 't' )// "T" starts time part
-bTimePart = true;
-else if ( c == 'D' || c == 'd')
-{
-nDays = nTemp;
-nTemp = 0;
-}
-else if ( c == 'Y' || c == 'y' || c == 'M' || c == 'm' )
-{
-//! how many days is a year or month?
-
-OSL_FAIL( "years or months in duration: not implemented");
-bSuccess = false;
-}
-else
-bSuccess = false;   // invalid character
-}
-}
-
-if ( bSuccess )
-{
-if ( nDays )
-nHours +

[Libreoffice-commits] core.git: sax/source

2021-01-19 Thread Andrea Gelmini (via logerrit)
 sax/source/expatwrap/saxwriter.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7b23283122b1dbfba9c7f2c740602979c0efe3da
Author: Andrea Gelmini 
AuthorDate: Tue Jan 19 21:22:47 2021 +0100
Commit: Julien Nabet 
CommitDate: Wed Jan 20 07:49:25 2021 +0100

Fix typo

Change-Id: I9edd52387417f8bb40646800beda7a3dca0b9abf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109657
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index 606db22e29c9..033052a0bd8d 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -446,7 +446,7 @@ bool SaxWriterHelper::convertToXML(const sal_Unicode* pStr, 
sal_Int32 nStrLen,
 }
 }
 
-// Deal with other uniciode cases
+// Deal with other unicode cases
 if (c >= 0xd800 && c < 0xdc00)
 {
 // 1. surrogate: save (until 2. surrogate)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2021-01-18 Thread dante (via logerrit)
 sax/source/expatwrap/saxwriter.cxx |   20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

New commits:
commit e8aef914671d9712fb3fadb2d8fba60f09784288
Author: dante 
AuthorDate: Thu Jan 14 19:50:14 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Jan 19 08:42:02 2021 +0100

Simplify getFirstLineBreak

Change-Id: I0fcacd3f3deb5867ed91a7037b74fa364ebc4c80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109302
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index 04fd90762cd9..606db22e29c9 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -999,23 +999,6 @@ const ReplacementPair* 
SaxWriterHelper::findXMLReplacement(const sal_Unicode* pS
 return nullptr;
 }
 
-/** returns position of first ascii 10 within the string, -1 when no 10 in 
string.
- */
-sal_Int32 getFirstLineBreak(const OUString& str) throw()
-{
-const sal_Unicode* pSource = str.getStr();
-sal_Int32 nLen = str.getLength();
-
-for (int n = 0; n < nLen; n++)
-{
-if (LINEFEED == pSource[n])
-{
-return n;
-}
-}
-return -1;
-}
-
 class SAXWriter : public WeakImplHelper
 {
 public:
@@ -1303,7 +1286,8 @@ void SAXWriter::characters(const OUString& aChars)
 sal_Int32 nIndentPrefix(-1);
 if (m_bAllowLineBreak)
 {
-sal_Int32 nFirstLineBreakOccurrence = 
getFirstLineBreak(aChars);
+// returns position of first ascii 10 within the string, -1 
when no 10 in string.
+sal_Int32 nFirstLineBreakOccurrence = aChars.indexOf(LINEFEED);
 
 nLength = m_pSaxWriterHelper->calcXMLByteLength(aChars, 
!m_bIsCDATA, false);
 nIndentPrefix = getIndentPrefixLength(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2021-01-18 Thread dante (via logerrit)
 sax/source/expatwrap/saxwriter.cxx |  242 -
 1 file changed, 157 insertions(+), 85 deletions(-)

New commits:
commit ae5ec5b944cf2378806498072c50d473a3ac62ed
Author: dante 
AuthorDate: Fri Jan 1 19:42:37 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Tue Jan 19 08:19:46 2021 +0100

Use customized xml entities on xmleport.

This will be mainly used on matml export for unicode characters.
It will be used mostly for mathml.

Change-Id: I59b96d44facbd01fa517317a0ae54d64d29b0a19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108562
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index f6a58b0bb4cb..04fd90762cd9 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -117,6 +117,9 @@ private:
 /// @throws SAXException
 void FinishStartElement();
 
+// Search for the correct replacement
+const ReplacementPair* findXMLReplacement(const sal_Unicode* pStr, 
sal_Int32 nStrLen);
+
 public:
 explicit SaxWriterHelper(Reference const& m_TempOut)
 : m_out(m_TempOut)
@@ -193,6 +196,10 @@ public:
 void setCustomEntityNames(
 const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, 
::rtl::OUString>>&
 replacements);
+
+// Calculate length for convertToXML
+sal_Int32 calcXMLByteLength(const OUString& rStr, bool bDoNormalization,
+bool bNormalizeWhitespace);
 };
 
 const bool g_bValidCharsBelow32[32] = {
@@ -282,10 +289,10 @@ bool SaxWriterHelper::convertToXML(const sal_Unicode* 
pStr, sal_Int32 nStrLen,
 
 for (sal_Int32 i = 0; i < nStrLen; i++)
 {
-sal_uInt16 c = pStr[i];
+sal_Unicode c = pStr[i];
 if (IsInvalidChar(c))
 bRet = false;
-else if ((c >= 0x0001) && (c <= 0x007F))
+else if ((c >= 0x0001) && (c <= 0x007F)) // Deal with ascii
 {
 if (bDoNormalization)
 {
@@ -414,26 +421,80 @@ bool SaxWriterHelper::convertToXML(const sal_Unicode* 
pStr, sal_Int32 nStrLen,
 rPos++;
 }
 }
-else if (c >= 0xd800 && c < 0xdc00)
-{
-// 1. surrogate: save (until 2. surrogate)
-OSL_ENSURE(nSurrogate == 0, "left-over Unicode surrogate");
-nSurrogate = ((c & 0x03ff) + 0x0040);
-}
-else if (c >= 0xdc00 && c < 0xe000)
+else
 {
-// 2. surrogate: write as UTF-8
-OSL_ENSURE(nSurrogate != 0, "lone 2nd Unicode surrogate");
+// Deal with replacements
+if (bDoNormalization && !m_Replacements.empty())
+{
+// search
+const ReplacementPair* it = findXMLReplacement(&pStr[i], 
nStrLen - i);
+
+// replace
+if (it != nullptr)
+{
+OString name = ::rtl::OUStringToOString(it->name, 
RTL_TEXTENCODING_UTF8);
+if (rPos + name.getLength() > SEQUENCESIZE)
+AddBytes(pTarget, rPos, reinterpret_cast(name.getStr()),
+ name.getLength());
+else
+{
+memcpy(&(pTarget[rPos]), name.getStr(), 
name.getLength());
+rPos += name.getLength();
+}
+i += it->replacement.getLength() - 1;
+continue;
+}
+}
+
+// Deal with other uniciode cases
+if (c >= 0xd800 && c < 0xdc00)
+{
+// 1. surrogate: save (until 2. surrogate)
+OSL_ENSURE(nSurrogate == 0, "left-over Unicode surrogate");
+nSurrogate = ((c & 0x03ff) + 0x0040);
+}
+else if (c >= 0xdc00 && c < 0xe000)
+{
+// 2. surrogate: write as UTF-8
+OSL_ENSURE(nSurrogate != 0, "lone 2nd Unicode surrogate");
+
+nSurrogate = (nSurrogate << 10) | (c & 0x03ff);
+if (rtl::isUnicodeScalarValue(nSurrogate) && nSurrogate >= 
0x0001)
+{
+sal_Int8 aBytes[] = { sal_Int8(0xF0 | ((nSurrogate >> 18) 
& 0x0F)),
+  sal_Int8(0x80 | ((nSurrogate >> 12) 
& 0x3F)),
+  sal_Int8(0x80 | ((nSurrogate >> 6) & 
0x3F)),
+  sal_Int8(0x80 | ((nSurrogate >> 0) & 
0x3F)) };
+if ((rPos + 4) > SEQUENCESIZE)
+AddBytes(pTarget, rPos, aBytes, 4);
+else
+{
+pTarget[rPos] = aBytes[0];
+rPos++;
+pTarget[rPos] = aBytes[1];
+rPos++;
+

[Libreoffice-commits] core.git: sax/source solenv/clang-format

2020-12-29 Thread dante (via logerrit)
 sax/source/expatwrap/saxwriter.cxx |  663 +
 solenv/clang-format/excludelist|1 
 2 files changed, 313 insertions(+), 351 deletions(-)

New commits:
commit cda385ac10ac0deb46c2c04e6d1b4d9f0c26
Author: dante 
AuthorDate: Mon Dec 28 21:19:43 2020 +0100
Commit: Noel Grandin 
CommitDate: Wed Dec 30 07:46:05 2020 +0100

Clang-format saxwriter

Change-Id: I4793d81e2ba3405b9ed07a2c5547572ed7e0bee6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108425
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index 03ca1f765d82..f6a58b0bb4cb 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -64,8 +64,8 @@ using namespace ::com::sun::star::io;
 *
 */
 
-namespace {
-
+namespace
+{
 enum SaxInvalidCharacterError
 {
 SAX_NONE,
@@ -92,13 +92,13 @@ public:
 #endif
 
 private:
-Reference< XOutputStream >  m_out;
-Sequence < sal_Int8 >   m_Sequence;
-sal_Int8*   mp_Sequence;
+Reference m_out;
+Sequence m_Sequence;
+sal_Int8* mp_Sequence;
 
-sal_Int32   nLastLineFeedPos; // is negative after writing 
a sequence
-sal_uInt32  nCurrentPos;
-boolm_bStartElementFinished;
+sal_Int32 nLastLineFeedPos; // is negative after writing a sequence
+sal_uInt32 nCurrentPos;
+bool m_bStartElementFinished;
 
 std::vector m_Replacements;
 
@@ -109,19 +109,16 @@ private:
 // so the sequence has to write out and reset rPos to 0
 // writes sequence only on overflow, sequence could be full on the end 
(rPos == SEQUENCESIZE)
 /// @throws SAXException
-void AddBytes(sal_Int8* pTarget, sal_uInt32& rPos,
-const sal_Int8* pBytes, sal_uInt32 nBytesCount);
+void AddBytes(sal_Int8* pTarget, sal_uInt32& rPos, const sal_Int8* pBytes,
+  sal_uInt32 nBytesCount);
 /// @throws SAXException
-bool convertToXML(const sal_Unicode * pStr,
-sal_Int32 nStrLen,
-bool bDoNormalization,
-bool bNormalizeWhitespace,
-sal_Int8 *pTarget,
-sal_uInt32& rPos);
+bool convertToXML(const sal_Unicode* pStr, sal_Int32 nStrLen, bool 
bDoNormalization,
+  bool bNormalizeWhitespace, sal_Int8* pTarget, 
sal_uInt32& rPos);
 /// @throws SAXException
 void FinishStartElement();
+
 public:
-explicit SaxWriterHelper(Reference< XOutputStream > const & m_TempOut)
+explicit SaxWriterHelper(Reference const& m_TempOut)
 : m_out(m_TempOut)
 , m_Sequence(SEQUENCESIZE)
 , mp_Sequence(nullptr)
@@ -141,39 +138,41 @@ public:
 /// @throws SAXException
 void insertIndentation(sal_uInt32 m_nLevel);
 
-// returns whether it works correct or invalid characters were in the string
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+// returns whether it works correct or invalid characters were in the 
string
+// If there are invalid characters in the string it returns sal_False.
+// Than the calling method has to throw the needed Exception.
 /// @throws SAXException
-bool writeString(const OUString& rWriteOutString,
-bool bDoNormalization,
-bool bNormalizeWhitespace);
+bool writeString(const OUString& rWriteOutString, bool bDoNormalization,
+ bool bNormalizeWhitespace);
 
 sal_uInt32 GetLastColumnCount() const throw()
-{ return static_cast(nCurrentPos - nLastLineFeedPos); }
+{
+return static_cast(nCurrentPos - nLastLineFeedPos);
+}
 
 /// @throws SAXException
 void startDocument();
 
-// returns whether it works correct or invalid characters were in the strings
-// If there are invalid characters in one of the strings it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+// returns whether it works correct or invalid characters were in the 
strings
+// If there are invalid characters in one of the strings it returns 
sal_False.
+// Than the calling method has to throw the needed Exception.
 /// @throws SAXException
-SaxInvalidCharacterError startElement(const OUString& rName, const 
Reference< XAttributeList >& xAttribs);
+SaxInvalidCharacterError startElement(const OUString& rName,
+  const Reference& 
xAttribs);
 /// @throws SAXException
 bool FinishEmptyElement();
 
-// returns whether it works correct or invalid characters were in the string
-// If there are invalid characters in the string it returns sal_False.
-// Than the calling method has to throw the needed Exception.
+// returns whether it works corr

[Libreoffice-commits] core.git: sax/source

2020-12-28 Thread Caolán McNamara (via logerrit)
 sax/source/fastparser/fastparser.cxx |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit c4542dd3534e5e05307938bb7627017fb8a883cb
Author: Caolán McNamara 
AuthorDate: Mon Dec 28 15:03:57 2020 +
Commit: Caolán McNamara 
CommitDate: Mon Dec 28 21:08:16 2020 +0100

ofz#28733 Direct-leak

free xmlEntityPtr the way desret_xmlEntityPtr does in libxml's testapi.c

Change-Id: Ia809413c3d4e7b13e799e6c1a57e8abe61bf218d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108415
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 9d13d25ce385..6bfa1ce0e205 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -676,7 +676,13 @@ FastSaxParserImpl::~FastSaxParserImpl()
 if( mxDocumentLocator.is() )
 mxDocumentLocator->dispose();
 for ( size_t i = 0; i < m_TemporalEntities.size(); ++i )
-if (m_TemporalEntities[i] != nullptr) xmlFree(m_TemporalEntities[i]);
+{
+if (!m_TemporalEntities[i])
+continue;
+xmlNodePtr pPtr = reinterpret_cast(m_TemporalEntities[i]);
+xmlUnlinkNode(pPtr);
+xmlFreeNode(pPtr);
+}
 }
 
 void FastSaxParserImpl::DefineNamespace( const OString& rPrefix, const 
OUString& namespaceURL )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-12-21 Thread Noel (via logerrit)
 sax/source/tools/converter.cxx |  415 ++---
 1 file changed, 68 insertions(+), 347 deletions(-)

New commits:
commit 0eeb310d9ed8654ac4c96c444ebad49a567ad618
Author: Noel 
AuthorDate: Mon Dec 21 11:25:03 2020 +0200
Commit: Noel Grandin 
CommitDate: Tue Dec 22 07:37:58 2020 +0100

reduce duplication in sax converter

Change-Id: I05bfb50e81a84b5f3bb7749e85058f967cb4b4ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108094
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index de2c66dc7435..a4a793c0392e 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -51,9 +51,20 @@ const char* const gpsPC = "pc";
 
 const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 14;
 
+static sal_Int64 toInt64_WithLength(const sal_Unicode * str, sal_Int16 radix, 
sal_Int32 nStrLength )
+{
+return rtl_ustr_toInt64_WithLength(str, radix, nStrLength);
+}
+static sal_Int64 toInt64_WithLength(const char * str, sal_Int16 radix, 
sal_Int32 nStrLength )
+{
+return rtl_str_toInt64_WithLength(str, radix, nStrLength);
+}
+
+
 /** convert string to measure using optional min and max values*/
-bool Converter::convertMeasure( sal_Int32& rValue,
-std::u16string_view rString,
+template
+static bool lcl_convertMeasure( sal_Int32& rValue,
+V rString,
 sal_Int16 nTargetUnit /* = 
MeasureUnit::MM_100TH */,
 sal_Int32 nMin /* = SAL_MIN_INT32 */,
 sal_Int32 nMax /* = SAL_MAX_INT32 */ )
@@ -266,217 +277,25 @@ bool Converter::convertMeasure( sal_Int32& rValue,
 
 /** convert string to measure using optional min and max values*/
 bool Converter::convertMeasure( sal_Int32& rValue,
-std::string_view rString,
+std::u16string_view rString,
 sal_Int16 nTargetUnit /* = 
MeasureUnit::MM_100TH */,
 sal_Int32 nMin /* = SAL_MIN_INT32 */,
 sal_Int32 nMax /* = SAL_MAX_INT32 */ )
 {
-bool bNeg = false;
-double nVal = 0;
-
-sal_Int32 nPos = 0;
-sal_Int32 const nLen = rString.size();
-
-// skip white space
-while( (nPos < nLen) && (rString[nPos] <= ' ') )
-nPos++;
-
-if( nPos < nLen && '-' == rString[nPos] )
-{
-bNeg = true;
-nPos++;
-}
-
-// get number
-while( nPos < nLen &&
-   '0' <= rString[nPos] &&
-   '9' >= rString[nPos] )
-{
-// TODO: check overflow!
-nVal *= 10;
-nVal += (rString[nPos] - '0');
-nPos++;
-}
-if( nPos < nLen && '.' == rString[nPos] )
-{
-nPos++;
-double nDiv = 1.;
-
-while( nPos < nLen &&
-   '0' <= rString[nPos] &&
-   '9' >= rString[nPos] )
-{
-// TODO: check overflow!
-nDiv *= 10;
-nVal += ( static_cast(rString[nPos] - '0') / nDiv );
-nPos++;
-}
-}
-
-// skip white space
-while( (nPos < nLen) && (rString[nPos] <= ' ') )
-nPos++;
-
-if( nPos < nLen )
-{
-
-if( MeasureUnit::PERCENT == nTargetUnit )
-{
-if( '%' != rString[nPos] )
-return false;
-}
-else if( MeasureUnit::PIXEL == nTargetUnit )
-{
-if( nPos + 1 >= nLen ||
-('p' != rString[nPos] &&
- 'P' != rString[nPos])||
-('x' != rString[nPos+1] &&
- 'X' != rString[nPos+1]) )
-return false;
-}
-else
-{
-OSL_ENSURE( MeasureUnit::TWIP == nTargetUnit || MeasureUnit::POINT 
== nTargetUnit ||
-MeasureUnit::MM_100TH == nTargetUnit || 
MeasureUnit::MM_10TH == nTargetUnit ||
-MeasureUnit::PIXEL == nTargetUnit, "unit is not 
supported");
-const char *aCmpsL[3] = { nullptr, nullptr, nullptr };
-const char *aCmpsU[3] = { nullptr, nullptr, nullptr };
-double aScales[3] = { 1., 1., 1. };
-
-if( MeasureUnit::TWIP == nTargetUnit )
-{
-switch( rString[nPos] )
-{
-case u'c':
-case u'C':
-aCmpsL[0] = "cm";
-aCmpsU[0] = "CM";
-aScales[0] = (72.*20.)/2.54; // twip
-break;
-case u'i':
-case u'I':
-aCmpsL[0] = "in";
-aCmpsU[0] = "IN";
-aScales[0] = 72.*20.; // twip
-break;
-case u'm':
-case u'M':
-aCmpsL[0] = "mm";
-aCmpsU[0] = "MM";
- 

[Libreoffice-commits] core.git: sax/source

2020-12-19 Thread dante (via logerrit)
 sax/source/fastparser/fastparser.cxx |   29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

New commits:
commit f460d8e8178cc6fad02347e2bab6580efe51c260
Author: dante 
AuthorDate: Fri Dec 18 03:25:21 2020 +0100
Commit: Noel Grandin 
CommitDate: Sat Dec 19 16:09:18 2020 +0100

Proposition for solution for memory error in 106804

https://gerrit.libreoffice.org/c/core/+/106804

This needs to be merged in the 7.1, it corrects a memory leak introduced in 
this same version.

Change-Id: Id3c3f86f88c32e631f0c414fbd7942aba2a91239
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107930
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 94d2651d4dff..f2a1ef3f2a92 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -227,6 +227,7 @@ public:
 
 private:
 std::vector m_Replacements;
+std::vector m_TemporalEntities;
 
 public:
 // XFastParser
@@ -673,6 +674,8 @@ FastSaxParserImpl::~FastSaxParserImpl()
 {
 if( mxDocumentLocator.is() )
 mxDocumentLocator->dispose();
+for ( size_t i = 0; i < m_TemporalEntities.size(); ++i )
+if (m_TemporalEntities[i] != nullptr) xmlFree(m_TemporalEntities[i]);
 }
 
 void FastSaxParserImpl::DefineNamespace( const OString& rPrefix, const 
OUString& namespaceURL )
@@ -1398,9 +1401,13 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const 
xmlChar *name )
 {
 auto it = std::lower_bound(m_Replacements.begin(), 
m_Replacements.end(), dname);
 if (it != m_Replacements.end() && it->name.compareToAscii(dname) == 0)
-return xmlNewEntity(
+{
+xmlEntityPtr entpt = xmlNewEntity(
 nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
 BAD_CAST(OUStringToOString(it->replacement, 
RTL_TEXTENCODING_UTF8).getStr()));
+m_TemporalEntities.push_back(entpt);
+return entpt;
+}
 }
 if( lname < 2 )
 return xmlGetPredefinedEntity(name);
@@ -1415,21 +1422,23 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( 
const xmlChar *name )
 if( cval == 0 )
 return xmlGetPredefinedEntity(name);
 OUString vname( &cval, 1 );
-return xmlNewEntity( nullptr,
-name,
-XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
-
BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+xmlEntityPtr entpt
+= xmlNewEntity(nullptr, name, XML_INTERNAL_GENERAL_ENTITY, 
nullptr, nullptr,
+   BAD_CAST(OUStringToOString(vname, 
RTL_TEXTENCODING_UTF8).getStr()));
+m_TemporalEntities.push_back(entpt);
+return entpt;
 }
 else
 {
 cval = static_cast( strtoul( dname + 2, nullptr, 10 ) 
);
 if( cval == 0 )
 return xmlGetPredefinedEntity(name);
-OUString vname( &cval, 1 );
-return xmlNewEntity( nullptr,
-name,
-XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
-
BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+OUString vname(&cval, 1);
+xmlEntityPtr entpt
+= xmlNewEntity(nullptr, name, XML_INTERNAL_GENERAL_ENTITY, 
nullptr, nullptr,
+   BAD_CAST(OUStringToOString(vname, 
RTL_TEXTENCODING_UTF8).getStr()));
+m_TemporalEntities.push_back(entpt);
+return entpt;
 }
 }
 return xmlGetPredefinedEntity(name);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-12-17 Thread Noel (via logerrit)
 sax/source/tools/converter.cxx |   84 -
 1 file changed, 42 insertions(+), 42 deletions(-)

New commits:
commit 11db2864308a4df47206f5c8a828f800fcbddd15
Author: Noel 
AuthorDate: Thu Dec 17 14:05:38 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Dec 17 14:29:47 2020 +0100

use more string_view in sax::Converter

Change-Id: If8a9bba41e6b08583f64388d7b5581e616ec9066
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107873
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 5caeb3161b8a..8c59586cea38 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1335,12 +1335,12 @@ enum Result { R_NOTHING, R_OVERFLOW, R_SUCCESS };
 }
 
 static Result
-readUnsignedNumber(const OUString & rString,
-sal_Int32 & io_rnPos, sal_Int32 & o_rNumber)
+readUnsignedNumber(std::u16string_view rString,
+size_t & io_rnPos, sal_Int32 & o_rNumber)
 {
-sal_Int32 nPos(io_rnPos);
+size_t nPos(io_rnPos);
 
-while (nPos < rString.getLength())
+while (nPos < rString.size())
 {
 const sal_Unicode c = rString[nPos];
 if (('0' > c) || (c > '9'))
@@ -1354,7 +1354,7 @@ readUnsignedNumber(const OUString & rString,
 return R_NOTHING;
 }
 
-const sal_Int64 nTemp = rtl_ustr_toInt64_WithLength(rString.getStr() + 
io_rnPos, 10, nPos - io_rnPos);
+const sal_Int64 nTemp = rtl_ustr_toInt64_WithLength(rString.data() + 
io_rnPos, 10, nPos - io_rnPos);
 
 const bool bOverflow = (nTemp >= SAL_MAX_INT32);
 
@@ -1365,15 +1365,15 @@ readUnsignedNumber(const OUString & rString,
 
 static Result
 readUnsignedNumberMaxDigits(int maxDigits,
-const OUString & rString, sal_Int32 & io_rnPos,
+std::u16string_view rString, size_t & io_rnPos,
 sal_Int32 & o_rNumber)
 {
 bool bOverflow(false);
 sal_Int64 nTemp(0);
-sal_Int32 nPos(io_rnPos);
+size_t nPos(io_rnPos);
 OSL_ENSURE(maxDigits >= 0, "negative amount of digits makes no sense");
 
-while (nPos < rString.getLength())
+while (nPos < rString.size())
 {
 const sal_Unicode c = rString[nPos];
 if (('0' <= c) && (c <= '9'))
@@ -1408,10 +1408,10 @@ readUnsignedNumberMaxDigits(int maxDigits,
 }
 
 static bool
-readDurationT(const OUString & rString, sal_Int32 & io_rnPos)
+readDurationT(std::u16string_view rString, size_t & io_rnPos)
 {
-if ((io_rnPos < rString.getLength()) &&
-(rString[io_rnPos] == 'T'))
+if ((io_rnPos < rString.size()) &&
+(rString[io_rnPos] == 'T' || rString[io_rnPos] == 't'))
 {
 ++io_rnPos;
 return true;
@@ -1420,11 +1420,11 @@ readDurationT(const OUString & rString, sal_Int32 & 
io_rnPos)
 }
 
 static bool
-readDurationComponent(const OUString & rString,
-sal_Int32 & io_rnPos, sal_Int32 & io_rnTemp, bool & io_rbTimePart,
+readDurationComponent(std::u16string_view rString,
+size_t & io_rnPos, sal_Int32 & io_rnTemp, bool & io_rbTimePart,
 sal_Int32 & o_rnTarget, const sal_Unicode cLower, const sal_Unicode cUpper)
 {
-if (io_rnPos < rString.getLength())
+if (io_rnPos < rString.size())
 {
 if (cLower == rString[io_rnPos] || cUpper == rString[io_rnPos])
 {
@@ -1454,7 +1454,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 std::u16string_view rString)
 {
 std::u16string_view string = trim(rString);
-sal_Int32 nPos(0);
+size_t nPos(0);
 
 bool bIsNegativeDuration(false);
 if (!string.empty() && ('-' == string[0]))
@@ -1463,7 +1463,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 ++nPos;
 }
 
-if (nPos < static_cast(string.size())
+if (nPos < string.size()
 && string[nPos] != 'P' && string[nPos] != 'p') // duration must start 
with "P"
 {
 return false;
@@ -1524,7 +1524,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 }
 
 // eeek! seconds are icky.
-if ((nPos < static_cast(string.size())) && bSuccess)
+if ((nPos < string.size()) && bSuccess)
 {
 if (string[nPos] == '.' ||
 string[nPos] == ',')
@@ -1536,7 +1536,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 nTemp = -1;
 const sal_Int32 nStart(nPos);
 bSuccess = readUnsignedNumberMaxDigits(9, string, nPos, 
nTemp) == R_SUCCESS;
-if ((nPos < static_cast(string.size())) && 
bSuccess)
+if ((nPos < string.size()) && bSuccess)
 {
 if (-1 != nTemp)
 {
@@ -1584,7 +1584,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 }
 }
 
-if (nPos != static_cast(string.size())) // string not processed 

[Libreoffice-commits] core.git: sax/source

2020-12-16 Thread dante (via logerrit)
 sax/source/fastparser/fastparser.cxx |   52 +++
 1 file changed, 35 insertions(+), 17 deletions(-)

New commits:
commit 9edd554eb634bcb88add30e3290cb9a8650ce38f
Author: dante 
AuthorDate: Tue Dec 15 15:39:21 2020 +0100
Commit: Noel Grandin 
CommitDate: Thu Dec 17 07:59:07 2020 +0100

Sort custom entity names on fast parser

When there are lots of entities and a lot of cases to replace, it becomes a 
ballast to search the whole array.
So in order to avoid it, now uses ordered search and stops when OUString 
order implies that it can't be further.
The entity list is sorted before the parse by quick sort.

Change-Id: I9c91338ad67ddea1c273e329542549a904a0e563
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107774
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index f0fe5aea2f67..94d2651d4dff 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -200,6 +200,21 @@ struct Entity : public ParserData
 Event& getEvent( CallbackType aType );
 };
 
+// Stuff for custom entity names
+struct ReplacementPair
+{
+OUString name;
+OUString replacement;
+};
+inline bool operator<(const ReplacementPair& lhs, const ReplacementPair& rhs)
+{
+return lhs.name < rhs.name;
+}
+inline bool operator<(const ReplacementPair& lhs, const char* rhs)
+{
+return lhs.name.compareToAscii(rhs) < 0;
+}
+
 } // namespace
 
 namespace sax_fastparser {
@@ -211,8 +226,7 @@ public:
 ~FastSaxParserImpl();
 
 private:
-::css::uno::Sequence< ::rtl::OUString > mEntityNames;
-::css::uno::Sequence< ::rtl::OUString > mEntityReplacements;
+std::vector m_Replacements;
 
 public:
 // XFastParser
@@ -934,10 +948,18 @@ void FastSaxParserImpl::setNamespaceHandler( const 
Reference< XFastNamespaceHand
 maData.mxNamespaceHandler = Handler;
 }
 
-void FastSaxParserImpl::setCustomEntityNames( const ::css::uno::Sequence< 
::rtl::OUString >& names, const ::css::uno::Sequence< ::rtl::OUString >& 
replacements )
+void FastSaxParserImpl::setCustomEntityNames(
+const ::css::uno::Sequence<::rtl::OUString>& names,
+const ::css::uno::Sequence<::rtl::OUString>& replacements)
 {
-mEntityNames = names;
-mEntityReplacements = replacements;
+m_Replacements.resize(names.size());
+for (size_t i = 0; i < names.size(); ++i)
+{
+m_Replacements[i].name = names[i];
+m_Replacements[i].replacement = replacements[i];
+}
+if (names.size() > 1)
+std::sort(m_Replacements.begin(), m_Replacements.end());
 }
 
 void FastSaxParserImpl::deleteUsedEvents()
@@ -1372,18 +1394,13 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( 
const xmlChar *name )
 int lname = strlen(dname);
 if( lname == 0 )
 return xmlGetPredefinedEntity(name);
-if (mEntityNames.hasElements())
+if (m_Replacements.size() > 0)
 {
-for (size_t i = 0; i < mEntityNames.size(); ++i)
-{
-if (mEntityNames[i].compareToAscii(dname) == 0)
-{
-return xmlNewEntity(
-nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, 
nullptr,
-BAD_CAST(
-OUStringToOString(mEntityReplacements[i], 
RTL_TEXTENCODING_UTF8).getStr()));
-}
-}
+auto it = std::lower_bound(m_Replacements.begin(), 
m_Replacements.end(), dname);
+if (it != m_Replacements.end() && it->name.compareToAscii(dname) == 0)
+return xmlNewEntity(
+nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+BAD_CAST(OUStringToOString(it->replacement, 
RTL_TEXTENCODING_UTF8).getStr()));
 }
 if( lname < 2 )
 return xmlGetPredefinedEntity(name);
@@ -1495,7 +1512,8 @@ OUString FastSaxParser::getImplementationName()
 return "com.sun.star.comp.extensions.xml.sax.FastParser";
 }
 
-void FastSaxParser::setCustomEntityNames( const ::css::uno::Sequence< 
::rtl::OUString >& names, const ::css::uno::Sequence< ::rtl::OUString >& 
replacements )
+void FastSaxParser::setCustomEntityNames(const 
::css::uno::Sequence<::rtl::OUString>& names,
+ const 
::css::uno::Sequence<::rtl::OUString>& replacements)
 {
 assert(names.size() == replacements.size());
 mpImpl->setCustomEntityNames(names, replacements);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source starmath/source

2020-12-10 Thread dante (via logerrit)
 sax/source/fastparser/fastparser.cxx |   18 +-
 starmath/source/mathmlattr.hxx   |1 -
 starmath/source/mathmlimport.cxx |1 +
 3 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit b9ffc3591189c54885094fefe477241418f67996
Author: dante 
AuthorDate: Wed Dec 9 17:14:17 2020 +0100
Commit: Mike Kaganski 
CommitDate: Fri Dec 11 07:40:00 2020 +0100

FastParser.cxx changes

If custom entity list is empty, custon entities by unicode value have to 
keep working.

Succefully loaded:

http://www.w3.org/1998/Math/MathML"; display="block">
 
  σ
  ∞
  σ
  ∞
 


Change-Id: I46cc5b04bd91d1aaadf3f99cb2079325bb0d08cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107498
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 04bf69a1705b..05288a4ef5f3 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -933,7 +933,6 @@ void FastSaxParserImpl::setNamespaceHandler( const 
Reference< XFastNamespaceHand
 maData.mxNamespaceHandler = Handler;
 }
 
-#include 
 void FastSaxParserImpl::setCustomEntityNames( const ::css::uno::Sequence< 
::rtl::OUString >& names, const ::css::uno::Sequence< ::rtl::OUString >& 
replacements )
 {
 mEntityNames = names;
@@ -1372,16 +1371,17 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( 
const xmlChar *name )
 int lname = strlen(dname);
 if( lname == 0 )
 return xmlGetPredefinedEntity(name);
-if( !mEntityNames.hasElements() )
-return xmlGetPredefinedEntity(name);
-for( size_t i = 0; i < mEntityNames.size(); ++i )
+if (mEntityNames.hasElements())
 {
-if( mEntityNames[i].compareToAscii(dname) == 0 )
+for (size_t i = 0; i < mEntityNames.size(); ++i)
 {
-return xmlNewEntity( nullptr,
-name,
-XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
-
BAD_CAST(OUStringToOString(mEntityReplacements[i],RTL_TEXTENCODING_UTF8).getStr()));
+if (mEntityNames[i].compareToAscii(dname) == 0)
+{
+return xmlNewEntity(
+nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, 
nullptr,
+BAD_CAST(
+OUStringToOString(mEntityReplacements[i], 
RTL_TEXTENCODING_UTF8).getStr()));
+}
 }
 }
 if( lname < 2 )
diff --git a/starmath/source/mathmlattr.hxx b/starmath/source/mathmlattr.hxx
index fba6f3bc4195..104495d2c878 100644
--- a/starmath/source/mathmlattr.hxx
+++ b/starmath/source/mathmlattr.hxx
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include "xparsmlbase.hxx"
 
 // MathML 3: 2.1.5.1 Syntax notation used in the MathML specification
 // 
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index c06d0043dee7..e68184660850 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -63,6 +63,7 @@ one go*/
 #include 
 
 #include "mathmlattr.hxx"
+#include "xparsmlbase.hxx"
 #include "mathmlimport.hxx"
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source starmath/Library_sm.mk starmath/source

2020-12-09 Thread dante (via logerrit)
 sax/source/fastparser/fastparser.cxx |   11 ++--
 starmath/Library_sm.mk   |1 
 starmath/source/mathmlattr.hxx   |1 
 starmath/source/mathmlimport.cxx |6 
 starmath/source/xparsmlbase.cxx  |   40 ++
 starmath/source/xparsmlbase.hxx  |   46 +++
 6 files changed, 102 insertions(+), 3 deletions(-)

New commits:
commit 6e0f18d7d523c62236a1968c36b4e0cc8586ac34
Author: dante 
AuthorDate: Wed Dec 2 00:12:05 2020 +0100
Commit: Noel Grandin 
CommitDate: Wed Dec 9 15:21:09 2020 +0100

Begining of support for &entityname for mathml.

Change-Id: I03ce79ed74088db3c1f6c1f87d7a75160ff19a30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107038
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 9b2d9bd97458..04bf69a1705b 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -933,6 +933,7 @@ void FastSaxParserImpl::setNamespaceHandler( const 
Reference< XFastNamespaceHand
 maData.mxNamespaceHandler = Handler;
 }
 
+#include 
 void FastSaxParserImpl::setCustomEntityNames( const ::css::uno::Sequence< 
::rtl::OUString >& names, const ::css::uno::Sequence< ::rtl::OUString >& 
replacements )
 {
 mEntityNames = names;
@@ -1368,6 +1369,11 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const 
xmlChar *name )
 if( !name )
 return xmlGetPredefinedEntity(name);
 const char* dname = XML_CAST(name);
+int lname = strlen(dname);
+if( lname == 0 )
+return xmlGetPredefinedEntity(name);
+if( !mEntityNames.hasElements() )
+return xmlGetPredefinedEntity(name);
 for( size_t i = 0; i < mEntityNames.size(); ++i )
 {
 if( mEntityNames[i].compareToAscii(dname) == 0 )
@@ -1378,12 +1384,11 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( 
const xmlChar *name )
 
BAD_CAST(OUStringToOString(mEntityReplacements[i],RTL_TEXTENCODING_UTF8).getStr()));
 }
 }
+if( lname < 2 )
+return xmlGetPredefinedEntity(name);
 if ( dname[0] == '#' )
 {
 sal_uInt32 cval = 0;
-int_fast16_t lname = strlen(dname);
-if( lname < 2 )
-return xmlGetPredefinedEntity(name);
 if( dname[1] == 'x' ||  dname[1] == 'X' )
 {
 if( lname < 3 )
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index a63b506783e1..cc3dab8875e7 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
 starmath/source/document \
 starmath/source/edit \
 starmath/source/format \
+starmath/source/xparsmlbase \
 starmath/source/mathmlattr \
 starmath/source/mathmlexport \
 starmath/source/mathmlimport \
diff --git a/starmath/source/mathmlattr.hxx b/starmath/source/mathmlattr.hxx
index 104495d2c878..fba6f3bc4195 100644
--- a/starmath/source/mathmlattr.hxx
+++ b/starmath/source/mathmlattr.hxx
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include "xparsmlbase.hxx"
 
 // MathML 3: 2.1.5.1 Syntax notation used in the MathML specification
 // 
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 5fa4a96ad406..c06d0043dee7 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -268,11 +268,17 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent(const 
Reference xFastParser(xFilter, UNO_QUERY);
 Reference 
xFastDocHandler(xFilter, UNO_QUERY);
 if (xFastParser)
+{
+
xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntitiesNames,
+  
starmathdatabase::icustomMathmlHtmlEntitiesValues);
 xFastParser->parseStream(aParserInput);
+}
 else if (xFastDocHandler)
 {
 Reference xParser
 = css::xml::sax::FastParser::create(rxContext);
+
xParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntitiesNames,
+  
starmathdatabase::icustomMathmlHtmlEntitiesValues);
 xParser->setFastDocumentHandler(xFastDocHandler);
 xParser->parseStream(aParserInput);
 }
diff --git a/starmath/source/xparsmlbase.cxx b/starmath/source/xparsmlbase.cxx
new file mode 100644
index ..8fbf6f9117f3
--- /dev/null
+++ b/starmath/source/xparsmlbase.cxx
@@ -0,0 +1,40 @@
+/* -*- 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 obtai

[Libreoffice-commits] core.git: sax/source

2020-12-07 Thread dante (via logerrit)
 sax/source/fastparser/fastparser.cxx |   39 +--
 1 file changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 1a6191621a0257c479bdfe24e125c0258d4b3d0d
Author: dante 
AuthorDate: Wed Dec 2 00:02:45 2020 +0100
Commit: Noel Grandin 
CommitDate: Mon Dec 7 13:28:52 2020 +0100

Adding suppor for &#; and &#x; on fastparser.

Change-Id: Iacbbe8a77532fe5034ceae286f50a74310f7d2ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107036
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 662991ff91ba..9b2d9bd97458 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 
 // Inverse of libxml's BAD_CAST.
 #define XML_CAST( str ) reinterpret_cast< const char* >( str )
@@ -1364,16 +1365,50 @@ void FastSaxParserImpl::callbackProcessingInstruction( 
const xmlChar *target, co
 
 xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const xmlChar *name )
 {
+if( !name )
+return xmlGetPredefinedEntity(name);
+const char* dname = XML_CAST(name);
 for( size_t i = 0; i < mEntityNames.size(); ++i )
 {
-if( mEntityNames[i].compareToAscii(XML_CAST(name)) == 0 )
+if( mEntityNames[i].compareToAscii(dname) == 0 )
 {
 return xmlNewEntity( nullptr,
-
BAD_CAST(OUStringToOString(mEntityNames[i],RTL_TEXTENCODING_UTF8).getStr()),
+name,
 XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
 
BAD_CAST(OUStringToOString(mEntityReplacements[i],RTL_TEXTENCODING_UTF8).getStr()));
 }
 }
+if ( dname[0] == '#' )
+{
+sal_uInt32 cval = 0;
+int_fast16_t lname = strlen(dname);
+if( lname < 2 )
+return xmlGetPredefinedEntity(name);
+if( dname[1] == 'x' ||  dname[1] == 'X' )
+{
+if( lname < 3 )
+return xmlGetPredefinedEntity(name);
+cval = static_cast( strtoul( dname + 2, nullptr, 16 ) 
);
+if( cval == 0 )
+return xmlGetPredefinedEntity(name);
+OUString vname( &cval, 1 );
+return xmlNewEntity( nullptr,
+name,
+XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+
BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+}
+else
+{
+cval = static_cast( strtoul( dname + 2, nullptr, 10 ) 
);
+if( cval == 0 )
+return xmlGetPredefinedEntity(name);
+OUString vname( &cval, 1 );
+return xmlNewEntity( nullptr,
+name,
+XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+
BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+}
+}
 return xmlGetPredefinedEntity(name);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sc/source

2020-12-01 Thread Caolán McNamara (via logerrit)
 sax/source/fastparser/fastparser.cxx|   28 ++--
 sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx |2 
 2 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit ebe25a18c4d2aa3fc5e1c8c57f14d71ce50cb15c
Author: Caolán McNamara 
AuthorDate: Tue Dec 1 13:16:16 2020 +
Commit: Caolán McNamara 
CommitDate: Tue Dec 1 18:17:14 2020 +0100

cid#1470375 Unrecoverable parse warning

and

cid#1470366 Unrecoverable parse warning
cid#1470365 Unrecoverable parse warning
cid#1470361 Unrecoverable parse warning
cid#1470360 Unrecoverable parse warning
cid#1470367 Unrecoverable parse warning

Change-Id: Ib0b5167de65d1a16438ba8f8c564b0b89d52e6d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106982
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 79ac533f72b6..662991ff91ba 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1495,20 +1495,20 @@ static void NormalizeURI( OUString& rName )
 bSuccess = NormalizeW3URI( rName );
 }
 
-const OUStringLiteral XML_URI_W3_PREFIX(u"http://www.w3.org/";);
-const OUStringLiteral XML_URI_XFORMS_SUFFIX(u"/xforms");
-const OUStringLiteral XML_N_XFORMS_1_0(u"http://www.w3.org/2002/xforms";);
-const OUStringLiteral XML_N_SVG(u"http://www.w3.org/2000/svg";);
-const OUStringLiteral 
XML_N_SVG_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
-const OUStringLiteral XML_N_FO(u"http://www.w3.org/1999/XSL/Format";);
-const OUStringLiteral 
XML_N_FO_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
-const OUStringLiteral XML_N_SMIL(u"http://www.w3.org/2001/SMIL20/";);
-const OUStringLiteral XML_N_SMIL_OLD(u"http://www.w3.org/2001/SMIL20";);
-const OUStringLiteral 
XML_N_SMIL_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
-const OUStringLiteral XML_URN_OASIS_NAMES_TC(u"urn:oasis:names:tc");
-const OUStringLiteral XML_XMLNS(u"xmlns");
-const OUStringLiteral XML_OPENDOCUMENT(u"opendocument");
-const OUStringLiteral XML_1_0(u"1.0");
+constexpr OUStringLiteral XML_URI_W3_PREFIX(u"http://www.w3.org/";);
+constexpr OUStringLiteral XML_URI_XFORMS_SUFFIX(u"/xforms");
+constexpr OUStringLiteral XML_N_XFORMS_1_0(u"http://www.w3.org/2002/xforms";);
+constexpr OUStringLiteral XML_N_SVG(u"http://www.w3.org/2000/svg";);
+constexpr OUStringLiteral 
XML_N_SVG_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
+constexpr OUStringLiteral XML_N_FO(u"http://www.w3.org/1999/XSL/Format";);
+constexpr OUStringLiteral 
XML_N_FO_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
+constexpr OUStringLiteral XML_N_SMIL(u"http://www.w3.org/2001/SMIL20/";);
+constexpr OUStringLiteral XML_N_SMIL_OLD(u"http://www.w3.org/2001/SMIL20";);
+constexpr OUStringLiteral 
XML_N_SMIL_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
+constexpr OUStringLiteral XML_URN_OASIS_NAMES_TC(u"urn:oasis:names:tc");
+constexpr OUStringLiteral XML_XMLNS(u"xmlns");
+constexpr OUStringLiteral XML_OPENDOCUMENT(u"opendocument");
+constexpr OUStringLiteral XML_1_0(u"1.0");
 
 static bool NormalizeW3URI( OUString& rName )
 {
diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx 
b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
index b48af4241a9b..f2e0155b578b 100644
--- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
@@ -49,7 +49,7 @@ const char* lclAnovaLabels[] =
 nullptr
 };
 
-const OUStringLiteral strWildcardRange = u"%RANGE%";
+constexpr OUStringLiteral strWildcardRange = u"%RANGE%";
 
 OUString lclCreateMultiParameterFormula(
 ScRangeList&aRangeList, const OUString& aFormulaTemplate,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-11-08 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |  145 ++-
 1 file changed, 143 insertions(+), 2 deletions(-)

New commits:
commit d63b3561efb6b01a11b4a26a0e1e609699915b4d
Author: Noel Grandin 
AuthorDate: Sun Nov 8 13:17:36 2020 +0200
Commit: Noel Grandin 
CommitDate: Sun Nov 8 14:23:22 2020 +0100

ofz#26944

this actually a regression from

commit 8c5ffecf1dbd3f93128910433da11d5315661680
Author: Noel 
   Date:   Fri Oct 23 15:12:22 2020 +0200
make SvXMLImport capable of mixing fast- and slow- contexts adhoc

where I did not get the namespace handling right, but it only
became obvious with

commit 3940cf7d716f3e469f47d3c831a799e58edf2eb8
Date:   Mon Nov 2 12:26:26 2020 +0200
drop the SvXMLExport::EndElement method..

Specifically, we have weird logic to treat some bad namespaces
as good (who knows why), but that logic only exists for the
slowparser path.
With the dropping of EndElement(), we ended up with calls
to SvXMLImport::startUnknownElement() calling
SvXMLImportContext::StartElement(), but without
a corresponding call to SvXMLImportContext::endFastElement.

To make this work right, I copied the namespace aliasing code
to FastParser.

Change-Id: I00ecbf046feeaac6f2a789f801175dba40836f84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105441
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 2b713b81576e..d51f471b43a1 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -62,6 +62,8 @@ using namespace ::com::sun::star::io;
 using namespace com::sun::star;
 using namespace sax_fastparser;
 
+static void NormalizeURI( OUString& rName );
+
 namespace {
 
 struct Event;
@@ -1151,8 +1153,10 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 // namespaces[] is (prefix/URI)
 if( namespaces[ i ] != nullptr )
 {
-DefineNamespace( OString( XML_CAST( namespaces[ i ] )),
-OUString( XML_CAST( namespaces[ i + 1 ] ), strlen( 
XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 ));
+OString aPrefix( XML_CAST( namespaces[ i ] ));
+OUString namespaceURL( XML_CAST( namespaces[ i + 1 ] ), 
strlen( XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 );
+NormalizeURI( namespaceURL );
+DefineNamespace(aPrefix, namespaceURL);
 if( rEntity.mxNamespaceHandler.is() )
 rEvent.mxDeclAttributes->addUnknown( OString( XML_CAST( 
namespaces[ i ] ) ), OString( XML_CAST( namespaces[ i + 1 ] ) ) );
 }
@@ -1160,6 +1164,7 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 {
 // default namespace
 sNamespace = OUString( XML_CAST( namespaces[ i + 1 ] ), 
strlen( XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 );
+NormalizeURI( sNamespace );
 nNamespaceToken = GetNamespaceToken( sNamespace );
 if( rEntity.mxNamespaceHandler.is() )
 rEvent.mxDeclAttributes->addUnknown( "", OString( 
XML_CAST( namespaces[ i + 1 ] ) ) );
@@ -1436,4 +1441,140 @@ 
com_sun_star_comp_extensions_xml_sax_FastParser_get_implementation(
 return cppu::acquire(new FastSaxParser);
 }
 
+// --
+// copy of the code in xmloff/source/core/namespace.cxx, which adds namespace 
aliases
+// for various dodgy namespace decls in the wild.
+
+static bool NormalizeW3URI( OUString& rName );
+static bool NormalizeOasisURN( OUString& rName );
+
+static void NormalizeURI( OUString& rName )
+{
+// try OASIS + W3 URI normalization
+bool bSuccess = NormalizeOasisURN( rName );
+if( ! bSuccess )
+bSuccess = NormalizeW3URI( rName );
+}
+
+const OUStringLiteral XML_URI_W3_PREFIX(u"http://www.w3.org/";);
+const OUStringLiteral XML_URI_XFORMS_SUFFIX(u"/xforms");
+const OUStringLiteral XML_N_XFORMS_1_0(u"http://www.w3.org/2002/xforms";);
+const OUStringLiteral XML_N_SVG(u"http://www.w3.org/2000/svg";);
+const OUStringLiteral 
XML_N_SVG_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
+const OUStringLiteral XML_N_FO(u"http://www.w3.org/1999/XSL/Format";);
+const OUStringLiteral 
XML_N_FO_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
+const OUStringLiteral XML_N_SMIL(u"http://www.w3.org/2001/SMIL20/";);
+const OUStringLiteral XML_N_SMIL_OLD(u"http://www.w3.org/2001/SMIL20";);
+const OUStringLiteral 
XML_N_SMIL_COMPAT(u"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
+const OUStringLiteral XML_URN_OASIS_NAMES_TC(u"urn:oasis:names:tc");
+const OUStringLiteral XML_XMLNS(u"xmlns");

[Libreoffice-commits] core.git: sax/source

2020-09-29 Thread Miklos Vajna (via logerrit)
 sax/source/fastparser/fastparser.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit cd85546a2fbdade42f80fd3b6bd650791db9f32d
Author: Miklos Vajna 
AuthorDate: Mon Sep 28 21:05:27 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 29 09:06:07 2020 +0200

tdf#136551 DOTX import: restore support for large XML attribute values

Regression from commit 82d08580e368afbc9d73da3613845a36a89b0a8c (switch
saxparser from expat to libxml2, 2014-11-14), expat used to allow huge
XML attribute values, while libxml2 defaults to rejecting values larger
than 10MB.

This looks like a sane limit, but the bugdoc has some fallback VML
markup where the actual graphic content of the shape is base64-encoded
in an XML attribute value.

libxml2 has an XML_PARSE_HUGE flag to lift this limit, so use that. If
this was not a problem with expat, then it should be no problem with
libxml2, either.

[ No testcase, adding a 10MB test document to the repo is not preferred. ]

Change-Id: Ifcd0ce52d3cb95bef36c58aa073bb59bc07490d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103567
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index a10ccdbcae24..2b713b81576e 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1061,8 +1061,10 @@ void FastSaxParserImpl::parse()
 throw SAXException("Couldn't create parser", Reference< 
XInterface >(), Any() );
 
 // Tell libxml2 parser to decode entities in attribute values.
+// Also allow XML attribute values which are larger than 10MB, 
because this used to work
+// with expat.
 // coverity[unsafe_xml_parse_config] - entity support is required
-xmlCtxtUseOptions(rEntity.mpParser, XML_PARSE_NOENT);
+xmlCtxtUseOptions(rEntity.mpParser, XML_PARSE_NOENT | 
XML_PARSE_HUGE);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-08-30 Thread Andrea Gelmini (via logerrit)
 sax/source/expatwrap/xml2utf.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit c0463f8a9fc4db7b62040010b3fefc9af3b17396
Author: Andrea Gelmini 
AuthorDate: Fri Aug 28 12:16:34 2020 +0200
Commit: Noel Grandin 
CommitDate: Mon Aug 31 08:34:55 2020 +0200

Fix typo in code

It passed "make check" on Linux

Change-Id: I86123dbc2052653aaf1d5c3a6fafb554c0b9a7fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101600
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index 9e531b13cfa6..1f044571d53d 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -160,7 +160,7 @@ void XMLFile2UTFConverter::removeEncoding( 
Sequence &seq )
 bool XMLFile2UTFConverter::isEncodingRecognizable( const Sequence< sal_Int8 > 
&seq)
 {
 const sal_Int8 *pSource = seq.getConstArray();
-bool bCheckIfFirstClosingBracketExsists = false;
+bool bCheckIfFirstClosingBracketExists = false;
 
 if( seq.getLength() < 8 ) {
 // no recognition possible, when less than 8 bytes are available
@@ -169,22 +169,22 @@ bool XMLFile2UTFConverter::isEncodingRecognizable( const 
Sequence< sal_Int8 > &s
 
 if( ! strncmp( reinterpret_cast(pSource), "') != seq.end();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-07-01 Thread Stephan Bergmann (via logerrit)
 sax/source/expatwrap/sax_expat.cxx  |2 +-
 sax/source/tools/converter.cxx  |   12 ++--
 sax/source/tools/fastserializer.cxx |   18 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit 5e3241cf1659a441af28f1e1adc8da2719e7cb85
Author: Stephan Bergmann 
AuthorDate: Wed Jul 1 19:54:23 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Jul 1 21:29:44 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: sax

Change-Id: I9f6a90d41d33350d0ebb72b1bf67527d24ab1dd2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97649
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index b80ebf033782..439166cb5641 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -140,7 +140,7 @@ struct Entity
 };
 
 
-static constexpr OUStringLiteral gsCDATA = "CDATA";
+constexpr OUStringLiteral gsCDATA = "CDATA";
 
 class SaxExpatParser_Impl
 {
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 1f070e0260e1..cea2c41e9caf 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -42,11 +42,11 @@ using namespace ::com::sun::star::i18n;
 
 namespace sax {
 
-static const char* const gpsMM = "mm";
-static const char* const gpsCM = "cm";
-static const char* const gpsPT = "pt";
-static const char* const gpsINCH = "in";
-static const char* const gpsPC = "pc";
+const char* const gpsMM = "mm";
+const char* const gpsCM = "cm";
+const char* const gpsPT = "pt";
+const char* const gpsINCH = "in";
+const char* const gpsPC = "pc";
 
 const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 14;
 
@@ -492,7 +492,7 @@ bool Converter::convertColor( sal_Int32& rColor, const 
OUString& rValue )
 return true;
 }
 
-static const char aHexTab[] = "0123456789abcdef";
+const char aHexTab[] = "0123456789abcdef";
 
 /** convert color to string */
 void Converter::convertColor( OUStringBuffer& rBuffer, sal_Int32 nColor )
diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 202641999b78..792784eb2a9c 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -42,15 +42,15 @@ using ::com::sun::star::io::XOutputStream;
 // number of characters without terminating 0
 #define N_CHARS(string) (SAL_N_ELEMENTS(string) - 1)
 
-static const char sClosingBracket[] = ">";
-static const char sSlashAndClosingBracket[] = "/>";
-static const char sColon[] = ":";
-static const char sOpeningBracket[] = "<";
-static const char sOpeningBracketAndSlash[] = "\n";
+const char sClosingBracket[] = ">";
+const char sSlashAndClosingBracket[] = "/>";
+const char sColon[] = ":";
+const char sOpeningBracket[] = "<";
+const char sOpeningBracketAndSlash[] = "\n";
 
 namespace sax_fastparser {
 FastSaxSerializer::FastSaxSerializer( const css::uno::Reference< 
css::io::XOutputStream >& xOutputStream )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-06-15 Thread Noel Grandin (via logerrit)
 sax/source/fastparser/fastparser.cxx |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 786d0b9abf76b2f84d333e18c902a374ab3b3090
Author: Noel Grandin 
AuthorDate: Mon Jun 15 09:26:24 2020 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 15 15:57:48 2020 +0200

small optimisations

remove a couple of string copies in the XML parser, which is always a
hot path

Change-Id: I84460ce13fb197bc7a3d354ff4c39d6939ff1d7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96313
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 49648fe626b2..a10ccdbcae24 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1227,9 +1227,12 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 nNamespaceToken = GetNamespaceToken( sNamespace );
 aElementPrefix = OUString( XML_CAST( prefix ), strlen( 
XML_CAST( prefix )), RTL_TEXTENCODING_UTF8 );
 }
-const OUString& rElementLocalName = OUString( XML_CAST( localName 
), strlen( XML_CAST( localName )), RTL_TEXTENCODING_UTF8 );
+OUString aElementLocalName( XML_CAST( localName ), strlen( 
XML_CAST( localName )), RTL_TEXTENCODING_UTF8 );
 rEvent.msNamespace = sNamespace;
-rEvent.msElementName = (aElementPrefix.isEmpty())? 
rElementLocalName : aElementPrefix + ":" + rElementLocalName;
+if( aElementPrefix.isEmpty() )
+rEvent.msElementName = std::move(aElementLocalName);
+else
+rEvent.msElementName = aElementPrefix + ":" + 
aElementLocalName;
 }
 else // token is always preferred.
 rEvent.msElementName.clear();
@@ -1305,7 +1308,7 @@ void FastSaxParserImpl::sendPendingCharacters()
 if (rEntity.mbEnableThreads)
 {
 Event& rEvent = rEntity.getEvent( CallbackType::CHARACTERS );
-rEvent.msChars = sChars;
+rEvent.msChars = std::move(sChars);
 produce();
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2020-04-02 Thread Noel Grandin (via logerrit)
 sax/source/expatwrap/sax_expat.cxx |   32 +-
 sax/source/expatwrap/xml2utf.cxx   |   65 ++---
 sax/source/fastparser/fastparser.cxx   |   65 ++---
 sax/source/fastparser/legacyfastparser.cxx |   88 ++---
 sax/source/tools/fastserializer.cxx|   30 -
 5 files changed, 139 insertions(+), 141 deletions(-)

New commits:
commit d8af42ec5004c8cdb57b6aa60a0f811cf61ad355
Author: Noel Grandin 
AuthorDate: Thu Apr 2 10:52:17 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 2 20:05:51 2020 +0200

loplugin:flatten in sax

Change-Id: I01c1f3328d04cf6ea7c76fab9547970387b968e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91551
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index 3172fbe89503..b80ebf033782 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -699,25 +699,25 @@ void SaxExpatParser_Impl::callbackStartElement( void 
*pvThis ,
 {
 SaxExpatParser_Impl *pImpl = static_cast(pvThis);
 
-if( pImpl->rDocumentHandler.is() ) {
-
-int i = 0;
-pImpl->rAttrList->Clear();
+if( !pImpl->rDocumentHandler.is() )
+return;
 
-while( awAttributes[i] ) {
-assert(awAttributes[i+1]);
-pImpl->rAttrList->AddAttribute(
-XML_CHAR_TO_OUSTRING( awAttributes[i] ) ,
-gsCDATA,  // expat doesn't know types
-XML_CHAR_TO_OUSTRING( awAttributes[i+1] ) );
-i +=2;
-}
+int i = 0;
+pImpl->rAttrList->Clear();
 
-CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(
-pImpl ,
-rDocumentHandler->startElement( XML_CHAR_TO_OUSTRING( pwName ) ,
-pImpl->rAttrList.get() ) );
+while( awAttributes[i] ) {
+assert(awAttributes[i+1]);
+pImpl->rAttrList->AddAttribute(
+XML_CHAR_TO_OUSTRING( awAttributes[i] ) ,
+gsCDATA,  // expat doesn't know types
+XML_CHAR_TO_OUSTRING( awAttributes[i+1] ) );
+i +=2;
 }
+
+CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(
+pImpl ,
+rDocumentHandler->startElement( XML_CHAR_TO_OUSTRING( pwName ) ,
+pImpl->rAttrList.get() ) );
 }
 
 void SaxExpatParser_Impl::callbackEndElement( void *pvThis , const XML_Char 
*pwName  )
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index 3e318d8827c3..420f90b6c3f0 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -117,43 +117,42 @@ sal_Int32 XMLFile2UTFConverter::readAndConvert( 
Sequence &seq , sal_In
 void XMLFile2UTFConverter::removeEncoding( Sequence &seq )
 {
 const sal_Int8 *pSource = seq.getArray();
-if (seq.getLength() >= 5 && !strncmp(reinterpret_cast(pSource), "= 5 && !strncmp(reinterpret_cast(pSource), "(pSource), seq.getLength() 
);
+// scan for encoding
+OString str( reinterpret_cast(pSource), seq.getLength() );
 
-// cut sequence to first line break
-// find first line break;
-int nMax = str.indexOf( 10 );
-if( nMax >= 0 )
-{
-str = str.copy( 0 , nMax );
-}
+// cut sequence to first line break
+// find first line break;
+int nMax = str.indexOf( 10 );
+if( nMax >= 0 )
+{
+str = str.copy( 0 , nMax );
+}
 
-int nFound = str.indexOf( " encoding" );
-if( nFound >= 0 ) {
-int nStop;
-int nStart = str.indexOf( "\"" , nFound );
-if( nStart < 0 || str.indexOf( "'" , nFound ) < nStart )
-{
-nStart = str.indexOf( "'" , nFound );
-nStop  = str.indexOf( "'" , nStart +1 );
-}
-else
-{
-nStop  = str.indexOf( "\"" , nStart +1);
-}
+int nFound = str.indexOf( " encoding" );
+if( nFound < 0 )return;
 
-if( nStart >= 0 && nStop >= 0 && nStart+1 < nStop )
-{
-// remove encoding tag from file
-memmove(&( seq.getArray()[nFound] ) ,
-&( seq.getArray()[nStop+1]) ,
-seq.getLength() - nStop -1);
-seq.realloc( seq.getLength() - ( nStop+1 - nFound ) );
-}
-}
+int nStop;
+int nStart = str.indexOf( "\"" , nFound );
+if( nStart < 0 || str.indexOf( "'" , nFound ) < nStart )
+{
+nStart = str.indexOf( "'" , nFound );
+nStop  = str.indexOf( "'" , nStart +1 );
+}
+else
+{
+nStop  = str.indexOf( "\"" , nStart +1);
+}
+
+if( nStart >= 0 && nStop >= 0 && nStart+1 < nStop )
+{
+// remove encoding tag from file
+memmove(&( seq.getArray

[Libreoffice-commits] core.git: sax/source xmloff/Library_xo.mk xmloff/source

2020-02-20 Thread Noel Grandin (via logerrit)
 sax/source/tools/fastattribs.cxx|4 
 xmloff/Library_xo.mk|2 
 xmloff/source/script/xmlbasici.cxx  |  147 --
 xmloff/source/script/xmlbasici.hxx  |   74 ---
 xmloff/source/script/xmlbasicscript.cxx |  323 
 xmloff/source/script/xmlbasicscript.hxx |  116 +++
 xmloff/source/script/xmlscripti.cxx |   21 --
 7 files changed, 451 insertions(+), 236 deletions(-)

New commits:
commit 4e97fa0f4e73acdf522643aeec486b1395e63727
Author: Noel Grandin 
AuthorDate: Thu Feb 20 13:09:32 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 20 13:37:48 2020 +0100

use fast-parser APIs for embedded script parsing

essentially, this duplicates and converts the service in
xmlscript/source/xmlflat_impexp/
and then converts it to use SvXMLImport APIs, stripping about 3 layers
of unnecessary indirection in the process.

Also improve some exception throwing in sax/ to make the next
programmers life easier when finding the source of exceptions.

Change-Id: I1ac552ee0565349e8322a55f6f609cf9f4521cab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89084
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 9b65718764fc..587749938c6b 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -144,7 +144,7 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 
Token )
getFastAttributeValue(i),
AttributeValueLength( i ) );
 
-throw SAXException();
+throw SAXException("FastAttributeList::getValueToken: unknown token " + 
OUString::number(Token), nullptr, Any());
 }
 
 sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, 
::sal_Int32 Default )
@@ -216,7 +216,7 @@ OUString FastAttributeList::getValue( ::sal_Int32 Token )
 if (maAttributeTokens[i] == Token)
 return OUString( getFastAttributeValue(i), 
AttributeValueLength(i), RTL_TEXTENCODING_UTF8 );
 
-throw SAXException();
+throw SAXException("FastAttributeList::getValue: unknown token " + 
OUString::number(Token), nullptr, Any());
 }
 
 OUString FastAttributeList::getValueByIndex( ::sal_Int32 nTokenIndex ) const
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 9cee6c131e83..3ea643c4be8f 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -193,7 +193,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
 xmloff/source/script/XMLScriptExportHandler \
 xmloff/source/script/XMLStarBasicContextFactory \
 xmloff/source/script/XMLStarBasicExportHandler \
-xmloff/source/script/xmlbasici \
+xmloff/source/script/xmlbasicscript \
 xmloff/source/script/xmlscripti \
 xmloff/source/style/AttributeContainerHandler \
 xmloff/source/style/DashStyle \
diff --git a/xmloff/source/script/xmlbasici.cxx 
b/xmloff/source/script/xmlbasici.cxx
deleted file mode 100644
index 0a69889f7218..
--- a/xmloff/source/script/xmlbasici.cxx
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "xmlbasici.hxx"
-#include 
-#include 
-#include 
-#include 
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
-// XMLBasicImportContext
-
-XMLBasicImportContext::XMLBasicImportContext( SvXMLImport& rImport, sal_uInt16 
nPrfx, const OUString& rLName,
-const Reference< frame::XModel >& rxModel )
-:SvXMLImportContext( rImport, nPrfx, rLName )
-,m_xModel( rxModel )
-{
-Reference< uno::XComponentContext > xContext = 
GetImport().GetComponentContext();
-m_xHandler = document::XMLOasisBasicImporter::create( xContext );
-
-m_xHandler->setTargetDocument( m_xModel );
-}
-
-XMLBasicImportContext::~XMLBasicImportContext()
-{
-}
-
-SvXMLImportContextRef XMLBasicImportContext::CreateChildContext(
-sal_uInt16 nPrefix, const OUString& rLocalName,
-const Reference< xml::sax::XAttributeList >& )
-{
-SvXMLImportContext* pContext = nullptr;
-
- 

[Libreoffice-commits] core.git: sax/source sccomp/source sc/source sfx2/source svtools/source sw/source

2020-01-15 Thread Mesut Çifci (via logerrit)
 sax/source/expatwrap/sax_expat.cxx  |3 +--
 sax/source/expatwrap/saxwriter.cxx  |3 +--
 sax/source/fastparser/fastparser.cxx|3 +--
 sc/source/filter/oox/ooxformulaparser.cxx   |3 +--
 sc/source/ui/unoobj/exceldetect.cxx |3 +--
 sccomp/source/solver/SolverComponent.cxx|3 +--
 sfx2/source/appl/appinit.cxx|3 +--
 sfx2/source/appl/macroloader.cxx|3 +--
 svtools/source/filter/SvFilterOptionsDialog.cxx |3 +--
 svtools/source/uno/unoevent.cxx |4 +---
 svtools/source/uno/wizard/unowizard.cxx |3 +--
 sw/source/core/docnode/finalthreadmanager.cxx   |3 +--
 sw/source/core/unocore/unocoll.cxx  |   24 
 sw/source/core/unocore/unodraw.cxx  |3 +--
 sw/source/core/unocore/unoportenum.cxx  |3 +--
 sw/source/uibase/ribbar/workctrl.cxx|3 +--
 16 files changed, 23 insertions(+), 47 deletions(-)

New commits:
commit b8f02637131fcfa499a6397914fdf4687c88053d
Author: Mesut Çifci 
AuthorDate: Wed Jan 15 11:33:29 2020 +0300
Commit: Stephan Bergmann 
CommitDate: Wed Jan 15 14:54:39 2020 +0100

tdf#88205 Adapt uses of css::uno::Sequence to use initializer_list ctor

Change-Id: Ib58c66590c60175d7984af55d23b7c55a6a2383e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86828
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sax/source/expatwrap/sax_expat.cxx 
b/sax/source/expatwrap/sax_expat.cxx
index c55cea3f2d04..3daafda63547 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -530,8 +530,7 @@ sal_Bool SaxExpatParser::supportsService(const OUString& 
ServiceName)
 // XServiceInfo
 css::uno::Sequence< OUString > SaxExpatParser::getSupportedServiceNames()
 {
-css::uno::Sequence seq { "com.sun.star.xml.sax.Parser" };
-return seq;
+return { "com.sun.star.xml.sax.Parser" };
 }
 
 
diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index ec59324524bf..f4f4c4bae142 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -1047,8 +1047,7 @@ sal_Bool SAXWriter::supportsService(const OUString& 
ServiceName)
 // XServiceInfo
 Sequence< OUString > SAXWriter::getSupportedServiceNames()
 {
-Sequence seq { "com.sun.star.xml.sax.Writer" };
-return seq;
+return { "com.sun.star.xml.sax.Writer" };
 }
 
 void SAXWriter::startDocument()
diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 2b843d03c74f..80bff5e9fef6 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1419,8 +1419,7 @@ sal_Bool FastSaxParser::supportsService( const OUString& 
ServiceName )
 
 uno::Sequence FastSaxParser::getSupportedServiceNames()
 {
-Sequence seq { "com.sun.star.xml.sax.FastParser" };
-return seq;
+return { "com.sun.star.xml.sax.FastParser" };
 }
 
 } // namespace sax_fastparser
diff --git a/sc/source/filter/oox/ooxformulaparser.cxx 
b/sc/source/filter/oox/ooxformulaparser.cxx
index 51422101d3ed..73e3565933b1 100644
--- a/sc/source/filter/oox/ooxformulaparser.cxx
+++ b/sc/source/filter/oox/ooxformulaparser.cxx
@@ -119,8 +119,7 @@ sal_Bool SAL_CALL OOXMLFormulaParser::supportsService( 
const OUString& rService
 
 Sequence< OUString > SAL_CALL OOXMLFormulaParser::getSupportedServiceNames()
 {
-Sequence< OUString > aServiceNames { 
"com.sun.star.sheet.FilterFormulaParser" };
-return aServiceNames;
+return { "com.sun.star.sheet.FilterFormulaParser" };
 }
 
 // com.sun.star.lang.XInitialization interface 
diff --git a/sc/source/ui/unoobj/exceldetect.cxx 
b/sc/source/ui/unoobj/exceldetect.cxx
index 41c5c01c9367..a56497f5cde3 100644
--- a/sc/source/ui/unoobj/exceldetect.cxx
+++ b/sc/source/ui/unoobj/exceldetect.cxx
@@ -37,8 +37,7 @@ sal_Bool ScExcelBiffDetect::supportsService( const OUString& 
aName )
 
 uno::Sequence ScExcelBiffDetect::getSupportedServiceNames()
 {
-uno::Sequence aNames { 
"com.sun.star.frame.ExtendedTypeDetection" };
-return aNames;
+return { "com.sun.star.frame.ExtendedTypeDetection" };
 }
 
 namespace {
diff --git a/sccomp/source/solver/SolverComponent.cxx 
b/sccomp/source/solver/SolverComponent.cxx
index 58ce00adf284..3df7bf5d5887 100644
--- a/sccomp/source/solver/SolverComponent.cxx
+++ b/sccomp/source/solver/SolverComponent.cxx
@@ -248,8 +248,7 @@ sal_Bool SAL_CALL SolverComponent::supportsService( const 
OUString& rServiceName
 
 uno::Sequence SAL_CALL SolverComponent::getSupportedServiceNames()
 {
-uno::Sequence aServiceNames { "com.sun.star.sheet.Solver" };
-return aServiceNames;
+return { "com.sun.star.sheet.Solver" };
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index 472a72e56

[Libreoffice-commits] core.git: sax/source

2019-12-05 Thread László Németh (via logerrit)
 sax/source/tools/fastserializer.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 579db0d2d3d2ddf5a5f8feaa2e7cc4dde81d7701
Author: László Németh 
AuthorDate: Thu Dec 5 11:42:59 2019 +0100
Commit: László Németh 
CommitDate: Fri Dec 6 08:10:51 2019 +0100

cleanup "tdf#117274 XLSX export: fix VML comment shape type id"

Limit special MSO ID check for attribute values.

Follow-up of commit c5d37d324cd6d17114c209de1862344ad58a1d93.

Change-Id: I0f16b0df0c5575b799bb505a93c660c15b3273c5
Reviewed-on: https://gerrit.libreoffice.org/84549
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index cc7293a6a3f9..a362ff438383 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -130,9 +130,7 @@ namespace sax_fastparser {
 if (nLen == -1)
 nLen = pStr ? strlen(pStr) : 0;
 
-if ( !bEscape ||
-// tdf#127274 don't escape the special VML shape type id 
"#_x_t202"
-(pStr && strcmp(pStr, "#_x_t202") == 0) )
+if (!bEscape)
 {
 writeBytes( pStr, nLen );
 return;
@@ -465,7 +463,12 @@ namespace sax_fastparser {
 
 writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote));
 
-write(rAttrList.getFastAttributeValue(j), 
rAttrList.AttributeValueLength(j), true);
+const char* pAttributeValue = rAttrList.getFastAttributeValue(j);
+
+// tdf#127274 don't escape the special VML shape type id 
"#_x_t202"
+bool bEscape = !(pAttributeValue && strcmp(pAttributeValue, 
"#_x_t202") == 0);
+
+write(pAttributeValue, rAttrList.AttributeValueLength(j), bEscape);
 
 writeBytes(sQuote, N_CHARS(sQuote));
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source sw/qa writerfilter/source

2019-11-16 Thread Mike Kaganski (via logerrit)
 sax/source/fastparser/fastparser.cxx  |   14 
 sw/qa/extras/ooxmlexport/data/tdf128820.fodt  | 1353 --
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   13 
 writerfilter/source/dmapper/PropertyMap.cxx   |   11 
 4 files changed, 41 insertions(+), 1350 deletions(-)

New commits:
commit 9fdf8c0a5cc036ea9bd1e11dd8f2c1a6e601fae2
Author: Mike Kaganski 
AuthorDate: Sat Nov 16 16:34:25 2019 +0300
Commit: Mike Kaganski 
CommitDate: Sat Nov 16 20:13:40 2019 +0100

Also consider saved exceptions when terminating parse

As with previous commit 18ae77a065cb8ae6940d4067f6ab7e99a3f74047, this
will start showing parse errors on invalid files which previously just
opened without warnings, silently losing the invalid stream part. Any
bug bisected to this commit is not a regression from this commit! The
real problem was already before, and was just disclosed by this (which
is the actual goal).

Also simplify unit test data for tdf#128820, which will now be enough
after the change.

A unit test (testN779627) revealed unexpected throws when parsing; this
was fixed.

Change-Id: I5a21b9001874ec6e3b8273c10043ef930bf1cc82
Reviewed-on: https://gerrit.libreoffice.org/82981
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 7383b8c339ea..9b35c1682be5 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -175,6 +175,8 @@ struct Entity : public ParserData
 css::uno::Any   maSavedException;
 osl::Mutex maSavedExceptionMutex;
 void saveException( const Any & e );
+// Thread-safe check if maSavedException has value
+bool hasException();
 void throwException( const ::rtl::Reference< FastLocatorImpl > 
&xDocumentLocator,
  bool mbDuringParse );
 
@@ -622,6 +624,12 @@ void Entity::saveException( const Any & e )
 }
 }
 
+bool Entity::hasException()
+{
+osl::MutexGuard g(maSavedExceptionMutex);
+return maSavedException.hasValue();
+}
+
 } // namespace
 
 namespace sax_fastparser {
@@ -1040,6 +1048,8 @@ void FastSaxParserImpl::parse()
 {
 if( xmlParseChunk( rEntity.mpParser, reinterpret_cast(seqOut.getConstArray()), 0, 1 ) != XML_ERR_OK )
 rEntity.throwException( mxDocumentLocator, true );
+if (rEntity.hasException())
+rEntity.throwException(mxDocumentLocator, true);
 }
 break;
 }
@@ -1068,10 +1078,8 @@ void FastSaxParserImpl::parse()
 {
 rEntity.throwException( mxDocumentLocator, true );
 }
-osl::ClearableMutexGuard g(rEntity.maSavedExceptionMutex);
-if (rEntity.maSavedException.hasValue())
+if (rEntity.hasException())
 {
-g.clear();
 rEntity.throwException( mxDocumentLocator, true );
 }
 } while( nRead > 0 );
diff --git a/sw/qa/extras/ooxmlexport/data/tdf128820.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf128820.fodt
index bb39fee02534..576fd966e28d 100644
--- a/sw/qa/extras/ooxmlexport/data/tdf128820.fodt
+++ b/sw/qa/extras/ooxmlexport/data/tdf128820.fodt
@@ -1,1353 +1,16 @@
 
 
-http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:dom="http://www.w3.org/2001/xml-

[Libreoffice-commits] core.git: sax/source

2019-11-13 Thread Stephan Bergmann (via logerrit)
 sax/source/expatwrap/saxwriter.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit 7e09d08807b5ba2fd8b9831557752a415bdad562
Author: Stephan Bergmann 
AuthorDate: Wed Nov 13 18:39:35 2019 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 13 22:30:31 2019 +0100

Fix useless assert(true) (which would never fire)

...and simplify the code a bit.  It had been introduced with
0a1d5af2a18d6a062c45d65689fbce619922dcc8 "tdf#115429 sax: assert if 
exporting an
invalid XML attribute/element", apparently meant to be an assert(false) 
instead.
A `make check screenshot` didn't cause the (now active) assert to fire in my
local build.

Change-Id: I275661f290491ff2d094288522f98d77cb4662ec
Reviewed-on: https://gerrit.libreoffice.org/82631
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index 901682a5ca01..7eb599a5cfc6 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -578,10 +578,8 @@ void CheckValidName(OUString const& rName)
 auto const c(rName[i]);
 if (c == ':')
 {
-if (hasColon)
-assert("only one colon allowed");
-else
-hasColon = true;
+assert(!hasColon && "only one colon allowed");
+hasColon = true;
 }
 else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != 
'.' &&
  !inrange(c, 0x00C0, 0x00D6) && !inrange(c, 0x00D8, 0x00F6) &&
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source

2019-10-31 Thread Noel Grandin (via logerrit)
 sax/source/tools/fastattribs.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 01a8d79fd76f7e523169c56a22be8ff84d8cd76a
Author: Noel Grandin 
AuthorDate: Thu Oct 31 08:07:26 2019 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 31 08:25:40 2019 +0100

tdf#125688, special-case empty return

in FastAttributeList::getUnknownAttributes,
shaves 5% off load time

Change-Id: I5acac243d7af0c6fb44cbc15832f9d322fa6c7f4
Reviewed-on: https://gerrit.libreoffice.org/81819
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 8aff8569d903..91df59d05107 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -234,7 +234,10 @@ OUString FastAttributeList::getOptionalValue( ::sal_Int32 
Token )
 }
 Sequence< Attribute > FastAttributeList::getUnknownAttributes(  )
 {
-Sequence< Attribute > aSeq( maUnknownAttributes.size() );
+auto nSize = maUnknownAttributes.size();
+if (nSize == 0)
+return {};
+Sequence< Attribute > aSeq( nSize );
 Attribute* pAttr = aSeq.getArray();
 for( const auto& rAttr : maUnknownAttributes )
 rAttr.FillAttribute( pAttr++ );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source

2019-10-12 Thread Julien Nabet (via logerrit)
 sax/source/tools/converter.cxx |   16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

New commits:
commit ad0bad298f33f0f530a3c797f777db1cdebad93b
Author: Julien Nabet 
AuthorDate: Sat Oct 12 11:17:42 2019 +0200
Commit: Julien Nabet 
CommitDate: Sat Oct 12 12:59:28 2019 +0200

No need to create functions for just returning "true" or "false"

Change-Id: I9c16047012675474bc2b58f33a65dd10d8aafbf6
Reviewed-on: https://gerrit.libreoffice.org/80711
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 95bb262a846c..15f8abbde4e3 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -422,28 +422,18 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer,
 rBuffer.appendAscii( psUnit );
 }
 
-static OUString getTrueString()
-{
-return "true";
-}
-
-static OUString getFalseString()
-{
-return "false";
-}
-
 /** convert string to boolean */
 bool Converter::convertBool( bool& rBool, const OUString& rString )
 {
-rBool = rString == getTrueString();
+rBool = rString == "true";
 
-return rBool || (rString == getFalseString());
+return rBool || (rString == "false");
 }
 
 /** convert boolean to string */
 void Converter::convertBool( OUStringBuffer& rBuffer, bool bValue )
 {
-rBuffer.append( bValue ? getTrueString() : getFalseString() );
+rBuffer.append( bValue );
 }
 
 /** convert string to percent */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source

2019-07-24 Thread Caolán McNamara (via logerrit)
 sax/source/fastparser/fastparser.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit da346f7afbe5e42b07c205c1c61c48d0f7036931
Author: Caolán McNamara 
AuthorDate: Wed Jul 24 11:16:14 2019 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jul 24 17:37:22 2019 +0200

cid#1448394 can't change xml_parse_config setting

Change-Id: I8c45c9d5e0a6bc7439aa4d0827e4752ec364d12c
Reviewed-on: https://gerrit.libreoffice.org/76247
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 1ac7b209d311..6114cbc469d1 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1055,6 +1055,7 @@ void FastSaxParserImpl::parse()
 throw SAXException("Couldn't create parser", Reference< 
XInterface >(), Any() );
 
 // Tell libxml2 parser to decode entities in attribute values.
+// coverity[unsafe-xml-parse-config] - entity support is required
 xmlCtxtUseOptions(rEntity.mpParser, XML_PARSE_NOENT);
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source

2019-05-30 Thread Eike Rathke (via logerrit)
 sax/source/tools/fastserializer.cxx |   43 +++-
 1 file changed, 33 insertions(+), 10 deletions(-)

New commits:
commit f677885fec59f252f36673ee4d8c0b4863625a4d
Author: Eike Rathke 
AuthorDate: Wed May 29 21:08:38 2019 +0200
Commit: Eike Rathke 
CommitDate: Thu May 30 19:21:56 2019 +0200

Resolves: tdf#125279 do not double _x005F_ escapement

Reading OOXML _x005F_ escaped content may not get unescaped, so
when writing back to OOXML do not attempt to escape it again, i.e.
write _x005F_x_ as is and not as _x005F_x005F_x_.

This is more a workaround, the proper fix would be to unescape
_x005F_ content upon read. But then the entire "invalid XML
character" escapement and handling control characters rat tail
would come into play.

Change-Id: I3d31dc84a362753c23a8c89f7a5d7bfd06e4367b
Reviewed-on: https://gerrit.libreoffice.org/73187
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 1a422ad8239a..70a359b1c5ee 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -199,6 +199,7 @@ namespace sax_fastparser {
 default:
 if (mbXescape)
 {
+char c1, c2, c3, c4;
 // Escape characters not valid in XML 1.0 as
 // _x_. A literal "_x_" has to be
 // escaped as _x005F_x_ (effectively
@@ -209,22 +210,44 @@ namespace sax_fastparser {
 if (c == '_' && i >= nNextXescape && i <= nLen 
- kXescapeLen &&
 pStr[i+6] == '_' &&
 ((pStr[i+1] | 0x20) == 'x') &&
-isHexDigit( pStr[i+2] ) &&
-isHexDigit( pStr[i+3] ) &&
-isHexDigit( pStr[i+4] ) &&
-isHexDigit( pStr[i+5] ))
+isHexDigit( c1 = pStr[i+2] ) &&
+isHexDigit( c2 = pStr[i+3] ) &&
+isHexDigit( c3 = pStr[i+4] ) &&
+isHexDigit( c4 = pStr[i+5] ))
 {
 // OOXML has the odd habit to write some
 // names using this that when re-saving
 // should *not* be escaped, specifically
 // _x0020_ for blanks in w:xpath values.
-if (strncmp( pStr+i+2, "0020", 4) != 0)
+if (!(c1 == '0' && c2 == '0' && c3 == '2' 
&& c4 == '0'))
 {
-writeBytes( "_x005F_", kXescapeLen);
-// Remember this escapement so in
-// _x_x_ only the first '_' is
-// escaped.
-nNextXescape = i + kXescapeLen;
+// When encountering "_x005F_x_"
+// assume that is an already escaped
+// sequence that was not unescaped and
+// shall be written as is, to not end
+// up with "_x005F_x005F_x_" and
+// repeated..
+if (c1 == '0' && c2 == '0' && c3 == 
'5' && (c4 | 0x20) == 'f' &&
+i + kXescapeLen <= nLen - 6 &&
+pStr[i+kXescapeLen+5] == '_' &&
+((pStr[i+kXescapeLen+0] | 
0x20) == 'x') &&
+isHexDigit( 
pStr[i+kXescapeLen+1] ) &&
+isHexDigit( 
pStr[i+kXescapeLen+2] ) &&
+isHexDigit( 
pStr[i+kXescapeLen+3] ) &&
+isHexDigit( 
pStr[i+kXescapeLen+4] ))
+{
+writeBytes( &c, 1 );
+// Remember this fake escapement.
+nNextXescape = i + kXescapeLen + 6;
+}
+else
+{
+   

[Libreoffice-commits] core.git: sax/source

2019-05-30 Thread Eike Rathke (via logerrit)
 sax/source/tools/fastserializer.cxx |   16 
 sax/source/tools/fastserializer.hxx |3 +++
 2 files changed, 19 insertions(+)

New commits:
commit 63c4e82c910422f928c8e0bcbb82b6c43d4d5557
Author: Eike Rathke 
AuthorDate: Tue May 14 16:32:12 2019 +0200
Commit: Eike Rathke 
CommitDate: Thu May 30 19:21:33 2019 +0200

Reintroduce mbXescape that got overaggressively removed

with

commit d4d37662b090cb237585156a47cd8e1f1cbe2656
CommitDate: Fri Oct 12 12:46:45 2018 +0200

loplugin:constfields in reportdesign,sal,sax

which killed also the bGood checking and later because that wasn't
used anymore also the SAL_WARN_IF() was eliminated with

commit 41eeaace84b45c803fff3ebd5ab981f0ad09393b
CommitDate: Mon Oct 29 15:12:26 2018 +0100

loplugin:oncevar

The mbXescape variable will be used, as the TODO said..

Change-Id: I11091379c27cf0222677595eb723b61ad3ebe4e8
Reviewed-on: https://gerrit.libreoffice.org/72302
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 4a4091438a40..1a422ad8239a 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -59,6 +59,7 @@ namespace sax_fastparser {
 , mbMarkStackEmpty(true)
 , mpDoubleStr(nullptr)
 , mnDoubleStrCapacity(RTL_STR_MAX_VALUEOFDOUBLE)
+, mbXescape(true)
 {
 rtl_string_new_WithLength(&mpDoubleStr, mnDoubleStrCapacity);
 mxFastTokenHandler = css::xml::sax::FastTokenHandler::create(
@@ -135,6 +136,7 @@ namespace sax_fastparser {
 return;
 }
 
+bool bGood = true;
 const sal_Int32 kXescapeLen = 7;
 char bufXescape[kXescapeLen+1];
 sal_Int32 nNextXescape = 0;
@@ -195,6 +197,7 @@ namespace sax_fastparser {
 }
 break;
 default:
+if (mbXescape)
 {
 // Escape characters not valid in XML 1.0 as
 // _x_. A literal "_x_" has to be
@@ -239,10 +242,23 @@ namespace sax_fastparser {
  * scanning for both encoded sequences and
  * write as _x_? */
 }
+#if OSL_DEBUG_LEVEL > 0
+else
+{
+if (bGood && invalidChar(pStr[i]))
+{
+bGood = false;
+// The SAL_WARN() for the single character 
is
+// issued in writeBytes(), just gather for 
the
+// SAL_WARN_IF() below.
+}
+}
+#endif
 writeBytes( &c, 1 );
 break;
 }
 }
+SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << 
OString(pStr,std::min(nLen,42)) << "'");
 }
 
 void FastSaxSerializer::endDocument()
diff --git a/sax/source/tools/fastserializer.hxx 
b/sax/source/tools/fastserializer.hxx
index b00ccf0923df..e3aa17a78f91 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -228,6 +228,9 @@ private:
 rtl_String *mpDoubleStr;
 sal_Int32 mnDoubleStrCapacity;
 TokenValueList maTokenValues;
+bool mbXescape; ///< whether to escape invalid XML characters as 
_x_ in write(const char*,sal_Int32,true)
+/* TODO: make that configurable from the outside for
+ * some specific cases? */
 
 #ifdef DBG_UTIL
 std::stack m_DebugStartedElements;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: sax/source scripting/source sdext/source sd/inc sd/source sfx2/inc sfx2/source shell/source starmath/inc starmath/source svl/source svtools/inc svtools/source

2019-01-28 Thread Libreoffice Gerrit user
 sax/source/expatwrap/xml2utf.cxx   |5 -
 sax/source/fastparser/legacyfastparser.cxx |3 -
 scripting/source/stringresource/stringresource.cxx |5 -
 sd/inc/pch/precompiled_sd.hxx  |1 
 sd/source/core/annotations/Annotation.cxx  |5 -
 sd/source/core/drawdoc3.cxx|   19 +++
 sd/source/core/sdpage.cxx  |   11 +---
 sd/source/core/sdpage2.cxx |3 -
 sd/source/core/text/textapi.cxx|5 -
 sd/source/core/undo/undofactory.cxx|   13 ++---
 sd/source/filter/eppt/pptx-animations.cxx  |5 -
 sd/source/filter/eppt/pptx-text.cxx|3 -
 sd/source/filter/ppt/propread.cxx  |   13 ++---
 sd/source/ui/animations/CustomAnimationList.cxx|9 +--
 sd/source/ui/animations/CustomAnimationPane.cxx|5 -
 sd/source/ui/animations/motionpathtag.cxx  |   23 -
 sd/source/ui/app/sddll.cxx |3 -
 sd/source/ui/app/sdmod2.cxx|3 -
 sd/source/ui/dlg/TemplateScanner.cxx   |3 -
 sd/source/ui/dlg/sddlgfact.cxx |   37 +++---
 sd/source/ui/dlg/sdtreelb.cxx  |3 -
 sd/source/ui/dlg/unchss.cxx|6 --
 sd/source/ui/docshell/docshel4.cxx |   15 ++---
 sd/source/ui/docshell/docshell.cxx |1 
 sd/source/ui/func/fulinend.cxx |3 -
 sd/source/ui/func/fupage.cxx   |3 -
 sd/source/ui/func/fuprobjs.cxx |3 -
 sd/source/ui/func/undoback.cxx |8 +--
 sd/source/ui/remotecontrol/BluetoothServer.cxx |9 +--
 sd/source/ui/sidebar/DocumentHelper.cxx|5 -
 sd/source/ui/sidebar/MasterPagesSelector.cxx   |3 -
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx |5 -
 sd/source/ui/unoidl/UnoDocumentSettings.cxx|3 -
 sd/source/ui/unoidl/unopback.cxx   |5 -
 sd/source/ui/view/OutlinerIterator.cxx |5 -
 sd/source/ui/view/ViewShellImplementation.cxx  |4 -
 sd/source/ui/view/drawview.cxx |9 +--
 sd/source/ui/view/drviews2.cxx |5 -
 sd/source/ui/view/drviews9.cxx |   11 +---
 sd/source/ui/view/drviewsb.cxx |3 -
 sd/source/ui/view/drviewse.cxx |3 -
 sd/source/ui/view/sdview3.cxx  |2 
 sd/source/ui/view/viewoverlaymanager.cxx   |5 -
 sdext/source/pdfimport/pdfparse/pdfentries.cxx |3 -
 sdext/source/pdfimport/pdfparse/pdfparse.cxx   |   13 ++---
 sfx2/inc/pch/precompiled_sfx.hxx   |1 
 sfx2/source/appl/workwin.cxx   |4 -
 sfx2/source/bastyp/fltfnc.cxx  |3 -
 sfx2/source/control/bindings.cxx   |2 
 sfx2/source/control/dispatch.cxx   |2 
 sfx2/source/control/recentdocsview.cxx |3 -
 sfx2/source/control/unoctitm.cxx   |4 -
 sfx2/source/dialog/dockwin.cxx |4 -
 sfx2/source/dialog/templdlg.cxx|7 +-
 sfx2/source/doc/docfile.cxx|3 -
 sfx2/source/doc/doctempl.cxx   |7 +-
 sfx2/source/sidebar/SidebarController.cxx  |3 -
 sfx2/source/view/classificationhelper.cxx  |3 -
 shell/source/win32/simplemail/smplmailclient.cxx   |3 -
 starmath/inc/pch/precompiled_sm.hxx|1 
 starmath/source/ElementsDockingWindow.cxx  |7 +-
 starmath/source/accessibility.cxx  |3 -
 starmath/source/caret.cxx  |4 -
 starmath/source/document.cxx   |   13 ++---
 starmath/source/edit.cxx   |3 -
 starmath/source/mathmlimport.cxx   |9 +--
 starmath/source/parse.cxx  |   43 -
 starmath/source/smdll.cxx  |3 -
 starmath/source/smmod.cxx  |3 -
 starmath/source/unomodel.cxx   |3 -
 svl/source/items/style.cxx |5 -
 svl/source/items/stylepool.cxx |3 -
 svl/source/numbers/zforlist.cxx|5 -
 svl/source/svdde/ddecli.cxx|3 -
 svtools/inc/pch/precompiled_svt.hxx|1 
 svtools/source/control/toolbarmenu.cxx  

[Libreoffice-commits] core.git: sax/source

2018-10-21 Thread Libreoffice Gerrit user
 sax/source/tools/fastattribs.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 52d68e39c749de45cbec4c9114c8d10d65d45936
Author: Mike Kaganski 
AuthorDate: Sat Oct 20 22:35:49 2018 +0200
Commit: Mike Kaganski 
CommitDate: Sun Oct 21 11:30:34 2018 +0200

tdf#120703 (PVS): handle failed realloc

V701 realloc() possible leak: when realloc() fails in allocating memory, 
original
 pointer 'mpChunk' is lost. Consider assigning realloc() to a temporary 
pointer.

Change-Id: If85475cf22ea10e4db35532724d947e4e9005e91
Reviewed-on: https://gerrit.libreoffice.org/62091
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index b8d1bacec630..d7ecbc1bd13d 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -85,8 +85,14 @@ void FastAttributeList::add( sal_Int32 nToken, const 
sal_Char* pValue, size_t nV
 maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 );
 if (maAttributeValues.back() > mnChunkLength)
 {
-mnChunkLength = std::max(mnChunkLength * 2, maAttributeValues.back());
-mpChunk = static_cast(realloc( mpChunk, mnChunkLength ));
+const sal_Int32 newLen = std::max(mnChunkLength * 2, 
maAttributeValues.back());
+if (auto p = static_cast(realloc(mpChunk, newLen)))
+{
+mnChunkLength = newLen;
+mpChunk = p;
+}
+else
+throw std::bad_alloc();
 }
 strncpy(mpChunk + nWritePosition, pValue, nValueLength);
 mpChunk[nWritePosition + nValueLength] = '\0';
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-10-17 Thread Libreoffice Gerrit user
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1d63be277eb7daedc7c59850ab53b6341352d0fd
Author: Caolán McNamara 
AuthorDate: Tue Oct 16 21:30:52 2018 +0100
Commit: Caolán McNamara 
CommitDate: Wed Oct 17 10:05:38 2018 +0200

ofz: thread shenanigans

Change-Id: I638b4e670f88aee78b6bd9ec638014795e103971
Reviewed-on: https://gerrit.libreoffice.org/61851
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 3d53147d9382..c910ad83381f 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -759,8 +759,8 @@ namespace
 xmlFreeDoc(m_rEntity.mpParser->myDoc);
 xmlFreeParserCtxt(m_rEntity.mpParser);
 }
-m_rParser.popEntity();
 joinThread();
+m_rParser.popEntity();
 }
 void setThread(const rtl::Reference &xParser)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-09-14 Thread Libreoffice Gerrit user
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6b12e4a9be9283951ac234692e79c9e00cd32654
Author: Michael Meeks 
AuthorDate: Fri Sep 14 11:53:39 2018 +0100
Commit: Michael Meeks 
CommitDate: Fri Sep 14 16:25:15 2018 +0200

Join the thread only if launch succeeded.

Change-Id: Idee779cea587e11f6d0f7902182c9394e73d46eb
Reviewed-on: https://gerrit.libreoffice.org/60488
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 2c730685f526..447acdc68274 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -814,8 +814,8 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 {
 rtl::Reference xParser;
 xParser = new ParserThread(this);
-aEnsureFree.setThread(xParser);
 xParser->launch();
+aEnsureFree.setThread(xParser);
 bool done = false;
 do {
 rEntity.maConsumeResume.wait();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-09-12 Thread Libreoffice Gerrit user
 sax/source/fastparser/fastparser.cxx |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit efa2681db1fb66e5f3677adff3a5e91ccba6b9ec
Author: Michael Meeks 
AuthorDate: Tue Sep 11 22:28:08 2018 +0100
Commit: Michael Meeks 
CommitDate: Wed Sep 12 09:56:22 2018 +0200

Ensure fastparser thread is joined in case of exceptions.

Change-Id: Ie0fb21776514a9a67e9fdff2ae856392cd711adb
Reviewed-on: https://gerrit.libreoffice.org/60361
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index a2b1e38b79fb..2c730685f526 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -744,6 +744,7 @@ namespace
 private:
 FastSaxParserImpl& m_rParser;
 Entity& m_rEntity;
+rtl::Reference m_xParser;
 public:
 ParserCleanup(FastSaxParserImpl& rParser, Entity& rEntity)
 : m_rParser(rParser)
@@ -759,6 +760,20 @@ namespace
 xmlFreeParserCtxt(m_rEntity.mpParser);
 }
 m_rParser.popEntity();
+joinThread();
+}
+void setThread(const rtl::Reference &xParser)
+{
+m_xParser = xParser;
+}
+void joinThread()
+{
+if (m_xParser.is())
+{
+rtl::Reference xToJoin = m_xParser;
+m_xParser.clear();
+xToJoin->join();
+}
 }
 };
 }
@@ -799,6 +814,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 {
 rtl::Reference xParser;
 xParser = new ParserThread(this);
+aEnsureFree.setThread(xParser);
 xParser->launch();
 bool done = false;
 do {
@@ -840,7 +856,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 rEntity.maUsedEvents.push(std::move(xEventList));
 }
 } while (!done);
-xParser->join();
+aEnsureFree.joinThread();
 deleteUsedEvents();
 
 // callbacks used inside XML_Parse may have caught an exception
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-08-13 Thread Libreoffice Gerrit user
 sax/source/fastparser/fastparser.cxx |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 4130f3bcaf6cc8778fcb921caa5357d9c945e353
Author: Caolán McNamara 
AuthorDate: Mon Aug 13 14:06:41 2018 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 13 16:56:45 2018 +0200

ofz#9591 Indirect-leak

==18428== 12,809 (176 direct, 12,633 indirect) bytes in 1 blocks are 
definitely lost in loss record 2,664 of 2,683
==18428==at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==18428==by 0x8D1CBC8: xmlNewDoc (tree.c:1171)
==18428==by 0x8D0C43D: xmlParseEntityDecl (parser.c:5521)
==18428==by 0x8D0F017: xmlParseMarkupDecl (parser.c:6802)
==18428==by 0x8D11588: xmlParseInternalSubset (parser.c:8305)
==18428==by 0x8D1733A: xmlParseTryOrFinish (parser.c:11977)
==18428==by 0x8D17DDA: xmlParseChunk (parser.c:12263)
==18428==by 0x3060C380: sax_fastparser::FastSaxParserImpl::parse() 
(fastparser.cxx:1041)
==18428==by 0x3060B6DC: 
sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource
 const&) (fastparser.cxx:850)
==18428==by 0x3060E675: 
sax_fastparser::FastSaxParser::parseStream(com::sun::star::xml::sax::InputSource
 const&) (fastparser.cxx:1357)
==18428==by 0x2F4B2ABE: 
SvXMLImport::parseStream(com::sun::star::xml::sax::InputSource const&) 
(xmlimp.cxx:485)
==18428==by 0x34E2C12C: 
filter::odfflatxml::OdfFlatXml::importer(com::sun::star::uno::Sequence
 const&, 
com::sun::star::uno::Reference 
const&, com::sun::star::uno::Sequence const&) 
(OdfFlatXml.cxx:150)

Change-Id: I63885b837e7311330255457da3a368bd3f4f8921
Reviewed-on: https://gerrit.libreoffice.org/58933
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 3486dcd53759..a2b1e38b79fb 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -752,8 +752,12 @@ namespace
 }
 ~ParserCleanup()
 {
-//xmlFreeParserCtxt accepts a null arg
-xmlFreeParserCtxt(m_rEntity.mpParser);
+if (m_rEntity.mpParser)
+{
+if (m_rEntity.mpParser->myDoc)
+xmlFreeDoc(m_rEntity.mpParser->myDoc);
+xmlFreeParserCtxt(m_rEntity.mpParser);
+}
 m_rParser.popEntity();
 }
 };
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source writerfilter/source

2018-07-17 Thread Libreoffice Gerrit user
 sax/source/fastparser/fastparser.cxx |   17 -
 writerfilter/source/ooxml/factoryimpl.py |6 ++
 2 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit d6bd9c273483b12f1bb2ae398afdba977e3ec336
Author: Noel Grandin 
AuthorDate: Tue Jul 17 09:49:55 2018 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 17 13:27:02 2018 +0200

tdf#79878 perf loading docx file, disable SAX threading for writer

since it seems to cost us 20% performance

Change-Id: Ic4796ee3756c8c722feb4851dc48a99e882ba0fe
Reviewed-on: https://gerrit.libreoffice.org/57545
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 83b36d122f42..4ae2f4fdaf4a 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -247,6 +247,7 @@ public:
 void parse();
 void produce( bool bForceFlush = false );
 bool m_bIgnoreMissingNSDecl;
+bool m_bDisableThreadedParser;
 
 private:
 bool consume(EventList&);
@@ -634,6 +635,7 @@ namespace sax_fastparser {
 
 FastSaxParserImpl::FastSaxParserImpl() :
 m_bIgnoreMissingNSDecl(false),
+m_bDisableThreadedParser(false),
 mpTop(nullptr)
 {
 mxDocumentLocator.set( new FastLocatorImpl( this ) );
@@ -781,7 +783,7 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 rEntity.mxDocumentHandler->startDocument();
 }
 
-if (!getenv("SAX_DISABLE_THREADS"))
+if (!getenv("SAX_DISABLE_THREADS") && !m_bDisableThreadedParser)
 {
 Reference 
xSeekable(rEntity.maStructSource.aInputStream, UNO_QUERY);
 // available() is not __really__ relevant here, but leave it in as a 
heuristic for non-seekable streams
@@ -1325,11 +1327,16 @@ FastSaxParser::initialize(css::uno::Sequence< 
css::uno::Any > const& rArguments)
 if (rArguments.getLength())
 {
 OUString str;
-if ( ( rArguments[0] >>= str ) && "IgnoreMissingNSDecl" == str )
-mpImpl->m_bIgnoreMissingNSDecl = true;
-else if ( str == "DoSmeplease" )
+if ( rArguments[0] >>= str )
 {
-//just ignore as this is already immune to billion laughs
+if ( str == "IgnoreMissingNSDecl" )
+mpImpl->m_bIgnoreMissingNSDecl = true;
+else if ( str == "DoSmeplease" )
+; //just ignore as this is already immune to billion laughs
+else if ( str == "DisableThreadedParser" )
+mpImpl->m_bDisableThreadedParser = true;
+else
+throw IllegalArgumentException();
 }
 else
 throw IllegalArgumentException();
diff --git a/writerfilter/source/ooxml/factoryimpl.py 
b/writerfilter/source/ooxml/factoryimpl.py
index acbaf4234261..2d54ee8ff6b8 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -152,6 +152,11 @@ def getFastParser():
 if (!mxFastParser.is())
 {
 mxFastParser = css::xml::sax::FastParser::create(mxContext);
+// the threaded parser is about 20% slower loading writer documents
+css::uno::Reference< css::lang::XInitialization > xInit( mxFastParser, 
css::uno::UNO_QUERY_THROW );
+css::uno::Sequence< css::uno::Any > args(1);
+args[0] <<= OUString("DisableThreadedParser");
+xInit->initialize(args);
 """)
 for url in sorted(ooxUrlAliases.keys()):
 print("""mxFastParser->registerNamespace("%s", 
oox::NMSP_%s);""" % (url, ooxUrlAliases[url]))
@@ -167,6 +172,7 @@ def getFastParser():
 def createImpl(model):
 print("""
 #include 
+#include 
 #include "ooxml/OOXMLFactory.hxx"
 #include "ooxml/OOXMLFastHelper.hxx"
 #include "ooxml/OOXMLStreamImpl.hxx"
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-07-11 Thread Noel Grandin
 sax/source/fastparser/fastparser.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit bd394492c165d27c96a44495d9ca694a242acb8f
Author: Noel Grandin 
Date:   Wed Jul 11 09:58:30 2018 +0200

tdf#79878 perf loading docx file, improve threading heuristic

this gives another 2% perf

Change-Id: Ia2983339f3f11daef37c48044904c8037a7a0bf6
Reviewed-on: https://gerrit.libreoffice.org/57265
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 72e42c1d0247..83b36d122f42 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -22,6 +22,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -780,8 +781,13 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 rEntity.mxDocumentHandler->startDocument();
 }
 
-rEntity.mbEnableThreads = rEntity.maStructSource.aInputStream->available() 
> 1
-&& !getenv("SAX_DISABLE_THREADS");
+if (!getenv("SAX_DISABLE_THREADS"))
+{
+Reference 
xSeekable(rEntity.maStructSource.aInputStream, UNO_QUERY);
+// available() is not __really__ relevant here, but leave it in as a 
heuristic for non-seekable streams
+rEntity.mbEnableThreads = (xSeekable.is() && xSeekable->getLength() > 
1)
+|| (rEntity.maStructSource.aInputStream->available() > 1);
+}
 
 if (rEntity.mbEnableThreads)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-07-11 Thread Noel Grandin
 sax/source/fastparser/fastparser.cxx |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 7d5c8923284b1ea8f82e30b7e8b2435e929e6c45
Author: Noel Grandin 
Date:   Tue Jul 10 13:34:41 2018 +0200

tdf#79878 perf loading docx file, more sax

(*) in GetTokenWithPrefix, use rtl_str_reverseCompare_WithLength
faster than strncmp
(*) No need for NamespaceDefine to be stored via std::shared_tr

Change-Id: Ibd262a3f4f5a0f518ec6abe1fb19e7803f78fe8b
Reviewed-on: https://gerrit.libreoffice.org/57261
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 9477559c12e8..72e42c1d0247 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -137,6 +137,7 @@ struct NamespaceDefine
 OUStringmaNamespaceURL;
 
 NamespaceDefine( const OString& rPrefix, sal_Int32 nToken, const OUString& 
rNamespaceURL ) : maPrefix( rPrefix ), mnToken( nToken ), maNamespaceURL( 
rNamespaceURL ) {}
+NamespaceDefine() : mnToken(-1) {}
 };
 
 // Entity binds all information needed for a single file | single call of 
parseStream
@@ -185,8 +186,7 @@ struct Entity : public ParserData
 std::stack< SaxContext, std::vector >  maContextStack;
 // Determines which elements of maNamespaceDefines are valid in current 
context
 std::stack< sal_uInt32, std::vector >  maNamespaceCount;
-std::vector< std::shared_ptr< NamespaceDefine > >
-  maNamespaceDefines;
+std::vector< NamespaceDefine > maNamespaceDefines;
 
 explicit Entity( const ParserData& rData );
 Entity( const Entity& rEntity ) = delete;
@@ -653,7 +653,7 @@ void FastSaxParserImpl::DefineNamespace( const OString& 
rPrefix, const OUString&
 if( rEntity.maNamespaceDefines.size() <= nOffset )
 rEntity.maNamespaceDefines.resize( rEntity.maNamespaceDefines.size() + 
64 );
 
-rEntity.maNamespaceDefines[nOffset].reset( new NamespaceDefine( rPrefix, 
GetNamespaceToken( namespaceURL ), namespaceURL ) );
+rEntity.maNamespaceDefines[nOffset] = NamespaceDefine( rPrefix, 
GetNamespaceToken( namespaceURL ), namespaceURL );
 }
 
 sal_Int32 FastSaxParserImpl::GetToken( const xmlChar* pName, sal_Int32 nameLen 
/* = 0 */ )
@@ -675,11 +675,11 @@ sal_Int32 FastSaxParserImpl::GetTokenWithPrefix( const 
xmlChar* pPrefix, int nPr
 while( nNamespace-- )
 {
 const auto & rNamespaceDefine = rEntity.maNamespaceDefines[nNamespace];
-const OString& rPrefix( rNamespaceDefine->maPrefix );
+const OString& rPrefix( rNamespaceDefine.maPrefix );
 if( (rPrefix.getLength() == nPrefixLen) &&
-(strncmp( rPrefix.getStr(), XML_CAST( pPrefix ), nPrefixLen ) == 0 
) )
+rtl_str_reverseCompare_WithLength(rPrefix.pData->buffer, 
rPrefix.pData->length, XML_CAST( pPrefix ), nPrefixLen ) == 0 )
 {
-nNamespaceToken = rNamespaceDefine->mnToken;
+nNamespaceToken = rNamespaceDefine.mnToken;
 break;
 }
 
@@ -714,8 +714,8 @@ OUString const & FastSaxParserImpl::GetNamespaceURL( const 
OString& rPrefix )
 {
 sal_uInt32 nNamespace = rEntity.maNamespaceCount.top();
 while( nNamespace-- )
-if( rEntity.maNamespaceDefines[nNamespace]->maPrefix == rPrefix )
-return rEntity.maNamespaceDefines[nNamespace]->maNamespaceURL;
+if( rEntity.maNamespaceDefines[nNamespace].maPrefix == rPrefix )
+return rEntity.maNamespaceDefines[nNamespace].maNamespaceURL;
 }
 
 throw SAXException("No namespace defined for " + 
OUString::fromUtf8(rPrefix),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sw/qa

2018-03-25 Thread Caolán McNamara
 sax/source/fastparser/fastparser.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 975884fbbc3f80a634258ee562037688a42027a9
Author: Caolán McNamara 
Date:   Sun Mar 25 14:36:28 2018 +0100

ofz#7110 ensure join is called on std::exceptions as well as uno::Exception

Change-Id: I1d17301e4d7f951b7176d5a91c0dca0ef051b2a2
Reviewed-on: https://gerrit.libreoffice.org/51830
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index c6c9c0b207fd..2765584a08fc 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -290,7 +290,7 @@ private:
 {
 mpParser->parse();
 }
-catch (const Exception &)
+catch (...)
 {
 Entity &rEntity = mpParser->getEntity();
 rEntity.getEvent( EXCEPTION );
@@ -445,7 +445,7 @@ void Entity::startElement( Event const *pEvent )
 maContextStack.top().mxContext.set( xContext.get() );
 xContext.set( nullptr, SAL_NO_ACQUIRE );
 }
-catch (const Exception&)
+catch (...)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -464,7 +464,7 @@ void Entity::characters( const OUString& sChars )
 {
 xContext->characters( sChars );
 }
-catch (const Exception&)
+catch (...)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -488,7 +488,7 @@ void Entity::endElement()
 else
 xContext->endUnknownElement( aContext.maNamespace, 
aContext.maElementName );
 }
-catch (const Exception&)
+catch (...)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -501,7 +501,7 @@ void Entity::processingInstruction( const OUString& 
rTarget, const OUString& rDa
 {
 mxDocumentHandler->processingInstruction( rTarget, rData );
 }
-catch (const Exception&)
+catch (...)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -1225,7 +1225,7 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 rEntity.startElement( &rEvent );
 }
 }
-catch (const Exception&)
+catch (...)
 {
 rEntity.saveException( ::cppu::getCaughtException() );
 }
diff --git a/sw/qa/core/data/ooxml/pass/ofz4825-1.docx 
b/sw/qa/core/data/ooxml/fail/ofz4825-1.docx
similarity index 100%
rename from sw/qa/core/data/ooxml/pass/ofz4825-1.docx
rename to sw/qa/core/data/ooxml/fail/ofz4825-1.docx
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-03-15 Thread Caolán McNamara
 sax/source/expatwrap/saxwriter.cxx |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 167fb3f7800e342b2009b98579a1d42d528b9b5a
Author: Caolán McNamara 
Date:   Thu Mar 15 16:17:51 2018 +

crashtesting: asserts on legal xml names on export

e.g. ooo82358-1.odt which has Chinese characters used in tags inside
a parent xforms:instance tag

Change-Id: If2edf9cc13e5a4cc969f5a46618a6534c52f2877
Reviewed-on: https://gerrit.libreoffice.org/51352
Reviewed-by: Michael Stahl 
Tested-by: Michael Stahl 
Tested-by: Jenkins 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index b7de667bcf05..c9d0a9b48cce 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -566,6 +566,13 @@ inline void SaxWriterHelper::startDocument()
 nCurrentPos = writeSequence();
 }
 
+#ifndef NDEBUG
+bool inrange(sal_Unicode c, sal_Unicode start, sal_Unicode end)
+{
+return c >= start && c <= end;
+}
+#endif
+
 void CheckValidName(OUString const& rName)
 {
 #ifdef NDEBUG
@@ -583,10 +590,17 @@ void CheckValidName(OUString const& rName)
 else
 hasColon = true;
 }
-else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != 
'.')
-{   // note: this will also warn about non-ASCII characters which
-// are allowed by XML but surely unexpected in LO filters
-// (OTOH we don't warn about invalid start chars)
+else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != 
'.' &&
+ !inrange(c, 0x00C0, 0x00D6) && !inrange(c, 0x00D8, 0x00F6) &&
+ !inrange(c, 0x00F8, 0x02FF) && !inrange(c, 0x0370, 0x037D) &&
+ !inrange(c, 0x037F, 0x1FFF) && !inrange(c, 0x200C, 0x200D) &&
+ !inrange(c, 0x2070, 0x218F) && !inrange(c, 0x2C00, 0x2FEF) &&
+ !inrange(c, 0x3001, 0xD7FF) && !inrange(c, 0xF900, 0xFDCF) &&
+ !inrange(c, 0xFDF0, 0xFFFD) && c != 0x00B7 &&
+ !inrange(c, 0x0300, 0x036F) && !inrange(c, 0x203F, 0x2040))
+{
+// https://www.w3.org/TR/xml11/#NT-NameChar
+// (currently we don't warn about invalid start chars)
 assert(!"unexpected character in attribute name");
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sd/source xmloff/source

2018-03-02 Thread Michael Stahl
 sax/source/tools/fastattribs.cxx   |1 +
 sd/source/filter/xml/sdtransform.cxx   |   13 -
 xmloff/source/core/SvXMLAttrCollection.cxx |   12 
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit 1bd9fcafe67cac9404c8c96553a262c048802c25
Author: Michael Stahl 
Date:   Wed Feb 28 21:28:55 2018 +0100

tdf#115429 sax,xmloff: assert on empty attribute names & namespaces

Surely that's indication of a bug somewhere.

Change-Id: Ic6219d8eb7f22301d8c4da98b2132ae3ef0467b5
Reviewed-on: https://gerrit.libreoffice.org/50579
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index fa91125b2245..a9f0baf7a2c0 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -80,6 +80,7 @@ void FastAttributeList::clear()
 
 void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t 
nValueLength )
 {
+assert(nToken != -1);
 maAttributeTokens.push_back( nToken );
 sal_Int32 nWritePosition = maAttributeValues.back();
 maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 );
diff --git a/sd/source/filter/xml/sdtransform.cxx 
b/sd/source/filter/xml/sdtransform.cxx
index c2ce55e066cd..e7d1ca8cc7a1 100644
--- a/sd/source/filter/xml/sdtransform.cxx
+++ b/sd/source/filter/xml/sdtransform.cxx
@@ -341,7 +341,18 @@ bool SdTransformOOo2xDocument::removeAlienAttributes( 
SfxItemSet& rSet, sal_uInt
 for( nItem = 0; nItem < nCount; nItem++ )
 {
 if( nItem != nFound )
-aNewItem.AddAttr( 
rAttr.GetAttrPrefix(nItem),rAttr.GetAttrNamespace(nItem), 
rAttr.GetAttrLName(nItem), rAttr.GetAttrValue(nItem ) );
+{
+OUString const& 
rNamespace(rAttr.GetAttrNamespace(nItem));
+OUString const& 
rPrefix(rAttr.GetAttrPrefix(nItem));
+if (rPrefix.isEmpty())
+{
+aNewItem.AddAttr(rAttr.GetAttrLName(nItem), 
rAttr.GetAttrValue(nItem));
+}
+else
+{
+aNewItem.AddAttr(rPrefix, rNamespace, 
rAttr.GetAttrLName(nItem), rAttr.GetAttrValue(nItem));
+}
+}
 }
 
 rSet.Put( aNewItem );
diff --git a/xmloff/source/core/SvXMLAttrCollection.cxx 
b/xmloff/source/core/SvXMLAttrCollection.cxx
index e203e3c9f920..fcb9a5b0dd9a 100644
--- a/xmloff/source/core/SvXMLAttrCollection.cxx
+++ b/xmloff/source/core/SvXMLAttrCollection.cxx
@@ -20,6 +20,7 @@ bool SvXMLAttrCollection::operator ==( const 
SvXMLAttrCollection& rCmp ) const
 bool SvXMLAttrCollection::AddAttr( const OUString& rLName,
const OUString& rValue )
 {
+assert(!rLName.isEmpty());
 aAttrs.emplace_back(rLName, rValue );
 return true;
 }
@@ -29,6 +30,9 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rLName,
const OUString& rValue )
 {
+assert(!rPrefix.isEmpty());
+assert(!rNamespace.isEmpty());
+assert(!rLName.isEmpty());
 sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
 aAttrs.emplace_back(nPos, rLName, rValue );
 return true;
@@ -38,6 +42,8 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rLName,
const OUString& rValue )
 {
+assert(!rPrefix.isEmpty());
+assert(!rLName.isEmpty());
 sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
 if( USHRT_MAX == nPos )
 return false;
@@ -49,6 +55,7 @@ bool SvXMLAttrCollection::SetAt( size_t i,
  const OUString& rLName,
  const OUString& rValue )
 {
+assert(!rLName.isEmpty());
 if( i >= GetAttrCount() )
 return false;
 aAttrs[i] = SvXMLAttr(rLName, rValue);
@@ -61,6 +68,9 @@ bool SvXMLAttrCollection::SetAt( size_t i,
  const OUString& rLName,
  const OUString& rValue )
 {
+assert(!rPrefix.isEmpty());
+assert(!rNamespace.isEmpty());
+assert(!rLName.isEmpty());
 if( i >= GetAttrCount() )
 return false;
 
@@ -77,6 +87,8 @@ bool SvXMLAttrCollection::SetAt( size_t i,
  const OUString& rLName,
  const OUString& rValue )
 {
+assert(!rPrefix.isEmpty());
+assert(!rLName.isEmpty());
 if( i >= GetAttrCount() )
 return false;
 
___
Libreoffic

[Libreoffice-commits] core.git: sax/source

2018-03-01 Thread Michael Stahl
 sax/source/expatwrap/saxwriter.cxx  |   30 ++
 sax/source/tools/fastserializer.cxx |   15 +++
 2 files changed, 41 insertions(+), 4 deletions(-)

New commits:
commit 0a1d5af2a18d6a062c45d65689fbce619922dcc8
Author: Michael Stahl 
Date:   Wed Feb 28 13:49:14 2018 +0100

tdf#115429 sax: assert if exporting an invalid XML attribute/element

Add a cheap check for this in both SaxWriter and FastSaxSerializer
so we can find such bugs earlier, e.g. with the weekly crashtesting.

Don't do a correct check but a cheap & fast one, let's ignore
non-ASCII characters for now as the only filter with such is UOF
and that is implemented with XSLT, not this sax code.

Change-Id: I4db8f70ffb23684d4cb4211468519edd6c7c465f
Reviewed-on: https://gerrit.libreoffice.org/50507
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sax/source/expatwrap/saxwriter.cxx 
b/sax/source/expatwrap/saxwriter.cxx
index a9d8f280706c..b7de667bcf05 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -566,6 +566,33 @@ inline void SaxWriterHelper::startDocument()
 nCurrentPos = writeSequence();
 }
 
+void CheckValidName(OUString const& rName)
+{
+#ifdef NDEBUG
+(void) rName;
+#else
+assert(!rName.isEmpty());
+bool hasColon(false);
+for (sal_Int32 i = 0; i < rName.getLength(); ++i)
+{
+auto const c(rName[i]);
+if (c == ':')
+{
+if (hasColon)
+assert("only one colon allowed");
+else
+hasColon = true;
+}
+else if (!rtl::isAsciiAlphanumeric(c) && c != '_' && c != '-' && c != 
'.')
+{   // note: this will also warn about non-ASCII characters which
+// are allowed by XML but surely unexpected in LO filters
+// (OTOH we don't warn about invalid start chars)
+assert(!"unexpected character in attribute name");
+}
+}
+#endif
+}
+
 inline SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& 
rName, const Reference< XAttributeList >& xAttribs)
 {
 FinishStartElement();
@@ -581,6 +608,7 @@ inline SaxInvalidCharacterError 
SaxWriterHelper::startElement(const OUString& rN
 nCurrentPos = writeSequence();
 
 SaxInvalidCharacterError eRet(SAX_NONE);
+CheckValidName(rName);
 if (!writeString(rName, false, false))
 eRet = SAX_ERROR;
 
@@ -598,6 +626,7 @@ inline SaxInvalidCharacterError 
SaxWriterHelper::startElement(const OUString& rN
 assert(DebugAttributes.find(rAttrName) == DebugAttributes.end());
 DebugAttributes.insert(rAttrName);
 #endif
+CheckValidName(rAttrName);
 if (!writeString(rAttrName, false, false))
 eRet = SAX_ERROR;
 
@@ -658,6 +687,7 @@ inline bool SaxWriterHelper::endElement(const OUString& 
rName)
 if (nCurrentPos == SEQUENCESIZE)
 nCurrentPos = writeSequence();
 
+CheckValidName(rName);
 bool bRet(writeString( rName, false, false));
 
 mp_Sequence[nCurrentPos] = '>';
diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 6257853a64a8..9356f3e081d1 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -270,11 +270,18 @@ namespace sax_fastparser {
 void FastSaxSerializer::writeId( ::sal_Int32 nElement )
 {
 if( HAS_NAMESPACE( nElement ) ) {
-
writeBytes(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement)));
+auto const 
Namespace(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement)));
+assert(Namespace.getLength() != 0);
+writeBytes(Namespace);
 writeBytes(sColon, N_CHARS(sColon));
-writeBytes(mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement)));
-} else
-writeBytes(mxFastTokenHandler->getUTF8Identifier(nElement));
+auto const 
Element(mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement)));
+assert(Element.getLength() != 0);
+writeBytes(Element);
+} else {
+auto const 
Element(mxFastTokenHandler->getUTF8Identifier(nElement));
+assert(Element.getLength() != 0);
+writeBytes(Element);
+}
 }
 
 #ifdef DBG_UTIL
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-02-27 Thread Vasily Melenchuk
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d5837fcf2b1c60cfe29e2f41f32e22213710a1b8
Author: Vasily Melenchuk 
Date:   Wed Feb 21 17:35:28 2018 +0300

sax: don't crash during logging

SaxParser was crashing during load of some MS documents if logging
is enabled.

Change-Id: I08a57b9a948bb4a35afcb82a29614c2f6a443446
Reviewed-on: https://gerrit.libreoffice.org/50110
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index ff5388f53d5f..c6c9c0b207fd 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1221,7 +1221,7 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 produce();
 else
 {
-SAL_INFO("sax.fastparser", " startElement line " << 
mxDocumentLocator->getLineNumber() << " column " << 
mxDocumentLocator->getColumnNumber() << " " << prefix << ":" << localName);
+SAL_INFO("sax.fastparser", " startElement line " << 
mxDocumentLocator->getLineNumber() << " column " << 
mxDocumentLocator->getColumnNumber() << " " << ( prefix ? XML_CAST(prefix) : 
"(null)" ) << ":" << localName);
 rEntity.startElement( &rEvent );
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-01-06 Thread Michael Stahl
 sax/source/fastparser/fastparser.cxx |   33 ++---
 1 file changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 2a88f62ac01daa72b6287a8cedccfb78579a6067
Author: Michael Stahl 
Date:   Fri Jan 5 15:36:59 2018 +0100

ofz#4392 sax: guard access to Entity::maSavedException with mutex

The problem here is presumably that the parser thread reports a
low-level SAX exception and the main thread reports a high-level filter
exception at the same time, so both threads modify maSavedException
concurrently.

Change-Id: Ic8ce9a4992208a24a111c990a67be163858ddaf8
Reviewed-on: https://gerrit.libreoffice.org/47478
Reviewed-by: Michael Meeks 
Tested-by: Jenkins 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index c0d2282c922d..f48ad47f2937 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -173,6 +173,7 @@ struct Entity : public ParserData
 // resource leaks), therefore any exception thrown by a UNO callback
 // must be saved somewhere until the C-XmlParser is stopped.
 css::uno::Any   maSavedException;
+osl::Mutex maSavedExceptionMutex;
 void saveException( const Any & e );
 void throwException( const ::rtl::Reference< FastLocatorImpl > 
&xDocumentLocator,
  bool mbDuringParse );
@@ -570,12 +571,20 @@ void Entity::throwException( const ::rtl::Reference< 
FastLocatorImpl > &xDocumen
  bool mbDuringParse )
 {
 // Error during parsing !
+Any savedException;
+{
+osl::MutexGuard g(maSavedExceptionMutex);
+if (maSavedException.hasValue())
+{
+savedException.setValue(&maSavedException, 
cppu::UnoType::get());
+}
+}
 SAXParseException aExcept(
 lclGetErrorMessage( mpParser,
 xDocumentLocator->getSystemId(),
 xDocumentLocator->getLineNumber() ),
 Reference< XInterface >(),
-Any( &maSavedException, 
cppu::UnoType::get() ),
+savedException,
 xDocumentLocator->getPublicId(),
 xDocumentLocator->getSystemId(),
 xDocumentLocator->getLineNumber(),
@@ -607,7 +616,15 @@ void Entity::saveException( const Any & e )
 // for XComponent; and yet expect to continue parsing.
 SAL_WARN("sax", "Unexpected exception from XML parser "
 << e.get());
-maSavedException = e;
+osl::MutexGuard g(maSavedExceptionMutex);
+if (maSavedException.hasValue())
+{
+SAL_INFO("sax.fastparser", "discarding exception, already have one");
+}
+else
+{
+maSavedException = e;
+}
 }
 
 } // namespace
@@ -814,6 +831,8 @@ void FastSaxParserImpl::parseStream(const InputSource& 
rStructSource)
 deleteUsedEvents();
 
 // callbacks used inside XML_Parse may have caught an exception
+// No need to lock maSavedExceptionMutex here because parser
+// thread is joined.
 if( rEntity.maSavedException.hasValue() )
 rEntity.throwException( mxDocumentLocator, true );
 }
@@ -1035,8 +1054,16 @@ void FastSaxParserImpl::parse()
 }
 
 // callbacks used inside XML_Parse may have caught an exception
-if( !bContinue || rEntity.maSavedException.hasValue() )
+if (!bContinue)
+{
 rEntity.throwException( mxDocumentLocator, true );
+}
+osl::ClearableMutexGuard g(rEntity.maSavedExceptionMutex);
+if (rEntity.maSavedException.hasValue())
+{
+g.clear();
+rEntity.throwException( mxDocumentLocator, true );
+}
 } while( nRead > 0 );
 rEntity.getEvent( DONE );
 if( rEntity.mbEnableThreads )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2018-01-05 Thread Michael Stahl
 sax/source/fastparser/fastparser.cxx |   51 +--
 1 file changed, 19 insertions(+), 32 deletions(-)

New commits:
commit e48b9b294a5bd69f5f782703f5f5571bfddd9181
Author: Michael Stahl 
Date:   Fri Jan 5 15:54:15 2018 +0100

sax: remove that odd Entity copy constructor

Change-Id: I7929ccf751d37f65975d6412e28d34bec4421c07

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index f56d368580ac..c0d2282c922d 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -188,7 +188,8 @@ struct Entity : public ParserData
   maNamespaceDefines;
 
 explicit Entity( const ParserData& rData );
-Entity( const Entity& rEntity );
+Entity( const Entity& rEntity ) = delete;
+Entity& operator=( const Entity& rEntity ) = delete;
 void startElement( Event const *pEvent );
 void characters( const OUString& sChars );
 void endElement();
@@ -238,7 +239,7 @@ public:
 void callbackCharacters( const xmlChar* s, int nLen );
 void callbackProcessingInstruction( const xmlChar *target, const xmlChar 
*data );
 
-void pushEntity( const Entity& rEntity );
+void pushEntity(const ParserData&, xml::sax::InputSource const&);
 void popEntity();
 Entity& getEntity() { return *mpTop; }
 void parse();
@@ -382,22 +383,6 @@ Entity::Entity(const ParserData& rData)
 {
 }
 
-Entity::Entity(const Entity& e)
-: ParserData(e)
-, mnProducedEventsSize(0)
-, mxProducedEvents()
-, mbEnableThreads(e.mbEnableThreads)
-, maStructSource(e.maStructSource)
-, mpParser(e.mpParser)
-, maConverter(e.maConverter)
-, maSavedException(e.maSavedException)
-, maNamespaceStack(e.maNamespaceStack)
-, maContextStack(e.maContextStack)
-, maNamespaceCount(e.maNamespaceCount)
-, maNamespaceDefines(e.maNamespaceDefines)
-{
-}
-
 void Entity::startElement( Event const *pEvent )
 {
 const sal_Int32& nElementToken = pEvent->mnElementToken;
@@ -758,24 +743,14 @@ namespace
 * the file-specific initialization work. (During a parser run, external files 
may be opened)
 *
 /
-void FastSaxParserImpl::parseStream(const InputSource& maStructSource)
+void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
 {
 xmlInitParser();
 
 // Only one text at one time
 MutexGuard guard( maMutex );
 
-Entity entity( maData );
-entity.maStructSource = maStructSource;
-
-if( !entity.maStructSource.aInputStream.is() )
-throw SAXException("No input source", Reference< XInterface >(), Any() 
);
-
-entity.maConverter.setInputStream( entity.maStructSource.aInputStream );
-if( !entity.maStructSource.sEncoding.isEmpty() )
-entity.maConverter.setEncoding( OUStringToOString( 
entity.maStructSource.sEncoding, RTL_TEXTENCODING_ASCII_US ) );
-
-pushEntity( entity );
+pushEntity(maData, rStructSource);
 Entity& rEntity = getEntity();
 ParserCleanup aEnsureFree(*this, rEntity);
 
@@ -988,10 +963,22 @@ bool FastSaxParserImpl::consume(EventList& rEventList)
 return true;
 }
 
-void FastSaxParserImpl::pushEntity( const Entity& rEntity )
+void FastSaxParserImpl::pushEntity(const ParserData& rEntityData,
+xml::sax::InputSource const& rSource)
 {
-maEntities.push( rEntity );
+if (!rSource.aInputStream.is())
+throw SAXException("No input source", Reference(), Any());
+
+maEntities.emplace(rEntityData);
 mpTop = &maEntities.top();
+
+mpTop->maStructSource = rSource;
+
+mpTop->maConverter.setInputStream(mpTop->maStructSource.aInputStream);
+if (!mpTop->maStructSource.sEncoding.isEmpty())
+{
+
mpTop->maConverter.setEncoding(OUStringToOString(mpTop->maStructSource.sEncoding,
 RTL_TEXTENCODING_ASCII_US));
+}
 }
 
 void FastSaxParserImpl::popEntity()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-11-30 Thread Caolán McNamara
 sax/source/fastparser/fastparser.cxx |  156 +--
 1 file changed, 77 insertions(+), 79 deletions(-)

New commits:
commit 5591aa360874c9133d046eeaa1c315df1a441bc4
Author: Caolán McNamara 
Date:   Wed Nov 29 21:18:11 2017 +

ofz: always free with xmlFreeParserCtxt

Change-Id: I90aed11ae0a29a0e9fc725b297e10a7ed30c9942
Reviewed-on: https://gerrit.libreoffice.org/45533
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 8c0286656764..1aa8811366ea 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -730,6 +730,27 @@ sal_Int32 FastSaxParserImpl::GetTokenWithContextNamespace( 
sal_Int32 nNamespaceT
 return FastToken::DONTKNOW;
 }
 
+namespace
+{
+class ParserCleanup
+{
+private:
+FastSaxParserImpl& m_rParser;
+Entity& m_rEntity;
+public:
+ParserCleanup(FastSaxParserImpl& rParser, Entity& rEntity)
+: m_rParser(rParser)
+, m_rEntity(rEntity)
+{
+}
+~ParserCleanup()
+{
+//xmlFreeParserCtxt accepts a null arg
+xmlFreeParserCtxt(m_rEntity.mpParser);
+m_rParser.popEntity();
+}
+};
+}
 /***
 *
 * parseStream does Parser-startup initializations. The FastSaxParser::parse() 
method does
@@ -755,104 +776,81 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 
 pushEntity( entity );
 Entity& rEntity = getEntity();
-try
+ParserCleanup aEnsureFree(*this, rEntity);
+
+// start the document
+if( rEntity.mxDocumentHandler.is() )
 {
-// start the document
-if( rEntity.mxDocumentHandler.is() )
-{
-Reference< XLocator > xLoc( mxDocumentLocator.get() );
-rEntity.mxDocumentHandler->setDocumentLocator( xLoc );
-rEntity.mxDocumentHandler->startDocument();
-}
+Reference< XLocator > xLoc( mxDocumentLocator.get() );
+rEntity.mxDocumentHandler->setDocumentLocator( xLoc );
+rEntity.mxDocumentHandler->startDocument();
+}
 
-rEntity.mbEnableThreads = 
rEntity.maStructSource.aInputStream->available() > 1
-&& !getenv("SAX_DISABLE_THREADS");
+rEntity.mbEnableThreads = rEntity.maStructSource.aInputStream->available() 
> 1
+&& !getenv("SAX_DISABLE_THREADS");
 
-if (rEntity.mbEnableThreads)
-{
-rtl::Reference xParser;
-xParser = new ParserThread(this);
-xParser->launch();
-bool done = false;
-do {
-rEntity.maConsumeResume.wait();
-rEntity.maConsumeResume.reset();
-
-osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
-while (!rEntity.maPendingEvents.empty())
-{
-if (rEntity.maPendingEvents.size() <= 
Entity::mnEventLowWater)
-rEntity.maProduceResume.set(); // start producer again
+if (rEntity.mbEnableThreads)
+{
+rtl::Reference xParser;
+xParser = new ParserThread(this);
+xParser->launch();
+bool done = false;
+do {
+rEntity.maConsumeResume.wait();
+rEntity.maConsumeResume.reset();
+
+osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
+while (!rEntity.maPendingEvents.empty())
+{
+if (rEntity.maPendingEvents.size() <= Entity::mnEventLowWater)
+rEntity.maProduceResume.set(); // start producer again
 
-std::unique_ptr xEventList = 
std::move(rEntity.maPendingEvents.front());
-rEntity.maPendingEvents.pop();
-aGuard.clear(); // unlock
+std::unique_ptr xEventList = 
std::move(rEntity.maPendingEvents.front());
+rEntity.maPendingEvents.pop();
+aGuard.clear(); // unlock
 
-if (!consume(*xEventList))
-done = true;
+if (!consume(*xEventList))
+done = true;
 
-aGuard.reset(); // lock
+aGuard.reset(); // lock
 
-if ( rEntity.maPendingEvents.size() <= 
Entity::mnEventLowWater )
+if ( rEntity.maPendingEvents.size() <= Entity::mnEventLowWater 
)
+{
+aGuard.clear();
+for (auto aEventIt = xEventList->maEvents.begin();
+aEventIt != xEventList->maEvents.end(); ++aEventIt)
 {
-aGuard.clear();
-for (auto aEventIt = xEventList->maEvents.begin();
-aEventIt != xEventList->maEvents.end(); ++aEventIt)
+if (aEventIt->mxAttrib

[Libreoffice-commits] core.git: sax/source

2017-10-25 Thread Caolán McNamara
 sax/source/tools/converter.cxx |   13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 89dd6ff111059cdfd254cc63087bb5353e9a416f
Author: Caolán McNamara 
Date:   Tue Oct 24 15:41:23 2017 +0100

ofz#3769 Integer-overflow

Change-Id: Ia245c6042f8c662bab870cf166db94d1cf2db9d3
Reviewed-on: https://gerrit.libreoffice.org/43781
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 0c560865a7b6..1cb8cf190f04 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -969,21 +969,15 @@ static Result
 readUnsignedNumber(const OUString & rString,
 sal_Int32 & io_rnPos, sal_Int32 & o_rNumber)
 {
-bool bOverflow(false);
-sal_Int64 nTemp(0);
 sal_Int32 nPos(io_rnPos);
 
+OUStringBuffer aNumber;
 while (nPos < rString.getLength())
 {
 const sal_Unicode c = rString[nPos];
 if (('0' <= c) && (c <= '9'))
 {
-nTemp *= 10;
-nTemp += (c - u'0');
-if (nTemp >= SAL_MAX_INT32)
-{
-bOverflow = true;
-}
+aNumber.append(c);
 }
 else
 {
@@ -998,6 +992,9 @@ readUnsignedNumber(const OUString & rString,
 return R_NOTHING;
 }
 
+const sal_Int64 nTemp = aNumber.toString().toInt64();
+const bool bOverflow = (nTemp >= SAL_MAX_INT32);
+
 io_rnPos = nPos;
 o_rNumber = nTemp;
 return (bOverflow) ? R_OVERFLOW : R_SUCCESS;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sw/inc sw/qa

2017-09-18 Thread Caolán McNamara
 sax/source/fastparser/fastparser.cxx  |9 
 sw/inc/iodetect.hxx   |2 
 sw/qa/extras/uiwriter/data/threadedException.fodt |  530 ++
 sw/qa/extras/uiwriter/uiwriter.cxx|   13 
 4 files changed, 553 insertions(+), 1 deletion(-)

New commits:
commit 5e381ffbe7069a454dc807113ab4058fad005c55
Author: Caolán McNamara 
Date:   Mon Sep 18 10:47:25 2017 +0100

allow events to accumulate past limit if an exception is pending

Change-Id: Ic54c31961b887e06267aba1ceb0378508d24ded0
Reviewed-on: https://gerrit.libreoffice.org/42411
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 59dd995ce0f5..5281ca14920e 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -550,6 +550,13 @@ Event& Entity::getEvent( CallbackType aType )
 return maSharedEvent;
 
 EventList& rEventList = getEventList();
+if (mnProducedEventsSize == rEventList.maEvents.size())
+{
+SAL_WARN_IF(!maSavedException.hasValue(), "sax",
+"Event vector should only exceed " << mnEventListSize <<
+" temporarily while an exception is pending");
+rEventList.maEvents.resize(mnProducedEventsSize + 1);
+}
 Event& rEvent = rEventList.maEvents[mnProducedEventsSize++];
 rEvent.maType = aType;
 return rEvent;
@@ -927,7 +934,7 @@ void FastSaxParserImpl::produce( bool bForceFlush )
 {
 Entity& rEntity = getEntity();
 if (bForceFlush ||
-rEntity.mnProducedEventsSize == Entity::mnEventListSize)
+rEntity.mnProducedEventsSize >= Entity::mnEventListSize)
 {
 osl::ResettableMutexGuard aGuard(rEntity.maEventProtector);
 
diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index df3d4aa64a04..a92ad13d3221 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -103,6 +103,8 @@ public:
 static const OUString GetSubStorageName( const SfxFilter& rFltr );
 };
 
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream 
&rStream);
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/uiwriter/data/threadedException.fodt 
b/sw/qa/extras/uiwriter/data/threadedException.fodt
new file mode 100644
index ..0c0312d2a464
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/threadedException.fodt
@@ -0,0 +1,530 @@
+
+
+http://www.w3.org/1999/xlink"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  2014-10-12T18:41:05.34
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  PT5M19S
+  
+  
+  
+  
+  3
+  
+  
+  
+  
+  LibreOfficeDev/4.4.0.0.alpha0$Windows_x86 
LibreOffice_project/86a3fe47a66950e26d23d7d7f2680fa7d4fb0839
+  
+  
+  
+  
+  writerInfo
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  Regina 
Henschel2014-10-12T18:46:53.23800Regina
 Henschel
+ 
+  
+   4403
+   0
+   36747
+   15475
+   true
+   false
+   
+
+ view2
+ 14095
+ 8774
+ 0
+ 4403
+ 36745
+ 19876
+ 0
+ 0
+ false
+ 100
+ false

[Libreoffice-commits] core.git: sax/source

2017-09-17 Thread Caolán McNamara
 sax/source/expatwrap/xml2utf.cxx |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 1ebf34c67142d1a36923ad6511301fb4b7458edd
Author: Caolán McNamara 
Date:   Sun Sep 17 17:51:43 2017 +0100

protect against short file

Change-Id: I20c6a6fb34485f42c2a828618e8918d8a441860a
Reviewed-on: https://gerrit.libreoffice.org/42389
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index fde25ce8482b..58ee36c1c829 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -221,8 +221,7 @@ bool XMLFile2UTFConverter::scanForEncoding( Sequence< 
sal_Int8 > &seq )
 }
 
 // first level : detect possible file formats
-if( ! strncmp( reinterpret_cast(pSource), "= 5 && !strncmp(reinterpret_cast(pSource), "(pSource), seq.getLength() 
);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-09-17 Thread Caolán McNamara
 sax/source/expatwrap/xml2utf.cxx |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 4025422a536a732ee2f91158d2749cc2adbc5408
Author: Caolán McNamara 
Date:   Sun Sep 17 14:01:05 2017 +0100

ofz: string has to be at least 5 chars long

Change-Id: I98c50a59c03fc886d50362b9c5dd8c84f60e0b62
Reviewed-on: https://gerrit.libreoffice.org/42379
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index c12783f10cef..fde25ce8482b 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -125,7 +125,7 @@ XMLFile2UTFConverter::~XMLFile2UTFConverter()
 void XMLFile2UTFConverter::removeEncoding( Sequence &seq )
 {
 const sal_Int8 *pSource = seq.getArray();
-if( ! strncmp( reinterpret_cast(pSource), "= 5 && !strncmp(reinterpret_cast(pSource), " &seq )
 &( seq.getArray()[nStop+1]) ,
 seq.getLength() - nStop -1);
 seq.realloc( seq.getLength() - ( nStop+1 - nFound ) );
-//  str = String( (char * ) seq.getArray() , seq.getLen() );
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-09-16 Thread Caolán McNamara
 sax/source/fastparser/fastparser.cxx |   66 +--
 1 file changed, 33 insertions(+), 33 deletions(-)

New commits:
commit 8508e409a2cc1d38a347204d90f29cac153e8015
Author: Caolán McNamara 
Date:   Sat Sep 16 14:29:11 2017 +0100

ofz: leak on fdo72541-1.fodt

Direct leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x600ca0 in operator new(unsigned long) 
/src/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
#1 0x86860c6 in (anonymous namespace)::Entity::getEventList() 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:538:32
#2 0x8683e1d in (anonymous namespace)::Entity::getEvent((anonymous 
namespace)::CallbackType) 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:552:29
#3 0x8684201 in 
sax_fastparser::FastSaxParserImpl::callbackStartElement(unsigned char const*, 
unsigned char const*, unsigned char const*, int, unsigned char const**, int, 
unsigned char const**) 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:1071:29
#4 0x8683cfb in (anonymous namespace)::call_callbackStartElement(void*, 
unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned 
char const**, int, int, unsigned char const**) 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:306:18
#5 0x5d178b6 in xmlParseStartTag2 (/out/fodtfuzzer+0x5d178b6)
#6 0x5d1b979 in xmlParseTryOrFinish (/out/fodtfuzzer+0x5d1b979)
#7 0x5d1ac9d in xmlParseChunk (/out/fodtfuzzer+0x5d1ac9d)
#8 0x8682d9e in sax_fastparser::FastSaxParserImpl::parse() 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:1040:25
#9 0x868a537 in (anonymous namespace)::ParserThread::execute() 
/src/libreoffice/sax/source/fastparser/fastparser.cxx:289:23
#10 0x514e7be in salhelper::Thread::run() 
/src/libreoffice/salhelper/source/thread.cxx:40:9
#11 0x1931a41 in threadFunc 
/src/libreoffice/include/osl/thread.hxx:185:15
#12 0x51d47a1 in osl_thread_start_Impl(void*) 
/src/libreoffice/sal/osl/unx/thread.cxx:237:9
#13 0x7fdeb7b396b9 in start_thread 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)

Change-Id: Ie0a04d4b887e3bb764e8fa80212dc5d5b3965aca
Reviewed-on: https://gerrit.libreoffice.org/42355
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index a0cfc2f9e740..59dd995ce0f5 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -148,11 +148,11 @@ struct Entity : public ParserData
 
 // unique for each Entity instance:
 
-// Number of valid events in mpProducedEvents:
+// Number of valid events in mxProducedEvents:
 size_t mnProducedEventsSize;
-EventList *mpProducedEvents;
-std::queue< EventList * > maPendingEvents;
-std::queue< EventList * > maUsedEvents;
+std::unique_ptr mxProducedEvents;
+std::queue> maPendingEvents;
+std::queue> maUsedEvents;
 osl::Mutex maEventProtector;
 
 static const size_t mnEventLowWater = 4;
@@ -194,7 +194,7 @@ struct Entity : public ParserData
 void characters( const OUString& sChars );
 void endElement();
 void processingInstruction( const OUString& rTarget, const OUString& rData 
);
-EventList* getEventList();
+EventList& getEventList();
 Event& getEvent( CallbackType aType );
 };
 
@@ -247,7 +247,7 @@ public:
 bool m_bIgnoreMissingNSDecl;
 
 private:
-bool consume(EventList *);
+bool consume(EventList&);
 void deleteUsedEvents();
 void sendPendingCharacters();
 
@@ -376,7 +376,7 @@ ParserData::ParserData()
 Entity::Entity(const ParserData& rData)
 : ParserData(rData)
 , mnProducedEventsSize(0)
-, mpProducedEvents(nullptr)
+, mxProducedEvents()
 , mbEnableThreads(false)
 , mpParser(nullptr)
 {
@@ -385,7 +385,7 @@ Entity::Entity(const ParserData& rData)
 Entity::Entity(const Entity& e)
 : ParserData(e)
 , mnProducedEventsSize(0)
-, mpProducedEvents(nullptr)
+, mxProducedEvents()
 , mbEnableThreads(e.mbEnableThreads)
 , maStructSource(e.maStructSource)
 , mpParser(e.mpParser)
@@ -521,27 +521,27 @@ void Entity::processingInstruction( const OUString& 
rTarget, const OUString& rDa
 }
 }
 
-EventList* Entity::getEventList()
+EventList& Entity::getEventList()
 {
-if (!mpProducedEvents)
+if (!mxProducedEvents)
 {
 osl::ResettableMutexGuard aGuard(maEventProtector);
 if (!maUsedEvents.empty())
 {
-mpProducedEvents = maUsedEvents.front();
+mxProducedEvents = std::move(maUsedEvents.front());
 maUsedEvents.pop();
 aGuard.clear(); // unlock
 mnProducedEventsSize = 0;
 }
-if (!mpProducedEvents)
+if (!mxProducedEvents)
 {
-mpProducedEvents = new EventList;
-mpProducedEvents->maEvents.re

[Libreoffice-commits] core.git: sax/source

2017-08-11 Thread Thorsten Behrens
 sax/source/fastparser/fastparser.cxx |  135 ---
 1 file changed, 135 deletions(-)

New commits:
commit 840a97f98f03491256a93d95e6614d41cdcddbcf
Author: Thorsten Behrens 
Date:   Fri Aug 11 00:10:30 2017 +0200

sax parser: remove long-disabled code

Entity ref and decl was disabled since 2014, let's remove it now.

Change-Id: I35dac78b8530bab99e955bf68dfe3f8951a63f99
Reviewed-on: https://gerrit.libreoffice.org/40998
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 4cdd3b034962..8188724a91d9 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -238,13 +238,6 @@ public:
 void callbackEndElement();
 void callbackCharacters( const xmlChar* s, int nLen );
 void callbackProcessingInstruction( const xmlChar *target, const xmlChar 
*data );
-#if 0
-bool callbackExternalEntityRef( XML_Parser parser, const xmlChar 
*openEntityNames, const xmlChar *base, const xmlChar *systemId, const xmlChar 
*publicId);
-void callbackEntityDecl(const xmlChar *entityName, int is_parameter_entity,
-const xmlChar *value, int value_length, const xmlChar *base,
-const xmlChar *systemId, const xmlChar *publicId,
-const xmlChar *notationName);
-#endif
 
 void pushEntity( const Entity& rEntity );
 void popEntity();
@@ -268,9 +261,6 @@ private:
 void DefineNamespace( const OString& rPrefix, const OUString& namespaceURL 
);
 
 private:
-#if 0
-FastSaxParser* mpFront;
-#endif
 osl::Mutex maMutex; ///< Protecting whole parseStream() execution
 ::rtl::Reference< FastLocatorImpl > mxDocumentLocator;
 NamespaceMapmaNamespaceMap;
@@ -334,24 +324,6 @@ static void call_callbackProcessingInstruction( void 
*userData, const xmlChar *t
 pFastParser->callbackProcessingInstruction( target, data );
 }
 
-#if 0
-static void call_callbackEntityDecl(void *userData, const xmlChar *entityName,
-int is_parameter_entity, const xmlChar *value, int value_length,
-const xmlChar *base, const xmlChar *systemId,
-const xmlChar *publicId, const xmlChar *notationName)
-{
-FastSaxParserImpl* pFastParser = 
reinterpret_cast(userData);
-pFastParser->callbackEntityDecl(entityName, is_parameter_entity, value,
-value_length, base, systemId, publicId, notationName);
-}
-
-static int call_callbackExternalEntityRef( XML_Parser parser,
-const xmlChar *openEntityNames, const xmlChar *base, const xmlChar 
*systemId, const xmlChar *publicId )
-{
-FastSaxParserImpl* pFastParser = reinterpret_cast( 
XML_GetUserData( parser ) );
-return pFastParser->callbackExternalEntityRef( parser, openEntityNames, 
base, systemId, publicId );
-}
-#endif
 }
 
 class FastLocatorImpl : public WeakImplHelper< XLocator >
@@ -651,9 +623,6 @@ void Entity::saveException( const Any & e )
 namespace sax_fastparser {
 
 FastSaxParserImpl::FastSaxParserImpl() :
-#if 0
-mpFront(pFront),
-#endif
 m_bIgnoreMissingNSDecl(false),
 mpTop(nullptr)
 {
@@ -1040,10 +1009,6 @@ void FastSaxParserImpl::parse()
 callbacks.characters = call_callbackCharacters;
 callbacks.processingInstruction = call_callbackProcessingInstruction;
 callbacks.initialized = XML_SAX2_MAGIC;
-#if 0
-XML_SetEntityDeclHandler(entity.mpParser, call_callbackEntityDecl);
-XML_SetExternalEntityRefHandler( entity.mpParser, 
call_callbackExternalEntityRef );
-#endif
 int nRead = 0;
 do
 {
@@ -1305,106 +1270,6 @@ void FastSaxParserImpl::callbackProcessingInstruction( 
const xmlChar *target, co
 rEntity.processingInstruction( rEvent.msNamespace, 
rEvent.msElementName );
 }
 
-#if 0
-void FastSaxParserImpl::callbackEntityDecl(
-SAL_UNUSED_PARAMETER const xmlChar * /*entityName*/,
-SAL_UNUSED_PARAMETER int /*is_parameter_entity*/,
-const xmlChar *value, SAL_UNUSED_PARAMETER int /*value_length*/,
-SAL_UNUSED_PARAMETER const xmlChar * /*base*/,
-SAL_UNUSED_PARAMETER const xmlChar * /*systemId*/,
-SAL_UNUSED_PARAMETER const xmlChar * /*publicId*/,
-SAL_UNUSED_PARAMETER const xmlChar * /*notationName*/)
-{
-if (value) { // value != 0 means internal entity
-SAL_INFO("sax", "FastSaxParser: internal entity declaration, 
stopping");
-XML_StopParser(getEntity().mpParser, XML_FALSE);
-getEntity().saveException( SAXParseException(
-"FastSaxParser: internal entity declaration, stopping",
-static_cast(mpFront), Any(),
-mxDocumentLocator->getPublicId(),
-mxDocumentLocator->getSystemId(),
-mxDocumentLocator->getLineNumber(),
-mxDocumentLocator->getColumnNumber() ) );
-} else {
-SAL_INFO("sax", "FastSaxParser: ignoring external entity declaration");
-}
-}
-
-bool FastSaxParserImpl::callbackExter

[Libreoffice-commits] core.git: sax/source

2017-07-20 Thread Takeshi Abe
 sax/source/expatwrap/xml2utf.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit b64e564492220b34c14f069e8e1f42675bd9abe6
Author: Takeshi Abe 
Date:   Tue Jul 18 22:44:33 2017 +0900

sax: Check if it starts with 5 bytes of "https://gerrit.libreoffice.org/40139
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index 18540c0ce1af..c12783f10cef 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -125,7 +125,7 @@ XMLFile2UTFConverter::~XMLFile2UTFConverter()
 void XMLFile2UTFConverter::removeEncoding( Sequence &seq )
 {
 const sal_Int8 *pSource = seq.getArray();
-if( ! strncmp( reinterpret_cast(pSource), "(pSource), " &s
 return false;
 }
 
-if( ! strncmp( reinterpret_cast(pSource), "(pSource), " &seq )
 }
 
 // first level : detect possible file formats
-if( ! strncmp( reinterpret_cast(pSource), "(pSource), "(pSource), seq.getLength() 
);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-06-16 Thread Eike Rathke
 sax/source/tools/fastserializer.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit c5bc40ae6cabe240700773df5cc7f010acce6014
Author: Eike Rathke 
Date:   Fri Jun 16 23:17:54 2017 +0200

Literal tab character is bad XML, write '	' instead

Additionally, it *may* have caused document corruption when loading such an
.xlsx file, though a small test case with an embedded literal tab character
could not reproduce the behaviour.
See

https://ask.libreoffice.org/en/question/100615/sudden-corruption-of-xlsx-file-bug/
and note that the literal tab character is a mere assumption, but it would 
be
possible.

Change-Id: Ia9d33955f1196222d335a1a4807fba78df4e4d85

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 1424d1e73538..ff74fe3b7079 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -150,8 +150,8 @@ namespace sax_fastparser {
 case '&':   writeBytes( "&", 5 );break;
 case '\'':  writeBytes( "'", 6 );   break;
 case '"':   writeBytes( """, 6 );   break;
-#if 0
 case '\t':
+#if 0
 // Seems OOXML prefers the _x_ escape over the
 // entity in *some* cases, apparently in attribute
 // values but not in element data.
@@ -163,13 +163,11 @@ namespace sax_fastparser {
 writeBytes( bufXescape, kXescapeLen);
 }
 else
+#endif
 {
-// We did never write this, but literal tab
-// instead. Should we?
 writeBytes( "	", 4 );
 }
 break;
-#endif
 case '\n':
 #if 0
 if (mbXescape)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-03-03 Thread Eike Rathke
 sax/source/tools/fastserializer.cxx |  127 +++-
 sax/source/tools/fastserializer.hxx |3 
 2 files changed, 115 insertions(+), 15 deletions(-)

New commits:
commit 8b25b67d5268abbb260da968cc23b6f6c8dd31af
Author: Eike Rathke 
Date:   Thu Mar 2 17:06:54 2017 +0100

escape invalid XML characters with _x_ when writing escaped

As defined in OOXML, see code comments.

Change-Id: I8ce0075790f2d4ef6227a9474c68466e0793dce2
Reviewed-on: https://gerrit.libreoffice.org/34824
Reviewed-by: Eike Rathke 
Tested-by: Jenkins 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index a571829..1424d1e 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -59,6 +59,7 @@ namespace sax_fastparser {
 , mbMarkStackEmpty(true)
 , mpDoubleStr(nullptr)
 , mnDoubleStrCapacity(RTL_STR_MAX_VALUEOFDOUBLE)
+, mbXescape(true)
 {
 rtl_string_new_WithLength(&mpDoubleStr, mnDoubleStrCapacity);
 mxFastTokenHandler = css::xml::sax::FastTokenHandler::create(
@@ -101,7 +102,6 @@ namespace sax_fastparser {
 write( sOutput.getStr(), sOutput.getLength(), bEscape );
 }
 
-#if OSL_DEBUG_LEVEL > 0
 /** Characters not allowed in XML 1.0
 XML 1.1 would exclude only U+
  */
@@ -119,7 +119,11 @@ namespace sax_fastparser {
 }
 return true;
 }
-#endif
+
+bool isHexDigit( char c )
+{
+return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c 
&& c <= 'f');
+}
 
 void FastSaxSerializer::write( const char* pStr, sal_Int32 nLen, bool 
bEscape )
 {
@@ -133,6 +137,9 @@ namespace sax_fastparser {
 }
 
 bool bGood = true;
+const sal_Int32 kXescapeLen = 7;
+char bufXescape[kXescapeLen+1];
+sal_Int32 nNextXescape = 0;
 for (sal_Int32 i = 0; i < nLen; ++i)
 {
 char c = pStr[ i ];
@@ -143,24 +150,114 @@ namespace sax_fastparser {
 case '&':   writeBytes( "&", 5 );break;
 case '\'':  writeBytes( "'", 6 );   break;
 case '"':   writeBytes( """, 6 );   break;
-case '\n':  writeBytes( "
", 5 );break;
-case '\r':  writeBytes( "
", 5 );break;
+#if 0
+case '\t':
+// Seems OOXML prefers the _x_ escape over the
+// entity in *some* cases, apparently in attribute
+// values but not in element data.
+// Would need to distinguish at a higher level.
+if (mbXescape)
+{
+snprintf( bufXescape, kXescapeLen+1, "_x%04x_",
+static_cast(static_cast(c)));
+writeBytes( bufXescape, kXescapeLen);
+}
+else
+{
+// We did never write this, but literal tab
+// instead. Should we?
+writeBytes( "	", 4 );
+}
+break;
+#endif
+case '\n':
+#if 0
+if (mbXescape)
+{
+snprintf( bufXescape, kXescapeLen+1, "_x%04x_",
+static_cast(static_cast(c)));
+writeBytes( bufXescape, kXescapeLen);
+}
+else
+#endif
+{
+writeBytes( "
", 5 );
+}
+break;
+case '\r':
+#if 0
+if (mbXescape)
+{
+snprintf( bufXescape, kXescapeLen+1, "_x%04x_",
+static_cast(static_cast(c)));
+writeBytes( bufXescape, kXescapeLen);
+}
+else
+#endif
+{
+writeBytes( "
", 5 );
+}
+break;
 default:
+if (mbXescape)
+{
+// Escape characters not valid in XML 1.0 as
+// _x_. A literal "_x_" has to be
+// escaped as _x005F_x_ (effectively
+// escaping the leading '_').
+// See ECMA-376-1:2016 page 3736,
+// 22.4.2.4 bstr (Basic String)
+// for r

[Libreoffice-commits] core.git: sax/source

2017-02-28 Thread Eike Rathke
 sax/source/tools/fastserializer.cxx |   55 +++-
 1 file changed, 54 insertions(+), 1 deletion(-)

New commits:
commit baca2ec8d5a457512e25b499c3cacc7a66ca853f
Author: Eike Rathke 
Date:   Tue Feb 28 22:14:08 2017 +0100

FastSaxSerializer: SAL_WARN() when writing invalid XML characters

This catches things for OOXML, that could be escaped using _x_

Change-Id: I937f67dc5edd3c0e5727d74bebb736dc82bdc53d

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 620fe68..a571829 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -101,6 +101,26 @@ namespace sax_fastparser {
 write( sOutput.getStr(), sOutput.getLength(), bEscape );
 }
 
+#if OSL_DEBUG_LEVEL > 0
+/** Characters not allowed in XML 1.0
+XML 1.1 would exclude only U+
+ */
+bool invalidChar( char c )
+{
+if (static_cast(c) >= 0x20)
+return false;
+
+switch (c)
+{
+case 0x09:
+case 0x0a:
+case 0x0d:
+return false;
+}
+return true;
+}
+#endif
+
 void FastSaxSerializer::write( const char* pStr, sal_Int32 nLen, bool 
bEscape )
 {
 if (nLen == -1)
@@ -112,6 +132,7 @@ namespace sax_fastparser {
 return;
 }
 
+bool bGood = true;
 for (sal_Int32 i = 0; i < nLen; ++i)
 {
 char c = pStr[ i ];
@@ -124,9 +145,26 @@ namespace sax_fastparser {
 case '"':   writeBytes( """, 6 );   break;
 case '\n':  writeBytes( "
", 5 );break;
 case '\r':  writeBytes( "
", 5 );break;
-default:writeBytes( &c, 1 );  break;
+default:
+#if OSL_DEBUG_LEVEL > 0
+/* FIXME: we should escape such invalid characters
+ * in the _x_ form OOXML uses. Note that also a
+ * literal "_x0008_" would have to be escaped then
+ * as _x005F_x0008_ (where only the leading '_' is
+ * escaped as _x005F_). */
+if (invalidChar(pStr[i]))
+{
+bGood = false;
+// The SAL_WARN() for the single character is
+// issued in writeBytes(), just gather for the
+// SAL_WARN_IF() below.
+}
+#endif
+writeBytes( &c, 1 ); break;
 }
 }
+SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << 
OString(pStr,std::min(nLen,42)) << "'");
+(void)bGood;
 }
 
 void FastSaxSerializer::endDocument()
@@ -496,6 +534,21 @@ namespace sax_fastparser {
 
 void FastSaxSerializer::writeBytes( const char* pStr, size_t nLen )
 {
+#if OSL_DEBUG_LEVEL > 0
+{
+bool bGood = true;
+for (size_t i=0; i < nLen; ++i)
+{
+if (invalidChar(pStr[i]))
+{
+bGood = false;
+SAL_WARN("sax", "FastSaxSerializer::writeBytes - illegal 
XML character 0x" <<
+std::hex << int(static_cast(pStr[i])));
+}
+}
+SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << 
OString(pStr,std::min(nLen,42)) << "'");
+}
+#endif
 maCachedOutputStream.writeBytes( reinterpret_cast(pStr), nLen );
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-02-20 Thread David Ostrovsky
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 996960f5a25c0833942c03b94356d2137c4d7557
Author: David Ostrovsky 
Date:   Fri Feb 17 22:21:08 2017 +

MSVC 14.0: Fix warning C4702: unreachable code

Change-Id: I38db92984daae40981f2d3f60c4efa38684d5328
Reviewed-on: https://gerrit.libreoffice.org/34382
Tested-by: Jenkins 
Reviewed-by: David Ostrovsky 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 498bd4d..1b0ad53 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -980,7 +980,7 @@ bool FastSaxParserImpl::consume(EventList *pEventList)
 return false;
 case EXCEPTION:
 rEntity.throwException( mxDocumentLocator, false );
-return false;
+SAL_FALLTHROUGH; // avoid unreachable code warning with some 
comilers
 default:
 assert(false);
 return false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-02-02 Thread Noel Grandin
 sax/source/tools/converter.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d7363da21d47cd7935896146fa27a5512d6baf5b
Author: Noel Grandin 
Date:   Thu Feb 2 10:29:06 2017 +0200

fix linux build

after commit 1461ebb
"expand out ::sax::Converter::convertNumber to OUString::number"

Change-Id: Ie219db074a626b124cc640612e549ec9ac869296

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index c3a7703..c0e9e1f 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -645,7 +645,7 @@ void Converter::convertAngle(OUStringBuffer& rBuffer, 
sal_Int16 const nAngle)
 {
 #if 1
 // wrong, but backward compatible with OOo/LO < 4.4
-rBuffer.append(nAngle);
+rBuffer.append(static_cast(nAngle));
 #else
 // maybe in the future... (see other convertAngle)
 double fAngle(double(nAngle) / 10.0);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2017-01-18 Thread Mike Kaganski
 sax/source/fastparser/fastparser.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 18ae77a065cb8ae6940d4067f6ab7e99a3f74047
Author: Mike Kaganski 
Date:   Wed Jan 18 10:16:14 2017 +0300

Also consider saved exceptions when mbEnableThreads is true

Previously, saved exceptions are only checked in FastSaxParserImpl::parse(),
which is used in case mbEnableThreads is false (when data in input stream
is no more than 1). This patch also enables the same check for the
other case.

Change-Id: Ie718556b7c01322e30698515ecd331b7ebad4105
Reviewed-on: https://gerrit.libreoffice.org/33249
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 03ea471..420f8c7 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -811,6 +811,10 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 } while (!done);
 xParser->join();
 deleteUsedEvents();
+
+// callbacks used inside XML_Parse may have caught an exception
+if( rEntity.maSavedException.hasValue() )
+rEntity.throwException( mxDocumentLocator, true );
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2016-07-29 Thread Mohammed Abdul Azeem
 sax/source/fastparser/fastparser.cxx |   50 +--
 1 file changed, 42 insertions(+), 8 deletions(-)

New commits:
commit 916a11d26cb74da9dd534e07b35737def6cbf54a
Author: Mohammed Abdul Azeem 
Date:   Thu Jul 28 23:10:12 2016 +0530

GSoC - moving FastAttributeList::clear to consumer thread:

this shares the load of clearing the attributes list with
the consumer when producer is busy.

Change-Id: I6e89858703c7af9c30b2d99fd6825dc81290b488
Reviewed-on: https://gerrit.libreoffice.org/27649
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index ab324a1..8fa9223 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -70,7 +70,11 @@ struct Entity;
 typedef std::unordered_map< OUString, sal_Int32,
 OUStringHash > NamespaceMap;
 
-typedef std::vector EventList;
+struct EventList
+{
+std::vector maEvents;
+bool mbIsAttributesEmpty;
+};
 
 enum CallbackType { INVALID, START_ELEMENT, END_ELEMENT, CHARACTERS, DONE, 
EXCEPTION };
 
@@ -531,7 +535,7 @@ EventList* Entity::getEventList()
 if (!mpProducedEvents)
 {
 mpProducedEvents = new EventList();
-mpProducedEvents->resize(mnEventListSize);
+mpProducedEvents->maEvents.resize(mnEventListSize);
 mnProducedEventsSize = 0;
 }
 }
@@ -544,7 +548,7 @@ Event& Entity::getEvent( CallbackType aType )
 return maSharedEvent;
 
 EventList* pEventList = getEventList();
-Event& rEvent = (*pEventList)[mnProducedEventsSize++];
+Event& rEvent = pEventList->maEvents[mnProducedEventsSize++];
 rEvent.maType = aType;
 return rEvent;
 }
@@ -783,6 +787,24 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 done = true;
 
 aGuard.reset(); // lock
+
+if ( rEntity.maPendingEvents.size() <= 
rEntity.mnEventLowWater )
+{
+aGuard.clear();
+for (auto aEventIt = pEventList->maEvents.begin();
+aEventIt != pEventList->maEvents.end(); ++aEventIt)
+{
+if (aEventIt->mxAttributes.is())
+{
+aEventIt->mxAttributes->clear();
+if( rEntity.mxNamespaceHandler.is() )
+aEventIt->mxDeclAttributes->clear();
+}
+pEventList->mbIsAttributesEmpty = true;
+}
+aGuard.reset();
+}
+
 rEntity.maUsedEvents.push(pEventList);
 }
 } while (!done);
@@ -926,8 +948,9 @@ void FastSaxParserImpl::produce( bool bForceFlush )
 bool FastSaxParserImpl::consume(EventList *pEventList)
 {
 Entity& rEntity = getEntity();
-for (EventList::iterator aEventIt = pEventList->begin();
- aEventIt != pEventList->end(); ++aEventIt)
+pEventList->mbIsAttributesEmpty = false;
+for (auto aEventIt = pEventList->maEvents.begin();
+ aEventIt != pEventList->maEvents.end(); ++aEventIt)
 {
 switch ((*aEventIt).maType)
 {
@@ -1042,17 +1065,28 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 }
 
 // create attribute map and process namespace instructions
-Event& rEvent = getEntity().getEvent( START_ELEMENT );
+Event& rEvent = rEntity.getEvent( START_ELEMENT );
+bool bIsAttributesEmpty = false;
+if ( rEntity.mbEnableThreads )
+bIsAttributesEmpty = rEntity.getEventList()->mbIsAttributesEmpty;
+
 if (rEvent.mxAttributes.is())
-rEvent.mxAttributes->clear();
+{
+if( !bIsAttributesEmpty )
+rEvent.mxAttributes->clear();
+}
 else
 rEvent.mxAttributes.set(
 new FastAttributeList( rEntity.mxTokenHandler,
rEntity.mpTokenHandler ) );
+
 if( rEntity.mxNamespaceHandler.is() )
 {
 if (rEvent.mxDeclAttributes.is())
-rEvent.mxDeclAttributes->clear();
+{
+if( !bIsAttributesEmpty )
+rEvent.mxDeclAttributes->clear();
+}
 else
 rEvent.mxDeclAttributes.set(
 new FastAttributeList( rEntity.mxTokenHandler,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2016-07-27 Thread Mohammed Abdul Azeem
 sax/source/fastparser/fastparser.cxx   |  109 +
 sax/source/fastparser/legacyfastparser.cxx |   16 
 2 files changed, 67 insertions(+), 58 deletions(-)

New commits:
commit 84db6c1d9c57c3dc115dc22413442cf1aa5e69df
Author: Mohammed Abdul Azeem 
Date:   Wed Jul 27 22:28:39 2016 +0530

GSOC - Avoid tokenizing strings for Unknown elements:

Added a special case when token handler is not set, which
avoids tokenizing strings.

Change-Id: I749a7af22e45180cc8bfc55843832b7ccb529ac6
Reviewed-on: https://gerrit.libreoffice.org/27593
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 49038b8..ab324a1 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -738,9 +738,6 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 Entity entity( maData );
 entity.maStructSource = maStructSource;
 
-if( !entity.mxTokenHandler.is() )
-throw SAXException("No token handler, use setTokenHandler()", 
Reference< XInterface >(), Any() );
-
 if( !entity.maStructSource.aInputStream.is() )
 throw SAXException("No input source", Reference< XInterface >(), Any() 
);
 
@@ -1072,60 +1069,88 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 
 try
 {
-/*  #158414# Each element may define new namespaces, also for 
attribues.
-First, process all namespaces, second, process the attributes 
after namespaces
-have been initialized. */
-
-// #158414# first: get namespaces
-for (int i = 0; i < numNamespaces * 2; i += 2)
+if ( rEntity.mxTokenHandler.is() )
 {
-// namespaces[] is (prefix/URI)
-if( namespaces[ i ] != nullptr )
+/*  #158414# Each element may define new namespaces, also for 
attribues.
+First, process all namespaces, second, process the attributes 
after namespaces
+have been initialized. */
+
+// #158414# first: get namespaces
+for (int i = 0; i < numNamespaces * 2; i += 2)
 {
-DefineNamespace( OString( XML_CAST( namespaces[ i ] )),
-OUString( XML_CAST( namespaces[ i + 1 ] ), strlen( 
XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 ));
-if( rEntity.mxNamespaceHandler.is() )
-rEvent.mxDeclAttributes->addUnknown( OString( 
XML_CAST( namespaces[ i ] ) ), OString( XML_CAST( namespaces[ i + 1 ] ) ) );
+// namespaces[] is (prefix/URI)
+if( namespaces[ i ] != nullptr )
+{
+DefineNamespace( OString( XML_CAST( namespaces[ i ] )),
+OUString( XML_CAST( namespaces[ i + 1 ] ), strlen( 
XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 ));
+}
+else
+{
+// default namespace
+sNamespace = OUString( XML_CAST( namespaces[ i + 1 ] ), 
strlen( XML_CAST( namespaces[ i + 1 ] )), RTL_TEXTENCODING_UTF8 );
+nNamespaceToken = GetNamespaceToken( sNamespace );
+}
 }
+
+// #158414# second: fill attribute list with other attributes
+for (int i = 0; i < numAttributes * 5; i += 5)
+{
+// attributes[] is ( localname / prefix / nsURI / valueBegin / 
valueEnd )
+if( attributes[ i + 1 ] != nullptr )
+{
+sal_Int32 nAttributeToken = GetTokenWithPrefix( 
attributes[ i + 1 ], strlen( XML_CAST( attributes[ i + 1 ] )), attributes[ i ], 
strlen( XML_CAST( attributes[ i ] )));
+if( nAttributeToken != FastToken::DONTKNOW )
+rEvent.mxAttributes->add( nAttributeToken, XML_CAST( 
attributes[ i + 3 ] ), attributes[ i + 4 ] - attributes[ i + 3 ] );
+else
+rEvent.mxAttributes->addUnknown( OUString( XML_CAST( 
attributes[ i + 1 ] ), strlen( XML_CAST( attributes[ i + 1 ] )), 
RTL_TEXTENCODING_UTF8 ),
+OString( XML_CAST( attributes[ i ] )), 
OString( XML_CAST( attributes[ i + 3 ] ), attributes[ i + 4 ] - attributes[ i + 
3 ] ));
+}
+else
+{
+sal_Int32 nAttributeToken = GetToken( attributes[ i ], 
strlen( XML_CAST( attributes[ i ] )));
+if( nAttributeToken != FastToken::DONTKNOW )
+rEvent.mxAttributes->add( nAttributeToken, XML_CAST( 
attributes[ i + 3 ] ), attributes[ i + 4 ] - attributes[ i + 3 ] );
+else
+rEvent.mxAttributes->addUnknown( XML_CAST( attributes[ 
i ] ),
+   

[Libreoffice-commits] core.git: sax/source

2016-05-04 Thread Rosemary Sebastian
 sax/source/tools/converter.cxx |   24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

New commits:
commit 9144a54a7612aa75cf58e857ddd4913f8bac6965
Author: Rosemary Sebastian 
Date:   Sun May 1 14:46:15 2016 +0530

tdf#94260 Convert pixel to 1/100 mm

The scaling factor 0.28 is chosen as per
https://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#pixels

Change-Id: I8dc7846699fbb2aa6e2a181a041b66d3cc33b8e5
Reviewed-on: https://gerrit.libreoffice.org/24547
Reviewed-by: Oliver Specht 
Tested-by: Oliver Specht 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index d1f6c9f..39baec9 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -125,10 +125,11 @@ bool Converter::convertMeasure( sal_Int32& rValue,
 else
 {
 OSL_ENSURE( MeasureUnit::TWIP == nTargetUnit || MeasureUnit::POINT 
== nTargetUnit ||
-MeasureUnit::MM_100TH == nTargetUnit || 
MeasureUnit::MM_10TH == nTargetUnit, "unit is not supported");
-const sal_Char *aCmpsL[2] = { nullptr, nullptr };
-const sal_Char *aCmpsU[2] = { nullptr, nullptr };
-double aScales[2] = { 1., 1. };
+MeasureUnit::MM_100TH == nTargetUnit || 
MeasureUnit::MM_10TH == nTargetUnit ||
+MeasureUnit::PIXEL == nTargetUnit, "unit is not 
supported");
+const sal_Char *aCmpsL[3] = { nullptr, nullptr, nullptr };
+const sal_Char *aCmpsU[3] = { nullptr, nullptr, nullptr };
+double aScales[3] = { 1., 1., 1. };
 
 if( MeasureUnit::TWIP == nTargetUnit )
 {
@@ -196,6 +197,10 @@ bool Converter::convertMeasure( sal_Int32& rValue,
 aCmpsL[1] = "pc";
 aCmpsU[1] = "PC";
 aScales[1] = (10.0 * nScaleFactor*2.54)/12.; // mm/100
+
+aCmpsL[2] = "px";
+aCmpsU[2] = "PX";
+aScales[2] = 0.28 * nScaleFactor; // mm/100
 break;
 }
 }
@@ -213,22 +218,23 @@ bool Converter::convertMeasure( sal_Int32& rValue,
 return false;
 
 double nScale = 0.;
-for( sal_uInt16 i= 0; i < 2; i++ )
+for( sal_uInt16 i= 0; i < 3; i++ )
 {
+sal_Int32 nTmp = nPos; // come back to the initial position 
before each iteration
 const sal_Char *pL = aCmpsL[i];
 if( pL )
 {
 const sal_Char *pU = aCmpsU[i];
-while( nPos < nLen && *pL )
+while( nTmp < nLen && *pL )
 {
-sal_Unicode c = rString[nPos];
+sal_Unicode c = rString[nTmp];
 if( c != *pL && c != *pU )
 break;
 pL++;
 pU++;
-nPos++;
+nTmp++;
 }
-if( !*pL && (nPos == nLen || ' ' == rString[nPos]) )
+if( !*pL && (nTmp == nLen || ' ' == rString[nTmp]) )
 {
 nScale = aScales[i];
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2016-02-03 Thread Caolán McNamara
 sax/source/tools/converter.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b9fa2963cf12e6987b3a0acc219c4fa591e41be8
Author: Caolán McNamara 
Date:   Wed Feb 3 10:30:43 2016 +

fix gcc build error

error: invalid operands of types '__gnu_cxx::__enable_if::__type
{aka double}' and 'int' to binary 'operator%'

apparently there's a template returning double for abs for the
non-int/long/float/double argument case. So promote earlier to int so the
abs is called

Change-Id: I882a27c5ec349f894c1c9f4857687360a46b55ae

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 744415e..cf061c9 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1250,7 +1250,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
 
 
 static void
-lcl_AppendTimezone(OUStringBuffer & i_rBuffer, sal_Int16 const nOffset)
+lcl_AppendTimezone(OUStringBuffer & i_rBuffer, int const nOffset)
 {
 if (0 == nOffset)
 {
@@ -1435,7 +1435,7 @@ lcl_MaxDaysPerMonth(const sal_Int32 nMonth, const 
sal_Int32 nYear)
 static void lcl_ConvertToUTC(
 sal_Int16 & o_rYear, sal_uInt16 & o_rMonth, sal_uInt16 & o_rDay,
 sal_uInt16 & o_rHours, sal_uInt16 & o_rMinutes,
-sal_Int16 const nSourceOffset)
+int const nSourceOffset)
 {
 sal_Int16 nOffsetHours(abs(nSourceOffset) / 60);
 sal_Int16 const nOffsetMinutes(abs(nSourceOffset) % 60);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2016-01-17 Thread Caolán McNamara
 sax/source/tools/fastserializer.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 734cadff24b3e8555b40c58b4abd1f1c366c25cb
Author: Caolán McNamara 
Date:   Sun Jan 17 20:32:07 2016 +

crashtesting: plain-text import allows liberal with the UTF-8 input

see ImplConvertUtf8ToUnicode which allows surrogates, so we need a 
non-liberal
utf-input there if we want to enfore non-liberal utf-output here.

Change-Id: I713818d7b6d79922d9b08f2b137a803384eccb65

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 8437ff0..b81886e 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -94,7 +94,7 @@ namespace sax_fastparser {
 
 void FastSaxSerializer::write( const OUString& sOutput, bool bEscape )
 {
-write( sOutput.toUtf8(), bEscape );
+write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8), bEscape );
 
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sw/qa

2016-01-12 Thread Mark Hung
 sax/source/tools/fastserializer.cxx   |   25 ++---
 sw/qa/extras/ooxmlexport/data/nonbmpchar.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |9 +
 3 files changed, 11 insertions(+), 23 deletions(-)

New commits:
commit 7ec5ba47783ac8b2d0141109d0efe6b20b363ced
Author: Mark Hung 
Date:   Sun Jan 10 00:28:14 2016 +0800

Fix FastSaxSerializer::write() for non-BMP unicode characters.

Change-Id: I6ee9d028813c970b9ac5b9f0574af932e73111bd
Reviewed-on: https://gerrit.libreoffice.org/21293
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 37ed847..8437ff0 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -94,29 +94,8 @@ namespace sax_fastparser {
 
 void FastSaxSerializer::write( const OUString& sOutput, bool bEscape )
 {
-const sal_Int32 nLength = sOutput.getLength();
-for (sal_Int32 i = 0; i < nLength; ++i)
-{
-const sal_Unicode cUnicode = sOutput[ i ];
-const char cChar = cUnicode;
-if (cUnicode & 0xff80)
-{
-write( OString(&cUnicode, 1, RTL_TEXTENCODING_UTF8) );
-}
-else if(bEscape) switch( cChar )
-{
-case '<':   writeBytes( "<", 4 ); break;
-case '>':   writeBytes( ">", 4 ); break;
-case '&':   writeBytes( "&", 5 );break;
-case '\'':  writeBytes( "'", 6 );   break;
-case '"':   writeBytes( """, 6 );   break;
-case '\n':  writeBytes( "
", 5 );break;
-case '\r':  writeBytes( "
", 5 );break;
-default:writeBytes( &cChar, 1 ); break;
-}
-else
-writeBytes( &cChar, 1 );
-}
+write( sOutput.toUtf8(), bEscape );
+
 }
 
 void FastSaxSerializer::write( const OString& sOutput, bool bEscape )
diff --git a/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx 
b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx
new file mode 100644
index 000..a6b5d41
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 9deea3e..68c0e2d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1011,6 +1011,15 @@ DECLARE_OOXMLEXPORT_TEST(testOO106020, "ooo106020-1.odt")
 assertXPath(pXmlDoc, "//w:tbl", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, "nonbmpchar.docx")
+{
+sal_uInt32  nCh = 0x24b62;
+OUString aExpected( &nCh, 1);
+// Assert that UTF8 encoded non-BMP Unicode character is correct
+uno::Reference xTextRange1 = getRun(getParagraph(1), 1);
+CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2015-07-04 Thread Norbert Thiebaud
 sax/source/tools/fastserializer.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit a551d82bfc3ddae2354d39c90e31ad6eefcd1617
Author: Norbert Thiebaud 
Date:   Sat Jul 4 04:46:32 2015 -0500

WaE do not us #if for DB_UTIL but #ifdef

Change-Id: I8b0a6c3323a4ffbe6a1ba09e5cff9ddd92ed49f1

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index a2ba5c15..2d4a2e1 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -426,7 +426,7 @@ namespace sax_fastparser {
 
 if ( maMarkStack.size() == 1  && eMergeType != MERGE_MARKS_IGNORE)
 {
-#if DBG_UTIL
+#ifdef DBG_UTIL
 while (!maMarkStack.top()->m_DebugEndedElements.empty())
 {
 assert(maMarkStack.top()->m_DebugEndedElements.front() == 
m_DebugStartedElements.top());
@@ -447,13 +447,13 @@ namespace sax_fastparser {
 return;
 }
 
-#if DBG_UTIL
+#ifdef DBG_UTIL
 ::std::deque 
topDebugStartedElements(maMarkStack.top()->m_DebugStartedElements);
 ::std::deque 
topDebugEndedElements(maMarkStack.top()->m_DebugEndedElements);
 #endif
 const Int8Sequence aMerge( maMarkStack.top()->getData() );
 maMarkStack.pop();
-#if DBG_UTIL
+#ifdef DBG_UTIL
 switch (eMergeType)
 {
 case MERGE_MARKS_APPEND:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2015-01-27 Thread Michael Meeks
 sax/source/tools/fastattribs.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 7f0dcdfd22f90e2697d8858558b66174bd64ae34
Author: Michael Meeks 
Date:   Tue Jan 27 11:10:32 2015 +0100

sax: minor optimization

Change-Id: I4812a567e37789c71af0cc6ba8f5a5caf0e3ec93

diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index c1a3e1c..8552ad4 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -71,9 +71,9 @@ FastAttributeList::~FastAttributeList()
 void FastAttributeList::clear()
 {
 maAttributeTokens.clear();
-maAttributeValues.clear();
-maAttributeValues.push_back( 0 );
-maUnknownAttributes.clear();
+maAttributeValues.resize(1);
+if (maUnknownAttributes.size() > 0)
+maUnknownAttributes.clear();
 }
 
 void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t 
nValueLength )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2015-01-22 Thread Caolán McNamara
 sax/source/fastparser/fastparser.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit c0c1b01a32b91984d61f2d0b9146719fcaed7e09
Author: Caolán McNamara 
Date:   Thu Jan 22 13:36:01 2015 +

WaE: warning C4101: ´e´ : unreferenced local variable

Change-Id: Ifa143e5a8f0e8254fbd324032951517d3a30c4c8

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 82a2856..38a1d2e 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -456,7 +456,7 @@ void Entity::startElement( Event *pEvent )
 maContextStack.top().mxContext.set( static_cast( xContext.get() ) );
 xContext.set( NULL, UNO_REF_NO_ACQUIRE );
 }
-catch (const Exception& e)
+catch (const Exception&)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -475,7 +475,7 @@ void Entity::characters( const OUString& sChars )
 {
 xContext->characters( sChars );
 }
-catch (const Exception& e)
+catch (const Exception&)
 {
 saveException( ::cppu::getCaughtException() );
 }
@@ -499,7 +499,7 @@ void Entity::endElement()
 else
 xContext->endUnknownElement( aContext.maNamespace, 
aContext.maElementName );
 }
-catch (const Exception& e)
+catch (const Exception&)
 {
 saveException( ::cppu::getCaughtException() );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source sc/source

2014-12-20 Thread Michael Weghorn
 sax/source/tools/converter.cxx   |2 +-
 sc/source/core/data/attarray.cxx |   13 -
 sc/source/core/data/documen7.cxx |3 +--
 sc/source/core/data/fillinfo.cxx |3 +--
 sc/source/core/tool/callform.cxx |3 +--
 sc/source/core/tool/chgtrack.cxx |5 ++---
 sc/source/core/tool/interpr2.cxx |   10 +-
 sc/source/core/tool/interpr3.cxx |   22 ++
 sc/source/core/tool/interpr5.cxx |   36 
 sc/source/core/tool/interpr6.cxx |   12 
 10 files changed, 41 insertions(+), 68 deletions(-)

New commits:
commit 8abd002240e8d7666300bf6fa832a28988e9ed0a
Author: Michael Weghorn 
Date:   Fri Dec 19 13:06:58 2014 +0100

fdo#39440 sax, sc: reduce scope of local variables

This addresses some cppcheck warnings.

Change-Id: I589e13ee086cffee481954215a97960db656e633
Reviewed-on: https://gerrit.libreoffice.org/13548
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index a831269..e4d3c96 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -84,10 +84,10 @@ bool Converter::convertMeasure( sal_Int32& rValue,
 nVal += (rString[nPos] - '0');
 nPos++;
 }
-double nDiv = 1.;
 if( nPos < nLen && '.' == rString[nPos] )
 {
 nPos++;
+double nDiv = 1.;
 
 while( nPos < nLen &&
'0' <= rString[nPos] &&
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 65af7f6..0f7683c 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -107,14 +107,13 @@ void ScAttrArray::TestData() const
 void ScAttrArray::Reset( const ScPatternAttr* pPattern )
 {
 ScDocumentPool*  pDocPool = pDocument->GetPool();
-const ScPatternAttr* pOldPattern;
 ScAddressaAdrStart( nCol, 0, nTab );
 ScAddressaAdrEnd  ( nCol, 0, nTab );
 
 for (SCSIZE i=0; iGetItemSet(), pOldPattern->GetItemSet() ) )
@@ -180,7 +179,6 @@ bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
 bool bFound = (nCount == 1);
 long nLo = 0;
 long nStartRow = 0;
-long nEndRow = 0;
 while ( !bFound && nLo <= nHi )
 {
 i = (nLo + nHi) / 2;
@@ -188,7 +186,7 @@ bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
 nStartRow = (long) pData[i - 1].nRow;
 else
 nStartRow = -1;
-nEndRow = (long) pData[i].nRow;
+const long nEndRow = (long) pData[i].nRow;
 if (nEndRow < (long) nRow)
 nLo = ++i;
 else
@@ -1606,8 +1604,6 @@ bool ScAttrArray::RemoveFlags( SCROW nStartRow, SCROW 
nEndRow, sal_Int16 nFlags
 
 void ScAttrArray::ClearItems( SCROW nStartRow, SCROW nEndRow, const 
sal_uInt16* pWhich )
 {
-const ScPatternAttr* pOldPattern;
-
 SCSIZE  nIndex;
 SCROW   nRow;
 SCROW   nThisRow;
@@ -1618,7 +1614,7 @@ void ScAttrArray::ClearItems( SCROW nStartRow, SCROW 
nEndRow, const sal_uInt16*
 
 while ( nThisRow <= nEndRow )
 {
-pOldPattern = pData[nIndex].pPattern;
+const ScPatternAttr* pOldPattern = pData[nIndex].pPattern;
 if ( pOldPattern->HasItemsSet( pWhich ) )
 {
 ScPatternAttr aNewPattern(*pOldPattern);
@@ -2147,7 +2143,6 @@ void ScAttrArray::DeleteArea(SCROW nStartRow, SCROW 
nEndRow)
 void ScAttrArray::DeleteHardAttr(SCROW nStartRow, SCROW nEndRow)
 {
 const ScPatternAttr* pDefPattern = pDocument->GetDefPattern();
-const ScPatternAttr* pOldPattern;
 
 SCSIZE  nIndex;
 SCROW   nRow;
@@ -2159,7 +2154,7 @@ void ScAttrArray::DeleteHardAttr(SCROW nStartRow, SCROW 
nEndRow)
 
 while ( nThisRow <= nEndRow )
 {
-pOldPattern = pData[nIndex].pPattern;
+const ScPatternAttr* pOldPattern = pData[nIndex].pPattern;
 
 if ( pOldPattern->GetItemSet().Count() )  // hard attributes ?
 {
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index af7337e..1871a24 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -589,13 +589,12 @@ void ScDocument::TrackFormulas( sal_uLong nHintId )
 {
 // outside the loop, check if any sheet has a "calculate" event script
 bool bCalcEvent = HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, 
true );
-SvtBroadcaster* pBC;
 ScFormulaCell* pTrack;
 ScFormulaCell* pNext;
 pTrack = pFormulaTrack;
 do
 {
-pBC = GetBroadcaster(pTrack->aPos);
+SvtBroadcaster* pBC = GetBroadcaster(pTrack->aPos);
 ScHint aHint(nHintId, pTrack->aPos);
 if (pBC)
 pBC->Broadcast( aHint );
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index c2d36c0..0328954 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -

[Libreoffice-commits] core.git: sax/source

2014-12-08 Thread Matúš Kukan
 sax/source/fastparser/fastparser.cxx |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 848adf433a2408fd37f333b66413b94be97e1f7a
Author: Matúš Kukan 
Date:   Mon Dec 8 11:41:34 2014 +0100

fastparser: Redundant check after assert

Change-Id: Ibc56102831d4d36392bea4e4e088e207cef99429

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index fc1f5a9..a0e99b9 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -623,15 +623,12 @@ void FastSaxParserImpl::DefineNamespace( const OString& 
rPrefix, const OUString&
 {
 Entity& rEntity = getEntity();
 assert(!rEntity.maNamespaceCount.empty()); // need a context!
-if( !rEntity.maNamespaceCount.empty() )
-{
-sal_uInt32 nOffset = rEntity.maNamespaceCount.top()++;
 
-if( rEntity.maNamespaceDefines.size() <= nOffset )
-rEntity.maNamespaceDefines.resize( 
rEntity.maNamespaceDefines.size() + 64 );
+sal_uInt32 nOffset = rEntity.maNamespaceCount.top()++;
+if( rEntity.maNamespaceDefines.size() <= nOffset )
+rEntity.maNamespaceDefines.resize( rEntity.maNamespaceDefines.size() + 
64 );
 
-rEntity.maNamespaceDefines[nOffset].reset( new NamespaceDefine( 
rPrefix, GetNamespaceToken( namespaceURL ), namespaceURL ) );
-}
+rEntity.maNamespaceDefines[nOffset].reset( new NamespaceDefine( rPrefix, 
GetNamespaceToken( namespaceURL ), namespaceURL ) );
 }
 
 sal_Int32 FastSaxParserImpl::GetToken( const xmlChar* pName, sal_Int32 nameLen 
/* = 0 */ )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-12-03 Thread Kohei Yoshida
 sax/source/fastparser/fastparser.cxx |   22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

New commits:
commit a09a709594dd0f6e38f8c6bf28433bd391e8842d
Author: Kohei Yoshida 
Date:   Wed Dec 3 19:41:04 2014 -0500

Prevent hang during loading of xlsm doc.

* We need to call xmlInitParser() before using it in a multi-threaded
  way (according to the libxml2 doc).
* Better to use 'rEntity' which references the one stored in the vector
  rather than 'entity' whose copy gets stored in the vector. On Windows
  at least 'rEntity' and 'entity' hold different parser pointer values.
* Free the parser before popping the entity. Popping the entity first then
  freeing the parser using its pointer value stored in the entity looks
  weird.

Change-Id: I6b64a6d8ac9c1d4fea8339d8fb2d38dfffbba47b

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 92791fc..fc1f5a9 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -720,6 +720,8 @@ sal_Int32 FastSaxParserImpl::GetTokenWithContextNamespace( 
sal_Int32 nNamespaceT
 void FastSaxParserImpl::parseStream(const InputSource& maStructSource)
 throw (SAXException, IOException, RuntimeException, std::exception)
 {
+xmlInitParser();
+
 // Only one text at one time
 MutexGuard guard( maMutex );
 
@@ -741,11 +743,11 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 try
 {
 // start the document
-if( entity.mxDocumentHandler.is() )
+if( rEntity.mxDocumentHandler.is() )
 {
 Reference< XLocator > xLoc( mxDocumentLocator.get() );
-entity.mxDocumentHandler->setDocumentLocator( xLoc );
-entity.mxDocumentHandler->startDocument();
+rEntity.mxDocumentHandler->setDocumentLocator( xLoc );
+rEntity.mxDocumentHandler->startDocument();
 }
 
 rEntity.mbEnableThreads = 
(rEntity.maStructSource.aInputStream->available() > 1);
@@ -786,33 +788,33 @@ void FastSaxParserImpl::parseStream(const InputSource& 
maStructSource)
 }
 
 // finish document
-if( entity.mxDocumentHandler.is() )
+if( rEntity.mxDocumentHandler.is() )
 {
-entity.mxDocumentHandler->endDocument();
+rEntity.mxDocumentHandler->endDocument();
 }
 }
 catch (const SAXException&)
 {
-popEntity();
 // TODO free mpParser.myDoc ?
-xmlFreeParserCtxt( entity.mpParser );
+xmlFreeParserCtxt( rEntity.mpParser );
+popEntity();
 throw;
 }
 catch (const IOException&)
 {
+xmlFreeParserCtxt( rEntity.mpParser );
 popEntity();
-xmlFreeParserCtxt( entity.mpParser );
 throw;
 }
 catch (const RuntimeException&)
 {
+xmlFreeParserCtxt( rEntity.mpParser );
 popEntity();
-xmlFreeParserCtxt( entity.mpParser );
 throw;
 }
 
+xmlFreeParserCtxt( rEntity.mpParser );
 popEntity();
-xmlFreeParserCtxt( entity.mpParser );
 }
 
 void FastSaxParserImpl::setFastDocumentHandler( const Reference< 
XFastDocumentHandler >& Handler ) throw (RuntimeException)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-12-01 Thread Kohei Yoshida
 sax/source/fastparser/fastparser.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 285cd8301c725cceead97d645f22fd92ba644492
Author: Kohei Yoshida 
Date:   Mon Dec 1 22:21:26 2014 -0500

We need to tell libxml2 parser to decode entities.

Else we would get raw entity values such as '&' in lieu of '&'.

Change-Id: Ib700705fd9b68980306883aa9652579e1686040d

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 7e31784..ae0e8d8 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1006,6 +1006,9 @@ void FastSaxParserImpl::parse()
 reinterpret_cast(seqOut.getConstArray()), nRead, 
NULL );
 if( !rEntity.mpParser )
 throw SAXException("Couldn't create parser", Reference< 
XInterface >(), Any() );
+
+// Tell libxml2 parser to decode entities in attribute values.
+xmlCtxtUseOptions(rEntity.mpParser, XML_PARSE_NOENT);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-12-01 Thread Matúš Kukan
 sax/source/fastparser/fastparser.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 373daf55d98ba706d3dea131e755da3a00eb259f
Author: Matúš Kukan 
Date:   Mon Dec 1 13:32:05 2014 +0100

Add message to exception

Change-Id: I0e7cf850b51343e4afc1ea0a0409ad2c4e596435

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index bf3aa01..7e31784 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -655,7 +655,8 @@ sal_Int32 FastSaxParserImpl::GetTokenWithPrefix( const 
xmlChar* pPrefix, int nPr
 }
 
 if( !nNamespace )
-throw SAXException(); // prefix that has no defined namespace url
+throw SAXException("No namespace defined for " + 
OUString(XML_CAST(pPrefix),
+nPrefixLen, RTL_TEXTENCODING_UTF8), Reference< XInterface 
>(), Any());
 }
 
 if( nNamespaceToken != FastToken::DONTKNOW )
@@ -688,7 +689,8 @@ OUString FastSaxParserImpl::GetNamespaceURL( const OString& 
rPrefix ) throw (SAX
 return rEntity.maNamespaceDefines[nNamespace]->maNamespaceURL;
 }
 
-throw SAXException(); // prefix that has no defined namespace url
+throw SAXException("No namespace defined for " + 
OUString::fromUtf8(rPrefix),
+Reference< XInterface >(), Any());
 }
 
 sal_Int32 FastSaxParserImpl::GetTokenWithContextNamespace( sal_Int32 
nNamespaceToken, const xmlChar* pName, int nNameLen )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-11-15 Thread Markus Mohrhard
 sax/source/fastparser/fastparser.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 169562ff2648a99a04a7faf6223c471e957608db
Author: Markus Mohrhard 
Date:   Sat Nov 15 12:23:04 2014 +0100

windows blind fix

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 8d5dad2..38a4bbb 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -877,7 +877,7 @@ void FastSaxParserImpl::setEntityResolver(const Reference < 
XEntityResolver > &
 maData.mxEntityResolver = Resolver;
 }
 
-void FastSaxParserImpl::setLocale( const Locale & Locale ) throw 
(RuntimeException)
+void FastSaxParserImpl::setLocale( const lang::Locale & Locale ) throw 
(RuntimeException)
 {
 maData.maLocale = Locale;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-11-10 Thread Luboš Luňák
 sax/source/fastparser/fastparser.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 6df3d5e93a86a3ecb79cdb11e943e037d7648724
Author: Luboš Luňák 
Date:   Mon Nov 10 15:05:22 2014 +0100

remove pointless const_cast

Change-Id: I6026ab64f0cfe1d509c8f94ce3b9c6f700c823cf

diff --git a/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index 12429be..5c78713 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -740,8 +740,8 @@ sal_Int32 FastSaxParserImpl::GetTokenWithContextNamespace( 
sal_Int32 nNamespaceT
 
 void FastSaxParserImpl::splitName( const XML_Char *pwName, const XML_Char 
*&rpPrefix, sal_Int32 &rPrefixLen, const XML_Char *&rpName, sal_Int32 &rNameLen 
)
 {
-XML_Char *p;
-for( p = const_cast< XML_Char* >( pwName ), rNameLen = 0, rPrefixLen = 0; 
*p; p++ )
+const XML_Char *p;
+for( p = pwName, rNameLen = 0, rPrefixLen = 0; *p; p++ )
 {
 if( *p == ':' )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-10-23 Thread Tor Lillqvist
 sax/source/tools/CachedOutputStream.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bb72ad2969f536356334b0538108748e3947b041
Author: Tor Lillqvist 
Date:   Thu Oct 23 21:28:29 2014 +0300

WaE: implicit conversion of NULL constant to 'nullptr_t'

Change-Id: I23a85ba05a596b566be35ebecc6b1804c0d0cb62

diff --git a/sax/source/tools/CachedOutputStream.hxx 
b/sax/source/tools/CachedOutputStream.hxx
index fc74118..f116978 100644
--- a/sax/source/tools/CachedOutputStream.hxx
+++ b/sax/source/tools/CachedOutputStream.hxx
@@ -47,7 +47,7 @@ public:
  , mpCache(mnMaximumSize)
  , pSeq(mpCache.get())
  , mbWriteToOutStream(true)
- , mpForMerge(NULL)
+ , mpForMerge(nullptr)
 {}
 ~CachedOutputStream() {}
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sax/source

2014-10-10 Thread Stephan Bergmann
 sax/source/tools/fastserializer.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit dccc707da6bdb52a479923e8cfb0d048d7baaec1
Author: Stephan Bergmann 
Date:   Fri Oct 10 14:11:03 2014 +0200

Revert "This was OString already; use it that way"

This reverts commit 9a25d12534f91c13400a63e265fb5aa14c6aca66,
there's another use of DebugAttributes.find(rAttrName) in that
function where rAttrName is of type OUString.

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 4466623..fbce18a 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -225,7 +225,7 @@ namespace sax_fastparser {
 void FastSaxSerializer::writeFastAttributeList( const Reference< 
XFastAttributeList >& Attribs )
 {
 #ifdef DBG_UTIL
-::std::set DebugAttributes;
+::std::set DebugAttributes;
 #endif
 Sequence< Attribute > aAttrSeq = Attribs->getUnknownAttributes();
 const Attribute *pAttr = aAttrSeq.getConstArray();
@@ -258,9 +258,10 @@ namespace sax_fastparser {
 
 #ifdef DBG_UTIL
 // Well-formedness constraint: Unique Att Spec
-OString const nameId(getId(nToken));
-assert(DebugAttributes.find(nameId) == DebugAttributes.end());
-DebugAttributes.insert(nameId);
+OUString const name(OStringToOUString(getId(nToken),
+  RTL_TEXTENCODING_UTF8));
+assert(DebugAttributes.find(name) == DebugAttributes.end());
+DebugAttributes.insert(name);
 #endif
 
 writeBytes(toUnoSequence(maEqualSignAndQuote));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >