Lines 141-147
Link Here
|
141 |
#include <iostream> |
141 |
#include <iostream> |
142 |
#include <dbgoutsw.hxx> |
142 |
#include <dbgoutsw.hxx> |
143 |
#endif |
143 |
#endif |
144 |
|
144 |
#include <svx/hlnkitem.hxx> |
145 |
#include "WW8Sttbf.hxx" |
145 |
#include "WW8Sttbf.hxx" |
146 |
#include "WW8FibData.hxx" |
146 |
#include "WW8FibData.hxx" |
147 |
#define MM_250 1417 // WW-Default fuer Hor. Seitenraender: 2.5 cm |
147 |
#define MM_250 1417 // WW-Default fuer Hor. Seitenraender: 2.5 cm |
Lines 152-158
Link Here
|
152 |
using namespace sw::types; |
152 |
using namespace sw::types; |
153 |
using namespace nsHdFtFlags; |
153 |
using namespace nsHdFtFlags; |
154 |
|
154 |
|
|
|
155 |
#define VT_EMPTY 0 |
156 |
#define VT_I4 3 |
157 |
#define VT_LPSTR 30 |
158 |
#define VT_LPWSTR 31 |
159 |
#define VT_BLOB 65 |
160 |
#define VT_TYPEMASK 0xFFF |
161 |
/** Expands to a pointer behind the last element of a STATIC data array (like STL end()). */ |
162 |
#define STATIC_TABLE_END( array ) ((array)+STATIC_TABLE_SIZE(array)) |
163 |
/** Expands to the size of a STATIC data array. */ |
164 |
#define STATIC_TABLE_SIZE( array ) (sizeof(array)/sizeof(*(array))) |
155 |
|
165 |
|
|
|
166 |
SwMacroInfo* GetMacroInfo( SdrObject* pObj, sal_Bool bCreate ) // static |
167 |
{ |
168 |
if ( pObj ) |
169 |
{ |
170 |
sal_uInt16 nCount = pObj->GetUserDataCount(); |
171 |
for( sal_uInt16 i = 0; i < nCount; i++ ) |
172 |
{ |
173 |
SdrObjUserData* pData = pObj->GetUserData( i ); |
174 |
if( pData && pData->GetInventor() == SW_DRAWLAYER |
175 |
&& pData->GetId() == SW_UD_IMAPDATA) |
176 |
return dynamic_cast<SwMacroInfo*>(pData); |
177 |
} |
178 |
if ( bCreate ) |
179 |
{ |
180 |
SwMacroInfo* pData = new SwMacroInfo; |
181 |
pObj->InsertUserData( pData, 0 ); |
182 |
return pData; |
183 |
} |
184 |
} |
185 |
|
186 |
return 0; |
187 |
}; |
188 |
|
189 |
void lclGetAbsPath( String& rPath, sal_uInt16 nLevel, SwDocShell* pDocShell) |
190 |
{ |
191 |
String aTmpStr; |
192 |
while( nLevel ) |
193 |
{ |
194 |
aTmpStr.AppendAscii( "../" ); |
195 |
--nLevel; |
196 |
} |
197 |
if(aTmpStr.Len()) |
198 |
aTmpStr += rPath; |
199 |
else |
200 |
aTmpStr = rPath; |
201 |
|
202 |
if(aTmpStr.Len()) |
203 |
{ |
204 |
bool bWasAbs = false; |
205 |
rPath = pDocShell->GetMedium()->GetURLObject().smartRel2Abs( aTmpStr, bWasAbs ).GetMainURL( INetURLObject::NO_DECODE ); |
206 |
// full path as stored in SvxURLField must be encoded |
207 |
} |
208 |
} |
209 |
|
210 |
void lclIgnoreString32( SvMemoryStream& rStrm, bool b16Bit ) |
211 |
{ |
212 |
sal_uInt32 nChars; |
213 |
rStrm >> nChars; |
214 |
if( b16Bit ) |
215 |
nChars *= 2; |
216 |
rStrm.SeekRel( nChars ); |
217 |
} |
218 |
|
219 |
String SwWW8ImplReader::ReadRawUniString( SvMemoryStream& rStrm,sal_uInt16 nChars, bool b16Bit ) |
220 |
{ |
221 |
// Fixed-size characters |
222 |
const sal_uInt8 WW8_NUL_C = '\x00'; /// NUL chararcter. |
223 |
const sal_uInt16 WW8_NUL = WW8_NUL_C; /// NUL chararcter (unicode). |
224 |
String aRet; |
225 |
sal_Unicode mcNulSubst = '\0'; |
226 |
|
227 |
sal_uInt16 nCharsLeft = nChars; |
228 |
sal_Unicode* pcBuffer = new sal_Unicode[ nCharsLeft + 1 ]; |
229 |
|
230 |
sal_Unicode* pcUniChar = pcBuffer; |
231 |
sal_Unicode* pcEndChar = pcBuffer + nCharsLeft; |
232 |
|
233 |
if( b16Bit ) |
234 |
{ |
235 |
sal_uInt16 nReadChar; |
236 |
for( ; (pcUniChar < pcEndChar); ++pcUniChar ) |
237 |
{ |
238 |
rStrm >> (nReadChar); |
239 |
(*pcUniChar) = (nReadChar == WW8_NUL) ? mcNulSubst : static_cast< sal_Unicode >( nReadChar ); |
240 |
} |
241 |
} |
242 |
else |
243 |
{ |
244 |
sal_uInt8 nReadChar; |
245 |
for( ; (pcUniChar < pcEndChar); ++pcUniChar ) |
246 |
{ |
247 |
rStrm >> nReadChar ; |
248 |
(*pcUniChar) = (nReadChar == WW8_NUL_C) ? mcNulSubst : static_cast< sal_Unicode >( nReadChar ); |
249 |
} |
250 |
} |
251 |
|
252 |
*pcEndChar = '\0'; |
253 |
aRet.Append( pcBuffer ); |
254 |
delete[] pcBuffer; |
255 |
return aRet; |
256 |
} |
257 |
|
258 |
void lclAppendString32( String& rString, SvMemoryStream& rStrm, sal_uInt32 nChars, bool b16Bit ) |
259 |
{ |
260 |
sal_uInt16 nReadChars = ulimit_cast< sal_uInt16 >( nChars ); |
261 |
String urlStr = SwWW8ImplReader::ReadRawUniString( rStrm, nReadChars, b16Bit ); |
262 |
rString.Append( urlStr ); |
263 |
} |
264 |
|
265 |
void lclAppendString32( String& rString, SvMemoryStream& rStrm, bool b16Bit ) |
266 |
{ |
267 |
sal_uInt32 nValue; |
268 |
rStrm >>( nValue ); |
269 |
lclAppendString32( rString, rStrm, nValue, b16Bit ); |
270 |
} |
271 |
|
272 |
void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocShell, struct HyperLinksTable& hlStr) |
273 |
{ |
274 |
// (0x01B8) HLINK ------------------------------------------------------------- |
275 |
const sal_uInt16 WW8_ID_HLINK = 0x01B8; |
276 |
const sal_uInt32 WW8_HLINK_BODY = 0x00000001; /// Contains file link or URL. |
277 |
const sal_uInt32 WW8_HLINK_ABS = 0x00000002; /// Absolute path. |
278 |
const sal_uInt32 WW8_HLINK_DESCR = 0x00000014; /// Description. |
279 |
const sal_uInt32 WW8_HLINK_MARK = 0x00000008; /// Text mark. |
280 |
const sal_uInt32 WW8_HLINK_FRAME = 0x00000080; /// Target frame. |
281 |
const sal_uInt32 WW8_HLINK_UNC = 0x00000100; /// UNC path. |
282 |
|
283 |
sal_uInt8 maGuidStdLink[ 16 ] ={ |
284 |
0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B }; |
285 |
|
286 |
sal_uInt8 maGuidUrlMoniker[ 16 ] = { |
287 |
0xE0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B }; |
288 |
|
289 |
sal_uInt8 maGuidFileMoniker[ 16 ] = { |
290 |
0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }; |
291 |
|
292 |
sal_uInt8* aGuid = new sal_uInt8[ 16 ]; |
293 |
sal_uInt32 nFlags; |
294 |
|
295 |
|
296 |
rStrm.Read( aGuid, 16); |
297 |
rStrm.SeekRel( 4 ); |
298 |
rStrm >> nFlags; |
299 |
|
300 |
sal_uInt16 nLevel = 0; // counter for level to climb down in path |
301 |
::std::auto_ptr< String > xLongName; // link / file name |
302 |
::std::auto_ptr< String > xShortName; // 8.3-representation of file name |
303 |
::std::auto_ptr< String > xTextMark; // text mark |
304 |
|
305 |
// description (ignore) |
306 |
if( ::get_flag( nFlags, WW8_HLINK_DESCR ) ) |
307 |
lclIgnoreString32( rStrm, true ); |
308 |
|
309 |
// target frame |
310 |
if( ::get_flag( nFlags, WW8_HLINK_FRAME ) ) |
311 |
{ |
312 |
::std::auto_ptr< String > FrmName; |
313 |
FrmName.reset( new String ); |
314 |
lclAppendString32(*FrmName , rStrm , true); |
315 |
hlStr.tarFrm = *FrmName; |
316 |
} |
317 |
|
318 |
// UNC path |
319 |
if( ::get_flag( nFlags, WW8_HLINK_UNC ) ) |
320 |
{ |
321 |
xLongName.reset( new String ); |
322 |
lclAppendString32( *xLongName, rStrm, true ); |
323 |
lclGetAbsPath( *xLongName, 0 , pDocShell); |
324 |
} |
325 |
// file link or URL |
326 |
else if( ::get_flag( nFlags, WW8_HLINK_BODY ) ) |
327 |
{ |
328 |
rStrm.Read( aGuid, 16); |
329 |
|
330 |
if( (memcmp(aGuid, maGuidFileMoniker, 16) == 0) ) |
331 |
{ |
332 |
rStrm >> nLevel; |
333 |
xShortName.reset( new String ); |
334 |
lclAppendString32( *xShortName,rStrm, false ); |
335 |
rStrm.SeekRel( 24 ); |
336 |
|
337 |
sal_uInt32 nStrLen; |
338 |
rStrm >> nStrLen; |
339 |
if( nStrLen ) |
340 |
{ |
341 |
rStrm >> nStrLen; |
342 |
nStrLen /= 2; |
343 |
rStrm.SeekRel( 2 ); |
344 |
xLongName.reset( new String ); |
345 |
lclAppendString32( *xLongName, rStrm,nStrLen, true ); |
346 |
lclGetAbsPath( *xLongName, nLevel, pDocShell); |
347 |
} |
348 |
else |
349 |
lclGetAbsPath( *xShortName, nLevel, pDocShell); |
350 |
} |
351 |
else if( (memcmp(aGuid, maGuidUrlMoniker, 16) == 0) ) |
352 |
{ |
353 |
sal_uInt32 nStrLen; |
354 |
rStrm >> nStrLen; |
355 |
nStrLen /= 2; |
356 |
xLongName.reset( new String ); |
357 |
lclAppendString32( *xLongName,rStrm, nStrLen, true ); |
358 |
if( !::get_flag( nFlags, WW8_HLINK_ABS ) ) |
359 |
lclGetAbsPath( *xLongName, 0 ,pDocShell); |
360 |
} |
361 |
else |
362 |
{ |
363 |
DBG_ERRORFILE( "WW8Hyperlink::ReadEmbeddedData - unknown content GUID" ); |
364 |
} |
365 |
} |
366 |
|
367 |
// text mark |
368 |
if( ::get_flag( nFlags, WW8_HLINK_MARK ) ) |
369 |
{ |
370 |
xTextMark.reset( new String ); |
371 |
lclAppendString32( *xTextMark, rStrm, true ); |
372 |
} |
373 |
|
374 |
DBG_ASSERT( rStrm.GetRecLeft() == 0, "WW8Hyperlink::ReadEmbeddedData - record size mismatch" ); |
375 |
|
376 |
if( !xLongName.get() && xShortName.get() ) |
377 |
{ |
378 |
xLongName.reset( new String ); |
379 |
xLongName->Append(*xShortName); |
380 |
} |
381 |
else if( !xLongName.get() && xTextMark.get() ) |
382 |
xLongName.reset( new String ); |
383 |
|
384 |
if( xLongName.get() ) |
385 |
{ |
386 |
if( xTextMark.get() ) |
387 |
{ |
388 |
if( xLongName->Len() == 0 ) |
389 |
xTextMark->SearchAndReplaceAll( '!', '.' ); |
390 |
xLongName->Append( '#' ); |
391 |
xLongName->Append( *xTextMark ); |
392 |
} |
393 |
hlStr.hLinkAddr = *xLongName; |
394 |
} |
395 |
} |
396 |
|
156 |
SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr ) |
397 |
SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr ) |
157 |
: SvxMSDffManager(*rRdr.pTableStream, rRdr.GetBaseURL(), rRdr.pWwFib->fcDggInfo, |
398 |
: SvxMSDffManager(*rRdr.pTableStream, rRdr.GetBaseURL(), rRdr.pWwFib->fcDggInfo, |
158 |
rRdr.pDataStream, 0, 0, COL_WHITE, 12, rRdr.pStrm, |
399 |
rRdr.pDataStream, 0, 0, COL_WHITE, 12, rRdr.pStrm, |
Lines 752-757
Link Here
|
752 |
delete pImpRec; |
993 |
delete pImpRec; |
753 |
} |
994 |
} |
754 |
|
995 |
|
|
|
996 |
sal_uInt32 nBufferSize = GetPropertyValue( DFF_Prop_pihlShape ); |
997 |
if( (0 < nBufferSize) && (nBufferSize <= 0xFFFF) && SeekToContent( DFF_Prop_pihlShape, rSt ) ) |
998 |
{ |
999 |
SvMemoryStream aMemStream; |
1000 |
String aStrURL; |
1001 |
struct HyperLinksTable hlStr; |
1002 |
sal_uInt16 mnRawRecId,mnRawRecSize; |
1003 |
aMemStream << sal_uInt16( 0 ) << static_cast< sal_uInt16 >( nBufferSize ); |
1004 |
|
1005 |
// copy from DFF stream to memory stream |
1006 |
::std::vector< sal_uInt8 > aBuffer( nBufferSize ); |
1007 |
sal_uInt8* pnData = &aBuffer.front(); |
1008 |
sal_uInt8 mnStreamSize; |
1009 |
if( pnData && rSt.Read( pnData, nBufferSize ) == nBufferSize ) |
1010 |
{ |
1011 |
aMemStream.Write( pnData, nBufferSize ); |
1012 |
aMemStream.Seek( STREAM_SEEK_TO_END ); |
1013 |
mnStreamSize = aMemStream.Tell(); |
1014 |
aMemStream.Seek( STREAM_SEEK_TO_BEGIN ); |
1015 |
bool bRet = 4 <= mnStreamSize; |
1016 |
if( bRet ) |
1017 |
aMemStream >> mnRawRecId >> mnRawRecSize; |
1018 |
SwDocShell* pDocShell = rReader.mpDocShell; |
1019 |
if(pDocShell) |
1020 |
{ |
1021 |
rReader.ReadEmbeddedData( aMemStream, pDocShell, hlStr); |
1022 |
} |
1023 |
} |
1024 |
|
1025 |
if(pObj && hlStr.hLinkAddr.Len() > 0) |
1026 |
{ |
1027 |
SwMacroInfo* pInfo = GetMacroInfo( pObj, true ); |
1028 |
if( pInfo ) |
1029 |
{ |
1030 |
pInfo->SetShapeId( rObjData.nShapeId ); |
1031 |
pInfo->SetHlink( hlStr.hLinkAddr ); |
1032 |
if(hlStr.tarFrm.Len() > 0) |
1033 |
pInfo->SetTarFrm( hlStr.tarFrm ); |
1034 |
String aNameStr = GetPropertyString( DFF_Prop_wzName, rSt ); |
1035 |
if(aNameStr.Len() > 0) |
1036 |
pInfo->SetName( aNameStr ); |
1037 |
} |
1038 |
} |
1039 |
} |
1040 |
|
755 |
return pObj; |
1041 |
return pObj; |
756 |
} |
1042 |
} |
757 |
|
1043 |
|
Lines 5424-5426
Link Here
|
5424 |
} |
5710 |
} |
5425 |
|
5711 |
|
5426 |
/* vi:set tabstop=4 shiftwidth=4 expandtab: */ |
5712 |
/* vi:set tabstop=4 shiftwidth=4 expandtab: */ |
|
|
5713 |
|
5714 |
SwMacroInfo::SwMacroInfo() : |
5715 |
SdrObjUserData( SW_DRAWLAYER, SW_UD_IMAPDATA, 0 ) |
5716 |
{ |
5717 |
} |
5718 |
|
5719 |
SwMacroInfo::~SwMacroInfo() |
5720 |
{ |
5721 |
} |
5722 |
|
5723 |
SdrObjUserData* SwMacroInfo::Clone( SdrObject* /*pObj*/ ) const |
5724 |
{ |
5725 |
return new SwMacroInfo( *this ); |
5726 |
} |
5727 |
|
5728 |
|
5729 |
|