1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_automation.hxx"
26 #include <svl/intitem.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/eitem.hxx>
29 #include "scmdstrm.hxx"
30 #include "svcommstream.hxx"
31 #include "rcontrol.hxx"
32
33 #if OSL_DEBUG_LEVEL > 1
34 #include "editwin.hxx"
35 #include "statemnt.hxx"
36 #endif
37
SCmdStream(SvStream * pIn)38 SCmdStream::SCmdStream(SvStream *pIn)
39 {
40 pSammel = pIn;
41 pCommStream = new SvCommStream( pSammel );
42 // SetCommStream( pCommStream );
43 }
44
~SCmdStream()45 SCmdStream::~SCmdStream()
46 {
47 delete pCommStream;
48 }
49
Read(String * & pString)50 void SCmdStream::Read (String* &pString)
51 {
52 if ( !pString )
53 pString = new String();
54 comm_UniChar* pStr;
55 sal_uInt16 nLenInChars;
56 CmdBaseStream::Read( pStr, nLenInChars );
57
58 *pString = String( pStr, nLenInChars );
59 delete [] pStr;
60 }
61
Read(String & aString)62 void SCmdStream::Read (String &aString)
63 {
64 comm_UniChar* pStr;
65 sal_uInt16 nLenInChars;
66 CmdBaseStream::Read( pStr, nLenInChars );
67
68 aString = String( pStr, nLenInChars );
69 delete [] pStr;
70 }
71
Read(SfxPoolItem * & pItem)72 void SCmdStream::Read ( SfxPoolItem *&pItem )
73 {
74 sal_uInt16 nType;
75 sal_uInt16 nId;
76 Read(nId);
77 #if OSL_DEBUG_LEVEL > 1
78 StatementList::m_pDbgWin->AddText( "Parameter: " );
79 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nId ) );
80 StatementList::m_pDbgWin->AddText( " " );
81 #endif
82 Read( nType );
83 switch (nType)
84 {
85 case BinUSHORT:
86 {
87 comm_USHORT nNr;
88 Read (nNr );
89 pItem = new SfxUInt16Item(nId,nNr);
90 #if OSL_DEBUG_LEVEL > 1
91 StatementList::m_pDbgWin->AddText( "USHORT:" );
92 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
93 #endif
94 }
95 break;
96 case BinULONG:
97 {
98 comm_ULONG nNr;
99 Read (nNr );
100 pItem = new SfxUInt32Item(nId,nNr);
101 #if OSL_DEBUG_LEVEL > 1
102 StatementList::m_pDbgWin->AddText( "ULONG:" );
103 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
104 #endif
105 }
106 break;
107 case BinString:
108 {
109 String aString;
110 Read (aString);
111
112 pItem = new SfxStringItem(nId,aString);
113 #if OSL_DEBUG_LEVEL > 1
114 StatementList::m_pDbgWin->AddText( "String:" );
115 StatementList::m_pDbgWin->AddText( aString );
116 #endif
117 }
118 break;
119 case BinBool:
120 {
121 comm_BOOL bBool;
122 Read (bBool);
123 pItem = new SfxBoolItem(nId,bBool);
124 #if OSL_DEBUG_LEVEL > 1
125 StatementList::m_pDbgWin->AddText( "BOOL:" );
126 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
127 #endif
128 }
129 break;
130 default:
131 DBG_ERROR1( "Ung�ltiger Typ im Stream:%hu", nType );
132 #if OSL_DEBUG_LEVEL > 1
133 StatementList::m_pDbgWin->AddText( "Ung�ltiger Typ !!!! " );
134 #endif
135 break;
136 }
137 #if OSL_DEBUG_LEVEL > 1
138 StatementList::m_pDbgWin->AddText( "\n" );
139 #endif
140 }
141
Read(::com::sun::star::beans::PropertyValue & rItem)142 void SCmdStream::Read ( ::com::sun::star::beans::PropertyValue &rItem )
143 {
144 sal_uInt16 nType;
145 String aId;
146 Read(aId);
147 rItem.Name = rtl::OUString( aId );
148 #if OSL_DEBUG_LEVEL > 1
149 StatementList::m_pDbgWin->AddText( "Parameter: " );
150 StatementList::m_pDbgWin->AddText( aId );
151 StatementList::m_pDbgWin->AddText( " " );
152 #endif
153 nType = GetNextType();
154 switch (nType)
155 {
156 case BinUSHORT:
157 {
158 comm_USHORT nNr;
159 Read (nNr );
160 rItem.Value <<= nNr;
161 #if OSL_DEBUG_LEVEL > 1
162 StatementList::m_pDbgWin->AddText( "USHORT:" );
163 StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) );
164 #endif
165 }
166 break;
167 case BinULONG:
168 {
169 comm_ULONG nNr;
170 Read (nNr );
171 rItem.Value <<= nNr;
172 #if OSL_DEBUG_LEVEL > 1
173 StatementList::m_pDbgWin->AddText( "ULONG:" );
174 StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) );
175 #endif
176 }
177 break;
178 case BinString:
179 {
180 String aString;
181 Read (aString);
182 rItem.Value <<= ::rtl::OUString( aString );
183 #if OSL_DEBUG_LEVEL > 1
184 StatementList::m_pDbgWin->AddText( "String:" );
185 StatementList::m_pDbgWin->AddText( aString );
186 #endif
187 }
188 break;
189 case BinBool:
190 {
191 comm_BOOL bBool;
192 Read (bBool);
193 rItem.Value <<= bBool;
194 #if OSL_DEBUG_LEVEL > 1
195 StatementList::m_pDbgWin->AddText( "BOOL:" );
196 StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" );
197 #endif
198 }
199 break;
200 default:
201 DBG_ERROR1( "Ung�ltiger Typ im Stream:%hu", nType );
202 #if OSL_DEBUG_LEVEL > 1
203 StatementList::m_pDbgWin->AddText( "Ung�ltiger Typ !!!! " );
204 #endif
205 break;
206 }
207 #if OSL_DEBUG_LEVEL > 1
208 StatementList::m_pDbgWin->AddText( "\n" );
209 #endif
210 }
211
212