Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
3ee84cb2
Kaydet (Commit)
3ee84cb2
authored
Ock 24, 2012
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use write_uInt16s_FromOUString pattern
üst
17ecf003
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
60 deletions
+94
-60
difexp.cxx
sc/source/filter/dif/difexp.cxx
+1
-1
docsh.cxx
sc/source/ui/docshell/docsh.cxx
+1
-1
stream.hxx
tools/inc/tools/stream.hxx
+58
-13
stream.cxx
tools/source/stream/stream.cxx
+30
-17
metaact.cxx
vcl/source/gdi/metaact.cxx
+4
-28
No files found.
sc/source/filter/dif/difexp.cxx
Dosyayı görüntüle @
3ee84cb2
...
...
@@ -255,7 +255,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
nPos
=
aTmpStr
.
Search
(
cStrDelim
,
nPos
+
2
);
}
rOut
.
WriteUniOrByteChar
(
cStrDelim
,
eCharSet
);
rOut
.
WriteUnicodeText
(
aTmpStr
);
write_uInt16s_FromOUString
(
rOut
,
aTmpStr
);
rOut
.
WriteUniOrByteChar
(
cStrDelim
,
eCharSet
);
}
else
if
(
bContextOrNotAsciiEncoding
)
...
...
sc/source/ui/docshell/docsh.cxx
Dosyayı görüntüle @
3ee84cb2
...
...
@@ -1947,7 +1947,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
}
if
(
bNeedQuotes
)
rStream
.
WriteUniOrByteChar
(
cStrDelim
,
eCharSet
);
rStream
.
WriteUnicodeText
(
aUniString
);
write_uInt16s_FromOUString
(
rStream
,
aUniString
);
if
(
bNeedQuotes
)
rStream
.
WriteUniOrByteChar
(
cStrDelim
,
eCharSet
);
}
...
...
tools/inc/tools/stream.hxx
Dosyayı görüntüle @
3ee84cb2
...
...
@@ -515,6 +515,50 @@ rtl::OUString read_lenPrefixed_uInt16s_ToOUString(SvStream& rStrm)
return
read_uInt16s_ToOUString
(
rStrm
,
nUnits
);
}
//Attempt to write a prefixed sequence of nUnits 16bit units from an OUString,
//returned value is number of bytes written
TOOLS_DLLPUBLIC
sal_Size
write_uInt16s_FromOUString
(
SvStream
&
rStrm
,
const
rtl
::
OUString
&
rStr
,
sal_Size
nUnits
);
TOOLS_DLLPUBLIC
inline
sal_Size
write_uInt16s_FromOUString
(
SvStream
&
rStrm
,
const
rtl
::
OUString
&
rStr
)
{
return
write_uInt16s_FromOUString
(
rStrm
,
rStr
,
rStr
.
getLength
());
}
namespace
streamdetail
{
//Attempt to write a pascal-style length (of type prefix) prefixed sequence of
//units from a string-type, returned value is number of bytes written (including
//byte-count of prefix)
template
<
typename
prefix
,
typename
S
,
sal_Size
(
*
writeOper
)(
SvStream
&
,
const
S
&
,
sal_Size
)
>
sal_Size
write_lenPrefixed_seq_From_str
(
SvStream
&
rStrm
,
const
S
&
rStr
)
{
SAL_WARN_IF
(
rStr
.
getLength
()
>
std
::
numeric_limits
<
prefix
>::
max
(),
"tools.stream"
,
"string too long for prefix count to fit in output type"
);
sal_Size
nWritten
=
0
;
prefix
nUnits
=
std
::
min
<
sal_Size
>
(
rStr
.
getLength
(),
std
::
numeric_limits
<
prefix
>::
max
());
rStrm
<<
nUnits
;
if
(
rStrm
.
good
())
{
nWritten
+=
sizeof
(
prefix
);
nWritten
+=
writeOper
(
rStrm
,
rStr
,
nUnits
);
}
return
nWritten
;
}
}
//Attempt to write a pascal-style length (of type prefix) prefixed sequence of
//16bit units from an OUString, returned value is number of bytes written (including
//byte-count of prefix)
template
<
typename
prefix
>
sal_Size
write_lenPrefixed_uInt16s_FromOUString
(
SvStream
&
rStrm
,
const
rtl
::
OUString
&
rStr
)
{
return
streamdetail
::
write_lenPrefixed_seq_From_str
<
prefix
,
rtl
::
OUString
,
write_uInt16s_FromOUString
>
(
rStrm
,
rStr
);
}
//Attempt to read 8bit units to an OString until a zero terminator is
//encountered, returned rtl::OString's length is number of units *definitely*
//successfully read, check SvStream::good() to see if null terminator was
...
...
@@ -546,25 +590,26 @@ rtl::OUString read_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
return
rtl
::
OStringToOUString
(
read_lenPrefixed_uInt8s_ToOString
<
prefix
>
(
rStrm
),
eEnc
);
}
//Attempt to write a prefixed sequence of nUnits 8bit units from an OString,
//returned value is number of bytes written
TOOLS_DLLPUBLIC
inline
sal_Size
write_uInt8s_FromOString
(
SvStream
&
rStrm
,
const
rtl
::
OString
&
rStr
,
sal_Size
nUnits
)
{
return
rStrm
.
Write
(
rStr
.
getStr
(),
nUnits
);
}
TOOLS_DLLPUBLIC
inline
sal_Size
write_uInt8s_FromOString
(
SvStream
&
rStrm
,
const
rtl
::
OString
&
rStr
)
{
return
write_uInt8s_FromOString
(
rStrm
,
rStr
,
rStr
.
getLength
());
}
//Attempt to write a pascal-style length (of type prefix) prefixed sequence of
//8bit units from an OString, returned value is number of bytes written (including
//byte-count of prefix)
template
<
typename
prefix
>
sal_Size
write_lenPrefixed_uInt8s_FromOString
(
SvStream
&
rStrm
,
const
rtl
::
OString
&
rStr
)
{
SAL_WARN_IF
(
rStr
.
getLength
()
>
std
::
numeric_limits
<
prefix
>::
max
(),
"tools.stream"
,
"string too long for prefix count to fit in output type"
);
sal_Size
nWritten
=
0
;
prefix
nUnits
=
std
::
min
<
sal_Size
>
(
rStr
.
getLength
(),
std
::
numeric_limits
<
prefix
>::
max
());
rStrm
<<
nUnits
;
if
(
rStrm
.
good
())
{
nWritten
+=
sizeof
(
prefix
);
nWritten
+=
rStrm
.
Write
(
rStr
.
getStr
(),
nUnits
);
}
return
nWritten
;
return
streamdetail
::
write_lenPrefixed_seq_From_str
<
prefix
,
rtl
::
OString
,
write_uInt8s_FromOString
>
(
rStrm
,
rStr
);
}
//Attempt to write a pascal-style length (of type prefix) prefixed sequence of
...
...
tools/source/stream/stream.cxx
Dosyayı görüntüle @
3ee84cb2
...
...
@@ -856,21 +856,21 @@ rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStream, rtl_TextE
read_zeroTerminated_uInt8s_ToOString
(
rStream
),
eEnc
);
}
/
*************************************************************************
|*
|* Stream::WriteUnicodeText()
|*
*************************************************************************/
sal_Bool
SvStream
::
WriteUnicodeText
(
const
String
&
rStr
)
{
DBG_ASSERT
(
sizeof
(
sal_Unicode
)
==
sizeof
(
sal_uInt16
),
"WriteUnicodeText: swapping sizeof(sal_Unicode) not implemented"
);
if
(
bSwap
)
/
/Attempt to write a prefixed sequence of nUnits 16bit units from an OUString,
//returned value is number of bytes written
sal_Size
write_uInt16s_FromOUString
(
SvStream
&
rStrm
,
const
rtl
::
OUString
&
rStr
,
sal_Size
nUnits
)
{
DBG_ASSERT
(
sizeof
(
sal_Unicode
)
==
sizeof
(
sal_uInt16
),
"write_uInt16s_FromOUString: swapping sizeof(sal_Unicode) not implemented"
);
sal_Size
nWritten
;
if
(
!
rStrm
.
IsEndianSwap
())
nWritten
=
rStrm
.
Write
(
(
char
*
)
rStr
.
getStr
(),
nUnits
*
sizeof
(
sal_Unicode
)
);
else
{
xub_StrLen
nLen
=
rStr
.
Len
()
;
sal_Size
nLen
=
nUnits
;
sal_Unicode
aBuf
[
384
];
sal_Unicode
*
const
pTmp
=
(
nLen
>
384
?
new
sal_Unicode
[
nLen
]
:
aBuf
);
memcpy
(
pTmp
,
rStr
.
GetBuffe
r
(),
nLen
*
sizeof
(
sal_Unicode
)
);
memcpy
(
pTmp
,
rStr
.
getSt
r
(),
nLen
*
sizeof
(
sal_Unicode
)
);
sal_Unicode
*
p
=
pTmp
;
const
sal_Unicode
*
const
pStop
=
pTmp
+
nLen
;
while
(
p
<
pStop
)
...
...
@@ -878,23 +878,36 @@ sal_Bool SvStream::WriteUnicodeText( const String& rStr )
SwapUShort
(
*
p
);
p
++
;
}
Write
(
(
char
*
)
pTmp
,
nLen
*
sizeof
(
sal_Unicode
)
);
nWritten
=
rStrm
.
Write
(
(
char
*
)
pTmp
,
nLen
*
sizeof
(
sal_Unicode
)
);
if
(
pTmp
!=
aBuf
)
delete
[]
pTmp
;
}
else
Write
(
(
char
*
)
rStr
.
GetBuffer
(),
rStr
.
Len
()
*
sizeof
(
sal_Unicode
)
);
return
nWritten
;
}
/*************************************************************************
|*
|* Stream::WriteUnicodeText()
|*
*************************************************************************/
sal_Bool
SvStream
::
WriteUnicodeText
(
const
String
&
rStr
)
{
write_uInt16s_FromOUString
(
*
this
,
rStr
,
rStr
.
Len
());
return
nError
==
SVSTREAM_OK
;
}
sal_Bool
SvStream
::
WriteUnicodeOrByteText
(
const
String
&
rStr
,
rtl_TextEncoding
eDestCharSet
)
{
if
(
eDestCharSet
==
RTL_TEXTENCODING_UNICODE
)
return
WriteUnicodeText
(
rStr
);
{
write_uInt16s_FromOUString
(
*
this
,
rStr
,
rStr
.
Len
());
return
nError
==
SVSTREAM_OK
;
}
else
{
rtl
::
OString
aStr
(
rtl
::
OUStringToOString
(
rStr
,
eDestCharSet
));
Write
(
aStr
.
getStr
()
,
aStr
.
getLength
());
write_uInt8s_FromOString
(
*
this
,
aStr
,
aStr
.
getLength
());
return
nError
==
SVSTREAM_OK
;
}
}
...
...
vcl/source/gdi/metaact.cxx
Dosyayı görüntüle @
3ee84cb2
...
...
@@ -1263,13 +1263,7 @@ void MetaTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
rOStm
<<
mnIndex
;
rOStm
<<
mnLen
;
sal_uInt16
nLen
=
sal
::
static_int_cast
<
sal_uInt16
>
(
maStr
.
getLength
());
// version 2
rOStm
<<
nLen
;
for
(
sal_uInt16
i
=
0
;
i
<
nLen
;
++
i
)
{
sal_Unicode
nUni
=
maStr
[
i
];
rOStm
<<
nUni
;
}
write_lenPrefixed_uInt16s_FromOUString
<
sal_uInt16
>
(
rOStm
,
maStr
);
// version 2
}
// ------------------------------------------------------------------------
...
...
@@ -1410,13 +1404,7 @@ void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
for
(
sal_uLong
i
=
0UL
;
i
<
nAryLen
;
i
++
)
rOStm
<<
mpDXAry
[
i
];
sal_uInt16
nLen
=
sal
::
static_int_cast
<
sal_uInt16
>
(
maStr
.
getLength
());
// version 2
rOStm
<<
nLen
;
for
(
sal_uInt16
j
=
0
;
j
<
nLen
;
++
j
)
{
sal_Unicode
nUni
=
maStr
[
j
];
rOStm
<<
nUni
;
}
write_lenPrefixed_uInt16s_FromOUString
<
sal_uInt16
>
(
rOStm
,
maStr
);
// version 2
}
// ------------------------------------------------------------------------
...
...
@@ -1550,13 +1538,7 @@ void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
rOStm
<<
mnIndex
;
rOStm
<<
mnLen
;
sal_uInt16
nLen
=
sal
::
static_int_cast
<
sal_uInt16
>
(
maStr
.
getLength
());
// version 2
rOStm
<<
nLen
;
for
(
sal_uInt16
i
=
0
;
i
<
nLen
;
++
i
)
{
sal_Unicode
nUni
=
maStr
[
i
];
rOStm
<<
nUni
;
}
write_lenPrefixed_uInt16s_FromOUString
<
sal_uInt16
>
(
rOStm
,
maStr
);
// version 2
}
// ------------------------------------------------------------------------
...
...
@@ -1637,13 +1619,7 @@ void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
rOStm
.
WriteUniOrByteString
(
maStr
,
pData
->
meActualCharSet
);
rOStm
<<
mnStyle
;
sal_uInt16
nLen
=
sal
::
static_int_cast
<
sal_uInt16
>
(
maStr
.
getLength
());
// version 2
rOStm
<<
nLen
;
for
(
sal_uInt16
i
=
0
;
i
<
nLen
;
++
i
)
{
sal_Unicode
nUni
=
maStr
[
i
];
rOStm
<<
nUni
;
}
write_lenPrefixed_uInt16s_FromOUString
<
sal_uInt16
>
(
rOStm
,
maStr
);
// version 2
}
// ------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment