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

2022-09-23 Thread Stephan Bergmann (via logerrit)
 unotools/qa/unit/configpaths.cxx   |   21 +---
 unotools/source/config/configpaths.cxx |   86 +++--
 2 files changed, 56 insertions(+), 51 deletions(-)

New commits:
commit 8cadfec386d0fb906dbe9b8ea8f918e61927e622
Author: Stephan Bergmann 
AuthorDate: Fri Sep 23 16:08:05 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Sep 23 19:59:36 2022 +0200

Fix utl::splitLastFromConfigurationPath

* Fix regressions introduced with 5edefc801fb48559c8064003f23d22d838710ee4 
"use
  more string_view in unotools".  (Notably, misuses of two-argument std
  string_view rfind are something to watch out for, see the commit message 
of
  93e234c45c62af9d57041de676d888f7695ac0e8 "Fix a misuse of two-argument std
  string_view rfind" for details.)

* Bring the implementation some more in accordance with the documentation, 
by
  being stricter about handling invalid paths, and making sure to really 
assign
  all of the input _sInPath to the output _rsLocalName in case of an invalid
  path.

* Only &...;-decode the names of set elements in ['...'] and ["..."], not
  anything else.

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

diff --git a/unotools/qa/unit/configpaths.cxx b/unotools/qa/unit/configpaths.cxx
index e0a92f37c894..7d9907d9e34d 100644
--- a/unotools/qa/unit/configpaths.cxx
+++ b/unotools/qa/unit/configpaths.cxx
@@ -47,9 +47,6 @@ public:
 CPPUNIT_ASSERT_EQUAL(OUString(""), path);
 CPPUNIT_ASSERT_EQUAL(OUString("foo"), last);
 }
-// TODO: Broken since 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
-// unotools" (expected "" vs. actual "/foo"):
-if ((false))
 {
 // Already prior to 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
 // unotools", and in discordance with the documentation, this 
returned true (but
@@ -65,9 +62,6 @@ public:
 CPPUNIT_ASSERT_EQUAL(OUString("/foo/bar"), path);
 CPPUNIT_ASSERT_EQUAL(OUString("baz"), last);
 }
-// TODO: Broken since 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
-// unotools" (expected "/foo/bar" vs. actual "/foo/bar/baz"):
-if ((false))
 {
 // Trailing slash accepted for backwards compatibility (cf
 // . "for backwards compatibility, ignore a final slash" comment in
@@ -77,9 +71,6 @@ public:
 CPPUNIT_ASSERT_EQUAL(OUString("/foo/bar"), path);
 CPPUNIT_ASSERT_EQUAL(OUString("baz"), last);
 }
-// TODO: Broken since 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
-// unotools" (expected true vs. actual false return):
-if ((false))
 {
 OUString path, last;
 CPPUNIT_ASSERT(utl::splitLastFromConfigurationPath(
@@ -93,18 +84,14 @@ public:
 CPPUNIT_ASSERT_EQUAL(OUString(""), path);
 CPPUNIT_ASSERT_EQUAL(OUString("foo"), last);
 }
-// TODO: Broken since 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
-// unotools" (expected false vs. actual true return):
-if ((false))
 {
-// Already prior to 5edefc801fb48559c8064003f23d22d838710ee4 "use 
more string_view in
-// unotools", and in discordance with the documentation, this set 
last to "foo" rather
-// than "foo/" (but "If _sInPath could not be parsed as 
a valid configuration
-// path, this is set to _sInPath"):
+// In accordance with the documentation, this sets last to "foo/" 
("If
+// _sInPath could not be parsed as a valid 
configuration path, this is set to
+// _sInPath"):
 OUString path, last;
 CPPUNIT_ASSERT(!utl::splitLastFromConfigurationPath(u"foo/", path, 
last));
 CPPUNIT_ASSERT_EQUAL(OUString(""), path);
-CPPUNIT_ASSERT_EQUAL(OUString("foo"), last);
+CPPUNIT_ASSERT_EQUAL(OUString("foo/"), last);
 }
 {
 // Some broken input missing a leading slash happens to be 
considered OK:
diff --git a/unotools/source/config/configpaths.cxx 
b/unotools/source/config/configpaths.cxx
index 4e5002238d93..4c626d96b4e0 100644
--- a/unotools/source/config/configpaths.cxx
+++ b/unotools/source/config/configpaths.cxx
@@ -19,6 +19,7 @@
 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -78,70 +79,87 @@ bool splitLastFromConfigurationPath(std::u16string_view 
_sInPath,
 {
 size_t nStart,nEnd;
 
-size_t nPos = _sInPath.size()-1;
+size_t nPos = _sInPath.size();
 
-// strip trailing slash
-if (nPos != std::u16string_view::npos && nPos > 0 && _sInPath[ nPos ] == 
'/')
+// for backwards compatibility, strip 

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

2021-06-30 Thread Noel Grandin (via logerrit)
 unotools/qa/complex/tempfile/Test01.java |2 ++
 unotools/qa/complex/tempfile/TestHelper.java |1 +
 unotools/source/ucbhelper/xtempfile.cxx  |7 ++-
 3 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit ecea9c42d5f1a5e63493fcd92944bd49fb91b338
Author: Noel Grandin 
AuthorDate: Wed Jun 30 10:30:25 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Jun 30 11:30:49 2021 +0200

fix failure in JunitTest_unotools_complex

Temp files created from OTempFileService are always opened with 
StreamMode::SHARE_DENYALL.
So normally you can't open them twice.

But the JunitTest_unotools_complex unit test used to work because it 
exploited a pessimisation in OTempFileService,
where that code would close the file when we read to the end.

Which meant that the unit test could open it again and read it.

However, in
commit 218f36dd614cf828e949f605faaf6a6fd615da26
Date:   Sun Jun 20 18:51:12 2021 +0200
tdf#135316 remove OTempFileService pessimisation
I removed that pessimisation.

So make the share mode a little more permissive.

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

diff --git a/unotools/qa/complex/tempfile/Test01.java 
b/unotools/qa/complex/tempfile/Test01.java
index f93b02186e8d..ca81e1801bef 100644
--- a/unotools/qa/complex/tempfile/Test01.java
+++ b/unotools/qa/complex/tempfile/Test01.java
@@ -51,6 +51,8 @@ public class Test01 {
 //compare the file name with the name in the URL.
 sFileURL = m_aTestHelper.GetTempFileURL( xTempFile );
 sFileName = m_aTestHelper.GetTempFileName( xTempFile );
+m_aTestHelper.Message( "Tempfile URL: " + sFileURL );
+m_aTestHelper.Message( "Tempfile name: " + sFileName );
 m_aTestHelper.CompareFileNameAndURL( sFileName, sFileURL );
 
 //write to the stream using the service.
diff --git a/unotools/qa/complex/tempfile/TestHelper.java 
b/unotools/qa/complex/tempfile/TestHelper.java
index 821c33da054b..9ea42b102673 100644
--- a/unotools/qa/complex/tempfile/TestHelper.java
+++ b/unotools/qa/complex/tempfile/TestHelper.java
@@ -78,6 +78,7 @@ public class TestHelper {
 public void ReadDirectlyFromTempFile( byte [][] pBytes, int nBytes,  
XSimpleFileAccess xSFA, String sTempFileURL )
  throws java.lang.Exception
 {
+Message ( "Attempting to read directly from " + sTempFileURL );
 XInputStream xInTemp = xSFA.openFileRead( sTempFileURL );
 if ( xInTemp == null )
 throw new java.lang.Exception("Cannot create input stream from 
URL.");
diff --git a/unotools/source/ucbhelper/xtempfile.cxx 
b/unotools/source/ucbhelper/xtempfile.cxx
index 0cc0d8904bac..d0f566c9e26c 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -234,7 +234,12 @@ void OTempFileService::checkError () const
 void OTempFileService::checkConnected ()
 {
 if (!mpStream && mpTempFile)
-mpStream = mpTempFile->GetStream( StreamMode::STD_READWRITE );
+{
+// Ideally we should open this SHARE_DENYALL, but the 
JunitTest_unotools_complex test wants to open
+// this file directly and read from it.
+mpStream = mpTempFile->GetStream(StreamMode::READ | StreamMode::WRITE
+ | StreamMode::SHARE_DENYWRITE);
+}
 
 if (!mpStream)
 throw css::io::NotConnectedException ( OUString(), static_cast < 
css::uno::XWeak * > (this ) );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-06-21 Thread Noel Grandin (via logerrit)
 unotools/qa/complex/tempfile/TempFileUnitTest.java |6 
 unotools/qa/complex/tempfile/Test01.java   |   87 -
 unotools/qa/complex/tempfile/Test02.java   |   55 ++
 unotools/qa/complex/tempfile/TestHelper.java   |  184 ++---
 unotools/source/ucbhelper/XTempFile.hxx|3 
 unotools/source/ucbhelper/xtempfile.cxx|   42 
 6 files changed, 116 insertions(+), 261 deletions(-)

New commits:
commit 218f36dd614cf828e949f605faaf6a6fd615da26
Author: Noel Grandin 
AuthorDate: Sun Jun 20 18:51:12 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 21 18:37:04 2021 +0200

tdf#135316 remove OTempFileService pessimisation

Closing the temp file when we read to the end, and then opening
it again later actually is quite expensive, just leave it open.

This takes my load time from 22s to 19s

Also clean up the unit-test that failed, so that I can get
a useful stack trace out of it when something fails,
specifically
(*) throw an exception when something goes wrong, instead
of just writing a message to stdout
(*) don't catch exceptions and write useless messages - just
let the exception flow up to the JUnit handler, which will log
a nice stacktrace with line numbers.

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

diff --git a/unotools/qa/complex/tempfile/TempFileUnitTest.java 
b/unotools/qa/complex/tempfile/TempFileUnitTest.java
index 2d23db0dbc1a..c737deaed70a 100644
--- a/unotools/qa/complex/tempfile/TempFileUnitTest.java
+++ b/unotools/qa/complex/tempfile/TempFileUnitTest.java
@@ -46,7 +46,7 @@ public class TempFileUnitTest
 }
 catch ( Exception e )
 {
-fail ( "Cannot get simple file access! Exception: " + e);
+fail ( "Cannot get simple file access!" + e);
 }
 if ( m_xSFA == null ) {
 fail ( "Cannot get simple file access!" );
@@ -58,12 +58,12 @@ public class TempFileUnitTest
 m_xSFA = null;
 }
 
-@Test public void ExecuteTest01() {
+@Test public void ExecuteTest01() throws Exception {
 Test01 aTest = new Test01( m_xMSF, m_xSFA );
 assertTrue( "Test01 failed!", aTest.test() );
 }
 
-@Test public void ExecuteTest02() {
+@Test public void ExecuteTest02() throws Exception {
 Test02 aTest = new Test02( m_xMSF, m_xSFA );
 assertTrue( "Test02 failed!", aTest.test() );
 }
diff --git a/unotools/qa/complex/tempfile/Test01.java 
b/unotools/qa/complex/tempfile/Test01.java
index ed8e729854c8..f93b02186e8d 100644
--- a/unotools/qa/complex/tempfile/Test01.java
+++ b/unotools/qa/complex/tempfile/Test01.java
@@ -34,70 +34,57 @@ public class Test01 {
 m_aTestHelper = new TestHelper( "Test01: ");
 }
 
-public boolean test() {
+public boolean test() throws Exception {
 XTempFile xTempFile = null;
 String sFileURL = null;
 String sFileName = null;
 //create a temporary file.
-try {
-Object oTempFile = m_xMSF.createInstance( 
"com.sun.star.io.TempFile" );
-xTempFile = UnoRuntime.queryInterface(XTempFile.class, oTempFile);
-m_aTestHelper.Message( "Tempfile created." );
-UnoRuntime.queryInterface(XTruncate.class, oTempFile);
-} catch( Exception e ) {
-m_aTestHelper.Error( "Cannot create TempFile. exception: " + e );
-return false;
-}
+Object oTempFile = m_xMSF.createInstance( "com.sun.star.io.TempFile" );
+xTempFile = UnoRuntime.queryInterface(XTempFile.class, oTempFile);
+m_aTestHelper.Message( "Tempfile created." );
+UnoRuntime.queryInterface(XTruncate.class, oTempFile);
 
 //retrieve the tempfile URL
-if ( xTempFile == null ) {
-m_aTestHelper.Error( "Cannot get XTempFile interface." );
-return false;
-}
+if ( xTempFile == null )
+throw new java.lang.Exception( "Cannot get XTempFile interface." );
 
-try {
-//compare the file name with the name in the URL.
-sFileURL = m_aTestHelper.GetTempFileURL( xTempFile );
-sFileName = m_aTestHelper.GetTempFileName( xTempFile );
-m_aTestHelper.CompareFileNameAndURL( sFileName, sFileURL );
+//compare the file name with the name in the URL.
+sFileURL = m_aTestHelper.GetTempFileURL( xTempFile );
+sFileName = m_aTestHelper.GetTempFileName( xTempFile );
+m_aTestHelper.CompareFileNameAndURL( sFileName, sFileURL );
 
-//write to the stream using the service.
-byte pBytesIn[] = new byte[9];
-byte pBytesOut1[][] = new byte [1][9];
-byte pBytesOut2[][] = new byte [1][9];
-Random oRandom = new Random();
- 

[Libreoffice-commits] core.git: unotools/qa unotools/source vcl/generic

2015-01-26 Thread Caolán McNamara
 unotools/qa/unit/testGetEnglishSearchName.cxx |7 +++
 unotools/source/misc/fontdefs.cxx |2 --
 vcl/generic/fontmanager/fontcache.cxx |2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 15e1c881684c0127c0ca989924bbf2508b4fd780
Author: Caolán McNamara caol...@redhat.com
Date:   Mon Jan 26 15:00:29 2015 +

don't strip font names of apparent script suffixes anymore

e.g. CM Roman CE should be left alone.

bump font cache id to invalidate old cached lists

I think this practice stems from Window 3.1/Word 95 where the encoding was
included in the font name
http://www.webcenter.ru/~kazarn/eng/fonts_ttf.htm#charsettbl Microsoft 
Office
still generates RTF files with weird-ass Win 3.1 style fontnames but any 
actual
existing fonts that happen to have names that fall into that pattern should 
be
left alone now.

Change-Id: Ibb704048d63b33ce510d6b1076700c6e94a0af2a

diff --git a/unotools/qa/unit/testGetEnglishSearchName.cxx 
b/unotools/qa/unit/testGetEnglishSearchName.cxx
index dbc8b17..c9d8e1f 100644
--- a/unotools/qa/unit/testGetEnglishSearchName.cxx
+++ b/unotools/qa/unit/testGetEnglishSearchName.cxx
@@ -39,12 +39,11 @@ void Test::testSingleElement()
 //trailingWhitespaces
 test1 = GetEnglishSearchFontName( Symbol );
 CPPUNIT_ASSERT_EQUAL(OUString(symbol),test1);
-//removing Skripts
+//no longer remove script suffixes
 test1 = GetEnglishSearchFontName( Symbol(SIP) );
 CPPUNIT_ASSERT_EQUAL(OUString(symbol(sip)),test1);
-//remove Whitespaces between
-test1 = GetEnglishSearchFontName( Symbol (thai) );
-CPPUNIT_ASSERT_EQUAL( OUString(symbol),test1);
+test1 = GetEnglishSearchFontName( CM Roman CE );
+CPPUNIT_ASSERT_EQUAL( OUString(cmromance),test1);
 //remove special characters; leave semicolon, numbers
 test1 = GetEnglishSearchFontName( sy;mb?=ol129 );
 CPPUNIT_ASSERT_EQUAL( OUString(sy;mbol129),test1);
diff --git a/unotools/source/misc/fontdefs.cxx 
b/unotools/source/misc/fontdefs.cxx
index f368cc6..04c6fc4 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -367,8 +367,6 @@ OUString GetEnglishSearchFontName(const OUString rInName)
 if ( i != nLen )
  rName.truncate(i);
 
-// Remove Script at the end
-rName = StripScriptFromName(rName.toString());
 nLen = rName.getLength();
 
 // remove all whitespaces and converts to lower case ASCII
diff --git a/vcl/generic/fontmanager/fontcache.cxx 
b/vcl/generic/fontmanager/fontcache.cxx
index 56a15bf..e978eb7 100644
--- a/vcl/generic/fontmanager/fontcache.cxx
+++ b/vcl/generic/fontmanager/fontcache.cxx
@@ -38,7 +38,7 @@
 #endif
 
 #define FONTCACHEFILE /user/psprint/pspfontcache
-#define CACHE_MAGIC LibreOffice PspFontCacheFile format 5
+#define CACHE_MAGIC LibreOffice PspFontCacheFile format 6
 
 using namespace std;
 using namespace psp;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-10-20 Thread Caolán McNamara
 unotools/qa/unit/testGetEnlishSearchName.cxx |6 +++---
 unotools/source/misc/fontdefs.cxx|2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit d89a2aaaeb7c4afdb70978e5cb54443119e3ee45
Author: Caolán McNamara caol...@redhat.com
Date:   Mon Oct 20 15:32:18 2014 +0100

fix font tests

Change-Id: I2738ea2a5c6714d8e43c06aa2eb4c53500a5afe9

diff --git a/unotools/qa/unit/testGetEnlishSearchName.cxx 
b/unotools/qa/unit/testGetEnlishSearchName.cxx
index 06ffcef..dbc8b17 100644
--- a/unotools/qa/unit/testGetEnlishSearchName.cxx
+++ b/unotools/qa/unit/testGetEnlishSearchName.cxx
@@ -40,10 +40,10 @@ void Test::testSingleElement()
 test1 = GetEnglishSearchFontName( Symbol );
 CPPUNIT_ASSERT_EQUAL(OUString(symbol),test1);
 //removing Skripts
-test1 = GetEnglishSearchFontName( Symbol(skript) );
-CPPUNIT_ASSERT_EQUAL(OUString(symbol),test1);
+test1 = GetEnglishSearchFontName( Symbol(SIP) );
+CPPUNIT_ASSERT_EQUAL(OUString(symbol(sip)),test1);
 //remove Whitespaces between
-test1 = GetEnglishSearchFontName( Symbol (skript) );
+test1 = GetEnglishSearchFontName( Symbol (thai) );
 CPPUNIT_ASSERT_EQUAL( OUString(symbol),test1);
 //remove special characters; leave semicolon, numbers
 test1 = GetEnglishSearchFontName( sy;mb?=ol129 );
diff --git a/unotools/source/misc/fontdefs.cxx 
b/unotools/source/misc/fontdefs.cxx
index cac720f..79f2821 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -406,7 +406,7 @@ OUString GetEnglishSearchFontName(const OUString rInName)
 c += 'a' - 'A';
 rName[ i ] = c;
 }
-else if( ((c  '0') || (c  '9'))  (c != ';') ) // not 0-9 or 
semicolon
+else if( ((c  '0') || (c  '9'))  (c != ';')  (c != '(')  
(c != ')') ) // not 0-9, semicolon, or brackets
 {
 // Remove white spaces and special characters
 rName.remove(i,1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits