View | Details | Raw Unified | Return to issue 120927
Collapse All | Expand All

(-)sw/source/filter/ww8/escher.hxx (+7 lines)
Lines 134-139 Link Here
134
    virtual void WriteFrmExtraData(const SwFrmFmt&);
134
    virtual void WriteFrmExtraData(const SwFrmFmt&);
135
    virtual void WritePictures();
135
    virtual void WritePictures();
136
    virtual ~SwBasicEscherEx();
136
    virtual ~SwBasicEscherEx();
137
    //i120927,this function is added to export hyperlink info,such as graphic/frame/OLE
138
    bool IsRelUrl();
139
    String GetBasePath();
140
    String BuildFileName(sal_uInt16& rnLevel, bool& rbRel, const String& rUrl );
141
    void WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFmtURL* pINetFmtArg);
142
    void PreWriteHyperlinkWithinFly(const SwFrmFmt& rFmt,EscherPropertyContainer& rPropOpt);
143
137
private:
144
private:
138
    //No copying
145
    //No copying
139
    SwBasicEscherEx(const SwBasicEscherEx&);
146
    SwBasicEscherEx(const SwBasicEscherEx&);
(-)sw/source/filter/ww8/wrtw8esh.cxx (+225 lines)
Lines 103-114 Link Here
103
// <--
103
// <--
104
#include "WW8FFData.hxx"
104
#include "WW8FFData.hxx"
105
#include <editeng/shaditem.hxx>
105
#include <editeng/shaditem.hxx>
106
#include <svx/unoapi.hxx>
107
#include <escher.hxx>
108
#include <fmtinfmt.hxx>
109
#include <fmturl.hxx>
110
#include "sfx2/sfxsids.hrc"
111
#include <svl/urihelper.hxx>
112
#include <unotools/saveopt.hxx>
106
113
107
using namespace com::sun::star;
114
using namespace com::sun::star;
108
using namespace sw::util;
115
using namespace sw::util;
109
using namespace sw::types;
116
using namespace sw::types;
110
using namespace nsFieldFlags;
117
using namespace nsFieldFlags;
118
using ::com::sun::star::uno::Reference;
119
using ::com::sun::star::uno::UNO_QUERY;
120
using ::com::sun::star::beans::XPropertySet;
121
using ::com::sun::star::drawing::XShape;
111
122
123
bool SwBasicEscherEx::IsRelUrl()
124
{
125
	SvtSaveOptions aSaveOpt;
126
	bool bRelUrl = false;
127
	SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
128
	if ( pMedium )
129
		bRelUrl = pMedium->IsRemote() ? aSaveOpt.IsSaveRelINet() : aSaveOpt.IsSaveRelFSys();
130
	return bRelUrl;
131
}
132
133
String SwBasicEscherEx::GetBasePath()
134
{
135
	String sDocUrl;
136
	String sBasePath;
137
	SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
138
	if ( pMedium )
139
	{
140
		const SfxItemSet* pPItemSet = pMedium->GetItemSet();
141
		if( pPItemSet )
142
		{
143
			const SfxStringItem* pPItem = dynamic_cast< const SfxStringItem* >( pPItemSet->GetItem( SID_FILE_NAME ) );	
144
			if ( pPItem )
145
			      	sDocUrl = pPItem->GetValue();
146
		}
147
	}
148
	
149
    	sBasePath = sDocUrl.Copy( 0, sDocUrl.SearchBackward( '/' ) + 1 );
150
	return sBasePath;
151
152
}
153
154
String SwBasicEscherEx::BuildFileName(sal_uInt16& rnLevel, bool& rbRel, const String& rUrl )
155
{
156
    	String aDosName( INetURLObject( rUrl ).getFSysPath( INetURLObject::FSYS_DOS ) );
157
    	rnLevel = 0;
158
	rbRel = IsRelUrl();
159
160
    	if( rbRel )
161
    	{
162
       	 // try to convert to relative file name
163
        	String aTmpName( aDosName );
164
        	aDosName = INetURLObject::GetRelURL( GetBasePath(), rUrl,
165
            	INetURLObject::WAS_ENCODED, INetURLObject::DECODE_WITH_CHARSET );
166
167
        	if( aDosName.SearchAscii( INET_FILE_SCHEME ) == 0 )
168
        	{
169
            		// not converted to rel -> back to old, return absolute flag
170
            		aDosName = aTmpName;
171
            		rbRel = false;
172
        	}
173
	       else if( aDosName.SearchAscii( "./" ) == 0 )
174
	       {
175
	            aDosName.Erase( 0, 2 );
176
	       }
177
	       else
178
	       {
179
	            while( aDosName.SearchAndReplaceAscii( "../", String::EmptyString() ) == 0 )
180
	                ++rnLevel;
181
	       }
182
	}
183
	return aDosName;
184
}
185
186
void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFmtURL* pINetFmtArg) 
187
{
188
	if ( !pINetFmtArg ) return;
189
	
190
	sal_uInt8 maGuidStdLink[ 16 ] ={
191
		0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
192
	sal_uInt8 maGuidUrlMoniker[ 16 ] = {
193
	    0xE0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
194
195
	sal_uInt8 maGuidFileMoniker[ 16 ] = {
196
		0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 };
197
	sal_uInt8 maGuidFileTail[] = {
198
            0xFF, 0xFF, 0xAD, 0xDE, 0x00, 0x00, 0x00, 0x00,
199
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
201
        };
202
	const sal_uInt16 WW8_ID_HLINK               = 0x01B8;
203
	const sal_uInt32 WW8_HLINK_BODY             = 0x00000001;   /// Contains file link or URL.
204
	const sal_uInt32 WW8_HLINK_ABS              = 0x00000002;   /// Absolute path.
205
	const sal_uInt32 WW8_HLINK_DESCR            = 0x00000014;   /// Description.
206
	const sal_uInt32 WW8_HLINK_MARK             = 0x00000008;   /// Text mark.
207
	const sal_uInt32 WW8_HLINK_FRAME            = 0x00000080;   /// Target frame.
208
	const sal_uInt32 WW8_HLINK_UNC              = 0x00000100;   /// UNC path.
209
	SvMemoryStream tmpStrm;
210
	String tmpTextMark;
211
	
212
	String rUrl = pINetFmtArg->GetURL();
213
	String rTarFrm = pINetFmtArg->GetTargetFrameName();
214
	sal_uInt32          mnFlags = 0;
215
216
    	INetURLObject aUrlObj( rUrl );
217
    	const INetProtocol eProtocol = aUrlObj.GetProtocol();
218
219
	//Target Frame
220
	if( rTarFrm.Len() > 0 )
221
    	{    		
222
		SwWW8Writer::WriteLong( tmpStrm, rTarFrm.Len()+1 );
223
        	SwWW8Writer::WriteString16( tmpStrm, rTarFrm, false);
224
225
        	tmpStrm << sal_uInt16( 0 );
226
227
        	mnFlags |= WW8_HLINK_FRAME;
228
    	}
229
230
    	// file link or URL
231
    	if( eProtocol == INET_PROT_FILE || (eProtocol == INET_PROT_NOT_VALID && rUrl.GetChar( 0 ) != '#') )
232
    	{
233
    		sal_uInt16 nLevel;
234
        	bool bRel;
235
        	String aFileName( BuildFileName( nLevel, bRel, rUrl ));
236
237
        	if( !bRel )
238
            		mnFlags |= WW8_HLINK_ABS;
239
240
		mnFlags |= WW8_HLINK_BODY;
241
		
242
		tmpStrm.Write( maGuidFileMoniker,sizeof(maGuidFileMoniker) );
243
		tmpStrm << nLevel;
244
		SwWW8Writer::WriteLong( tmpStrm, aFileName.Len()+1);
245
		SwWW8Writer::WriteString8( tmpStrm, aFileName, true, RTL_TEXTENCODING_MS_1252 );
246
		tmpStrm.Write( maGuidFileTail,sizeof(maGuidFileTail) );
247
248
		//For UNICODE
249
		SwWW8Writer::WriteLong( tmpStrm, 2*aFileName.Len()+6);
250
		SwWW8Writer::WriteLong( tmpStrm, 2*aFileName.Len());
251
		tmpStrm << sal_uInt16(0x0003);
252
		SwWW8Writer::WriteString16(tmpStrm, aFileName, false);
253
    	}
254
   	else if( eProtocol != INET_PROT_NOT_VALID )
255
    	{
256
       	tmpStrm.Write( maGuidUrlMoniker,sizeof(maGuidUrlMoniker) );
257
        	SwWW8Writer::WriteLong( tmpStrm, 2*(rUrl.Len()+1));
258
259
        	SwWW8Writer::WriteString16(tmpStrm, rUrl, true);
260
        	mnFlags |= WW8_HLINK_BODY | WW8_HLINK_ABS;
261
    	}
262
    	else if( rUrl.GetChar( 0 ) == '#' )
263
    	{
264
       	String aTextMark( rUrl.Copy( 1 ) );
265
        	aTextMark.SearchAndReplace( '.', '!' );
266
		sal_uInt8 tmpLen = aTextMark.Len();
267
		tmpTextMark = aTextMark;
268
    	}
269
	
270
	if( tmpTextMark.Len() == 0 && aUrlObj.HasMark() )
271
	{
272
       	tmpTextMark = aUrlObj.GetMark();
273
	}
274
275
   	if( tmpTextMark.Len()>0 )
276
    	{
277
		SwWW8Writer::WriteLong( tmpStrm, tmpTextMark.Len()+1);
278
        	SwWW8Writer::WriteString16(tmpStrm, tmpTextMark, true);
279
280
       	mnFlags |= WW8_HLINK_MARK;
281
    	}
282
		
283
	rStrm.Write( maGuidStdLink,16 );
284
       rStrm  << sal_uInt32( 2 )
285
            << mnFlags;
286
	tmpStrm.Seek( STREAM_SEEK_TO_BEGIN );
287
	sal_uInt32 nStrmPos = tmpStrm.Tell();
288
    	tmpStrm.Seek( STREAM_SEEK_TO_END );
289
    	sal_uInt32 nStrmSize = tmpStrm.Tell();
290
    	tmpStrm.Seek( nStrmPos );
291
	sal_uInt32 nLen;
292
	nLen = nStrmSize - nStrmPos;
293
	if(nLen >0)
294
	{
295
		sal_uInt8* pBuffer = new sal_uInt8[ nLen ];
296
		tmpStrm.Read(pBuffer, nLen);
297
		rStrm.Write( pBuffer, nLen );
298
		delete[] pBuffer;
299
	}
300
}
301
void SwBasicEscherEx::PreWriteHyperlinkWithinFly(const SwFrmFmt& rFmt,EscherPropertyContainer& rPropOpt)
302
{
303
	const SfxPoolItem* pItem;
304
	const SwAttrSet& rAttrSet = rFmt.GetAttrSet();
305
	if (SFX_ITEM_SET == rAttrSet.GetItemState(RES_URL, true, &pItem))
306
	{
307
		const SwFmtURL *pINetFmt = dynamic_cast<const SwFmtURL*>(pItem);
308
		if(pINetFmt && pINetFmt->GetURL().Len()>0)
309
		{
310
			SvMemoryStream *rStrm = new SvMemoryStream ; 
311
			String tmpstr=pINetFmt->GetURL();
312
			WriteHyperlinkWithinFly( *rStrm, pINetFmt );
313
			sal_uInt8* pBuf = (sal_uInt8*) rStrm->GetData();
314
			sal_uInt32 nSize = rStrm->Seek( STREAM_SEEK_TO_END );
315
			rPropOpt.AddOpt( ESCHER_Prop_pihlShape, sal_True, nSize, pBuf, nSize );
316
			sal_uInt32 nValue;
317
			String aNamestr = pINetFmt->GetName();
318
			if(aNamestr.Len()>0)
319
			{
320
				rPropOpt.AddOpt(ESCHER_Prop_wzName, aNamestr );
321
			}
322
			if(rPropOpt.GetOpt( ESCHER_Prop_fPrint, nValue))
323
			{
324
				nValue|=0x03080008;
325
				rPropOpt.AddOpt(ESCHER_Prop_fPrint, nValue );
326
			}
327
			else 
328
				rPropOpt.AddOpt(ESCHER_Prop_fPrint, 0x03080008 );
329
		}				
330
	}
331
}
332
112
//#110185# get a part fix for this type of element
333
//#110185# get a part fix for this type of element
113
bool WW8Export::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt)
334
bool WW8Export::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt)
114
{
335
{
Lines 1842-1847 Link Here
1842
    {
2063
    {
1843
        rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
2064
        rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
1844
    }
2065
    }
2066
	
2067
	PreWriteHyperlinkWithinFly(rFmt,rPropOpt);	
1845
2068
1846
    return nLineWidth;
2069
    return nLineWidth;
1847
}
2070
}
Lines 1936-1941 Link Here
1936
        }
2159
        }
1937
    }
2160
    }
1938
2161
2162
	PreWriteHyperlinkWithinFly(rFmt,rPropOpt);	
2163
1939
    return nLineWidth;
2164
    return nLineWidth;
1940
}
2165
}
1941
2166
(-)sw/source/filter/ww8/wrtww8.hxx (+2 lines)
Lines 901-906 Link Here
901
901
902
    using StgWriter::Write;
902
    using StgWriter::Write;
903
    virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 );
903
    virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 );
904
	//Seems not an expected to provide method to access the private member
905
	SfxMedium* GetMedia(){ return mpMedium;};
904
906
905
private:
907
private:
906
    /// No copying.
908
    /// No copying.
(-)sw/source/filter/ww8/ww8graf.cxx (+38 lines)
Lines 99-104 Link Here
99
99
100
#include <math.h>
100
#include <math.h>
101
101
102
#include <fmturl.hxx>
103
#include <svx/hlnkitem.hxx>
104
#include <svl/whiter.hxx>
105
#include "ww8par2.hxx"
106
102
using namespace ::com::sun::star;
107
using namespace ::com::sun::star;
103
using namespace sw::types;
108
using namespace sw::types;
104
using namespace sw::util;
109
using namespace sw::util;
Lines 2728-2733 Link Here
2728
    if (pRecord->bHidden)
2733
    if (pRecord->bHidden)
2729
        return 0;
2734
        return 0;
2730
2735
2736
	if(pObject)
2737
	{
2738
		sal_uInt16 nCount = pObject ? pObject->GetUserDataCount() : 0;
2739
		if(nCount)
2740
		{
2741
			String lnName, aObjName, aTarFrm;
2742
			for (sal_uInt16 i = 0; i < nCount; i++ )
2743
			{
2744
				SdrObjUserData* pData = pObject->GetUserData( i ); 
2745
				if( pData && pData->GetInventor() == SW_DRAWLAYER
2746
						&& pData->GetId() == SW_UD_IMAPDATA)
2747
				{
2748
					SwMacroInfo* macInf = dynamic_cast<SwMacroInfo*>(pData);
2749
					if( macInf->GetShapeId() == pF->nSpId)
2750
					{
2751
						lnName = macInf->GetHlink();
2752
						aObjName = macInf->GetName();
2753
						aTarFrm = macInf->GetTarFrm();
2754
						break;
2755
					}
2756
				}
2757
			}
2758
			SwFmtURL* pFmtURL = new SwFmtURL();
2759
			pFmtURL->SetURL( lnName, false );
2760
			if(aObjName.Len() > 0)
2761
				pFmtURL->SetName(aObjName);
2762
			if(aTarFrm.Len()>0)
2763
				pFmtURL->SetTargetFrameName(aTarFrm);
2764
			pFmtURL->SetMap(0);
2765
			aFlySet.Put(*pFmtURL);
2766
		}
2767
	}
2768
2731
    // If we are to be "below text" then we are not to be opaque
2769
    // If we are to be "below text" then we are not to be opaque
2732
    // #i14045# MM If we are in a header or footer then make the object transparent
2770
    // #i14045# MM If we are in a header or footer then make the object transparent
2733
    // Not exactly like word but close enough for now
2771
    // Not exactly like word but close enough for now
(-)sw/source/filter/ww8/ww8par.cxx (-1 / +304 lines)
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
(-)sw/source/filter/ww8/ww8par.hxx (+48 lines)
Lines 31-36 Link Here
31
#include <editeng/frmdir.hxx>
31
#include <editeng/frmdir.hxx>
32
#include <fltshell.hxx>         // fuer den Attribut Stack
32
#include <fltshell.hxx>         // fuer den Attribut Stack
33
33
34
#include <svx/svdobj.hxx>
35
#define SW_DRAWLAYER 0x30334353
36
#define SW_UD_IMAPDATA		2
37
34
#include <vector>
38
#include <vector>
35
#include <stack>
39
#include <stack>
36
#include <deque>
40
#include <deque>
Lines 365-371 Link Here
365
    SwWW8FltRefStack& operator=(const SwWW8FltRefStack&);
369
    SwWW8FltRefStack& operator=(const SwWW8FltRefStack&);
366
};
370
};
367
371
372
template< typename Type >
373
inline bool get_flag( Type nBitField, Type nMask )
374
{ return (nBitField & nMask) != 0; }
368
375
376
template< typename ReturnType, typename Type >
377
inline ReturnType ulimit_cast( Type nValue, ReturnType nMax )
378
{ return static_cast< ReturnType >( ::std::min< Type >( nValue, nMax ) ); }
379
380
381
template< typename ReturnType, typename Type >
382
inline ReturnType ulimit_cast( Type nValue )
383
{ return ulimit_cast( nValue, ::std::numeric_limits< ReturnType >::max() ); }
384
385
class SwMacroInfo : public SdrObjUserData
386
{
387
public:
388
                    SwMacroInfo();
389
    virtual         ~SwMacroInfo();
390
391
    virtual SdrObjUserData* Clone( SdrObject* pObj ) const;
392
393
394
    void            SetHlink( const rtl::OUString& rHlink ) { maHlink = rHlink; }
395
    const rtl::OUString& GetHlink() const { return maHlink; }
396
	 void            SetTarFrm( const rtl::OUString& rTarFrm ) { maTarFrm = rTarFrm; }
397
    const rtl::OUString& GetTarFrm() const { return maTarFrm; }
398
	void            SetShapeId( const sal_uInt32& rShapeId ) { maShapeId = rShapeId; }
399
    const sal_uInt32& GetShapeId() const { return maShapeId; }
400
	void            SetName( const rtl::OUString& rName ) { maNameStr = rName; }
401
	const rtl::OUString& GetName() const { return maNameStr; }
402
403
private:
404
    sal_uInt32   maShapeId;
405
    rtl::OUString   maHlink;
406
	rtl::OUString maNameStr;
407
	rtl::OUString maTarFrm;
408
};
409
struct HyperLinksTable
410
{
411
	String hLinkAddr;
412
	String tarFrm;
413
};
414
369
namespace sw
415
namespace sw
370
{
416
{
371
    namespace hack
417
    namespace hack
Lines 1667-1672 Link Here
1667
    CharSet GetCurrentCJKCharSet();
1713
    CharSet GetCurrentCJKCharSet();
1668
1714
1669
    void PostProcessAttrs();
1715
    void PostProcessAttrs();
1716
	static void       ReadEmbeddedData(SvMemoryStream& rStrm, SwDocShell* pDocShell ,struct HyperLinksTable& hlStr);
1717
	static String ReadRawUniString( SvMemoryStream& rStrm,sal_uInt16 nChars, bool b16Bit );
1670
};
1718
};
1671
1719
1672
bool CanUseRemoteLink(const String &rGrfName);
1720
bool CanUseRemoteLink(const String &rGrfName);

Return to issue 120927