xref: /AOO41X/main/oox/source/ole/olehelper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "oox/ole/olehelper.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
31*cdf0e10cSrcweir #include "oox/helper/binaryinputstream.hxx"
32*cdf0e10cSrcweir #include "oox/helper/graphichelper.hxx"
33*cdf0e10cSrcweir #include "oox/token/tokens.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir namespace oox {
36*cdf0e10cSrcweir namespace ole {
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir // ============================================================================
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir using ::rtl::OUString;
41*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir // ============================================================================
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir const sal_uInt32 OLE_COLORTYPE_MASK         = 0xFF000000;
48*cdf0e10cSrcweir const sal_uInt32 OLE_COLORTYPE_CLIENT       = 0x00000000;
49*cdf0e10cSrcweir const sal_uInt32 OLE_COLORTYPE_PALETTE      = 0x01000000;
50*cdf0e10cSrcweir const sal_uInt32 OLE_COLORTYPE_BGR          = 0x02000000;
51*cdf0e10cSrcweir const sal_uInt32 OLE_COLORTYPE_SYSCOLOR     = 0x80000000;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir const sal_uInt32 OLE_PALETTECOLOR_MASK      = 0x0000FFFF;
54*cdf0e10cSrcweir const sal_uInt32 OLE_BGRCOLOR_MASK          = 0x00FFFFFF;
55*cdf0e10cSrcweir const sal_uInt32 OLE_SYSTEMCOLOR_MASK       = 0x0000FFFF;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /** Swaps the red and blue component of the passed color. */
58*cdf0e10cSrcweir inline sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor )
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     return static_cast< sal_uInt32 >( (nColor & 0xFF00FF00) | ((nColor & 0x0000FF) << 16) | ((nColor & 0xFF0000) >> 16) );
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir /** Returns the UNO RGB color from the passed encoded OLE BGR color. */
64*cdf0e10cSrcweir inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nOleColor )
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     return static_cast< sal_Int32 >( lclSwapRedBlue( nOleColor ) & 0xFFFFFF );
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir // ----------------------------------------------------------------------------
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir const sal_Char* const OLE_GUID_URLMONIKER   = "{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}";
72*cdf0e10cSrcweir const sal_Char* const OLE_GUID_FILEMONIKER  = "{00000303-0000-0000-C000-000000000046}";
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir const sal_uInt32 OLE_STDPIC_ID              = 0x0000746C;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_VERSION       = 2;
77*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASTARGET     = 0x00000001;   /// Has hyperlink moniker.
78*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_ABSOLUTE      = 0x00000002;   /// Absolute path.
79*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASLOCATION   = 0x00000008;   /// Has target location.
80*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASDISPLAY    = 0x00000010;   /// Has display string.
81*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASGUID       = 0x00000020;   /// Has identification GUID.
82*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASTIME       = 0x00000040;   /// Has creation time.
83*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_HASFRAME      = 0x00000080;   /// Has frame.
84*cdf0e10cSrcweir const sal_uInt32 OLE_STDHLINK_ASSTRING      = 0x00000100;   /// Hyperlink as simple string.
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir // ----------------------------------------------------------------------------
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir template< typename Type >
89*cdf0e10cSrcweir void lclAppendHex( OUStringBuffer& orBuffer, Type nValue )
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir     const sal_Int32 nWidth = 2 * sizeof( Type );
92*cdf0e10cSrcweir     static const sal_Unicode spcHexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
93*cdf0e10cSrcweir     orBuffer.setLength( orBuffer.getLength() + nWidth );
94*cdf0e10cSrcweir     for( sal_Int32 nCharIdx = orBuffer.getLength() - 1, nCharEnd = nCharIdx - nWidth; nCharIdx > nCharEnd; --nCharIdx, nValue >>= 4 )
95*cdf0e10cSrcweir         orBuffer.setCharAt( nCharIdx, spcHexChars[ nValue & 0xF ] );
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, bool bUnicode )
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     OUString aRet;
101*cdf0e10cSrcweir     sal_Int32 nChars = rInStrm.readInt32();
102*cdf0e10cSrcweir     if( nChars > 0 )
103*cdf0e10cSrcweir     {
104*cdf0e10cSrcweir         sal_Int32 nReadChars = getLimitedValue< sal_Int32, sal_Int32 >( nChars, 0, SAL_MAX_UINT16 );
105*cdf0e10cSrcweir         // byte strings are always in ANSI (Windows 1252) encoding
106*cdf0e10cSrcweir         aRet = bUnicode ? rInStrm.readUnicodeArray( nReadChars, true ) : rInStrm.readCharArrayUC( nReadChars, RTL_TEXTENCODING_MS_1252, true );
107*cdf0e10cSrcweir         // strings are NUL terminated, remove trailing NUL and possible other garbage
108*cdf0e10cSrcweir         sal_Int32 nNulPos = aRet.indexOf( '\0' );
109*cdf0e10cSrcweir         if( nNulPos >= 0 )
110*cdf0e10cSrcweir             aRet = aRet.copy( 0, nNulPos );
111*cdf0e10cSrcweir         // skip remaining chars
112*cdf0e10cSrcweir         rInStrm.skip( (bUnicode ? 2 : 1) * (nChars - nReadChars) );
113*cdf0e10cSrcweir     }
114*cdf0e10cSrcweir     return aRet;
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir } // namespace
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir // ============================================================================
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir StdFontInfo::StdFontInfo() :
122*cdf0e10cSrcweir     mnHeight( 0 ),
123*cdf0e10cSrcweir     mnWeight( OLE_STDFONT_NORMAL ),
124*cdf0e10cSrcweir     mnCharSet( WINDOWS_CHARSET_ANSI ),
125*cdf0e10cSrcweir     mnFlags( 0 )
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight,
130*cdf0e10cSrcweir         sal_uInt16 nWeight, sal_uInt16 nCharSet, sal_uInt8 nFlags ) :
131*cdf0e10cSrcweir     maName( rName ),
132*cdf0e10cSrcweir     mnHeight( nHeight ),
133*cdf0e10cSrcweir     mnWeight( nWeight ),
134*cdf0e10cSrcweir     mnCharSet( nCharSet ),
135*cdf0e10cSrcweir     mnFlags( nFlags )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir // ============================================================================
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir /*static*/ sal_Int32 OleHelper::decodeOleColor(
142*cdf0e10cSrcweir         const GraphicHelper& rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     static const sal_Int32 spnSystemColors[] =
145*cdf0e10cSrcweir     {
146*cdf0e10cSrcweir         XML_scrollBar,      XML_background,     XML_activeCaption,  XML_inactiveCaption,
147*cdf0e10cSrcweir         XML_menu,           XML_window,         XML_windowFrame,    XML_menuText,
148*cdf0e10cSrcweir         XML_windowText,     XML_captionText,    XML_activeBorder,   XML_inactiveBorder,
149*cdf0e10cSrcweir         XML_appWorkspace,   XML_highlight,      XML_highlightText,  XML_btnFace,
150*cdf0e10cSrcweir         XML_btnShadow,      XML_grayText,       XML_btnText,        XML_inactiveCaptionText,
151*cdf0e10cSrcweir         XML_btnHighlight,   XML_3dDkShadow,     XML_3dLight,        XML_infoText,
152*cdf0e10cSrcweir         XML_infoBk
153*cdf0e10cSrcweir     };
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     switch( nOleColor & OLE_COLORTYPE_MASK )
156*cdf0e10cSrcweir     {
157*cdf0e10cSrcweir         case OLE_COLORTYPE_CLIENT:
158*cdf0e10cSrcweir             return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir         case OLE_COLORTYPE_PALETTE:
161*cdf0e10cSrcweir             return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         case OLE_COLORTYPE_BGR:
164*cdf0e10cSrcweir             return lclDecodeBgrColor( nOleColor );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir         case OLE_COLORTYPE_SYSCOLOR:
167*cdf0e10cSrcweir             return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE );
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir     OSL_ENSURE( false, "OleHelper::decodeOleColor - unknown color type" );
170*cdf0e10cSrcweir     return API_RGB_BLACK;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir /*static*/ sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir     return OLE_COLORTYPE_BGR | lclSwapRedBlue( static_cast< sal_uInt32 >( nRgbColor & 0xFFFFFF ) );
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir /*static*/ OUString OleHelper::importGuid( BinaryInputStream& rInStrm )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir     OUStringBuffer aBuffer;
181*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '{' ) );
182*cdf0e10cSrcweir     lclAppendHex( aBuffer, rInStrm.readuInt32() );
183*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '-' ) );
184*cdf0e10cSrcweir     lclAppendHex( aBuffer, rInStrm.readuInt16() );
185*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '-' ) );
186*cdf0e10cSrcweir     lclAppendHex( aBuffer, rInStrm.readuInt16() );
187*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '-' ) );
188*cdf0e10cSrcweir     lclAppendHex( aBuffer, rInStrm.readuInt8() );
189*cdf0e10cSrcweir     lclAppendHex( aBuffer, rInStrm.readuInt8() );
190*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '-' ) );
191*cdf0e10cSrcweir     for( int nIndex = 0; nIndex < 6; ++nIndex )
192*cdf0e10cSrcweir         lclAppendHex( aBuffer, rInStrm.readuInt8() );
193*cdf0e10cSrcweir     aBuffer.append( sal_Unicode( '}' ) );
194*cdf0e10cSrcweir     return aBuffer.makeStringAndClear();
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir /*static*/ bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInStrm, bool bWithGuid )
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir     if( bWithGuid )
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir         bool bIsStdFont = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDFONT );
202*cdf0e10cSrcweir         OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" );
203*cdf0e10cSrcweir         if( !bIsStdFont )
204*cdf0e10cSrcweir             return false;
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     sal_uInt8 nVersion, nNameLen;
208*cdf0e10cSrcweir     rInStrm >> nVersion >> orFontInfo.mnCharSet >> orFontInfo.mnFlags >> orFontInfo.mnWeight >> orFontInfo.mnHeight >> nNameLen;
209*cdf0e10cSrcweir     // according to spec the name is ASCII
210*cdf0e10cSrcweir     orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US );
211*cdf0e10cSrcweir     OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" );
212*cdf0e10cSrcweir     return !rInStrm.isEof() && (nVersion <= 1);
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir /*static*/ bool OleHelper::importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid )
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir     if( bWithGuid )
218*cdf0e10cSrcweir     {
219*cdf0e10cSrcweir         bool bIsStdPic = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDPIC );
220*cdf0e10cSrcweir         OSL_ENSURE( bIsStdPic, "OleHelper::importStdPic - unexpected header GUID, expected StdPic" );
221*cdf0e10cSrcweir         if( !bIsStdPic )
222*cdf0e10cSrcweir             return false;
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     sal_uInt32 nStdPicId;
226*cdf0e10cSrcweir     sal_Int32 nBytes;
227*cdf0e10cSrcweir     rInStrm >> nStdPicId >> nBytes;
228*cdf0e10cSrcweir     OSL_ENSURE( nStdPicId == OLE_STDPIC_ID, "OleHelper::importStdPic - unexpected header version" );
229*cdf0e10cSrcweir     return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes);
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir /*static*/ bool OleHelper::importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, bool bWithGuid )
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir     if( bWithGuid )
235*cdf0e10cSrcweir     {
236*cdf0e10cSrcweir         bool bIsStdHlink = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDHLINK );
237*cdf0e10cSrcweir         OSL_ENSURE( bIsStdHlink, "OleHelper::importStdHlink - unexpected header GUID, expected StdHlink" );
238*cdf0e10cSrcweir         if( !bIsStdHlink )
239*cdf0e10cSrcweir             return false;
240*cdf0e10cSrcweir     }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir     sal_uInt32 nVersion, nFlags;
243*cdf0e10cSrcweir     rInStrm >> nVersion >> nFlags;
244*cdf0e10cSrcweir     OSL_ENSURE( nVersion == OLE_STDHLINK_VERSION, "OleHelper::importStdHlink - unexpected header version" );
245*cdf0e10cSrcweir     if( rInStrm.isEof() || (nVersion != OLE_STDHLINK_VERSION) )
246*cdf0e10cSrcweir         return false;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     // display string
249*cdf0e10cSrcweir     if( getFlag( nFlags, OLE_STDHLINK_HASDISPLAY ) )
250*cdf0e10cSrcweir         orHlinkInfo.maDisplay = lclReadStdHlinkString( rInStrm, true );
251*cdf0e10cSrcweir     // frame string
252*cdf0e10cSrcweir     if( getFlag( nFlags, OLE_STDHLINK_HASFRAME ) )
253*cdf0e10cSrcweir         orHlinkInfo.maFrame = lclReadStdHlinkString( rInStrm, true );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     // target
256*cdf0e10cSrcweir     if( getFlag( nFlags, OLE_STDHLINK_HASTARGET ) )
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         if( getFlag( nFlags, OLE_STDHLINK_ASSTRING ) )
259*cdf0e10cSrcweir         {
260*cdf0e10cSrcweir             OSL_ENSURE( getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - link not absolute" );
261*cdf0e10cSrcweir             orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, true );
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir         else // hyperlink moniker
264*cdf0e10cSrcweir         {
265*cdf0e10cSrcweir             OUString aGuid = importGuid( rInStrm );
266*cdf0e10cSrcweir             if( aGuid.equalsAscii( OLE_GUID_FILEMONIKER ) )
267*cdf0e10cSrcweir             {
268*cdf0e10cSrcweir                 // file name, maybe relative and with directory up-count
269*cdf0e10cSrcweir                 sal_Int16 nUpLevels;
270*cdf0e10cSrcweir                 rInStrm >> nUpLevels;
271*cdf0e10cSrcweir                 OSL_ENSURE( (nUpLevels == 0) || !getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - absolute filename with upcount" );
272*cdf0e10cSrcweir                 orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, false );
273*cdf0e10cSrcweir                 rInStrm.skip( 24 );
274*cdf0e10cSrcweir                 sal_Int32 nBytes = rInStrm.readInt32();
275*cdf0e10cSrcweir                 if( nBytes > 0 )
276*cdf0e10cSrcweir                 {
277*cdf0e10cSrcweir                     sal_Int64 nEndPos = rInStrm.tell() + ::std::max< sal_Int32 >( nBytes, 0 );
278*cdf0e10cSrcweir                     sal_uInt16 nChars = getLimitedValue< sal_uInt16, sal_Int32 >( rInStrm.readInt32() / 2, 0, SAL_MAX_UINT16 );
279*cdf0e10cSrcweir                     rInStrm.skip( 2 );  // key value
280*cdf0e10cSrcweir                     orHlinkInfo.maTarget = rInStrm.readUnicodeArray( nChars );  // NOT null terminated
281*cdf0e10cSrcweir                     rInStrm.seek( nEndPos );
282*cdf0e10cSrcweir                 }
283*cdf0e10cSrcweir                 if( !getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ) )
284*cdf0e10cSrcweir                     for( sal_Int16 nLevel = 0; nLevel < nUpLevels; ++nLevel )
285*cdf0e10cSrcweir                         orHlinkInfo.maTarget = CREATE_OUSTRING( "../" ) + orHlinkInfo.maTarget;
286*cdf0e10cSrcweir             }
287*cdf0e10cSrcweir             else if( aGuid.equalsAscii( OLE_GUID_URLMONIKER ) )
288*cdf0e10cSrcweir             {
289*cdf0e10cSrcweir                 // URL, maybe relative and with leading '../'
290*cdf0e10cSrcweir                 sal_Int32 nBytes = rInStrm.readInt32();
291*cdf0e10cSrcweir                 sal_Int64 nEndPos = rInStrm.tell() + ::std::max< sal_Int32 >( nBytes, 0 );
292*cdf0e10cSrcweir                 orHlinkInfo.maTarget = rInStrm.readNulUnicodeArray();
293*cdf0e10cSrcweir                 rInStrm.seek( nEndPos );
294*cdf0e10cSrcweir             }
295*cdf0e10cSrcweir             else
296*cdf0e10cSrcweir             {
297*cdf0e10cSrcweir                 OSL_ENSURE( false, "OleHelper::importStdHlink - unsupported hyperlink moniker" );
298*cdf0e10cSrcweir                 return false;
299*cdf0e10cSrcweir             }
300*cdf0e10cSrcweir         }
301*cdf0e10cSrcweir     }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     // target location
304*cdf0e10cSrcweir     if( getFlag( nFlags, OLE_STDHLINK_HASLOCATION ) )
305*cdf0e10cSrcweir         orHlinkInfo.maLocation = lclReadStdHlinkString( rInStrm, true );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir     return !rInStrm.isEof();
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir // ============================================================================
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir } // namespace ole
313*cdf0e10cSrcweir } // namespace oox
314