summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-19 15:41:59 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-19 16:52:22 +0200
commit7320d7a4a4dd0657f2d650a6f580ad399529f0f1 (patch)
treed6d4e3865290d2bbbbed0fcc13ae9981f648ca3f
parent766cdd869d7d983e9e171a3eae0629cb9a0206ff (diff)
OUStringChar must either take a sal_Unicode or an ASCII char
...so forbid anything else, to avoid issues like the one described in 766cdd869d7d983e9e171a3eae0629cb9a0206ff "This code wants to add the numeric SvxRotateMode value". Some remaining places that apparently do want to convert some numeric value to sal_Unicode have been augmented with an explicit cast. Change-Id: I6200a84e250e697bc88694bd71142ca1d9a13651 Reviewed-on: https://gerrit.libreoffice.org/81132 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--embeddedobj/source/msole/ownview.cxx2
-rw-r--r--include/rtl/stringutils.hxx3
-rw-r--r--sc/source/core/tool/editutil.cxx2
-rw-r--r--sc/source/filter/qpro/qpro.cxx2
-rw-r--r--sd/source/core/drawdoc4.cxx4
-rw-r--r--sd/source/core/stlsheet.cxx2
-rw-r--r--svl/source/numbers/zformat.cxx2
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx4
-rw-r--r--sw/source/core/edit/autofmt.cxx4
-rw-r--r--sw/source/core/table/swtable.cxx4
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/ui/vba/vbatablehelper.cxx4
-rw-r--r--sw/source/uibase/dbui/mmconfigitem.cxx2
-rw-r--r--unoidl/source/sourceprovider-scanner.l6
14 files changed, 24 insertions, 19 deletions
diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx
index 244ab320e270..7d938cfd15ba 100644
--- a/embeddedobj/source/msole/ownview.cxx
+++ b/embeddedobj/source/msole/ownview.cxx
@@ -289,7 +289,7 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI
aReadSeq[0] == '.'
)
{
- aFileSuffix += OUStringChar( aReadSeq[0] );
+ aFileSuffix += OUStringChar( sal_Unicode(aReadSeq[0]) );
}
} while( aReadSeq[0] );
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index 6ea44c72d8be..a043f753ccce 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -12,6 +12,7 @@
#include "sal/config.h"
+#include <cassert>
#include <cstddef>
#include "sal/types.h"
@@ -79,6 +80,8 @@ namespace rtl
*/
struct SAL_WARN_UNUSED OUStringChar_ {
constexpr OUStringChar_(sal_Unicode theC): c(theC) {}
+ constexpr OUStringChar_(char theC): c(theC) { assert(c <= 0x7F); }
+ template<typename T> OUStringChar_(T &&) = delete;
sal_Unicode const c;
};
using OUStringChar = OUStringChar_ const;
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index dbbda0548754..03543f2f0b6e 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -735,7 +735,7 @@ static OUString lcl_GetCharStr( sal_Int32 nNo )
nCalc = nNo % coDiff;
if( !nCalc )
nCalc = coDiff;
- aStr = OUStringChar( 'a' - 1 + nCalc ) + aStr;
+ aStr = OUStringChar( sal_Unicode('a' - 1 + nCalc) ) + aStr;
nNo = sal::static_int_cast<sal_Int32>( nNo - nCalc );
if( nNo )
nNo /= coDiff;
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index 116304c5ad7e..b59ce7f664ab 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -182,7 +182,7 @@ ErrCode ScQProReader::parse( ScDocument *pDoc )
if( nTab < 26 )
{
OUString aName;
- aName += OUStringChar( 'A' + nTab );
+ aName += OUStringChar( sal_Unicode('A' + nTab) );
if (!nTab)
pDoc->RenameTab( nTab, aName );
else
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index 8820252853d4..be447edcef72 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -1075,10 +1075,10 @@ OUString SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const
switch (mePageNumType)
{
case css::style::NumberingType::CHARS_UPPER_LETTER:
- aPageNumValue += OUStringChar( (nNum - 1) % 26 + 'A' );
+ aPageNumValue += OUStringChar( sal_Unicode((nNum - 1) % 26 + 'A') );
break;
case css::style::NumberingType::CHARS_LOWER_LETTER:
- aPageNumValue += OUStringChar( (nNum - 1) % 26 + 'a' );
+ aPageNumValue += OUStringChar( sal_Unicode((nNum - 1) % 26 + 'a') );
break;
case css::style::NumberingType::ROMAN_UPPER:
bUpper = true;
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 77f7908337bc..9d097c01f633 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -614,7 +614,7 @@ struct ApiNameMap
OUString GetApiNameForHelpId(sal_uLong nId)
{
if ((nId >= HID_PSEUDOSHEET_OUTLINE1) && (nId <= HID_PSEUDOSHEET_OUTLINE9))
- return "outline" + OUStringChar('1' + (nId - HID_PSEUDOSHEET_OUTLINE1));
+ return "outline" + OUStringChar(sal_Unicode('1' + (nId - HID_PSEUDOSHEET_OUTLINE1)));
for (const auto& i : pApiNameMap)
if (nId == i.mnHelpId)
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index e215ca40f84c..63a8b5d9e3ab 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -998,7 +998,7 @@ SvNumberformat::SvNumberformat(OUString& rString,
{
//! eSymbolType is negative
sal_uInt8 nNum = static_cast<sal_uInt8>(1 - (eSymbolType - BRACKET_SYMBOLTYPE_DBNUM1));
- sStr = "DBNum" + OUStringChar('0' + nNum);
+ sStr = "DBNum" + OUStringChar(sal_Unicode('0' + nNum));
NumFor[nIndex].SetNatNumNum( nNum, true );
}
break;
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index 0271af05eb69..4480fd533540 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -346,10 +346,10 @@ IMPL_LINK(GraphicExporter, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
switch(mpDoc->GetPageNumType())
{
case css::style::NumberingType::CHARS_UPPER_LETTER:
- aPageNumValue += OUStringChar( (mnPageNumber - 1) % 26 + 'A' );
+ aPageNumValue += OUStringChar( sal_Unicode((mnPageNumber - 1) % 26 + 'A') );
break;
case css::style::NumberingType::CHARS_LOWER_LETTER:
- aPageNumValue += OUStringChar( (mnPageNumber - 1) % 26 + 'a' );
+ aPageNumValue += OUStringChar( sal_Unicode((mnPageNumber - 1) % 26 + 'a') );
break;
case css::style::NumberingType::ROMAN_UPPER:
bUpper = true;
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 59de10036107..591c4a988d20 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -788,12 +788,12 @@ SwAutoFormat::GetDigitLevel(const SwTextFrame& rFrame, TextFrameIndex& rPos,
}
if( pNumTypes )
- *pNumTypes += OUStringChar('0' + SVX_NUM_ARABIC);
+ *pNumTypes += OUStringChar(sal_Unicode('0' + SVX_NUM_ARABIC));
eScan = eScan | CHG;
}
else if( pNumTypes && !(eScan & DIGIT) )
- *pNumTypes += OUStringChar('0' + SVX_NUM_ARABIC);
+ *pNumTypes += OUStringChar(sal_Unicode('0' + SVX_NUM_ARABIC));
eScan &= ~DELIM; // remove Delim
if( 0 != (eScan & ~CHG) && DIGIT != (eScan & ~CHG))
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 9c9a4b95b03d..5a099eec65cf 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1790,9 +1790,9 @@ void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm )
do {
const sal_uInt16 nCalc = nCol % coDiff;
if( nCalc >= 26 )
- rNm = OUStringChar( 'a' - 26 + nCalc ) + rNm;
+ rNm = OUStringChar( sal_Unicode('a' - 26 + nCalc) ) + rNm;
else
- rNm = OUStringChar( 'A' + nCalc ) + rNm;
+ rNm = OUStringChar( sal_Unicode('A' + nCalc) ) + rNm;
if( 0 == (nCol = nCol - nCalc) )
break;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7bbf9179b211..3eb6cf085b7c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6675,7 +6675,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
aBuffer.append( pPrev, pIt - pPrev );
// If bullet char is empty, set lvlText as empty
- if ( rNumberingString == OUStringChar(0) && nNumberingType == SVX_NUM_CHAR_SPECIAL )
+ if ( rNumberingString == OUStringChar('\0') && nNumberingType == SVX_NUM_CHAR_SPECIAL )
{
m_pSerializer->singleElementNS(XML_w, XML_lvlText, FSNS(XML_w, XML_val), "");
}
diff --git a/sw/source/ui/vba/vbatablehelper.cxx b/sw/source/ui/vba/vbatablehelper.cxx
index 45de339fb978..a106668f0c39 100644
--- a/sw/source/ui/vba/vbatablehelper.cxx
+++ b/sw/source/ui/vba/vbatablehelper.cxx
@@ -104,9 +104,9 @@ OUString SwVbaTableHelper::getColumnStr( sal_Int32 nCol )
do{
nCalc = nCol % coDiff;
if( nCalc >= 26 )
- sRet = OUStringChar( 'a' - 26 + nCalc ) + sRet;
+ sRet = OUStringChar( sal_Unicode('a' - 26 + nCalc) ) + sRet;
else
- sRet = OUStringChar( 'A' + nCalc ) + sRet;
+ sRet = OUStringChar( sal_Unicode('A' + nCalc) ) + sRet;
if( 0 == ( nCol = nCol - nCalc ) )
break;
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index 51df1fc8b202..7a60a41fff79 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -373,7 +373,7 @@ static void lcl_ConvertToNumbers(OUString& rBlock, const std::vector<std::pair<O
for (size_t i = 0; i < rHeaders.size(); ++i)
{
OUString sHeader = "<" + rHeaders[i].first + ">";
- OUString sReplace = "<" + OUStringChar('0' + i) + ">";
+ OUString sReplace = "<" + OUStringChar(sal_Unicode('0' + i)) + ">";
sBlock = sBlock.replaceAll(sHeader, sReplace);
}
rBlock = sBlock;
diff --git a/unoidl/source/sourceprovider-scanner.l b/unoidl/source/sourceprovider-scanner.l
index a688dd24c9e5..1c80c9e6d5b4 100644
--- a/unoidl/source/sourceprovider-scanner.l
+++ b/unoidl/source/sourceprovider-scanner.l
@@ -241,10 +241,12 @@ ALNUM {DIGIT}|{ALPHA}
}
. {
- unsigned char c = yytext[0];
+ char c = yytext[0];
yyextra->errorMessage = c >= ' ' && c <= '~'
? OUString("invalid character \"" + OUStringChar(c) + "\"")
- : OUString("invalid byte x" + OUString::number(c, 16).toAsciiUpperCase());
+ : OUString(
+ "invalid byte x"
+ + OUString::number(static_cast<unsigned char>(c), 16).toAsciiUpperCase());
return TOK_ERROR;
}