summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-22 13:47:46 +0200
committerNoel Grandin <noel@peralex.com>2014-07-23 13:26:18 +0200
commite72ddca6a00b2f86f58869db9f688c37d9072bda (patch)
treecce5c4ffedb3975eaf48c648d5eb93c27519ecac /svl
parent8497efb425d901257464a03e7c5faa3f1bbea9fe (diff)
move string IO methods out of global header
and into a module-local header. It's not like the methods have any actual relationship with the SfxPoolItem class. Change-Id: I1378364a1554642333b0c5c79d869d719b53fa0c
Diffstat (limited to 'svl')
-rw-r--r--svl/source/inc/poolio.hxx43
-rw-r--r--svl/source/inc/stringio.hxx66
-rw-r--r--svl/source/items/cntwall.cxx1
-rw-r--r--svl/source/items/ctypeitm.cxx1
-rw-r--r--svl/source/items/macitem.cxx9
-rw-r--r--svl/source/items/poolio.cxx28
-rw-r--r--svl/source/items/poolitem.cxx25
-rw-r--r--svl/source/items/slstitm.cxx1
-rw-r--r--svl/source/items/stritem.cxx1
9 files changed, 142 insertions, 33 deletions
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index 02e1c60913e9..2dcd2cafdc46 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -71,7 +71,7 @@ struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl
typedef boost::unordered_map<SfxPoolItem*,sal_uInt32> Hash;
public:
- /// Track list of indicees into our array that contain an empty slot
+ /// Track list of indices into our array that contain an empty slot
FreeList maFree;
/// Hash of SfxPoolItem pointer to index into our array that contains that slot
Hash maHash;
@@ -244,6 +244,47 @@ struct SfxItemPool_Impl
#define SFX_STYLES_REC_HEADER sal_uInt16(0x0010)
#define SFX_STYLES_REC_STYLES sal_uInt16(0x0020)
+/** Read in a Unicode string from a streamed byte string representation.
+
+ @param rStream Some (input) stream. Its Stream/TargetCharSets must
+ be set to correct values!
+
+ @return On success, returns the reconstructed Unicode string.
+ */
+OUString readByteString(SvStream & rStream);
+
+/** Write a byte string representation of a Unicode string into a stream.
+
+ @param rStream Some (output) stream. Its Stream/TargetCharSets must
+ be set to correct values!
+
+ @param rString Some Unicode string.
+ */
+void writeByteString(SvStream & rStream, const OUString& rString);
+
+/** Read in a Unicode string from either a streamed Unicode or byte string
+ representation.
+
+ @param rStream Some (input) stream. If bUnicode is false, its
+ Stream/TargetCharSets must be set to correct values!
+
+ @param bUnicode Whether to read in a stream Unicode (true) or byte
+ string (false) representation.
+
+ @return On success, returns the reconstructed Unicode string.
+ */
+OUString readUnicodeString(SvStream & rStream, bool bUnicode);
+
+/** Write a Unicode string representation of a Unicode string into a
+ stream.
+
+ @param rStream Some (output) stream.
+
+ @param rString Some Unicode string.
+ */
+void writeUnicodeString(SvStream & rStream, const OUString& rString);
+
+
#endif // INCLUDED_SVL_SOURCE_INC_POOLIO_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/inc/stringio.hxx b/svl/source/inc/stringio.hxx
new file mode 100644
index 000000000000..6d8685205ee2
--- /dev/null
+++ b/svl/source/inc/stringio.hxx
@@ -0,0 +1,66 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SVL_SOURCE_INC_STRINGIO_HXX
+#define INCLUDED_SVL_SOURCE_INC_STRINGIO_HXX
+
+/** Read in a Unicode string from a streamed byte string representation.
+
+ @param rStream Some (input) stream. Its Stream/TargetCharSets must
+ be set to correct values!
+
+ @return On success, returns the reconstructed Unicode string.
+ */
+OUString readByteString(SvStream & rStream);
+
+/** Write a byte string representation of a Unicode string into a stream.
+
+ @param rStream Some (output) stream. Its Stream/TargetCharSets must
+ be set to correct values!
+
+ @param rString Some Unicode string.
+ */
+void writeByteString(SvStream & rStream, const OUString& rString);
+
+/** Read in a Unicode string from either a streamed Unicode or byte string
+ representation.
+
+ @param rStream Some (input) stream. If bUnicode is false, its
+ Stream/TargetCharSets must be set to correct values!
+
+ @param bUnicode Whether to read in a stream Unicode (true) or byte
+ string (false) representation.
+
+ @return On success, returns the reconstructed Unicode string.
+ */
+OUString readUnicodeString(SvStream & rStream, bool bUnicode);
+
+/** Write a Unicode string representation of a Unicode string into a
+ stream.
+
+ @param rStream Some (output) stream.
+
+ @param rString Some Unicode string.
+ */
+void writeUnicodeString(SvStream & rStream, const OUString& rString);
+
+
+#endif // INCLUDED_SVL_SOURCE_INC_STRINGIO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/cntwall.cxx b/svl/source/items/cntwall.cxx
index afd8e34774f8..ce2fe9dd929a 100644
--- a/svl/source/items/cntwall.cxx
+++ b/svl/source/items/cntwall.cxx
@@ -23,6 +23,7 @@
#include <tools/vcompat.hxx>
#include <svl/cntwall.hxx>
+#include <stringio.hxx>
#define CNTWALLPAPERITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
#define CNTWALLPAPERITEM_STREAM_SEEKREL (-( (long)( sizeof( sal_uInt32 ) ) ) )
diff --git a/svl/source/items/ctypeitm.cxx b/svl/source/items/ctypeitm.cxx
index e212bc6e8441..d0a2734d3204 100644
--- a/svl/source/items/ctypeitm.cxx
+++ b/svl/source/items/ctypeitm.cxx
@@ -22,6 +22,7 @@
#include <unotools/intlwrapper.hxx>
#include <tools/stream.hxx>
#include <svl/ctypeitm.hxx>
+#include <stringio.hxx>
// The following defines are copied from chaos/source/items/cstritem.cxx:
#define CNTSTRINGITEM_STREAM_MAGIC ( (sal_uInt32)0xfefefefe )
diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx
index ca0eb4205d47..ecdfa9fa5159 100644
--- a/svl/source/items/macitem.cxx
+++ b/svl/source/items/macitem.cxx
@@ -20,6 +20,7 @@
#include <tools/stream.hxx>
#include <svl/macitem.hxx>
+#include <stringio.hxx>
TYPEINIT1_FACTORY(SvxMacroItem, SfxPoolItem, new SvxMacroItem(0));
@@ -107,8 +108,8 @@ SvStream& SvxMacroTableDtor::Read( SvStream& rStrm, sal_uInt16 nVersion )
sal_uInt16 nCurKey, eType = STARBASIC;
OUString aLibName, aMacName;
rStrm.ReadUInt16( nCurKey );
- aLibName = SfxPoolItem::readByteString(rStrm);
- aMacName = SfxPoolItem::readByteString(rStrm);
+ aLibName = readByteString(rStrm);
+ aMacName = readByteString(rStrm);
if( SVX_MACROTBL_VERSION40 <= nVersion )
rStrm.ReadUInt16( eType );
@@ -135,8 +136,8 @@ SvStream& SvxMacroTableDtor::Write( SvStream& rStream ) const
{
const SvxMacro& rMac = it->second;
rStream.WriteUInt16( it->first );
- SfxPoolItem::writeByteString(rStream, rMac.GetLibName());
- SfxPoolItem::writeByteString(rStream, rMac.GetMacName());
+ writeByteString(rStream, rMac.GetLibName());
+ writeByteString(rStream, rMac.GetMacName());
if( SVX_MACROTBL_VERSION40 <= nVersion )
rStream.WriteUInt16( (sal_uInt16)rMac.GetScriptType() );
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index 4a3c67d26a99..4b667c1b56e0 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -149,7 +149,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
{
SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER);
rStream.WriteUInt16( pImp->nVersion );
- SfxPoolItem::writeByteString(rStream, pImp->aName);
+ writeByteString(rStream, pImp->aName);
}
// VersionMaps
@@ -560,7 +560,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
// Read Header
rStream.ReadUInt16( pImp->nLoadingVersion );
- aExternName = SfxPoolItem::readByteString(rStream);
+ aExternName = readByteString(rStream);
bool bOwnPool = aExternName == pImp->aName;
//! As long as we cannot read foreign Pools
@@ -734,7 +734,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
OUString aExternName;
if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 2 )
rStream.ReadUInt16( pImp->nLoadingVersion );
- aExternName = SfxPoolItem::readByteString(rStream);
+ aExternName = readByteString(rStream);
bool bOwnPool = aExternName == pImp->aName;
pImp->bStreaming = true;
@@ -1534,4 +1534,26 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
}
+OUString readByteString(SvStream& rStream)
+{
+ return rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
+}
+
+void writeByteString(SvStream & rStream, const OUString& rString)
+{
+ rStream.WriteUniOrByteString(rString, rStream.GetStreamCharSet());
+}
+
+OUString readUnicodeString(SvStream & rStream, bool bUnicode)
+{
+ return rStream.ReadUniOrByteString(bUnicode ? RTL_TEXTENCODING_UCS2 :
+ rStream.GetStreamCharSet());
+}
+
+void writeUnicodeString(SvStream & rStream, const OUString& rString)
+{
+ rStream.WriteUniOrByteString(rString, RTL_TEXTENCODING_UCS2);
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index ef327d69b2ff..6445721cd141 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -159,31 +159,6 @@ SvStream& SfxPoolItem::Store(SvStream &rStream, sal_uInt16 ) const
return rStream;
}
-// static
-OUString SfxPoolItem::readByteString(SvStream& rStream)
-{
- return rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
-}
-
-// static
-void SfxPoolItem::writeByteString(SvStream & rStream, const OUString& rString)
-{
- rStream.WriteUniOrByteString(rString, rStream.GetStreamCharSet());
-}
-
-// static
-OUString SfxPoolItem::readUnicodeString(SvStream & rStream, bool bUnicode)
-{
- return rStream.ReadUniOrByteString(bUnicode ? RTL_TEXTENCODING_UCS2 :
- rStream.GetStreamCharSet());
-}
-
-// static
-void SfxPoolItem::writeUnicodeString(SvStream & rStream, const OUString& rString)
-{
- rStream.WriteUniOrByteString(rString, RTL_TEXTENCODING_UCS2);
-}
-
/**
* This virtual method allows to get a textual representation of the value
* for the SfxPoolItem subclasses. It should be overloaded by all UI-relevant
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx
index 2b875f8db728..8fc3c5d10e34 100644
--- a/svl/source/items/slstitm.cxx
+++ b/svl/source/items/slstitm.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <tools/stream.hxx>
+#include <stringio.hxx>
TYPEINIT1_AUTOFACTORY(SfxStringListItem, SfxPoolItem);
diff --git a/svl/source/items/stritem.cxx b/svl/source/items/stritem.cxx
index bdb75b63caaa..dd94154bbe8e 100644
--- a/svl/source/items/stritem.cxx
+++ b/svl/source/items/stritem.cxx
@@ -18,6 +18,7 @@
*/
#include <svl/stritem.hxx>
+#include <stringio.hxx>
// class SfxStringItem