core.git: include/tools tools/source

2024-04-16 Thread Mike Kaganski (via logerrit)
 include/tools/XmlWriter.hxx|7 +--
 tools/source/xml/XmlWriter.cxx |   13 -
 2 files changed, 5 insertions(+), 15 deletions(-)

New commits:
commit 96f62b48b4425f0bc2b6d8497782694078d968fc
Author: Mike Kaganski 
AuthorDate: Mon Apr 15 08:19:25 2024 +0100
Commit: Mike Kaganski 
CommitDate: Wed Apr 17 06:40:40 2024 +0200

Simplify a bit

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

diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx
index 03cc151b2624..9c8f82a86f42 100644
--- a/include/tools/XmlWriter.hxx
+++ b/include/tools/XmlWriter.hxx
@@ -48,12 +48,15 @@ public:
 void endDocument();
 
 void startElement(const char* sName);
-void startElement(const OString& sName);
+void startElement(const OString& sName) { startElement(sName.getStr()); }
 void startElement(const OString& sPrefix, const OString& sName, const 
OString& sNamespaceUri);
 void endElement();
 
 void attribute(const char* sTagName, const OString& aValue);
-void attribute(const OString& sTagName, const OString& aValue);
+void attribute(const OString& sTagName, const OString& aValue)
+{
+attribute(sTagName.getStr(), aValue);
+}
 void attribute(const char* sTagName, std::u16string_view aValue);
 void attribute(const char* sTagName, sal_Int64 aNumber);
 template 
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index f49c312bd133..8bbd7951a3b8 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -99,12 +99,6 @@ void XmlWriter::startElement(const char* pName)
 (void)xmlTextWriterStartElement(mpImpl->mpWriter, xmlName);
 }
 
-void XmlWriter::startElement(const OString& rName)
-{
-xmlChar* xmlName = BAD_CAST(rName.getStr());
-(void)xmlTextWriterStartElement(mpImpl->mpWriter, xmlName);
-}
-
 void XmlWriter::endElement() { 
(void)xmlTextWriterEndElement(mpImpl->mpWriter); }
 
 void XmlWriter::attributeBase64(const char* pName, std::vector 
const& rValueInBytes)
@@ -128,13 +122,6 @@ void XmlWriter::attribute(const char* name, const OString& 
value)
 (void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
 }
 
-void XmlWriter::attribute(const OString& name, const OString& value)
-{
-xmlChar* xmlName = BAD_CAST(name.getStr());
-xmlChar* xmlValue = BAD_CAST(value.getStr());
-(void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
-}
-
 void XmlWriter::attribute(const char* name, std::u16string_view value)
 {
 attribute(name, OUStringToOString(value, RTL_TEXTENCODING_UTF8));


core.git: include/tools tools/source

2024-03-02 Thread Noel Grandin (via logerrit)
 include/tools/json_writer.hxx |6 +++---
 tools/source/misc/json_writer.cxx |   21 -
 2 files changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 06daf1719ef6dfb5b01d7ff09ce6df4c5c332cd5
Author: Noel Grandin 
AuthorDate: Sat Mar 2 16:47:10 2024 +0200
Commit: Noel Grandin 
CommitDate: Sat Mar 2 20:11:07 2024 +0100

avoid a memcpy when constructing output of tools::JsonWriter

we can store the data in an rtl::OString object and then return
that directly

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

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 9efa358a5e60..eca19a6e736a 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -33,7 +33,7 @@ class TOOLS_DLLPUBLIC JsonWriter
 ~ScopedJsonWriterNode() { mrWriter.endNode(closing); }
 };
 
-char* mpBuffer;
+rtl_String* mpBuffer;
 char* mPos;
 int mSpaceAllocated;
 int mStartNodeCount;
@@ -96,14 +96,14 @@ private:
 inline void addValidationMark()
 {
 #ifndef NDEBUG
-*(mpBuffer + mSpaceAllocated - 1) = JSON_WRITER_DEBUG_MARKER;
+*(mpBuffer->buffer + mSpaceAllocated - 1) = JSON_WRITER_DEBUG_MARKER;
 #endif
 }
 
 inline void validate()
 {
 #ifndef NDEBUG
-unsigned char c = *(mpBuffer + mSpaceAllocated - 1);
+unsigned char c = *(mpBuffer->buffer + mSpaceAllocated - 1);
 assert(c == JSON_WRITER_DEBUG_MARKER);
 #endif
 }
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 86021dfcc5ca..0ffc5cb903f9 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -20,8 +20,8 @@ namespace tools
 constexpr int DEFAULT_BUFFER_SIZE = 2048;
 
 JsonWriter::JsonWriter()
-: mpBuffer(static_cast(malloc(DEFAULT_BUFFER_SIZE)))
-, mPos(mpBuffer)
+: mpBuffer(rtl_string_alloc(DEFAULT_BUFFER_SIZE))
+, mPos(mpBuffer->buffer)
 , mSpaceAllocated(DEFAULT_BUFFER_SIZE)
 , mStartNodeCount(0)
 , mbFirstFieldInNode(true)
@@ -38,7 +38,7 @@ JsonWriter::JsonWriter()
 JsonWriter::~JsonWriter()
 {
 assert(mbClosed && "forgot to extract data?");
-free(mpBuffer);
+rtl_string_release(mpBuffer);
 }
 
 JsonWriter::ScopedJsonWriterNode<'}'> JsonWriter::startNode(std::string_view 
pNodeName)
@@ -291,12 +291,15 @@ void JsonWriter::addCommaBeforeField()
 void JsonWriter::ensureSpace(int noMoreBytesRequired)
 {
 assert(!mbClosed && "already extracted data");
-int currentUsed = mPos - mpBuffer;
+int currentUsed = mPos - mpBuffer->buffer;
 if (currentUsed + noMoreBytesRequired >= mSpaceAllocated)
 {
 auto newSize = (currentUsed + noMoreBytesRequired) * 2;
-mpBuffer = static_cast(realloc(mpBuffer, newSize));
-mPos = mpBuffer + currentUsed;
+rtl_String* pNewBuffer = rtl_string_alloc(newSize);
+memcpy(pNewBuffer->buffer, mpBuffer->buffer, currentUsed);
+rtl_string_release(mpBuffer);
+mpBuffer = pNewBuffer;
+mPos = mpBuffer->buffer + currentUsed;
 mSpaceAllocated = newSize;
 
 addValidationMark();
@@ -339,13 +342,13 @@ OString JsonWriter::finishAndGetAsOString()
 *mPos = 0;
 mbClosed = true;
 
-OString ret(mpBuffer, mPos - mpBuffer);
-return ret;
+mpBuffer->length = mPos - mpBuffer->buffer;
+return mpBuffer;
 }
 
 bool JsonWriter::isDataEquals(std::string_view s) const
 {
-return std::string_view(mpBuffer, static_cast(mPos - mpBuffer)) == 
s;
+return std::string_view(mpBuffer->buffer, static_cast(mPos - 
mpBuffer->buffer)) == s;
 }
 
 } // namespace tools


core.git: include/tools tools/source

2023-12-17 Thread Mike Kaganski (via logerrit)
 include/tools/bigint.hxx|  127 --
 tools/source/generic/bigint.cxx |  500 ++--
 2 files changed, 238 insertions(+), 389 deletions(-)

New commits:
commit bcbc0857bf4bc24b5ea36e445a367cce0a382da4
Author: Mike Kaganski 
AuthorDate: Sun Dec 17 21:11:31 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Dec 17 22:34:02 2023 +0100

Simplify BigInt

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

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index f8f57fc45de7..a880f81c748b 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -23,9 +23,11 @@
 #include 
 
 #include 
+#include 
+#include 
 #include 
 
-#define MAX_DIGITS 8
+#define MAX_DIGITS 4
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC BigInt
 {
@@ -33,21 +35,20 @@ private:
 // we only use one of these two fields at a time
 union {
 sal_Int32   nVal;
-sal_uInt16  nNum[MAX_DIGITS];
+sal_uInt32  nNum[MAX_DIGITS];
 };
-sal_uInt8   nLen: 5;// current length, if 0, data is in 
nVal, otherwise data is in nNum
-boolbIsNeg  : 1;// Is Sign negative?
+sal_uInt8   nLen;// current length, if 0, data is in nVal, 
otherwise data is in nNum
+boolbIsNeg;// Is Sign negative?
 
-TOOLS_DLLPRIVATE void MakeBigInt(BigInt const &);
+TOOLS_DLLPRIVATE BigInt MakeBig() const;
 TOOLS_DLLPRIVATE void Normalize();
-TOOLS_DLLPRIVATE void Mult(BigInt const &, sal_uInt16);
-TOOLS_DLLPRIVATE void Div(sal_uInt16, sal_uInt16 &);
-TOOLS_DLLPRIVATE bool IsLess(BigInt const &) const;
+TOOLS_DLLPRIVATE static BigInt Mult(BigInt const &, sal_uInt32);
+TOOLS_DLLPRIVATE void Div(sal_uInt32, sal_uInt32 &);
+TOOLS_DLLPRIVATE bool ABS_IsLessLong(BigInt const &) const;
 TOOLS_DLLPRIVATE void AddLong(BigInt &, BigInt &);
 TOOLS_DLLPRIVATE void SubLong(BigInt &, BigInt &);
 TOOLS_DLLPRIVATE void MultLong(BigInt const &, BigInt &) const;
-TOOLS_DLLPRIVATE void DivLong(BigInt const &, BigInt &) const;
-TOOLS_DLLPRIVATE void ModLong(BigInt const &, BigInt &) const;
+TOOLS_DLLPRIVATE void DivLong(BigInt const &, BigInt &, BigInt * = 
nullptr) const;
 TOOLS_DLLPRIVATE bool ABS_IsLess(BigInt const &) const;
 
 public:
@@ -65,32 +66,42 @@ public:
 {
 }
 
-#if SAL_TYPES_SIZEOFLONG == 4
-BigInt(int nValue)
-: nVal(nValue)
-, nLen(0)
-, bIsNeg(false)
-{
-}
-#endif
-
 BigInt( double nVal );
 BigInt( sal_uInt32 nVal );
 BigInt( sal_Int64 nVal );
 BigInt( const BigInt& rBigInt );
 BigInt( std::u16string_view rString );
 
+template 
+requires(std::is_integral_v && std::is_signed_v && sizeof(N) <= 
sizeof(sal_Int32))
+BigInt(N val)
+: BigInt(sal_Int32(val))
+{
+}
+
+template 
+requires(std::is_integral_v && std::is_unsigned_v && sizeof(N) 
<= sizeof(sal_uInt32))
+BigInt(N val)
+: BigInt(sal_uInt32(val))
+{
+}
+
+template 
+requires(std::is_integral_v && std::is_signed_v && sizeof(N) == 
sizeof(sal_Int64))
+BigInt(N val)
+: BigInt(sal_Int64(val))
+{
+}
+
 operatorsal_Int16() const;
 operatorsal_uInt16() const;
 operatorsal_Int32() const;
 operatorsal_uInt32() const;
 operatordouble() const;
-#if SAL_TYPES_SIZEOFPOINTER == 8
-operatortools::Long() const;
-#endif
+operatorsal_Int64() const;
 
-boolIsNeg() const;
-boolIsZero() const;
+boolIsNeg() const { return !IsLong() ? bIsNeg : nVal < 0; }
+boolIsZero() const { return IsLong() && nVal == 0; }
 boolIsLong() const { return nLen == 0; }
 
 voidAbs();
@@ -107,20 +118,8 @@ public:
 /* Scale and round value */
 static tools::Long Scale(tools::Long nVal, tools::Long nMult, tools::Long 
nDiv);
 
-friend inline   BigInt operator +( const BigInt& rVal1, const BigInt& 
rVal2 );
-friend inline   BigInt operator -( const BigInt& rVal1, const BigInt& 
rVal2 );
-friend inline   BigInt operator *( const BigInt& rVal1, const BigInt& 
rVal2 );
-friend inline   BigInt operator /( const BigInt& rVal1, const BigInt& 
rVal2 );
-friend inline   BigInt operator %( const BigInt& rVal1, const BigInt& 
rVal2 );
-
 TOOLS_DLLPUBLIC friend  bool operator==( const BigInt& rVal1, 
const BigInt& rVal2 );
-friend inline   bool operator!=( const BigInt& rVal1, const BigInt& rVal2 
);
-TOOLS_DLLPUBLIC friend  bool operator< ( const BigInt& rVal1, 
const BigInt& rVal2 );
-friend inline   bool operator> ( const BigInt& rVal1, const BigInt& rVal2 
);
-friend inline   bool operator<=( const BigInt& 

core.git: include/tools tools/source

2023-12-12 Thread Mike Kaganski (via logerrit)
 include/tools/globname.hxx|   11 ++-
 tools/source/ref/globname.cxx |   21 -
 2 files changed, 6 insertions(+), 26 deletions(-)

New commits:
commit fbefacef9e136d434d5dc788d4e918bb6e3815f4
Author: Mike Kaganski 
AuthorDate: Tue Dec 12 09:37:32 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Dec 12 10:39:41 2023 +0100

Simplify and fix SvGlobalName comparison

Its operator< (required for stl containers) was not comparing Data4.
The defaulted comparison uses a different order, but that shouldn't
matter.

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

diff --git a/include/tools/globname.hxx b/include/tools/globname.hxx
index d72b6bf1ab51..7812a83f5735 100644
--- a/include/tools/globname.hxx
+++ b/include/tools/globname.hxx
@@ -22,12 +22,16 @@
 #include 
 #include 
 
+#include 
+
 struct SAL_WARN_UNUSED SvGUID
 {
 sal_uInt32 Data1;
 sal_uInt16 Data2;
 sal_uInt16 Data3;
 sal_uInt8  Data4[8];
+friend constexpr auto operator<=>(const SvGUID&, const SvGUID&) = default;
+friend constexpr bool operator==(const SvGUID&, const SvGUID&) = default;
 };
 
 class SvStream;
@@ -52,11 +56,8 @@ public:
 TOOLS_DLLPUBLIC friend SvStream & operator >> ( SvStream &, SvGlobalName & 
);
 TOOLS_DLLPUBLIC friend SvStream & WriteSvGlobalName( SvStream &, const 
SvGlobalName & );
 
-bool  operator < ( const SvGlobalName & rObj ) const;
-
-bool  operator == ( const SvGlobalName & rObj ) const;
-bool  operator != ( const SvGlobalName & rObj ) const
-  { return !(*this == rObj); }
+friend constexpr auto operator<=>(const SvGlobalName&, const 
SvGlobalName&) = default;
+friend constexpr bool operator==(const SvGlobalName&, const SvGlobalName&) 
= default;
 
 void  MakeFromMemory( void const * pData );
 bool  MakeId( std::u16string_view rId );
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index e5cee830df22..4ae220659e3c 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -59,27 +59,6 @@ SvStream& operator >> ( SvStream& rStr, SvGlobalName & rObj )
 return rStr;
 }
 
-
-bool SvGlobalName::operator < ( const SvGlobalName & rObj ) const
-{
-if( m_aData.Data3 < rObj.m_aData.Data3 )
-return true;
-else if( m_aData.Data3 > rObj.m_aData.Data3 )
-return false;
-
-if( m_aData.Data2 < rObj.m_aData.Data2 )
-return true;
-else if( m_aData.Data2 > rObj.m_aData.Data2 )
-return false;
-
-return m_aData.Data1 < rObj.m_aData.Data1;
-}
-
-bool SvGlobalName::operator == ( const SvGlobalName & rObj ) const
-{
-return memcmp(_aData, _aData, sizeof(m_aData)) == 0;
-}
-
 void SvGlobalName::MakeFromMemory( void const * pData )
 {
 memcpy( _aData, pData, sizeof( m_aData ) );


core.git: include/tools tools/source

2023-12-11 Thread Mike Kaganski (via logerrit)
 include/tools/globname.hxx|   21 +
 tools/source/ref/globname.cxx |   11 ---
 2 files changed, 17 insertions(+), 15 deletions(-)

New commits:
commit 70153b7350fbd0c12a63e879a93a443672061044
Author: Mike Kaganski 
AuthorDate: Mon Dec 11 17:47:43 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Dec 12 08:54:59 2023 +0100

Make some SvGlobalName ctors constexpr

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

diff --git a/include/tools/globname.hxx b/include/tools/globname.hxx
index 50c3fc27b923..d72b6bf1ab51 100644
--- a/include/tools/globname.hxx
+++ b/include/tools/globname.hxx
@@ -35,17 +35,17 @@ class SvStream;
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC SvGlobalName
 {
 public:
-SvGlobalName() = default;
-SvGlobalName(const SvGlobalName& rObj) = default;
+constexpr SvGlobalName() = default;
+constexpr SvGlobalName(const SvGlobalName& rObj) = default;
 
-SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
+inline constexpr SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
   sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
   sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 );
 
 // create SvGlobalName from a platform independent representation
 SvGlobalName( const css::uno::Sequence< sal_Int8 >& aSeq );
 
-SvGlobalName( const SvGUID & rId );
+inline constexpr SvGlobalName( const SvGUID & rId );
 
 SvGlobalName & operator = ( const SvGlobalName & rObj ) = default;
 
@@ -72,6 +72,19 @@ private:
 SvGUID m_aData = {};
 };
 
+inline constexpr SvGlobalName::SvGlobalName(const SvGUID& rId)
+: m_aData(rId)
+{
+}
+
+inline constexpr SvGlobalName::SvGlobalName(sal_uInt32 n1, sal_uInt16 n2, 
sal_uInt16 n3,
+sal_uInt8 b8, sal_uInt8 b9, 
sal_uInt8 b10,
+sal_uInt8 b11, sal_uInt8 b12, 
sal_uInt8 b13,
+sal_uInt8 b14, sal_uInt8 b15)
+: m_aData{ n1, n2, n3, { b8, b9, b10, b11, b12, b13, b14, b15 } }
+{
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index df8ff10943ea..e5cee830df22 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -27,17 +27,6 @@
 #include 
 
 // SvGlobalName 

-SvGlobalName::SvGlobalName( const SvGUID & rId ) :
-m_aData( rId )
-{
-}
-
-SvGlobalName::SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
-sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, 
sal_uInt8 b11,
-sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, 
sal_uInt8 b15 ) :
-m_aData{ n1, n2, n3, { b8, b9, b10, b11, b12, b13, b14, b15 } }
-{
-}
 
 SvGlobalName::SvGlobalName( const css::uno::Sequence < sal_Int8 >& aSeq )
 {


core.git: include/tools tools/source

2023-12-10 Thread Mike Kaganski (via logerrit)
 include/tools/stream.hxx   |2 +-
 tools/source/stream/stream.cxx |   14 +++---
 2 files changed, 4 insertions(+), 12 deletions(-)

New commits:
commit d88d113c7de2681a0e88c276adc363c8f5a4ea8e
Author: Mike Kaganski 
AuthorDate: Sun Dec 10 15:20:39 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Dec 10 17:08:06 2023 +0100

Simplify SvStream::WriteDouble

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index d3e741bbd016..a6349c0be066 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -259,7 +259,7 @@ public:
 SvStream&   WriteChar( char nChar );
 SvStream&   WriteUChar( unsigned char nChar );
 SvStream&   WriteFloat( float nFloat );
-SvStream&   WriteDouble( const double& rDouble );
+SvStream&   WriteDouble( double nDouble );
 
 template 
 SvStream&   WriteNumberAsString( N n ) { return 
WriteOString(OString::number(n)); }
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f5ddabac548d..b948c12847c6 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1029,21 +1029,13 @@ SvStream& SvStream::WriteFloat( float v )
 return *this;
 }
 
-SvStream& SvStream::WriteDouble ( const double& r )
+SvStream& SvStream::WriteDouble ( double v )
 {
 #if defined UNX
 if (m_isSwap)
-{
-  double nHelp = r;
-  SwapDouble(nHelp);
-  writeNumberWithoutSwap(nHelp);
-  return *this;
-}
-else
+SwapDouble(v);
 #endif
-{
-writeNumberWithoutSwap(r);
-}
+writeNumberWithoutSwap(v);
 return *this;
 }
 


[Libreoffice-commits] core.git: include/tools tools/source

2023-08-03 Thread Eike Rathke (via logerrit)
 include/tools/duration.hxx |   13 +++--
 tools/source/datetime/duration.cxx |   25 ++---
 2 files changed, 25 insertions(+), 13 deletions(-)

New commits:
commit 46e672db8002e7aaac881bee65b5c50c4e14c666
Author: Eike Rathke 
AuthorDate: Thu Aug 3 20:52:43 2023 +0200
Commit: Eike Rathke 
CommitDate: Thu Aug 3 21:42:53 2023 +0200

Resolves: tdf#127334 Increase tools::Duration accuracy epsilon unsharpness

... when converting from double, i.e. to 300 nanoseconds.
Empirically determined..

Change-Id: I92c43b5f244923363af5d44bece9c155126ca343
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155324
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/include/tools/duration.hxx b/include/tools/duration.hxx
index ea33953751b8..9fae80d1d7c9 100644
--- a/include/tools/duration.hxx
+++ b/include/tools/duration.hxx
@@ -31,8 +31,17 @@ public:
 minutes and seconds values here though. */
 Duration(const Time& rStart, const Time& rEnd);
 
-/** Difference in days, like DateTime()-DateTime(). */
-explicit Duration(double fTimeInDays);
+/** Difference in days, like DateTime()-DateTime().
+
+@param  nAccuracyEpsilonNanoseconds
+Round for example by 1 nanosecond if it's just 1 off to a
+second,  i.e. 09 or 01. This can be loosened if
+necessary. For example, if fTimeInDays is a date+time in
+"today's" range with a significant seconds resolution, an
+accuracy epsilon (=unsharpness) of ~300 is required. Hence 
default.
+Must be 0 <= nAccuracyEpsilonNanoseconds <= 
Time::nanoSecPerSec - 1.
+ */
+explicit Duration(double fTimeInDays, sal_uInt64 
nAccuracyEpsilonNanoseconds = 300);
 
 /** Time can be a limited duration as well and can have out-of-range
 values, it will be normalized. Sign of both days and Time must be equal
diff --git a/tools/source/datetime/duration.cxx 
b/tools/source/datetime/duration.cxx
index a7b2762fff49..a655f016a1bc 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -47,8 +47,9 @@ Duration::Duration(const Time& rStart, const Time& rEnd)
 }
 }
 
-Duration::Duration(double fTimeInDays)
+Duration::Duration(double fTimeInDays, sal_uInt64 nAccuracyEpsilonNanoseconds)
 {
+assert(nAccuracyEpsilonNanoseconds <= Time::nanoSecPerSec - 1);
 double fInt, fFrac;
 if (fTimeInDays < 0.0)
 {
@@ -66,19 +67,21 @@ Duration::Duration(double fTimeInDays)
 fFrac *= Time::nanoSecPerDay;
 fFrac = ::rtl::math::approxFloor(fFrac);
 sal_Int64 nNS = static_cast(fFrac);
-// Round by 1 nanosecond if it's just 1 off to a second, i.e.
-// 09 or 01. This could be loosened to rounding by 2 or
-// such if necessary.
 const sal_Int64 nN = nNS % Time::nanoSecPerSec;
-if (std::abs(nN) == 1)
-nNS -= (nNS < 0) ? -1 : 1;
-else if (std::abs(nN) == Time::nanoSecPerSec - 1)
+if (nN)
 {
-nNS += (nNS < 0) ? -1 : 1;
-if (std::abs(nNS) >= Time::nanoSecPerDay)
+const sal_uInt64 nA = std::abs(nN);
+if (nA <= nAccuracyEpsilonNanoseconds)
+nNS -= (nNS < 0) ? -nN : nN;
+else if (nA >= Time::nanoSecPerSec - nAccuracyEpsilonNanoseconds)
 {
-mnDays += nNS / Time::nanoSecPerDay;
-nNS %= Time::nanoSecPerDay;
+const sal_Int64 nD = Time::nanoSecPerSec - nA;
+nNS += (nNS < 0) ? -nD : nD;
+if (std::abs(nNS) >= Time::nanoSecPerDay)
+{
+mnDays += nNS / Time::nanoSecPerDay;
+nNS %= Time::nanoSecPerDay;
+}
 }
 }
 maTime.MakeTimeFromNS(nNS);


[Libreoffice-commits] core.git: include/tools tools/source

2023-06-21 Thread Eike Rathke (via logerrit)
 include/tools/datetime.hxx |   11 ---
 tools/source/datetime/datetime.cxx |4 ++--
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 9cf4983e7e6db5c2198c61c30b9c77d089105b3a
Author: Eike Rathke 
AuthorDate: Wed Jun 21 14:31:02 2023 +0200
Commit: Eike Rathke 
CommitDate: Wed Jun 21 21:48:12 2023 +0200

Change DateTime friend operator-() to return tools::Duration instead of 
double

Change-Id: Ica69b1a8916c73443d9ec91dd35ed126fcf97151
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153392
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx
index 21cb65921d27..17d2f89a80b6 100644
--- a/include/tools/datetime.hxx
+++ b/include/tools/datetime.hxx
@@ -101,9 +101,14 @@ public:
 { return operator+( rDateTime, -fTimeInDays ); }
 TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, 
const tools::Time& rTime );
 TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, 
const tools::Time& rTime );
-TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, 
const DateTime& rDateTime2 );
-/** Same as friend operator-() to be able to disable operator-() to find
-places where tools::Duration could be used instead. */
+/** Use operator-() if a duration is to be remembered or processed. */
+TOOLS_DLLPUBLIC friend tools::Duration operator -( const DateTime& 
rDateTime1, const DateTime& rDateTime2 );
+/** Use Sub() if the floating point "time in days" value is to be
+processed. This also takes a shortcut for whole days values (equal
+times), and only for times inflicted values uses an intermediary
+tools::Duration for conversion. Note that the resulting floating point
+value neverthless in many cases is not an exact representation down to
+nanoseconds. */
 static  double  Sub( const DateTime& rDateTime1, const DateTime& 
rDateTime2 );
 TOOLS_DLLPUBLIC friend sal_Int64 operator -( const DateTime& rDateTime, 
const Date& rDate )
 { return static_cast(rDateTime) - rDate; }
diff --git a/tools/source/datetime/datetime.cxx 
b/tools/source/datetime/datetime.cxx
index f2e5a0e69c57..6f9dea26c6e8 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -194,9 +194,9 @@ DateTime operator +( const DateTime& rDateTime, double 
fTimeInDays )
 return aDateTime;
 }
 
-double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 )
+tools::Duration operator -( const DateTime& rDateTime1, const DateTime& 
rDateTime2 )
 {
-return DateTime::Sub( rDateTime1, rDateTime2);
+return tools::Duration( rDateTime2, rDateTime1);
 }
 
 // static


[Libreoffice-commits] core.git: include/tools tools/source

2023-06-20 Thread Eike Rathke (via logerrit)
 include/tools/datetime.hxx |3 +++
 tools/source/datetime/datetime.cxx |6 ++
 2 files changed, 9 insertions(+)

New commits:
commit 66da786bdd4588b31755058acf46034c2056215c
Author: Eike Rathke 
AuthorDate: Tue Jun 20 16:05:58 2023 +0200
Commit: Eike Rathke 
CommitDate: Wed Jun 21 02:17:19 2023 +0200

Introduce double DateTime::Sub() as a substitute for friend double 
operator-()

Change-Id: Idb93b3e9b4dcbd09ad7f4253a523fe5be24d0776
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153354
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx
index 2194711dc208..21cb65921d27 100644
--- a/include/tools/datetime.hxx
+++ b/include/tools/datetime.hxx
@@ -102,6 +102,9 @@ public:
 TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, 
const tools::Time& rTime );
 TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, 
const tools::Time& rTime );
 TOOLS_DLLPUBLIC friend double   operator -( const DateTime& rDateTime1, 
const DateTime& rDateTime2 );
+/** Same as friend operator-() to be able to disable operator-() to find
+places where tools::Duration could be used instead. */
+static  double  Sub( const DateTime& rDateTime1, const DateTime& 
rDateTime2 );
 TOOLS_DLLPUBLIC friend sal_Int64 operator -( const DateTime& rDateTime, 
const Date& rDate )
 { return static_cast(rDateTime) - rDate; }
 /** Duration can be negative, so adding it will subtract its value. */
diff --git a/tools/source/datetime/datetime.cxx 
b/tools/source/datetime/datetime.cxx
index bb4c1ff173a5..f2e5a0e69c57 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -195,6 +195,12 @@ DateTime operator +( const DateTime& rDateTime, double 
fTimeInDays )
 }
 
 double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 )
+{
+return DateTime::Sub( rDateTime1, rDateTime2);
+}
+
+// static
+double DateTime::Sub( const DateTime& rDateTime1, const DateTime& rDateTime2 )
 {
 if (static_cast(rDateTime1) != static_cast(rDateTime2))
 {


[Libreoffice-commits] core.git: include/tools tools/source

2023-05-27 Thread Eike Rathke (via logerrit)
 include/tools/datetime.hxx |3 ++
 tools/source/datetime/datetime.cxx |   48 +++--
 2 files changed, 18 insertions(+), 33 deletions(-)

New commits:
commit 7e3ddf1e5aae5e4e956495e3d86a8cbf6e251b5e
Author: Eike Rathke 
AuthorDate: Sat May 27 23:14:30 2023 +0200
Commit: Eike Rathke 
CommitDate: Sun May 28 03:49:55 2023 +0200

Factor out DateTime::NormalizeTimeRemainderAndApply(tools::Time& rTime)

Change-Id: Ie520b10baaeb4c94973c44435c3241e5d2254968
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152345
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx
index 7b78b29bdfc5..dd435e3994ba 100644
--- a/include/tools/datetime.hxx
+++ b/include/tools/datetime.hxx
@@ -83,6 +83,9 @@ public:
 voidAddTime( double fTimeInDays );
 DateTime&   operator +=( const tools::Time& rTime );
 DateTime&   operator -=( const tools::Time& rTime );
+private:
+voidNormalizeTimeRemainderAndApply( tools::Time& rTime );
+public:
 
 TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, 
sal_Int32 nDays );
 TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, 
sal_Int32 nDays );
diff --git a/tools/source/datetime/datetime.cxx 
b/tools/source/datetime/datetime.cxx
index efdb928986c3..47dc0555bc87 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -94,33 +94,37 @@ sal_Int64 DateTime::GetSecFromDateTime( const Date& rDate ) 
const
 }
 }
 
-DateTime& DateTime::operator +=( const tools::Time& rTime )
+void DateTime::NormalizeTimeRemainderAndApply( tools::Time& rTime )
 {
-tools::Time aTime = *this;
-aTime += rTime;
-sal_uInt16 nHours = aTime.GetHour();
-if ( aTime.GetTime() > 0 )
+sal_uInt16 nHours = rTime.GetHour();
+if ( rTime.GetTime() > 0 )
 {
 if (nHours >= 24)
 {
 AddDays( nHours / 24 );
 nHours %= 24;
-aTime.SetHour( nHours );
+rTime.SetHour( nHours );
 }
 }
-else if ( aTime.GetTime() != 0 )
+else if ( rTime.GetTime() != 0 )
 {
 if (nHours >= 24)
 {
 AddDays( -static_cast(nHours) / 24 );
 nHours %= 24;
-aTime.SetHour( nHours );
+rTime.SetHour( nHours );
 }
 Date::operator--();
-aTime = Time( 24, 0, 0 )+aTime;
+rTime = Time( 24, 0, 0 ) + rTime;
 }
-tools::Time::operator=( aTime );
+tools::Time::operator=( rTime );
+}
 
+DateTime& DateTime::operator +=( const tools::Time& rTime )
+{
+tools::Time aTime = *this;
+aTime += rTime;
+NormalizeTimeRemainderAndApply(aTime);
 return *this;
 }
 
@@ -128,29 +132,7 @@ DateTime& DateTime::operator -=( const tools::Time& rTime )
 {
 tools::Time aTime = *this;
 aTime -= rTime;
-sal_uInt16 nHours = aTime.GetHour();
-if ( aTime.GetTime() > 0 )
-{
-if (nHours >= 24)
-{
-AddDays( nHours / 24 );
-nHours %= 24;
-aTime.SetHour( nHours );
-}
-}
-else if ( aTime.GetTime() != 0 )
-{
-if (nHours >= 24)
-{
-AddDays( -static_cast(nHours) / 24 );
-nHours %= 24;
-aTime.SetHour( nHours );
-}
-Date::operator--();
-aTime = Time( 24, 0, 0 )+aTime;
-}
-tools::Time::operator=( aTime );
-
+NormalizeTimeRemainderAndApply(aTime);
 return *this;
 }
 


[Libreoffice-commits] core.git: include/tools tools/source

2023-04-03 Thread Mike Kaganski (via logerrit)
 include/tools/json_writer.hxx |   31 +++---
 tools/source/misc/json_writer.cxx |  183 +-
 2 files changed, 65 insertions(+), 149 deletions(-)

New commits:
commit e8e244d93c02f4d5b58b9a29dd7fc0d69316888a
Author: Mike Kaganski 
AuthorDate: Mon Apr 3 11:21:54 2023 +0300
Commit: Mike Kaganski 
CommitDate: Mon Apr 3 15:25:23 2023 +0200

Simplify JsonWriter a bit

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

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 700e82b9a2c6..d0c057bc63bc 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -47,25 +47,28 @@ public:
 JsonWriter();
 ~JsonWriter();
 
-[[nodiscard]] ScopedJsonWriterNode startNode(const char*);
-[[nodiscard]] ScopedJsonWriterArray startArray(const char*);
+[[nodiscard]] ScopedJsonWriterNode startNode(std::string_view);
+[[nodiscard]] ScopedJsonWriterArray startArray(std::string_view);
 [[nodiscard]] ScopedJsonWriterStruct startStruct();
 
-void put(const char* pPropName, const OUString& rPropValue);
+void put(std::string_view pPropName, const OUString& rPropValue);
 // Assumes utf-8 property value encoding
-void put(const char* pPropName, std::string_view rPropValue);
-void put(const char* pPropName, const char* pPropVal)
+void put(std::string_view pPropName, std::string_view rPropValue);
+void put(std::string_view pPropName, const char* pPropVal)
 {
 put(pPropName, std::string_view(pPropVal));
 }
+template  void put(std::string_view pPropName, const char 
()[N])
+{
+put(pPropName, std::string_view(pPropVal, N));
+}
 
-void put(const char* pPropName, sal_uInt16 nPropVal) { put(pPropName, 
sal_Int64(nPropVal)); }
-void put(const char* pPropName, sal_Int16 nPropVal) { put(pPropName, 
sal_Int64(nPropVal)); }
-void put(const char* pPropName, sal_Int32 nPropVal) { put(pPropName, 
sal_Int64(nPropVal)); }
-void put(const char* pPropName, sal_uInt32 nPropVal) { put(pPropName, 
sal_Int64(nPropVal)); }
-void put(const char* pPropName, sal_Int64);
-void put(const char* pPropName, bool);
-void put(const char* pPropName, double);
+template , int> = 0>
+void put(std::string_view pPropName, N n)
+{
+putLiteral(pPropName, OString::number(n));
+}
+void put(std::string_view pPropName, bool);
 
 void putSimpleValue(const OUString& rPropValue);
 
@@ -79,7 +82,7 @@ public:
 std::string extractAsStdString();
 
 /** returns true if the current JSON data matches the string */
-bool isDataEquals(const std::string&) const;
+bool isDataEquals(std::string_view) const;
 
 private:
 void endNode();
@@ -89,6 +92,8 @@ private:
 void writeEscapedOUString(const OUString& rPropVal);
 std::pair extractDataImpl();
 void ensureSpace(int noMoreBytesRequired);
+void ensureSpaceAndWriteNameColon(std::string_view name, int valSize);
+void putLiteral(std::string_view propName, std::string_view propValue);
 
 // overflow validation in debug mode
 static constexpr unsigned char JSON_WRITER_DEBUG_MARKER = 0xde;
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 3d78f82e08e6..c5e92385904b 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -39,24 +39,13 @@ JsonWriter::~JsonWriter()
 free(mpBuffer);
 }
 
-ScopedJsonWriterNode JsonWriter::startNode(const char* pNodeName)
+ScopedJsonWriterNode JsonWriter::startNode(std::string_view pNodeName)
 {
-auto len = strlen(pNodeName);
-ensureSpace(len + 8);
+putLiteral(pNodeName, "{ ");
 
-addCommaBeforeField();
-
-*mPos = '"';
-++mPos;
-memcpy(mPos, pNodeName, len);
-mPos += len;
-memcpy(mPos, "\": { ", 5);
-mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
 
-validate();
-
 return ScopedJsonWriterNode(*this);
 }
 
@@ -72,24 +61,13 @@ void JsonWriter::endNode()
 validate();
 }
 
-ScopedJsonWriterArray JsonWriter::startArray(const char* pNodeName)
+ScopedJsonWriterArray JsonWriter::startArray(std::string_view pNodeName)
 {
-auto len = strlen(pNodeName);
-ensureSpace(len + 8);
+putLiteral(pNodeName, "[ ");
 
-addCommaBeforeField();
-
-*mPos = '"';
-++mPos;
-memcpy(mPos, pNodeName, len);
-mPos += len;
-memcpy(mPos, "\": [ ", 5);
-mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
 
-validate();
-
 return ScopedJsonWriterArray(*this);
 }
 
@@ -187,6 +165,9 @@ static bool writeEscapedSequence(sal_uInt32 ch, char*& pos)
 
 void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
 {
+*mPos = '"';
+++mPos;
+
 // Convert from UTF-16 to UTF-8 and perform escaping
 sal_Int32 i = 0;
 while (i < 

[Libreoffice-commits] core.git: include/tools tools/source

2023-02-27 Thread Noel Grandin (via logerrit)
 include/tools/stream.hxx|5 ++---
 tools/source/stream/strmunx.cxx |   34 +++---
 tools/source/stream/strmwnt.cxx |   38 +-
 3 files changed, 26 insertions(+), 51 deletions(-)

New commits:
commit 6db64ffb8430d40475721662c77bbc18ac6255fb
Author: Noel Grandin 
AuthorDate: Mon Feb 27 09:35:07 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Feb 27 11:34:07 2023 +

inline StreamData into SvFileStream

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index b141c8ed44f7..4a5f91043021 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -587,12 +587,11 @@ TOOLS_DLLPUBLIC bool isEmptyFileUrl(const OUString& rUrl);
 class TOOLS_DLLPUBLIC SvFileStream final : public SvStream
 {
 private:
-std::unique_ptr
-pInstanceData;
-OUStringaFilename;
+void*   mxFileHandle = nullptr; // on windows, it is a a HANDLE, 
otherwise, it is a oslFileHandle
 #if defined(_WIN32)
 sal_uInt16  nLockCounter;
 #endif
+OUStringaFilename;
 boolbIsOpen;
 
 SvFileStream (const SvFileStream&) = delete;
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 8e145d20b964..c19d5b00b4b2 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -92,16 +92,6 @@ void unlockFile( SvFileStream const * pStream )
 
 }
 
-// StreamData 
--
-
-class StreamData
-{
-public:
-oslFileHandle rHandle;
-
-StreamData() : rHandle( nullptr ) { }
-};
-
 static ErrCode GetSvError( int nErrno )
 {
 static struct { int nErr; ErrCode sv; } const errArr[] =
@@ -198,7 +188,6 @@ SvFileStream::SvFileStream( const OUString& rFileName, 
StreamMode nOpenMode )
 {
 bIsOpen = false;
 m_isWritable= false;
-pInstanceData.reset(new StreamData);
 
 SetBufferSize( 1024 );
 // convert URL to SystemPath, if necessary
@@ -215,7 +204,6 @@ SvFileStream::SvFileStream()
 {
 bIsOpen = false;
 m_isWritable= false;
-pInstanceData.reset(new StreamData);
 SetBufferSize( 1024 );
 }
 
@@ -231,7 +219,7 @@ std::size_t SvFileStream::GetData( void* pData, std::size_t 
nSize )
 sal_uInt64 nRead = 0;
 if ( IsOpen() )
 {
-oslFileError rc = 
osl_readFile(pInstanceData->rHandle,pData,static_cast(nSize),);
+oslFileError rc = 
osl_readFile(mxFileHandle,pData,static_cast(nSize),);
 if ( rc != osl_File_E_None )
 {
 SetError( ::GetSvError( rc ));
@@ -248,7 +236,7 @@ std::size_t SvFileStream::PutData( const void* pData, 
std::size_t nSize )
 sal_uInt64 nWrite = 0;
 if ( IsOpen() )
 {
-oslFileError rc = 
osl_writeFile(pInstanceData->rHandle,pData,static_cast(nSize),);
+oslFileError rc = 
osl_writeFile(mxFileHandle,pData,static_cast(nSize),);
 if ( rc != osl_File_E_None )
 {
 SetError( ::GetSvError( rc ) );
@@ -269,9 +257,9 @@ sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos)
 oslFileError rc;
 sal_uInt64 nNewPos;
 if ( nPos != STREAM_SEEK_TO_END )
-rc = osl_setFilePos( pInstanceData->rHandle, osl_Pos_Absolut, nPos 
);
+rc = osl_setFilePos( mxFileHandle, osl_Pos_Absolut, nPos );
 else
-rc = osl_setFilePos( pInstanceData->rHandle, osl_Pos_End, 0 );
+rc = osl_setFilePos( mxFileHandle, osl_Pos_End, 0 );
 
 if ( rc != osl_File_E_None )
 {
@@ -280,7 +268,7 @@ sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos)
 }
 if ( nPos != STREAM_SEEK_TO_END )
 return nPos;
-osl_getFilePos( pInstanceData->rHandle,  );
+osl_getFilePos( mxFileHandle,  );
 return nNewPos;
 }
 SetError( SVSTREAM_GENERALERROR );
@@ -289,7 +277,7 @@ sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos)
 
 void SvFileStream::FlushData()
 {
-auto rc = osl_syncFile(pInstanceData->rHandle);
+auto rc = osl_syncFile(mxFileHandle);
 if (rc != osl_File_E_None)
 SetError( ::GetSvError( rc ));
  }
@@ -440,7 +428,7 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nOpenMode )
 }
 if ( rc == osl_File_E_None )
 {
-pInstanceData->rHandle = nHandleTmp;
+mxFileHandle = nHandleTmp;
 bIsOpen = true;
 if ( uFlags & osl_File_OpenFlag_Write )
 m_isWritable = true;
@@ -450,7 +438,7 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nOpenMode )
 osl_closeFile( nHandleTmp );
 bIsOpen = false;
 m_isWritable = false;
-pInstanceData->rHandle = nullptr;
+   

[Libreoffice-commits] core.git: include/tools tools/source vcl/source

2022-10-27 Thread Noel Grandin (via logerrit)
 include/tools/fract.hxx|3 +++
 tools/source/generic/fract.cxx |   40 
 vcl/source/outdev/map.cxx  |   32 +---
 3 files changed, 44 insertions(+), 31 deletions(-)

New commits:
commit 551e5943d4bec10c31077f38ccf5d8149c05265c
Author: Noel Grandin 
AuthorDate: Thu Oct 27 08:48:25 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 27 10:58:04 2022 +0200

tdf#123419 optimise ImplMakeFraction

which is very hot here. Push it down into Fraction, where we can skip
the construction of boost::rational intermediate values

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

diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index c844f8eed619..e1305ca8a8fd 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -72,6 +72,9 @@ public:
 
 voidReduceInaccurate( unsigned nSignificantBits );
 
+/// Multiply the two fractions represented here and reduce inaccuracy to 
32-bits, used by vcl
+static Fraction MakeFraction(tools::Long nN1, tools::Long nN2, tools::Long 
nD1, tools::Long nD2);
+
 // Compute value usable as hash.
 size_t GetHashValue() const;
 
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 7f2ffba1003d..b6ae743764df 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -483,4 +483,44 @@ size_t Fraction::GetHashValue() const
 return hash;
 }
 
+Fraction Fraction::MakeFraction( tools::Long nN1, tools::Long nN2, tools::Long 
nD1, tools::Long nD2 )
+{
+if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following 
while loop will be endless
+{
+SAL_WARN("tools.fraction", "Invalid parameter for ImplMakeFraction");
+return Fraction( 1, 1 );
+}
+
+tools::Long i = 1;
+
+if ( nN1 < 0 ) { i = -i; nN1 = -nN1; }
+if ( nN2 < 0 ) { i = -i; nN2 = -nN2; }
+if ( nD1 < 0 ) { i = -i; nD1 = -nD1; }
+if ( nD2 < 0 ) { i = -i; nD2 = -nD2; }
+// all positive; i sign
+
+boost::rational a = toRational(i*nN1, nD1);
+boost::rational b = toRational(nN2, nD2);
+bool bFail = checked_multiply_by(a, b);
+
+
+while ( bFail ) {
+if ( nN1 > nN2 )
+nN1 = (nN1 + 1) / 2;
+else
+nN2 = (nN2 + 1) / 2;
+if ( nD1 > nD2 )
+nD1 = (nD1 + 1) / 2;
+else
+nD2 = (nD2 + 1) / 2;
+
+a = toRational(i*nN1, nD1);
+b = toRational(nN2, nD2);
+bFail = checked_multiply_by(a, b);
+}
+
+rational_ReduceInaccurate(a, /*nSignificantBits*/32);
+return Fraction(a.numerator(), a.denominator());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 2c3801bf9e84..02221c345862 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -44,37 +44,7 @@ ctor fraction once); we could also do this with BigInts
 
 static Fraction ImplMakeFraction( tools::Long nN1, tools::Long nN2, 
tools::Long nD1, tools::Long nD2 )
 {
-if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following 
while loop will be endless
-{
-SAL_WARN("vcl.gdi", "Invalid parameter for ImplMakeFraction");
-return Fraction( 1, 1 );
-}
-
-tools::Long i = 1;
-
-if ( nN1 < 0 ) { i = -i; nN1 = -nN1; }
-if ( nN2 < 0 ) { i = -i; nN2 = -nN2; }
-if ( nD1 < 0 ) { i = -i; nD1 = -nD1; }
-if ( nD2 < 0 ) { i = -i; nD2 = -nD2; }
-// all positive; i sign
-
-Fraction aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
-
-while ( !aF.IsValid() ) {
-if ( nN1 > nN2 )
-nN1 = (nN1 + 1) / 2;
-else
-nN2 = (nN2 + 1) / 2;
-if ( nD1 > nD2 )
-nD1 = (nD1 + 1) / 2;
-else
-nD2 = (nD2 + 1) / 2;
-
-aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
-}
-
-aF.ReduceInaccurate(32);
-return aF;
+return Fraction::MakeFraction(nN1, nN2, nD1, nD2);
 }
 
 static auto setMapRes(ImplMapRes& rMapRes, const o3tl::Length eUnit)


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

2022-10-24 Thread Noel Grandin (via logerrit)
 include/tools/stream.hxx   |5 +++--
 tools/source/stream/strmwnt.cxx|2 ++
 unotools/source/ucbhelper/tempfile.cxx |9 +
 3 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 1ea0ea19f1dc13c4191ab9d4222adfd2579b802c
Author: Noel Grandin 
AuthorDate: Mon Oct 24 09:06:42 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Oct 24 10:10:54 2022 +0200

tdf#133768 speed up temp file creation

Use DELETE_ON_CLOSE attribute, so we can avoid calling osl_removeFile.
Shaves 5% off the export time.

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index c56a3d44cef6..b141c8ed44f7 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -50,8 +50,9 @@ enum class StreamMode {
 // file i/o
 NOCREATE = 0x0004,  ///< 1 == Don't create file
 TRUNC= 0x0008,  ///< Truncate _existing_ file to zero 
length
-COPY_ON_SYMLINK  = 0x0010,  ///< copy-on-write for symlinks (Unix)
+COPY_ON_SYMLINK  = 0x0010,  ///< copy-on-write for symlinks 
(Unix-only)
 TEMPORARY= 0x0020,  ///< temporary file attribute 
(Windows-only)
+DELETE_ON_CLOSE  = 0x0040,  ///< only for temporary files 
(Windows-only)
 // sharing options
 SHARE_DENYNONE   = 0x0100,
 SHARE_DENYREAD   = 0x0200,  // overrides denynone
@@ -65,7 +66,7 @@ enum class StreamMode {
 };
 namespace o3tl
 {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 #define STREAM_SEEK_TO_BEGIN0L
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index 4ea9c7eb1d42..f88cbe307606 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -304,6 +304,8 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nMode )
 
 if ( nMode & StreamMode::TEMPORARY )
 nAttributes |= FILE_ATTRIBUTE_TEMPORARY;
+if ( nMode & StreamMode::DELETE_ON_CLOSE )
+nAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
 
 pInstanceData->hFile = CreateFileW(
 o3tl::toW(aFilename.getStr()),
diff --git a/unotools/source/ucbhelper/tempfile.cxx 
b/unotools/source/ucbhelper/tempfile.cxx
index 61ef2d247c01..efeb872b5d6d 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -409,7 +409,11 @@ SvStream* TempFileFast::GetStream( StreamMode eMode )
 if (!mxStream)
 {
 OUString aName = CreateTempNameFast();
+#ifdef _WIN32
+mxStream.reset(new SvFileStream(aName, eMode | StreamMode::TEMPORARY | 
StreamMode::DELETE_ON_CLOSE));
+#else
 mxStream.reset(new SvFileStream(aName, eMode | StreamMode::TEMPORARY));
+#endif
 }
 return mxStream.get();
 }
@@ -420,8 +424,13 @@ void TempFileFast::CloseStream()
 {
 OUString aName = mxStream->GetFileName();
 mxStream.reset();
+#ifdef _WIN32
+// On Windows, the file is opened with FILE_FLAG_DELETE_ON_CLOSE, so 
it will delete as soon as the handle closes.
+// On other platforms, we need to explicitly delete it.
+#else
 if (!aName.isEmpty() && 
(osl::FileBase::getFileURLFromSystemPath(aName, aName) == 
osl::FileBase::E_None))
 File::remove(aName);
+#endif
 }
 }
 


[Libreoffice-commits] core.git: include/tools tools/source

2022-06-17 Thread Jan-Marek Glogowski (via logerrit)
 include/tools/gen.hxx|   30 +-
 tools/source/generic/gen.cxx |   17 -
 2 files changed, 29 insertions(+), 18 deletions(-)

New commits:
commit 80d801cf07b6583e824ad89c3c750b076118f41d
Author: Jan-Marek Glogowski 
AuthorDate: Tue Jun 14 05:37:30 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jun 17 20:41:28 2022 +0200

Rectangle: split SetSize into SetWidth/SetHeight

... and inline the functions.

Change-Id: I9285c72e8524f8f0a2d242bfd4cd29edf6d1ed73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135811
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 7a8e66e2a6ff..ab8b443ca403 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -537,7 +537,9 @@ public:
 /// Set the top edge of the rectangle to y, preserving the height
 inline void SetPosY(tools::Long y);
 inline void SetPos( const Point& rPoint );
-voidSetSize( const Size& rSize );
+inline void SetWidth(tools::Long);
+inline void SetHeight(tools::Long);
+inline void SetSize(const Size&);
 
 constexpr Point GetPos() const { return TopLeft(); }
 constexpr Size GetSize() const { return { GetWidth(), GetHeight() }; }
@@ -671,6 +673,32 @@ inline void tools::Rectangle::SetPos( const Point& rPoint )
 SetPosY(rPoint.Y());
 }
 
+inline void tools::Rectangle::SetWidth(tools::Long nWidth)
+{
+if (nWidth < 0)
+nRight = nLeft + nWidth + 1;
+else if (nWidth > 0)
+nRight = nLeft + nWidth - 1;
+else
+SetWidthEmpty();
+}
+
+inline void tools::Rectangle::SetHeight(tools::Long nHeight)
+{
+if (nHeight < 0)
+nBottom = nTop + nHeight + 1;
+else if (nHeight > 0)
+nBottom = nTop + nHeight - 1;
+else
+SetHeightEmpty();
+}
+
+inline void tools::Rectangle::SetSize(const Size& rSize)
+{
+SetWidth(rSize.Width());
+SetHeight(rSize.Height());
+}
+
 constexpr inline tools::Long tools::Rectangle::GetWidth() const
 {
 tools::Long n = 0;
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 27120d6abbd1..069b7482cfba 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -42,23 +42,6 @@ size_t Pair::GetHashValue() const
 return hash;
 }
 
-void tools::Rectangle::SetSize( const Size& rSize )
-{
-if ( rSize.Width() < 0 )
-nRight  = nLeft + rSize.Width() +1;
-else if ( rSize.Width() > 0 )
-nRight  = nLeft + rSize.Width() -1;
-else
-SetWidthEmpty();
-
-if ( rSize.Height() < 0 )
-nBottom  = nTop + rSize.Height() +1;
-else if ( rSize.Height() > 0 )
-nBottom  = nTop + rSize.Height() -1;
-else
-SetHeightEmpty();
-}
-
 void tools::Rectangle::SaturatingSetSize(const Size& rSize)
 {
 if (rSize.Width() < 0)


[Libreoffice-commits] core.git: include/tools tools/source

2022-06-12 Thread offtkp (via logerrit)
 include/tools/zcodec.hxx   |   14 +++
 tools/source/zcodec/zcodec.cxx |   52 +++--
 2 files changed, 59 insertions(+), 7 deletions(-)

New commits:
commit 932257c50c1dc9302b14862424e24e975f88bcc2
Author: offtkp 
AuthorDate: Wed Jun 1 02:13:13 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 12 09:29:53 2022 +0200

Add compression support for GZ through ZCodec

ZCodec uses zlib to deflate. That file has code
to allow for compressing to GZ but it's wrapped in defines.

There's places in code where there's need for zlib headers
(ie. svx/source/gallery2/codec.cxx:71) and there will be need
for gz header compression when EMZ/WMZ/SVGZ export support
is added.

Made compression functions care about mbGzLib bool. Also added
a SetCompressionMetadata function to set metadata which are otherwise
impossible to know (such as filename, which is needed in the header)

Change-Id: Ic01050262b0b15e0632564b139c66656afac4611
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135213
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 745d44e9199e..a86dbec70b62 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define ZCODEC_NO_COMPRESSION   0
 #define ZCODEC_DEFAULT_COMPRESSION  6
@@ -31,6 +32,7 @@ class SvStream;
 
 // The overall client call protocol is one of:
 // * BeginCompression, Compress, EndCompression
+// * BeginCompression, SetCompressionMetadata, Compress, EndCompression (for 
gz files)
 // * BeginCompression, Decompress, EndCompression
 // * BeginCompression, Write*, EndCompression
 // * BeginCompression, Read*, EndCompression
@@ -47,6 +49,10 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ZCodec
 SvStream*   mpOStm;
 std::unique_ptr mpOutBuf;
 size_t  mnOutBufSize;
+sal_uInt32  mnUncompressedSize;
+sal_uInt32  mnInBufCRC32;
+sal_uInt32  mnLastModifiedTime;
+OString msFilename;
 
 int mnCompressLevel;
 boolmbGzLib;
@@ -69,6 +75,14 @@ public:
 voidBeginCompression( int nCompressLevel = 
ZCODEC_DEFAULT_COMPRESSION, bool gzLib = false );
 tools::LongEndCompression();
 
+/**
+ * @brief Set metadata for gzlib compression
+ *
+ * @param sFilename the uncompressed file filename
+ * @param nLastModifiedTime the files last modified time in unix format
+ */
+voidSetCompressionMetadata( const OString& sFilename,
+sal_uInt32 nLastModifiedTime, sal_uInt32 
nInBufCRC32 );
 voidCompress( SvStream& rIStm, SvStream& rOStm );
 tools::LongDecompress( SvStream& rIStm, SvStream& rOStm );
 boolAttemptDecompression( SvStream& rIStm, SvStream& rOStm );
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 80daa1507a19..16248939f3d6 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -29,14 +29,15 @@
 #include 
 
 /* gzip flag byte */
-//  GZ_ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
-#define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define GZ_EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
-#define GZ_ORIG_NAME0x08 /* bit 3 set: original file name present */
-#define GZ_COMMENT  0x10 /* bit 4 set: file comment present */
-#define GZ_RESERVED 0xE0 /* bits 5..7: reserved */
-
+//   GZ_ASCII_FLAG = 0x01;   /* bit 0 set: file probably 
ascii text */
+constexpr sal_uInt8  GZ_HEAD_CRC   = 0x02;   /* bit 1 set: header CRC 
present */
+constexpr sal_uInt8  GZ_EXTRA_FIELD= 0x04;   /* bit 2 set: extra field 
present */
+constexpr sal_uInt8  GZ_ORIG_NAME  = 0x08;   /* bit 3 set: original file 
name present */
+constexpr sal_uInt8  GZ_COMMENT= 0x10;   /* bit 4 set: file comment 
present */
+constexpr sal_uInt8  GZ_RESERVED   = 0xE0;   /* bits 5..7: reserved */
 constexpr sal_uInt16 GZ_MAGIC_BYTES_LE = 0x8B1F; /* gzip magic bytes, little 
endian */
+constexpr sal_uInt8  GZ_DEFLATE= 0x08;
+constexpr sal_uInt8  GZ_FS_UNKNOWN = 0xFF;
 
 ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize )
 : meState(STATE_INIT)
@@ -109,6 +110,25 @@ tools::Long ZCodec::EndCompression()
 
 retvalue = pStream->total_in;
 deflateEnd( pStream );
+if ( mbGzLib )
+{
+// metadata must be set to compress as gz format
+assert(!msFilename.isEmpty());
+// overwrite zlib checksum
+mpOStm->Seek(STREAM_SEEK_TO_END);
+mpOStm->SeekRel(-4);
+mpOStm->WriteUInt32( mnInBufCRC32 );   // Uncompressed 
buffer CRC32
+mpOStm->WriteUInt32( 

[Libreoffice-commits] core.git: include/tools tools/source

2022-06-03 Thread Stephan Bergmann (via logerrit)
 include/tools/multisel.hxx |7 +++--
 tools/source/memtools/multisel.cxx |   48 -
 2 files changed, 30 insertions(+), 25 deletions(-)

New commits:
commit 6af99a90d059446d028cb6fe94c7c74140f2ed02
Author: Stephan Bergmann 
AuthorDate: Fri Jun 3 13:44:20 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Jun 3 15:10:12 2022 +0200

Use more appropriate type for MultiSelection::nCurSubSel et al

(In MultiSelection::LastSelected, there is no need to set nCurSubSel (to a
potentially negative value) before setting bCurValid to false, as 
nCurSubSel is
only ever used after checking that bCurValid is true.)

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

diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index a5c68ca0eb23..ea7a1343feeb 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -34,14 +35,14 @@ private:
 std::vector< Range >
 aSels;  // array of SV-selections
 Range   aTotRange;  // total range of indexes
-sal_Int32   nCurSubSel; // index in aSels of current selected index
+std::size_t nCurSubSel; // index in aSels of current selected index
 sal_Int32   nCurIndex;  // current selected entry
 sal_Int32   nSelCount;  // number of selected indexes
 boolbCurValid;  // are nCurIndex and nCurSubSel valid
 
 TOOLS_DLLPRIVATE void   ImplClear();
-TOOLS_DLLPRIVATE sal_Int32  ImplFindSubSelection( sal_Int32 nIndex ) 
const;
-TOOLS_DLLPRIVATE void   ImplMergeSubSelections( sal_Int32 nPos1, 
sal_Int32 nPos2 );
+TOOLS_DLLPRIVATE std::size_tImplFindSubSelection( sal_Int32 nIndex ) 
const;
+TOOLS_DLLPRIVATE void   ImplMergeSubSelections( sal_Int32 nPos1, 
std::size_t nPos2 );
 
 public:
 MultiSelection();
diff --git a/tools/source/memtools/multisel.cxx 
b/tools/source/memtools/multisel.cxx
index c6dd9d8c3146..ff81f6c14ccc 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
+
+#include 
+
 #include 
 #include 
 
@@ -29,20 +33,20 @@ void MultiSelection::ImplClear()
 aSels.clear();
 }
 
-sal_Int32 MultiSelection::ImplFindSubSelection( sal_Int32 nIndex ) const
+std::size_t MultiSelection::ImplFindSubSelection( sal_Int32 nIndex ) const
 {
 // iterate through the sub selections
-sal_Int32 n = 0;
+std::size_t n = 0;
 for ( ;
-  n < sal_Int32(aSels.size()) && nIndex > aSels[ n ].Max();
+  n < aSels.size() && nIndex > aSels[ n ].Max();
   ++n ) {} /* empty loop */
 return n;
 }
 
-void MultiSelection::ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 )
+void MultiSelection::ImplMergeSubSelections( sal_Int32 nPos1, std::size_t 
nPos2 )
 {
 // didn't a sub selection at nPos2 exist?
-if ( nPos2 >= sal_Int32(aSels.size()) )
+if ( nPos2 >= aSels.size() )
 return;
 
 // did the sub selections touch each other?
@@ -141,12 +145,12 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool 
bSelect )
 return false;
 
 // find the virtual target position
-sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
+std::size_t nSubSelPos = ImplFindSubSelection( nIndex );
 
 if ( bSelect )
 {
 // is it included in the found sub selection?
-if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos 
].Contains( nIndex ) )
+if ( nSubSelPos < aSels.size() && aSels[ nSubSelPos ].Contains( nIndex 
) )
 // already selected, nothing to do
 return false;
 
@@ -164,7 +168,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect 
)
 ImplMergeSubSelections( nSubSelPos-1, nSubSelPos );
 }
 // is it at the beginning of the found sub selection
-else if (  nSubSelPos < sal_Int32(aSels.size())
+else if (  nSubSelPos < aSels.size()
 && aSels[ nSubSelPos ].Min() == (nIndex+1)
 )
 // expand the found sub selection
@@ -172,7 +176,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect 
)
 else
 {
 // create a new sub selection
-if ( nSubSelPos < sal_Int32(aSels.size()) ) {
+if ( nSubSelPos < aSels.size() ) {
 aSels.insert( aSels.begin() + nSubSelPos, Range( nIndex, 
nIndex ) );
 } else {
 aSels.push_back( Range( nIndex, nIndex ) );
@@ -184,7 +188,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect 
)
 else
 {
 // is it excluded from the found sub selection?
-if (  

[Libreoffice-commits] core.git: include/tools tools/source

2022-04-28 Thread Noel Grandin (via logerrit)
 include/tools/inetmime.hxx |2 +-
 tools/source/inet/inetmime.cxx |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit e6d60166dbece401d29608d5c9005a882b443baa
Author: Noel Grandin 
AuthorDate: Thu Apr 28 12:57:55 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 28 17:49:28 2022 +0200

use more string_view in tools::INetMIME

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

diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index a3c7de49690c..3c0fe30ffbde 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -180,7 +180,7 @@ public:
 parameters will be modified.
  */
 static sal_Unicode const * scanContentType(
-OUString const & rStr,
+std::u16string_view rStr,
 OUString * pType = nullptr, OUString * pSubType = nullptr,
 INetContentTypeParameterList * pParameters = nullptr);
 
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 85f03cfce3e2..2a57c099c93f 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -1003,11 +1003,11 @@ bool INetMIME::scanUnsigned(const sal_Unicode *& rBegin,
 
 // static
 sal_Unicode const * INetMIME::scanContentType(
-OUString const & rStr, OUString * pType,
+std::u16string_view rStr, OUString * pType,
 OUString * pSubType, INetContentTypeParameterList * pParameters)
 {
-sal_Unicode const * pBegin = rStr.getStr();
-sal_Unicode const * pEnd = pBegin + rStr.getLength();
+sal_Unicode const * pBegin = rStr.data();
+sal_Unicode const * pEnd = pBegin + rStr.size();
 sal_Unicode const * p = skipLinearWhiteSpaceComment(pBegin, pEnd);
 sal_Unicode const * pTypeBegin = p;
 while (p != pEnd && isTokenChar(*p))


[Libreoffice-commits] core.git: include/tools tools/source

2022-04-28 Thread Noel Grandin (via logerrit)
 include/tools/color.hxx|2 +-
 tools/source/generic/color.cxx |   14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 4149201b099487c5b46d7015b0c174dfff1841ec
Author: Noel Grandin 
AuthorDate: Thu Apr 28 11:41:48 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 28 16:08:03 2022 +0200

use more string_view in tools::Color

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

diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 5fcf840edfe6..0cf6e122eb90 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -391,7 +391,7 @@ public:
   * rgb
   * If fails returns Color().
   */
-static Color STRtoRGB(const OUString& colorname);
+static Color STRtoRGB(std::u16string_view colorname);
 
 /** Color space conversion tools
   * @param nHue
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 0493b5250f62..1c740f03df03 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -159,30 +159,30 @@ Color Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, 
sal_uInt16 nBri )
 return Color( cR, cG, cB );
 }
 
-Color Color::STRtoRGB(const OUString& colorname)
+Color Color::STRtoRGB(std::u16string_view colorname)
 {
 Color col;
-if(colorname.isEmpty()) return col;
+if(colorname.empty()) return col;
 
-switch(colorname.getLength()){
+switch(colorname.size()){
 case 7:
-col.mValue = o3tl::toUInt32(colorname.subView(1,6), 16);
+col.mValue = o3tl::toUInt32(colorname.substr(1,6), 16);
 break;
 case 6:
-col.mValue = colorname.toUInt32(16);
+col.mValue = o3tl::toUInt32(colorname, 16);
 break;
 case 4:
 {
 sal_Unicode data[6] = { colorname[1], colorname[1], colorname[2],
  colorname[2], colorname[3], colorname[3] 
};
-col.mValue = OUString(data,6).toUInt32(16);
+col.mValue = o3tl::toUInt32(std::u16string_view(data,6), 16);
 break;
 }
 case 3:
 {
 sal_Unicode data[6] = { colorname[0], colorname[0], colorname[1],
  colorname[1], colorname[2], colorname[2] 
};
-col.mValue = OUString(data,6).toUInt32(16);
+col.mValue = o3tl::toUInt32(std::u16string_view(data,6), 16);
 break;
 }
 default:


[Libreoffice-commits] core.git: include/tools tools/source

2022-03-11 Thread Noel Grandin (via logerrit)
 include/tools/wldcrd.hxx |2 +-
 tools/source/fsys/wldcrd.cxx |   38 +-
 2 files changed, 22 insertions(+), 18 deletions(-)

New commits:
commit a378ac93e1b4e3c0dacdd3f0a3500813714537c7
Author: Noel Grandin 
AuthorDate: Fri Mar 11 19:18:25 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Mar 12 08:41:25 2022 +0100

tdf#147921 Filesave DOC: wrong layout and then all missing from 7.3

regression from
commit 990b2cb056788f7f412656a303456d90c003cf83
Author: Noel Grandin 
Date:   Mon Jun 21 13:00:07 2021 +0200
simplify and improve Wildcard

Cannot pass a string_view into something expecting a char* because
then it gets the length wrong.

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

diff --git a/include/tools/wldcrd.hxx b/include/tools/wldcrd.hxx
index fdbefcc4d2ea..5c18ad20fc68 100644
--- a/include/tools/wldcrd.hxx
+++ b/include/tools/wldcrd.hxx
@@ -32,7 +32,7 @@ private:
 OUString aWildString;
 char cSepSymbol;
 
-static bool ImpMatch( const sal_Unicode *pWild, const sal_Unicode *pStr );
+static bool ImpMatch( std::u16string_view aWild, std::u16string_view aStr 
);
 
 public:
 WildCard()
diff --git a/tools/source/fsys/wldcrd.cxx b/tools/source/fsys/wldcrd.cxx
index 6e0259696aca..a9867c00ba51 100644
--- a/tools/source/fsys/wldcrd.cxx
+++ b/tools/source/fsys/wldcrd.cxx
@@ -25,22 +25,26 @@
  * '?' in pWild mean match exactly one character.
  *
  */
-bool WildCard::ImpMatch( const sal_Unicode *pWild, const sal_Unicode *pStr )
+bool WildCard::ImpMatch( std::u16string_view aWild, std::u16string_view aStr )
 {
 intpos=0;
 intflag=0;
+const sal_Unicode* pWild = aWild.data();
+const sal_Unicode* pWildEnd = aWild.data() + aWild.size();
+const sal_Unicode* pStr = aStr.data();
+const sal_Unicode* pStrEnd = aStr.data() + aStr.size();
 
-while ( *pWild || flag )
+while ( pWild != pWildEnd || flag )
 {
 switch (*pWild)
 {
 case '?':
-if ( *pStr == '\0' )
+if ( pStr == pStrEnd )
 return false;
 break;
 
 default:
-if ( (*pWild == '\\') && ((*(pWild+1)=='?') || (*(pWild+1) == 
'*')) )
+if ( (*pWild == '\\') && (pWild + 1 != pWildEnd) && 
((*(pWild+1)=='?') || (*(pWild+1) == '*')) )
 pWild++;
 if ( *pWild != *pStr )
 if ( !pos )
@@ -53,37 +57,37 @@ bool WildCard::ImpMatch( const sal_Unicode *pWild, const 
sal_Unicode *pStr )
 // circumstances!
 [[fallthrough]];
 case '*':
-while ( *pWild == '*' )
+while ( pWild != pWildEnd && *pWild == '*' )
 pWild++;
-if ( *pWild == '\0' )
+if ( pWild == pWildEnd )
 return true;
 flag = 1;
 pos  = 0;
-if ( *pStr == '\0' )
-return ( *pWild == '\0' );
-while ( *pStr && *pStr != *pWild )
+if ( pStr == pStrEnd )
+return false;
+while ( pStr != pStrEnd && *pStr != *pWild )
 {
 if ( *pWild == '?' ) {
 pWild++;
-while ( *pWild == '*' )
+while ( pWild != pWildEnd && *pWild == '*' )
 pWild++;
 }
 pStr++;
-if ( *pStr == '\0' )
-return ( *pWild == '\0' );
+if ( pStr == pStrEnd )
+return pWild == pWildEnd;
 }
 break;
 }
-if ( *pWild != '\0' )
+if ( pWild != pWildEnd )
 pWild++;
-if ( *pStr != '\0' )
+if ( pStr != pStrEnd )
 pStr++;
 else
 flag = 0;
 if ( flag )
 pos--;
 }
-return ( *pStr == '\0' ) && ( *pWild == '\0' );
+return ( pStr == pStrEnd ) && ( pWild == pWildEnd );
 }
 
 bool WildCard::Matches( std::u16string_view rString ) const
@@ -97,13 +101,13 @@ bool WildCard::Matches( std::u16string_view rString ) const
 while ( (nSepPos = aTmpWild.indexOf(cSepSymbol)) != -1 )
 {
 // Check all split wildcards
-if ( ImpMatch( aTmpWild.subView( 0, nSepPos ).data(), 
rString.data() ) )
+if ( ImpMatch( aTmpWild.subView( 0, nSepPos ), rString ) )
 return true;
 aTmpWild = aTmpWild.copy(nSepPos + 1); // remove separator
 }
 }
 
-return ImpMatch( aTmpWild.getStr(), rString.data() );
+return ImpMatch( aTmpWild, rString );
 }
 
 /* vim:set 

[Libreoffice-commits] core.git: include/tools tools/source

2022-02-24 Thread Caolán McNamara (via logerrit)
 include/tools/stream.hxx   |1 -
 tools/source/stream/stream.cxx |6 --
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 50fa3055ad53f9e1f93c90e2119261dc6fa879a2
Author: Caolán McNamara 
AuthorDate: Thu Feb 24 09:49:44 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Feb 24 13:06:40 2022 +0100

cid#1500555 try -taint_source function annotation tag on function body

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index cb3d7c7de804..9c9591a86355 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -454,7 +454,6 @@ inline OUString read_uInt8s_ToOUString(SvStream& rStrm,
 
 /// Attempt to read nUnits 16bit units to an OUString, returned
 /// OUString's length is number of units successfully read
-// coverity[ -taint_source ]
 TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream& rStrm,
 std::size_t nUnits);
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 43cdf4eae459..62c9be957c83 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1787,7 +1787,8 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize)
 ReAllocateMemory( nDiff );
 }
 
-//Create an OString of nLen bytes from rStream
+// Create an OString of nLen bytes from rStream
+// coverity[ -taint_source ]
 OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen)
 {
 rtl_String *pStr = nullptr;
@@ -1818,7 +1819,8 @@ OString read_uInt8s_ToOString(SvStream& rStrm, 
std::size_t nLen)
 return pStr ? OString(pStr, SAL_NO_ACQUIRE) : OString();
 }
 
-//Create an OUString of nLen sal_Unicode code units from rStream
+// Create an OUString of nLen sal_Unicode code units from rStream
+// coverity[ -taint_source ]
 OUString read_uInt16s_ToOUString(SvStream& rStrm, std::size_t nLen)
 {
 rtl_uString *pStr = nullptr;


[Libreoffice-commits] core.git: include/tools tools/source

2022-02-23 Thread Caolán McNamara (via logerrit)
 include/tools/stream.hxx   |1 +
 tools/source/stream/stream.cxx |1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d4ec94c90a195a34e19f8a7af48424a14f7cf227
Author: Caolán McNamara 
AuthorDate: Wed Feb 23 11:13:59 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 23 14:56:32 2022 +0100

cid#1500555 try -taint_source function annotation tag

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 9c9591a86355..cb3d7c7de804 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -454,6 +454,7 @@ inline OUString read_uInt8s_ToOUString(SvStream& rStrm,
 
 /// Attempt to read nUnits 16bit units to an OUString, returned
 /// OUString's length is number of units successfully read
+// coverity[ -taint_source ]
 TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream& rStrm,
 std::size_t nUnits);
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index c567aad82d36..43cdf4eae459 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1851,7 +1851,6 @@ OUString read_uInt16s_ToOUString(SvStream& rStrm, 
std::size_t nLen)
 }
 
 // take ownership of buffer and return, otherwise return empty string
-// coverity[return_tainted_data : SUPPRESS] - we consider the string 
untainted at this point
 return pStr ? OUString(pStr, SAL_NO_ACQUIRE) : OUString();
 }
 


[Libreoffice-commits] core.git: include/tools tools/source

2022-02-08 Thread Mike Kaganski (via logerrit)
 include/tools/globname.hxx|   40 +
 tools/source/ref/globname.cxx |  177 +++---
 2 files changed, 55 insertions(+), 162 deletions(-)

New commits:
commit 4e0ba699ab3ba0294acd2589507b50fab82c98f5
Author: Mike Kaganski 
AuthorDate: Tue Feb 8 18:21:22 2022 +0300
Commit: Mike Kaganski 
CommitDate: Wed Feb 9 06:11:39 2022 +0100

Simplify SvGlobalName

Its data only takes 16 bytes, the same as std::string_view on 64-bit
platforms, which is considered trivial. No need to use cow_wrapper
that would itself take 8 bytes, and have the performance penalty.

Also reuse the conversion to sequence from comphelper.

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

diff --git a/include/tools/globname.hxx b/include/tools/globname.hxx
index 88a5e492d923..8ff2a8b28220 100644
--- a/include/tools/globname.hxx
+++ b/include/tools/globname.hxx
@@ -21,7 +21,6 @@
 
 #include 
 #include 
-#include 
 
 struct SAL_WARN_UNUSED SvGUID
 {
@@ -31,39 +30,13 @@ struct SAL_WARN_UNUSED SvGUID
 sal_uInt8  Data4[8];
 };
 
-struct SAL_WARN_UNUSED ImpSvGlobalName
-{
-struct SvGUID   szData = {};
-
-ImpSvGlobalName(const SvGUID )
-: szData(rData)
-{
-}
-ImpSvGlobalName(sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
-  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
-  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15);
-ImpSvGlobalName( const ImpSvGlobalName & rObj );
-ImpSvGlobalName() = default;
-
-booloperator == ( const ImpSvGlobalName & rObj ) const;
-};
-
 class SvStream;
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC SvGlobalName
 {
-::o3tl::cow_wrapper< ImpSvGlobalName > pImp;
-
 public:
-SvGlobalName();
-SvGlobalName( const SvGlobalName & rObj ) :
-pImp( rObj.pImp )
-{
-}
-SvGlobalName( SvGlobalName && rObj ) noexcept :
-pImp( std::move(rObj.pImp) )
-{
-}
+SvGlobalName() = default;
+SvGlobalName(const SvGlobalName& rObj) = default;
 
 SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
   sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
@@ -74,9 +47,7 @@ public:
 
 SvGlobalName( const SvGUID & rId );
 
-SvGlobalName & operator = ( const SvGlobalName & rObj );
-SvGlobalName & operator = ( SvGlobalName && rObj ) noexcept;
-~SvGlobalName();
+SvGlobalName & operator = ( const SvGlobalName & rObj ) = default;
 
 TOOLS_DLLPUBLIC friend SvStream & operator >> ( SvStream &, SvGlobalName & 
);
 TOOLS_DLLPUBLIC friend SvStream & WriteSvGlobalName( SvStream &, const 
SvGlobalName & );
@@ -91,11 +62,14 @@ public:
 bool  MakeId( const OUString & rId );
 OUString  GetHexName() const;
 
-const SvGUID& GetCLSID() const { return pImp->szData; }
+const SvGUID& GetCLSID() const { return m_aData; }
 
 // platform independent representation of a "GlobalName"
 // maybe transported remotely
 css::uno::Sequence < sal_Int8 > GetByteSequence() const;
+
+private:
+SvGUID m_aData = {};
 };
 
 #endif
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index fda6fafab53c..87bb46d50c2b 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -20,134 +20,81 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
 #include 
 #include 
 
-// ImpSvGlobalName 
-ImpSvGlobalName::ImpSvGlobalName( const ImpSvGlobalName & rObj )
-: szData(rObj.szData)
-{
-}
-
-ImpSvGlobalName::ImpSvGlobalName(sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
-  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 
b11,
-  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, 
sal_uInt8 b15)
-{
-szData.Data1 = n1;
-szData.Data2 = n2;
-szData.Data3 = n3;
-szData.Data4[0] = b8;
-szData.Data4[1] = b9;
-szData.Data4[2] = b10;
-szData.Data4[3] = b11;
-szData.Data4[4] = b12;
-szData.Data4[5] = b13;
-szData.Data4[6] = b14;
-szData.Data4[7] = b15;
-}
-
-bool ImpSvGlobalName::operator == ( const ImpSvGlobalName & rObj ) const
-{
-return !memcmp( , , sizeof( szData ) );
-}
-
 // SvGlobalName 

-SvGlobalName::SvGlobalName()
-{
-}
-
 SvGlobalName::SvGlobalName( const SvGUID & rId ) :
-pImp( ImpSvGlobalName( rId ) )
+m_aData( rId )
 {
 }
 
 SvGlobalName::SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
 sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, 
sal_uInt8 b11,
 sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, 
sal_uInt8 b15 ) :
-pImp( ImpSvGlobalName(n1, n2, n3, b8, b9, b10, b11, b12, b13, b14, b15) )
+m_aData{ 

[Libreoffice-commits] core.git: include/tools tools/source

2022-01-31 Thread Szymon Kłos (via logerrit)
 include/tools/json_writer.hxx |   18 +
 tools/source/misc/json_writer.cxx |   39 --
 2 files changed, 55 insertions(+), 2 deletions(-)

New commits:
commit 496fcccfa655f250086c10de9e3c05f5fcf43f3f
Author: Szymon Kłos 
AuthorDate: Wed Dec 8 11:53:35 2021 +0100
Commit: Michael Meeks 
CommitDate: Mon Jan 31 17:01:33 2022 +0100

jsonwriter: ensure correct number of bytes is available

In some functions author forgot that addCommaBeforeField()
can add additional two characters.

I didn't change cases where more bytes than needed are requested.

Additional change is that in debug mode there is a marker at the
end of allocated buffer - we check that after every write to
detect overflow. No need to request more space for a marker as
we always allocate "needed size * 2".

Change-Id: I28066797b0ba833e408b0a731abc01b7fd989da3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126535
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129163
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 72ed59edadc5..700e82b9a2c6 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -89,6 +89,24 @@ private:
 void writeEscapedOUString(const OUString& rPropVal);
 std::pair extractDataImpl();
 void ensureSpace(int noMoreBytesRequired);
+
+// overflow validation in debug mode
+static constexpr unsigned char JSON_WRITER_DEBUG_MARKER = 0xde;
+
+inline void addValidationMark()
+{
+#ifndef NDEBUG
+*(mpBuffer + mSpaceAllocated - 1) = JSON_WRITER_DEBUG_MARKER;
+#endif
+}
+
+inline void validate()
+{
+#ifndef NDEBUG
+unsigned char c = *(mpBuffer + mSpaceAllocated - 1);
+assert(c == JSON_WRITER_DEBUG_MARKER);
+#endif
+}
 };
 
 /**
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index d6e34179f930..7730a9a603d5 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -30,6 +30,8 @@ JsonWriter::JsonWriter()
 ++mPos;
 *mPos = ' ';
 ++mPos;
+
+addValidationMark();
 }
 
 JsonWriter::~JsonWriter()
@@ -41,7 +43,7 @@ JsonWriter::~JsonWriter()
 ScopedJsonWriterNode JsonWriter::startNode(const char* pNodeName)
 {
 auto len = strlen(pNodeName);
-ensureSpace(len + 6);
+ensureSpace(len + 8);
 
 addCommaBeforeField();
 
@@ -53,6 +55,9 @@ ScopedJsonWriterNode JsonWriter::startNode(const char* 
pNodeName)
 mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
+
+validate();
+
 return ScopedJsonWriterNode(*this);
 }
 
@@ -64,12 +69,14 @@ void JsonWriter::endNode()
 *mPos = '}';
 ++mPos;
 mbFirstFieldInNode = false;
+
+validate();
 }
 
 ScopedJsonWriterArray JsonWriter::startArray(const char* pNodeName)
 {
 auto len = strlen(pNodeName);
-ensureSpace(len + 6);
+ensureSpace(len + 8);
 
 addCommaBeforeField();
 
@@ -81,6 +88,9 @@ ScopedJsonWriterArray JsonWriter::startArray(const char* 
pNodeName)
 mPos += 5;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
+
+validate();
+
 return ScopedJsonWriterArray(*this);
 }
 
@@ -92,6 +102,8 @@ void JsonWriter::endArray()
 *mPos = ']';
 ++mPos;
 mbFirstFieldInNode = false;
+
+validate();
 }
 
 ScopedJsonWriterStruct JsonWriter::startStruct()
@@ -106,6 +118,9 @@ ScopedJsonWriterStruct JsonWriter::startStruct()
 ++mPos;
 mStartNodeCount++;
 mbFirstFieldInNode = true;
+
+validate();
+
 return ScopedJsonWriterStruct(*this);
 }
 
@@ -117,6 +132,8 @@ void JsonWriter::endStruct()
 *mPos = '}';
 ++mPos;
 mbFirstFieldInNode = false;
+
+validate();
 }
 
 static char getEscapementChar(char ch)
@@ -211,6 +228,8 @@ void JsonWriter::writeEscapedOUString(const OUString& 
rPropVal)
 ++mPos;
 }
 }
+
+validate();
 }
 
 void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
@@ -234,6 +253,8 @@ void JsonWriter::put(const char* pPropName, const OUString& 
rPropVal)
 
 *mPos = '"';
 ++mPos;
+
+validate();
 }
 
 void JsonWriter::put(const char* pPropName, std::string_view rPropVal)
@@ -287,6 +308,8 @@ void JsonWriter::put(const char* pPropName, 
std::string_view rPropVal)
 
 *mPos = '"';
 ++mPos;
+
+validate();
 }
 
 void JsonWriter::put(const char* pPropName, sal_Int64 nPropVal)
@@ -305,6 +328,8 @@ void JsonWriter::put(const char* pPropName, sal_Int64 
nPropVal)
 mPos += 3;
 
 mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal);
+
+validate();
 }
 
 void JsonWriter::put(const char* pPropName, double fPropVal)
@@ -324,6 +349,8 @@ void JsonWriter::put(const char* pPropName, double fPropVal)
 
 memcpy(mPos, sPropVal.getStr(), sPropVal.getLength());
 mPos += sPropVal.getLength();
+
+validate();
 }
 
 void JsonWriter::put(const 

[Libreoffice-commits] core.git: include/tools tools/source

2021-11-22 Thread Noel Grandin (via logerrit)
 include/tools/urlobj.hxx |2 
 tools/source/fsys/urlobj.cxx |   94 +--
 2 files changed, 47 insertions(+), 49 deletions(-)

New commits:
commit 1b327e4a33a2a2c575c247ea90365652d6549852
Author: Noel Grandin 
AuthorDate: Mon Nov 22 11:16:30 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Nov 22 12:20:18 2021 +0100

tdf#133835 speedup calc autofilter (9)

Remove the temporary buffer in INetURLObject::setAbsURIRef,
and just write directly to the main buffer.

This is a behaviour change since we are "committing" bad data to the
buffer if the URL is incorrect, but since it that case we set the
whole object to be invalid, that should not matter.

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

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 6413d2787f96..6bba4d9aa13b 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -255,7 +255,7 @@ public:
 // General Structure:
 
 INetURLObject():
-m_eScheme(INetProtocol::NotValid), m_eSmartScheme(INetProtocol::Http) 
{}
+m_aAbsURIRef(256), m_eScheme(INetProtocol::NotValid), 
m_eSmartScheme(INetProtocol::Http) {}
 
 bool HasError() const { return m_eScheme == INetProtocol::NotValid; }
 
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 8babbf90b79f..adc73849b5f0 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -732,7 +732,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 
 sal_uInt32 nFragmentDelimiter = '#';
 
-OUStringBuffer aSynAbsURIRef(rTheAbsURIRef.getLength()*2);
+m_aAbsURIRef.setLength(0);
 
 // Parse :
 sal_Unicode const * p = pPos;
@@ -745,7 +745,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 char const * pTemp = pPrefix->m_eKind >= PrefixInfo::Kind::External ?
  pPrefix->m_pTranslatedPrefix :
  pPrefix->m_pPrefix;
-aSynAbsURIRef.appendAscii(pTemp);
+m_aAbsURIRef.appendAscii(pTemp);
 m_aScheme = SubString( 0, strstr(pTemp, ":") - pTemp );
 }
 else
@@ -889,8 +889,8 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 if (m_eScheme != INetProtocol::Generic) {
 aSynScheme = static_cast(getSchemeInfo().m_sScheme);
 }
-m_aScheme.set(aSynAbsURIRef, aSynScheme, aSynAbsURIRef.getLength());
-aSynAbsURIRef.append(':');
+m_aScheme.set(m_aAbsURIRef, aSynScheme, m_aAbsURIRef.getLength());
+m_aAbsURIRef.append(':');
 }
 
 sal_uInt32 nSegmentDelimiter = '/';
@@ -916,7 +916,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 setInvalid();
 return false;
 }
-aSynAbsURIRef.append("//");
+m_aAbsURIRef.append("//");
 OUStringBuffer aSynAuthority;
 while (pPos < pEnd
&& *pPos != '/' && *pPos != '?'
@@ -929,9 +929,9 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 appendUCS4(aSynAuthority, nUTF32, eEscapeType,
PART_AUTHORITY, eCharset, false);
 }
-m_aHost.set(aSynAbsURIRef,
+m_aHost.set(m_aAbsURIRef,
 aSynAuthority.makeStringAndClear(),
-aSynAbsURIRef.getLength());
+m_aAbsURIRef.getLength());
 // misusing m_aHost to store the authority
 break;
 }
@@ -941,7 +941,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 if (pEnd - pPos >= 2 && pPos[0] == '/' && pPos[1] == '/')
 {
 pPos += 2;
-aSynAbsURIRef.append("//");
+m_aAbsURIRef.append("//");
 OUStringBuffer aSynAuthority;
 while (pPos < pEnd
&& *pPos != '/' && *pPos != '?'
@@ -965,9 +965,9 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 setInvalid();
 return false;
 }
-m_aHost.set(aSynAbsURIRef,
+m_aHost.set(m_aAbsURIRef,
 aSynAuthority.makeStringAndClear(),
-aSynAbsURIRef.getLength());
+m_aAbsURIRef.getLength());
 // misusing m_aHost to store the authority
 }
 break;
@@ -981,7 +981,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 

[Libreoffice-commits] core.git: include/tools tools/source

2021-11-21 Thread Noel Grandin (via logerrit)
 include/tools/urlobj.hxx |   16 
 tools/source/fsys/urlobj.cxx |   38 +++---
 2 files changed, 27 insertions(+), 27 deletions(-)

New commits:
commit 7805a224b96897807e49fd49dd5276d6089b0b5c
Author: Noel Grandin 
AuthorDate: Sat Nov 20 20:28:42 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Nov 22 07:50:59 2021 +0100

tdf#133835 speedup calc autofilter (6)

INetURLObject::SetPort Avoid allocating temporary string on heap,
saves 20%

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

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 8049e165d7a0..6413d2787f96 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -938,17 +938,17 @@ private:
 
 sal_Int32 getEnd() const { return m_nBegin + m_nLength; }
 
-inline sal_Int32 clear();
+sal_Int32 clear();
 
-inline sal_Int32 set(OUStringBuffer & rString,
- OUString const & rSubString,
- sal_Int32 nTheBegin);
+sal_Int32 set(OUStringBuffer & rString,
+  std::u16string_view rSubString,
+  sal_Int32 nTheBegin);
 
-inline sal_Int32 set(OUString & rString,
- OUString const & rSubString);
+sal_Int32 set(OUString & rString,
+  std::u16string_view rSubString);
 
-inline sal_Int32 set(OUStringBuffer & rString,
- OUString const & rSubString);
+sal_Int32 set(OUStringBuffer & rString,
+  std::u16string_view rSubString);
 
 inline void operator +=(sal_Int32 nDelta);
 
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 9a5a82ceb632..d265111d2e2e 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -221,7 +221,7 @@ using namespace css;
segment = *(pchar / ";")
  */
 
-inline sal_Int32 INetURLObject::SubString::clear()
+sal_Int32 INetURLObject::SubString::clear()
 {
 sal_Int32 nDelta = -m_nLength;
 m_nBegin = -1;
@@ -229,32 +229,33 @@ inline sal_Int32 INetURLObject::SubString::clear()
 return nDelta;
 }
 
-inline sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
-   OUString const & rSubString)
+sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
+   std::u16string_view rSubString)
 {
-sal_Int32 nDelta = rSubString.getLength() - m_nLength;
+sal_Int32 nDelta = rSubString.size() - m_nLength;
 
 rString.remove(m_nBegin, m_nLength);
 rString.insert(m_nBegin, rSubString);
 
-m_nLength = rSubString.getLength();
+m_nLength = rSubString.size();
 return nDelta;
 }
 
-inline sal_Int32 INetURLObject::SubString::set(OUString & rString,
-   OUString const & rSubString)
+sal_Int32 INetURLObject::SubString::set(OUString & rString,
+   std::u16string_view rSubString)
 {
-sal_Int32 nDelta = rSubString.getLength() - m_nLength;
+sal_Int32 nDelta = rSubString.size() - m_nLength;
 
-rString = rString.replaceAt(m_nBegin, m_nLength, rSubString);
+rString = OUString::Concat(rString.subView(0, m_nBegin)) + 
+ rSubString + rString.subView(m_nBegin + m_nLength);
 
-m_nLength = rSubString.getLength();
+m_nLength = rSubString.size();
 return nDelta;
 }
 
-inline sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
-   OUString const & rSubString,
-   sal_Int32 nTheBegin)
+sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
+std::u16string_view rSubString,
+sal_Int32 nTheBegin)
 {
 m_nBegin = nTheBegin;
 return set(rString, rSubString);
@@ -1411,7 +1412,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 {
 aSynAbsURIRef.append(':');
 m_aPort.set(aSynAbsURIRef,
-OUString(pPort + 1, pHostPortEnd - (pPort + 1)),
+std::u16string_view{pPort + 1, 
static_cast(pHostPortEnd - (pPort + 1))},
 aSynAbsURIRef.getLength());
 }
 }
@@ -2334,7 +2335,7 @@ bool INetURLObject::setPassword(std::u16string_view 
rThePassword,
 else if (m_aHost.isPresent())
 {
 m_aAbsURIRef.insert(m_aHost.getBegin(), ":@" );
-m_aUser.set(m_aAbsURIRef, OUString(), m_aHost.getBegin());
+m_aUser.set(m_aAbsURIRef, std::u16string_view{}, m_aHost.getBegin());
 nDelta
 = m_aAuth.set(m_aAbsURIRef, aNewAuth, m_aHost.getBegin() + 1) + 2;
 }
@@ -2343,7 

[Libreoffice-commits] core.git: include/tools tools/source

2021-11-21 Thread Noel Grandin (via logerrit)
 include/tools/urlobj.hxx |2 
 tools/source/fsys/urlobj.cxx |  158 +++
 2 files changed, 102 insertions(+), 58 deletions(-)

New commits:
commit 0b46361ef84a61100a0274a007062317607d097a
Author: Noel Grandin 
AuthorDate: Sat Nov 20 08:03:49 2021 +0200
Commit: Noel Grandin 
CommitDate: Sun Nov 21 10:26:52 2021 +0100

tdf#133835 speedup calc autofilter (4)

Tweak INetURLObject::parseHost so it doesn't need its own
OUStringBuffer, and can just use the callers'
Saves 5%

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

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 6b9dece8bdf3..ede630b7ea7b 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -1037,7 +1037,7 @@ private:
 
 TOOLS_DLLPRIVATE static bool parseHost(
 sal_Unicode const *& rBegin, sal_Unicode const * pEnd,
-OUString & rCanonic);
+OUStringBuffer* pCanonic);
 
 TOOLS_DLLPRIVATE static bool parseHostOrNetBiosName(
 sal_Unicode const * pBegin, sal_Unicode const * pEnd,
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 6b074180f6df..8b2882b06b32 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1370,16 +1370,15 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 }
 break;
 }
-OUStringBuffer aSynHost(64);
+sal_Int32 nLenBeforeHost = aSynAbsURIRef.getLength();
 if (!parseHostOrNetBiosName(
 pHostPortBegin, pPort, eMechanism, eCharset,
-bNetBiosName, ))
+bNetBiosName, ))
 {
 setInvalid();
 return false;
 }
-m_aHost.set(aSynAbsURIRef, aSynHost.makeStringAndClear(),
-aSynAbsURIRef.getLength());
+m_aHost = SubString(nLenBeforeHost, aSynAbsURIRef.getLength() - 
nLenBeforeHost);
 if (pPort != pHostPortEnd)
 {
 aSynAbsURIRef.append(':');
@@ -2329,7 +2328,7 @@ bool INetURLObject::setPassword(std::u16string_view 
rThePassword,
 
 // static
 bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * 
pEnd,
-OUString & rCanonic)
+OUStringBuffer* pCanonic)
 {
 // RFC 2373 is inconsistent about how to write an IPv6 address in which an
 // IPv4 address directly follows the abbreviating "::".  The ABNF in
@@ -2343,19 +2342,20 @@ bool INetURLObject::parseHost(sal_Unicode const *& 
rBegin, sal_Unicode const * p
  STATE_IP6_HEXSEQ1_MAYBE_IP4, STATE_IP6_HEXSEQ2,
  STATE_IP6_HEXSEQ2_COLON, STATE_IP6_HEXSEQ2_MAYBE_IP4,
  STATE_IP6_IP4, STATE_IP6_IP4_DOT, STATE_IP6_DONE };
-OUStringBuffer aTheCanonic(32);
 sal_uInt32 nNumber = 0;
 int nDigits = 0;
 int nOctets = 0;
 State eState = STATE_INITIAL;
 sal_Unicode const * p = rBegin;
+sal_Int32 nOriginalCanonicLength = pCanonic ? pCanonic->getLength() : 0;
 for (; p != pEnd; ++p)
 switch (eState)
 {
 case STATE_INITIAL:
 if (*p == '[')
 {
-aTheCanonic.append('[');
+if (pCanonic)
+pCanonic->append('[');
 eState = STATE_IP6;
 }
 else if (rtl::isAsciiAlpha(*p) || *p == '_')
@@ -2425,8 +2425,11 @@ bool INetURLObject::parseHost(sal_Unicode const *& 
rBegin, sal_Unicode const * p
 if (*p == '.')
 if (nOctets < 4)
 {
-aTheCanonic.append(static_cast(nNumber));
-aTheCanonic.append( '.' );
+if (pCanonic)
+{
+pCanonic->append(static_cast(nNumber));
+pCanonic->append( '.' );
+}
 ++nOctets;
 eState = STATE_IP4_DOT;
 }
@@ -2477,7 +2480,8 @@ bool INetURLObject::parseHost(sal_Unicode const *& 
rBegin, sal_Unicode const * p
 case STATE_IP6_COLON:
 if (*p == ':')
 {
-aTheCanonic.append("::");
+if (pCanonic)
+pCanonic->append("::");
 eState = STATE_IP6_2COLON;
 }
 else
@@ -2489,7 +2493,8 @@ bool INetURLObject::parseHost(sal_Unicode const *& 
rBegin, sal_Unicode const * p
 eState = STATE_IP6_DONE;
 else if (*p == ':')
 {
-aTheCanonic.append(':');
+if (pCanonic)
+

[Libreoffice-commits] core.git: include/tools tools/source

2021-10-13 Thread Mike Kaganski (via logerrit)
 include/tools/json_writer.hxx |   15 ---
 tools/source/misc/json_writer.cxx |   29 -
 2 files changed, 20 insertions(+), 24 deletions(-)

New commits:
commit 02d225f2a46b3d531e187976d8f2c39ed390899c
Author: Mike Kaganski 
AuthorDate: Thu Oct 14 00:15:11 2021 +0300
Commit: Mike Kaganski 
CommitDate: Thu Oct 14 07:40:52 2021 +0200

Simplify JsonWriter a bit

Move ensureSpace code to json_writer.cxx, and merge with reallocBuffer.
The methods are private, and are only used in methods in the same .CXX,
so the code will get inlined as compiler decides anyway, but becomes
simpler.

Make extractDataAs* to consider the known size of the data, to avoid
calculating null-terminated size. To do that, the code is moved from
extractData to private extractDataImpl, which returns both pointer
and size.

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

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 45df53c61c5f..72ed59edadc5 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 
 /** Simple JSON encoder designed specifically for LibreOfficeKit purposes.
  *
@@ -73,7 +74,7 @@ public:
 
 /** Hands ownership of the underlying storage buffer to the caller,
  * after this no more document modifications may be written. */
-char* extractData();
+char* extractData() { return extractDataImpl().first; }
 OString extractAsOString();
 std::string extractAsStdString();
 
@@ -85,17 +86,9 @@ private:
 void endArray();
 void endStruct();
 void addCommaBeforeField();
-void reallocBuffer(int noMoreBytesRequired);
 void writeEscapedOUString(const OUString& rPropVal);
-
-// this part inline to speed up the fast path
-inline void ensureSpace(int noMoreBytesRequired)
-{
-assert(mpBuffer && "already extracted data");
-int currentUsed = mPos - mpBuffer;
-if (currentUsed + noMoreBytesRequired >= mSpaceAllocated)
-reallocBuffer(noMoreBytesRequired);
-}
+std::pair extractDataImpl();
+void ensureSpace(int noMoreBytesRequired);
 };
 
 /**
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 7024b580c7fd..d6e34179f930 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -388,18 +388,22 @@ void JsonWriter::addCommaBeforeField()
 }
 }
 
-void JsonWriter::reallocBuffer(int noMoreBytesRequired)
+void JsonWriter::ensureSpace(int noMoreBytesRequired)
 {
+assert(mpBuffer && "already extracted data");
 int currentUsed = mPos - mpBuffer;
-auto newSize = std::max(mSpaceAllocated * 2, (currentUsed + 
noMoreBytesRequired) * 2);
-mpBuffer = static_cast(realloc(mpBuffer, newSize));
-mPos = mpBuffer + currentUsed;
-mSpaceAllocated = newSize;
+if (currentUsed + noMoreBytesRequired >= mSpaceAllocated)
+{
+auto newSize = (currentUsed + noMoreBytesRequired) * 2;
+mpBuffer = static_cast(realloc(mpBuffer, newSize));
+mPos = mpBuffer + currentUsed;
+mSpaceAllocated = newSize;
+}
 }
 
 /** Hands ownership of the underlying storage buffer to the caller,
   * after this no more document modifications may be written. */
-char* JsonWriter::extractData()
+std::pair JsonWriter::extractDataImpl()
 {
 assert(mStartNodeCount == 0 && "did not close all nodes");
 assert(mpBuffer && "data already extracted");
@@ -409,24 +413,23 @@ char* JsonWriter::extractData()
 ++mPos;
 // null-terminate
 *mPos = 0;
+const int sz = mPos - mpBuffer;
 mPos = nullptr;
-char* pRet = nullptr;
-std::swap(pRet, mpBuffer);
-return pRet;
+return { std::exchange(mpBuffer, nullptr), sz };
 }
 
 OString JsonWriter::extractAsOString()
 {
-char* pChar = extractData();
-OString ret(pChar);
+auto[pChar, sz] = extractDataImpl();
+OString ret(pChar, sz);
 free(pChar);
 return ret;
 }
 
 std::string JsonWriter::extractAsStdString()
 {
-char* pChar = extractData();
-std::string ret(pChar);
+auto[pChar, sz] = extractDataImpl();
+std::string ret(pChar, sz);
 free(pChar);
 return ret;
 }


[Libreoffice-commits] core.git: include/tools tools/source

2021-09-10 Thread Noel Grandin (via logerrit)
 include/tools/json_writer.hxx |4 ++--
 tools/source/misc/json_writer.cxx |6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 9490588c2460a77c16aacd52b7f449db60a6b34b
Author: Noel Grandin 
AuthorDate: Fri Sep 10 19:29:41 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 10 21:19:24 2021 +0200

clang:optin.performance.Padding in tools

Excessive padding in 'class tools::JsonWriter' (15 padding bytes, where
7 is optimal).

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

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 2e50670c5b26..fb40e1920314 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -34,10 +34,10 @@ class TOOLS_DLLPUBLIC JsonWriter
 friend class ScopedJsonWriterArray;
 friend class ScopedJsonWriterStruct;
 
-int mSpaceAllocated;
 char* mpBuffer;
-int mStartNodeCount;
 char* mPos;
+int mSpaceAllocated;
+int mStartNodeCount;
 bool mbFirstFieldInNode;
 
 public:
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index c326201eb9e5..b6482329ea55 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -21,10 +21,10 @@ namespace tools
 constexpr int DEFAULT_BUFFER_SIZE = 2048;
 
 JsonWriter::JsonWriter()
-: mSpaceAllocated(DEFAULT_BUFFER_SIZE)
-, mpBuffer(static_cast(malloc(mSpaceAllocated)))
-, mStartNodeCount(0)
+: mpBuffer(static_cast(malloc(DEFAULT_BUFFER_SIZE)))
 , mPos(mpBuffer)
+, mSpaceAllocated(DEFAULT_BUFFER_SIZE)
+, mStartNodeCount(0)
 , mbFirstFieldInNode(true)
 {
 *mPos = '{';


[Libreoffice-commits] core.git: include/tools tools/source

2021-08-17 Thread Mike Kaganski (via logerrit)
 include/tools/gen.hxx|9 -
 tools/source/generic/gen.cxx |9 -
 2 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 28708b5b7ad12bc30f02142c990e5ad4128af912
Author: Mike Kaganski 
AuthorDate: Sat Aug 14 22:08:17 2021 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 17 11:24:46 2021 +0200

Simplify and inline tools::Rectangle::Justify

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 2d23b693fa50..5cc23bf83654 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -472,7 +472,7 @@ public:
 constexpr Rectangle( tools::Long nLeft, tools::Long nTop );
 constexpr Rectangle( const Point& rLT, const Size& rSize );
 
-static RectangleJustify( const Point& rLT, const Point& rRB );
+inline constexpr static Rectangle Justify(const Point& rLT, const Point& 
rRB);
 
 constexpr tools::Long Left() const { return nLeft; }
 constexpr tools::Long Right() const { return IsWidthEmpty() ? nLeft : 
nRight; }
@@ -626,6 +626,13 @@ constexpr inline tools::Rectangle::Rectangle( const Point& 
rLT, const Size& rSiz
 , nBottom(rSize.Height() ? nTop + (rSize.Height() + (rSize.Height() > 0 ? 
-1 : 1)) : RECT_EMPTY)
 {}
 
+constexpr inline tools::Rectangle tools::Rectangle::Justify(const Point& rLT, 
const Point& rRB)
+{
+const std::pair aLeftRight = 
std::minmax(rLT.X(), rRB.X());
+const std::pair aTopBottom = 
std::minmax(rLT.Y(), rRB.Y());
+return { aLeftRight.first, aTopBottom.first, aLeftRight.second, 
aTopBottom.second };
+}
+
 inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long 
nVertMove )
 {
 nLeft += nHorzMove;
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 4d365a575808..027c7b9356b1 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -35,15 +35,6 @@ OString Pair::toString() const
 return OString::number(A()) + ", " + OString::number(B());
 }
 
-tools::Rectangle tools::Rectangle::Justify( const Point& rLT, const Point& rRB 
)
-{
-tools::Long nLeft   = std::min(rLT.X(), rRB.X());
-tools::Long nTop= std::min(rLT.Y(), rRB.Y());
-tools::Long nRight  = std::max(rLT.X(), rRB.X());
-tools::Long nBottom = std::max(rLT.Y(), rRB.Y());
-return Rectangle( nLeft, nTop, nRight, nBottom );
-}
-
 void tools::Rectangle::SetSize( const Size& rSize )
 {
 if ( rSize.Width() < 0 )


[Libreoffice-commits] core.git: include/tools tools/source

2021-08-15 Thread Mike Kaganski (via logerrit)
 include/tools/gen.hxx|   86 ++-
 tools/source/generic/gen.cxx |   54 +--
 2 files changed, 47 insertions(+), 93 deletions(-)

New commits:
commit 6c12c659fb22aeab1d1d5d0e8298662e2a602499
Author: Mike Kaganski 
AuthorDate: Sat Aug 14 03:20:01 2021 +0300
Commit: Mike Kaganski 
CommitDate: Sun Aug 15 10:18:49 2021 +0200

Simplify tools::Rectangle a bit

1. Simplify/delegate ctors
2. Simplify getWidth/getHeight
3. Simplify expand
4. Simplify operators += / -= / + / -

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index b8bd6eeb35d4..3c97728c7402 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -464,7 +464,7 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Rectangle final
 {
 static constexpr short RECT_EMPTY = -32767;
 public:
-constexpr Rectangle();
+constexpr Rectangle() = default;
 constexpr Rectangle( const Point& rLT, const Point& rRB );
 constexpr Rectangle( tools::Long nLeft, tools::Long nTop,
  tools::Long nRight, tools::Long nBottom );
@@ -475,14 +475,14 @@ public:
 static RectangleJustify( const Point& rLT, const Point& rRB );
 
 constexpr tools::Long Left() const { return nLeft; }
-constexpr tools::Long Right() const { return nRight == RECT_EMPTY ? nLeft 
: nRight; }
+constexpr tools::Long Right() const { return IsWidthEmpty() ? nLeft : 
nRight; }
 constexpr tools::Long Top() const { return nTop; }
-constexpr tools::Long Bottom() const { return nBottom == RECT_EMPTY ? nTop 
: nBottom; }
+constexpr tools::Long Bottom() const { return IsHeightEmpty() ? nTop : 
nBottom; }
 
-voidSetLeft(tools::Long v){ nLeft = v;   }
-voidSetRight(tools::Long v)   { nRight = v;  }
-voidSetTop(tools::Long v) { nTop = v;}
-voidSetBottom(tools::Long v)  { nBottom = v; }
+constexpr void SetLeft(tools::Long v) { nLeft = v; }
+constexpr void SetRight(tools::Long v) { nRight = v; }
+constexpr void SetTop(tools::Long v) { nTop = v; }
+constexpr void SetBottom(tools::Long v) { nBottom = v; }
 
 constexpr Point TopLeft() const { return { Left(), Top() }; }
 constexpr Point TopRight() const { return { Right(), Top() }; }
@@ -511,7 +511,7 @@ public:
 {
 tools::Long n = 0;
 
-if (nRight != RECT_EMPTY)
+if (!IsWidthEmpty())
 {
 n = nRight - nLeft;
 if (n < 0)
@@ -528,7 +528,7 @@ public:
 {
 tools::Long n = 0;
 
-if (nBottom != RECT_EMPTY)
+if (!IsHeightEmpty())
 {
 n = nBottom - nTop;
 if (n < 0)
@@ -554,9 +554,9 @@ public:
 voidSetEmpty() { nRight = nBottom = RECT_EMPTY; }
 voidSetWidthEmpty() { nRight = RECT_EMPTY; }
 voidSetHeightEmpty() { nBottom = RECT_EMPTY; }
-constexpr bool IsEmpty() const { return (nRight == RECT_EMPTY) || (nBottom 
== RECT_EMPTY); }
-boolIsWidthEmpty() const { return nRight == RECT_EMPTY; }
-boolIsHeightEmpty() const { return nBottom == RECT_EMPTY; }
+constexpr bool IsEmpty() const { return IsWidthEmpty() || IsHeightEmpty(); 
}
+constexpr bool IsWidthEmpty() const { return nRight == RECT_EMPTY; }
+constexpr bool IsHeightEmpty() const { return nBottom == RECT_EMPTY; }
 
 inline bool operator == ( const tools::Rectangle& rRect ) const;
 inline bool operator != ( const tools::Rectangle& rRect ) const;
@@ -571,9 +571,9 @@ public:
 tools::Long getX() const { return nLeft; }
 tools::Long getY() const { return nTop; }
 /// Returns the difference between right and left, assuming the range 
includes one end, but not the other.
-tools::Long getWidth() const;
+tools::Long getWidth() const { return Right() - Left(); }
 /// Returns the difference between bottom and top, assuming the range 
includes one end, but not the other.
-tools::Long getHeight() const;
+tools::Long getHeight() const { return Bottom() - Top(); }
 /// Set the left edge of the rectangle to x, preserving the width
 voidsetX( tools::Long x );
 /// Set the top edge of the rectangle to y, preserving the height
@@ -597,25 +597,15 @@ public:
 voidSaturatingSetY(tools::Long y);
 
 private:
-tools::LongnLeft;
-tools::LongnTop;
-tools::LongnRight;
-tools::LongnBottom;
+tools::Long nLeft = 0;
+tools::Long nTop = 0;
+tools::Long nRight = RECT_EMPTY;
+tools::Long nBottom = RECT_EMPTY;
 };
 }
 
-constexpr inline 

[Libreoffice-commits] core.git: include/tools tools/source

2021-08-11 Thread Mike Kaganski (via logerrit)
 include/tools/gen.hxx|   93 ++-
 tools/source/generic/gen.cxx |   10 
 2 files changed, 15 insertions(+), 88 deletions(-)

New commits:
commit 5351e837a11fb9d19759cd1b91ca4b5d43e2f75a
Author: Mike Kaganski 
AuthorDate: Thu Aug 12 03:43:27 2021 +0200
Commit: Mike Kaganski 
CommitDate: Thu Aug 12 04:48:48 2021 +0200

Unify and simplify tools::Rectangle methods returning Point

Make the methods use Left()/Top()/Right()/Bottom(), allowing to
avoid explicit checks for emptiness.

Also do not use std::min/max in *Center(), so that e.g. TopCenter
returns top value the same way as TopLeft and TopRight do.

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 5386de129c56..b8bd6eeb35d4 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -474,37 +474,25 @@ public:
 
 static RectangleJustify( const Point& rLT, const Point& rRB );
 
-tools::Long Left() const{ return nLeft;   }
-tools::Long Right() const;
-tools::Long Top() const { return nTop;}
-tools::Long Bottom() const;
+constexpr tools::Long Left() const { return nLeft; }
+constexpr tools::Long Right() const { return nRight == RECT_EMPTY ? nLeft 
: nRight; }
+constexpr tools::Long Top() const { return nTop; }
+constexpr tools::Long Bottom() const { return nBottom == RECT_EMPTY ? nTop 
: nBottom; }
 
 voidSetLeft(tools::Long v){ nLeft = v;   }
 voidSetRight(tools::Long v)   { nRight = v;  }
 voidSetTop(tools::Long v) { nTop = v;}
 voidSetBottom(tools::Long v)  { nBottom = v; }
 
-constexpr Point TopLeft() const
-{
-return Point( nLeft, nTop );
-}
-constexpr Point TopRight() const
-{
-return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop );
-}
-constexpr Point TopCenter() const
-{
-if (IsEmpty())
-return Point(nLeft, nTop);
-else
-return Point((nLeft + nRight) / 2, std::min(nTop, nBottom));
-}
-inline Point BottomLeft() const;
-inline Point BottomRight() const;
-inline Point BottomCenter() const;
-inline Point LeftCenter() const;
-inline Point RightCenter() const;
-inline Point Center() const;
+constexpr Point TopLeft() const { return { Left(), Top() }; }
+constexpr Point TopRight() const { return { Right(), Top() }; }
+constexpr Point TopCenter() const { return { (Left() + Right()) / 2, Top() 
}; }
+constexpr Point BottomLeft() const { return { Left(), Bottom() }; }
+constexpr Point BottomRight() const { return { Right(), Bottom() }; }
+constexpr Point BottomCenter() const { return { (Left() + Right()) / 2, 
Bottom() }; }
+constexpr Point LeftCenter() const { return { Left(), (Top() + Bottom()) / 
2 }; }
+constexpr Point RightCenter() const { return { Right(), (Top() + Bottom()) 
/ 2 }; }
+constexpr Point Center() const { return { (Left() + Right()) / 2, (Top() + 
Bottom()) / 2 }; }
 
 /// Move the top and left edges by a delta, preserving width and height
 inline void Move( tools::Long nHorzMoveDelta, tools::Long 
nVertMoveDelta );
@@ -516,10 +504,7 @@ public:
 inline void SetPos( const Point& rPoint );
 voidSetSize( const Size& rSize );
 
-constexpr Size GetSize() const
-{
-return Size(GetWidth(), GetHeight());
-}
+constexpr Size GetSize() const { return { GetWidth(), GetHeight() }; }
 
 /// Returns the difference between right and left, assuming the range is 
inclusive.
 constexpr tools::Long GetWidth() const
@@ -569,7 +554,7 @@ public:
 voidSetEmpty() { nRight = nBottom = RECT_EMPTY; }
 voidSetWidthEmpty() { nRight = RECT_EMPTY; }
 voidSetHeightEmpty() { nBottom = RECT_EMPTY; }
-constexpr bool IsEmpty() const;
+constexpr bool IsEmpty() const { return (nRight == RECT_EMPTY) || (nBottom 
== RECT_EMPTY); }
 boolIsWidthEmpty() const { return nRight == RECT_EMPTY; }
 boolIsHeightEmpty() const { return nBottom == RECT_EMPTY; }
 
@@ -655,54 +640,6 @@ constexpr inline tools::Rectangle::Rectangle( const Point& 
rLT, const Size& rSiz
 , nBottom( rSize.Height() ? nTop+(rSize.Height()-1) : RECT_EMPTY )
 {}
 
-constexpr inline bool tools::Rectangle::IsEmpty() const
-{
-return (nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY);
-}
-
-inline Point tools::Rectangle::BottomLeft() const
-{
-return Point( nLeft, (nBottom == RECT_EMPTY) ? nTop : nBottom );
-}
-
-inline Point tools::Rectangle::BottomRight() const
-{
-return Point( (nRight  == RECT_EMPTY) ? nLeft : 

[Libreoffice-commits] core.git: include/tools tools/source

2021-08-11 Thread Mike Kaganski (via logerrit)
 include/tools/stream.hxx   |3 
 tools/source/stream/stream.cxx |  185 ++---
 2 files changed, 33 insertions(+), 155 deletions(-)

New commits:
commit 84bf981a4fdf94cae40dd199762dc03d681618fe
Author: Mike Kaganski 
AuthorDate: Tue Aug 10 22:53:46 2021 +0200
Commit: Mike Kaganski 
CommitDate: Wed Aug 11 08:16:35 2021 +0200

Deduplicate number read/write

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index e99d41c8ac45..884b95f07290 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -409,6 +409,9 @@ public:
 bool good() const { return !(eof() || bad()); }
 
 private:
+template  SvStream& ReadNumber(T& r);
+template  SvStream& WriteNumber(T n);
+
 template
 void readNumberWithoutSwap(T& rDataDest)
 { readNumberWithoutSwap_(, sizeof(rDataDest)); }
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 515f3a1657ab..d42cefdf63cf 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -53,44 +53,23 @@ static void swapNibbles(unsigned char )
 #include 
 
 // !!! Do not inline if already the operators <<,>> are inline
-static void SwapUShort( sal_uInt16& r )
+template  && sizeof(T) == 
2, int> = 0>
+static void SwapNumber(T& r)
 {   r = OSL_SWAPWORD(r);   }
-static void SwapShort( short& r )
-{   r = OSL_SWAPWORD(r);   }
-static void SwapULong( sal_uInt32& r )
-{   r = OSL_SWAPDWORD(r);   }
-static void SwapLongInt( sal_Int32& r )
+template  && sizeof(T) == 
4, int> = 0>
+static void SwapNumber(T& r)
 {   r = OSL_SWAPDWORD(r);   }
-
-static void SwapUInt64( sal_uInt64& r )
+template  && sizeof(T) == 
8, int> = 0>
+static void SwapNumber(T& r)
 {
 union
 {
-sal_uInt64 n;
+T n;
 sal_uInt32 c[2];
 } s;
 
 s.n = r;
-s.c[0] ^= s.c[1]; // swap the 32 bit words
-s.c[1] ^= s.c[0];
-s.c[0] ^= s.c[1];
-// swap the bytes in the words
-s.c[0] = OSL_SWAPDWORD(s.c[0]);
-s.c[1] = OSL_SWAPDWORD(s.c[1]);
-r = s.n;
-}
-static void SwapInt64( sal_Int64& r )
-{
-union
-{
-sal_Int64 n;
-sal_Int32 c[2];
-} s;
-
-s.n = r;
-s.c[0] ^= s.c[1]; // swap the 32 bit words
-s.c[1] ^= s.c[0];
-s.c[0] ^= s.c[1];
+std::swap(s.c[0], s.c[1]); // swap the 32 bit words
 // swap the bytes in the words
 s.c[0] = OSL_SWAPDWORD(s.c[0]);
 s.c[1] = OSL_SWAPDWORD(s.c[1]);
@@ -136,8 +115,6 @@ static void SwapDouble( double& r )
 }
 #endif
 
-static void SwapUnicode(sal_Unicode & r) { r = OSL_SWAPWORD(r); }
-
 //SDO
 
 void SvStream::readNumberWithoutSwap_(void * pDataDest, int nDataSize)
@@ -554,7 +531,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 
nMaxCodepointsToRead
 for( j = n = 0; j < nLen ; ++j )
 {
 if (m_isSwap)
-SwapUnicode( buf[n] );
+SwapNumber( buf[n] );
 c = buf[j];
 if ( c == '\n' || c == '\r' )
 {
@@ -596,7 +573,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 
nMaxCodepointsToRead
 sal_Unicode cTemp;
 ReadBytes( , sizeof(cTemp) );
 if (m_isSwap)
-SwapUnicode( cTemp );
+SwapNumber( cTemp );
 if( cTemp == c || (cTemp != '\n' && cTemp != '\r') )
 Seek( nOldFilePos );
 }
@@ -677,7 +654,7 @@ std::size_t write_uInt16s_FromOUString(SvStream& rStrm, 
std::u16string_view rStr
 const sal_Unicode* const pStop = pTmp + nLen;
 while ( p < pStop )
 {
-SwapUnicode( *p );
+SwapNumber( *p );
 p++;
 }
 nWritten = rStrm.WriteBytes( pTmp, nLen * sizeof(sal_Unicode) );
@@ -813,83 +790,25 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
 return Seek( nActualPos );
 }
 
-SvStream& SvStream::ReadUInt16(sal_uInt16& r)
-{
-sal_uInt16 n = 0;
-readNumberWithoutSwap(n);
-if (good())
-{
-if (m_isSwap)
-SwapUShort(n);
-r = n;
-}
-return *this;
-}
-
-SvStream& SvStream::ReadUInt32(sal_uInt32& r)
-{
-sal_uInt32 n = 0;
-readNumberWithoutSwap(n);
-if (good())
-{
-if (m_isSwap)
-SwapULong(n);
-r = n;
-}
-return *this;
-}
-
-SvStream& SvStream::ReadUInt64(sal_uInt64& r)
-{
-sal_uInt64 n = 0;
-readNumberWithoutSwap(n);
-if (good())
-{
-if (m_isSwap)
-SwapUInt64(n);
-r = n;
-}
-return *this;
-}
-
-SvStream& SvStream::ReadInt16(sal_Int16& r)
-{
-sal_Int16 n = 0;
-readNumberWithoutSwap(n);
-if (good())
-{
-if 

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

2021-06-23 Thread Noel Grandin (via logerrit)
 include/tools/stream.hxx   |4 +++-
 tools/source/stream/strmunx.cxx|5 -
 tools/source/stream/strmwnt.cxx|5 -
 unotools/source/ucbhelper/tempfile.cxx |3 +++
 4 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 9815bf197c27afdfeccf967898c3a000bcf7b256
Author: Noel Grandin 
AuthorDate: Mon Jun 21 12:54:29 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Jun 23 14:29:57 2021 +0200

tdf#135316 add SvFileStream::SetDontFlushOnClose

if we're going to be deleting a temporary file, there is no point
flushing it on close, which has a measureable cost

This takes my load time from  17s to 16s

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index f99b09955368..e99d41c8ac45 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -49,7 +49,7 @@ enum class StreamMode {
 NOCREATE = 0x0004,  ///< 1 == Don't create file
 TRUNC= 0x0008,  ///< Truncate _existing_ file to zero 
length
 COPY_ON_SYMLINK  = 0x0010,  ///< copy-on-write for symlinks (Unix)
-TEMPORARY= 0x0020,  ///< temporary file attribute (Windows)
+TEMPORARY= 0x0020,  ///< temporary file attribute 
(Windows-only)
 // sharing options
 SHARE_DENYNONE   = 0x0100,
 SHARE_DENYREAD   = 0x0200,  // overrides denynone
@@ -586,6 +586,7 @@ private:
 sal_uInt16  nLockCounter;
 #endif
 boolbIsOpen;
+boolmbDontFlushOnClose; ///< used to avoid flushing when 
closing temporary files
 
 SvFileStream (const SvFileStream&) = delete;
 SvFileStream & operator= (const SvFileStream&) = delete;
@@ -612,6 +613,7 @@ public:
 boolIsOpen() const { return bIsOpen; }
 
 const OUString& GetFileName() const { return aFilename; }
+voidSetDontFlushOnClose(bool b) { mbDontFlushOnClose = b; }
 };
 
 // MemoryStream
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 0b745e69b140..e034f53ac33b 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -197,6 +197,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, 
StreamMode nOpenMode )
 {
 bIsOpen = false;
 m_isWritable= false;
+mbDontFlushOnClose  = false;
 pInstanceData.reset(new StreamData);
 
 SetBufferSize( 1024 );
@@ -214,6 +215,7 @@ SvFileStream::SvFileStream()
 {
 bIsOpen = false;
 m_isWritable= false;
+mbDontFlushOnClose  = false;
 pInstanceData.reset(new StreamData);
 SetBufferSize( 1024 );
 }
@@ -457,7 +459,8 @@ void SvFileStream::Close()
 if ( IsOpen() )
 {
 SAL_INFO("tools", "Closing " << aFilename);
-Flush();
+if ( !mbDontFlushOnClose )
+Flush();
 osl_closeFile( pInstanceData->rHandle );
 pInstanceData->rHandle = nullptr;
 }
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index d85ce3a0c372..c91628b55091 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -107,6 +107,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, 
StreamMode nMode )
 bIsOpen = false;
 nLockCounter= 0;
 m_isWritable= false;
+mbDontFlushOnClose  = false;
 pInstanceData.reset( new StreamData );
 
 SetBufferSize( 8192 );
@@ -123,6 +124,7 @@ SvFileStream::SvFileStream()
 bIsOpen = false;
 nLockCounter= 0;
 m_isWritable= false;
+mbDontFlushOnClose  = false;
 pInstanceData.reset( new StreamData );
 
 SetBufferSize( 8192 );
@@ -377,7 +379,8 @@ void SvFileStream::Close()
 nLockCounter = 1;
 UnlockFile();
 }
-Flush();
+if ( !mbDontFlushOnClose )
+Flush();
 CloseHandle( pInstanceData->hFile );
 }
 bIsOpen = false;
diff --git a/unotools/source/ucbhelper/tempfile.cxx 
b/unotools/source/ucbhelper/tempfile.cxx
index c63287efe114..25c15920d52b 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -386,6 +386,9 @@ TempFile::TempFile(TempFile && other) noexcept :
 
 TempFile::~TempFile()
 {
+// if we're going to delete this file, no point in flushing it when closing
+if (pStream && bKillingFileEnabled && !aName.isEmpty())
+static_cast(pStream.get())->SetDontFlushOnClose(true);
 pStream.reset();
 if ( bKillingFileEnabled )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2021-06-22 Thread Noel Grandin (via logerrit)
 include/tools/wldcrd.hxx |   10 +-
 tools/source/fsys/wldcrd.cxx |9 -
 2 files changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 990b2cb056788f7f412656a303456d90c003cf83
Author: Noel Grandin 
AuthorDate: Mon Jun 21 13:00:07 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Jun 22 08:41:58 2021 +0200

simplify and improve Wildcard

it is faster to just process OUString data, rather than perform
expensive conversion to OString and back again.

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

diff --git a/include/tools/wldcrd.hxx b/include/tools/wldcrd.hxx
index fd127a30a1af..b50bbcd11fc9 100644
--- a/include/tools/wldcrd.hxx
+++ b/include/tools/wldcrd.hxx
@@ -30,10 +30,10 @@
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC WildCard
 {
 private:
-OString aWildString;
+OUString aWildString;
 char cSepSymbol;
 
-static bool ImpMatch( const char *pWild, const char *pStr );
+static bool ImpMatch( const sal_Unicode *pWild, const sal_Unicode *pStr );
 
 public:
 WildCard()
@@ -43,19 +43,19 @@ public:
 }
 
 WildCard(std::u16string_view rWildCard, const char cSeparator = '\0')
-: aWildString(OUStringToOString(rWildCard, 
osl_getThreadTextEncoding()))
+: aWildString(rWildCard)
 , cSepSymbol(cSeparator)
 {
 }
 
 OUString getGlob() const
 {
-return OStringToOUString(aWildString, osl_getThreadTextEncoding());
+return aWildString;
 }
 
 void setGlob(std::u16string_view rString)
 {
-aWildString = OUStringToOString(rString, osl_getThreadTextEncoding());
+aWildString = rString;
 }
 
 bool Matches( std::u16string_view rStr ) const;
diff --git a/tools/source/fsys/wldcrd.cxx b/tools/source/fsys/wldcrd.cxx
index 7608549665ca..6e0259696aca 100644
--- a/tools/source/fsys/wldcrd.cxx
+++ b/tools/source/fsys/wldcrd.cxx
@@ -25,7 +25,7 @@
  * '?' in pWild mean match exactly one character.
  *
  */
-bool WildCard::ImpMatch( const char *pWild, const char *pStr )
+bool WildCard::ImpMatch( const sal_Unicode *pWild, const sal_Unicode *pStr )
 {
 intpos=0;
 intflag=0;
@@ -88,8 +88,7 @@ bool WildCard::ImpMatch( const char *pWild, const char *pStr )
 
 bool WildCard::Matches( std::u16string_view rString ) const
 {
-OString aTmpWild = aWildString;
-OString aString(OUStringToOString(rString, osl_getThreadTextEncoding()));
+OUString aTmpWild = aWildString;
 
 sal_Int32 nSepPos;
 
@@ -98,13 +97,13 @@ bool WildCard::Matches( std::u16string_view rString ) const
 while ( (nSepPos = aTmpWild.indexOf(cSepSymbol)) != -1 )
 {
 // Check all split wildcards
-if ( ImpMatch( aTmpWild.copy( 0, nSepPos ).getStr(), 
aString.getStr() ) )
+if ( ImpMatch( aTmpWild.subView( 0, nSepPos ).data(), 
rString.data() ) )
 return true;
 aTmpWild = aTmpWild.copy(nSepPos + 1); // remove separator
 }
 }
 
-return ImpMatch( aTmpWild.getStr(), aString.getStr() );
+return ImpMatch( aTmpWild.getStr(), rString.data() );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2021-06-19 Thread Noel Grandin (via logerrit)
 include/tools/stream.hxx   |2 +-
 tools/source/stream/stream.cxx |9 -
 2 files changed, 1 insertion(+), 10 deletions(-)

New commits:
commit 5c59e061c6271cfe2f8ec12ba21de50e71bd9ef4
Author: Noel Grandin 
AuthorDate: Sat Jun 19 15:45:27 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 19 21:24:00 2021 +0200

SvMemoryStream::GetSize can be more efficient

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index b55a45ff3022..f99b09955368 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -658,7 +658,7 @@ public:
 
 virtual voidResetError() override;
 
-sal_uInt64  GetSize();
+sal_uInt64  GetSize() { return TellEnd(); }
 std::size_t GetEndOfData() const { return nEndOfData; }
 const void* GetData() { Flush(); return pBuf; }
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 04ddd2cba111..515f3a1657ab 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1673,15 +1673,6 @@ SvMemoryStream::~SvMemoryStream()
 }
 }
 
-sal_uInt64 SvMemoryStream::GetSize()
-{
-Flush();
-sal_uInt64 const nTemp = Tell();
-sal_uInt64 const nLength = Seek( STREAM_SEEK_TO_END );
-Seek( nTemp );
-return nLength;
-}
-
 void SvMemoryStream::SetBuffer( void* pNewBuf, std::size_t nCount,
  std::size_t nEOF )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2021-01-06 Thread Noel Grandin (via logerrit)
 include/tools/bigint.hxx|   30 
 tools/source/generic/bigint.cxx |   59 ++--
 2 files changed, 34 insertions(+), 55 deletions(-)

New commits:
commit 33b8f7c10baead5fdd24d9b68caab54052bd00ba
Author: Noel Grandin 
AuthorDate: Wed Jan 6 10:41:22 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Jan 6 17:29:36 2021 +0100

bIsBig member is redundant

we can just use nLen != 0 to get the same information

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

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index 3299d56c5374..14efb7e69248 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -33,9 +33,8 @@ private:
 sal_Int32   nVal;
 sal_uInt16  nNum[MAX_DIGITS];
 };
-sal_uInt8   nLen: 5;// current length
-boolbIsNeg  : 1,// Is Sign negative?
-bIsBig  : 1;// if true , value is in nNum array
+sal_uInt8   nLen: 5;// current length, if 0, data is in 
nVal, otherwise data is in nNum
+boolbIsNeg  : 1;// Is Sign negative?
 
 TOOLS_DLLPRIVATE void MakeBigInt(BigInt const &);
 TOOLS_DLLPRIVATE void Normalize();
@@ -54,7 +53,6 @@ public:
 : nVal(0)
 , nLen(0)
 , bIsNeg(false)
-, bIsBig(false)
 {
 }
 
@@ -62,7 +60,6 @@ public:
 : nVal(nValue)
 , nLen(0)
 , bIsNeg(false)
-, bIsBig(false)
 {
 }
 
@@ -71,7 +68,6 @@ public:
 : nVal(nValue)
 , nLen(0)
 , bIsNeg(false)
-, bIsBig(false)
 {
 }
 #endif
@@ -93,7 +89,7 @@ public:
 
 boolIsNeg() const;
 boolIsZero() const;
-boolIsLong() const { return !bIsBig; }
+boolIsLong() const { return nLen == 0; }
 
 voidAbs();
 
@@ -127,7 +123,7 @@ public:
 
 inline BigInt::operator sal_Int16() const
 {
-if ( !bIsBig && nVal >= SAL_MIN_INT16 && nVal <= SAL_MAX_INT16 )
+if ( nLen == 0 && nVal >= SAL_MIN_INT16 && nVal <= SAL_MAX_INT16 )
 return static_cast(nVal);
 assert(false && "out of range");
 return 0;
@@ -135,7 +131,7 @@ inline BigInt::operator sal_Int16() const
 
 inline BigInt::operator sal_uInt16() const
 {
-if ( !bIsBig && nVal >= 0 && nVal <= SAL_MAX_UINT16 )
+if ( nLen == 0 && nVal >= 0 && nVal <= SAL_MAX_UINT16 )
 return static_cast(nVal);
 assert(false && "out of range");
 return 0;
@@ -143,7 +139,7 @@ inline BigInt::operator sal_uInt16() const
 
 inline BigInt::operator sal_Int32() const
 {
-if (!bIsBig)
+if (nLen == 0)
 return nVal;
 assert(false && "out of range");
 return 0;
@@ -151,7 +147,7 @@ inline BigInt::operator sal_Int32() const
 
 inline BigInt::operator sal_uInt32() const
 {
-if ( !bIsBig && nVal >= 0 )
+if ( nLen == 0 && nVal >= 0 )
 return static_cast(nVal);
 assert(false && "out of range");
 return 0;
@@ -161,7 +157,7 @@ inline BigInt::operator sal_uInt32() const
 inline BigInt::operator tools::Long() const
 {
 // Clamp to int32 since long is int32 on Windows.
-if (!bIsBig)
+if (nLen == 0)
 return nVal;
 assert(false && "out of range");
 return 0;
@@ -170,15 +166,15 @@ inline BigInt::operator tools::Long() const
 
 inline BigInt& BigInt::operator =( sal_Int32 nValue )
 {
-bIsBig = false;
-nVal   = nValue;
+nLen = 0;
+nVal = nValue;
 
 return *this;
 }
 
 inline bool BigInt::IsNeg() const
 {
-if ( !bIsBig )
+if ( nLen == 0 )
 return (nVal < 0);
 else
 return bIsNeg;
@@ -186,7 +182,7 @@ inline bool BigInt::IsNeg() const
 
 inline bool BigInt::IsZero() const
 {
-if ( bIsBig )
+if ( nLen != 0 )
 return false;
 else
 return (nVal == 0);
@@ -194,7 +190,7 @@ inline bool BigInt::IsZero() const
 
 inline void BigInt::Abs()
 {
-if ( bIsBig )
+if ( nLen != 0 )
 bIsNeg = false;
 else if ( nVal < 0 )
 nVal = -nVal;
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 6616ef76f423..5c8c7771a2c5 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -41,7 +41,7 @@ const sal_Int32 MY_MINLONG  = -MY_MAXLONG;
 // TODO: Needs conversion to sal_uInt16/INT16/sal_uInt32/sal_Int32
 void BigInt::MakeBigInt( const BigInt& rVal )
 {
-if ( rVal.bIsBig )
+if ( rVal.nLen != 0 )
 {
 memcpy( static_cast(this), static_cast(), 
sizeof( BigInt ) );
 while ( nLen > 1 && nNum[nLen-1] == 0 )
@@ -50,7 +50,6 @@ void BigInt::MakeBigInt( const BigInt& rVal )
 else
 {
 nVal = rVal.nVal;
-bIsBig = true;
 sal_uInt32 nTmp;
 if (nVal < 0)
 {
@@ -74,7 +73,7 @@ void 

[Libreoffice-commits] core.git: include/tools tools/source

2020-12-24 Thread Stephan Bergmann (via logerrit)
 include/tools/bigint.hxx|   54 +++-
 tools/source/generic/bigint.cxx |   77 
 2 files changed, 37 insertions(+), 94 deletions(-)

New commits:
commit ad9e04321df25824d2288a2ef1f4275f070f1cf7
Author: Stephan Bergmann 
AuthorDate: Thu Dec 24 14:23:34 2020 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Dec 24 22:48:15 2020 +0100

Revert "add sal*Int64 conversions to BigInt"

This reverts commit 5dae4238ea6e21df42f4437a43d152954fc494fd, which appears 
to
have ambiguitiy problems not only on Windows, but generally with 32-bit 
builds
like :

> 
/home/tdf/lode/jenkins/workspace/android_x86/tools/source/generic/bigint.cxx:501:18:
 error: conversion from 'int' to 'const BigInt' is ambiguous
> *this *= 10;
>  ^~
> 
/home/tdf/lode/jenkins/workspace/android_x86/include/tools/bigint.hxx:58:5: 
note: candidate constructor
> BigInt(sal_Int32 nValue)
> ^
> 
/home/tdf/lode/jenkins/workspace/android_x86/include/tools/bigint.hxx:66:5: 
note: candidate constructor
> BigInt( double nVal );
> ^
> 
/home/tdf/lode/jenkins/workspace/android_x86/include/tools/bigint.hxx:67:5: 
note: candidate constructor
> BigInt( sal_uInt32 nVal );
> ^
> 
/home/tdf/lode/jenkins/workspace/android_x86/include/tools/bigint.hxx:68:5: 
note: candidate constructor
> BigInt( sal_Int64 nVal );
> ^
> 
/home/tdf/lode/jenkins/workspace/android_x86/include/tools/bigint.hxx:69:5: 
note: candidate constructor
> BigInt( sal_uInt64 nVal );
> ^

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

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index ecf7ba05b96a..a8d8575fb53b 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -63,23 +63,30 @@ public:
 {
 }
 
+#if SAL_TYPES_SIZEOFLONG == 4
+BigInt(int nValue)
+: nVal(nValue)
+, nLen(0)
+, bIsNeg(false)
+, bIsBig(false)
+{
+}
+#endif
+
 BigInt( double nVal );
 BigInt( sal_uInt32 nVal );
 BigInt( sal_Int64 nVal );
-BigInt( sal_uInt64 nVal );
 BigInt( const BigInt& rBigInt );
 BigInt( const OUString& rString );
-// for some conversions, MSVC does not see int as being equivalent to sal_Int*
-#ifdef _WIN32
-BigInt( int nVal ) : BigInt(static_cast(nVal)) {}
-#endif
-inline operator sal_Int16() const;
-inline operator sal_uInt16() const;
-inline operator sal_Int32() const;
+
+operatorsal_Int16() const;
+operatorsal_uInt16() const;
+operatorsal_Int32() const;
 operatorsal_uInt32() const;
-operatorsal_Int64() const;
-operatorsal_uInt64() const;
 operatordouble() const;
+#if SAL_TYPES_SIZEOFPOINTER == 8
+operatortools::Long() const;
+#endif
 
 boolIsNeg() const;
 boolIsZero() const;
@@ -94,13 +101,7 @@ public:
 BigInt& operator /=( const BigInt& rVal );
 BigInt& operator %=( const BigInt& rVal );
 
-// for some conversions, MSVC does not see int as being equivalent to sal_Int*
-#ifdef _WIN32
-inline BigInt&  operator  =( int nValue ) { return 
operator=(static_cast(nValue)); }
-#endif
-inline BigInt&  operator  =( sal_Int32 nValue );
-inline BigInt&  operator  =( sal_Int64 nValue ) { return *this = 
BigInt(nValue); }
-inline BigInt&  operator  =( sal_uInt64 nValue ) { return *this = 
BigInt(nValue); }
+BigInt& operator  =( sal_Int32 nValue );
 
 friend inline   BigInt operator +( const BigInt& rVal1, const BigInt& 
rVal2 );
 friend inline   BigInt operator -( const BigInt& rVal1, const BigInt& 
rVal2 );
@@ -142,6 +143,25 @@ inline BigInt::operator sal_Int32() const
 return 0;
 }
 
+inline BigInt::operator sal_uInt32() const
+{
+if ( !bIsBig && nVal >= 0 )
+return static_cast(nVal);
+assert(false && "out of range");
+return 0;
+}
+
+#if SAL_TYPES_SIZEOFPOINTER == 8
+inline BigInt::operator tools::Long() const
+{
+// Clamp to int32 since long is int32 on Windows.
+if (!bIsBig)
+return nVal;
+assert(false && "out of range");
+return 0;
+}
+#endif
+
 inline BigInt& BigInt::operator =( sal_Int32 nValue )
 {
 bIsBig = false;
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 1239868b1432..62350a30c311 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -594,83 +594,6 @@ BigInt::BigInt( sal_Int64 nValue )
 }
 }
 
-BigInt::BigInt( sal_uInt64 nValue )
-: nVal(0)
-{
-bIsNeg = false;
-nLen = 0;
-
-if (nValue <= SAL_MAX_INT32)
-{
-bIsBig = false;
-

[Libreoffice-commits] core.git: include/tools tools/source

2020-12-24 Thread Noel Grandin (via logerrit)
 include/tools/bigint.hxx|   54 
 tools/source/generic/bigint.cxx |   77 
 2 files changed, 94 insertions(+), 37 deletions(-)

New commits:
commit 5dae4238ea6e21df42f4437a43d152954fc494fd
Author: Noel Grandin 
AuthorDate: Wed Dec 23 10:57:00 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu Dec 24 12:00:35 2020 +0100

add sal*Int64 conversions to BigInt

we have the capability, so lets use it

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

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index a8d8575fb53b..ecf7ba05b96a 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -63,30 +63,23 @@ public:
 {
 }
 
-#if SAL_TYPES_SIZEOFLONG == 4
-BigInt(int nValue)
-: nVal(nValue)
-, nLen(0)
-, bIsNeg(false)
-, bIsBig(false)
-{
-}
-#endif
-
 BigInt( double nVal );
 BigInt( sal_uInt32 nVal );
 BigInt( sal_Int64 nVal );
+BigInt( sal_uInt64 nVal );
 BigInt( const BigInt& rBigInt );
 BigInt( const OUString& rString );
-
-operatorsal_Int16() const;
-operatorsal_uInt16() const;
-operatorsal_Int32() const;
+// for some conversions, MSVC does not see int as being equivalent to sal_Int*
+#ifdef _WIN32
+BigInt( int nVal ) : BigInt(static_cast(nVal)) {}
+#endif
+inline operator sal_Int16() const;
+inline operator sal_uInt16() const;
+inline operator sal_Int32() const;
 operatorsal_uInt32() const;
+operatorsal_Int64() const;
+operatorsal_uInt64() const;
 operatordouble() const;
-#if SAL_TYPES_SIZEOFPOINTER == 8
-operatortools::Long() const;
-#endif
 
 boolIsNeg() const;
 boolIsZero() const;
@@ -101,7 +94,13 @@ public:
 BigInt& operator /=( const BigInt& rVal );
 BigInt& operator %=( const BigInt& rVal );
 
-BigInt& operator  =( sal_Int32 nValue );
+// for some conversions, MSVC does not see int as being equivalent to sal_Int*
+#ifdef _WIN32
+inline BigInt&  operator  =( int nValue ) { return 
operator=(static_cast(nValue)); }
+#endif
+inline BigInt&  operator  =( sal_Int32 nValue );
+inline BigInt&  operator  =( sal_Int64 nValue ) { return *this = 
BigInt(nValue); }
+inline BigInt&  operator  =( sal_uInt64 nValue ) { return *this = 
BigInt(nValue); }
 
 friend inline   BigInt operator +( const BigInt& rVal1, const BigInt& 
rVal2 );
 friend inline   BigInt operator -( const BigInt& rVal1, const BigInt& 
rVal2 );
@@ -143,25 +142,6 @@ inline BigInt::operator sal_Int32() const
 return 0;
 }
 
-inline BigInt::operator sal_uInt32() const
-{
-if ( !bIsBig && nVal >= 0 )
-return static_cast(nVal);
-assert(false && "out of range");
-return 0;
-}
-
-#if SAL_TYPES_SIZEOFPOINTER == 8
-inline BigInt::operator tools::Long() const
-{
-// Clamp to int32 since long is int32 on Windows.
-if (!bIsBig)
-return nVal;
-assert(false && "out of range");
-return 0;
-}
-#endif
-
 inline BigInt& BigInt::operator =( sal_Int32 nValue )
 {
 bIsBig = false;
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 62350a30c311..1239868b1432 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -594,6 +594,83 @@ BigInt::BigInt( sal_Int64 nValue )
 }
 }
 
+BigInt::BigInt( sal_uInt64 nValue )
+: nVal(0)
+{
+bIsNeg = false;
+nLen = 0;
+
+if (nValue <= SAL_MAX_INT32)
+{
+bIsBig = false;
+nVal   = static_cast(nValue);
+}
+else
+{
+bIsBig  = true;
+for (int i = 0; (i != sizeof(sal_uInt64) / 2) && (nValue != 0); ++i)
+{
+nNum[i] = static_cast(nValue & 0xUL);
+nValue = nValue >> 16;
+++nLen;
+}
+}
+}
+
+BigInt::operator sal_uInt32() const
+{
+if ( !bIsBig )
+{
+assert(nVal >= 0 && "out of range");
+return static_cast(nVal);
+}
+else
+{
+assert(nLen <= 2 && "out of range");
+assert(!bIsNeg && "out of range");
+
+int i = nLen-1;
+sal_uInt32 nRet = nNum[i];
+
+while ( i )
+{
+nRet = nRet << 16;
+i--;
+nRet |= nNum[i];
+}
+
+return nRet;
+}
+}
+
+BigInt::operator sal_Int64() const
+{
+if ( !bIsBig )
+{
+return nVal;
+}
+else
+{
+assert(nLen <= 4 && "out of range");
+assert((nLen < 4 || nNum[4] <= SAL_MAX_INT16) && "out of range");
+
+int i = nLen-1;
+sal_Int64 nRet = nNum[i];
+
+while ( i )
+{
+nRet = nRet << 16;
+i--;
+nRet |= nNum[i];
+}
+

[Libreoffice-commits] core.git: include/tools tools/source vcl/source

2020-12-02 Thread Szymon Kłos (via logerrit)
 include/tools/json_writer.hxx |3 ++
 tools/source/misc/json_writer.cxx |   49 +++---
 vcl/source/control/combobox.cxx   |   18 +++--
 vcl/source/control/listbox.cxx|   10 +++
 vcl/source/window/toolbox2.cxx|4 +--
 vcl/source/window/window.cxx  |4 +--
 6 files changed, 56 insertions(+), 32 deletions(-)

New commits:
commit 7fc2fe5c612f95b9624f49b5fdea2d3c8c94caf1
Author: Szymon Kłos 
AuthorDate: Tue Nov 24 15:03:27 2020 +0100
Commit: Szymon Kłos 
CommitDate: Thu Dec 3 08:45:24 2020 +0100

jsdialog: fix arrays in JsonWriter output

Change-Id: I5638b1b02afcdd57b16b60d83d3d15da45866060
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107066
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 10e1a3a7aafc..440fedccf45e 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -64,6 +64,8 @@ public:
 void put(const char* pPropName, bool);
 void put(const char* pPropName, double);
 
+void putSimpleValue(const OUString& rPropValue);
+
 /// This assumes that this data belongs at this point in the stream, and 
is valid, and properly encoded
 void putRaw(const rtl::OStringBuffer&);
 
@@ -82,6 +84,7 @@ private:
 void endStruct();
 void addCommaBeforeField();
 void reallocBuffer(int noMoreBytesRequired);
+void writeEscapedOUString(const OUString& rPropVal);
 
 // this part inline to speed up the fast path
 inline void ensureSpace(int noMoreBytesRequired)
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index 1ccee8569480..a0e0280b840e 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -120,21 +120,8 @@ void JsonWriter::endStruct()
 mbFirstFieldInNode = false;
 }
 
-void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
+void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
 {
-auto nPropNameLength = strlen(pPropName);
-auto nWorstCasePropValLength = rPropVal.getLength() * 2;
-ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
-
-addCommaBeforeField();
-
-*mPos = '"';
-++mPos;
-memcpy(mPos, pPropName, nPropNameLength);
-mPos += nPropNameLength;
-memcpy(mPos, "\": \"", 4);
-mPos += 4;
-
 // Convert from UTF-16 to UTF-8 and perform escaping
 for (int i = 0; i < rPropVal.getLength(); ++i)
 {
@@ -175,6 +162,24 @@ void JsonWriter::put(const char* pPropName, const 
OUString& rPropVal)
 ++mPos;
 }
 }
+}
+
+void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
+{
+auto nPropNameLength = strlen(pPropName);
+auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
+
+addCommaBeforeField();
+
+*mPos = '"';
+++mPos;
+memcpy(mPos, pPropName, nPropNameLength);
+mPos += nPropNameLength;
+memcpy(mPos, "\": \"", 4);
+mPos += 4;
+
+writeEscapedOUString(rPropVal);
 
 *mPos = '"';
 ++mPos;
@@ -332,6 +337,22 @@ void JsonWriter::put(const char* pPropName, bool nPropVal)
 mPos += strlen(pVal);
 }
 
+void JsonWriter::putSimpleValue(const OUString& rPropVal)
+{
+auto nWorstCasePropValLength = rPropVal.getLength() * 2;
+ensureSpace(nWorstCasePropValLength + 4);
+
+addCommaBeforeField();
+
+*mPos = '"';
+++mPos;
+
+writeEscapedOUString(rPropVal);
+
+*mPos = '"';
+++mPos;
+}
+
 void JsonWriter::putRaw(const rtl::OStringBuffer& rRawBuf)
 {
 ensureSpace(rRawBuf.getLength() + 2);
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 666feb9e3216..89bf43b075f7 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1544,18 +1544,20 @@ void ComboBox::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
 {
 Control::DumpAsPropertyTree(rJsonWriter);
 
-auto entriesNode = rJsonWriter.startNode("entries");
-for (int i = 0; i < GetEntryCount(); ++i)
 {
-auto entryNode = rJsonWriter.startNode("");
-rJsonWriter.put("", GetEntry(i));
+auto entriesNode = rJsonWriter.startArray("entries");
+for (int i = 0; i < GetEntryCount(); ++i)
+{
+rJsonWriter.putSimpleValue(GetEntry(i));
+}
 }
 
-auto selectedNode = rJsonWriter.startNode("selectedEntries");
-for (int i = 0; i < GetSelectedEntryCount(); ++i)
 {
-auto entryNode = rJsonWriter.startNode("");
-rJsonWriter.put("", GetSelectedEntryPos(i));
+auto selectedNode = rJsonWriter.startArray("selectedEntries");
+for (int i = 0; i < GetSelectedEntryCount(); ++i)
+{
+
rJsonWriter.putSimpleValue(OUString::number(GetSelectedEntryPos(i)));
+}
 }
 
 rJsonWriter.put("selectedCount", GetSelectedEntryCount());
diff 

[Libreoffice-commits] core.git: include/tools tools/source

2020-11-20 Thread dante (via logerrit)
 include/tools/color.hxx|   21 -
 tools/source/generic/color.cxx |   39 +++
 2 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit fcc9128aabb56d521e71e3e537d895e640c86004
Author: dante 
AuthorDate: Fri Nov 20 12:33:57 2020 +0100
Commit: Noel Grandin 
CommitDate: Sat Nov 21 07:17:26 2020 +0100

Changes to the color class

Before colors could be only converted to string rrggbb. Now also supports 
RRGGBB. It can also be converted back into a color.

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

diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index dfa84d255dbc..99966c65d779 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -333,6 +333,19 @@ public:
   */
 static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 
nBrightness);
 
+/** Converts a string into a color. Supports:
+  * #RRGGBB
+  * #rrggbb
+  * #RGB
+  * #rgb
+  * RRGGBB
+  * rrggbb
+  * RGB
+  * rgb
+  * If fails returns Color().
+  */
+static Color STRtoRGB(const OUString& colorname);
+
 /** Color space conversion tools
   * @param nHue
   * @param nSaturation
@@ -340,12 +353,18 @@ public:
   */
 void RGBtoHSB(sal_uInt16& nHue, sal_uInt16& nSaturation, sal_uInt16& 
nBrightness) const;
 
-/* Return color as RGB hex string
+/* Return color as RGB hex string: rrggbb
  * for example "00ff00" for green color
  * @return hex string
  */
 OUString AsRGBHexString() const;
 
+/* Return color as RGB hex string: RRGGBB
+ * for example "00FF00" for green color
+ * @return hex string
+ */
+OUString AsRGBHEXString() const;
+
 /* get ::basegfx::BColor from this color
  * @return basegfx color
  */
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 2b7c5cc35102..cf4e084b722f 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -158,6 +158,38 @@ Color Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, 
sal_uInt16 nBri )
 return Color( cR, cG, cB );
 }
 
+Color Color::STRtoRGB(const OUString& colorname)
+{
+Color col;
+if(colorname.isEmpty()) return col;
+
+switch(colorname.getLength()){
+case 7:
+col.mValue = colorname.copy(1,6).toUInt32(16);
+break;
+case 6:
+col.mValue = colorname.toUInt32(16);
+break;
+case 4:
+{
+sal_Unicode data[6] = { colorname[1], colorname[1], colorname[2],
+ colorname[2], colorname[3], colorname[3] 
};
+col.mValue = OUString(data,6).toUInt32(16);
+break;
+}
+case 3:
+{
+sal_Unicode data[6] = { colorname[0], colorname[0], colorname[1],
+ colorname[1], colorname[2], colorname[2] 
};
+col.mValue = OUString(data,6).toUInt32(16);
+break;
+}
+default:
+break;
+}
+return col;
+}
+
 OUString Color::AsRGBHexString() const
 {
 std::stringstream ss;
@@ -165,6 +197,13 @@ OUString Color::AsRGBHexString() const
 return OUString::createFromAscii(ss.str().c_str());
 }
 
+OUString Color::AsRGBHEXString() const
+{
+std::stringstream ss;
+ss << std::hex << std::uppercase << std::setfill ('0') << std::setw(6) << 
sal_uInt32(GetRGBColor());
+return OUString::createFromAscii(ss.str().c_str());
+}
+
 void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
 {
 if (n100thPercent == 0)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2020-11-12 Thread Mike Kaganski (via logerrit)
 include/tools/bigint.hxx|4 +
 tools/source/generic/bigint.cxx |  100 
 2 files changed, 24 insertions(+), 80 deletions(-)

New commits:
commit 8927bea9fafae63898f1d6099af7c305c063a067
Author: Mike Kaganski 
AuthorDate: Thu Nov 12 12:23:41 2020 +0200
Commit: Mike Kaganski 
CommitDate: Thu Nov 12 19:14:41 2020 +0100

Simplify comparison operators

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

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index a07ba53d7f92..6683f07e3121 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -114,7 +114,7 @@ public:
 TOOLS_DLLPUBLIC friend  bool operator==( const BigInt& rVal1, 
const BigInt& rVal2 );
 friend inline   bool operator!=( const BigInt& rVal1, const BigInt& rVal2 
);
 TOOLS_DLLPUBLIC friend  bool operator< ( const BigInt& rVal1, 
const BigInt& rVal2 );
-TOOLS_DLLPUBLIC friend  bool operator> ( const BigInt& rVal1, 
const BigInt& rVal2 );
+friend inline   bool operator> ( const BigInt& rVal1, const BigInt& rVal2 
);
 friend inline   bool operator<=( const BigInt& rVal1, const BigInt& rVal2 
);
 friend inline   bool operator>=( const BigInt& rVal1, const BigInt& rVal2 
);
 
@@ -226,6 +226,8 @@ inline bool operator!=( const BigInt& rVal1, const BigInt& 
rVal2 )
 return !(rVal1 == rVal2);
 }
 
+inline bool operator>(const BigInt& rVal1, const BigInt& rVal2) { return rVal2 
< rVal1; }
+
 inline bool operator<=( const BigInt& rVal1, const BigInt& rVal2 )
 {
 return !( rVal1 > rVal2);
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 4a1ddfff391e..d90ac2447fa1 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -22,7 +22,7 @@
 #include 
 #include 
 
-
+#include 
 #include 
 
 /**
@@ -822,90 +822,32 @@ BigInt& BigInt::operator%=( const BigInt& rVal )
 
 bool operator==( const BigInt& rVal1, const BigInt& rVal2 )
 {
-if ( rVal1.bIsBig || rVal2.bIsBig )
-{
-BigInt nA, nB;
-nA.MakeBigInt( rVal1 );
-nB.MakeBigInt( rVal2 );
-if ( nA.bIsNeg == nB.bIsNeg )
-{
-if ( nA.nLen == nB.nLen )
-{
-int i;
-for ( i = nA.nLen - 1; i > 0 && nA.nNum[i] == nB.nNum[i]; i-- )
-{
-}
-
-return nA.nNum[i] == nB.nNum[i];
-}
-return false;
-}
-return false;
-}
-return rVal1.nVal == rVal2.nVal;
+if (!rVal1.bIsBig && !rVal2.bIsBig)
+return rVal1.nVal == rVal2.nVal;
+
+BigInt nA, nB;
+nA.MakeBigInt(rVal1);
+nB.MakeBigInt(rVal2);
+return nA.bIsNeg == nB.bIsNeg && nA.nLen == nB.nLen
+   && std::equal(nA.nNum, nA.nNum + nA.nLen, nB.nNum);
 }
 
 bool operator<( const BigInt& rVal1, const BigInt& rVal2 )
 {
-if ( rVal1.bIsBig || rVal2.bIsBig )
-{
-BigInt nA, nB;
-nA.MakeBigInt( rVal1 );
-nB.MakeBigInt( rVal2 );
-if ( nA.bIsNeg == nB.bIsNeg )
-{
-if ( nA.nLen == nB.nLen )
-{
-int i;
-for ( i = nA.nLen - 1; i > 0 && nA.nNum[i] == nB.nNum[i]; i-- )
-{
-}
+if (!rVal1.bIsBig && !rVal2.bIsBig)
+return rVal1.nVal < rVal2.nVal;
 
-if ( nA.bIsNeg )
-return nA.nNum[i] > nB.nNum[i];
-else
-return nA.nNum[i] < nB.nNum[i];
-}
-if ( nA.bIsNeg )
-return nA.nLen > nB.nLen;
-else
-return nA.nLen < nB.nLen;
-}
+BigInt nA, nB;
+nA.MakeBigInt(rVal1);
+nB.MakeBigInt(rVal2);
+if (nA.bIsNeg != nB.bIsNeg)
 return !nB.bIsNeg;
-}
-return rVal1.nVal < rVal2.nVal;
-}
-
-bool operator >(const BigInt& rVal1, const BigInt& rVal2 )
-{
-if ( rVal1.bIsBig || rVal2.bIsBig )
-{
-BigInt nA, nB;
-nA.MakeBigInt( rVal1 );
-nB.MakeBigInt( rVal2 );
-if ( nA.bIsNeg == nB.bIsNeg )
-{
-if ( nA.nLen == nB.nLen )
-{
-int i;
-for ( i = nA.nLen - 1; i > 0 && nA.nNum[i] == nB.nNum[i]; i-- )
-{
-}
-
-if ( nA.bIsNeg )
-return nA.nNum[i] < nB.nNum[i];
-else
-return nA.nNum[i] > nB.nNum[i];
-}
-if ( nA.bIsNeg )
-return nA.nLen < nB.nLen;
-else
-return nA.nLen > nB.nLen;
-}
-return !nA.bIsNeg;
-}
-
-return rVal1.nVal > rVal2.nVal;
+if (nA.nLen != nB.nLen)
+return nA.bIsNeg ? (nA.nLen > nB.nLen) : (nA.nLen < nB.nLen);
+int i = nA.nLen - 1;

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

2020-02-19 Thread Noel Grandin (via logerrit)
 include/tools/stream.hxx   |3 ++-
 tools/source/stream/strmwnt.cxx|7 ++-
 unotools/source/ucbhelper/tempfile.cxx |2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 27960861a66d13a3f0bb3ff8503bc9fdb53745da
Author: Noel Grandin 
AuthorDate: Tue Feb 18 18:54:43 2020 +0200
Commit: Noel Grandin 
CommitDate: Wed Feb 19 09:14:31 2020 +0100

use FILE_ATTRIBUTE_TEMPORARY on Windows for temp files

which acts as a hint to the OS that these files do not
need persistent storage.
If there is sufficient system RAM, these files will never
even hit disk.

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 0f17c37c4958..2e8fbc6771b5 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -48,6 +48,7 @@ enum class StreamMode {
 NOCREATE = 0x0004,  ///< 1 == Don't create file
 TRUNC= 0x0008,  ///< Truncate _existing_ file to zero 
length
 COPY_ON_SYMLINK  = 0x0010,  ///< copy-on-write for symlinks (Unix)
+TEMPORARY= 0x0020,  ///< temporary file attribute (Windows)
 // sharing options
 SHARE_DENYNONE   = 0x0100,
 SHARE_DENYREAD   = 0x0200,  // overrides denynone
@@ -61,7 +62,7 @@ enum class StreamMode {
 };
 namespace o3tl
 {
-template<> struct typed_flags : is_typed_flags {};
+template<> struct typed_flags : is_typed_flags {};
 }
 
 #define STREAM_SEEK_TO_BEGIN0L
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index 23fa71526447..d85ce3a0c372 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -300,13 +300,18 @@ void SvFileStream::Open( const OUString& rFilename, 
StreamMode nMode )
 nOpenAction = OPEN_EXISTING;
 }
 
+DWORD nAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS;
+
+if ( nMode & StreamMode::TEMPORARY )
+nAttributes |= FILE_ATTRIBUTE_TEMPORARY;
+
 pInstanceData->hFile = CreateFileW(
 o3tl::toW(aFilename.getStr()),
 nAccessMode,
 nShareMode,
 nullptr,
 nOpenAction,
-FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
+nAttributes,
 nullptr
 );
 
diff --git a/unotools/source/ucbhelper/tempfile.cxx 
b/unotools/source/ucbhelper/tempfile.cxx
index afda12972ac0..f6d66bdc33b6 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -420,7 +420,7 @@ SvStream* TempFile::GetStream( StreamMode eMode )
 if (!pStream)
 {
 if (!aName.isEmpty())
-pStream.reset(new SvFileStream(aName, eMode));
+pStream.reset(new SvFileStream(aName, eMode | 
StreamMode::TEMPORARY));
 else
 pStream.reset(new SvMemoryStream(nullptr, 0, eMode));
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source vcl/inc vcl/Library_vcl.mk vcl/source

2019-12-28 Thread Tomaž Vajngerl (via logerrit)
 include/tools/XmlWriter.hxx   |2 
 tools/source/xml/XmlWriter.cxx|   11 +-
 vcl/Library_vcl.mk|1 
 vcl/inc/pdf/XmpMetadata.hxx   |   47 +++
 vcl/source/gdi/pdfwriter_impl.cxx |  145 ++
 vcl/source/pdf/XmpMetadata.cxx|  159 ++
 6 files changed, 245 insertions(+), 120 deletions(-)

New commits:
commit d016e052ddf30649ad9b729b59134ce1e90a0263
Author: Tomaž Vajngerl 
AuthorDate: Thu Dec 19 20:55:16 2019 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 28 19:46:50 2019 +0100

pdf: extract XMP metadata writing and use XmlWriter

Instead of writing XMP metadata with a string buffer, change to
use XmlWriter instead. Extract XMP metadata writing into its own
class vcl::pdf::XmpMetadata.

This also needs a change to the XmlWriter to not write a classic
XML header: ''

Change-Id: I95ea0e7ba58e7c43a0c707bf9c676994210ff104
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85908
Reviewed-by: Tomaž Vajngerl 
Tested-by: Tomaž Vajngerl 

diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx
index da056c68a596..7efe3a57353a 100644
--- a/include/tools/XmlWriter.hxx
+++ b/include/tools/XmlWriter.hxx
@@ -40,7 +40,7 @@ public:
 
 ~XmlWriter();
 
-bool startDocument(sal_Int32 nIndent = 2);
+bool startDocument(sal_Int32 nIndent = 2, bool bWriteXmlHeader = true);
 void endDocument();
 
 void startElement(const OString& sName);
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index 3400a6e9d94b..a314eed6e940 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -36,11 +36,13 @@ struct XmlWriterImpl
 XmlWriterImpl(SvStream* pStream)
 : mpStream(pStream)
 , mpWriter(nullptr)
+, mbWriteXmlHeader(true)
 {
 }
 
 SvStream* const mpStream;
 xmlTextWriterPtr mpWriter;
+bool mbWriteXmlHeader;
 };
 
 XmlWriter::XmlWriter(SvStream* pStream)
@@ -54,21 +56,24 @@ XmlWriter::~XmlWriter()
 endDocument();
 }
 
-bool XmlWriter::startDocument(sal_Int32 nIndent)
+bool XmlWriter::startDocument(sal_Int32 nIndent, bool bWriteXmlHeader)
 {
+mpImpl->mbWriteXmlHeader = bWriteXmlHeader;
 xmlOutputBufferPtr xmlOutBuffer
 = xmlOutputBufferCreateIO(funcWriteCallback, funcCloseCallback, 
mpImpl->mpStream, nullptr);
 mpImpl->mpWriter = xmlNewTextWriter(xmlOutBuffer);
 if (mpImpl->mpWriter == nullptr)
 return false;
 xmlTextWriterSetIndent(mpImpl->mpWriter, nIndent);
-xmlTextWriterStartDocument(mpImpl->mpWriter, nullptr, "UTF-8", nullptr);
+if (mpImpl->mbWriteXmlHeader)
+xmlTextWriterStartDocument(mpImpl->mpWriter, nullptr, "UTF-8", 
nullptr);
 return true;
 }
 
 void XmlWriter::endDocument()
 {
-xmlTextWriterEndDocument(mpImpl->mpWriter);
+if (mpImpl->mbWriteXmlHeader)
+xmlTextWriterEndDocument(mpImpl->mpWriter);
 xmlFreeTextWriter(mpImpl->mpWriter);
 mpImpl->mpWriter = nullptr;
 }
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index b401d811f596..0bc271576da7 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -448,6 +448,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/fontsubset/sft \
 vcl/source/fontsubset/ttcr \
 vcl/source/fontsubset/xlat \
+vcl/source/pdf/XmpMetadata \
 vcl/source/uitest/logger \
 vcl/source/uitest/uiobject \
 vcl/source/uitest/uitest \
diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx
new file mode 100644
index ..d9f9cacc45b4
--- /dev/null
+++ b/vcl/inc/pdf/XmpMetadata.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_PDF_XMPMETADATA_HXX
+#define INCLUDED_VCL_INC_PDF_XMPMETADATA_HXX
+
+#include 
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+class XmpMetadata
+{
+private:
+bool mbWritten;
+std::unique_ptr mpMemoryStream;
+
+public:
+OString msTitle;
+OString msAuthor;
+OString msSubject;
+OString msProducer;
+OString msKeywords;
+sal_Int32 mnPDF_A;
+
+public:
+XmpMetadata();
+sal_uInt64 getSize();
+const void* getData();
+
+private:
+void write();
+};
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f5fb555b1f56..891d5db93a7b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -74,6 +74,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pdfwriter_impl.hxx"
 
@@ -5232,132 +5233,44 

[Libreoffice-commits] core.git: include/tools tools/source

2019-12-18 Thread Miklos Vajna (via logerrit)
 include/tools/debug.hxx  |6 +++---
 tools/source/debug/debug.cxx |4 
 2 files changed, 3 insertions(+), 7 deletions(-)

New commits:
commit fc761cb2cc343c0c0f3ca8a908a547603a029e36
Author: Miklos Vajna 
AuthorDate: Wed Dec 18 10:46:43 2019 +0100
Commit: Miklos Vajna 
CommitDate: Wed Dec 18 15:04:12 2019 +0100

tools: define DbgTestSolarMutex() unconditionally

See the discussion at , and
this came up on IRC today again.

The above change broke the invariant that you can mix product and debug
(but not dbgutil) builds. Restore this, without mandating dbgutil for
the solar mutex assert code, which is useful for plain debug builds as
well.

Change-Id: I1f8bdb114b129fc4f39f186ba917e35e346a16b5
Reviewed-on: https://gerrit.libreoffice.org/85369
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index b66a9b2866ef..c72da4d06887 100644
--- a/include/tools/debug.hxx
+++ b/include/tools/debug.hxx
@@ -34,14 +34,14 @@
 standard assert.
 */
 
-#ifndef NDEBUG
-// we want the solar mutex checking to be enabled in the assert-enabled builds 
that the QA people use
-
 typedef void (*DbgTestSolarMutexProc)();
 
 TOOLS_DLLPUBLIC void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam );
 TOOLS_DLLPUBLIC void DbgTestSolarMutex();
 
+#ifndef NDEBUG
+// we want the solar mutex checking to be enabled in the assert-enabled builds 
that the QA people use
+
 #define DBG_TESTSOLARMUTEX()   \
 do \
 {  \
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index a410b6feeaa9..7d39fdecac58 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -61,8 +61,6 @@
 #include 
 #endif
 
-#ifndef NDEBUG
-
 namespace {
 
 struct DebugData
@@ -97,8 +95,6 @@ void DbgTestSolarMutex()
 aDebugData.pDbgTestSolarMutex();
 }
 
-#endif
-
 static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any 
& caught)
 {
 auto toOString = [](OUString const & s) {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2019-12-12 Thread Stephan Bergmann (via logerrit)
 include/tools/stream.hxx|2 
 tools/source/stream/strmunx.cxx |  105 +++-
 tools/source/stream/strmwnt.cxx |   44 +---
 3 files changed, 34 insertions(+), 117 deletions(-)

New commits:
commit 2bf22c8d2642e30fdedab69b7437ae83deaec014
Author: Stephan Bergmann 
AuthorDate: Thu Dec 12 11:18:31 2019 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Dec 12 13:19:10 2019 +0100

SvFileStream::Lock/UnlockRange are only called from within SvFileStream 
itself

...and only for whole-file locking, so simplify the implementations in
strmunx.cx and strmwnt.cxx accordingly

Change-Id: I973e0ea41f246ad614232b107c8bf152073867be
Reviewed-on: https://gerrit.libreoffice.org/85039
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 33b2e986b573..0f17c37c4958 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -582,8 +582,6 @@ private:
 SvFileStream (const SvFileStream&) = delete;
 SvFileStream & operator= (const SvFileStream&) = delete;
 
-bool LockRange( sal_uInt64 nByteOffset, std::size_t nBytes );
-bool UnlockRange( sal_uInt64 nByteOffset, std::size_t nBytes );
 bool LockFile();
 void UnlockFile();
 
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 1b02435db0a3..a0cfd7c09d74 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -17,13 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
 #include 
 #include 
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -41,51 +40,9 @@ namespace {
 
 struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {};
 
-struct InternalStreamLock
-{
-sal_uInt64 m_nStartPos;
-sal_uInt64 m_nEndPos;
-SvFileStream*  m_pStream;
-osl::DirectoryItem m_aItem;
-
-InternalStreamLock( sal_uInt64, sal_uInt64, SvFileStream* );
-~InternalStreamLock();
-};
-
-struct LockList : public rtl::Static< std::vector, 
LockList > {};
-
-InternalStreamLock::InternalStreamLock(
-sal_uInt64 const nStart,
-sal_uInt64 const nEnd,
-SvFileStream* pStream ) :
-m_nStartPos( nStart ),
-m_nEndPos( nEnd ),
-m_pStream( pStream )
-{
-(void)osl::DirectoryItem::get( m_pStream->GetFileName(), m_aItem );
-#if OSL_DEBUG_LEVEL > 1
-OString aFileName(OUStringToOString(m_pStream->GetFileName(),
-  
osl_getThreadTextEncoding()));
-fprintf( stderr, "locked %s", aFileName.getStr() );
-if( m_nStartPos || m_nEndPos )
-fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
-fprintf( stderr, "\n" );
-#endif
-}
-
-InternalStreamLock::~InternalStreamLock()
-{
-#if OSL_DEBUG_LEVEL > 1
-OString aFileName(OUStringToOString(m_pStream->GetFileName(),
-  
osl_getThreadTextEncoding()));
-fprintf( stderr, "unlocked %s", aFileName.getStr() );
-if( m_nStartPos || m_nEndPos )
-fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos );
-fprintf( stderr, "\n" );
-#endif
-}
+struct Locks : public rtl::Static< std::map, Locks > {};
 
-bool lockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream* 
pStream )
+bool lockFile( SvFileStream* pStream )
 {
 osl::DirectoryItem aItem;
 if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != 
osl::FileBase::E_None )
@@ -104,12 +61,12 @@ bool lockFile( sal_uInt64 const nStart, sal_uInt64 const 
nEnd, SvFileStream* pSt
 return true;
 
 osl::MutexGuard aGuard( LockMutex::get() );
-std::vector  = LockList::get();
-for( const auto& rLock : rLockList )
+auto  = Locks::get();
+for( const auto& [rLockStream, rLockItem] : rLocks )
 {
-if( aItem.isIdenticalTo( rLock.m_aItem ) )
+if( aItem.isIdenticalTo( rLockItem ) )
 {
-StreamMode nLockMode = rLock.m_pStream->GetStreamMode();
+StreamMode nLockMode = rLockStream->GetStreamMode();
 StreamMode nNewMode = pStream->GetStreamMode();
 bool bDenyByOptions = (nLockMode & StreamMode::SHARE_DENYALL) ||
 ( (nLockMode & StreamMode::SHARE_DENYWRITE) && (nNewMode & 
StreamMode::WRITE) ) ||
@@ -117,31 +74,19 @@ bool lockFile( sal_uInt64 const nStart, sal_uInt64 const 
nEnd, SvFileStream* pSt
 
 if( bDenyByOptions )
 {
-if( rLock.m_nStartPos == 0 && rLock.m_nEndPos == 0 ) // whole 
file is already locked
-return false;
-if( nStart == 0 && nEnd == 0) // cannot lock whole file
-return false;
-
-if( ( nStart < rLock.m_nStartPos && nEnd > rLock.m_nStartPos ) 
||
-( nStart < rLock.m_nEndPos && nEnd > rLock.m_nEndPos ) )
-

[Libreoffice-commits] core.git: include/tools tools/source

2019-08-30 Thread Noel Grandin (via logerrit)
 include/tools/poly.hxx |3 ++-
 tools/source/generic/poly2.cxx |9 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 1c7fdf561bc924741a121439a6cb42f96f285b58
Author: Noel Grandin 
AuthorDate: Fri Aug 30 09:09:08 2019 +0200
Commit: Noel Grandin 
CommitDate: Fri Aug 30 11:13:09 2019 +0200

fix PolyPolygon move operator=

and add move constructor, found by loplugin:noexceptmove

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

diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index aed40ece0367..765865b5a228 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -197,6 +197,7 @@ public:
 PolyPolygon( sal_uInt16 nInitSize = 16 );
 PolyPolygon( const tools::Polygon& rPoly );
 PolyPolygon( const tools::PolyPolygon& rPolyPoly );
+PolyPolygon( tools::PolyPolygon&& rPolyPoly ) noexcept;
 ~PolyPolygon();
 
 voidInsert( const tools::Polygon& rPoly, sal_uInt16 nPos = 
POLYPOLY_APPEND );
@@ -242,7 +243,7 @@ public:
 tools::Polygon& operator[]( sal_uInt16 nPos );
 
 tools::PolyPolygon& operator=( const tools::PolyPolygon& rPolyPoly );
-tools::PolyPolygon& operator=( tools::PolyPolygon&& rPolyPoly );
+tools::PolyPolygon& operator=( tools::PolyPolygon&& rPolyPoly ) noexcept;
 booloperator==( const tools::PolyPolygon& rPolyPoly ) 
const;
 booloperator!=( const tools::PolyPolygon& rPolyPoly ) const
 { return !(PolyPolygon::operator==( rPolyPoly )); }
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index 0603a1dc8513..d37ba809f2fb 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -45,6 +45,11 @@ PolyPolygon::PolyPolygon( const tools::PolyPolygon& 
rPolyPoly )
 {
 }
 
+PolyPolygon::PolyPolygon( tools::PolyPolygon&& rPolyPoly ) noexcept
+: mpImplPolyPolygon( std::move(rPolyPoly.mpImplPolyPolygon) )
+{
+}
+
 PolyPolygon::~PolyPolygon()
 {
 }
@@ -341,9 +346,9 @@ PolyPolygon& PolyPolygon::operator=( const 
tools::PolyPolygon& rPolyPoly )
 return *this;
 }
 
-PolyPolygon& PolyPolygon::operator=( tools::PolyPolygon&& rPolyPoly )
+PolyPolygon& PolyPolygon::operator=( tools::PolyPolygon&& rPolyPoly ) noexcept
 {
-mpImplPolyPolygon = rPolyPoly.mpImplPolyPolygon;
+mpImplPolyPolygon = std::move(rPolyPoly.mpImplPolyPolygon);
 return *this;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-08-23 Thread Noel Grandin (via logerrit)
 include/tools/b3dtrans.hxx|4 ++--
 include/tools/wldcrd.hxx  |2 +-
 tools/source/generic/b3dtrans.cxx |4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 3d9f291cd336dc59d8582e349d5f9e8e86776703
Author: Noel Grandin 
AuthorDate: Fri Aug 23 10:38:09 2019 +0200
Commit: Noel Grandin 
CommitDate: Fri Aug 23 13:42:03 2019 +0200

loplugin:returnconstval in tools

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

diff --git a/include/tools/b3dtrans.hxx b/include/tools/b3dtrans.hxx
index e42c7efbb76a..2f6752e0848a 100644
--- a/include/tools/b3dtrans.hxx
+++ b/include/tools/b3dtrans.hxx
@@ -121,8 +121,8 @@ public:
 void CalcViewport();
 
 // Direct accessors for miscellaneous transformations
-const basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec);
-const basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec);
+basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec);
+basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec);
 
 static void Frustum(
 basegfx::B3DHomMatrix& rTarget,
diff --git a/include/tools/wldcrd.hxx b/include/tools/wldcrd.hxx
index 9ff2a5b8ffd6..5fc3d87e4ab5 100644
--- a/include/tools/wldcrd.hxx
+++ b/include/tools/wldcrd.hxx
@@ -44,7 +44,7 @@ public:
 {
 }
 
-const OUString getGlob() const
+OUString getGlob() const
 {
 return OStringToOUString(aWildString, osl_getThreadTextEncoding());
 }
diff --git a/tools/source/generic/b3dtrans.cxx 
b/tools/source/generic/b3dtrans.cxx
index a896e9f1b7df..b8e29be31d4a 100644
--- a/tools/source/generic/b3dtrans.cxx
+++ b/tools/source/generic/b3dtrans.cxx
@@ -334,14 +334,14 @@ void 
B3dTransformationSet::SetViewportRectangle(tools::Rectangle const & rRect,
 
 // direct access to various transformations
 
-const basegfx::B3DPoint B3dTransformationSet::WorldToEyeCoor(const 
basegfx::B3DPoint& rVec)
+basegfx::B3DPoint B3dTransformationSet::WorldToEyeCoor(const 
basegfx::B3DPoint& rVec)
 {
 basegfx::B3DPoint aVec(rVec);
 aVec *= maOrientation;
 return aVec;
 }
 
-const basegfx::B3DPoint B3dTransformationSet::EyeToWorldCoor(const 
basegfx::B3DPoint& rVec)
+basegfx::B3DPoint B3dTransformationSet::EyeToWorldCoor(const 
basegfx::B3DPoint& rVec)
 {
 basegfx::B3DPoint aVec(rVec);
 aVec *= maInvOrientation;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-15 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 3932c8184a8c93a17c0c7429d5dd9597b087e076
Author: Noel Grandin 
AuthorDate: Fri Jul 12 20:16:40 2019 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 15 09:33:15 2019 +0200

make tools::Rectangle::getWidth return 0 when empty

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 63d13e146336..9dea74be4caa 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -455,7 +455,7 @@ public:
 longgetX() const { return nLeft; }
 longgetY() const { return nTop; }
 /// Returns the difference between right and left, assuming the range 
includes one end, but not the other.
-longgetWidth() const { return nRight - nLeft; }
+longgetWidth() const;
 /// Returns the difference between bottom and top, assuming the range 
includes one end, but not the other.
 longgetHeight() const { return nBottom - nTop; }
 /// Set the left edge of the rectangle to x, preserving the width
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 3783fa347c55..5755929bd502 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -303,4 +303,9 @@ long tools::Rectangle::Bottom() const
 return nBottom == RECT_EMPTY ? nTop : nBottom;
 }
 
+/// Returns the difference between right and left, assuming the range includes 
one end, but not the other.
+long tools::Rectangle::getWidth() const
+{
+return nRight == RECT_EMPTY ? 0 : nRight - nLeft;
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-12 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 5d390df540c19b88814d22a2e8b0dab86af17541
Author: Noel Grandin 
AuthorDate: Fri Jul 12 17:06:28 2019 +0200
Commit: Noel Grandin 
CommitDate: Fri Jul 12 20:12:20 2019 +0200

make tools::Rectangle::Bottom return Top when empty

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index dd0514396567..63d13e146336 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -388,7 +388,7 @@ public:
 longLeft() const{ return nLeft;   }
 longRight() const;
 longTop() const { return nTop;}
-longBottom() const  { return nBottom; }
+longBottom() const;
 
 voidSetLeft(long v){ nLeft = v;   }
 voidSetRight(long v)   { nRight = v;  }
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 459687dc961a..3783fa347c55 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -297,4 +298,9 @@ long tools::Rectangle::Right() const
 return nRight == RECT_EMPTY ? nLeft : nRight;
 }
 
+long tools::Rectangle::Bottom() const
+{
+return nBottom == RECT_EMPTY ? nTop : nBottom;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source vcl/source

2019-07-12 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx |2 +-
 tools/source/generic/gen.cxx  |6 ++
 vcl/source/gdi/mtfxmldump.cxx |5 +++--
 3 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 1ce1c26dd98e6477139e08d1ebe89fa950ff5fb0
Author: Noel Grandin 
AuthorDate: Fri Jul 12 12:06:41 2019 +0200
Commit: Noel Grandin 
CommitDate: Fri Jul 12 17:04:02 2019 +0200

make tools::Rectangle::Right return Left when empty

I tried making this assert, but there are just too many places where we
pass around empty rectangles, so rather just return the value of nLeft,
in a similar fashion to methods like Rectangle::TopLeft

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 54a438bfa161..dd0514396567 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -386,7 +386,7 @@ public:
 Rectangle( const Point& rLT, const Size& rSize );
 
 longLeft() const{ return nLeft;   }
-longRight() const   { return nRight;  }
+longRight() const;
 longTop() const { return nTop;}
 longBottom() const  { return nBottom; }
 
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index fc927f50e41e..459687dc961a 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -20,6 +20,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -291,4 +292,9 @@ void tools::Rectangle::setY( long y )
 nTop  = y;
 }
 
+long tools::Rectangle::Right() const
+{
+return nRight == RECT_EMPTY ? nLeft : nRight;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 8c168a89d4c4..c679b08e86e6 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -459,8 +459,9 @@ void writeRectangle(tools::XmlWriter& rWriter, 
tools::Rectangle const& rRectangl
 {
 rWriter.attribute("left", rRectangle.Left());
 rWriter.attribute("top", rRectangle.Top());
-rWriter.attribute("right", rRectangle.Right());
-rWriter.attribute("bottom", rRectangle.Bottom());
+// FIXME what should we write for empty?
+rWriter.attribute("right", rRectangle.IsWidthEmpty() ? -32767 : 
rRectangle.Right());
+rWriter.attribute("bottom", rRectangle.IsHeightEmpty() ? -32767 : 
rRectangle.Bottom());
 }
 
 void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-10 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 031d30bd698117e2bcdd0df76f8b669a1e366d2c
Author: Noel Grandin 
AuthorDate: Wed Jul 10 12:32:15 2019 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 10 13:46:55 2019 +0200

make tools::Rectangle::setY respect empty state

and make non-inline so it is easy to disable this for debugging, if need
be

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 9dfab3a17019..54a438bfa161 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -461,7 +461,7 @@ public:
 /// Set the left edge of the rectangle to x, preserving the width
 voidsetX( long x );
 /// Set the top edge of the rectangle to y, preserving the height
-voidsetY( long y ) { nBottom += y - nTop;  nTop  = y; }
+voidsetY( long y );
 voidsetWidth( long n ) { nRight = nLeft + n; }
 voidsetHeight( long n ) { nBottom = nTop + n; }
 /// Returns the string representation of the rectangle, format is "x, y, 
width, height".
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index db7980ea100a..1b9e4a0d733f 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -282,5 +282,11 @@ void tools::Rectangle::setX( long x )
 nLeft = x;
 }
 
+void tools::Rectangle::setY( long y )
+{
+if (nBottom != RECT_EMPTY)
+nBottom += y - nTop;
+nTop  = y;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-10 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 1ddf8be9bcb2151157823870fd0a03e022fdad60
Author: Noel Grandin 
AuthorDate: Wed Jul 10 10:04:19 2019 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 10 12:28:19 2019 +0200

make tools::Rectangle::setX respect empty state

and make non-inline so it is easy to disable this for debugging, if need
be

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index ebe44840d964..9dfab3a17019 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -459,7 +459,7 @@ public:
 /// Returns the difference between bottom and top, assuming the range 
includes one end, but not the other.
 longgetHeight() const { return nBottom - nTop; }
 /// Set the left edge of the rectangle to x, preserving the width
-voidsetX( long x ) { nRight  += x - nLeft; nLeft = x; }
+voidsetX( long x );
 /// Set the top edge of the rectangle to y, preserving the height
 voidsetY( long y ) { nBottom += y - nTop;  nTop  = y; }
 voidsetWidth( long n ) { nRight = nLeft + n; }
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 021e421c3b80..db7980ea100a 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -275,5 +275,12 @@ long tools::Rectangle::AdjustBottom( long nVertMoveDelta )
 return nBottom;
 }
 
+void tools::Rectangle::setX( long x )
+{
+if (nRight != RECT_EMPTY)
+nRight += x - nLeft;
+nLeft = x;
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-10 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 7554ec519c49782614f474109e1962dfbb392e95
Author: Noel Grandin 
AuthorDate: Wed Jul 10 08:39:11 2019 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 10 09:58:11 2019 +0200

make tools::Rectangle::AdjustBottom respect empty state

and make non-inline so it is easy to disable this for debugging, if need
be

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index e29726a5e305..ebe44840d964 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -411,7 +411,7 @@ public:
 longAdjustLeft( long nHorzMoveDelta ) { nLeft += 
nHorzMoveDelta; return nLeft; }
 longAdjustRight( long nHorzMoveDelta );
 longAdjustTop( long nVertMoveDelta ) { nTop += 
nVertMoveDelta; return nTop; }
-longAdjustBottom( long nVertMoveDelta ) { nBottom += 
nVertMoveDelta; return nBottom; }
+longAdjustBottom( long nVertMoveDelta );
 inline void SetPos( const Point& rPoint );
 voidSetSize( const Size& rSize );
 inline Size GetSize() const;
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index d298e6be4c77..021e421c3b80 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -266,5 +266,14 @@ long tools::Rectangle::AdjustRight(long nHorzMoveDelta)
 return nRight;
 }
 
+long tools::Rectangle::AdjustBottom( long nVertMoveDelta )
+{
+if (nBottom == RECT_EMPTY)
+nBottom = nTop + nVertMoveDelta - 1;
+else
+nBottom += nVertMoveDelta;
+return nBottom;
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-10 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|2 +-
 tools/source/generic/gen.cxx |8 
 2 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit ed0f690b93d478380366d96655a3efe5848c6737
Author: Noel Grandin 
AuthorDate: Tue Jul 9 14:51:19 2019 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 10 08:33:25 2019 +0200

make tools::Rectangle::AdjustRight respect empty state

and make non-inline so it is easy to disable this for debugging, if need
be

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 897db7a25f79..e29726a5e305 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -409,7 +409,7 @@ public:
 inline void Move( long nHorzMoveDelta, long nVertMoveDelta );
 voidMove( Size const & s ) { Move(s.Width(), s.Height()); }
 longAdjustLeft( long nHorzMoveDelta ) { nLeft += 
nHorzMoveDelta; return nLeft; }
-longAdjustRight( long nHorzMoveDelta ) { nRight += 
nHorzMoveDelta; return nRight; }
+longAdjustRight( long nHorzMoveDelta );
 longAdjustTop( long nVertMoveDelta ) { nTop += 
nVertMoveDelta; return nTop; }
 longAdjustBottom( long nVertMoveDelta ) { nBottom += 
nVertMoveDelta; return nBottom; }
 inline void SetPos( const Point& rPoint );
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 020be91ac3c0..d298e6be4c77 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -257,6 +257,14 @@ void tools::Rectangle::shrink(long nShrinkBy)
 nBottom -= nShrinkBy;
 }
 
+long tools::Rectangle::AdjustRight(long nHorzMoveDelta)
+{
+if (nRight == RECT_EMPTY)
+nRight = nLeft + nHorzMoveDelta - 1;
+else
+nRight += nHorzMoveDelta;
+return nRight;
+}
 
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-07-09 Thread Noel Grandin (via logerrit)
 include/tools/gen.hxx|   10 +-
 tools/source/generic/gen.cxx |   11 +++
 2 files changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 77ca41321193ddfaa0ca05d1fa43f3b614209a61
Author: Noel Grandin 
AuthorDate: Tue Jul 9 13:33:41 2019 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 9 14:36:02 2019 +0200

make tools::Rectangle::shrink respect empty state

and make non-inline so it is easy to disable this for debugging, if need
be

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

diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 56af47582a7f..897db7a25f79 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -471,7 +471,7 @@ public:
  * Expands the rectangle in all directions by the input value.
  */
 void expand(long nExpandBy);
-inline void shrink(long nShrinkBy);
+void shrink(long nShrinkBy);
 
 /**
  * Sanitizing variants for handling data from the outside
@@ -722,14 +722,6 @@ inline Rectangle operator - ( const Rectangle& rRect, 
const Point& rPt )
 }
 }
 
-inline void tools::Rectangle::shrink(long nShrinkBy)
-{
-nLeft   += nShrinkBy;
-nTop+= nShrinkBy;
-nRight  -= nShrinkBy;
-nBottom -= nShrinkBy;
-}
-
 template< typename charT, typename traits >
 inline std::basic_ostream & operator <<(
 std::basic_ostream & stream, const tools::Rectangle& 
rectangle )
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 53bb2680c5c8..020be91ac3c0 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -247,5 +247,16 @@ void tools::Rectangle::expand(long nExpandBy)
 nBottom += nExpandBy;
 }
 
+void tools::Rectangle::shrink(long nShrinkBy)
+{
+nLeft   += nShrinkBy;
+nTop+= nShrinkBy;
+if (nRight != RECT_EMPTY)
+nRight -= nShrinkBy;
+if (nBottom != RECT_EMPTY)
+nBottom -= nShrinkBy;
+}
+
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/tools tools/source

2019-06-25 Thread Noel Grandin (via logerrit)
 include/tools/fract.hxx|   22 ++---
 tools/source/generic/fract.cxx |  173 -
 2 files changed, 80 insertions(+), 115 deletions(-)

New commits:
commit 31589bf0239679d73417902655045c48c4868016
Author: Noel Grandin 
AuthorDate: Mon Jun 24 15:02:55 2019 +0200
Commit: Noel Grandin 
CommitDate: Tue Jun 25 13:20:51 2019 +0200

tdf#94677 Calc is slow opening large CSV, improve tools::Fraction

Flatten the tools::Fraction class.

Shaves 1s off a load time of 49s

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

diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index bba143b0530d..ed1f5f0be649 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -29,14 +29,15 @@ class SvStream;
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Fraction final
 {
-struct Impl;
-
-std::unique_ptr mpImpl;
+/// these two fields form a boost::rational, but I didn't want to put more 
boost headers into the global space
+sal_Int32   mnNumerator = 0;
+sal_Int32   mnDenominator = 1;
+boolmbValid = true;
 
 public:
-Fraction();
-Fraction( const Fraction & rFrac );
-Fraction( Fraction && rFrac );
+Fraction() = default;
+Fraction( const Fraction & rFrac ) = default;
+Fraction( Fraction && rFrac ) = default;
 explicitFraction( double dVal );
 Fraction( double nNum, double nDen );
 Fraction( sal_Int64 nNum, sal_Int64 nDen );
@@ -45,9 +46,8 @@ public:
 T1 nNum, T2 nDen,
 typename std::enable_if::value && 
std::is_integral::value, int>::type = 0)
 : Fraction( sal_Int64(nNum), sal_Int64(nDen) ) {}
-~Fraction();
 
-boolIsValid() const;
+boolIsValid() const { return mbValid; }
 
 sal_Int32   GetNumerator() const;
 sal_Int32   GetDenominator() const;
@@ -58,8 +58,8 @@ public:
 #endif
 explicit operator double() const;
 
-Fraction&   operator=( const Fraction& rfrFrac );
-Fraction&   operator=( Fraction&& rfrFrac );
+Fraction&   operator=( const Fraction& rfrFrac ) = default;
+Fraction&   operator=( Fraction&& rfrFrac ) = default;
 Fraction&   operator=( double v ) { return operator=(Fraction(v)); }
 
 Fraction&   operator+=( const Fraction& rfrFrac );
@@ -85,7 +85,7 @@ public:
 TOOLS_DLLPUBLIC friend bool operator<=( const Fraction& rVal1, const 
Fraction& rVal2 );
 TOOLS_DLLPUBLIC friend bool operator>=( const Fraction& rVal1, const 
Fraction& rVal2 );
 
-TOOLS_DLLPUBLIC friend SvStream& ReadFraction( SvStream& rIStream, 
Fraction const & rFract );
+TOOLS_DLLPUBLIC friend SvStream& ReadFraction( SvStream& rIStream, 
Fraction & rFract );
 TOOLS_DLLPUBLIC friend SvStream& WriteFraction( SvStream& rOStream, const 
Fraction& rFract );
 };
 
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index e6e05dfd5dc6..3a8eb09822c8 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -39,40 +39,16 @@ static boost::rational 
rational_FromDouble(double dVal);
 
 static void rational_ReduceInaccurate(boost::rational& rRational, 
unsigned nSignificantBits);
 
-struct Fraction::Impl
-{
-boolvalid;
-boost::rational  value;
-
-Impl()
-: valid(false)
-{
-}
-Impl(const Impl&) = delete;
-Impl& operator=(const Impl&) = delete;
-};
-
-Fraction::Fraction() : mpImpl(new Impl)
-{
-mpImpl->valid = true;
-}
-
-Fraction::Fraction( const Fraction& rFrac ) : mpImpl(new Impl)
-{
-mpImpl->valid = rFrac.mpImpl->valid;
-if (mpImpl->valid)
-mpImpl->value.assign( rFrac.mpImpl->value.numerator(), 
rFrac.mpImpl->value.denominator() );
-}
-
-Fraction::Fraction( Fraction&& rFrac ) : mpImpl(std::move(rFrac.mpImpl))
+static boost::rational toRational(sal_Int32 n, sal_Int32 d)
 {
+return boost::rational(n, d);
 }
 
 // Initialized by setting nNum as nominator and nDen as denominator
 // Negative values in the denominator are invalid and cause the
 // inversion of both nominator and denominator signs
 // in order to return the correct value.
-Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : mpImpl(new Impl)
+Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : mnNumerator(nNum), 
mnDenominator(nDen)
 {
 assert( nNum >= std::numeric_limits::min() );
 assert( nNum <= std::numeric_limits::max( ));
@@ -80,18 +56,16 @@ Fraction::Fraction( sal_Int64 nNum, sal_Int64 nDen ) : 
mpImpl(new Impl)
 assert( nDen <= std::numeric_limits::max( ));
 if ( nDen == 0 )
 {
-mpImpl->valid = false;
+

[Libreoffice-commits] core.git: include/tools tools/source

2019-01-10 Thread Libreoffice Gerrit user
 include/tools/urlobj.hxx |4 ++--
 tools/source/fsys/urlobj.cxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4f36ea1a1ecde6c000aeb878ab46747edd16c8f0
Author: Stephan Bergmann 
AuthorDate: Thu Jan 10 15:32:05 2019 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Jan 11 08:05:57 2019 +0100

o3tl::string_view -> std::string_view (in tools)

Change-Id: Ic3952cf0f05752813f60199b7b2c8c8e8dc27427
Reviewed-on: https://gerrit.libreoffice.org/66118
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 84556aa4a609..391a629c5598 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -23,10 +23,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
+#include 
 
 class SvMemoryStream;
 
@@ -381,7 +381,7 @@ public:
 
 bool isSchemeEqualTo(INetProtocol scheme) const { return scheme == 
m_eScheme; }
 
-bool isSchemeEqualTo(o3tl::u16string_view scheme) const;
+bool isSchemeEqualTo(std::u16string_view scheme) const;
 
 /** Check if the scheme is one of the WebDAV scheme
  *  we know about.
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index e280a7f84abe..45bd5a0d283f 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -3862,7 +3862,7 @@ OUString INetURLObject::getExternalURL() const
 return aTheExtURIRef;
 }
 
-bool INetURLObject::isSchemeEqualTo(o3tl::u16string_view scheme) const {
+bool INetURLObject::isSchemeEqualTo(std::u16string_view scheme) const {
 return m_aScheme.isPresent()
 && (rtl_ustr_compareIgnoreAsciiCase_WithLength(
 scheme.data(), scheme.size(),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2018-11-09 Thread Libreoffice Gerrit user
 include/tools/stream.hxx   |3 ---
 tools/source/stream/stream.cxx |   28 
 2 files changed, 8 insertions(+), 23 deletions(-)

New commits:
commit 4e6b448b998e3589baa2de46fb2135f1162695ed
Author: Noel Grandin 
AuthorDate: Fri Nov 9 08:45:45 2018 +0200
Commit: Noel Grandin 
CommitDate: Fri Nov 9 18:35:42 2018 +0100

SvStream::m_isConsistent is always true

ever since
commit a3b0ee88be3c6bff94ec6fe908f209c1dbb9748d
Date:   Sun Jul 10 22:17:35 2011 +0100
strip out unused methods

found by loplugin:singlevalfields

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index c627ed494998..370372aba454 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -156,9 +156,6 @@ private:
 
 // Error codes, conversion, compression, ...
 boolm_isDirty;  ///< true: Stream != buffer content
-boolm_isConsistent; ///< false: Buffer contains data, which 
were
-///< NOT allowed to be written by PutData
-///< into the derived stream (cf. PutBack)
 boolm_isSwap;
 boolm_isEof;
 ErrCode m_nError;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 8fe25c28d055..ea9f533b3af3 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -329,7 +329,6 @@ SvStream::SvStream() :
, m_isIoWrite(false)
 
, m_isDirty(false)
-   , m_isConsistent(true)
, m_isEof(false)
 
, m_nCompressMode(SvStreamCompressFlags::NONE)
@@ -402,7 +401,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
 sal_uInt64 const nActualFilePos = Tell();
 bool bDontSeek = (m_pRWBuf == nullptr);
 
-if (m_isDirty && m_isConsistent && m_isWritable)  // due to Windows NT: 
Access denied
+if (m_isDirty && m_isWritable)  // due to Windows NT: Access denied
 Flush();
 
 if (m_nBufSize)
@@ -417,7 +416,6 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
 m_nBufSize  = nBufferSize;
 if (m_nBufSize)
 m_pRWBuf.reset(new sal_uInt8[ m_nBufSize ]);
-m_isConsistent  = true;
 m_pBufPos   = m_pRWBuf.get();
 m_isIoRead = m_isIoWrite = false;
 if( !bDontSeek )
@@ -431,7 +429,6 @@ void SvStream::ClearBuffer()
 m_nBufFilePos   = 0;
 m_pBufPos   = m_pRWBuf.get();
 m_isDirty   = false;
-m_isConsistent  = true;
 m_isIoRead = m_isIoWrite = false;
 
 m_isEof = false;
@@ -893,8 +890,7 @@ SvStream& SvStream::ReadInt64(sal_Int64& r)
 
 SvStream& SvStream::ReadSChar( signed char& r )
 {
-if ((m_isIoRead || !m_isConsistent) &&
-sizeof(signed char) <= m_nBufFree)
+if (m_isIoRead && sizeof(signed char) <= m_nBufFree)
 {
 r = *m_pBufPos;
 m_nBufActualPos += sizeof(signed char);
@@ -910,8 +906,7 @@ SvStream& SvStream::ReadSChar( signed char& r )
 
 SvStream& SvStream::ReadChar( char& r )
 {
-if ((m_isIoRead || !m_isConsistent) &&
-sizeof(char) <= m_nBufFree)
+if (m_isIoRead && sizeof(char) <= m_nBufFree)
 {
 r = *m_pBufPos;
 m_nBufActualPos += sizeof(char);
@@ -925,8 +920,7 @@ SvStream& SvStream::ReadChar( char& r )
 
 SvStream& SvStream::ReadUChar( unsigned char& r )
 {
-if ((m_isIoRead || !m_isConsistent) &&
-sizeof(char) <= m_nBufFree)
+if (m_isIoRead && sizeof(char) <= m_nBufFree)
 {
 r = *m_pBufPos;
 m_nBufActualPos += sizeof(char);
@@ -953,8 +947,7 @@ SvStream& SvStream::ReadUtf16(sal_Unicode& r)
 
 SvStream& SvStream::ReadCharAsBool( bool& r )
 {
-if ((m_isIoRead || !m_isConsistent) &&
-sizeof(char) <= m_nBufFree)
+if (m_isIoRead && sizeof(char) <= m_nBufFree)
 {
 SAL_WARN_IF(
 *m_pBufPos > 1, "tools.stream", unsigned(*m_pBufPos) << " not 
0/1");
@@ -1234,8 +1227,6 @@ void SvStream::FlushBuffer(bool isConsistent)
 std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
 {
 std::size_t nSaveCount = nCount;
-if (!m_isConsistent)
-RefreshBuffer();
 
 if (!m_pRWBuf)
 {
@@ -1321,8 +1312,6 @@ std::size_t SvStream::WriteBytes( const void* pData, 
std::size_t nCount )
 SetError( ERRCODE_IO_CANTWRITE );
 return 0;
 }
-if (!m_isConsistent)
-RefreshBuffer();   // Remove changes in buffer through PutBack
 
 if (!m_pRWBuf)
 {
@@ -1404,7 +1393,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
 }
 else
 {
-FlushBuffer(m_isConsistent);
+FlushBuffer(true);
 m_nBufActualLen = 0;
 m_nBufActualPos = 0;
 m_pBufPos = m_pRWBuf.get();
@@ -1442,21 +1431,20 @@ sal_uInt64 SvStream::TellEnd()
 
 void SvStream::Flush()
 {
-

[Libreoffice-commits] core.git: include/tools tools/source

2018-10-17 Thread Libreoffice Gerrit user
 include/tools/stream.hxx   |2 +-
 tools/source/stream/stream.cxx |5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 4b5e8066e230b4fcbadb39b306f7c272865b0245
Author: Noel Grandin 
AuthorDate: Wed Oct 17 10:12:55 2018 +0200
Commit: Noel Grandin 
CommitDate: Wed Oct 17 12:06:31 2018 +0200

workaround weird linking error on tb71

ever since
commit 9ec8bf8f22fe74884185492ef2576ce79b41e4f1
add SvStream::TellEnd

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index dc2c926c371e..f6dc99155a1c 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -273,7 +273,7 @@ public:
 sal_uInt64  Seek( sal_uInt64 nPos );
 sal_uInt64  SeekRel( sal_Int64 nPos );
 sal_uInt64  Tell() const { return m_nBufFilePos + m_nBufActualPos;  }
-sal_uInt64  TellEnd() { return Tell() + remainingSize();  }
+sal_uInt64  TellEnd();
 // length between current (Tell()) pos and end of stream
 virtual sal_uInt64 remainingSize();
 voidFlush();
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f1d7269069f9..21b317e774b9 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1911,6 +1911,11 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize)
 ReAllocateMemory( nDiff );
 }
 
+sal_uInt64 SvStream::TellEnd()
+{
+return Tell() + remainingSize();
+}
+
 //Create a OString of nLen bytes from rStream
 OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source vcl/source

2018-07-30 Thread Libreoffice Gerrit user
 include/tools/debug.hxx  |4 ++--
 tools/source/debug/debug.cxx |2 +-
 vcl/source/app/svmain.cxx|2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 9cceba9a928cf3b3447f293020be2fe76c035ed5
Author: Noel Grandin 
AuthorDate: Fri Jul 27 10:13:19 2018 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 30 08:58:59 2018 +0200

make DBG_TESTSOLARMUTEX available in assert builds

where our QA people are more likely to trigger it

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

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index 3f5d68a670e4..3fa2d5f9460a 100644
--- a/include/tools/debug.hxx
+++ b/include/tools/debug.hxx
@@ -35,7 +35,8 @@
 standard assert.
 */
 
-#ifdef DBG_UTIL
+#ifndef NDEBUG
+// we want the solar mutex checking to be enabled in the assert-enabled builds 
that the QA people use
 
 typedef void (*DbgTestSolarMutexProc)();
 
@@ -49,7 +50,6 @@ do \
 } while(false)
 
 #else
-// NO DBG_UTIL
 
 #define DBG_TESTSOLARMUTEX() ((void)0)
 
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 220d577be52d..9f32eab3267c 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -45,7 +45,7 @@
 #include 
 #endif
 
-#ifdef DBG_UTIL
+#ifndef NDEBUG
 
 struct DebugData
 {
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index c2de4819b541..471abc951ffc 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -367,7 +367,7 @@ bool InitVCL()
 // Set exception handler
 pExceptionHandler = osl_addSignalHandler(VCLExceptionSignal_impl, nullptr);
 
-#ifdef DBG_UTIL
+#ifndef NDEBUG
 DbgGUIInitSolarMutexCheck();
 #endif
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2018-07-26 Thread Libreoffice Gerrit user
 include/tools/b3dtrans.hxx|1 -
 tools/source/generic/b3dtrans.cxx |1 -
 2 files changed, 2 deletions(-)

New commits:
commit de3cb0118af97d3ea8aafe4759ffc61073448de0
Author: Stephan Bergmann 
AuthorDate: Thu Jul 26 10:55:12 2018 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jul 26 10:55:12 2018 +0200

-Werror,-Wunused-private-field

...since ee025b744ac9efafe7c083ed80f8e2cc7cb3e2c1 "loplugin:returnconstant 
in
tools,comphelper,unotools"

Change-Id: Ia5fb60f5929084d8e3c6f45d81eefa55da100954

diff --git a/include/tools/b3dtrans.hxx b/include/tools/b3dtrans.hxx
index c57d7ce24abd..964c9fb1abbc 100644
--- a/include/tools/b3dtrans.hxx
+++ b/include/tools/b3dtrans.hxx
@@ -195,7 +195,6 @@ private:
 virtual void DeviceRectangleChange() override;
 
 basegfx::B3DPoint   aPosition;
-basegfx::B3DPoint   aCorrectedPosition;
 basegfx::B3DVector  aLookAt;
 double  fFocalLength;
 double  fBankAngle;
diff --git a/tools/source/generic/b3dtrans.cxx 
b/tools/source/generic/b3dtrans.cxx
index 184b6a1ff8bc..f892b11a5154 100644
--- a/tools/source/generic/b3dtrans.cxx
+++ b/tools/source/generic/b3dtrans.cxx
@@ -389,7 +389,6 @@ B3dCamera::B3dCamera(
 double fFocLen, double fBnkAng)
 :   B3dViewport(),
 aPosition(rPos),
-aCorrectedPosition(rPos),
 aLookAt(rLkAt),
 fFocalLength(fFocLen),
 fBankAngle(fBnkAng)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2018-04-18 Thread Noel Grandin
 include/tools/multisel.hxx |2 +-
 tools/source/memtools/multisel.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit fd73aa73519fa9cd9242aafacfad434a4a0fb6f8
Author: Noel Grandin 
Date:   Tue Apr 17 11:29:37 2018 +0200

tdf#117044 Base crash when attempting to edit a table definition

this story started in
commit  433fc2214c980abd82fa6240f45e634a53a3c61c (patch)
sal_uIntPtr->sal_Int32 in MultiSelection
which caused a regression, reported in tdf#116981.
I attempted to fix it in
commit 235d61890512894e27f4f81e38a325eee3c67b30
Date:   Fri Apr 13 17:14:59 2018 +0200
tdf#116981 Base when deleting table column
and
commit 0973e1f4e727a3204c843398bcb0e6a411b1a02d
Date:   Mon Apr 16 08:28:16 2018 +0200
follow on for tdf#116981

But my analysis was wrong.

To recap, and get it right:

Before all this, MultiSelection stored it's values internally as
sal_uIntPtr, but returned them as long in FirstSelected(),
NextSelected(),and SFX_ENDOFSELECTION was defined to be ULONG_MAX.
On 64-bit Linux, sal_uIntPtr is typedefed to sal_uInt64, and ULONG_MAX
is 2^64, which means that previously, the SFX_ENDOFSELECTION value was
being converted from 2^64 to -1 when it was returned, which was why
these loops worked.

So convert SFX_ENDOFSELECTION to -1 to match how how the external code
wants it to be (and the code frequently uses -1 instead of
SFX_ENDOFSELECTION or BROWSER_ENDOFSELECTION)

The modification to MultiSelection::Select is necessary because
previously, nCurMin and nCurMax would be == ULONG_MAX,
and we would, somewhat unintuitively, end up in the
// expand on left side?
if( nTmpMax < nCurMin )
part of the logic, which would do the right thing, even if a little
weirdly.

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

diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index 323ab4b355ee..3e06a3dce239 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-#define SFX_ENDOFSELECTION  SAL_MIN_INT32
+#define SFX_ENDOFSELECTION  (-1)
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection
 {
diff --git a/tools/source/memtools/multisel.cxx 
b/tools/source/memtools/multisel.cxx
index 1928a6913e5a..b63cabd01cdb 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -238,7 +238,7 @@ void MultiSelection::Select( const Range& rIndexRange, bool 
bSelect )
 DBG_ASSERT(aTotRange.IsInside(nTmpMin), "selected index out of range" );
 
 // replace whole selection?
-if( nTmpMin <= nCurMin && nTmpMax >= nCurMax )
+if( aSels.empty() || (nTmpMin <= nCurMin && nTmpMax >= nCurMax ) )
 {
 ImplClear();
 if ( bSelect )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source ucb/source

2018-03-04 Thread Stephan Bergmann
 include/tools/urlobj.hxx  |2 --
 tools/source/fsys/urlobj.cxx  |   16 ++--
 ucb/source/ucp/webdav-neon/webdavprovider.cxx |4 ++--
 ucb/source/ucp/webdav-neon/webdavprovider.hxx |4 ++--
 ucb/source/ucp/webdav/webdavprovider.cxx  |4 ++--
 ucb/source/ucp/webdav/webdavprovider.hxx  |4 ++--
 6 files changed, 10 insertions(+), 24 deletions(-)

New commits:
commit a7780e82305fe2e900afbe9909f9df80ad4019d5
Author: Stephan Bergmann 
Date:   Sun Mar 4 17:13:04 2018 +0100

Remove unnecessary INetProtocol::Webdav[s] again

...that 65abd11d68ba9f849d89b98b6a56071411875c89 "Support for webdav:// and
webdavs:// schemes from command line" had added for no good reason, and are
removed again on the same grounds as 
eda273fd46e63daa4f15525e05b695450df53cea
"Remove unnecessary INetProtocol::VndSunStarWebdavs again".

Change-Id: I29135207dfdffcc818664432a11fa3b5b3a0561a
Reviewed-on: https://gerrit.libreoffice.org/50748
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index e199ab0c49a9..99780fa0e79d 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -55,8 +55,6 @@ enum class INetProtocol
 File,
 Mailto,
 VndSunStarWebdav,
-Webdav,
-Webdavs,
 PrivSoffice,
 VndSunStarHelp,
 Https,
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 78e5c6b1e731..c6e74ddffc58 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -332,12 +332,6 @@ INetURLObject::getSchemeInfo(INetProtocol eTheScheme)
 "vnd.sun.star.webdav", "vnd.sun.star.webdav://", true, false,
 false, false, true, true, true, true},
 SchemeInfo{
-"webdav", "webdav://", true, false, false, false, true, true,
-true, true},
-SchemeInfo{
-"webdavs", "webdavs://", true, false, false, false, true, true,
-true, true},
-SchemeInfo{
 "private", "private:", false, false, false, false, false, false,
 false, true},
 SchemeInfo{
@@ -2180,10 +2174,6 @@ INetURLObject::PrefixInfo const * 
INetURLObject::getPrefix(sal_Unicode const *&
 { "vnd.sun.star.tdoc:", nullptr, INetProtocol::VndSunStarTdoc,
   PrefixInfo::OFFICIAL },
 { "vnd.sun.star.webdav:", nullptr, INetProtocol::VndSunStarWebdav,
-  PrefixInfo::OFFICIAL },
-{ "webdav:", nullptr, INetProtocol::Webdav,
-  PrefixInfo::OFFICIAL },
-{ "webdavs:", nullptr, INetProtocol::Webdavs,
   PrefixInfo::OFFICIAL }
 };
 /* This list needs to be sorted, or you'll introduce serious bugs */
@@ -2934,8 +2924,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 
 case INetProtocol::Http:
 case INetProtocol::VndSunStarWebdav:
-case INetProtocol::Webdav:
-case INetProtocol::Webdavs:
 case INetProtocol::Https:
 case INetProtocol::Smb:
 case INetProtocol::Cmis:
@@ -3900,8 +3888,8 @@ bool INetURLObject::isAnyKnownWebDAVScheme() const {
  isSchemeEqualTo( INetProtocol::Https ) ||
  isSchemeEqualTo( INetProtocol::VndSunStarWebdav ) ||
  isSchemeEqualTo( u"vnd.sun.star.webdavs" ) ||
- isSchemeEqualTo( INetProtocol::Webdav ) ||
- isSchemeEqualTo( INetProtocol::Webdavs ));
+ isSchemeEqualTo( u"webdav" ) ||
+ isSchemeEqualTo( u"webdavs" ));
 }
 
 // static
diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx 
b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
index ee2febfe1872..54d4ed5de655 100644
--- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
@@ -140,14 +140,14 @@ ContentProvider::queryContent(
 
 if (aURL.isSchemeEqualTo( INetProtocol::VndSunStarWebdav ) ||
 aURL.isSchemeEqualTo(DAV_URL_SCHEME) ||
-aURL.isSchemeEqualTo( INetProtocol::Webdav ) )
+aURL.isSchemeEqualTo( WEBDAV_URL_SCHEME ) )
 {
 aURL.changeScheme( INetProtocol::Http );
 xCanonicId = new ::ucbhelper::ContentIdentifier( aURL.getExternalURL() 
);
 }
 else if ( aURL.isSchemeEqualTo( VNDSUNSTARWEBDAVS_URL_SCHEME ) ||
 aURL.isSchemeEqualTo( DAVS_URL_SCHEME ) ||
-aURL.isSchemeEqualTo( INetProtocol::Webdavs ))
+aURL.isSchemeEqualTo( WEBDAVS_URL_SCHEME ))
 {
 aURL.changeScheme( INetProtocol::Https );
 xCanonicId = new ::ucbhelper::ContentIdentifier( aURL.getExternalURL() 
);
diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.hxx 
b/ucb/source/ucp/webdav-neon/webdavprovider.hxx
index c8b4679ac1fc..e90d5364a742 100644
--- a/ucb/source/ucp/webdav-neon/webdavprovider.hxx
+++ b/ucb/source/ucp/webdav-neon/webdavprovider.hxx
@@ -53,8 

[Libreoffice-commits] core.git: include/tools tools/source ucb/source

2018-03-04 Thread Stephan Bergmann
 include/tools/urlobj.hxx  |1 -
 tools/source/fsys/urlobj.cxx  |8 +---
 ucb/source/ucp/webdav-neon/webdavprovider.cxx |2 +-
 ucb/source/ucp/webdav-neon/webdavprovider.hxx |2 +-
 ucb/source/ucp/webdav/webdavprovider.cxx  |2 +-
 ucb/source/ucp/webdav/webdavprovider.hxx  |2 +-
 6 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 919546585a09a755f0454c80ec5d9fdadd12d87a
Author: Stephan Bergmann 
Date:   Sun Mar 4 16:27:42 2018 +0100

Remove unnecessary INetProtocol::VndSunStarWebdavs again

...that 65abd11d68ba9f849d89b98b6a56071411875c89 "Support for webdav:// and
webdavs:// schemes from command line" had added for no good reason.  See the
discussion linked from the commit message of
d3de490437df4c9093f32e97fc185066d64c0f46 "Add vnd.sun.star.webdavs URL 
scheme"
why this had deliberately not been added when adding the 
vnd.sun.star.webdavs
scheme.

Change-Id: I5728ab0d2517dae54a3536a347a83ff4cbfc18fa
Reviewed-on: https://gerrit.libreoffice.org/50734
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index cceab871a383..e199ab0c49a9 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -55,7 +55,6 @@ enum class INetProtocol
 File,
 Mailto,
 VndSunStarWebdav,
-VndSunStarWebdavs,
 Webdav,
 Webdavs,
 PrivSoffice,
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 5e8ca4d0d614..78e5c6b1e731 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -332,9 +332,6 @@ INetURLObject::getSchemeInfo(INetProtocol eTheScheme)
 "vnd.sun.star.webdav", "vnd.sun.star.webdav://", true, false,
 false, false, true, true, true, true},
 SchemeInfo{
-"vnd.sun.star.webdavs", "vnd.sun.star.webdavs://", true, false,
-false, false, true, true, true, true},
-SchemeInfo{
 "webdav", "webdav://", true, false, false, false, true, true,
 true, true},
 SchemeInfo{
@@ -2184,8 +2181,6 @@ INetURLObject::PrefixInfo const * 
INetURLObject::getPrefix(sal_Unicode const *&
   PrefixInfo::OFFICIAL },
 { "vnd.sun.star.webdav:", nullptr, INetProtocol::VndSunStarWebdav,
   PrefixInfo::OFFICIAL },
-{ "vnd.sun.star.webdavs:", nullptr, 
INetProtocol::VndSunStarWebdavs,
-  PrefixInfo::OFFICIAL },
 { "webdav:", nullptr, INetProtocol::Webdav,
   PrefixInfo::OFFICIAL },
 { "webdavs:", nullptr, INetProtocol::Webdavs,
@@ -2939,7 +2934,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
 
 case INetProtocol::Http:
 case INetProtocol::VndSunStarWebdav:
-case INetProtocol::VndSunStarWebdavs:
 case INetProtocol::Webdav:
 case INetProtocol::Webdavs:
 case INetProtocol::Https:
@@ -3905,7 +3899,7 @@ bool INetURLObject::isAnyKnownWebDAVScheme() const {
 return ( isSchemeEqualTo( INetProtocol::Http ) ||
  isSchemeEqualTo( INetProtocol::Https ) ||
  isSchemeEqualTo( INetProtocol::VndSunStarWebdav ) ||
- isSchemeEqualTo( INetProtocol::VndSunStarWebdavs ) ||
+ isSchemeEqualTo( u"vnd.sun.star.webdavs" ) ||
  isSchemeEqualTo( INetProtocol::Webdav ) ||
  isSchemeEqualTo( INetProtocol::Webdavs ));
 }
diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx 
b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
index 16a0e21f351b..ee2febfe1872 100644
--- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
@@ -145,7 +145,7 @@ ContentProvider::queryContent(
 aURL.changeScheme( INetProtocol::Http );
 xCanonicId = new ::ucbhelper::ContentIdentifier( aURL.getExternalURL() 
);
 }
-else if ( aURL.isSchemeEqualTo( INetProtocol::VndSunStarWebdavs ) ||
+else if ( aURL.isSchemeEqualTo( VNDSUNSTARWEBDAVS_URL_SCHEME ) ||
 aURL.isSchemeEqualTo( DAVS_URL_SCHEME ) ||
 aURL.isSchemeEqualTo( INetProtocol::Webdavs ))
 {
diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.hxx 
b/ucb/source/ucp/webdav-neon/webdavprovider.hxx
index 3e90c7fef5ab..c8b4679ac1fc 100644
--- a/ucb/source/ucp/webdav-neon/webdavprovider.hxx
+++ b/ucb/source/ucp/webdav-neon/webdavprovider.hxx
@@ -48,7 +48,7 @@ namespace webdav_ucp {
 // contents for. The UCB will select the provider ( i.e. in order to create
 // contents ) according to this scheme.
 #define VNDSUNSTARWEBDAV_URL_SCHEME  "vnd.sun.star.webdav"
-#define VNDSUNSTARWEBDAVS_URL_SCHEME "vnd.sun.star.webdavs"
+#define VNDSUNSTARWEBDAVS_URL_SCHEME u"vnd.sun.star.webdavs"
 #define HTTP_URL_SCHEME  "http"
 #define HTTPS_URL_SCHEME "https"
 #define DAV_URL_SCHEME   

[Libreoffice-commits] core.git: include/tools tools/source

2017-11-12 Thread Noel Grandin
 include/tools/inetmime.hxx |   60 ---
 tools/source/inet/inetmime.cxx |   69 -
 2 files changed, 27 insertions(+), 102 deletions(-)

New commits:
commit 508b60b7fd9270cdc5df8cbe5b733b4f6ea8575f
Author: Noel Grandin 
Date:   Fri Nov 10 11:41:02 2017 +0200

inline INetMIMEOutputSink

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

diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 75af8b41f1d3..11208eae50ef 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -240,66 +240,6 @@ inline sal_uInt32 INetMIME::getUTF32Character(const 
sal_Unicode *& rBegin,
 return *rBegin++;
 }
 
-class INetMIMEOutputSink
-{
-private:
-OStringBuffer m_aBuffer;
-
-/** Write a sequence of octets.
-
-@param pBegin  Points to the start of the sequence, must not be null.
-
-@param pEnd  Points past the end of the sequence, must be >= pBegin.
- */
-void writeSequence(const sal_Char * pBegin, const sal_Char * pEnd);
-
-/** Write a null terminated sequence of octets (without the terminating
-null).
-
-@param pOctets  A null terminated sequence of octets, must not be
-null.
- */
-void writeSequence(const sal_Char * pSequence);
-
-public:
-
-/** Write a single octet.
-
-@param nOctet  Some octet.
-
-@return  This instance.
- */
-inline INetMIMEOutputSink & operator <<(sal_Char nOctet);
-
-/** Write a null terminated sequence of octets (without the terminating
-null).
-
-@param pOctets  A null terminated sequence of octets, must not be
-null.
-
-@return  This instance.
- */
-inline INetMIMEOutputSink & operator <<(const sal_Char * pOctets);
-
-OString takeBuffer()
-{
-return m_aBuffer.makeStringAndClear();
-}
-};
-
-
-inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(sal_Char nOctet)
-{
-writeSequence(,  + 1);
-return *this;
-}
-
-inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const sal_Char *
-pOctets)
-{
-writeSequence(pOctets);
-return *this;
-}
 
 #endif
 
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 0be1ee62d8b2..0ec6bcdbb70e 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -197,38 +197,38 @@ inline sal_Unicode * putUTF32Character(sal_Unicode * 
pBuffer,
 return pBuffer;
 }
 
-void writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar)
+void writeUTF8(OStringBuffer & rSink, sal_uInt32 nChar)
 {
 // See RFC 2279 for a discussion of UTF-8.
 DBG_ASSERT(nChar < 0x8000, "writeUTF8(): Bad char");
 
 if (nChar < 0x80)
-rSink << sal_Char(nChar);
+rSink.append(sal_Char(nChar));
 else if (nChar < 0x800)
-rSink << sal_Char(nChar >> 6 | 0xC0)
-  << sal_Char((nChar & 0x3F) | 0x80);
+rSink.append(sal_Char(nChar >> 6 | 0xC0))
+ .append(sal_Char((nChar & 0x3F) | 0x80));
 else if (nChar < 0x1)
-rSink << sal_Char(nChar >> 12 | 0xE0)
-  << sal_Char((nChar >> 6 & 0x3F) | 0x80)
-  << sal_Char((nChar & 0x3F) | 0x80);
+rSink.append(sal_Char(nChar >> 12 | 0xE0))
+ .append(sal_Char((nChar >> 6 & 0x3F) | 0x80))
+ .append(sal_Char((nChar & 0x3F) | 0x80));
 else if (nChar < 0x20)
-rSink << sal_Char(nChar >> 18 | 0xF0)
-  << sal_Char((nChar >> 12 & 0x3F) | 0x80)
-  << sal_Char((nChar >> 6 & 0x3F) | 0x80)
-  << sal_Char((nChar & 0x3F) | 0x80);
+rSink.append(sal_Char(nChar >> 18 | 0xF0))
+ .append(sal_Char((nChar >> 12 & 0x3F) | 0x80))
+ .append(sal_Char((nChar >> 6 & 0x3F) | 0x80))
+ .append(sal_Char((nChar & 0x3F) | 0x80));
 else if (nChar < 0x400)
-rSink << sal_Char(nChar >> 24 | 0xF8)
-  << sal_Char((nChar >> 18 & 0x3F) | 0x80)
-  << sal_Char((nChar >> 12 & 0x3F) | 0x80)
-  << sal_Char((nChar >> 6 & 0x3F) | 0x80)
-  << sal_Char((nChar & 0x3F) | 0x80);
+rSink.append(sal_Char(nChar >> 24 | 0xF8))
+ .append(sal_Char((nChar >> 18 & 0x3F) | 0x80))
+ .append(sal_Char((nChar >> 12 & 0x3F) | 0x80))
+ .append(sal_Char((nChar >> 6 & 0x3F) | 0x80))
+ .append(sal_Char((nChar & 0x3F) | 0x80));
 else
-rSink << sal_Char(nChar >> 30 | 0xFC)
-  << sal_Char((nChar >> 24 & 0x3F) | 0x80)
-  << sal_Char((nChar >> 18 & 0x3F) | 0x80)
-  << sal_Char((nChar >> 12 & 0x3F) | 0x80)
-  << sal_Char((nChar 

[Libreoffice-commits] core.git: include/tools tools/source vcl/inc vcl/source

2017-11-06 Thread Jan-Marek Glogowski
 include/tools/stream.hxx|1 
 tools/source/stream/stream.cxx  |   21 +++
 vcl/inc/pdfread.hxx |4 ++
 vcl/source/filter/graphicfilter.cxx |2 -
 vcl/source/filter/ipdf/pdfread.cxx  |   66 
 vcl/source/gdi/impgraph.cxx |   13 ---
 6 files changed, 79 insertions(+), 28 deletions(-)

New commits:
commit 3a88795c1211c62277dc646e61c2ba8306febe37
Author: Jan-Marek Glogowski 
Date:   Thu Oct 26 16:05:54 2017 +0200

tdf#108748 generate PDF preview on SwapIn

When including a PDF as an image, it's represented internally as
a Bitmap with additional PDF data. On SwapIn, LibreOffice just
imported the PDF data missing the PDF preview. The Graphic also
gad the wrong image type, which results in a busy loop on master,
with a strange / unhelpful STR_COMCORE_READERROR generated by
SwNoTextFrame::PaintPicture.

This is a workaround to generate the Bitmap on SwapIn, which
will really slow down LibreOffice when importing many PDFs.

I guess the job of generating the PDF previews should probably
be deferred to a thread or a low priority Scheduler task, just
like the general image loading is handled.

Change-Id: I8084e4533995ecddc5b03ef19cb0c6a2dbf60ebd
Reviewed-on: https://gerrit.libreoffice.org/43906
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 00aa872f53e3..64823f48d078 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -252,6 +252,7 @@ public:
 SvStream&   WriteOString(const OString& rStr)
 { return WriteCharPtr(rStr.getStr()); }
 SvStream&   WriteStream( SvStream& rStream );
+sal_uInt64  WriteStream( SvStream& rStream, sal_uInt64 nSize );
 
 SvStream&   WriteBool( bool b )
 { return WriteUChar(static_cast(b)); }
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 4f95afd2c1e8..4c363dc67484 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1179,6 +1179,27 @@ SvStream& SvStream::WriteStream( SvStream& rStream )
 return *this;
 }
 
+sal_uInt64 SvStream::WriteStream( SvStream& rStream, sal_uInt64 nSize )
+{
+const sal_uInt32 cBufLen = 0x8000;
+std::unique_ptr pBuf( new char[ cBufLen ] );
+sal_uInt32 nCurBufLen = cBufLen;
+sal_uInt32 nCount;
+sal_uInt64 nWriteSize = nSize;
+
+do {
+if ( nSize >= nCurBufLen )
+nWriteSize -= nCurBufLen;
+else
+nCurBufLen = nWriteSize;
+nCount = rStream.ReadBytes( pBuf.get(), nCurBufLen );
+WriteBytes( pBuf.get(), nCount );
+}
+while( nWriteSize && nCount == nCurBufLen );
+
+return nSize - nWriteSize;
+}
+
 OUString SvStream::ReadUniOrByteString( rtl_TextEncoding eSrcCharSet )
 {
 // read UTF-16 string directly from stream ?
diff --git a/vcl/source/filter/ipdf/pdfread.hxx b/vcl/inc/pdfread.hxx
similarity index 73%
rename from vcl/source/filter/ipdf/pdfread.hxx
rename to vcl/inc/pdfread.hxx
index 2cb3abd7bc01..e873c49a1cdd 100644
--- a/vcl/source/filter/ipdf/pdfread.hxx
+++ b/vcl/inc/pdfread.hxx
@@ -17,6 +17,10 @@ namespace vcl
 {
 
 /// Imports a PDF stream into rGraphic as a GDIMetaFile.
+VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap ,
+ css::uno::Sequence ,
+ sal_uInt64 nPos = STREAM_SEEK_TO_BEGIN,
+ sal_uInt64 nSize = STREAM_SEEK_TO_END);
 VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
 
 }
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 776ef710eee7..062f5ee3701d 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -44,7 +44,7 @@
 #include 
 #include 
 #include "igif/gifread.hxx"
-#include "ipdf/pdfread.hxx"
+#include 
 #include "jpeg/jpeg.hxx"
 #include "ixbm/xbmread.hxx"
 #include "ixpm/xpmread.hxx"
diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 254e2adf1cd8..59a7b1f80469 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "pdfread.hxx"
+#include 
 
 #include 
 
@@ -56,7 +56,8 @@ double pointToPixel(double fPoint)
 }
 
 /// Does PDF to bitmap conversion using pdfium.
-bool generatePreview(SvStream& rStream, Graphic& rGraphic)
+bool generatePreview(SvStream& rStream, Bitmap& rBitmap,
+ sal_uInt64 nPos, sal_uInt64 nSize)
 {
 FPDF_LIBRARY_CONFIG aConfig;
 aConfig.version = 2;
@@ -67,7 +68,8 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic)
 
 // Read input into a buffer.
 SvMemoryStream 

[Libreoffice-commits] core.git: include/tools tools/source

2017-10-30 Thread Noel Grandin
 include/tools/urlobj.hxx |   13 +++---
 tools/source/fsys/urlobj.cxx |   82 ---
 2 files changed, 46 insertions(+), 49 deletions(-)

New commits:
commit 5be1ff2938321b4e29af32dc1b7eb4b898b250b4
Author: Noel Grandin 
Date:   Mon Oct 30 09:33:56 2017 +0200

loplugin:constantparam in tools

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

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index e5a4e5922ef3..fc03b9aa8f65 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -342,7 +342,6 @@ public:
 static OUString
 GetAbsURL(OUString const & rTheBaseURIRef,
   OUString const & rTheRelURIRef,
-  bool bIgnoreFragment = false,
   EncodeMechanism eEncodeMechanism = EncodeMechanism::WasEncoded,
   DecodeMechanism eDecodeMechanism = DecodeMechanism::ToIUri,
   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
@@ -1024,12 +1023,12 @@ private:
 // External URLs:
 
 static bool convertIntToExt(
-OUString const & rTheIntURIRef, bool bOctets,
+OUString const & rTheIntURIRef,
 OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism,
 rtl_TextEncoding eCharset);
 
 static bool convertExtToInt(
-OUString const & rTheExtURIRef, bool bOctets,
+OUString const & rTheExtURIRef,
 OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism,
 rtl_TextEncoding eCharset);
 
@@ -1070,7 +1069,7 @@ private:
 OUString & rCanonic);
 
 TOOLS_DLLPRIVATE static bool parseHostOrNetBiosName(
-sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets,
+sal_Unicode const * pBegin, sal_Unicode const * pEnd,
 EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
 bool bNetBiosName, OUStringBuffer* pCanonic);
 
@@ -1082,7 +1081,7 @@ private:
 
 TOOLS_DLLPRIVATE static bool parsePath(
 INetProtocol eScheme, sal_Unicode const ** pBegin,
-sal_Unicode const * pEnd, bool bOctets, EncodeMechanism eMechanism,
+sal_Unicode const * pEnd, EncodeMechanism eMechanism,
 rtl_TextEncoding eCharset, bool bSkippedInitialSlash,
 sal_uInt32 nSegmentDelimiter, sal_uInt32 nAltSegmentDelimiter,
 sal_uInt32 nQueryDelimiter, sal_uInt32 nFragmentDelimiter,
@@ -1264,7 +1263,7 @@ inline bool INetURLObject::translateToExternal(OUString 
const &
eDecodeMechanism,
rtl_TextEncoding eCharset)
 {
-return convertIntToExt(rTheIntURIRef, false, rTheExtURIRef,
+return convertIntToExt(rTheIntURIRef, rTheExtURIRef,
eDecodeMechanism, eCharset);
 }
 
@@ -1276,7 +1275,7 @@ inline bool INetURLObject::translateToInternal(OUString 
const &
eDecodeMechanism,
rtl_TextEncoding eCharset)
 {
-return convertExtToInt(rTheExtURIRef, false, rTheIntURIRef,
+return convertExtToInt(rTheExtURIRef, rTheIntURIRef,
eDecodeMechanism, eCharset);
 }
 
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 5c8d8be91132..eee91285258e 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -796,7 +796,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 sal_Unicode const * pe = n == -1 ? pEnd : p1 + n;
 if (
 parseHostOrNetBiosName(
-p1, pe, bOctets, EncodeMechanism::All, 
RTL_TEXTENCODING_DONTKNOW,
+p1, pe, EncodeMechanism::All, 
RTL_TEXTENCODING_DONTKNOW,
 true, nullptr) ||
 (scanDomain(p1, pe) > 0 && p1 == pe)
)
@@ -1039,7 +1039,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 ++p1;
 }
 if (parseHostOrNetBiosName(
-pPos + 2, p1, bOctets, EncodeMechanism::All,
+pPos + 2, p1, EncodeMechanism::All,
 RTL_TEXTENCODING_DONTKNOW, true, nullptr))
 {
 aSynAbsURIRef.append("//");
@@ -1108,7 +1108,7 @@ bool INetURLObject::setAbsURIRef(OUString const & 
rTheAbsURIRef,
 }
 if (
  parseHostOrNetBiosName(
-p1, pe, bOctets, EncodeMechanism::All,
+p1, pe, EncodeMechanism::All,
 

[Libreoffice-commits] core.git: include/tools tools/source

2017-10-16 Thread Stephan Bergmann
 include/tools/fract.hxx|2 --
 tools/source/generic/fract.cxx |   31 +--
 2 files changed, 1 insertion(+), 32 deletions(-)

New commits:
commit cb19a1ab5b8e6f1a4fdd90e50d13c106512b4da0
Author: Stephan Bergmann 
Date:   Mon Oct 16 14:39:29 2017 +0200

-Werror,-Wtautological-constant-compare (Clang 6)

...making Fraction::HasOverflowValue() always return false on all platforms,
regardless of size of long, since 331e2e5ed3bf4e0b2c1fab3b7bca836170317827
"long->sal_Int32 in Fraction" changed Fraction::Impl::value from
boost::rational to boost::rational, and changed the 
limits
to compare with in Fraction::HasOverflowValue from long to sal_Int32.

Change-Id: I226ca240d6092ac803a1f65a363b1384903da17a

diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index 95aa5f5e727b..74075e63cafc 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -32,8 +32,6 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Fraction final
 
 std::unique_ptr mpImpl;
 
-boolHasOverflowValue();
-
 public:
 Fraction();
 Fraction( const Fraction & rFrac );
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 1a78d4dfc654..d50cffc990aa 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -112,8 +112,6 @@ Fraction::Fraction( double dVal ) : mpImpl(new Impl)
 try
 {
 mpImpl->value = rational_FromDouble( dVal );
-if ( HasOverflowValue() )
-throw boost::bad_rational();
 mpImpl->valid = true;
 }
 catch (const boost::bad_rational&)
@@ -127,15 +125,6 @@ Fraction::~Fraction()
 {
 }
 
-bool Fraction::HasOverflowValue()
-{
-//coverity[result_independent_of_operands]
-return mpImpl->value.numerator() < std::numeric_limits::min() ||
-mpImpl->value.numerator() > std::numeric_limits::max() ||
-mpImpl->value.denominator() < std::numeric_limits::min() ||
-mpImpl->value.denominator() > std::numeric_limits::max();
-}
-
 Fraction::operator double() const
 {
 if (!mpImpl->valid)
@@ -164,12 +153,6 @@ Fraction& Fraction::operator += ( const Fraction& rVal )
 
 mpImpl->value += rVal.mpImpl->value;
 
-if ( HasOverflowValue() )
-{
-mpImpl->valid = false;
-SAL_WARN( "tools.fraction", "'operator +=' detected overflow" );
-}
-
 return *this;
 }
 
@@ -186,12 +169,6 @@ Fraction& Fraction::operator -= ( const Fraction& rVal )
 
 mpImpl->value -= rVal.mpImpl->value;
 
-if ( HasOverflowValue() )
-{
-mpImpl->valid = false;
-SAL_WARN( "tools.fraction", "'operator -=' detected overflow" );
-}
-
 return *this;
 }
 
@@ -231,7 +208,7 @@ Fraction& Fraction::operator *= ( const Fraction& rVal )
 
 bool bFail = checked_multiply_by(mpImpl->value, rVal.mpImpl->value);
 
-if (bFail || HasOverflowValue())
+if (bFail)
 {
 mpImpl->valid = false;
 }
@@ -252,12 +229,6 @@ Fraction& Fraction::operator /= ( const Fraction& rVal )
 
 mpImpl->value /= rVal.mpImpl->value;
 
-if ( HasOverflowValue() )
-{
-mpImpl->valid = false;
-SAL_WARN( "tools.fraction", "'operator /=' detected overflow" );
-}
-
 return *this;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source vcl/headless vcl/inc vcl/opengl vcl/quartz vcl/source vcl/unx vcl/win

2017-09-18 Thread Stephan Bergmann
 include/tools/poly.hxx   |1 +
 tools/source/generic/poly.cxx|5 +
 vcl/headless/svpgdi.cxx  |2 +-
 vcl/inc/headless/svpgdi.hxx  |2 +-
 vcl/inc/openglgdiimpl.hxx|2 +-
 vcl/inc/quartz/salgdi.h  |2 +-
 vcl/inc/salgdi.hxx   |4 ++--
 vcl/inc/salgdiimpl.hxx   |2 +-
 vcl/inc/unx/genpspgraphics.h |2 +-
 vcl/inc/unx/salgdi.h |2 +-
 vcl/inc/win/salgdi.h |2 +-
 vcl/opengl/gdiimpl.cxx   |2 +-
 vcl/quartz/salgdicommon.cxx  |2 +-
 vcl/source/gdi/salgdilayout.cxx  |2 +-
 vcl/source/outdev/curvedshapes.cxx   |8 
 vcl/source/outdev/line.cxx   |4 ++--
 vcl/source/outdev/polyline.cxx   |6 +++---
 vcl/source/outdev/rect.cxx   |4 ++--
 vcl/unx/generic/gdi/gdiimpl.cxx  |2 +-
 vcl/unx/generic/gdi/gdiimpl.hxx  |2 +-
 vcl/unx/generic/gdi/salgdi.cxx   |2 +-
 vcl/unx/generic/print/genpspgraphics.cxx |4 ++--
 vcl/win/gdi/gdiimpl.cxx  |4 ++--
 vcl/win/gdi/gdiimpl.hxx  |2 +-
 vcl/win/gdi/salgdi.cxx   |2 +-
 25 files changed, 39 insertions(+), 33 deletions(-)

New commits:
commit 80363950fda5eeef9830f61e57899d1805c91751
Author: Stephan Bergmann 
Date:   Mon Sep 18 10:37:17 2017 +0200

Acknowledge that WinSalGraphicsImpl::drawPolyLine modifies pPtAry

Change-Id: Idde44857f8ace883cc759321c71e2ca7a4359334
Reviewed-on: https://gerrit.libreoffice.org/42406
Reviewed-by: Stephan Bergmann 
Tested-by: Stephan Bergmann 

diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index 40a129414a38..044bafe3f3e2 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -171,6 +171,7 @@ public:
 voidRead( SvStream& rIStream );
 voidWrite( SvStream& rOStream ) const;
 
+Point * GetPointAry();
 const Point*GetConstPointAry() const;
 const PolyFlags*GetConstFlagAry() const;
 
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 0cdc61f91b65..217565a1ae60 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -796,6 +796,11 @@ Polygon::~Polygon()
 }
 }
 
+Point * Polygon::GetPointAry()
+{
+return mpImplPolygon->mpPointAry;
+}
+
 const Point* Polygon::GetConstPointAry() const
 {
 return mpImplPolygon->mpPointAry;
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index dea4185abea8..08b6ad2522f9 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -577,7 +577,7 @@ void SvpSalGraphics::drawRect( long nX, long nY, long 
nWidth, long nHeight )
 m_aLineColor = aOrigLineColor;
 }
 
-void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, const SalPoint* pPtAry)
+void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, SalPoint* pPtAry)
 {
 basegfx::B2DPolygon aPoly;
 aPoly.append(basegfx::B2DPoint(pPtAry->mnX, pPtAry->mnY), nPoints);
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 56ed365339f2..5879c1bfdf44 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -178,7 +178,7 @@ public:
   basegfx::B2DLineJoin,
   css::drawing::LineCap,
   double fMiterMinimumAngle) override;
-virtual voiddrawPolyLine( sal_uInt32 nPoints, const SalPoint* 
pPtAry ) override;
+virtual voiddrawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry 
) override;
 virtual voiddrawPolygon( sal_uInt32 nPoints, const SalPoint* 
pPtAry ) override;
 virtual voiddrawPolyPolygon( sal_uInt32 nPoly,
  const sal_uInt32* pPoints,
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 7bc6644fdc48..67efca02924e 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -244,7 +244,7 @@ public:
 
 virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) 
override;
 
-virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) 
override;
+virtual void drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
 
 virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) 
override;
 
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 12356fb57767..9a9626719169 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -228,7 +228,7 @@ public:
 virtual voiddrawPixel( long nX, long nY, SalColor nSalColor ) 
override;
 virtual voiddrawLine( long nX1, long nY1, long nX2, long nY2 ) 

[Libreoffice-commits] core.git: include/tools tools/source

2017-06-25 Thread Noel Grandin
 include/tools/stream.hxx   |   13 +
 tools/source/stream/stream.cxx |  104 +
 2 files changed, 67 insertions(+), 50 deletions(-)

New commits:
commit 3361e28f944d9f752f0e0df91968559f1ae55f72
Author: Noel Grandin 
Date:   Fri Jun 23 14:35:24 2017 +0200

make some tools macros into functions

in the process, eliminate the need to explicitly specify the
source/destination type at the callsites.

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index a6c5adbea898..b8f30625d822 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -412,6 +412,19 @@ public:
 of v should be unchanged,
 */
 virtual bool good() const { return !(eof() || bad()); }
+
+private:
+template
+void readNumberWithoutSwap(T& rDataDest)
+{ readNumberWithoutSwap_(, sizeof(rDataDest)); }
+
+void readNumberWithoutSwap_(void * pDataDest, int nDataSize);
+
+template
+void writeNumberWithoutSwap(T const & rDataSrc)
+{ writeNumberWithoutSwap_(, sizeof(rDataSrc)); }
+
+void writeNumberWithoutSwap_(const void * pDataSrc, int nDataSize);
 };
 
 inline SvStream& operator<<( SvStream& rStr, SvStrPtr f )
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 871d8f69b5ac..db90b56d41fe 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -131,37 +131,41 @@ static void SwapUnicode(sal_Unicode & r) { r = 
OSL_SWAPWORD(r); }
 
 //SDO
 
-#define READNUMBER_WITHOUT_SWAP(datatype,value) \
-if (m_isIoRead && sizeof(datatype) <= m_nBufFree)   \
-{   \
-for (std::size_t i = 0; i < sizeof(datatype); i++)  \
-reinterpret_cast()[i] = m_pBufPos[i]; \
-m_nBufActualPos += sizeof(datatype);\
-m_pBufPos += sizeof(datatype);  \
-m_nBufFree -= sizeof(datatype); \
-}   \
-else\
-{   \
-ReadBytes( , sizeof(datatype) );  \
-}   \
-
-
-#define WRITENUMBER_WITHOUT_SWAP(datatype,value) \
-if (m_isIoWrite && sizeof(datatype) <= m_nBufFree)  \
-{   \
-for (std::size_t i = 0; i < sizeof(datatype); i++)  \
-m_pBufPos[i] = reinterpret_cast()[i]; \
-m_nBufFree -= sizeof(datatype); \
-m_nBufActualPos += sizeof(datatype);\
-if (m_nBufActualPos > m_nBufActualLen)  \
-m_nBufActualLen = m_nBufActualPos;  \
-m_pBufPos += sizeof(datatype);  \
-m_isDirty = true;   \
-}   \
-else\
-{   \
-WriteBytes( , sizeof(datatype) ); \
-}   \
+void SvStream::readNumberWithoutSwap_(void * pDataDest, int nDataSize)
+{
+if (m_isIoRead && nDataSize <= m_nBufFree)
+{
+for (int i = 0; i < nDataSize; i++)
+static_cast(pDataDest)[i] = m_pBufPos[i];
+m_nBufActualPos += nDataSize;
+m_pBufPos += nDataSize;
+m_nBufFree -= nDataSize;
+}
+else
+{
+ReadBytes( pDataDest, nDataSize );
+}
+}
+
+
+void SvStream::writeNumberWithoutSwap_(const void * pDataSrc, int nDataSize)
+{
+if (m_isIoWrite && nDataSize <= m_nBufFree)
+{
+for (int i = 0; i < nDataSize; i++)
+m_pBufPos[i] = static_cast(pDataSrc)[i];
+m_nBufFree -= nDataSize;
+m_nBufActualPos += nDataSize;
+if (m_nBufActualPos > m_nBufActualLen)
+m_nBufActualLen = m_nBufActualPos;
+m_pBufPos += nDataSize;
+m_isDirty = true;
+}
+else
+{
+WriteBytes( pDataSrc, nDataSize );
+}
+}
 
 //  class SvLockBytes
 
@@ -731,7 +735,7 @@ void SvStream::StartWritingUnicodeText()
 // http://www.unicode.org/faq/utf_bom.html#BOM
 // Upon read: 0xfeff(-257) => no swap; 0xfffe(-2) => swap
 sal_uInt16 v = 0xfeff;
-WRITENUMBER_WITHOUT_SWAP(sal_uInt16, v); // write native format
+writeNumberWithoutSwap(v); // write native format
 }
 
 void SvStream::StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet )
@@ -812,7 +816,7 @@ sal_uInt64 

[Libreoffice-commits] core.git: include/tools tools/source

2017-03-13 Thread Caolán McNamara
 include/tools/stream.hxx   |1 
 tools/source/stream/stream.cxx |   66 +++--
 2 files changed, 20 insertions(+), 47 deletions(-)

New commits:
commit ee555c835aac8e21f0a08e7c9d513182728a4cfe
Author: Caolán McNamara 
Date:   Mon Mar 13 16:30:52 2017 +

merge these similar buffer flushes together

adds an extra SVSTREAM_WRITE_ERROR check to some of them, otherwise
they're all the same

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 3a1843d..bd7f77b 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -188,6 +188,7 @@ protected:
 virtual voidFlushData();
 virtual voidSetSize(sal_uInt64 nSize);
 
+voidFlushBuffer(bool isConsistent);
 voidClearError();
 voidClearBuffer();
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index fa69f58..f838edb 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1196,6 +1196,19 @@ SvStream& SvStream::WriteUniOrByteString( const 
OUString& rStr, rtl_TextEncoding
 return *this;
 }
 
+void SvStream::FlushBuffer(bool isConsistent)
+{
+if (m_isDirty && isConsistent) // Does stream require a flush?
+{
+SeekPos(m_nBufFilePos);
+if (m_nCryptMask)
+CryptAndWriteBuffer(m_pRWBuf, m_nBufActualLen);
+else if (PutData(m_pRWBuf, m_nBufActualLen) != m_nBufActualLen)
+SetError(SVSTREAM_WRITE_ERROR);
+m_isDirty = false;
+}
+}
+
 std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
 {
 std::size_t nSaveCount = nCount;
@@ -1225,15 +1238,7 @@ std::size_t SvStream::ReadBytes( void* pData, 
std::size_t nCount )
 }
 else
 {
-if (m_isDirty) // Does stream require a flush?
-{
-SeekPos(m_nBufFilePos);
-if (m_nCryptMask)
-CryptAndWriteBuffer(m_pRWBuf, m_nBufActualLen);
-else
-PutData(m_pRWBuf, m_nBufActualLen);
-m_isDirty = false;
-}
+FlushBuffer(true);
 
 // Does data block fit into buffer?
 if (nCount > m_nBufSize)
@@ -1288,6 +1293,7 @@ std::size_t SvStream::WriteBytes( const void* pData, 
std::size_t nCount )
 {
 if( !nCount )
 return 0;
+
 if (!m_isWritable)
 {
 SetError( ERRCODE_IO_CANTWRITE );
@@ -1321,16 +1327,7 @@ std::size_t SvStream::WriteBytes( const void* pData, 
std::size_t nCount )
 }
 else
 {
-// Does stream require flushing?
-if (m_isDirty)
-{
-SeekPos(m_nBufFilePos);
-if (m_nCryptMask)
-CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen );
-else
-PutData( m_pRWBuf, m_nBufActualLen );
-m_isDirty = false;
-}
+FlushBuffer(true);
 
 // Does data block fit into buffer?
 if (nCount > m_nBufSize)
@@ -1385,15 +1382,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
 }
 else
 {
-if (m_isDirty && m_isConsistent)
-{
-SeekPos(m_nBufFilePos);
-if (m_nCryptMask)
-CryptAndWriteBuffer( m_pRWBuf, m_nBufActualLen );
-else
-PutData( m_pRWBuf, m_nBufActualLen );
-m_isDirty = false;
-}
+FlushBuffer(m_isConsistent);
 m_nBufActualLen = 0;
 m_nBufActualPos = 0;
 m_pBufPos = m_pRWBuf;
@@ -1416,31 +1405,14 @@ sal_uInt64 SvStream::remainingSize()
 
 void SvStream::Flush()
 {
-if (m_isDirty && m_isConsistent)
-{
-SeekPos(m_nBufFilePos);
-if (m_nCryptMask)
-CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen );
-else
-if (PutData( m_pRWBuf, m_nBufActualLen ) != m_nBufActualLen)
-SetError( SVSTREAM_WRITE_ERROR );
-m_isDirty = false;
-}
+FlushBuffer(m_isConsistent);
 if (m_isWritable)
 FlushData();
 }
 
 void SvStream::RefreshBuffer()
 {
-if (m_isDirty && m_isConsistent)
-{
-SeekPos(m_nBufFilePos);
-if (m_nCryptMask)
-CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen );
-else
-PutData( m_pRWBuf, m_nBufActualLen );
-m_isDirty = false;
-}
+FlushBuffer(m_isConsistent);
 SeekPos(m_nBufFilePos);
 m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf, m_nBufSize );
 if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING)
___
Libreoffice-commits mailing 

[Libreoffice-commits] core.git: include/tools tools/source

2017-02-21 Thread Stephan Bergmann
 include/tools/inetmime.hxx |9 -
 tools/source/fsys/urlobj.cxx   |   18 --
 tools/source/inet/inetmime.cxx |   12 
 3 files changed, 16 insertions(+), 23 deletions(-)

New commits:
commit 5c99f2c8524625491ba1b4d736bdd457d258eea3
Author: Stephan Bergmann 
Date:   Tue Feb 21 15:15:30 2017 +0100

Move INetMIME::getHexDigit(int to its only place of use

Change-Id: I8d02a51a0da5aad4cd95e15fe6bb329b43e32067

diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 69d5836..106e561 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -109,15 +109,6 @@ public:
  */
 static inline int getHexWeight(sal_uInt32 nChar);
 
-/** Get a hexadecimal digit encoded as US-ASCII.
-
-@param nWeight  Must be in the range 0--15, inclusive.
-
-@return  The canonic (i.e., upper case) hexadecimal digit
-corresponding to nWeight (US-ASCII '0'--'9' or 'A'--'F').
- */
-static sal_uInt32 getHexDigit(int nWeight);
-
 /** Check two US-ASCII strings for equality, ignoring case.
 
 @param pBegin1  Points to the start of the first string, must not be
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 455ece0..45af339 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -36,6 +36,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -406,13 +407,26 @@ inline INetURLObject::SchemeInfo const & 
INetURLObject::getSchemeInfo() const
 return getSchemeInfo(m_eScheme);
 }
 
+namespace {
+
+sal_Unicode getHexDigit(sal_uInt32 nWeight)
+{
+assert(nWeight < 16);
+static const sal_Unicode aDigits[16]
+= { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
+'D', 'E', 'F' };
+return aDigits[nWeight];
+}
+
+}
+
 // static
 inline void INetURLObject::appendEscape(OUStringBuffer & rTheText,
 sal_uInt32 nOctet)
 {
 rTheText.append( '%' );
-rTheText.append( (sal_Unicode)INetMIME::getHexDigit(int(nOctet >> 4)) );
-rTheText.append( (sal_Unicode)INetMIME::getHexDigit(int(nOctet & 15)) );
+rTheText.append( getHexDigit(nOctet >> 4) );
+rTheText.append( getHexDigit(nOctet & 15) );
 }
 
 namespace {
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 8fc5a45..ad15355 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -1145,18 +1145,6 @@ bool INetMIME::isIMAPAtomChar(sal_uInt32 nChar)
 }
 
 // static
-sal_uInt32 INetMIME::getHexDigit(int nWeight)
-{
-DBG_ASSERT(nWeight >= 0 && nWeight < 16,
-   "INetMIME::getHexDigit(): Bad weight");
-
-static const sal_Char aDigits[16]
-= { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
-'D', 'E', 'F' };
-return aDigits[nWeight];
-}
-
-// static
 bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1,
const sal_Unicode * pEnd1,
const sal_Char * pString2)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-10-10 Thread Noel Grandin
 include/tools/resid.hxx|   21 +
 tools/source/rc/resmgr.cxx |6 +++---
 2 files changed, 12 insertions(+), 15 deletions(-)

New commits:
commit cc589883a98e8d21c57480719c9d4380fc292a59
Author: Noel Grandin 
Date:   Wed Oct 5 15:28:34 2016 +0200

rename SetResMgr to ClearResMgr

since that is it's only use.
Also clean up the comment block nearby.

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

diff --git a/include/tools/resid.hxx b/include/tools/resid.hxx
index 29452c6..0feec42 100644
--- a/include/tools/resid.hxx
+++ b/include/tools/resid.hxx
@@ -35,15 +35,16 @@ class ResMgr;
 class ResId
 {
 /*
-consider two cases: either m_pResource is valid and points
-two a resource data buffer; then m_nResId and m_pResMgr are
-not used and may be 0 resp. NULL
-or m_pResource is NULL, the m_nResId and m_pResMgr must be valid.
-In this case the highest bit if set decides whether to
-not to release the Resource context after loading this id
+Consider two cases:
+either
+(a) m_pResource is valid and points to a resource data buffer;
+then m_nResId and m_pResMgr are not used and may be 0 and nullptr 
respectively
+or
+(b) m_pResource is NULL, then m_nResId and m_pResMgr must be valid.
+In this case the highest bit, if set, decides whether or not to
+release the Resource context after loading this id.
 */
 RSHEADER_TYPE*  m_pResource;
-
 mutable sal_uInt32  m_nResId;  // Resource Identifier
 mutable RESOURCE_TYPE   m_nRT; // type for loading (mutable to be 
set later)
 mutable ResMgr *m_pResMgr; // load from this ResMgr (mutable 
for setting on demand)
@@ -85,11 +86,7 @@ public:
  }
 
 ResMgr *GetResMgr() const { return m_pResMgr; }
-voidSetResMgr( ResMgr * pMgr ) const
-{
-m_pResMgr = pMgr;
-OSL_ENSURE( m_pResMgr != nullptr, "invalid ResMgr set on ResId" );
-}
+voidClearResMgr() const { m_pResMgr = nullptr; }
 
 const ResId &  SetAutoRelease(bool bRelease) const
 {
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 473b900..18d4a59 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -923,7 +923,7 @@ bool ResMgr::IsAvailable( const ResId& rId, const Resource* 
pResObj ) const
 if( pMgr->pFallbackResMgr )
 {
 ResId aId( rId );
-aId.SetResMgr( nullptr );
+aId.ClearResMgr();
 return pMgr->pFallbackResMgr->IsAvailable( aId, pResObj );
 }
 
@@ -961,7 +961,7 @@ bool ResMgr::GetResource( const ResId& rId, const Resource* 
pResObj )
 if( pFallbackResMgr )
 {
 ResId aId( rId );
-aId.SetResMgr( nullptr );
+aId.ClearResMgr();
 return pFallbackResMgr->GetResource( aId, pResObj );
 }
 
@@ -1094,7 +1094,7 @@ RSHEADER_TYPE* ResMgr::CreateBlock( const ResId& rId )
 if( pFallbackResMgr )
 {
 ResId aId( rId );
-aId.SetResMgr( nullptr );
+aId.ClearResMgr();
 return pFallbackResMgr->CreateBlock( aId );
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-10-08 Thread Arnaud Versini
 include/tools/stream.hxx   |3 --
 tools/source/stream/stream.cxx |   60 +++--
 2 files changed, 28 insertions(+), 35 deletions(-)

New commits:
commit face6b697741a94c2f445d745a279f9033c64258
Author: Arnaud Versini 
Date:   Sun Aug 7 20:49:19 2016 +0200

TOOLS: Remove SvStream::ImpInit()

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

diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index d9cf3d2..1268eab 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -176,9 +176,6 @@ private:
 // Userdata
 longm_nVersion;   // for external use
 
-// helper methods
-TOOLS_DLLPRIVATE void ImpInit();
-
 SvStream ( const SvStream& rStream ) = delete;
 SvStream&   operator=( const SvStream& rStream ) = delete;
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index cca67de..d778180 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -309,45 +309,46 @@ void SvStream::SetSize(sal_uInt64 const nSize)
 m_nError = m_xLockBytes->SetSize( nSize );
 }
 
-void SvStream::ImpInit()
-{
-m_nActPos   = 0;
-m_nCompressMode = SvStreamCompressFlags::NONE;
-m_eStreamCharSet= osl_getThreadTextEncoding();
-m_nCryptMask= 0;
-m_isEof = false;
+SvStream::SvStream() :
+ m_nActPos(0)
+
+   , m_pRWBuf(nullptr)
+   , m_pBufPos(nullptr)
+   , m_nBufSize(0)
+   , m_nBufActualLen(0)
+   , m_nBufActualPos(0)
+   , m_nBufFree(0)
+   , m_isIoRead(false)
+   , m_isIoWrite(false)
+
+   , m_isDirty(false)
+   , m_isConsistent(true)
+   , m_isEof(false)
+
+   , m_nCompressMode(SvStreamCompressFlags::NONE)
 #if defined UNX
-m_eLineDelimiter= LINEEND_LF;   // UNIX-Format
+   , m_eLineDelimiter(LINEEND_LF)   // UNIX-Format
 #else
-m_eLineDelimiter= LINEEND_CRLF; // DOS-Format
+   , m_eLineDelimiter(LINEEND_CRLF) // DOS-Format
 #endif
+   , m_eStreamCharSet(osl_getThreadTextEncoding())
 
-SetEndian( SvStreamEndian::LITTLE );
-
-m_nBufFilePos   = 0;
-m_nBufActualPos = 0;
-m_isDirty   = false;
-m_isConsistent  = true;
-m_isWritable= true;
+   , m_nCryptMask(0)
 
-m_pRWBuf= nullptr;
-m_pBufPos   = nullptr;
-m_nBufSize  = 0;
-m_nBufActualLen = 0;
-m_isIoRead  = false;
-m_isIoWrite = false;
-m_nBufFree  = 0;
+   , m_nVersion(0)
 
-m_eStreamMode   = StreamMode::NONE;
+   , m_nBufFilePos(0)
+   , m_eStreamMode(StreamMode::NONE)
+   , m_isWritable(true)
 
-m_nVersion  = 0;
+{
+SetEndian( SvStreamEndian::LITTLE );
 
 ClearError();
 }
 
-SvStream::SvStream( SvLockBytes* pLockBytesP )
+SvStream::SvStream( SvLockBytes* pLockBytesP ) : SvStream()
 {
-ImpInit();
 m_xLockBytes = pLockBytesP;
 if( pLockBytesP ) {
 const SvStream* pStrm = pLockBytesP->GetStream();
@@ -358,11 +359,6 @@ SvStream::SvStream( SvLockBytes* pLockBytesP )
 SetBufferSize( 256 );
 }
 
-SvStream::SvStream()
-{
-ImpInit();
-}
-
 SvStream::~SvStream()
 {
 if (m_xLockBytes.Is())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-06-27 Thread tymyjan
 include/tools/zcodec.hxx   |   23 +++
 tools/source/zcodec/zcodec.cxx |   20 ++--
 2 files changed, 21 insertions(+), 22 deletions(-)

New commits:
commit 08fc0da4033b8ea2b3ae67aa06175e839771396b
Author: tymyjan 
Date:   Sat Jun 4 23:54:47 2016 +0200

tdf#75280 Cleaning up of sal_uIntPtr usage #1a

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

diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 0238115..7cce2a4 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -40,13 +40,13 @@ class TOOLS_DLLPUBLIC ZCodec
 boolmbStatus;
 boolmbFinish;
 sal_uInt8*  mpInBuf;
-sal_uIntPtr mnInBufSize;
-sal_uIntPtr mnInToRead;
+size_t  mnInBufSize;
+size_t  mnInToRead;
 SvStream*   mpOStm;
 sal_uInt8*  mpOutBuf;
-sal_uIntPtr mnOutBufSize;
+size_t  mnOutBufSize;
 
-sal_uIntPtr mnCRC;
+sal_uInt32  mnCRC;
 int mnCompressLevel;
 boolmbUpdateCrc;
 boolmbGzLib;
@@ -55,7 +55,6 @@ class TOOLS_DLLPUBLIC ZCodec
 voidInitCompress();
 voidInitDecompress(SvStream & inStream);
 voidImplWriteBack();
-
 voidUpdateCRC( sal_uInt8* pSource, long nDatSize );
 
 public:
@@ -69,14 +68,14 @@ public:
 longDecompress( SvStream& rIStm, SvStream& rOStm );
 boolAttemptDecompression( SvStream& rIStm, SvStream& rOStm );
 
-voidWrite( SvStream& rOStm, const sal_uInt8* pData, 
sal_uIntPtr nSize );
-longRead( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize 
);
-longReadAsynchron( SvStream& rIStm, sal_uInt8* pData, 
sal_uIntPtr nSize );
+voidWrite( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 
nSize );
+longRead( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize 
);
+longReadAsynchron( SvStream& rIStm, sal_uInt8* pData, 
sal_uInt32 nSize );
 
-voidSetBreak( sal_uIntPtr );
-sal_uIntPtr GetBreak();
-voidSetCRC( sal_uIntPtr nCurrentCRC );
-sal_uIntPtr GetCRC() { return mnCRC;}
+voidSetBreak( size_t );
+size_t  GetBreak();
+voidSetCRC( sal_uInt32 nCurrentCRC );
+sal_uInt32  GetCRC() { return mnCRC;}
 };
 
 #endif
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index e841888..839ef4c 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -134,7 +134,7 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm )
 long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
 {
 int err;
-sal_uIntPtr nInToRead;
+size_t nInToRead;
 longnOldTotal_Out = PZSTREAM->total_out;
 
 assert(meState == STATE_INIT);
@@ -169,7 +169,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
 return ( mbStatus ) ? (long)(PZSTREAM->total_out - nOldTotal_Out) : -1;
 }
 
-void ZCodec::Write( SvStream& rOStm, const sal_uInt8* pData, sal_uIntPtr nSize 
)
+void ZCodec::Write( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 nSize )
 {
 if (meState == STATE_INIT)
 {
@@ -194,10 +194,10 @@ void ZCodec::Write( SvStream& rOStm, const sal_uInt8* 
pData, sal_uIntPtr nSize )
 }
 }
 
-long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize )
+long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize )
 {
 int err;
-sal_uIntPtr nInToRead;
+size_t nInToRead;
 
 if ( mbFinish )
 return 0;   // PZSTREAM->total_out;
@@ -238,10 +238,10 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, 
sal_uIntPtr nSize )
 return (mbStatus ? (long)(nSize - PZSTREAM->avail_out) : -1);
 }
 
-long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr 
nSize )
+long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 
nSize )
 {
 int err = 0;
-sal_uIntPtr nInToRead;
+size_t nInToRead;
 
 if ( mbFinish )
 return 0;   // PZSTREAM->total_out;
@@ -258,7 +258,7 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* 
pData, sal_uIntPtr nSize
 {
 nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
 
-sal_uInt64 const nRemaining = rIStm.remainingSize();
+sal_uInt32 const nRemaining = rIStm.remainingSize();
 if (nRemaining < nInToRead)
 {
 rIStm.SetError( ERRCODE_IO_PENDING );
@@ -305,17 +305,17 @@ void ZCodec::ImplWriteBack()
 }
 }
 
-void ZCodec::SetBreak( sal_uIntPtr nInToRead )
+void ZCodec::SetBreak( size_t nInToRead )
 {
 mnInToRead 

[Libreoffice-commits] core.git: include/tools tools/source

2016-06-09 Thread Noel Grandin
 include/tools/debug.hxx  |   20 ++--
 tools/source/debug/debug.cxx |   34 +++---
 2 files changed, 21 insertions(+), 33 deletions(-)

New commits:
commit 6ab52cbb0ef1d2d08938d9355300155dbbb691fe
Author: Noel Grandin 
Date:   Wed Jun 8 12:32:34 2016 +0200

reduce "no DbgTestSolarMutex function set" warning

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

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index 4ad9022..3f5d68a 100644
--- a/include/tools/debug.hxx
+++ b/include/tools/debug.hxx
@@ -39,21 +39,13 @@
 
 typedef void (*DbgTestSolarMutexProc)();
 
-// Dbg prototypes
-#define DBG_FUNC_SETTESTSOLARMUTEX  2
-#define DBG_FUNC_TESTSOLARMUTEX 3
+TOOLS_DLLPUBLIC void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam );
+TOOLS_DLLPUBLIC void DbgTestSolarMutex();
 
-TOOLS_DLLPUBLIC void* DbgFunc( sal_uInt16 nAction, void* pData = nullptr );
-
-inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc )
-{
-DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, 
reinterpret_cast(reinterpret_cast(pProc)) );
-}
-
-#define DBG_TESTSOLARMUTEX()\
-do  \
-{   \
-DbgFunc(DBG_FUNC_TESTSOLARMUTEX);   \
+#define DBG_TESTSOLARMUTEX()   \
+do \
+{  \
+DbgTestSolarMutex();   \
 } while(false)
 
 #else
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index edb4ffe..dafd60a 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -47,35 +47,31 @@
 struct DebugData
 {
 DbgTestSolarMutexProc   pDbgTestSolarMutex;
+boolbTestSolarMutexWasSet;
 
 DebugData()
-:pDbgTestSolarMutex( nullptr )
+:pDbgTestSolarMutex( nullptr ), bTestSolarMutexWasSet(false)
 {
 }
 };
 
 static DebugData aDebugData;
 
-void* DbgFunc( sal_uInt16 nAction, void* pParam )
+void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam )
 {
-DebugData* pDebugData = 
-
-switch ( nAction )
-{
-case DBG_FUNC_SETTESTSOLARMUTEX:
-pDebugData->pDbgTestSolarMutex = 
reinterpret_cast(reinterpret_cast(pParam));
-break;
-
-case DBG_FUNC_TESTSOLARMUTEX:
-SAL_WARN_IF(
-pDebugData->pDbgTestSolarMutex == nullptr, "tools.debug",
-"no DbgTestSolarMutex function set");
-if ( pDebugData->pDbgTestSolarMutex )
-pDebugData->pDbgTestSolarMutex();
-break;
-}
+aDebugData.pDbgTestSolarMutex = pParam;
+if (pParam)
+aDebugData.bTestSolarMutexWasSet = true;
+}
 
-return nullptr;
+void DbgTestSolarMutex()
+{
+// don't warn if it was set at least once, because then we're probably 
just post-DeInitVCL()
+SAL_WARN_IF(
+!aDebugData.bTestSolarMutexWasSet && aDebugData.pDbgTestSolarMutex == 
nullptr, "tools.debug",
+"no DbgTestSolarMutex function set");
+if ( aDebugData.pDbgTestSolarMutex )
+aDebugData.pDbgTestSolarMutex();
 }
 
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-04-25 Thread Noel Grandin
 include/tools/errinf.hxx|   14 ++---
 tools/source/ref/errinf.cxx |  121 ++--
 2 files changed, 59 insertions(+), 76 deletions(-)

New commits:
commit 668e3d422c6f87a534911a7884bd22fac47c4262
Author: Noel Grandin 
Date:   Fri Apr 22 14:30:48 2016 +0200

use std::vector<> instead of embedding next pointers for ErrorHandler data

Change-Id: I759fc0d2bbc113873e2dda8edc8eb2eaf8036626

diff --git a/include/tools/errinf.hxx b/include/tools/errinf.hxx
index 1f9946b..571561e 100644
--- a/include/tools/errinf.hxx
+++ b/include/tools/errinf.hxx
@@ -75,7 +75,7 @@ public:
 
 StringErrorInfo( sal_uIntPtr lUserId,
 const OUString& aStringP,
-sal_uInt16 nFlags = 0);
+sal_uInt16 nMask = 0);
 const OUString& GetErrorString() const { return aString; }
 };
 
@@ -88,8 +88,8 @@ private:
 public:
 
 TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1,
-   const OUString & rTheArg2, sal_uInt16 nFlags = 0):
-DynamicErrorInfo(nUserID, nFlags), aArg1(rTheArg1), aArg2(rTheArg2) {}
+   const OUString & rTheArg2, sal_uInt16 nMask = 0):
+DynamicErrorInfo(nUserID, nMask), aArg1(rTheArg1), aArg2(rTheArg2) {}
 
 virtual ~TwoStringErrorInfo() {}
 
@@ -101,10 +101,10 @@ class TOOLS_DLLPUBLIC MessageInfo : public 
DynamicErrorInfo
 {
 public:
 
-MessageInfo(sal_uIntPtr UserId, sal_uInt16 nFlags = 0) :
-DynamicErrorInfo(UserId, nFlags) {}
-MessageInfo(sal_uIntPtr UserId, const OUString , sal_uInt16 nFlags = 
0 ) :
-DynamicErrorInfo(UserId, nFlags), aArg(rArg) {}
+MessageInfo(sal_uIntPtr UserId, sal_uInt16 nMask = 0) :
+DynamicErrorInfo(UserId, nMask) {}
+MessageInfo(sal_uIntPtr UserId, const OUString , sal_uInt16 nMask = 0 
) :
+DynamicErrorInfo(UserId, nMask), aArg(rArg) {}
 
 const OUString& GetMessageArg() const { return aArg; }
 
diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx
index 5d7af96..07e59f0 100644
--- a/tools/source/ref/errinf.cxx
+++ b/tools/source/ref/errinf.cxx
@@ -18,25 +18,25 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 class ErrorHandler;
 
 namespace {
-typedef void (* DisplayFnPtr)();
+  typedef void (* DisplayFnPtr)();
 }
 
 struct EDcrData
 {
 public:
-ErrorHandler   *pFirstHdl;
-ErrorContext   *pFirstCtx;
-DisplayFnPtr   pDsp;
-bool   bIsWindowDsp;
+std::vector  errorHandlers;
+std::vector  contexts;
+DisplayFnPtrpDsp;
+boolbIsWindowDsp;
 
 DynamicErrorInfo*ppDcr[ERRCODE_DYNAMIC_COUNT];
 sal_uInt16  nNextDcr;
@@ -59,9 +59,7 @@ friend class ErrorInfo;
 };
 
 EDcrData::EDcrData()
-: pFirstHdl(nullptr)
-, pFirstCtx(nullptr)
-, pDsp(nullptr)
+: pDsp(nullptr)
 , bIsWindowDsp(false)
 , nNextDcr(0)
 {
@@ -72,26 +70,23 @@ EDcrData::EDcrData()
 void DynamicErrorInfo_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
 {
 // Register dynamic identifier
-EDcrData& pData=TheEDcrData::get();
-lErrId= (((sal_uIntPtr)pData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) +
-pDcr->GetErrorCode();
-DynamicErrorInfo **ppDcr=pData.ppDcr;
-sal_uInt16 nNext=pData.nNextDcr;
+EDcrData& pData = TheEDcrData::get();
+lErrId = (((sal_uIntPtr)pData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) +
+ pDcr->GetErrorCode();
 
-if(ppDcr[nNext])
+if(pData.ppDcr[pData.nNextDcr])
 {
-delete ppDcr[nNext];
+delete pData.ppDcr[pData.nNextDcr];
 }
-ppDcr[nNext]=pDcr;
+pData.ppDcr[pData.nNextDcr] = pDcr;
 if(++pData.nNextDcr>=ERRCODE_DYNAMIC_COUNT)
 pData.nNextDcr=0;
 }
 
 void DynamicErrorInfo_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr)
 {
-DynamicErrorInfo **ppDcr=TheEDcrData::get().ppDcr;
-sal_uIntPtr lIdx=(
-((sal_uIntPtr)(*pDcr) & 
ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
+DynamicErrorInfo **ppDcr = TheEDcrData::get().ppDcr;
+sal_uIntPtr lIdx = (((sal_uIntPtr)(*pDcr) & ERRCODE_DYNAMIC_MASK) >> 
ERRCODE_DYNAMIC_SHIFT) - 1;
 DBG_ASSERT(ppDcr[lIdx]==pDcr,"ErrHdl: Error nicht gefunden");
 if(ppDcr[lIdx]==pDcr)
 ppDcr[lIdx]=nullptr;
@@ -130,8 +125,8 @@ DynamicErrorInfo::~DynamicErrorInfo()
 
 ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
 {
-sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
-DynamicErrorInfo* pDcr=TheEDcrData::get().ppDcr[lIdx];
+sal_uIntPtr lIdx = ((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
+DynamicErrorInfo* pDcr = TheEDcrData::get().ppDcr[lIdx];
 if(pDcr && 

[Libreoffice-commits] core.git: include/tools tools/source

2016-04-25 Thread Noel Grandin
 include/tools/errinf.hxx|6 +++---
 tools/source/ref/errinf.cxx |   14 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit f4b8b9ad1109b63afea6d8111a2e0799399a2fb2
Author: Noel Grandin 
Date:   Fri Apr 22 13:51:47 2016 +0200

rename EDcr_Impl to DynamicErrorInfo_Impl

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

diff --git a/include/tools/errinf.hxx b/include/tools/errinf.hxx
index 28c1c26..390de61 100644
--- a/include/tools/errinf.hxx
+++ b/include/tools/errinf.hxx
@@ -31,7 +31,7 @@
 // FIXME: horrible legacy dependency on VCL from tools.
 namespace vcl { class Window; }
 
-class EDcr_Impl;
+class DynamicErrorInfo_Impl;
 class ErrHdl_Impl;
 
 class TOOLS_DLLPUBLIC ErrorInfo
@@ -52,10 +52,10 @@ public:
 
 class TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo
 {
-friend class EDcr_Impl;
+friend class DynamicErrorInfo_Impl;
 
 private:
-std::unique_ptr   pImpl;
+std::unique_ptr   pImpl;
 
 public:
 
diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx
index 5e589ba..97f0616 100644
--- a/tools/source/ref/errinf.cxx
+++ b/tools/source/ref/errinf.cxx
@@ -45,7 +45,7 @@ public:
 
 struct TheEDcrData: public rtl::Static {};
 
-class EDcr_Impl
+class DynamicErrorInfo_Impl
 {
 sal_uIntPtr lErrId;
 sal_uInt16  nMask;
@@ -69,7 +69,7 @@ EDcrData::EDcrData()
 ppDcr[n]=nullptr;
 }
 
-void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
+void DynamicErrorInfo_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
 {
 // Register dynamic identifier
 EDcrData& pData=TheEDcrData::get();
@@ -87,7 +87,7 @@ void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
 pData.nNextDcr=0;
 }
 
-void EDcr_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr)
+void DynamicErrorInfo_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr)
 {
 DynamicErrorInfo **ppDcr=TheEDcrData::get().ppDcr;
 sal_uIntPtr lIdx=(
@@ -105,7 +105,7 @@ ErrorInfo::~ErrorInfo()
 ErrorInfo *ErrorInfo::GetErrorInfo(sal_uIntPtr lId)
 {
 if(lId & ERRCODE_DYNAMIC_MASK)
-return EDcr_Impl::GetDynamicErrorInfo(lId);
+return DynamicErrorInfo_Impl::GetDynamicErrorInfo(lId);
 else
 return new ErrorInfo(lId);
 }
@@ -117,7 +117,7 @@ DynamicErrorInfo::operator sal_uIntPtr() const
 
 DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, sal_uInt16 nMask)
 : ErrorInfo(lArgUserId),
-  pImpl(new EDcr_Impl)
+  pImpl(new DynamicErrorInfo_Impl)
 {
 pImpl->RegisterEDcr(this);
 pImpl->nMask=nMask;
@@ -125,10 +125,10 @@ DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr 
lArgUserId, sal_uInt16 nMask)
 
 DynamicErrorInfo::~DynamicErrorInfo()
 {
-EDcr_Impl::UnRegisterEDcr(this);
+DynamicErrorInfo_Impl::UnRegisterEDcr(this);
 }
 
-ErrorInfo* EDcr_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
+ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
 {
 sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
 DynamicErrorInfo* pDcr=TheEDcrData::get().ppDcr[lIdx];
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-04-25 Thread Noel Grandin
 include/tools/errinf.hxx|6 +++---
 tools/source/ref/errinf.cxx |8 
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit d848960a3e77a8608a48f3ba394928c955f1e2d9
Author: Noel Grandin 
Date:   Fri Apr 22 13:53:12 2016 +0200

rename Errhdl_Impl to ErrorHandler_Impl

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

diff --git a/include/tools/errinf.hxx b/include/tools/errinf.hxx
index 390de61..1f9946b 100644
--- a/include/tools/errinf.hxx
+++ b/include/tools/errinf.hxx
@@ -32,7 +32,7 @@
 namespace vcl { class Window; }
 
 class DynamicErrorInfo_Impl;
-class ErrHdl_Impl;
+class ErrorHandler_Impl;
 
 class TOOLS_DLLPUBLIC ErrorInfo
 {
@@ -138,10 +138,10 @@ typedef void BasicDisplayErrorFunc(
 
 class TOOLS_DLLPUBLIC ErrorHandler
 {
-friend class ErrHdl_Impl;
+friend class ErrorHandler_Impl;
 
 private:
-std::unique_ptr  pImpl;
+std::unique_ptr  pImpl;
 
 static sal_uInt16   HandleError_Impl( sal_uIntPtr lId,
   sal_uInt16 nFlags,
diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx
index 97f0616..5d7af96 100644
--- a/tools/source/ref/errinf.cxx
+++ b/tools/source/ref/errinf.cxx
@@ -149,7 +149,7 @@ StringErrorInfo::StringErrorInfo(
 {
 }
 
-class ErrHdl_Impl
+class ErrorHandler_Impl
 {
 public:
 ErrorHandler*pNext;
@@ -197,7 +197,7 @@ ErrorContext *ErrorContext::GetContext()
 }
 
 ErrorHandler::ErrorHandler()
-: pImpl(new ErrHdl_Impl)
+: pImpl(new ErrorHandler_Impl)
 {
 EDcrData =TheEDcrData::get();
 ErrorHandler *=pData.pFirstHdl;
@@ -289,7 +289,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
 nErrFlags = nDynFlags;
 }
 
-if(ErrHdl_Impl::CreateString(pData.pFirstHdl,pInfo,aErr,nErrFlags))
+if(ErrorHandler_Impl::CreateString(pData.pFirstHdl,pInfo,aErr,nErrFlags))
 {
 if (bJustCreateString)
 {
@@ -354,7 +354,7 @@ sal_uInt16 ErrorHandler::HandleError(sal_uIntPtr lId, 
sal_uInt16 nFlags)
 return HandleError_Impl( lId, nFlags, false, aDummy );
 }
 
-bool ErrHdl_Impl::CreateString( const ErrorHandler *pStart,
+bool ErrorHandler_Impl::CreateString( const ErrorHandler *pStart,
 const ErrorInfo* pInfo, OUString& pStr,
 sal_uInt16 )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source vcl/source

2016-04-12 Thread Noel Grandin
 include/tools/resid.hxx|   35 ++-
 tools/source/rc/rc.cxx |   11 +--
 tools/source/rc/resmgr.cxx |4 ++--
 vcl/source/window/resource.cxx |1 -
 4 files changed, 17 insertions(+), 34 deletions(-)

New commits:
commit f9aee52eb56c69373c98ced5aff2128ea8c26f1d
Author: Noel Grandin 
Date:   Sun Apr 10 14:44:15 2016 +0200

give tools::ResId a shave and a haircut

m_nRT2 and m_nWinBits fields are not in use anymore, at least as far
back as 2013, when the heading files were moved around

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

diff --git a/include/tools/resid.hxx b/include/tools/resid.hxx
index aa47075..29452c6 100644
--- a/include/tools/resid.hxx
+++ b/include/tools/resid.hxx
@@ -47,12 +47,10 @@ class ResId
 mutable sal_uInt32  m_nResId;  // Resource Identifier
 mutable RESOURCE_TYPE   m_nRT; // type for loading (mutable to be 
set later)
 mutable ResMgr *m_pResMgr; // load from this ResMgr (mutable 
for setting on demand)
-mutable RESOURCE_TYPE   m_nRT2;// type for loading (supersedes 
m_nRT)
-mutable sal_uInt32  m_nWinBits;// container for original style 
bits on a window in a resource
 
 void ImplInit( sal_uInt32 nId, ResMgr& rMgr, RSHEADER_TYPE* pRes )
 {
-m_pResource = pRes; m_nResId = nId; m_nRT = RSC_NOTYPE; m_pResMgr = 
 m_nRT2 = RSC_NOTYPE; m_nWinBits = 0;
+m_pResource = pRes; m_nResId = nId; m_nRT = RSC_NOTYPE; m_pResMgr = 

 OSL_ENSURE( m_pResMgr != nullptr, "ResId without ResMgr created" );
 }
 
@@ -66,8 +64,6 @@ public:
 ImplInit( nId, rMgr, nullptr );
 }
 
-void SetWinBits( sal_uInt32 nBits ) const { m_nWinBits = nBits; }
-
 RESOURCE_TYPE   GetRT() const { return m_nRT; }
 
 /** Set the type if not already set. Ask for type with GetRT()
@@ -81,22 +77,12 @@ public:
 @see
 ResId::GetRT2(), ResId::GetRT()
 */
-const ResId &   SetRT( RESOURCE_TYPE nType ) const
-{
-if( RSC_NOTYPE == m_nRT )
-m_nRT = nType;
-return *this;
-}
-
-/** Get the effective type (m_nRT2 or m_nRT1)
-
-A second resource type is used to supersede settings
-of the base class ( e.g. Window )
-*/
-RESOURCE_TYPE   GetRT2() const
-{
-return (RSC_NOTYPE == m_nRT2) ? m_nRT : m_nRT2;
-}
+ const ResId &   SetRT( RESOURCE_TYPE nType ) const
+ {
+ if( RSC_NOTYPE == m_nRT )
+ m_nRT = nType;
+ return *this;
+ }
 
 ResMgr *GetResMgr() const { return m_pResMgr; }
 voidSetResMgr( ResMgr * pMgr ) const
@@ -114,11 +100,10 @@ public:
 return *this;
 }
 
-boolIsAutoRelease()  const
-{ return !(m_nResId & RSC_DONTRELEASE); }
+boolIsAutoRelease()  const { return !(m_nResId & 
RSC_DONTRELEASE); }
 
-sal_uInt32  GetId()const { return m_nResId & ~RSC_DONTRELEASE; 
}
-RSHEADER_TYPE*  GetpResource() const { return m_pResource; }
+sal_uInt32  GetId()  const { return m_nResId & 
~RSC_DONTRELEASE; }
+RSHEADER_TYPE*  GetpResource()   const { return m_pResource; }
 
 TOOLS_DLLPUBLIC OUString toString() const;
 TOOLS_DLLPUBLIC operator OUString() const { return toString(); }
diff --git a/tools/source/rc/rc.cxx b/tools/source/rc/rc.cxx
index de16eaa..262f07a 100644
--- a/tools/source/rc/rc.cxx
+++ b/tools/source/rc/rc.cxx
@@ -18,7 +18,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -42,6 +42,7 @@ void Resource::GetRes( const ResId& rResId )
 OUString ResId::toString() const
 {
 SetRT( RSC_STRING );
+
 ResMgr* pResMgr = GetResMgr();
 
 if ( !pResMgr || !pResMgr->GetResource( *this ) )
@@ -49,11 +50,9 @@ OUString ResId::toString() const
 OUString sRet;
 
 #if OSL_DEBUG_LEVEL > 0
-sRet = OUStringBuffer().
-append("(GetId())).
-append(" not found>").
-makeStringAndClear();
+sRet = "(GetId()))
++ " not found>";
 #endif
 
 if( pResMgr )
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 8cccee4..668b414 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -913,7 +913,7 @@ bool ResMgr::IsAvailable( const ResId& rId, const Resource* 
pResObj ) const
 
 boolbAvailable = false;
 RSHEADER_TYPE*  pClassRes = rId.GetpResource();
-RESOURCE_TYPE   nRT = rId.GetRT2();
+RESOURCE_TYPE   nRT = rId.GetRT();
 sal_uInt32  nId = rId.GetId();
 const ResMgr*   pMgr = rId.GetResMgr();
 
@@ -978,7 +978,7 @@ bool ResMgr::GetResource( const ResId& rId, const Resource* 
pResObj )
 }
 
 RSHEADER_TYPE*  pClassRes = 

[Libreoffice-commits] core.git: include/tools tools/source

2016-04-04 Thread Noel Grandin
 include/tools/multisel.hxx |2 -
 include/tools/urlobj.hxx   |   42 
 tools/source/fsys/urlobj.cxx   |   55 -
 tools/source/memtools/multisel.cxx |   25 +++-
 4 files changed, 48 insertions(+), 76 deletions(-)

New commits:
commit 953f8f2cfecbe3005eb7de84daf1c9d86379244c
Author: Noel Grandin 
Date:   Fri Apr 1 14:23:45 2016 +0200

loplugin:constantparam in tools

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

diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index e8ad7ce..103d7fa 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -94,7 +94,7 @@ class TOOLS_DLLPUBLIC StringRangeEnumerator
 bool   mbValidInput;
 
 bool setRange( const OUString& i_rNewRange );
-bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence, bool 
bMayAdjust );
+bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence );
 bool insertJoinedRanges( const std::vector< sal_Int32 >& rNumbers );
 bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues 
= nullptr ) const;
 public:
diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 383a3aa..7b48084 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -422,7 +422,7 @@ public:
 { return decode(m_aAuth, eMechanism, eCharset); }
 
 inline bool SetUser(OUString const & rTheUser)
-{ return setUser(rTheUser, WAS_ENCODED, RTL_TEXTENCODING_UTF8); }
+{ return setUser(rTheUser, RTL_TEXTENCODING_UTF8); }
 
 inline bool SetPass(OUString const & rThePassword);
 
@@ -444,7 +444,7 @@ public:
 sal_uInt32 GetPort() const;
 
 inline bool SetHost(OUString const & rTheHost)
-{ return setHost(rTheHost, WAS_ENCODED, RTL_TEXTENCODING_UTF8); }
+{ return setHost(rTheHost, RTL_TEXTENCODING_UTF8); }
 
 bool SetPort(sal_uInt32 nThePort);
 
@@ -539,7 +539,7 @@ public:
 the specified place to insert the new segment does not exist, false is
 returned.  If false is returned, the object is not modified.
  */
-inline bool insertName(OUString const & rTheName,
+bool insertName(OUString const & rTheName,
bool bAppendFinalSlash = false,
sal_Int32 nIndex = LAST_SEGMENT,
EncodeMechanism eMechanism = WAS_ENCODED,
@@ -665,8 +665,6 @@ public:
 @param bIgnoreFinalSlash  If true, a final slash at the end of the
 hierarchical path does not denote an empty segment, but is ignored.
 
-@param eMechanism  See the general discussion for set-methods.
-
 @param eCharset  See the general discussion for set-methods.
 
 @return  True if the extension has successfully been modified (and the
@@ -677,7 +675,6 @@ public:
 bool setExtension(OUString const & rTheExtension,
   sal_Int32 nIndex = LAST_SEGMENT,
   bool bIgnoreFinalSlash = true,
-  EncodeMechanism eMechanism = WAS_ENCODED,
   rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
 
 /** Remove the extension of the name of a segment.
@@ -1015,7 +1012,7 @@ private:
 // Relative URLs:
 
 bool convertRelToAbs(
-OUString const & rTheRelURIRef, bool bOctets,
+OUString const & rTheRelURIRef,
 INetURLObject & rTheAbsURIRef, bool & rWasAbsolute,
 EncodeMechanism eMechanism, rtl_TextEncoding eCharset,
 bool bIgnoreFragment, bool bSmart, bool bRelativeNonURIs,
@@ -1061,13 +1058,13 @@ private:
 
 bool setUser(
 OUString const & rTheUser,
-EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
+rtl_TextEncoding eCharset);
 
 bool clearPassword();
 
 bool setPassword(
 OUString const & rThePassword,
-EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
+rtl_TextEncoding eCharset);
 
 // Host and Port:
 
@@ -1082,7 +1079,7 @@ private:
 
 bool setHost(
 OUString const & rTheHost,
-EncodeMechanism eMechanism, rtl_TextEncoding eCharset);
+rtl_TextEncoding eCharset);
 
 // Path:
 
@@ -1109,11 +1106,6 @@ private:
 TOOLS_DLLPRIVATE SubString getSegment(
 sal_Int32 nIndex, bool bIgnoreFinalSlash) const;
 
-bool insertName(
-OUString const & rTheName, bool bOctets, bool bAppendFinalSlash,
-sal_Int32 nIndex, bool bIgnoreFinalSlash, EncodeMechanism eMechanism,
-rtl_TextEncoding eCharset);
-
 // Query:
 
 bool clearQuery();
@@ -1235,7 +1227,7 @@ INetURLObject::smartRel2Abs(OUString const & 
rTheRelURIRef,
 FSysStyle eStyle) const
 {
 

[Libreoffice-commits] core.git: include/tools tools/source

2016-03-05 Thread Matteo Casalin
 include/tools/unqidx.hxx |6 ++
 tools/source/memtools/unqidx.cxx |   39 +++
 2 files changed, 17 insertions(+), 28 deletions(-)

New commits:
commit 078188793b2753bf607bb629464935ccefd28136
Author: Matteo Casalin 
Date:   Sat Mar 5 14:59:11 2016 +0100

Remove unuseful nStartIndex data member (and fix indexing)

The methods that modify nUinqIndex already maintain class invariants:
* Insert() never decrease its value
* Remove() can replace its value with that of the removed item,
  which was no lower than the one specified in constructor call.
Besides, boundary checks against nStartIndex are not really needed
since the various methods rely on map::find.

Finally, FirstIndex/NextIndex/LastIndex/GetIndexOf did not adjust with
nStartIndex the index value retrieved from tha map, thus provifing wrong
values. Since the map now stores the real indexes, consistency is granted.

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

diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index b6d65b4..99c5655 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -31,13 +31,11 @@ public:
 
 private:
 std::map maMap;
-const Index nStartIndex;
 Index nUniqIndex;
 
 public:
-UniqueIndexImpl( Index _nStartIndex = 0 )
-: maMap(),
-  nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex) {}
+UniqueIndexImpl( Index nStartIndex = 0 )
+: maMap(), nUniqIndex(nStartIndex) {}
 
 Index Insert( void* p );
 // insert value with key, replacing existing entry if necessary
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 56a9f0a..b53895f 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -32,42 +32,33 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
 
 maMap[ nUniqIndex ] = p;
 
-nUniqIndex++;
-return ( nUniqIndex + nStartIndex - 1 );
+return nUniqIndex++;
 }
 
 void* UniqueIndexImpl::Remove( Index nIndex )
 {
-// Check for valid index
-if ( nIndex >= nStartIndex )
+std::map::iterator it = maMap.find( nIndex );
+if ( it != maMap.end() )
 {
-std::map::iterator it = maMap.find( nIndex - nStartIndex 
);
-if( it != maMap.end() )
-{
-// Allow to recycle freed indexes, as was done by
-// original implementation based on a vector
-// This is not really needed when using a map, and
-// really unique indexes might be better/safer?
-if ( nIndex < nUniqIndex )
-nUniqIndex = nIndex;
+// Allow to recycle freed indexes, as was done by
+// original implementation based on a vector
+// This is not really needed when using a map, and
+// really unique indexes might be better/safer?
+if ( nIndex < nUniqIndex )
+nUniqIndex = nIndex;
 
-void* p = it->second;
-maMap.erase( it );
-return p;
-}
+void* p = it->second;
+maMap.erase( it );
+return p;
 }
 return nullptr;
 }
 
 void* UniqueIndexImpl::Get( Index nIndex ) const
 {
-// check for valid index
-if ( nIndex >= nStartIndex )
-{
-std::map::const_iterator it = maMap.find( nIndex - 
nStartIndex );
-if( it != maMap.end() )
-return it->second;
-}
+std::map::const_iterator it = maMap.find( nIndex );
+if ( it != maMap.end() )
+return it->second;
 return nullptr;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2016-01-15 Thread Noel Grandin
 include/tools/inetmime.hxx |4 -
 include/tools/inetmsg.hxx  |4 -
 include/tools/link.hxx |1 
 include/tools/multisel.hxx |6 --
 include/tools/pstm.hxx |2 
 include/tools/rc.hxx   |4 -
 include/tools/ref.hxx  |2 
 include/tools/resid.hxx|3 -
 include/tools/stream.hxx   |9 +--
 include/tools/urlobj.hxx   |5 --
 include/tools/vcompat.hxx  |1 
 include/tools/vector2d.hxx |   92 -
 include/tools/zcodec.hxx   |4 -
 tools/source/fsys/urlobj.cxx   |5 --
 tools/source/generic/poly.cxx  |   25 +-
 tools/source/inet/inetmime.cxx |3 -
 tools/source/inet/inetmsg.cxx  |   12 +---
 tools/source/memtools/multisel.cxx |7 --
 tools/source/ref/pstm.cxx  |5 --
 tools/source/stream/stream.cxx |   16 +-
 tools/source/stream/strmunx.cxx|4 -
 tools/source/stream/strmwnt.cxx|6 --
 tools/source/zcodec/zcodec.cxx |8 ---
 23 files changed, 58 insertions(+), 170 deletions(-)

New commits:
commit e15a997b153551a4c0e91964b5cff1b6269a9790
Author: Noel Grandin 
Date:   Fri Jan 15 12:00:55 2016 +0200

loplugin:unusedmethods unused return value in include/tools

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

diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 1c86055..1bc2404 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -255,10 +255,8 @@ private:
 
 @param pOctets  A null terminated sequence of octets, must not be
 null.
-
-@return  The length of pOctets (without the terminating null).
  */
-sal_Size writeSequence(const sal_Char * pSequence);
+void writeSequence(const sal_Char * pSequence);
 
 /** Write a sequence of octets.
 
diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx
index 996e334..ae7f23c 100644
--- a/include/tools/inetmsg.hxx
+++ b/include/tools/inetmsg.hxx
@@ -174,8 +174,8 @@ public:
 }
 INetMIMEMessage* GetParent() const { return pParent; }
 
-bool EnableAttachMultipartFormDataChild();
-bool AttachChild (
+void EnableAttachMultipartFormDataChild();
+void AttachChild (
 INetMIMEMessage& rChildMsg, bool bOwner = true );
 
 const OString& GetMultipartBoundary() const { return m_aBoundary; }
diff --git a/include/tools/link.hxx b/include/tools/link.hxx
index 584f963..3eaea7b 100644
--- a/include/tools/link.hxx
+++ b/include/tools/link.hxx
@@ -101,7 +101,6 @@ public:
 bool operator ==(Link const & other) const
 { return function_ == other.function_ && instance_ == other.instance_; };
 
-bool operator !=(Link const & other) const { return !operator ==(other); };
 void *GetInstance() const { return instance_; }
 
 private:
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index 3b6dafc..633f507 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -44,7 +44,7 @@ private:
 
 TOOLS_DLLPRIVATE void   ImplClear();
 TOOLS_DLLPRIVATE size_t ImplFindSubSelection( long nIndex ) const;
-TOOLS_DLLPRIVATE bool   ImplMergeSubSelections( size_t nPos1, 
size_t nPos2 );
+TOOLS_DLLPRIVATE void   ImplMergeSubSelections( size_t nPos1, 
size_t nPos2 );
 TOOLS_DLLPRIVATE long   ImplFwdUnselected();
 
 public:
@@ -55,10 +55,6 @@ public:
 
 MultiSelection& operator= ( const MultiSelection& rOrig );
 booloperator== ( MultiSelection& rOrig );
-booloperator!= ( MultiSelection& rOrig )
-{ return !operator==( rOrig ); }
-booloperator !() const
-{ return nSelCount == 0; }
 
 voidSelectAll( bool bSelect = true );
 boolSelect( long nIndex, bool bSelect = true );
diff --git a/include/tools/pstm.hxx b/include/tools/pstm.hxx
index e1e5843..92b5349 100644
--- a/include/tools/pstm.hxx
+++ b/include/tools/pstm.hxx
@@ -145,7 +145,7 @@ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
 
 protected:
 voidWriteObj( sal_uInt8 nHdr, SvPersistBase * pObj );
-sal_uInt32  ReadObj( SvPersistBase * & rpObj, bool bRegister );
+voidReadObj( SvPersistBase * & rpObj, bool bRegister );
 
 public:
 virtual voidResetError() override;
diff --git a/include/tools/rc.hxx b/include/tools/rc.hxx
index 6b1e1be..372b70b 100644
--- a/include/tools/rc.hxx
+++ b/include/tools/rc.hxx
@@ -44,8 +44,8 @@ protected:
 { return m_pResMgr->GetClass(); }
 
 // increase the memory pointer gotten by GetClassRes()
-void* IncrementRes( sal_uInt32 nBytes )
-{ 

[Libreoffice-commits] core.git: include/tools tools/source

2015-11-13 Thread Tomaž Vajngerl
 include/tools/cpuid.hxx |1 -
 tools/source/misc/cpuid.cxx |7 ---
 2 files changed, 8 deletions(-)

New commits:
commit 726ce582abb800a809ac144f50a7aa20e3fadcef
Author: Tomaž Vajngerl 
Date:   Fri Nov 13 14:48:25 2015 +0100

remove SSE detection code (but keep SSE2)

For corner case CPUs out there that support SSE and not SSE2 it
makes more sense to use the "fallback" code path instead of
writing a SSE only version. For this reason detecting SSE is not
relevant anymore - so removing it.

Change-Id: I3f1425af2cb5cdf9fba699e2996014598a15b5c1

diff --git a/include/tools/cpuid.hxx b/include/tools/cpuid.hxx
index 316e656..2445129 100644
--- a/include/tools/cpuid.hxx
+++ b/include/tools/cpuid.hxx
@@ -18,7 +18,6 @@ namespace tools
 {
 namespace cpuid
 {
-TOOLS_DLLPUBLIC bool hasSSE();
 TOOLS_DLLPUBLIC bool hasSSE2();
 }
 }
diff --git a/tools/source/misc/cpuid.cxx b/tools/source/misc/cpuid.cxx
index 1d0518c..b4406be 100644
--- a/tools/source/misc/cpuid.cxx
+++ b/tools/source/misc/cpuid.cxx
@@ -36,12 +36,6 @@ static void getCpuId(uint32_t array[4])
 #endif
 }
 
-bool hasSSE()
-{
-uint32_t cpuInfoArray[] = {0, 0, 0, 0};
-getCpuId(cpuInfoArray);
-return (cpuInfoArray[3] & (1 << 25)) != 0;
-}
 bool hasSSE2()
 {
 uint32_t cpuInfoArray[] = {0, 0, 0, 0};
@@ -51,7 +45,6 @@ bool hasSSE2()
 
 #else
 
-bool hasSSE() { return false; }
 bool hasSSE2() { return false; }
 
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2015-09-08 Thread Tor Lillqvist
 include/tools/diagnose_ex.h  |   10 --
 tools/source/debug/debug.cxx |9 +++--
 2 files changed, 7 insertions(+), 12 deletions(-)

New commits:
commit 8ab005af961709b51398c523516fe61a54ca2131
Author: Tor Lillqvist 
Date:   Tue Sep 8 18:26:02 2015 +0300

Avoid pain when using selective debuginfo

Compile in the DbgUnhandledException function always.

Change-Id: I302954598e599e8db71967974b18ade54ca2de13

diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index 1294615..7efffc6 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -27,10 +27,12 @@
 
 #include 
 
-#define OSL_UNUSED( expression ) \
-(void)(expression)
+#include 
 
+#define OSL_UNUSED( expression )\
+(void)(expression)
 
+TOOLS_DLLPUBLIC void DbgUnhandledException(const ::com::sun::star::uno::Any& 
caughtException, const char* currentFunction, const char* fileAndLineNo);
 
 #if OSL_DEBUG_LEVEL > 0
 #include 
@@ -38,10 +40,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-
-TOOLS_DLLPUBLIC void DbgUnhandledException(const 
::com::sun::star::uno::Any& caughtException, const char* currentFunction, const 
char* fileAndLineNo);
 
 /** reports a caught UNO exception via OSL diagnostics
 
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 1d1c8d6..4006b51 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -28,12 +28,15 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
+#include 
 #include 
 
 #include 
@@ -77,8 +80,6 @@ void* DbgFunc( sal_uInt16 nAction, void* pParam )
 
 #endif
 
-#if OSL_DEBUG_LEVEL > 0
-
 void DbgUnhandledException(const css::uno::Any & caught, const char* 
currentFunction, const char* fileAndLineNo)
 {
 OString sMessage( "caught an exception!" );
@@ -124,8 +125,4 @@ void DbgUnhandledException(const css::uno::Any & caught, 
const char* currentFunc
 "legacy.osl", fileAndLineNo, "%s", sMessage.getStr());
 }
 
-#endif
-
-
-
 /* 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: include/tools tools/source

2015-08-30 Thread Daniel Robertson
 include/tools/globname.hxx|   60 
 tools/source/ref/globname.cxx |   90 ++
 2 files changed, 57 insertions(+), 93 deletions(-)

New commits:
commit c1a9d0139112d7489ca6dd29b18f9418c6da3085
Author: Daniel Robertson danlrobertso...@gmail.com
Date:   Thu Aug 27 16:27:33 2015 -0400

tdf#62525: use cow_wrapper for SvGlobalName

Convert the pimpled copy-on-write SvGlobalName class to use the
::o3tl::cow_wrapper using the default reference counting policy.

Change-Id: I7bceb06ddfb31ca5901e5e7d5d93dda494db945f
Reviewed-on: https://gerrit.libreoffice.org/18070
Reviewed-by: Thorsten Behrens thorsten.behr...@cib.de
Tested-by: Thorsten Behrens thorsten.behr...@cib.de

diff --git a/include/tools/globname.hxx b/include/tools/globname.hxx
index 6796c3b..42ff4f4 100644
--- a/include/tools/globname.hxx
+++ b/include/tools/globname.hxx
@@ -23,6 +23,7 @@
 
 #include tools/toolsdllapi.h
 #include com/sun/star/uno/Sequence.hxx
+#include o3tl/cow_wrapper.hxx
 
 struct SvGUID
 {
@@ -35,20 +36,16 @@ struct SvGUID
 struct ImpSvGlobalName
 {
 struct SvGUID   szData;
-sal_uInt16  nRefCount;
 
-enum Empty { EMPTY };
-
-ImpSvGlobalName(const SvGUID rData)
-: szData(rData)
-, nRefCount(0)
-{
-}
-ImpSvGlobalName(sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
-  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 
b11,
-  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, 
sal_uInt8 b15);
-ImpSvGlobalName( const ImpSvGlobalName  rObj );
-ImpSvGlobalName( Empty );
+ImpSvGlobalName(const SvGUID rData)
+: szData(rData)
+{
+}
+ImpSvGlobalName(sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
+  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
+  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15);
+ImpSvGlobalName( const ImpSvGlobalName  rObj );
+ImpSvGlobalName();
 
 booloperator == ( const ImpSvGlobalName  rObj ) const;
 };
@@ -57,30 +54,26 @@ class SvStream;
 
 class TOOLS_DLLPUBLIC SvGlobalName
 {
-ImpSvGlobalName * pImp;
-voidNewImp();
+::o3tl::cow_wrapper ImpSvGlobalName  pImp;
 
 public:
-SvGlobalName();
-SvGlobalName( const SvGlobalName  rObj )
-{
-pImp = rObj.pImp;
-pImp-nRefCount++;
-}
-SvGlobalName( ImpSvGlobalName * pImpP )
-{
-pImp = pImpP;
-pImp-nRefCount++;
-}
-SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
-  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 
b11,
-  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, 
sal_uInt8 b15 );
-
-// create SvGlobalName from a platform independent representation
-SvGlobalName( const ::com::sun::star::uno::Sequence sal_Int8  
aSeq );
+SvGlobalName();
+SvGlobalName( const SvGlobalName  rObj ) :
+pImp( rObj.pImp )
+{
+}
+
+SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
+  sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
+  sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 );
+
+// create SvGlobalName from a platform independent representation
+SvGlobalName( const ::com::sun::star::uno::Sequence sal_Int8  aSeq );
+
+SvGlobalName( const SvGUID  rId );
 
 SvGlobalName  operator = ( const SvGlobalName  rObj );
-~SvGlobalName();
+~SvGlobalName();
 
 TOOLS_DLLPUBLIC friend SvStream  operator  ( SvStream , SvGlobalName  
);
 TOOLS_DLLPUBLIC friend SvStream  WriteSvGlobalName( SvStream , const 
SvGlobalName  );
@@ -97,7 +90,6 @@ public:
 bool  MakeId( const OUString  rId );
 OUString  GetHexName() const;
 
-  SvGlobalName( const SvGUID  rId );
 const SvGUID GetCLSID() const { return pImp-szData; }
 
 // platform independent representation of a GlobalName
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index fe96048..b11e21f 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -27,22 +27,19 @@
 #include tools/globname.hxx
 
 // ImpSvGlobalName 
-ImpSvGlobalName::ImpSvGlobalName( const ImpSvGlobalName  rObj )
-: szData(rObj.szData)
-, nRefCount(0)
+ImpSvGlobalName::ImpSvGlobalName()
 {
+memset( szData, 0, sizeof( szData ) );
 }
 
-ImpSvGlobalName::ImpSvGlobalName( Empty )
-: nRefCount(1)
+ImpSvGlobalName::ImpSvGlobalName( const ImpSvGlobalName  rObj )
+: szData(rObj.szData)
 {
-memset( szData, 0, sizeof( szData ) );
 }
 
 

[Libreoffice-commits] core.git: include/tools tools/source

2015-08-27 Thread Caolán McNamara
 include/tools/color.hxx|2 +-
 tools/source/generic/color.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 1e8b7cdbbd084a1e75f82bfff605321c8480b78d
Author: Caolán McNamara caol...@redhat.com
Date:   Thu Aug 27 11:58:47 2015 +0100

this farcical staroffice 5.0 related junk can at least be const

Change-Id: I096d98f6e0cb61cacd9cd82a623f832b88ded1e6

diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 00c89e2..0451a69 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -201,7 +201,7 @@ public:
 }
 
 SvStream Read(SvStream rIStream, bool bNewFormat = true);
-SvStream Write(SvStream rOStream, bool bNewFormat = true);
+SvStream Write(SvStream rOStream, bool bNewFormat = true) const;
 
 TOOLS_DLLPUBLIC friend SvStream ReadColor(SvStream rIStream, Color 
rColor);
 TOOLS_DLLPUBLIC friend SvStream WriteColor(SvStream rOStream, const 
Color rColor);
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 87185b8..6d7ebaf 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -227,7 +227,7 @@ SvStream Color::Read( SvStream rIStm, bool bNewFormat )
 return rIStm;
 }
 
-SvStream Color::Write( SvStream rOStm, bool bNewFormat )
+SvStream Color::Write( SvStream rOStm, bool bNewFormat ) const
 {
 if ( bNewFormat )
 rOStm.WriteUInt32( mnColor );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source vcl/inc vcl/source

2015-08-26 Thread Tor Lillqvist
 include/tools/debug.hxx|   49 --
 include/tools/resmgr.hxx   |2 
 tools/source/debug/debug.cxx   |  261 -
 tools/source/rc/resmgr.cxx |   45 --
 vcl/inc/dbggui.hxx |   12 
 vcl/source/app/dbggui.cxx  |  789 -
 vcl/source/window/settings.cxx |   34 -
 vcl/source/window/window.cxx   |7 
 vcl/source/window/winproc.cxx  |9 
 9 files changed, 19 insertions(+), 1189 deletions(-)

New commits:
commit 139b32b84c029b6ff7a9236b58f65351a5723640
Author: Tor Lillqvist t...@collabora.com
Date:   Wed Aug 26 10:31:55 2015 +0300

Bin the fairly useless DbgDialog stuff and handle fallout

See (short) discussion on the mailing list, How was it again, is the
DbgDialog useful?.

Change-Id: Ibde1eb13f16edf94f1f7aebd0befd1b0b171d5c4

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index 65fd18b9..3dfafab 100644
--- a/include/tools/debug.hxx
+++ b/include/tools/debug.hxx
@@ -41,61 +41,12 @@
 
 typedef void (*DbgTestSolarMutexProc)();
 
-#define DBG_TEST_RESOURCE   (0x0200)
-#define DBG_TEST_DIALOG (0x0400)
-#define DBG_TEST_BOLDAPPFONT(0x0800)
-
-struct DbgData
-{
-sal_uIntPtr   nTestFlags;
-sal_CharaDbgWinState[50];   // DbgGUIData for VCL
-};
-
 // Dbg prototypes
-#define DBG_FUNC_GETDATA0
-#define DBG_FUNC_SAVEDATA   1
 #define DBG_FUNC_SETTESTSOLARMUTEX  2
 #define DBG_FUNC_TESTSOLARMUTEX 3
 
 TOOLS_DLLPUBLIC void* DbgFunc( sal_uInt16 nAction, void* pData = NULL );
 
-inline DbgData* DbgGetData()
-{
-return static_castDbgData*(DbgFunc( DBG_FUNC_GETDATA ));
-}
-
-inline void DbgSaveData( const DbgData rData )
-{
-DbgFunc( DBG_FUNC_SAVEDATA, const_castDbgData *(rData) );
-}
-
-inline bool DbgIsResource()
-{
-DbgData* pData = DbgGetData();
-if ( pData )
-return pData-nTestFlags  DBG_TEST_RESOURCE;
-else
-return false;
-}
-
-inline bool DbgIsDialog()
-{
-DbgData* pData = DbgGetData();
-if ( pData )
-return pData-nTestFlags  DBG_TEST_DIALOG;
-else
-return false;
-}
-
-inline bool DbgIsBoldAppFont()
-{
-DbgData* pData = DbgGetData();
-if ( pData )
-return pData-nTestFlags  DBG_TEST_BOLDAPPFONT;
-else
-return false;
-}
-
 inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc )
 {
 DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, 
reinterpret_castvoid*(reinterpret_castsal_uIntPtr(pProc)) );
diff --git a/include/tools/resmgr.hxx b/include/tools/resmgr.hxx
index b993548..4c72c17 100644
--- a/include/tools/resmgr.hxx
+++ b/include/tools/resmgr.hxx
@@ -143,7 +143,7 @@ public:
 
 #ifdef DBG_UTIL
 /// Test whether resource still exists
-voidTestStack( const Resource * );
+voidTestStack();
 #endif
 
 /// Check whether resource is available
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index aff0a3b..1d1c8d6 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -19,8 +19,6 @@
 
 #if defined (UNX) || defined (__GNUC__)
 #include unistd.h
-#else
-#include direct.h
 #endif
 
 #include errno.h
@@ -30,10 +28,6 @@
 #include string.h
 #include stdio.h
 
-#if defined ( WNT )
-#include windows.h
-#endif
-
 #include com/sun/star/task/ErrorCodeIOException.hpp
 #include tools/debug.hxx
 #include rtl/string.h
@@ -49,259 +43,36 @@
 
 struct DebugData
 {
-DbgData aDbgData;
-boolbInit;
 DbgTestSolarMutexProc   pDbgTestSolarMutex;
 
 DebugData()
-:bInit( false )
-,pDbgTestSolarMutex( NULL )
+:pDbgTestSolarMutex( NULL )
 {
-aDbgData.nTestFlags = DBG_TEST_RESOURCE;
-aDbgData.aDbgWinState[0] = 0;
 }
 };
 
 static DebugData aDebugData;
 
-#define FILE_LINEEND\n
-
-typedef FILE*   FILETYPE;
-#define FileOpenfopen
-#define FileReadfread
-#define FilePrintF  fprintf
-#define FileClose   fclose
-
-namespace
-{
-enum ConfigSection
-{
-eGUI,
-eTest,
-
-eUnknown
-};
-
-void lcl_lineFeed( FILETYPE _pFile )
-{
-FilePrintF( _pFile, %s, FILE_LINEEND );
-}
-
-const sal_Char* lcl_getSectionName( ConfigSection _eSection )
-{
-const sal_Char* pSectionName = NULL;
-switch ( _eSection )
-{
-case eGUI   : pSectionName = gui; break;
-case eTest  : pSectionName = test;break;
-case eUnknown:
-OSL_ASSERT(false);
-break;
-}
-return pSectionName;
-}
-
-ConfigSection lcl_getSectionFromName( const sal_Char* _pSectionName, 
size_t _nSectionNameLength )
-{
-if ( strncmp( _pSectionName, gui, _nSectionNameLength  3 ? 
_nSectionNameLength : 3 ) == 0 )
-return eGUI;
-if ( strncmp( _pSectionName, test,_nSectionNameLength  4 ? 

[Libreoffice-commits] core.git: include/tools tools/source

2014-12-10 Thread David Ostrovsky
 include/tools/debug.hxx  |2 +-
 tools/source/debug/debug.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c2a93a21a5a7af38ae659b9340beeb13c084eb12
Author: David Ostrovsky da...@ostrovsky.org
Date:   Mon Dec 8 08:19:15 2014 +0100

long is 32 bit on Windows x86_64 platform

So that this is always wrong (on this platform) to write:

reinterpret_castfoo(reinterpret_castlong(bar))

it should be:
renterpret_castfoo(reinterpret_castsal_uIntPtr(bar))

Change-Id: Ia286246ee1616988f755c2d2054b26efacc51af0
Reviewed-on: https://gerrit.libreoffice.org/13366
Reviewed-by: Michael Stahl mst...@redhat.com
Tested-by: Michael Stahl mst...@redhat.com

diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx
index 6e73d2e..cdbe081 100644
--- a/include/tools/debug.hxx
+++ b/include/tools/debug.hxx
@@ -98,7 +98,7 @@ inline sal_uIntPtr DbgIsBoldAppFont()
 
 inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc )
 {
-DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, 
reinterpret_castvoid*(reinterpret_castlong(pProc)) );
+DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, 
reinterpret_castvoid*(reinterpret_castsal_uIntPtr(pProc)) );
 }
 
 #define DBG_ASSERTWARNING( sCon, aWarning ) \
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 274d116..9e65c44 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -288,7 +288,7 @@ void* DbgFunc( sal_uInt16 nAction, void* pParam )
 break;
 
 case DBG_FUNC_SETTESTSOLARMUTEX:
-pDebugData-pDbgTestSolarMutex = 
reinterpret_castDbgTestSolarMutexProc(reinterpret_castlong(pParam));
+pDebugData-pDbgTestSolarMutex = 
reinterpret_castDbgTestSolarMutexProc(reinterpret_castsal_uIntPtr(pParam));
 break;
 
 case DBG_FUNC_TESTSOLARMUTEX:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2014-10-14 Thread Takeshi Abe
 include/tools/unqidx.hxx |7 +--
 tools/source/memtools/unqidx.cxx |   36 ++--
 2 files changed, 23 insertions(+), 20 deletions(-)

New commits:
commit 4e3772b1b472636b381ed511dcfff216fbe55d37
Author: Takeshi Abe t...@fixedpoint.jp
Date:   Mon Oct 13 21:05:31 2014 +0900

fdo#75757: remove inheritance to std::map

from UniqueIndexImpl.

Change-Id: Iaa9040dff117ed5b05955c9f6eef31878dccf3b0
Reviewed-on: https://gerrit.libreoffice.org/11951
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index 9042476..27de75f 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -25,18 +25,21 @@
 
 #define UNIQUEINDEX_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
 
-class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl : public 
std::mapsal_uInt32, void*
+class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl
 {
 private:
+std::mapsal_uInt32, void* maMap;
 sal_uIntPtr   nStartIndex;
 sal_uIntPtr   nUniqIndex;
 sal_uIntPtr   nCount;
 
 public:
 UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 )
-: std::mapsal_uInt32, void*(),
+: maMap(),
   nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
 
+size_t size() const { return maMap.size(); }
+
 sal_uIntPtr   Insert( void* p );
 // insert value with key, replacing existing entry if necessary
 void  Insert( sal_uIntPtr aIndex, void* p );
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index d9d7e7b..726c96c 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -26,7 +26,7 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p )
 return UNIQUEINDEX_ENTRY_NOTFOUND;
 
// Expend array if full
-sal_uIntPtr nTmp = size();
+sal_uIntPtr nTmp = maMap.size();
 if( nTmp == nCount )
 nTmp++;
 
@@ -34,11 +34,11 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p )
 nUniqIndex = nUniqIndex % nTmp;
 
 // Search next empty index
-while ( find( nUniqIndex ) != end() )
+while ( maMap.find( nUniqIndex ) != maMap.end() )
 nUniqIndex = (nUniqIndex+1) % nTmp;
 
 // Insert object to array
-(*this)[ nUniqIndex ] = p;
+maMap[ nUniqIndex ] = p;
 
 nCount++;
 nUniqIndex++;
@@ -53,10 +53,10 @@ void UniqueIndexImpl::Insert( sal_uIntPtr nIndex, void* p )
 
 sal_uIntPtr nContIndex = nIndex - nStartIndex;
 
-bool bFound = find( nContIndex ) != end();
+bool bFound = maMap.find( nContIndex ) != maMap.end();
 
 // Insert object to array
-(*this)[ nContIndex ] = p;
+maMap[ nContIndex ] = p;
 
 if( !bFound )
 nCount++;
@@ -70,11 +70,11 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
 {
 // insert index as empty entry, and reduce indexcount,
 // if this entry was used
-iterator it = find( nIndex - nStartIndex );
-if( it != end() )
+std::mapsal_uInt32, void*::iterator it = maMap.find( nIndex - 
nStartIndex );
+if( it != maMap.end() )
 {
 void* p = it-second;
-erase( it );
+maMap.erase( it );
 nCount--;
 return p;
 }
@@ -88,8 +88,8 @@ void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
 if ( (nIndex = nStartIndex) 
  (nIndex  (size() + nStartIndex)) )
 {
-const_iterator it = find( nIndex - nStartIndex );
-if( it != end() )
+std::mapsal_uInt32, void*::const_iterator it = maMap.find( nIndex - 
nStartIndex );
+if( it != maMap.end() )
 return it-second;
 }
 return NULL;
@@ -97,34 +97,34 @@ void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
 
 sal_uIntPtr UniqueIndexImpl::FirstIndex() const
 {
-if ( empty() )
+if ( maMap.empty() )
 return UNIQUEINDEX_ENTRY_NOTFOUND;
 
-return begin()-first;
+return maMap.begin()-first;
 }
 
 sal_uIntPtr UniqueIndexImpl::LastIndex() const
 {
-if ( empty() )
+if ( maMap.empty() )
 return UNIQUEINDEX_ENTRY_NOTFOUND;
 
-return rbegin()-first;
+return maMap.rbegin()-first;
 }
 
 sal_uIntPtr UniqueIndexImpl::NextIndex(sal_uIntPtr aIndex) const
 {
-const_iterator it = find( aIndex );
-if ( it == end() )
+std::mapsal_uInt32, void*::const_iterator it = maMap.find( aIndex );
+if ( it == maMap.end() )
 return UNIQUEINDEX_ENTRY_NOTFOUND;
 ++it;
-if ( it == end() )
+if ( it == maMap.end() )
 return UNIQUEINDEX_ENTRY_NOTFOUND;
 return it-first;
 }
 
 sal_uIntPtr UniqueIndexImpl::GetIndexOf(void* p) const
 {
-for( const_iterator it = begin(); it != end(); ++it )
+for( std::mapsal_uInt32, void*::const_iterator it = maMap.begin(); it != 
maMap.end(); ++it )
 if( it-second == p )
 return it-first;
 return UNIQUEINDEX_ENTRY_NOTFOUND;

[Libreoffice-commits] core.git: include/tools tools/source

2014-07-08 Thread Michael Meeks
 include/tools/date.hxx  |3 +++
 tools/source/datetime/tdate.cxx |   31 +--
 2 files changed, 24 insertions(+), 10 deletions(-)

New commits:
commit a2b44216f1b1e8d7f4f293e13b257f49ae13de61
Author: Michael Meeks michael.me...@collabora.com
Date:   Tue Jul 8 11:49:59 2014 +0100

fdo#66507 - accelerate common datum date conversion to days.

Saves ~40bn cycles, 10% of calculation for the bug document.

Change-Id: I9d48706ad2cfe290965b648306d95b4d66e5fc63

diff --git a/include/tools/date.hxx b/include/tools/date.hxx
index 6b08e4a..e750573 100644
--- a/include/tools/date.hxx
+++ b/include/tools/date.hxx
@@ -190,6 +190,9 @@ public:
 /// Semantically identical to Normalize() member method.
 static bool Normalize( sal_uInt16  rDay, sal_uInt16  rMonth, sal_uInt16 
 rYear );
 
+ private:
+/// An accelerated form of DateToDays on this date
+long GetAsNormalizedDays() const;
 };
 
 #endif
diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 4fc2fc0..e1e640d 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -62,6 +62,17 @@ sal_uInt16 Date::GetDaysInMonth( sal_uInt16 nMonth, 
sal_uInt16 nYear )
 return ImplDaysInMonth( nMonth, nYear);
 }
 
+long Date::GetAsNormalizedDays() const
+{
+// This is a very common datum we often calculate from.
+if (nDate == 18991230) // 1899-12-30
+{
+assert(DateToDays( GetDay(), GetMonth(), GetYear() ) == 693594);
+return 693594;
+}
+return DateToDays( GetDay(), GetMonth(), GetYear() );
+}
+
 long Date::DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear )
 {
 long nDays;
@@ -173,7 +184,7 @@ void Date::SetYear( sal_uInt16 nNewYear )
 
 DayOfWeek Date::GetDayOfWeek() const
 {
-return (DayOfWeek)((sal_uIntPtr)(DateToDays( GetDay(), GetMonth(), 
GetYear() )-1) % 7);
+return (DayOfWeek)((sal_uIntPtr)(GetAsNormalizedDays()-1) % 7);
 }
 
 sal_uInt16 Date::GetDayOfYear() const
@@ -263,7 +274,8 @@ sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay,
 {
 // next x_Sunday == first x_Sunday in the new year
 // == still the same week!
-long nTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
+long nTempDays = GetAsNormalizedDays();
+
 nTempDays +=  6 - (GetDayOfWeek()+(7-(short)eStartDay)) % 7;
 sal_uInt16  nDay;
 sal_uInt16  nMonth;
@@ -405,7 +417,7 @@ Date Date::operator +=( long nDays )
 if (nDays == 0)
 return *this;
 
-longnTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
+long nTempDays = GetAsNormalizedDays();
 
 nTempDays += nDays;
 if ( nTempDays  MAX_DAYS )
@@ -430,7 +442,7 @@ Date Date::operator -=( long nDays )
 if (nDays == 0)
 return *this;
 
-longnTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
+long nTempDays = GetAsNormalizedDays();
 
 nTempDays -= nDays;
 if ( nTempDays  MAX_DAYS )
@@ -451,7 +463,7 @@ Date Date::operator ++()
 sal_uInt16  nDay;
 sal_uInt16  nMonth;
 sal_uInt16  nYear;
-longnTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
+long nTempDays = GetAsNormalizedDays();
 
 if ( nTempDays  MAX_DAYS )
 {
@@ -468,7 +480,7 @@ Date Date::operator --()
 sal_uInt16  nDay;
 sal_uInt16  nMonth;
 sal_uInt16  nYear;
-longnTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
+long nTempDays = GetAsNormalizedDays();
 
 if ( nTempDays  1 )
 {
@@ -509,10 +521,9 @@ Date operator -( const Date rDate, long nDays )
 
 long operator -( const Date rDate1, const Date rDate2 )
 {
-sal_uIntPtr  nTempDays1 = Date::DateToDays( rDate1.GetDay(), 
rDate1.GetMonth(),
-rDate1.GetYear() );
-sal_uIntPtr  nTempDays2 = Date::DateToDays( rDate2.GetDay(), 
rDate2.GetMonth(),
-rDate2.GetYear() );
+sal_uIntPtr nTempDays1 = rDate1.GetAsNormalizedDays();
+sal_uIntPtr nTempDays2 = rDate2.GetAsNormalizedDays();
+
 return nTempDays1 - nTempDays2;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2014-06-23 Thread Stephan Bergmann
 include/tools/urlobj.hxx |   50 +++--
 tools/source/fsys/urlobj.cxx |  237 ---
 2 files changed, 133 insertions(+), 154 deletions(-)

New commits:
commit 9ede5cd987a0e9287575875c53f0a10f6412236f
Author: Stephan Bergmann sberg...@redhat.com
Date:   Mon Jun 23 11:52:14 2014 +0200

Remove unused INetURLObject::PART_* values

Change-Id: Icebdf0cad5306ae42a30de0b4f997e3b611675eb

diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index cd10405..aee3aea 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -866,37 +866,25 @@ public:
 
 enum Part
 {
-PART_OBSOLETE_NORMAL = 0x001, // Obsolete, do not use!
-PART_OBSOLETE_FILE = 0x002, // Obsolete, do not use!
-PART_OBSOLETE_PARAM = 0x004, // Obsolete, do not use!
-PART_USER_PASSWORD = 0x008,
-PART_IMAP_ACHAR = 0x010,
-PART_VIM = 0x020,
-PART_HOST_EXTRA = 0x040,
-PART_FPATH = 0x080,
-PART_AUTHORITY = 0x100,
-PART_PATH_SEGMENTS_EXTRA = 0x200,
-PART_REL_SEGMENT_EXTRA = 0x400,
-PART_URIC = 0x800,
-PART_HTTP_PATH = 0x1000,
-PART_FILE_SEGMENT_EXTRA = 0x2000, // Obsolete, do not use!
-PART_MESSAGE_ID = 0x4000,
-PART_MESSAGE_ID_PATH = 0x8000,
-PART_MAILTO = 0x1,
-PART_PATH_BEFORE_QUERY = 0x2,
-PART_PCHAR = 0x4,
-PART_FRAGMENT = 0x8, // Obsolete, do not use!
-PART_VISIBLE = 0x10,
-PART_VISIBLE_NONSPECIAL = 0x20,
-PART_CREATEFRAGMENT = 0x40,
-PART_UNO_PARAM_VALUE = 0x80,
-PART_UNAMBIGUOUS = 0x100,
-PART_URIC_NO_SLASH = 0x200,
-PART_HTTP_QUERY = 0x400, //TODO! unused?
-PART_NEWS_ARTICLE_LOCALPART = 0x800,
-max_part = 0x8000
-// Do not use!  Only there to allow compatible changes in the
-// future.
+PART_USER_PASSWORD  = 0x1,
+PART_IMAP_ACHAR = 0x2,
+PART_VIM= 0x4,
+PART_FPATH  = 0x8,
+PART_AUTHORITY  = 0x00010,
+PART_REL_SEGMENT_EXTRA  = 0x00020,
+PART_URIC   = 0x00040,
+PART_HTTP_PATH  = 0x00080,
+PART_MESSAGE_ID_PATH= 0x00100,
+PART_MAILTO = 0x00200,
+PART_PATH_BEFORE_QUERY  = 0x00400,
+PART_PCHAR  = 0x00800,
+PART_VISIBLE= 0x01000,
+PART_VISIBLE_NONSPECIAL = 0x02000,
+PART_UNO_PARAM_VALUE= 0x04000,
+PART_UNAMBIGUOUS= 0x08000,
+PART_URIC_NO_SLASH  = 0x1,
+PART_HTTP_QUERY = 0x2, //TODO! unused?
+PART_NEWS_ARTICLE_LOCALPART = 0x4
 };
 
 enum EscapeType
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 55a5ddd..91fffad 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -441,134 +441,125 @@ namespace unnamed_tools_urlobj {
 
 enum
 {
-PA = INetURLObject::PART_OBSOLETE_NORMAL,
-PB = INetURLObject::PART_OBSOLETE_FILE,
-PC = INetURLObject::PART_OBSOLETE_PARAM,
-PD = INetURLObject::PART_USER_PASSWORD,
-PE = INetURLObject::PART_IMAP_ACHAR,
-PF = INetURLObject::PART_VIM,
-PG = INetURLObject::PART_HOST_EXTRA,
-PH = INetURLObject::PART_FPATH,
-PI = INetURLObject::PART_AUTHORITY,
-PJ = INetURLObject::PART_PATH_SEGMENTS_EXTRA,
-PK = INetURLObject::PART_REL_SEGMENT_EXTRA,
-PL = INetURLObject::PART_URIC,
-PM = INetURLObject::PART_HTTP_PATH,
-PN = INetURLObject::PART_FILE_SEGMENT_EXTRA,
-PO = INetURLObject::PART_MESSAGE_ID,
-PP = INetURLObject::PART_MESSAGE_ID_PATH,
-PQ = INetURLObject::PART_MAILTO,
-PR = INetURLObject::PART_PATH_BEFORE_QUERY,
-PS = INetURLObject::PART_PCHAR,
-PT = INetURLObject::PART_FRAGMENT,
-PU = INetURLObject::PART_VISIBLE,
-PV = INetURLObject::PART_VISIBLE_NONSPECIAL,
-PW = INetURLObject::PART_CREATEFRAGMENT,
-PX = INetURLObject::PART_UNO_PARAM_VALUE,
-PY = INetURLObject::PART_UNAMBIGUOUS,
-PZ = INetURLObject::PART_URIC_NO_SLASH,
-P1 = INetURLObject::PART_HTTP_QUERY,
-P2 = INetURLObject::PART_NEWS_ARTICLE_LOCALPART
+PA = INetURLObject::PART_USER_PASSWORD,
+PB = INetURLObject::PART_IMAP_ACHAR,
+PC = INetURLObject::PART_VIM,
+PD = INetURLObject::PART_FPATH,
+PE = INetURLObject::PART_AUTHORITY,
+PF = INetURLObject::PART_REL_SEGMENT_EXTRA,
+PG = INetURLObject::PART_URIC,
+PH = INetURLObject::PART_HTTP_PATH,
+PI = INetURLObject::PART_MESSAGE_ID_PATH,
+PJ = INetURLObject::PART_MAILTO,
+PK = INetURLObject::PART_PATH_BEFORE_QUERY,
+PL = INetURLObject::PART_PCHAR,
+PM = INetURLObject::PART_VISIBLE,
+PN = INetURLObject::PART_VISIBLE_NONSPECIAL,
+PO = 

[Libreoffice-commits] core.git: include/tools tools/source

2014-05-21 Thread Stephan Bergmann
 include/tools/zcodec.hxx   |   10 ++
 tools/source/zcodec/zcodec.cxx |  152 +++--
 2 files changed, 79 insertions(+), 83 deletions(-)

New commits:
commit 1c92fbf4fd73a8b0ad6b79b84fa67b7e24c948a1
Author: Stephan Bergmann sberg...@redhat.com
Date:   Wed May 21 17:03:41 2014 +0200

Replace ZCodec::mbInit with sane enum

...and document how the member functions are supposed to be called from 
client
code.

Change-Id: Ia4847945e4a361c43a0ed001e3e78e901c9abcad

diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 5dc6723..fe13970 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -27,10 +27,16 @@
 
 class SvStream;
 
+// The overall client call protocol is one of:
+// * BeginCompression, Compress, EndCompression
+// * BeginCompression, Decompress, EndCompression
+// * BeginCompression, Write*, EndCompression
+// * BeginCompression, Read*, EndCompression
+// * BeginCompression, ReadAsynchron*, EndCompression
 class TOOLS_DLLPUBLIC ZCodec
 {
-private:
-sal_uIntPtr mbInit;
+enum State { STATE_INIT, STATE_DECOMPRESS, STATE_COMPRESS };
+State   meState;
 boolmbStatus;
 boolmbFinish;
 SvStream*   mpIStm;
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 23abb0b..2a0b88d 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -38,7 +38,7 @@
 static const int gz_magic[2] = { 0x1f, 0x8b }; /* gzip magic header */
 
 ZCodec::ZCodec( sal_uIntPtr nInBufSize, sal_uIntPtr nOutBufSize )
-: mbInit(0)
+: meState(STATE_INIT)
 , mbStatus(false)
 , mbFinish(false)
 , mpIStm(NULL)
@@ -63,7 +63,7 @@ ZCodec::~ZCodec()
 
 void ZCodec::BeginCompression( int nCompressLevel, bool updateCrc, bool gzLib )
 {
-mbInit = 0;
+assert(meState == STATE_INIT);
 mbStatus = true;
 mbFinish = false;
 mpIStm = mpOStm = NULL;
@@ -83,9 +83,9 @@ long ZCodec::EndCompression()
 {
 long retvalue = 0;
 
-if ( mbInit != 0 )
+if (meState != STATE_INIT)
 {
-if ( mbInit  2 )   // 1-decompress, 3-compress
+if (meState == STATE_COMPRESS)
 {
 do
 {
@@ -105,6 +105,7 @@ long ZCodec::EndCompression()
 }
 delete[] mpOutBuf;
 delete[] mpInBuf;
+meState = STATE_INIT;
 }
 return ( mbStatus ) ? retvalue : -1;
 }
@@ -113,13 +114,11 @@ long ZCodec::Compress( SvStream rIStm, SvStream rOStm )
 {
 long nOldTotal_In = PZSTREAM-total_in;
 
-if ( mbInit == 0 )
-{
-mpIStm = rIStm;
-mpOStm = rOStm;
-ImplInitBuf( false );
-mpInBuf = new sal_uInt8[ mnInBufSize ];
-}
+assert(meState == STATE_INIT);
+mpIStm = rIStm;
+mpOStm = rOStm;
+ImplInitBuf( false );
+mpInBuf = new sal_uInt8[ mnInBufSize ];
 while (( PZSTREAM-avail_in = mpIStm-Read( PZSTREAM-next_in = mpInBuf, 
mnInBufSize )) != 0 )
 {
 if ( PZSTREAM-avail_out == 0 )
@@ -139,16 +138,11 @@ long ZCodec::Decompress( SvStream rIStm, SvStream rOStm 
)
 sal_uIntPtr nInToRead;
 longnOldTotal_Out = PZSTREAM-total_out;
 
-if ( mbFinish )
-return PZSTREAM-total_out - nOldTotal_Out;
-
-if ( mbInit == 0 )
-{
-mpIStm = rIStm;
-mpOStm = rOStm;
-ImplInitBuf( true );
-PZSTREAM-next_out = mpOutBuf = new sal_uInt8[ PZSTREAM-avail_out = 
mnOutBufSize ];
-}
+assert(meState == STATE_INIT);
+mpIStm = rIStm;
+mpOStm = rOStm;
+ImplInitBuf( true );
+PZSTREAM-next_out = mpOutBuf = new sal_uInt8[ PZSTREAM-avail_out = 
mnOutBufSize ];
 do
 {
 if ( PZSTREAM-avail_out == 0 ) ImplWriteBack();
@@ -173,14 +167,12 @@ long ZCodec::Decompress( SvStream rIStm, SvStream rOStm 
)
 while ( ( err != Z_STREAM_END)   ( PZSTREAM-avail_in || mnInToRead ) );
 ImplWriteBack();
 
-if ( err == Z_STREAM_END )
-mbFinish = true;
 return ( mbStatus ) ? (long)(PZSTREAM-total_out - nOldTotal_Out) : -1;
 }
 
 long ZCodec::Write( SvStream rOStm, const sal_uInt8* pData, sal_uIntPtr nSize 
)
 {
-if ( mbInit == 0 )
+if (meState == STATE_INIT)
 {
 mpOStm = rOStm;
 ImplInitBuf( false );
@@ -212,7 +204,7 @@ long ZCodec::Read( SvStream rIStm, sal_uInt8* pData, 
sal_uIntPtr nSize )
 return 0;   // PZSTREAM-total_out;
 
 mpIStm = rIStm;
-if ( mbInit == 0 )
+if (meState == STATE_INIT)
 {
 ImplInitBuf( true );
 }
@@ -256,7 +248,7 @@ long ZCodec::ReadAsynchron( SvStream rIStm, sal_uInt8* 
pData, sal_uIntPtr nSize
 if ( mbFinish )
 return 0;   // PZSTREAM-total_out;
 
-if ( mbInit == 0 )
+if (meState == STATE_INIT)
 {
 mpIStm = rIStm;
 ImplInitBuf( true );
@@ -308,7 +300,7 @@ void ZCodec::ImplWriteBack()
 
 if ( nAvail )
 {
-if ( mbInit  2  mbUpdateCrc )
+if (meState == STATE_COMPRESS 

[Libreoffice-commits] core.git: include/tools tools/source unusedcode.easy

2014-03-01 Thread Caolán McNamara
 include/tools/resmgr.hxx   |2 ++
 tools/source/rc/resmgr.cxx |6 --
 unusedcode.easy|7 ++-
 3 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 875129a8d4eca6b8ac184c4ae3539ffce8194e39
Author: Caolán McNamara caol...@redhat.com
Date:   Sat Mar 1 10:59:01 2014 +

callcatcher: update unused code

Change-Id: I429eeb3fc0dd0d0c55612eb482d99ab4ceda2f56

diff --git a/include/tools/resmgr.hxx b/include/tools/resmgr.hxx
index 2aef810..b25cc0a 100644
--- a/include/tools/resmgr.hxx
+++ b/include/tools/resmgr.hxx
@@ -137,8 +137,10 @@ public:
  static ResMgr* CreateResMgr( const sal_Char* pPrefixName,
   LanguageTag aLocale = LanguageTag( 
LANGUAGE_SYSTEM) );
 
+#ifdef DBG_UTIL
 /// Test whether resource still exists
 voidTestStack( const Resource * );
+#endif
 
 /// Check whether resource is available
 boolIsAvailable( const ResId rId,
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index ae9cd4c..e56a5d9 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -922,12 +922,6 @@ void ResMgr::TestStack( const Resource* pResObj )
 }
 }
 
-#else
-
-void ResMgr::TestStack( const Resource* )
-{
-}
-
 #endif
 
 bool ResMgr::IsAvailable( const ResId rId, const Resource* pResObj ) const
diff --git a/unusedcode.easy b/unusedcode.easy
index 86cb448..8043786 100644
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -41,6 +41,8 @@ OutputDevice::PixelToLogic(Region const, MapMode const) 
const
 SalGraphics::drawTransformedBitmap(basegfx::B2DPoint const, basegfx::B2DPoint 
const, basegfx::B2DPoint const, SalBitmap const, SalBitmap const*)
 ScDocument::CreateFormatTable() const
 ScExtIButton::GetSelected() const
+ScSimpleRefDlg::GetRefString() const
+ScTable::GetCellCount(short) const
 ScVbaFormatooo::vba::excel::XStyle::getAddIndent()
 ScVbaFormatooo::vba::excel::XStyle::setAddIndent(com::sun::star::uno::Any 
const)
 SdrItemBrowser::ForceParent()
@@ -57,6 +59,7 @@ SmFontPickList::Contains(Font const) const
 SmParser::Insert(rtl::OUString const, int)
 SotFactory::Find(SvGlobalName const)
 StyleSettings::SetActiveColor2(Color const)
+StyleSettings::SetCursorSize(long)
 StyleSettings::SetDeactiveColor2(Color const)
 StyleSettings::SetFloatTitleHeight(long)
 StyleSettings::SetHideDisabledMenuItems(bool)
@@ -244,9 +247,11 @@ connectivity::sdbcx::OGroup::OGroup(unsigned char)
 drawinglayer::attribute::SdrFillGraphicAttribute::getLogSize() const
 editeng::MisspellRange::MisspellRange()
 editeng::Section::Section()
+formula::DoubleVectorRefToken::GetRequestedArrayLength() const
 formula::FormulaDlg::CheckMatrix()
 formula::FormulaTokenArray::AddString(unsigned short const*)
-formula::SingleVectorRefToken::SingleVectorRefToken(double const*, unsigned 
long)
+formula::SingleVectorRefToken::GetRequestedArrayLength() const
+formula::SingleVectorRefToken::SingleVectorRefToken(double const*, unsigned 
long, unsigned long)
 oglcanvas::CanvasHelper::flush() const
 oglcanvas::TextLayout::draw(com::sun::star::rendering::ViewState const, 
com::sun::star::rendering::RenderState const, 
com::sun::star::uno::Referencecom::sun::star::rendering::XGraphicDevice 
const) const
 oox::AttributeConversion::decodeDouble(rtl::OUString const)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2014-02-18 Thread Jan Hubicka
 include/tools/zcodec.hxx   |5 -
 tools/source/zcodec/zcodec.cxx |5 -
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 3db6d2cb99f9559ba29759990675e469613a8bb0
Author: Jan Hubicka hubi...@ucw.cz
Date:   Tue Feb 18 19:17:46 2014 +0100

GCC 4.9, LTO: libvcl uses GZCodec but it is not linked with the 
implementation

This is not valid C++ and GCC now resolves the virtual calls and inlines
destructor that leads to undefined symbols.

Change-Id: I841d25bc6f994f0e73665b174994f9471597131e

diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 14e2d5b..e5d9592 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -102,7 +102,10 @@ class GZCodec : public ZCodec
 public:
 GZCodec(){};
 ~GZCodec(){};
-virtual voidBeginCompression( sal_uIntPtr nCompressMethod = 
ZCODEC_DEFAULT );
+virtual voidBeginCompression( sal_uIntPtr nCompressMethod = 
ZCODEC_DEFAULT )
+{
+ZCodec::BeginCompression( nCompressMethod | ZCODEC_GZ_LIB );
+};
 };
 
 #endif
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index fe2e573..dd993f1 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -413,9 +413,4 @@ sal_uIntPtr ZCodec::UpdateCRC ( sal_uIntPtr nLatestCRC, 
sal_uInt8* pSource, long
 return rtl_crc32( nLatestCRC, pSource, nDatSize );
 }
 
-void GZCodec::BeginCompression( sal_uIntPtr nCompressMethod )
-{
-ZCodec::BeginCompression( nCompressMethod | ZCODEC_GZ_LIB );
-};
-
 /* 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: include/tools tools/source

2013-10-21 Thread Caolán McNamara
 include/tools/string.hxx   |4 
 tools/source/string/strimp.cxx |   34 --
 2 files changed, 38 deletions(-)

New commits:
commit cfda947d7c0476b9c402c84f9d8515c76ec87bac
Author: Caolán McNamara caol...@redhat.com
Date:   Mon Oct 21 14:32:36 2013 +0100

Related: fdo#38838 remove UniString::Copy

Change-Id: I566e3ade54962bbc6ace9b757f79c1b8ed9ffd00

diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index 9560220..3933595 100644
--- a/include/tools/string.hxx
+++ b/include/tools/string.hxx
@@ -103,7 +103,6 @@ public:
 UniString();
 UniString( const ResId rResId );
 UniString( const UniString rStr );
-UniString( const UniString rStr, xub_StrLen nPos, 
xub_StrLen nLen );
 UniString( const OUString rStr );
~UniString();
 
@@ -133,9 +132,6 @@ public:
 
 xub_StrLen  Len() const { return (xub_StrLen)mpData-mnLen; }
 
-UniString   Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = 
STRING_LEN ) const
-{ return UniString( *this, nIndex, nCount ); }
-
 const sal_Unicode*  GetBuffer() const { return mpData-maStr; }
 
 friend sal_Bool operator == ( const UniString rStr1,   const 
UniString rStr2 );
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx
index a3e44fa..de479e4 100644
--- a/tools/source/string/strimp.cxx
+++ b/tools/source/string/strimp.cxx
@@ -94,40 +94,6 @@ STRING::STRING( const STRING rStr )
 mpData = rStr.mpData;
 }
 
-STRING::STRING( const STRING rStr, xub_StrLen nPos, xub_StrLen nLen )
-: mpData( NULL )
-{
-if ( nPos  rStr.mpData-mnLen )
-nLen = 0;
-else
-{
-// correct length if necessary
-sal_Int32 nMaxLen = rStr.mpData-mnLen-nPos;
-if ( nLen  nMaxLen )
-nLen = static_cast xub_StrLen (nMaxLen);
-}
-
-if ( nLen )
-{
-// Increase reference counter if it suffices
-if ( (nPos == 0)  (nLen == rStr.mpData-mnLen) )
-{
-STRING_ACQUIRE((STRING_TYPE *)rStr.mpData);
-mpData = rStr.mpData;
-}
-else
-{
-// otherwise, copy string
-mpData = ImplAllocData( nLen );
-memcpy( mpData-maStr, rStr.mpData-maStr+nPos, nLen*sizeof( 
STRCODE ) );
-}
-}
-else
-{
-STRING_NEW((STRING_TYPE **)mpData);
-}
-}
-
 STRING::~STRING()
 {
 // free string data
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source unusedcode.easy

2013-09-14 Thread Caolán McNamara
 include/tools/string.hxx   |2 -
 tools/source/string/strimp.cxx |   42 -
 unusedcode.easy|1 
 3 files changed, 1 insertion(+), 44 deletions(-)

New commits:
commit 5167539b10478cdb14d6690147d440d99ea05e83
Author: Caolán McNamara caol...@redhat.com
Date:   Sat Sep 14 14:04:23 2013 +0100

Related: fdo#38838 one UniString::Search variant now unused

Change-Id: Id0b7b9bf53985f0692cd446a528274fb2009d33e

diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index 5fd64e9..543ad6f 100644
--- a/include/tools/string.hxx
+++ b/include/tools/string.hxx
@@ -137,6 +137,7 @@ private:
 TOOLS_DLLPRIVATE sal_Bool   Equals( const sal_Unicode* pCharStr,
 xub_StrLen nIndex, xub_StrLen nLen ) const;
 TOOLS_DLLPRIVATE sal_Bool   EqualsIgnoreCaseAscii( const sal_Unicode* 
pCharStr ) const;
+TOOLS_DLLPRIVATE xub_StrLen Search( const sal_Unicode* pCharStr, 
xub_StrLen nIndex = 0 ) const;
 public:
 UniString();
 UniString( const ResId rResId );
@@ -250,7 +251,6 @@ public:
 
 xub_StrLen  Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const;
 xub_StrLen  Search( const UniString rStr, xub_StrLen nIndex = 0 ) 
const;
-xub_StrLen  Search( const sal_Unicode* pCharStr, xub_StrLen nIndex 
= 0 ) const;
 xub_StrLen  SearchAscii( const sal_Char* pAsciiStr, xub_StrLen 
nIndex = 0 ) const;
 xub_StrLen  SearchBackward( sal_Unicode c, xub_StrLen nIndex = 
STRING_LEN ) const;
 
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx
index c6d882b..3357c22 100644
--- a/tools/source/string/strimp.cxx
+++ b/tools/source/string/strimp.cxx
@@ -428,48 +428,6 @@ xub_StrLen STRING::Search( const STRING rStr, xub_StrLen 
nIndex ) const
 return STRING_NOTFOUND;
 }
 
-xub_StrLen STRING::Search( const STRCODE* pCharStr, xub_StrLen nIndex ) const
-{
-DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
-sal_Int32 nLen = mpData-mnLen;
-xub_StrLen nStrLen  = ImplStringLen( pCharStr );
-
-// rStr was not found if its length is zero
-// or index is larger than searched string
-if ( !nStrLen || (nIndex = nLen) )
-return STRING_NOTFOUND;
-
-const STRCODE* pStr = mpData-maStr;
-pStr += nIndex;
-
-if ( nStrLen == 1 )
-{
-STRCODE cSearch = *pCharStr;
-while ( nIndex  nLen )
-{
-if ( *pStr == cSearch )
-return nIndex;
-++pStr,
-++nIndex;
-}
-}
-else
-{
-// search only within string
-while ( nLen - nIndex = nStrLen )
-{
-// increase match if found
-if ( ImplStringCompareWithoutZero( pStr, pCharStr, nStrLen ) == 0 )
-return nIndex;
-++pStr,
-++nIndex;
-}
-}
-
-return STRING_NOTFOUND;
-}
-
 void STRING::SearchAndReplaceAll( STRCODE c, STRCODE cRep )
 {
 DBG_CHKTHIS( STRING, DBGCHECKSTRING );
diff --git a/unusedcode.easy b/unusedcode.easy
index 8004805..f736e9d 100644
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -57,7 +57,6 @@ SfxGrabBagItem::SetGrabBag(std::__debug::maprtl::OUString, 
com::sun::star::uno:
 SfxTemplatePanelControl::SetParagraphFamily()
 SmFontPickList::Contains(Font const) const
 SmParser::Insert(rtl::OUString const, int)
-String::Search(unsigned short const*, unsigned short) const
 SvdProgressInfo::ReportError()
 SvpSalInstance::PostEvent(SalFrame const*, void*, unsigned short)
 SvpSalInstance::PostedEventsInQueue()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools tools/source

2013-05-21 Thread Noel Grandin
 include/tools/diagnose_ex.h  |   44 --
 tools/source/debug/debug.cxx |   49 +++
 2 files changed, 54 insertions(+), 39 deletions(-)

New commits:
commit 863d38fbfa4fb4861e476828c46410602100919e
Author: Noel Grandin n...@peralex.com
Date:   Tue May 21 08:40:07 2013 +0200

move DBG_UNHANDLED_EXCEPTION out of line

makes it easier to set a breakpoint on it.
Plus it's getting a little big to be a macro.

Change-Id: I2827aa3618ba966fbc85a4a56e0e794a55630730
Reviewed-on: https://gerrit.libreoffice.org/3988
Reviewed-by: Fridrich Strba fridr...@documentfoundation.org
Tested-by: Fridrich Strba fridr...@documentfoundation.org

diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index 261c0ae..a38b2d4 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -30,6 +30,8 @@
 #define OSL_UNUSED( expression ) \
 (void)(expression)
 
+
+
 #if OSL_DEBUG_LEVEL  0
 #include com/sun/star/configuration/CorruptedConfigurationException.hpp
 #include com/sun/star/task/ErrorCodeIOException.hpp
@@ -39,51 +41,15 @@
 #include boost/current_function.hpp
 #include typeinfo
 
+void DbgUnhandledException(const ::com::sun::star::uno::Any 
caughtException, const char* currentFunction);
+
 /** reports a caught UNO exception via OSL diagnostics
 
 Note that whenever you use this, it might be an indicator that your 
error
 handling is not correct 
 */
 #define DBG_UNHANDLED_EXCEPTION()   \
-::com::sun::star::uno::Any caught( ::cppu::getCaughtException() ); \
-OString sMessage( caught an exception! ); \
-sMessage += \nin function:; \
-sMessage += BOOST_CURRENT_FUNCTION; \
-sMessage += \ntype: ; \
-sMessage += OUStringToOString( caught.getValueTypeName(), 
osl_getThreadTextEncoding() ); \
-::com::sun::star::uno::Exception exception; \
-caught = exception; \
-if ( !exception.Message.isEmpty() ) \
-{ \
-sMessage += \nmessage: ; \
-sMessage += OUStringToOString( exception.Message, 
osl_getThreadTextEncoding() ); \
-} \
-if ( exception.Context.is() ) \
-{ \
-const char* pContext = typeid( *exception.Context.get() ).name(); \
-sMessage += \ncontext: ; \
-sMessage += pContext; \
-} \
-{ \
-::com::sun::star::configuration::CorruptedConfigurationException \
-specialized; \
-if ( caught = specialized ) \
-{ \
-sMessage += \ndetails: ; \
-sMessage += OUStringToOString( \
-specialized.Details, osl_getThreadTextEncoding() ); \
-} \
-} \
-{ \
-::com::sun::star::task::ErrorCodeIOException specialized; \
-if ( caught = specialized ) \
-{ \
-sMessage += \ndetails: ; \
-sMessage += OString::valueOf( specialized.ErrCode ); \
-} \
-} \
-sMessage += \n; \
-OSL_ENSURE( false, sMessage.getStr() )
+DbgUnhandledException( ::cppu::getCaughtException(), 
BOOST_CURRENT_FUNCTION);
 
 #else   // OSL_DEBUG_LEVEL
 #define DBG_UNHANDLED_EXCEPTION()
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 104353b..eec15eb 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -42,6 +42,7 @@
 #include vector
 
 #include osl/diagnose.h
+#include tools/diagnose_ex.h
 
 #ifdef DBG_UTIL
 
@@ -1585,4 +1586,52 @@ void DbgOutf( const sal_Char*, ... ) {}
 
 #endif
 
+
+#if OSL_DEBUG_LEVEL  0
+
+void DbgUnhandledException(const css::uno::Any  caught, const char* 
currentFunction)
+{
+OString sMessage( caught an exception! );
+sMessage += \nin function:;
+sMessage += currentFunction;
+sMessage += \ntype: ;
+sMessage += OUStringToOString( caught.getValueTypeName(), 
osl_getThreadTextEncoding() );
+::com::sun::star::uno::Exception exception;
+caught = exception;
+if ( !exception.Message.isEmpty() )
+{
+sMessage += \nmessage: ;
+sMessage += OUStringToOString( exception.Message, 
osl_getThreadTextEncoding() );
+}
+if ( exception.Context.is() )
+{
+const char* pContext = typeid( *exception.Context.get() ).name();
+sMessage += \ncontext: ;
+sMessage += pContext;
+}
+{
+::com::sun::star::configuration::CorruptedConfigurationException
+specialized;
+if ( caught = specialized )
+{
+sMessage += \ndetails: ;
+sMessage += OUStringToOString(
+specialized.Details, osl_getThreadTextEncoding() );
+}
+}
+{
+