[Libreoffice-commits] .: 9 commits - basic/source comphelper/inc configure.in connectivity/source l10ntools/source starmath/inc tools/inc tools/source vbahelper/util xml2cmp/Executable_xml2cmp.mk
Caolán McNamara
caolan at kemper.freedesktop.org
Sat Sep 17 15:22:38 PDT 2011
basic/source/runtime/iosys.cxx | 9 --
comphelper/inc/comphelper/string.hxx | 84 +++++++++++++++++++++-
configure.in | 2
connectivity/source/drivers/dbase/DTable.cxx | 38 +++-------
l10ntools/source/export.cxx | 6 -
l10ntools/source/helpex.cxx | 7 -
l10ntools/source/lngmerge.cxx | 2
l10ntools/source/xrmmerge.cxx | 2
starmath/inc/parse.hxx | 34 ++++-----
tools/inc/tools/string.hxx | 3
tools/source/string/strimp.cxx | 31 --------
tools/source/string/tustring.cxx | 31 ++++++++
vbahelper/util/makefile.mk | 100 ---------------------------
xml2cmp/Executable_xml2cmp.mk | 10 --
14 files changed, 155 insertions(+), 204 deletions(-)
New commits:
commit 27ba6af823a3c174326d1e9c19aa114abd71f03e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 23:14:44 2011 +0100
m4 is a real pain with [], fixes missing themes/icons
diff --git a/configure.in b/configure.in
index 75c0385..43c34a5 100755
--- a/configure.in
+++ b/configure.in
@@ -7792,7 +7792,7 @@ for theme in $with_theme; do
[AC_MSG_ERROR([Unknown value for --with-themes: $theme])]
)
WITH_THEMES="$WITH_THEMES $theme"
- SCPDEFS="$SCPDEFS -DTHEME_`echo $theme|tr '[:lower:]' '[:upper:]'`"
+ SCPDEFS="$SCPDEFS -DTHEME_`echo $theme|tr '[[:lower:]]' '[[:upper:]]'`"
done
AC_MSG_RESULT([$WITH_THEMES])
AC_SUBST([WITH_THEMES])
commit ec303dfe52f7ba78ffba2a5327fda38abfef5d6f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 22:59:00 2011 +0100
charset arg doesn't exist anymore, fixes helpex
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 86b94d3..49d9a0f 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -527,7 +527,7 @@ Export::~Export()
if ( bMergeMode && !bUnmerge ) {
if ( !pMergeDataFile )
- pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog);//, bUTF8 );
+ pMergeDataFile = new MergeDataFile(sMergeSrc, sFile, bErrorLog);
delete pMergeDataFile;
}
@@ -1881,7 +1881,7 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
// search for merge data
if ( !pMergeDataFile ){
- pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );//, bUTF8 );
+ pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
// Init Languages
ByteString sTmp = Export::sLanguages;
@@ -1931,7 +1931,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
/*****************************************************************************/
{
if ( !pMergeDataFile ){
- pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );//, bUTF8 );
+ pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
// Init Languages
ByteString sTmp = Export::sLanguages;
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index e67f979..b6a0199 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -225,10 +225,8 @@ int _cdecl main( int argc, char *argv[] )
if ( bMergeMode )
{
-
//sal_uInt64 startreadloc = Export::startMessure();
- MergeDataFile aMergeDataFile( sSDFFile, sInputFile , sal_False, RTL_TEXTENCODING_MS_1252 );
- //MergeDataFile aMergeDataFile( sSDFFile, sInputFile , sal_False, RTL_TEXTENCODING_MS_1252, false );
+ MergeDataFile aMergeDataFile(sSDFFile, sInputFile, sal_False);
//Export::stopMessure( ByteString("read localize.sdf") , startreadloc );
hasNoError = aParser.Merge( sSDFFile, sOutputFile , Export::sLanguages , aMergeDataFile );
@@ -260,8 +258,7 @@ int _cdecl main( int argc, char *argv[] )
aFStream.close();
ByteString sHelpFile(""); // dummy
- //MergeDataFile aMergeDataFile( sSDFFile, sHelpFile , sal_False, RTL_TEXTENCODING_MS_1252, false );
- MergeDataFile aMergeDataFile( sSDFFile, sHelpFile , sal_False, RTL_TEXTENCODING_MS_1252 );
+ MergeDataFile aMergeDataFile( sSDFFile, sHelpFile, sal_False );
//aMergeDataFile.Dump();
std::vector<ByteString> aLanguages;
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 066fb01..8281073 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -219,7 +219,7 @@ sal_Bool LngParser::Merge(
}
nError = LNG_OK;
- MergeDataFile aMergeDataFile( rSDFFile, sSource , sal_False, RTL_TEXTENCODING_MS_1252);//, bDBIsUTF8 );
+ MergeDataFile aMergeDataFile( rSDFFile, sSource, sal_False );
ByteString sTmp( Export::sLanguages );
if( sTmp.ToUpperAscii().Equals("ALL") )
Export::SetLanguages( aMergeDataFile.GetLanguages() );
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 4043e6f..a2a701e 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -605,7 +605,7 @@ XRMResMerge::XRMResMerge(
{
if ( rMergeSource.Len())
pMergeDataFile = new MergeDataFile(
- rMergeSource, sInputFileName, bErrorLog);//, bUTF8 );
+ rMergeSource, sInputFileName, bErrorLog);
if( Export::sLanguages.EqualsIgnoreCaseAscii("ALL") ){
Export::SetLanguages( pMergeDataFile->GetLanguages() );
aLanguages = pMergeDataFile->GetLanguages();
commit 6c033b649dac28b2cd1ea9d0bc3e2ccf5aaf6e6e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 22:21:28 2011 +0100
drop makefile.mk
diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk
deleted file mode 100755
index 48f4f93..0000000
--- a/vbahelper/util/makefile.mk
+++ /dev/null
@@ -1,100 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..
-
-PRJNAME=vbahelper
-TARGET=vbahelper
-
-# --- Settings ---------------------------------------------------
-
-.INCLUDE : settings.mk
-
-TARGET_HELPER=vbahelper
-
-LIB1TARGET= $(SLB)$/$(TARGET).lib
-LIB1FILES=$(SLB)$/$(TARGET)bits.lib
-
-SHL1TARGET= $(TARGET_HELPER)$(DLLPOSTFIX)
-
-
-# dynamic libraries
-SHL1STDLIBS= \
- $(CPPULIB) \
- $(COMPHELPERLIB) \
- $(CPPUHELPERLIB) \
- $(BASICLIB) \
- $(TOOLSLIB) \
- $(SALLIB)\
- $(SFXLIB) \
- $(SVTOOLLIB) \
- $(SVLLIB) \
- $(VCLLIB) \
- $(SVTOOLLIB) \
- $(MSFILTERLIB) \
- $(TKLIB)
-
-SHL1DEPN=
-SHL1IMPLIB= i$(TARGET_HELPER)
-SHL1USE_EXPORTS=name
-SHL1LIBS=$(LIB1TARGET)
-
-SHL1DEF=$(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME=$(SHL1TARGET)
-DEFLIB1NAME=$(TARGET)
-
-TARGET_MSFORMS=msforms
-SHL2TARGET=$(TARGET_MSFORMS)$(DLLPOSTFIX).uno
-SHL2IMPLIB= i$(TARGET_MSFORMS)
-
-SHL2VERSIONMAP=$(SOLARENV)/src/component.map
-SHL2DEF=$(MISC)$/$(SHL2TARGET).def
-DEF2NAME=$(SHL2TARGET)
-SHL2STDLIBS= \
- $(CPPUHELPERLIB) \
- $(CPPULIB) \
- $(COMPHELPERLIB) \
- $(SVLIB) \
- $(TOOLSLIB) \
- $(SALLIB)\
- $(VBAHELPERLIB) \
- $(SFXLIB) \
- $(SVXLIB) \
- $(SVTOOLLIB) \
- $(SVLLIB) \
- $(VCLLIB) \
- $(TKLIB) \
- $(BASICLIB) \
- $(SVXMSFILTERLIB) \
-
-SHL2DEPN=$(SHL1TARGETN)
-SHL2LIBS=$(SLB)$/$(TARGET_MSFORMS).lib
-
-# --- Targets -----------------------------------------------------------
-
-.INCLUDE : target.mk
commit bca6b33e570888dca4f500ec76d2eefeb25452ac
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 21:43:49 2011 +0100
reformat so that numbers are correct
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index e4fb34f..f4a4973 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -97,23 +97,23 @@ enum SmTokenType
/*125*/ TMINUSPLUS, TOPLUS, TOMINUS, TDIV, TOTIMES,
/*130*/ TODIVIDE, TTRANSL, TTRANSR, TIINT, TIIINT,
/*135*/ TLINT, TLLINT, TLLLINT, TPROD, TCOPROD,
-/*140*/ TFORALL, TEXISTS, TNOTEXISTS, TLIM, TNABLA, TTOWARD,
-/*145*/ TSINH, TCOSH, TTANH, TCOTH, TASIN,
-/*150*/ TACOS, TATAN, TLN, TLOG, TUOPER,
-/*155*/ TBOPER, TBLACK, TWHITE, TRED, TGREEN,
-/*160*/ TBLUE, TCYAN, TMAGENTA, TYELLOW, TFIXED,
-/*165*/ TSANS, TSERIF, TPOINT, TASINH, TACOSH,
-/*170*/ TATANH, TACOTH, TACOT, TEXP, TCDOT,
-/*175*/ TODOT, TLESLANT, TGESLANT, TNSUBSET, TNSUPSET,
-/*180*/ TNSUBSETEQ, TNSUPSETEQ, TPARTIAL, TNEG, TNI,
-/*185*/ TBACKEPSILON, TALEPH, TIM, TRE, TWP,
-/*190*/ TEMPTYSET, TINFINITY, TESCAPE, TLIMSUP, TLIMINF,
-/*195*/ TNDIVIDES, TDRARROW, TDLARROW, TDLRARROW, TUNDERBRACE,
-/*200*/ TOVERBRACE, TCIRC, TTOP, THBAR, TLAMBDABAR,
-/*205*/ TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW, TDIVIDES,
-/*210*/ TNDIBVIDES, TSETN, TSETZ, TSETQ, TSETR,
-/*215*/ TSETC, TWIDEVEC, TWIDETILDE, TWIDEHAT, TWIDESLASH,
-/*220*/ TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE,
+/*140*/ TFORALL, TEXISTS, TNOTEXISTS, TLIM, TNABLA,
+/*145*/ TTOWARD, TSINH, TCOSH, TTANH, TCOTH,
+/*150*/ TASIN, TACOS, TATAN, TLN, TLOG,
+/*155*/ TUOPER, TBOPER, TBLACK, TWHITE, TRED,
+/*160*/ TGREEN, TBLUE, TCYAN, TMAGENTA, TYELLOW,
+/*165*/ TFIXED, TSANS, TSERIF, TPOINT, TASINH,
+/*170*/ TACOSH, TATANH, TACOTH, TACOT, TEXP,
+/*175*/ TCDOT, TODOT, TLESLANT, TGESLANT, TNSUBSET,
+/*180*/ TNSUPSET, TNSUBSETEQ, TNSUPSETEQ, TPARTIAL, TNEG,
+/*185*/ TNI, TBACKEPSILON, TALEPH, TIM, TRE,
+/*190*/ TWP, TEMPTYSET, TINFINITY, TESCAPE, TLIMSUP,
+/*195*/ TLIMINF, TNDIVIDES, TDRARROW, TDLARROW, TDLRARROW,
+/*200*/ TUNDERBRACE, TOVERBRACE, TCIRC, TTOP, THBAR,
+/*205*/ TLAMBDABAR, TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW,
+/*210*/ TDIVIDES, TNDIBVIDES, TSETN, TSETZ, TSETQ,
+/*215*/ TSETR, TSETC, TWIDEVEC, TWIDETILDE, TWIDEHAT,
+/*220*/ TWIDESLASH, TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE,
/*225*/ TUNKNOWN, TDEBUG
};
commit f20bafad82340f1f735c1804a34ddd3a34c00e74
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 14:09:38 2011 +0100
ditch ByteString::Expand
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx
index 9a70a66..b2bbfe7 100644
--- a/tools/inc/tools/string.hxx
+++ b/tools/inc/tools/string.hxx
@@ -177,7 +177,6 @@ private:
// Append(char)
void operator +=(int); // not implemented; to detect misuses
// of operator +=(sal_Char)
-
public:
ByteString();
ByteString( const ByteString& rStr );
@@ -234,8 +233,6 @@ public:
ByteString& Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN );
ByteString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const;
- ByteString& Expand( xub_StrLen nCount, sal_Char cExpandChar = ' ' );
-
ByteString& EraseLeadingChars( sal_Char c = ' ' );
ByteString& EraseTrailingChars( sal_Char c = ' ' );
ByteString& EraseLeadingAndTrailingChars( sal_Char c = ' ' );
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx
index 3d15cb2..d842875 100644
--- a/tools/source/string/strimp.cxx
+++ b/tools/source/string/strimp.cxx
@@ -769,37 +769,6 @@ STRING& STRING::Erase( xub_StrLen nIndex, xub_StrLen nCount )
// -----------------------------------------------------------------------
-STRING& STRING::Expand( xub_StrLen nCount, STRCODE cExpandChar )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- // Muss der String erweitert werden
- sal_Int32 nLen = mpData->mnLen;
- if ( nCount <= nLen )
- return *this;
-
- // Neuen String anlegen
- STRINGDATA* pNewData = ImplAllocData( nCount );
-
- // Alten String kopieren
- memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
-
- // und initialisieren
- STRCODE* pStr = pNewData->maStr;
- pStr += nLen;
- for (sal_Int32 i = nCount - nLen; i > 0; --i) {
- *pStr++ = cExpandChar;
- }
-
- // Alte Daten loeschen und Neue zuweisen
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = pNewData;
-
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
STRING& STRING::EraseLeadingChars( STRCODE c )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx
index 720d5a2..0f98741 100644
--- a/tools/source/string/tustring.cxx
+++ b/tools/source/string/tustring.cxx
@@ -474,4 +474,35 @@ STRING& STRING::Fill( xub_StrLen nCount, STRCODE cFillChar )
return *this;
}
+// -----------------------------------------------------------------------
+
+STRING& STRING::Expand( xub_StrLen nCount, STRCODE cExpandChar )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ // Muss der String erweitert werden
+ sal_Int32 nLen = mpData->mnLen;
+ if ( nCount <= nLen )
+ return *this;
+
+ // Neuen String anlegen
+ STRINGDATA* pNewData = ImplAllocData( nCount );
+
+ // Alten String kopieren
+ memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
+
+ // und initialisieren
+ STRCODE* pStr = pNewData->maStr;
+ pStr += nLen;
+ for (sal_Int32 i = nCount - nLen; i > 0; --i) {
+ *pStr++ = cExpandChar;
+ }
+
+ // Alte Daten loeschen und Neue zuweisen
+ STRING_RELEASE((STRING_TYPE *)mpData);
+ mpData = pNewData;
+
+ return *this;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 98f84dfaeff753f6bf7c8b841466dbb0319e9037
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 14:09:23 2011 +0100
simplify this
diff --git a/xml2cmp/Executable_xml2cmp.mk b/xml2cmp/Executable_xml2cmp.mk
index 40e8428..156199f 100644
--- a/xml2cmp/Executable_xml2cmp.mk
+++ b/xml2cmp/Executable_xml2cmp.mk
@@ -47,14 +47,8 @@ $(eval $(call gb_Executable_add_exception_objects,xml2cmp,\
xml2cmp/source/xcd/dependy \
))
-#uwinapi is part of STDLIBS on windows, but is created in sal,
-#which depends on this module.
-ifeq ($(OS),WNT)
+#uwinapi is part of STDLIBS on windows, but it is created in sal, which
+#depends on this module.
$(eval $(call gb_Executable_add_linked_libs,xml2cmp,\
$(filter-out uwinapi,$(gb_STDLIBS)) \
))
-else
-$(eval $(call gb_Executable_add_linked_libs,xml2cmp,\
- $(gb_STDLIBS) \
-))
-endif
commit 32b2e810ad2a6084d8a0e027aea414b65e2e8c4f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 00:15:49 2011 +0100
use read_uInt8s_AsOString and comphelper::string::padToLength
which allows us to simplify the read in DTable.cxx quite a bit
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 5b57527..fe08f66 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -51,6 +51,7 @@
#include <rtl/ustrbuf.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -659,14 +660,8 @@ SbError SbiStream::Read( ByteString& rBuf, sal_uInt16 n, bool bForceReadingPerBy
return nError = SbERR_BAD_RECORD_LENGTH;
rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*pStrm, n));
//Pad it out with ' ' to the requested length on short read
- sal_Int32 nRead = aBuffer.getLength();
sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n);
- if (nRead < nRequested)
- {
- aBuffer.setLength(nRequested);
- for (sal_Int32 i = nRead; i < nRequested; ++i)
- aBuffer.setCharAt(i, ' ');
- }
+ comphelper::string::padToLength(aBuffer, nRequested, ' ');
rBuf = aBuffer.makeStringAndClear();
}
MapError();
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index b0304fa..ccee3af 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -51,6 +51,7 @@
#include <connectivity/dbconversion.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include <comphelper/property.hxx>
+#include <comphelper/string.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/ucbhelper.hxx>
#include <comphelper/types.hxx>
@@ -61,6 +62,7 @@
#include "connectivity/dbconversion.hxx"
#include "resource/dbase_res.hrc"
#include <rtl/logfile.hxx>
+#include <rtl/strbuf.hxx>
#include <algorithm>
@@ -1951,12 +1953,14 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
if (!m_pMemoStream || !WriteMemo(rRow.get()[nPos]->get(), nBlockNo))
break;
- ByteString aStr;
- ByteString aBlock(rtl::OString::valueOf(static_cast<sal_Int32>(nBlockNo)));
- aStr.Expand(static_cast<sal_uInt16>(nLen - aBlock.Len()), '0' );
- aStr += aBlock;
+ rtl::OString aBlock(rtl::OString::valueOf(static_cast<sal_Int32>(nBlockNo)));
+ //align aBlock at the right of a nLen sequence, fill to the left with '0'
+ rtl::OStringBuffer aStr;
+ comphelper::string::padToLength(aStr, nLen - aBlock.getLength(), '0');
+ aStr.append(aBlock);
+
// Copy characters:
- memcpy(pData, aStr.GetBuffer(), nLen);
+ memcpy(pData, aStr.getStr(), nLen);
} break;
default:
{
@@ -2726,24 +2730,11 @@ sal_Bool ODbaseTable::ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable)
{
if ( bIsText )
{
- ::rtl::OUStringBuffer aStr;
- while ( nLength > STRING_MAXLEN )
- {
- ByteString aBStr;
- aBStr.Expand(STRING_MAXLEN);
- m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN);
- aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding));
- nLength -= STRING_MAXLEN;
- }
- if ( nLength > 0 )
- {
- ByteString aBStr;
- aBStr.Expand(static_cast<xub_StrLen>(nLength));
- m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength);
- aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding));
- }
- if ( aStr.getLength() )
- aVariable = aStr.makeStringAndClear();
+ rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*m_pMemoStream, nLength));
+ //pad it out with ' ' to expected length on short read
+ sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(nLength);
+ comphelper::string::padToLength(aBuffer, nRequested, ' ');
+ aVariable = rtl::OStringToOUString(aBuffer.makeStringAndClear(), m_eEncoding);
} // if ( bIsText )
else
{
commit 76092149d0bd7c5432441972ddfb622cad26af86
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 17 00:10:45 2011 +0100
add a pad and truncate
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index c7f29f6..aeec120 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -33,15 +33,15 @@
#include <cstddef>
#include "comphelper/comphelperdllapi.h"
-#include "sal/types.h"
+#include <sal/types.h>
+#include <rtl/strbuf.hxx>
+#include <rtl/ustrbuf.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/i18n/XCollator.hpp>
#include <com/sun/star/i18n/XBreakIterator.hpp>
-namespace rtl { class OUString; }
-
// rtl::OUString helper functions that are not widespread or mature enough to
// go into the stable URE API:
namespace comphelper { namespace string {
@@ -251,6 +251,84 @@ COMPHELPER_DLLPUBLIC inline sal_Bool matchL(const rtl::OString& rStr, const char
rStr.pData->length-fromIndex, pMatch, nMatchLen, nMatchLen ) == 0;
}
+
+namespace detail
+{
+ template<typename B> B& truncateToLength(B& rBuffer, sal_Int32 nLen)
+ {
+ if (nLen < rBuffer.getLength())
+ rBuffer.remove(nLen, rBuffer.getLength()-nLen);
+ return rBuffer;
+ }
+}
+
+/** Truncate a buffer to a given length.
+
+ If the StringBuffer has more characters than nLength it will be truncated
+ on the right to nLength characters.
+
+ Has no effect if the StringBuffer is <= nLength
+
+ @param rBuf StringBuffer to operate on
+ @param nLength Length to truncate the buffer to
+
+ @return rBuf;
+ */
+COMPHELPER_DLLPUBLIC inline rtl::OStringBuffer& truncateToLength(
+ rtl::OStringBuffer& rBuffer, sal_Int32 nLength) SAL_THROW(())
+{
+ return detail::truncateToLength(rBuffer, nLength);
+}
+
+COMPHELPER_DLLPUBLIC inline rtl::OUStringBuffer& truncateToLength(
+ rtl::OUStringBuffer& rBuffer, sal_Int32 nLength) SAL_THROW(())
+{
+ return detail::truncateToLength(rBuffer, nLength);
+}
+
+namespace detail
+{
+ template<typename B, typename U> B& padToLength(B& rBuffer, sal_Int32 nLen,
+ U cFill = '\0')
+ {
+ sal_Int32 nOrigLen = rBuffer.getLength();
+ if (nLen > nOrigLen)
+ {
+ rBuffer.setLength(nLen);
+ for (sal_Int32 i = nOrigLen; i < nLen; ++i)
+ rBuffer.setCharAt(i, cFill);
+ }
+ return rBuffer;
+ }
+}
+
+/** Pad a buffer to a given length using a given char.
+
+ If the StringBuffer has less characters than nLength it will be expanded on
+ the right to nLength characters, with the expansion filled using cFill.
+
+ Has no effect if the StringBuffer is >= nLength
+
+ @param rBuf StringBuffer to operate on
+ @param nLength Length to pad the buffer to
+ @param cFill character to fill expansion with
+
+ @return rBuf;
+ */
+COMPHELPER_DLLPUBLIC inline rtl::OStringBuffer& padToLength(
+ rtl::OStringBuffer& rBuffer, sal_Int32 nLength,
+ sal_Char cFill = '\0') SAL_THROW(())
+{
+ return detail::padToLength(rBuffer, nLength, cFill);
+}
+
+COMPHELPER_DLLPUBLIC inline rtl::OUStringBuffer& padToLength(
+ rtl::OUStringBuffer& rBuffer, sal_Int32 nLength,
+ sal_Unicode cFill = '\0') SAL_THROW(())
+{
+ return detail::padToLength(rBuffer, nLength, cFill);
+}
+
/** Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.
commit ba3ac5771366c0cecf0a6c39728f87dbf691fef6
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Sep 16 16:07:24 2011 +0100
memcpy is of the same length as preceding memset
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 6e1c5d8..b0304fa 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1956,7 +1956,6 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
aStr.Expand(static_cast<sal_uInt16>(nLen - aBlock.Len()), '0' );
aStr += aBlock;
// Copy characters:
- memset(pData,' ',nLen); // Clear to NULL
memcpy(pData, aStr.GetBuffer(), nLen);
} break;
default:
More information about the Libreoffice-commits
mailing list