xref: /trunk/main/automation/source/server/scmdstrm.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_automation.hxx"
30 #include <svl/intitem.hxx>
31 #include <svl/stritem.hxx>
32 #include <svl/eitem.hxx>
33 #include "scmdstrm.hxx"
34 #include "svcommstream.hxx"
35 #include "rcontrol.hxx"
36 
37 #if OSL_DEBUG_LEVEL > 1
38 #include "editwin.hxx"
39 #include "statemnt.hxx"
40 #endif
41 
42 SCmdStream::SCmdStream(SvStream *pIn)
43 {
44     pSammel = pIn;
45     pCommStream = new SvCommStream( pSammel );
46 //  SetCommStream( pCommStream );
47 }
48 
49 SCmdStream::~SCmdStream()
50 {
51     delete pCommStream;
52 }
53 
54 void SCmdStream::Read (String* &pString)
55 {
56     if ( !pString )
57         pString = new String();
58     comm_UniChar* pStr;
59     sal_uInt16 nLenInChars;
60     CmdBaseStream::Read( pStr, nLenInChars );
61 
62     *pString = String( pStr, nLenInChars );
63     delete [] pStr;
64 }
65 
66 void SCmdStream::Read (String &aString)
67 {
68     comm_UniChar* pStr;
69     sal_uInt16 nLenInChars;
70     CmdBaseStream::Read( pStr, nLenInChars );
71 
72     aString = String( pStr, nLenInChars );
73     delete [] pStr;
74 }
75 
76 void SCmdStream::Read ( SfxPoolItem *&pItem )
77 {
78     sal_uInt16 nType;
79     sal_uInt16 nId;
80     Read(nId);
81 #if OSL_DEBUG_LEVEL > 1
82         StatementList::m_pDbgWin->AddText( "Parameter: " );
83         StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nId ) );
84         StatementList::m_pDbgWin->AddText( " " );
85 #endif
86     Read( nType );
87     switch (nType)
88     {
89         case BinUSHORT:
90             {
91                 comm_USHORT nNr;
92                 Read (nNr );
93                 pItem = new SfxUInt16Item(nId,nNr);
94 #if OSL_DEBUG_LEVEL > 1
95                 StatementList::m_pDbgWin->AddText( "USHORT:" );
96                 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
97 #endif
98             }
99             break;
100         case BinULONG:
101             {
102                 comm_ULONG nNr;
103                 Read (nNr );
104                 pItem = new SfxUInt32Item(nId,nNr);
105 #if OSL_DEBUG_LEVEL > 1
106                 StatementList::m_pDbgWin->AddText( "ULONG:" );
107                 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
108 #endif
109             }
110             break;
111         case BinString:
112             {
113                 String aString;
114                 Read (aString);
115 
116                 pItem = new SfxStringItem(nId,aString);
117 #if OSL_DEBUG_LEVEL > 1
118                 StatementList::m_pDbgWin->AddText( "String:" );
119                 StatementList::m_pDbgWin->AddText( aString );
120 #endif
121             }
122             break;
123         case BinBool:
124             {
125                 comm_BOOL bBool;
126                 Read (bBool);
127                 pItem = new SfxBoolItem(nId,bBool);
128 #if OSL_DEBUG_LEVEL > 1
129                 StatementList::m_pDbgWin->AddText( "BOOL:" );
130                 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
131 #endif
132             }
133             break;
134         default:
135             DBG_ERROR1( "Ung�ltiger Typ im Stream:%hu", nType );
136 #if OSL_DEBUG_LEVEL > 1
137             StatementList::m_pDbgWin->AddText( "Ung�ltiger Typ !!!! " );
138 #endif
139             break;
140     }
141 #if OSL_DEBUG_LEVEL > 1
142         StatementList::m_pDbgWin->AddText( "\n" );
143 #endif
144 }
145 
146 void SCmdStream::Read ( ::com::sun::star::beans::PropertyValue &rItem )
147 {
148     sal_uInt16 nType;
149     String aId;
150     Read(aId);
151     rItem.Name = rtl::OUString( aId );
152 #if OSL_DEBUG_LEVEL > 1
153         StatementList::m_pDbgWin->AddText( "Parameter: " );
154         StatementList::m_pDbgWin->AddText( aId );
155         StatementList::m_pDbgWin->AddText( " " );
156 #endif
157     nType = GetNextType();
158     switch (nType)
159     {
160         case BinUSHORT:
161             {
162                 comm_USHORT nNr;
163                 Read (nNr );
164                 rItem.Value <<= nNr;
165 #if OSL_DEBUG_LEVEL > 1
166                 StatementList::m_pDbgWin->AddText( "USHORT:" );
167                 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
168 #endif
169             }
170             break;
171         case BinULONG:
172             {
173                 comm_ULONG nNr;
174                 Read (nNr );
175                 rItem.Value <<= nNr;
176 #if OSL_DEBUG_LEVEL > 1
177                 StatementList::m_pDbgWin->AddText( "ULONG:" );
178                 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
179 #endif
180             }
181             break;
182         case BinString:
183             {
184                 String aString;
185                 Read (aString);
186                 rItem.Value <<= ::rtl::OUString( aString );
187 #if OSL_DEBUG_LEVEL > 1
188                 StatementList::m_pDbgWin->AddText( "String:" );
189                 StatementList::m_pDbgWin->AddText( aString );
190 #endif
191             }
192             break;
193         case BinBool:
194             {
195                 comm_BOOL bBool;
196                 Read (bBool);
197                 rItem.Value <<= bBool;
198 #if OSL_DEBUG_LEVEL > 1
199                 StatementList::m_pDbgWin->AddText( "BOOL:" );
200                 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
201 #endif
202             }
203             break;
204         default:
205             DBG_ERROR1( "Ung�ltiger Typ im Stream:%hu", nType );
206 #if OSL_DEBUG_LEVEL > 1
207             StatementList::m_pDbgWin->AddText( "Ung�ltiger Typ !!!! " );
208 #endif
209             break;
210     }
211 #if OSL_DEBUG_LEVEL > 1
212         StatementList::m_pDbgWin->AddText( "\n" );
213 #endif
214 }
215 
216