summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-01-22 14:33:23 +0100
committerMichael Stahl <mstahl@redhat.com>2015-01-23 14:04:25 +0100
commit853c2fc71a96755a9dee629fd5d0e1cff9a48034 (patch)
treed4e6429ade20f5cc1a701932e70708ddb6b2fbf6
parentba68436e3fea34b4ae696f96f8048502865cdc79 (diff)
sal: try to avoid abuse of OUStringBuffer(int) ctor
... to avoid bugs like commit f0d6e0e1e21afd0adf5bd01d771b2d83d8f13a48. Change-Id: I1e41d421609e09bf62a7a04ba34f3a8e8d118fd3
-rw-r--r--include/rtl/strbuf.hxx17
-rw-r--r--include/rtl/ustrbuf.hxx17
-rw-r--r--sc/source/core/data/documen4.cxx3
-rw-r--r--sc/source/core/data/documentimport.cxx3
-rw-r--r--xmloff/source/text/txtparai.cxx2
5 files changed, 39 insertions, 3 deletions
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 9352d54307c8..5450472c2fe1 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -96,6 +96,23 @@ public:
{
rtl_string_new_WithLength( &pData, length );
}
+#if __cplusplus >= 201103L
+ explicit OStringBuffer(unsigned int length)
+ : OStringBuffer(static_cast<int>(length))
+ {
+ }
+ explicit OStringBuffer(long length)
+ : OStringBuffer(static_cast<int>(length))
+ {
+ }
+ explicit OStringBuffer(unsigned long length)
+ : OStringBuffer(static_cast<int>(length))
+ {
+ }
+ // avoid obvious bugs
+ explicit OStringBuffer(char) = delete;
+ explicit OStringBuffer(sal_Unicode) = delete;
+#endif
/**
Constructs a string buffer so that it represents the same
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index a9252b851ce1..0240557f65ba 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -91,6 +91,23 @@ public:
{
rtl_uString_new_WithLength( &pData, length );
}
+#if __cplusplus >= 201103L
+ explicit OUStringBuffer(unsigned int length)
+ : OUStringBuffer(static_cast<int>(length))
+ {
+ }
+ explicit OUStringBuffer(long length)
+ : OUStringBuffer(static_cast<int>(length))
+ {
+ }
+ explicit OUStringBuffer(unsigned long length)
+ : OUStringBuffer(static_cast<int>(length))
+ {
+ }
+ // avoid obvious bugs
+ explicit OUStringBuffer(char) = delete;
+ explicit OUStringBuffer(sal_Unicode) = delete;
+#endif
/**
Constructs a string buffer so that it represents the same
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index e593351f4867..27f8a20d9267 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -374,7 +374,8 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // multiple (repeate
}
ScRefAddress aRef;
- OUStringBuffer aForString('=');
+ OUStringBuffer aForString;
+ aForString.append('=');
aForString.append(ScCompiler::GetNativeSymbol(ocTableOp));
aForString.append(ScCompiler::GetNativeSymbol( ocOpen));
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 48878f59eb84..4191642a44c4 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -375,7 +375,8 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam
ScDocument* pDoc = &mpImpl->mrDoc;
ScRefAddress aRef;
- OUStringBuffer aFormulaBuf('=');
+ OUStringBuffer aFormulaBuf;
+ aFormulaBuf.append('=');
aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocTableOp));
aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocOpen));
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 7676d74c5fe8..b65135f0b5df 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -133,7 +133,7 @@ void XMLCharContext::EndElement()
}
else
{
- OUStringBuffer sBuff( m_nCount );
+ OUStringBuffer sBuff(static_cast<int>(m_nCount));
while( m_nCount-- )
sBuff.append( &m_c, 1 );