merge the formfield patch from ooo-build
[ooovba.git] / package / source / zipapi / ByteChucker.cxx
blob3b609445a00050aa76a4197e76e37022f1442cd6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ByteChucker.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_package.hxx"
33 #include <ByteChucker.hxx>
34 #include <PackageConstants.hxx>
35 #include <com/sun/star/io/XSeekable.hpp>
36 #include <com/sun/star/io/XOutputStream.hpp>
38 using namespace ::com::sun::star::io;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
42 ByteChucker::ByteChucker(Reference<XOutputStream> xOstream)
43 : xStream(xOstream)
44 , xSeek (xOstream, UNO_QUERY )
45 , a1Sequence ( 1 )
46 , a2Sequence ( 2 )
47 , a4Sequence ( 4 )
48 , p1Sequence ( a1Sequence.getArray() )
49 , p2Sequence ( a2Sequence.getArray() )
50 , p4Sequence ( a4Sequence.getArray() )
54 ByteChucker::~ByteChucker()
58 void ByteChucker::WriteBytes( const Sequence< sal_Int8 >& aData )
59 throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
61 xStream->writeBytes(aData);
64 sal_Int64 ByteChucker::GetPosition( )
65 throw(IOException, RuntimeException)
67 return xSeek->getPosition();
70 ByteChucker& ByteChucker::operator << (sal_Int8 nInt8)
72 p1Sequence[0] = nInt8 & 0xFF;
73 WriteBytes( a1Sequence );
74 return *this;
77 ByteChucker& ByteChucker::operator << (sal_Int16 nInt16)
79 p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF);
80 p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF);
81 WriteBytes( a2Sequence );
82 return *this;
84 ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
86 p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF);
87 p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF);
88 p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF);
89 p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF);
90 WriteBytes( a4Sequence );
91 return *this;
94 ByteChucker& ByteChucker::operator << (sal_uInt8 nuInt8)
96 p1Sequence[0] = nuInt8 & 0xFF;
97 WriteBytes( a1Sequence );
98 return *this;
100 ByteChucker& ByteChucker::operator << (sal_uInt16 nuInt16)
102 p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF);
103 p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF);
104 WriteBytes( a2Sequence );
105 return *this;
107 ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
109 p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF);
110 p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF);
111 p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
112 p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
113 WriteBytes( a4Sequence );
114 return *this;