merge the formfield patch from ooo-build
[ooovba.git] / automation / source / server / scmdstrm.cxx
blob8da348871af54fbcb5de2800cf2dcec34466523e
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: scmdstrm.cxx,v $
10 * $Revision: 1.7 $
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_automation.hxx"
33 #include <svtools/intitem.hxx>
34 #include <svtools/stritem.hxx>
35 #include <svtools/eitem.hxx>
36 #include "scmdstrm.hxx"
37 #include "svcommstream.hxx"
38 #include "rcontrol.hxx"
40 #if OSL_DEBUG_LEVEL > 1
41 #include "editwin.hxx"
42 #include "statemnt.hxx"
43 #endif
45 SCmdStream::SCmdStream(SvStream *pIn)
47 pSammel = pIn;
48 pCommStream = new SvCommStream( pSammel );
49 // SetCommStream( pCommStream );
52 SCmdStream::~SCmdStream()
54 delete pCommStream;
57 void SCmdStream::Read (String* &pString)
59 if ( !pString )
60 pString = new String();
61 comm_UniChar* pStr;
62 USHORT nLenInChars;
63 CmdBaseStream::Read( pStr, nLenInChars );
65 *pString = String( pStr, nLenInChars );
66 delete [] pStr;
69 void SCmdStream::Read (String &aString)
71 comm_UniChar* pStr;
72 USHORT nLenInChars;
73 CmdBaseStream::Read( pStr, nLenInChars );
75 aString = String( pStr, nLenInChars );
76 delete [] pStr;
79 void SCmdStream::Read ( SfxPoolItem *&pItem )
81 USHORT nType;
82 USHORT nId;
83 Read(nId);
84 #if OSL_DEBUG_LEVEL > 1
85 StatementList::m_pDbgWin->AddText( "Parameter: " );
86 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nId ) );
87 StatementList::m_pDbgWin->AddText( " " );
88 #endif
89 Read( nType );
90 switch (nType)
92 case BinUSHORT:
94 comm_USHORT nNr;
95 Read (nNr );
96 pItem = new SfxUInt16Item(nId,nNr);
97 #if OSL_DEBUG_LEVEL > 1
98 StatementList::m_pDbgWin->AddText( "USHORT:" );
99 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
100 #endif
102 break;
103 case BinULONG:
105 comm_ULONG nNr;
106 Read (nNr );
107 pItem = new SfxUInt32Item(nId,nNr);
108 #if OSL_DEBUG_LEVEL > 1
109 StatementList::m_pDbgWin->AddText( "ULONG:" );
110 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
111 #endif
113 break;
114 case BinString:
116 String aString;
117 Read (aString);
119 pItem = new SfxStringItem(nId,aString);
120 #if OSL_DEBUG_LEVEL > 1
121 StatementList::m_pDbgWin->AddText( "String:" );
122 StatementList::m_pDbgWin->AddText( aString );
123 #endif
125 break;
126 case BinBool:
128 comm_BOOL bBool;
129 Read (bBool);
130 pItem = new SfxBoolItem(nId,bBool);
131 #if OSL_DEBUG_LEVEL > 1
132 StatementList::m_pDbgWin->AddText( "BOOL:" );
133 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
134 #endif
136 break;
137 default:
138 DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType );
139 #if OSL_DEBUG_LEVEL > 1
140 StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " );
141 #endif
142 break;
144 #if OSL_DEBUG_LEVEL > 1
145 StatementList::m_pDbgWin->AddText( "\n" );
146 #endif
149 void SCmdStream::Read ( ::com::sun::star::beans::PropertyValue &rItem )
151 USHORT nType;
152 String aId;
153 Read(aId);
154 rItem.Name = rtl::OUString( aId );
155 #if OSL_DEBUG_LEVEL > 1
156 StatementList::m_pDbgWin->AddText( "Parameter: " );
157 StatementList::m_pDbgWin->AddText( aId );
158 StatementList::m_pDbgWin->AddText( " " );
159 #endif
160 nType = GetNextType();
161 switch (nType)
163 case BinUSHORT:
165 comm_USHORT nNr;
166 Read (nNr );
167 rItem.Value <<= nNr;
168 #if OSL_DEBUG_LEVEL > 1
169 StatementList::m_pDbgWin->AddText( "USHORT:" );
170 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
171 #endif
173 break;
174 case BinULONG:
176 comm_ULONG nNr;
177 Read (nNr );
178 rItem.Value <<= nNr;
179 #if OSL_DEBUG_LEVEL > 1
180 StatementList::m_pDbgWin->AddText( "ULONG:" );
181 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
182 #endif
184 break;
185 case BinString:
187 String aString;
188 Read (aString);
189 rItem.Value <<= ::rtl::OUString( aString );
190 #if OSL_DEBUG_LEVEL > 1
191 StatementList::m_pDbgWin->AddText( "String:" );
192 StatementList::m_pDbgWin->AddText( aString );
193 #endif
195 break;
196 case BinBool:
198 comm_BOOL bBool;
199 Read (bBool);
200 rItem.Value <<= bBool;
201 #if OSL_DEBUG_LEVEL > 1
202 StatementList::m_pDbgWin->AddText( "BOOL:" );
203 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
204 #endif
206 break;
207 default:
208 DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType );
209 #if OSL_DEBUG_LEVEL > 1
210 StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " );
211 #endif
212 break;
214 #if OSL_DEBUG_LEVEL > 1
215 StatementList::m_pDbgWin->AddText( "\n" );
216 #endif