189dcb3daSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
389dcb3daSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
489dcb3daSAndrew Rist * or more contributor license agreements. See the NOTICE file
589dcb3daSAndrew Rist * distributed with this work for additional information
689dcb3daSAndrew Rist * regarding copyright ownership. The ASF licenses this file
789dcb3daSAndrew Rist * to you under the Apache License, Version 2.0 (the
889dcb3daSAndrew Rist * "License"); you may not use this file except in compliance
989dcb3daSAndrew Rist * with the License. You may obtain a copy of the License at
1089dcb3daSAndrew Rist *
1189dcb3daSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1289dcb3daSAndrew Rist *
1389dcb3daSAndrew Rist * Unless required by applicable law or agreed to in writing,
1489dcb3daSAndrew Rist * software distributed under the License is distributed on an
1589dcb3daSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1689dcb3daSAndrew Rist * KIND, either express or implied. See the License for the
1789dcb3daSAndrew Rist * specific language governing permissions and limitations
1889dcb3daSAndrew Rist * under the License.
1989dcb3daSAndrew Rist *
2089dcb3daSAndrew Rist *************************************************************/
2189dcb3daSAndrew Rist
2289dcb3daSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define WORKAROUND_98119
28cdf0e10cSrcweir
29cdf0e10cSrcweir #ifdef WORKAROUND_98119
30cdf0e10cSrcweir #include "bufferedinputstream.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <string.h>
34cdf0e10cSrcweir #ifndef _VOS_DIAGNOSE_HXX_
35cdf0e10cSrcweir #include <vos/diagnose.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <osl/thread.h>
38cdf0e10cSrcweir #include <rtl/memory.h>
39cdf0e10cSrcweir #include <osl/file.hxx>
40cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
41cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx>
42cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
43cdf0e10cSrcweir #include <rtl/uri.hxx>
44cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
45cdf0e10cSrcweir #include <libxslt/xslt.h>
46cdf0e10cSrcweir #include <libxslt/transform.h>
47cdf0e10cSrcweir #include <libxslt/xsltutils.h>
48cdf0e10cSrcweir #include "db.hxx"
49cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
50cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
51cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
53cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
54cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp>
55cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
56cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifier.hpp>
57cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp>
58cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
59cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
60cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
61cdf0e10cSrcweir
62cdf0e10cSrcweir #include "urlparameter.hxx"
63cdf0e10cSrcweir #include "databases.hxx"
64cdf0e10cSrcweir
65cdf0e10cSrcweir namespace chelp {
66cdf0e10cSrcweir
ascii_isDigit(sal_Unicode ch)67cdf0e10cSrcweir inline bool ascii_isDigit( sal_Unicode ch )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir return ((ch >= 0x0030) && (ch <= 0x0039));
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
ascii_isLetter(sal_Unicode ch)72cdf0e10cSrcweir inline bool ascii_isLetter( sal_Unicode ch )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir return ( ( (ch >= 0x0041) && (ch <= 0x005A) ) ||
75cdf0e10cSrcweir ( (ch >= 0x0061) && (ch <= 0x007A) ) );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
isLetterOrDigit(sal_Unicode ch)78cdf0e10cSrcweir inline bool isLetterOrDigit( sal_Unicode ch )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir return ascii_isLetter( ch ) || ascii_isDigit( ch );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir using namespace cppu;
86cdf0e10cSrcweir using namespace com::sun::star::io;
87cdf0e10cSrcweir using namespace com::sun::star::uno;
88cdf0e10cSrcweir using namespace com::sun::star::lang;
89cdf0e10cSrcweir using namespace com::sun::star::ucb;
90cdf0e10cSrcweir using namespace com::sun::star::beans;
91cdf0e10cSrcweir using namespace com::sun::star::container;
92cdf0e10cSrcweir using namespace chelp;
93cdf0e10cSrcweir
94cdf0e10cSrcweir
URLParameter(const rtl::OUString & aURL,Databases * pDatabases)95cdf0e10cSrcweir URLParameter::URLParameter( const rtl::OUString& aURL,
96cdf0e10cSrcweir Databases* pDatabases )
97cdf0e10cSrcweir throw( com::sun::star::ucb::IllegalIdentifierException )
98cdf0e10cSrcweir : m_pDatabases( pDatabases ),
99cdf0e10cSrcweir m_aURL( aURL )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir init( false );
102cdf0e10cSrcweir parse();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir
isErrorDocument()106cdf0e10cSrcweir bool URLParameter::isErrorDocument()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir bool bErrorDoc = false;
109cdf0e10cSrcweir
110cdf0e10cSrcweir if( isFile() )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA =
113cdf0e10cSrcweir m_pDatabases->findJarFileForPath( get_jar(), get_language(), get_path() );
114cdf0e10cSrcweir bErrorDoc = !xNA.is();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir return bErrorDoc;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir
getByName(const char * par)121cdf0e10cSrcweir rtl::OString URLParameter::getByName( const char* par )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir rtl::OUString val;
124cdf0e10cSrcweir
125cdf0e10cSrcweir if( strcmp( par,"Program" ) == 0 )
126cdf0e10cSrcweir val = get_program();
127cdf0e10cSrcweir else if( strcmp( par,"Database" ) == 0 )
128cdf0e10cSrcweir val = get_module();
129cdf0e10cSrcweir else if( strcmp( par,"DatabasePar" ) == 0 )
130cdf0e10cSrcweir val = get_dbpar();
131cdf0e10cSrcweir else if( strcmp( par,"Id" ) == 0 )
132cdf0e10cSrcweir val = get_id();
133cdf0e10cSrcweir else if( strcmp( par,"Path" ) == 0 )
134cdf0e10cSrcweir val = get_path();
135cdf0e10cSrcweir else if( strcmp( par,"Language" ) == 0 )
136cdf0e10cSrcweir val = get_language();
137cdf0e10cSrcweir else if( strcmp( par,"System" ) == 0 )
138cdf0e10cSrcweir val = get_system();
139cdf0e10cSrcweir else if( strcmp( par,"HelpPrefix" ) == 0 )
140cdf0e10cSrcweir val = get_prefix();
141cdf0e10cSrcweir
142cdf0e10cSrcweir return rtl::OString( val.getStr(),val.getLength(),RTL_TEXTENCODING_UTF8 );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir
get_id()146cdf0e10cSrcweir rtl::OUString URLParameter::get_id()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir if( m_aId.compareToAscii("start") == 0 )
149cdf0e10cSrcweir { // module is set
150cdf0e10cSrcweir StaticModuleInformation* inf =
151cdf0e10cSrcweir m_pDatabases->getStaticInformationForModule( get_module(),
152cdf0e10cSrcweir get_language() );
153cdf0e10cSrcweir if( inf )
154cdf0e10cSrcweir m_aId = inf->get_id();
155cdf0e10cSrcweir
156cdf0e10cSrcweir m_bStart = true;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir return m_aId;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
get_tag()162cdf0e10cSrcweir rtl::OUString URLParameter::get_tag()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir if( isFile() )
165cdf0e10cSrcweir return get_the_tag();
166cdf0e10cSrcweir else
167cdf0e10cSrcweir return m_aTag;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir
get_title()171cdf0e10cSrcweir rtl::OUString URLParameter::get_title()
172cdf0e10cSrcweir {
173cdf0e10cSrcweir if( isFile() )
174cdf0e10cSrcweir return get_the_title();
175cdf0e10cSrcweir else if( m_aModule.compareToAscii("") != 0 )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir StaticModuleInformation* inf =
178cdf0e10cSrcweir m_pDatabases->getStaticInformationForModule( get_module(),
179cdf0e10cSrcweir get_language() );
180cdf0e10cSrcweir if( inf )
181cdf0e10cSrcweir m_aTitle = inf->get_title();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir else // This must be the root
184cdf0e10cSrcweir m_aTitle = rtl::OUString::createFromAscii("root");
185cdf0e10cSrcweir
186cdf0e10cSrcweir return m_aTitle;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir
get_language()190cdf0e10cSrcweir rtl::OUString URLParameter::get_language()
191cdf0e10cSrcweir {
192cdf0e10cSrcweir if( m_aLanguage.getLength() == 0 )
193cdf0e10cSrcweir return m_aDefaultLanguage;
194cdf0e10cSrcweir
195cdf0e10cSrcweir return m_aLanguage;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir
get_program()199cdf0e10cSrcweir rtl::OUString URLParameter::get_program()
200cdf0e10cSrcweir {
201cdf0e10cSrcweir if( ! m_aProgram.getLength() )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir StaticModuleInformation* inf =
204cdf0e10cSrcweir m_pDatabases->getStaticInformationForModule( get_module(),
205cdf0e10cSrcweir get_language() );
206cdf0e10cSrcweir if( inf )
207cdf0e10cSrcweir m_aProgram = inf->get_program();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir return m_aProgram;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir
init(bool bDefaultLanguageIsInitialized)213cdf0e10cSrcweir void URLParameter::init( bool bDefaultLanguageIsInitialized )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir (void)bDefaultLanguageIsInitialized;
216cdf0e10cSrcweir
217*70e197d9SHerbert Dürr m_bHelpDataFileRead = false;
218cdf0e10cSrcweir m_bStart = false;
219cdf0e10cSrcweir m_bUseDB = true;
220cdf0e10cSrcweir m_nHitCount = 100; // The default maximum hitcount
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223cdf0e10cSrcweir
get_the_tag()224cdf0e10cSrcweir rtl::OUString URLParameter::get_the_tag()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir if(m_bUseDB) {
227*70e197d9SHerbert Dürr if( ! m_bHelpDataFileRead )
228*70e197d9SHerbert Dürr readHelpDataFile();
229cdf0e10cSrcweir
230*70e197d9SHerbert Dürr m_bHelpDataFileRead = true;
231cdf0e10cSrcweir
232cdf0e10cSrcweir return m_aTag;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir else
235cdf0e10cSrcweir return rtl::OUString();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir
239cdf0e10cSrcweir
get_the_path()240cdf0e10cSrcweir rtl::OUString URLParameter::get_the_path()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir if(m_bUseDB) {
243*70e197d9SHerbert Dürr if( ! m_bHelpDataFileRead )
244*70e197d9SHerbert Dürr readHelpDataFile();
245*70e197d9SHerbert Dürr m_bHelpDataFileRead = true;
246cdf0e10cSrcweir
247cdf0e10cSrcweir return m_aPath;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir else
250cdf0e10cSrcweir return get_id();
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir
254cdf0e10cSrcweir
get_the_title()255cdf0e10cSrcweir rtl::OUString URLParameter::get_the_title()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir if(m_bUseDB) {
258*70e197d9SHerbert Dürr if( ! m_bHelpDataFileRead )
259*70e197d9SHerbert Dürr readHelpDataFile();
260*70e197d9SHerbert Dürr m_bHelpDataFileRead = true;
261cdf0e10cSrcweir
262cdf0e10cSrcweir return m_aTitle;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir else
265cdf0e10cSrcweir return rtl::OUString();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir
get_the_jar()269cdf0e10cSrcweir rtl::OUString URLParameter::get_the_jar()
270cdf0e10cSrcweir {
271cdf0e10cSrcweir if(m_bUseDB) {
272*70e197d9SHerbert Dürr if( ! m_bHelpDataFileRead )
273*70e197d9SHerbert Dürr readHelpDataFile();
274*70e197d9SHerbert Dürr m_bHelpDataFileRead = true;
275cdf0e10cSrcweir
276cdf0e10cSrcweir return m_aJar;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir else
279cdf0e10cSrcweir return get_module() + rtl::OUString::createFromAscii(".jar");
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir
283cdf0e10cSrcweir
284cdf0e10cSrcweir
readHelpDataFile()285*70e197d9SHerbert Dürr void URLParameter::readHelpDataFile()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir static rtl::OUString aQuestionMark( rtl::OUString::createFromAscii( "?" ) );
288cdf0e10cSrcweir
289cdf0e10cSrcweir if( get_id().compareToAscii("") == 0 )
290cdf0e10cSrcweir return;
291cdf0e10cSrcweir
292cdf0e10cSrcweir rtl::OUString aModule = get_module();
293cdf0e10cSrcweir rtl::OUString aLanguage = get_language();
294cdf0e10cSrcweir
295cdf0e10cSrcweir DataBaseIterator aDbIt( *m_pDatabases, aModule, aLanguage, false );
296cdf0e10cSrcweir bool bSuccess = false;
297cdf0e10cSrcweir
298cdf0e10cSrcweir int nSize = 0;
299cdf0e10cSrcweir const sal_Char* pData = NULL;
300cdf0e10cSrcweir
301*70e197d9SHerbert Dürr helpdatafileproxy::HDFData aHDFData;
302cdf0e10cSrcweir rtl::OUString aExtensionPath;
303cdf0e10cSrcweir rtl::OUString aExtensionRegistryPath;
304cdf0e10cSrcweir while( true )
305cdf0e10cSrcweir {
306*70e197d9SHerbert Dürr helpdatafileproxy::Hdf* pHdf = aDbIt.nextHdf( &aExtensionPath, &aExtensionRegistryPath );
307*70e197d9SHerbert Dürr if( !pHdf )
308cdf0e10cSrcweir break;
309cdf0e10cSrcweir
310cdf0e10cSrcweir rtl::OString keyStr( m_aId.getStr(),m_aId.getLength(),RTL_TEXTENCODING_UTF8 );
311cdf0e10cSrcweir
312*70e197d9SHerbert Dürr bSuccess = pHdf->getValueForKey( keyStr, aHDFData );
313*70e197d9SHerbert Dürr if( bSuccess )
314cdf0e10cSrcweir {
315*70e197d9SHerbert Dürr nSize = aHDFData.getSize();
316*70e197d9SHerbert Dürr pData = aHDFData.getData();
317*70e197d9SHerbert Dürr break;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir if( bSuccess )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir DbtToStringConverter converter( pData, nSize );
324cdf0e10cSrcweir m_aTitle = converter.getTitle();
325cdf0e10cSrcweir m_pDatabases->replaceName( m_aTitle );
326cdf0e10cSrcweir m_aPath = converter.getFile();
327cdf0e10cSrcweir m_aJar = converter.getDatabase();
328cdf0e10cSrcweir if( aExtensionPath.getLength() > 0 )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir rtl::OUStringBuffer aExtendedJarStrBuf;
331cdf0e10cSrcweir aExtendedJarStrBuf.append( aQuestionMark );
332cdf0e10cSrcweir aExtendedJarStrBuf.append( aExtensionPath );
333cdf0e10cSrcweir aExtendedJarStrBuf.append( aQuestionMark );
334cdf0e10cSrcweir aExtendedJarStrBuf.append( m_aJar );
335cdf0e10cSrcweir m_aJar = aExtendedJarStrBuf.makeStringAndClear();
336cdf0e10cSrcweir m_aExtensionRegistryPath = aExtensionRegistryPath;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir m_aTag = converter.getHash();
339cdf0e10cSrcweir }
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir
343cdf0e10cSrcweir
344cdf0e10cSrcweir // Class encapsulating the transformation of the XInputStream to XHTML
345cdf0e10cSrcweir
346cdf0e10cSrcweir
347cdf0e10cSrcweir class InputStreamTransformer
348cdf0e10cSrcweir : public OWeakObject,
349cdf0e10cSrcweir public XInputStream,
350cdf0e10cSrcweir public XSeekable
351cdf0e10cSrcweir {
352cdf0e10cSrcweir public:
353cdf0e10cSrcweir
354cdf0e10cSrcweir InputStreamTransformer( URLParameter* urlParam,
355cdf0e10cSrcweir Databases* pDatatabases,
356cdf0e10cSrcweir bool isRoot = false );
357cdf0e10cSrcweir
358cdf0e10cSrcweir ~InputStreamTransformer();
359cdf0e10cSrcweir
360cdf0e10cSrcweir virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
361cdf0e10cSrcweir virtual void SAL_CALL acquire( void ) throw();
362cdf0e10cSrcweir virtual void SAL_CALL release( void ) throw();
363cdf0e10cSrcweir
364cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData,sal_Int32 nBytesToRead )
365cdf0e10cSrcweir throw( NotConnectedException,
366cdf0e10cSrcweir BufferSizeExceededException,
367cdf0e10cSrcweir IOException,
368cdf0e10cSrcweir RuntimeException);
369cdf0e10cSrcweir
370cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readSomeBytes( Sequence< sal_Int8 >& aData,sal_Int32 nMaxBytesToRead )
371cdf0e10cSrcweir throw( NotConnectedException,
372cdf0e10cSrcweir BufferSizeExceededException,
373cdf0e10cSrcweir IOException,
374cdf0e10cSrcweir RuntimeException);
375cdf0e10cSrcweir
376cdf0e10cSrcweir virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException,
377cdf0e10cSrcweir BufferSizeExceededException,
378cdf0e10cSrcweir IOException,
379cdf0e10cSrcweir RuntimeException );
380cdf0e10cSrcweir
381cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available( void ) throw( NotConnectedException,
382cdf0e10cSrcweir IOException,
383cdf0e10cSrcweir RuntimeException );
384cdf0e10cSrcweir
385cdf0e10cSrcweir virtual void SAL_CALL closeInput( void ) throw( NotConnectedException,
386cdf0e10cSrcweir IOException,
387cdf0e10cSrcweir RuntimeException );
388cdf0e10cSrcweir
389cdf0e10cSrcweir virtual void SAL_CALL seek( sal_Int64 location ) throw( IllegalArgumentException,
390cdf0e10cSrcweir IOException,
391cdf0e10cSrcweir RuntimeException );
392cdf0e10cSrcweir
393cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getPosition( void ) throw( IOException,RuntimeException );
394cdf0e10cSrcweir
395cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getLength( void ) throw( IOException,RuntimeException );
396cdf0e10cSrcweir
397cdf0e10cSrcweir void addToBuffer( const char* buffer,int len );
398cdf0e10cSrcweir
getData() const399cdf0e10cSrcweir sal_Int8* getData() const { return (sal_Int8*) buffer; }
400cdf0e10cSrcweir
getLen() const401cdf0e10cSrcweir sal_Int32 getLen() const { return sal_Int32( len ); }
402cdf0e10cSrcweir
403cdf0e10cSrcweir private:
404cdf0e10cSrcweir
405cdf0e10cSrcweir osl::Mutex m_aMutex;
406cdf0e10cSrcweir
407cdf0e10cSrcweir int len,pos;
408cdf0e10cSrcweir char *buffer;
409cdf0e10cSrcweir };
410cdf0e10cSrcweir
411cdf0e10cSrcweir
412cdf0e10cSrcweir
open(const Reference<XMultiServiceFactory> & rxSMgr,const Command & aCommand,sal_Int32 CommandId,const Reference<XCommandEnvironment> & Environment,const Reference<XOutputStream> & xDataSink)413cdf0e10cSrcweir void URLParameter::open( const Reference< XMultiServiceFactory >& rxSMgr,
414cdf0e10cSrcweir const Command& aCommand,
415cdf0e10cSrcweir sal_Int32 CommandId,
416cdf0e10cSrcweir const Reference< XCommandEnvironment >& Environment,
417cdf0e10cSrcweir const Reference< XOutputStream >& xDataSink )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir (void)rxSMgr;
420cdf0e10cSrcweir (void)aCommand;
421cdf0e10cSrcweir (void)CommandId;
422cdf0e10cSrcweir (void)Environment;
423cdf0e10cSrcweir
424cdf0e10cSrcweir if( ! xDataSink.is() )
425cdf0e10cSrcweir return;
426cdf0e10cSrcweir
427cdf0e10cSrcweir if( isPicture() )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir Reference< XInputStream > xStream;
430cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA =
431cdf0e10cSrcweir m_pDatabases->jarFile( rtl::OUString::createFromAscii( "picture.jar" ),
432cdf0e10cSrcweir get_language() );
433cdf0e10cSrcweir
434cdf0e10cSrcweir rtl::OUString path = get_path();
435cdf0e10cSrcweir if( xNA.is() )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir try
438cdf0e10cSrcweir {
439cdf0e10cSrcweir Any aEntry = xNA->getByHierarchicalName( path );
440cdf0e10cSrcweir Reference< XActiveDataSink > xSink;
441cdf0e10cSrcweir if( ( aEntry >>= xSink ) && xSink.is() )
442cdf0e10cSrcweir xStream = xSink->getInputStream();
443cdf0e10cSrcweir }
444cdf0e10cSrcweir catch ( NoSuchElementException & )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir if( xStream.is() )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir sal_Int32 ret;
451cdf0e10cSrcweir Sequence< sal_Int8 > aSeq( 4096 );
452cdf0e10cSrcweir while( true )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir try
455cdf0e10cSrcweir {
456cdf0e10cSrcweir ret = xStream->readBytes( aSeq,4096 );
457cdf0e10cSrcweir xDataSink->writeBytes( aSeq );
458cdf0e10cSrcweir if( ret < 4096 )
459cdf0e10cSrcweir break;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir catch( const Exception& )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir break;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir }
466cdf0e10cSrcweir }
467cdf0e10cSrcweir }
468cdf0e10cSrcweir else
469cdf0e10cSrcweir {
470cdf0e10cSrcweir // a standard document or else an active help text, plug in the new input stream
471cdf0e10cSrcweir InputStreamTransformer* p = new InputStreamTransformer( this,m_pDatabases,isRoot() );
472cdf0e10cSrcweir try
473cdf0e10cSrcweir {
474cdf0e10cSrcweir xDataSink->writeBytes( Sequence< sal_Int8 >( p->getData(),p->getLen() ) );
475cdf0e10cSrcweir }
476cdf0e10cSrcweir catch( const Exception& )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir }
479cdf0e10cSrcweir delete p;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir xDataSink->closeOutput();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir
485cdf0e10cSrcweir
open(const Reference<XMultiServiceFactory> & rxSMgr,const Command & aCommand,sal_Int32 CommandId,const Reference<XCommandEnvironment> & Environment,const Reference<XActiveDataSink> & xDataSink)486cdf0e10cSrcweir void URLParameter::open( const Reference< XMultiServiceFactory >& rxSMgr,
487cdf0e10cSrcweir const Command& aCommand,
488cdf0e10cSrcweir sal_Int32 CommandId,
489cdf0e10cSrcweir const Reference< XCommandEnvironment >& Environment,
490cdf0e10cSrcweir const Reference< XActiveDataSink >& xDataSink )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir (void)rxSMgr;
493cdf0e10cSrcweir (void)aCommand;
494cdf0e10cSrcweir (void)CommandId;
495cdf0e10cSrcweir (void)Environment;
496cdf0e10cSrcweir
497cdf0e10cSrcweir if( isPicture() )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir Reference< XInputStream > xStream;
500cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA =
501cdf0e10cSrcweir m_pDatabases->jarFile( rtl::OUString::createFromAscii( "picture.jar" ),
502cdf0e10cSrcweir get_language() );
503cdf0e10cSrcweir
504cdf0e10cSrcweir rtl::OUString path = get_path();
505cdf0e10cSrcweir if( xNA.is() )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir try
508cdf0e10cSrcweir {
509cdf0e10cSrcweir Any aEntry = xNA->getByHierarchicalName( path );
510cdf0e10cSrcweir Reference< XActiveDataSink > xSink;
511cdf0e10cSrcweir if( ( aEntry >>= xSink ) && xSink.is() )
512cdf0e10cSrcweir xStream = xSink->getInputStream();
513cdf0e10cSrcweir }
514cdf0e10cSrcweir catch ( NoSuchElementException & )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir #ifdef WORKAROUND_98119
519cdf0e10cSrcweir xDataSink->setInputStream( turnToSeekable(xStream) );
520cdf0e10cSrcweir #else
521cdf0e10cSrcweir xDataSink->setInputStream( xStream );
522cdf0e10cSrcweir #endif
523cdf0e10cSrcweir }
524cdf0e10cSrcweir else
525cdf0e10cSrcweir // a standard document or else an active help text, plug in the new input stream
526cdf0e10cSrcweir xDataSink->setInputStream( new InputStreamTransformer( this,m_pDatabases,isRoot() ) );
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
529cdf0e10cSrcweir
530cdf0e10cSrcweir // #include <stdio.h>
531cdf0e10cSrcweir
parse()532cdf0e10cSrcweir void URLParameter::parse() throw( com::sun::star::ucb::IllegalIdentifierException )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir // fprintf(stdout,"url send to xmlhelp: %s\n",(rtl::OUStringToOString(m_aURL,RTL_TEXTENCODING_UTF8).getStr()));
535cdf0e10cSrcweir m_aExpr = m_aURL;
536cdf0e10cSrcweir
537cdf0e10cSrcweir sal_Int32 lstIdx = m_aExpr.lastIndexOf( sal_Unicode( '#' ) );
538cdf0e10cSrcweir if( lstIdx != -1 )
539cdf0e10cSrcweir m_aExpr = m_aExpr.copy( 0,lstIdx );
540cdf0e10cSrcweir
541cdf0e10cSrcweir if( ! scheme() ||
542cdf0e10cSrcweir ! name( module() ) ||
543cdf0e10cSrcweir ! query() ||
544cdf0e10cSrcweir ! m_aLanguage.getLength() ||
545cdf0e10cSrcweir ! m_aSystem.getLength() )
546cdf0e10cSrcweir throw com::sun::star::ucb::IllegalIdentifierException();
547cdf0e10cSrcweir }
548cdf0e10cSrcweir
549cdf0e10cSrcweir
scheme()550cdf0e10cSrcweir bool URLParameter::scheme()
551cdf0e10cSrcweir {
552cdf0e10cSrcweir // Correct extension help links as sometimes the
553cdf0e10cSrcweir // module is missing resulting in a misformed URL
554cdf0e10cSrcweir if( m_aExpr.compareToAscii( "vnd.sun.star.help:///", 21 ) == 0 )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir sal_Int32 nLen = m_aExpr.getLength();
557cdf0e10cSrcweir rtl::OUString aLastStr = m_aExpr.copy( nLen - 6 );
558cdf0e10cSrcweir if( aLastStr.compareToAscii( "DbPAR=" ) == 0 )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir rtl::OUString aNewExpr = m_aExpr.copy( 0, 20 );
561cdf0e10cSrcweir rtl::OUString aSharedStr = rtl::OUString::createFromAscii( "shared" );
562cdf0e10cSrcweir aNewExpr += aSharedStr;
563cdf0e10cSrcweir aNewExpr += m_aExpr.copy( 20 );
564cdf0e10cSrcweir aNewExpr += aSharedStr;
565cdf0e10cSrcweir m_aExpr = aNewExpr;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir }
568cdf0e10cSrcweir
569cdf0e10cSrcweir for( sal_Int32 nPrefixLen = 20 ; nPrefixLen >= 18 ; --nPrefixLen )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir if( m_aExpr.compareToAscii( "vnd.sun.star.help://", nPrefixLen ) == 0 )
572cdf0e10cSrcweir {
573cdf0e10cSrcweir m_aExpr = m_aExpr.copy( nPrefixLen );
574cdf0e10cSrcweir return true;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir return false;
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
580cdf0e10cSrcweir
module()581cdf0e10cSrcweir bool URLParameter::module()
582cdf0e10cSrcweir {
583cdf0e10cSrcweir sal_Int32 idx = 0,length = m_aExpr.getLength();
584cdf0e10cSrcweir
585cdf0e10cSrcweir while( idx < length && isLetterOrDigit( (m_aExpr.getStr())[idx] ) )
586cdf0e10cSrcweir ++idx;
587cdf0e10cSrcweir
588cdf0e10cSrcweir if( idx != 0 )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir m_aModule = m_aExpr.copy( 0,idx );
591cdf0e10cSrcweir m_aExpr = m_aExpr.copy( idx );
592cdf0e10cSrcweir return true;
593cdf0e10cSrcweir }
594cdf0e10cSrcweir else
595cdf0e10cSrcweir return false;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir
598cdf0e10cSrcweir
599cdf0e10cSrcweir
name(bool modulePresent)600cdf0e10cSrcweir bool URLParameter::name( bool modulePresent )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir // if modulepresent, a name may be present, but must not
603cdf0e10cSrcweir
604cdf0e10cSrcweir sal_Int32 length = m_aExpr.getLength();
605cdf0e10cSrcweir
606cdf0e10cSrcweir if( length != 0 && (m_aExpr.getStr())[0] == sal_Unicode( '/' ) )
607cdf0e10cSrcweir {
608cdf0e10cSrcweir sal_Int32 idx = 1;
609cdf0e10cSrcweir while( idx < length && (m_aExpr.getStr())[idx] != '?' )
610cdf0e10cSrcweir // ( isLetterOrDigit( (m_aExpr.getStr())[idx] )
611cdf0e10cSrcweir // || (m_aExpr.getStr())[idx] == '/'
612cdf0e10cSrcweir // || (m_aExpr.getStr())[idx] == '.' ))
613cdf0e10cSrcweir ++idx;
614cdf0e10cSrcweir
615cdf0e10cSrcweir if( idx != 1 && ! modulePresent )
616cdf0e10cSrcweir return false;
617cdf0e10cSrcweir else
618cdf0e10cSrcweir {
619cdf0e10cSrcweir m_aId = m_aExpr.copy( 1,idx-1 );
620cdf0e10cSrcweir m_aExpr = m_aExpr.copy( idx );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir // fprintf(stdout,"id %s\n",(rtl::OUStringToOString(m_aId,RTL_TEXTENCODING_UTF8).getStr()));
625cdf0e10cSrcweir return true;
626cdf0e10cSrcweir }
627cdf0e10cSrcweir
628cdf0e10cSrcweir
query()629cdf0e10cSrcweir bool URLParameter::query()
630cdf0e10cSrcweir {
631cdf0e10cSrcweir rtl::OUString query_;
632cdf0e10cSrcweir
633cdf0e10cSrcweir if( ! m_aExpr.getLength() )
634cdf0e10cSrcweir return true;
635cdf0e10cSrcweir else if( (m_aExpr.getStr())[0] == sal_Unicode( '?' ) )
636cdf0e10cSrcweir query_ = m_aExpr.copy( 1 ).trim();
637cdf0e10cSrcweir else
638cdf0e10cSrcweir return false;
639cdf0e10cSrcweir
640cdf0e10cSrcweir
641cdf0e10cSrcweir bool ret = true;
642cdf0e10cSrcweir sal_Int32 delimIdx,equalIdx;
643cdf0e10cSrcweir rtl::OUString parameter,value;
644cdf0e10cSrcweir
645cdf0e10cSrcweir while( query_.getLength() != 0 )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir delimIdx = query_.indexOf( sal_Unicode( '&' ) );
648cdf0e10cSrcweir equalIdx = query_.indexOf( sal_Unicode( '=' ) );
649cdf0e10cSrcweir parameter = query_.copy( 0,equalIdx ).trim();
650cdf0e10cSrcweir if( delimIdx == -1 )
651cdf0e10cSrcweir {
652cdf0e10cSrcweir value = query_.copy( equalIdx + 1 ).trim();
653cdf0e10cSrcweir query_ = rtl::OUString();
654cdf0e10cSrcweir }
655cdf0e10cSrcweir else
656cdf0e10cSrcweir {
657cdf0e10cSrcweir value = query_.copy( equalIdx+1,delimIdx - equalIdx - 1 ).trim();
658cdf0e10cSrcweir query_ = query_.copy( delimIdx+1 ).trim();
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir if( parameter.compareToAscii( "Language" ) == 0 )
662cdf0e10cSrcweir m_aLanguage = value;
663cdf0e10cSrcweir else if( parameter.compareToAscii( "Device" ) == 0 )
664cdf0e10cSrcweir m_aDevice = value;
665cdf0e10cSrcweir else if( parameter.compareToAscii( "Program" ) == 0 )
666cdf0e10cSrcweir m_aProgram = value;
667cdf0e10cSrcweir else if( parameter.compareToAscii( "Eid" ) == 0 )
668cdf0e10cSrcweir m_aEid = value;
669cdf0e10cSrcweir else if( parameter.compareToAscii( "UseDB" ) == 0 )
670cdf0e10cSrcweir m_bUseDB = ! ( value.compareToAscii("no") == 0 );
671cdf0e10cSrcweir else if( parameter.compareToAscii( "DbPAR" ) == 0 )
672cdf0e10cSrcweir m_aDbPar = value;
673cdf0e10cSrcweir else if( parameter.compareToAscii( "Query" ) == 0 )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir if( ! m_aQuery.getLength() )
676cdf0e10cSrcweir m_aQuery = value;
677cdf0e10cSrcweir else
678cdf0e10cSrcweir m_aQuery += ( rtl::OUString::createFromAscii( " " ) + value );
679cdf0e10cSrcweir }
680cdf0e10cSrcweir else if( parameter.compareToAscii( "Scope" ) == 0 )
681cdf0e10cSrcweir m_aScope = value;
682cdf0e10cSrcweir else if( parameter.compareToAscii( "System" ) == 0 )
683cdf0e10cSrcweir m_aSystem = value;
684cdf0e10cSrcweir else if( parameter.compareToAscii( "HelpPrefix" ) == 0 )
685cdf0e10cSrcweir m_aPrefix = rtl::Uri::decode(
686cdf0e10cSrcweir value,
687cdf0e10cSrcweir rtl_UriDecodeWithCharset,
688cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 );
689cdf0e10cSrcweir else if( parameter.compareToAscii( "HitCount" ) == 0 )
690cdf0e10cSrcweir m_nHitCount = value.toInt32();
691cdf0e10cSrcweir else if( parameter.compareToAscii( "Active" ) == 0 )
692cdf0e10cSrcweir m_aActive = value;
693cdf0e10cSrcweir else
694cdf0e10cSrcweir ret = false;
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
697cdf0e10cSrcweir return ret;
698cdf0e10cSrcweir }
699cdf0e10cSrcweir
700cdf0e10cSrcweir struct UserData {
701cdf0e10cSrcweir
UserDataUserData702cdf0e10cSrcweir UserData( InputStreamTransformer* pTransformer,
703cdf0e10cSrcweir URLParameter* pInitial,
704cdf0e10cSrcweir Databases* pDatabases )
705cdf0e10cSrcweir : m_pTransformer( pTransformer ),
706cdf0e10cSrcweir m_pDatabases( pDatabases ),
707cdf0e10cSrcweir m_pInitial( pInitial )
708cdf0e10cSrcweir {
709cdf0e10cSrcweir }
710cdf0e10cSrcweir
711cdf0e10cSrcweir InputStreamTransformer* m_pTransformer;
712cdf0e10cSrcweir Databases* m_pDatabases;
713cdf0e10cSrcweir URLParameter* m_pInitial;
714cdf0e10cSrcweir };
715cdf0e10cSrcweir
716cdf0e10cSrcweir UserData *ugblData = 0;
717cdf0e10cSrcweir
718cdf0e10cSrcweir extern "C" {
719cdf0e10cSrcweir
720cdf0e10cSrcweir static int
fileMatch(const char * URI)721cdf0e10cSrcweir fileMatch(const char * URI) {
722cdf0e10cSrcweir if ((URI != NULL) && !strncmp(URI, "file:/", 6))
723cdf0e10cSrcweir return 1;
724cdf0e10cSrcweir return 0;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir
727cdf0e10cSrcweir static int
zipMatch(const char * URI)728cdf0e10cSrcweir zipMatch(const char * URI) {
729cdf0e10cSrcweir if ((URI != NULL) && !strncmp(URI, "vnd.sun.star.zip:/", 18))
730cdf0e10cSrcweir return 1;
731cdf0e10cSrcweir return 0;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir
734cdf0e10cSrcweir static int
helpMatch(const char * URI)735cdf0e10cSrcweir helpMatch(const char * URI) {
736cdf0e10cSrcweir if ((URI != NULL) && !strncmp(URI, "vnd.sun.star.help:/", 19))
737cdf0e10cSrcweir return 1;
738cdf0e10cSrcweir return 0;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir
741cdf0e10cSrcweir static void *
fileOpen(const char * URI)742cdf0e10cSrcweir fileOpen(const char *URI) {
743cdf0e10cSrcweir osl::File *pRet = new osl::File(rtl::OUString(URI, strlen(URI), RTL_TEXTENCODING_UTF8));
744cdf0e10cSrcweir pRet->open(OpenFlag_Read);
745cdf0e10cSrcweir return pRet;
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir static void *
zipOpen(const char *)749cdf0e10cSrcweir zipOpen(const char * /*URI*/) {
750cdf0e10cSrcweir rtl::OUString language,jar,path;
751cdf0e10cSrcweir
752cdf0e10cSrcweir if( ugblData->m_pInitial->get_eid().getLength() )
753cdf0e10cSrcweir return (void*)(new Reference< XHierarchicalNameAccess >);
754cdf0e10cSrcweir else
755cdf0e10cSrcweir {
756cdf0e10cSrcweir jar = ugblData->m_pInitial->get_jar();
757cdf0e10cSrcweir language = ugblData->m_pInitial->get_language();
758cdf0e10cSrcweir path = ugblData->m_pInitial->get_path();
759cdf0e10cSrcweir }
760cdf0e10cSrcweir
761cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA =
762cdf0e10cSrcweir ugblData->m_pDatabases->findJarFileForPath( jar, language, path );
763cdf0e10cSrcweir
764cdf0e10cSrcweir Reference< XInputStream > xInputStream;
765cdf0e10cSrcweir
766cdf0e10cSrcweir if( xNA.is() )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir try
769cdf0e10cSrcweir {
770cdf0e10cSrcweir Any aEntry = xNA->getByHierarchicalName( path );
771cdf0e10cSrcweir Reference< XActiveDataSink > xSink;
772cdf0e10cSrcweir if( ( aEntry >>= xSink ) && xSink.is() )
773cdf0e10cSrcweir xInputStream = xSink->getInputStream();
774cdf0e10cSrcweir }
775cdf0e10cSrcweir catch ( NoSuchElementException & )
776cdf0e10cSrcweir {
777cdf0e10cSrcweir }
778cdf0e10cSrcweir }
779cdf0e10cSrcweir
780cdf0e10cSrcweir if( xInputStream.is() )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir return new Reference<XInputStream>(xInputStream);
783cdf0e10cSrcweir }
784cdf0e10cSrcweir return 0;
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
787cdf0e10cSrcweir static void *
helpOpen(const char * URI)788cdf0e10cSrcweir helpOpen(const char * URI) {
789cdf0e10cSrcweir rtl::OUString language,jar,path;
790cdf0e10cSrcweir
791cdf0e10cSrcweir URLParameter urlpar( rtl::OUString::createFromAscii( URI ),
792cdf0e10cSrcweir ugblData->m_pDatabases );
793cdf0e10cSrcweir
794cdf0e10cSrcweir jar = urlpar.get_jar();
795cdf0e10cSrcweir language = urlpar.get_language();
796cdf0e10cSrcweir path = urlpar.get_path();
797cdf0e10cSrcweir
798cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA =
799cdf0e10cSrcweir ugblData->m_pDatabases->findJarFileForPath( jar, language, path );
800cdf0e10cSrcweir
801cdf0e10cSrcweir Reference< XInputStream > xInputStream;
802cdf0e10cSrcweir
803cdf0e10cSrcweir if( xNA.is() )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir try
806cdf0e10cSrcweir {
807cdf0e10cSrcweir Any aEntry = xNA->getByHierarchicalName( path );
808cdf0e10cSrcweir Reference< XActiveDataSink > xSink;
809cdf0e10cSrcweir if( ( aEntry >>= xSink ) && xSink.is() )
810cdf0e10cSrcweir xInputStream = xSink->getInputStream();
811cdf0e10cSrcweir }
812cdf0e10cSrcweir catch ( NoSuchElementException & )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir }
815cdf0e10cSrcweir }
816cdf0e10cSrcweir
817cdf0e10cSrcweir if( xInputStream.is() )
818cdf0e10cSrcweir return new Reference<XInputStream>(xInputStream);
819cdf0e10cSrcweir return 0;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir static int
helpRead(void * context,char * buffer,int len)823cdf0e10cSrcweir helpRead(void * context, char * buffer, int len) {
824cdf0e10cSrcweir Reference< XInputStream > *pRef = (Reference< XInputStream >*)context;
825cdf0e10cSrcweir
826cdf0e10cSrcweir Sequence< sal_Int8 > aSeq;
827cdf0e10cSrcweir len = (*pRef)->readBytes( aSeq,len);
828cdf0e10cSrcweir memcpy(buffer, aSeq.getConstArray(), len);
829cdf0e10cSrcweir
830cdf0e10cSrcweir return len;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir
833cdf0e10cSrcweir static int
zipRead(void * context,char * buffer,int len)834cdf0e10cSrcweir zipRead(void * context, char * buffer, int len) {
835cdf0e10cSrcweir if( ugblData->m_pInitial->get_eid().getLength() )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir ugblData->m_pDatabases->popupDocument( ugblData->m_pInitial,&buffer,&len);
838cdf0e10cSrcweir return len;
839cdf0e10cSrcweir }
840cdf0e10cSrcweir else
841cdf0e10cSrcweir return helpRead(context, buffer, len);
842cdf0e10cSrcweir }
843cdf0e10cSrcweir
844cdf0e10cSrcweir static int
fileRead(void * context,char * buffer,int len)845cdf0e10cSrcweir fileRead(void * context, char * buffer, int len) {
846cdf0e10cSrcweir int nRead = 0;
847cdf0e10cSrcweir osl::File *pFile = (osl::File*)context;
848cdf0e10cSrcweir if (pFile)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir sal_uInt64 uRead = 0;
851cdf0e10cSrcweir if (osl::FileBase::E_None == pFile->read(buffer, len, uRead))
852cdf0e10cSrcweir nRead = static_cast<int>(uRead);
853cdf0e10cSrcweir }
854cdf0e10cSrcweir return nRead;
855cdf0e10cSrcweir }
856cdf0e10cSrcweir
857cdf0e10cSrcweir static int
uriClose(void * context)858cdf0e10cSrcweir uriClose(void * context) {
859cdf0e10cSrcweir Reference< XInputStream > *pRef = (Reference< XInputStream >*)context;
860cdf0e10cSrcweir delete pRef;
861cdf0e10cSrcweir return 0;
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir static int
fileClose(void * context)865cdf0e10cSrcweir fileClose(void * context) {
866cdf0e10cSrcweir osl::File *pFile = (osl::File*)context;
867cdf0e10cSrcweir if (pFile)
868cdf0e10cSrcweir {
869cdf0e10cSrcweir pFile->close();
870cdf0e10cSrcweir delete pFile;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir return 0;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir
875cdf0e10cSrcweir } // extern "C"
876cdf0e10cSrcweir
877cdf0e10cSrcweir /*
878cdf0e10cSrcweir // For debugging only
879cdf0e10cSrcweir extern "C" void StructuredXMLErrorFunction(void *userData, xmlErrorPtr error)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir (void)userData;
882cdf0e10cSrcweir (void)error;
883cdf0e10cSrcweir
884cdf0e10cSrcweir // Reset error handler
885cdf0e10cSrcweir xmlSetStructuredErrorFunc( NULL, NULL );
886cdf0e10cSrcweir }
887cdf0e10cSrcweir */
888cdf0e10cSrcweir
InputStreamTransformer(URLParameter * urlParam,Databases * pDatabases,bool isRoot)889cdf0e10cSrcweir InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
890cdf0e10cSrcweir Databases* pDatabases,
891cdf0e10cSrcweir bool isRoot )
892cdf0e10cSrcweir : len( 0 ),
893cdf0e10cSrcweir pos( 0 ),
894cdf0e10cSrcweir buffer( new char[1] ) // Initializing with one element to avoid gcc compiler warning
895cdf0e10cSrcweir {
896cdf0e10cSrcweir if( isRoot )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir delete[] buffer;
899cdf0e10cSrcweir pDatabases->cascadingStylesheet( urlParam->get_language(),
900cdf0e10cSrcweir &buffer,
901cdf0e10cSrcweir &len );
902cdf0e10cSrcweir }
903cdf0e10cSrcweir else if( urlParam->isActive() )
904cdf0e10cSrcweir {
905cdf0e10cSrcweir delete[] buffer;
906cdf0e10cSrcweir pDatabases->setActiveText( urlParam->get_module(),
907cdf0e10cSrcweir urlParam->get_language(),
908cdf0e10cSrcweir urlParam->get_id(),
909cdf0e10cSrcweir &buffer,
910cdf0e10cSrcweir &len );
911cdf0e10cSrcweir }
912cdf0e10cSrcweir else
913cdf0e10cSrcweir {
914cdf0e10cSrcweir UserData userData( this,urlParam,pDatabases );
915cdf0e10cSrcweir
916cdf0e10cSrcweir // Uses the implementation detail, that rtl::OString::getStr returns a zero terminated character-array
917cdf0e10cSrcweir
918cdf0e10cSrcweir const char* parameter[47];
919cdf0e10cSrcweir rtl::OString parString[46];
920cdf0e10cSrcweir int last = 0;
921cdf0e10cSrcweir
922cdf0e10cSrcweir parString[last++] = "Program";
923cdf0e10cSrcweir rtl::OString aPureProgramm( urlParam->getByName( "Program" ) );
924cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + aPureProgramm + rtl::OString('\'');
925cdf0e10cSrcweir parString[last++] = "Database";
926cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + urlParam->getByName( "DatabasePar" ) + rtl::OString('\'');
927cdf0e10cSrcweir parString[last++] = "Id";
928cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + urlParam->getByName( "Id" ) + rtl::OString('\'');
929cdf0e10cSrcweir parString[last++] = "Path";
930cdf0e10cSrcweir rtl::OString aPath( urlParam->getByName( "Path" ) );
931cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + aPath + rtl::OString('\'');
932cdf0e10cSrcweir
933cdf0e10cSrcweir rtl::OString aPureLanguage = urlParam->getByName( "Language" );
934cdf0e10cSrcweir parString[last++] = "Language";
935cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + aPureLanguage + rtl::OString('\'');
936cdf0e10cSrcweir parString[last++] = "System";
937cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + urlParam->getByName( "System" ) + rtl::OString('\'');
938cdf0e10cSrcweir parString[last++] = "productname";
939cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + rtl::OString(
940cdf0e10cSrcweir pDatabases->getProductName().getStr(),
941cdf0e10cSrcweir pDatabases->getProductName().getLength(),
942cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ) + rtl::OString('\'');
943cdf0e10cSrcweir parString[last++] = "productversion";
944cdf0e10cSrcweir parString[last++] = rtl::OString('\'') +
945cdf0e10cSrcweir rtl::OString( pDatabases->getProductVersion().getStr(),
946cdf0e10cSrcweir pDatabases->getProductVersion().getLength(),
947cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ) + rtl::OString('\'');
948cdf0e10cSrcweir
949cdf0e10cSrcweir parString[last++] = "imgrepos";
950cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + pDatabases->getImagesZipFileURL() + rtl::OString('\'');
951cdf0e10cSrcweir parString[last++] = "hp";
952cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + urlParam->getByName( "HelpPrefix" ) + rtl::OString('\'');
953cdf0e10cSrcweir
954cdf0e10cSrcweir if( parString[last-1].getLength() )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir parString[last++] = "sm";
957cdf0e10cSrcweir parString[last++] = "'vnd.sun.star.help%3A%2F%2F'";
958cdf0e10cSrcweir parString[last++] = "qm";
959cdf0e10cSrcweir parString[last++] = "'%3F'";
960cdf0e10cSrcweir parString[last++] = "es";
961cdf0e10cSrcweir parString[last++] = "'%3D'";
962cdf0e10cSrcweir parString[last++] = "am";
963cdf0e10cSrcweir parString[last++] = "'%26'";
964cdf0e10cSrcweir parString[last++] = "cl";
965cdf0e10cSrcweir parString[last++] = "'%3A'";
966cdf0e10cSrcweir parString[last++] = "sl";
967cdf0e10cSrcweir parString[last++] = "'%2F'";
968cdf0e10cSrcweir parString[last++] = "hm";
969cdf0e10cSrcweir parString[last++] = "'%23'";
970cdf0e10cSrcweir parString[last++] = "cs";
971cdf0e10cSrcweir parString[last++] = "'css'";
972cdf0e10cSrcweir
973cdf0e10cSrcweir parString[last++] = "vendorname";
974cdf0e10cSrcweir parString[last++] = rtl::OString("''");
975cdf0e10cSrcweir parString[last++] = "vendorversion";
976cdf0e10cSrcweir parString[last++] = rtl::OString("''");
977cdf0e10cSrcweir parString[last++] = "vendorshort";
978cdf0e10cSrcweir parString[last++] = rtl::OString("''");
979cdf0e10cSrcweir }
980cdf0e10cSrcweir
981cdf0e10cSrcweir // Do we need to add extension path?
982cdf0e10cSrcweir ::rtl::OUString aExtensionPath;
983cdf0e10cSrcweir rtl::OUString aJar = urlParam->get_jar();
984cdf0e10cSrcweir
985cdf0e10cSrcweir bool bAddExtensionPath = false;
986cdf0e10cSrcweir rtl::OUString aExtensionRegistryPath;
987cdf0e10cSrcweir sal_Int32 nQuestionMark1 = aJar.indexOf( sal_Unicode('?') );
988cdf0e10cSrcweir sal_Int32 nQuestionMark2 = aJar.lastIndexOf( sal_Unicode('?') );
989cdf0e10cSrcweir if( nQuestionMark1 != -1 && nQuestionMark2 != -1 && nQuestionMark1 != nQuestionMark2 )
990cdf0e10cSrcweir {
991cdf0e10cSrcweir aExtensionPath = aJar.copy( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 );
992cdf0e10cSrcweir aExtensionRegistryPath = urlParam->get_ExtensionRegistryPath();
993cdf0e10cSrcweir bAddExtensionPath = true;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir else
996cdf0e10cSrcweir {
997cdf0e10cSrcweir // Path not yet specified, search directly
998cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xNA = pDatabases->findJarFileForPath
999cdf0e10cSrcweir ( aJar, urlParam->get_language(), urlParam->get_path(), &aExtensionPath, &aExtensionRegistryPath );
1000cdf0e10cSrcweir if( xNA.is() && aExtensionPath.getLength() )
1001cdf0e10cSrcweir bAddExtensionPath = true;
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir if( bAddExtensionPath )
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
1007cdf0e10cSrcweir Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
1008cdf0e10cSrcweir OSL_ASSERT( xProps.is() );
1009cdf0e10cSrcweir Reference< XComponentContext > xContext;
1010cdf0e10cSrcweir if (xProps.is())
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir xProps->getPropertyValue(
1013cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir if( !xContext.is() )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir throw RuntimeException(
1018cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "InputStreamTransformer::InputStreamTransformer(), no XComponentContext" ),
1019cdf0e10cSrcweir Reference< XInterface >() );
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionRegistryPath, xContext );
1023cdf0e10cSrcweir rtl::OString aExpandedExtensionPath = rtl::OUStringToOString( aOUExpandedExtensionPath, osl_getThreadTextEncoding() );
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir parString[last++] = "ExtensionPath";
1026cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + aExpandedExtensionPath + rtl::OString('\'');
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir // ExtensionId
1029cdf0e10cSrcweir rtl::OString aPureExtensionId;
1030cdf0e10cSrcweir sal_Int32 iSlash = aPath.indexOf( '/' );
1031cdf0e10cSrcweir if( iSlash != -1 )
1032cdf0e10cSrcweir aPureExtensionId = aPath.copy( 0, iSlash );
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir parString[last++] = "ExtensionId";
1035cdf0e10cSrcweir parString[last++] = rtl::OString('\'') + aPureExtensionId + rtl::OString('\'');
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir for( int i = 0; i < last; ++i )
1039cdf0e10cSrcweir parameter[i] = parString[i].getStr();
1040cdf0e10cSrcweir parameter[last] = 0;
1041cdf0e10cSrcweir
1042cdf0e10cSrcweir rtl::OUString xslURL = pDatabases->getInstallPathAsURL();
1043cdf0e10cSrcweir
1044cdf0e10cSrcweir rtl::OString xslURLascii(
1045cdf0e10cSrcweir xslURL.getStr(),
1046cdf0e10cSrcweir xslURL.getLength(),
1047cdf0e10cSrcweir RTL_TEXTENCODING_UTF8);
1048cdf0e10cSrcweir xslURLascii += "main_transform.xsl";
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir ugblData = &userData;
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir xmlInitParser();
1053cdf0e10cSrcweir xmlRegisterInputCallbacks(zipMatch, zipOpen, zipRead, uriClose);
1054cdf0e10cSrcweir xmlRegisterInputCallbacks(helpMatch, helpOpen, helpRead, uriClose);
1055cdf0e10cSrcweir xmlRegisterInputCallbacks(fileMatch, fileOpen, fileRead, fileClose);
1056cdf0e10cSrcweir //xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction );
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir xsltStylesheetPtr cur =
1059cdf0e10cSrcweir xsltParseStylesheetFile((const xmlChar *)xslURLascii.getStr());
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir xmlDocPtr doc = xmlParseFile("vnd.sun.star.zip:/");
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir xmlDocPtr res = xsltApplyStylesheet(cur, doc, parameter);
1064cdf0e10cSrcweir if (res)
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir xmlChar *doc_txt_ptr=0;
1067cdf0e10cSrcweir int doc_txt_len;
1068cdf0e10cSrcweir xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, res, cur);
1069cdf0e10cSrcweir addToBuffer((const char*)doc_txt_ptr, doc_txt_len);
1070cdf0e10cSrcweir xmlFree(doc_txt_ptr);
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir xmlPopInputCallbacks(); //filePatch
1073cdf0e10cSrcweir xmlPopInputCallbacks(); //helpPatch
1074cdf0e10cSrcweir xmlPopInputCallbacks(); //zipMatch
1075cdf0e10cSrcweir xmlFreeDoc(res);
1076cdf0e10cSrcweir xmlFreeDoc(doc);
1077cdf0e10cSrcweir xsltFreeStylesheet(cur);
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir
~InputStreamTransformer()1082cdf0e10cSrcweir InputStreamTransformer::~InputStreamTransformer()
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir delete[] buffer;
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir
queryInterface(const Type & rType)1088cdf0e10cSrcweir Any SAL_CALL InputStreamTransformer::queryInterface( const Type& rType ) throw( RuntimeException )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir Any aRet = ::cppu::queryInterface( rType,
1091cdf0e10cSrcweir SAL_STATIC_CAST( XInputStream*,this ),
1092cdf0e10cSrcweir SAL_STATIC_CAST( XSeekable*,this ) );
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir
1098cdf0e10cSrcweir
acquire(void)1099cdf0e10cSrcweir void SAL_CALL InputStreamTransformer::acquire( void ) throw()
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir OWeakObject::acquire();
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir
release(void)1106cdf0e10cSrcweir void SAL_CALL InputStreamTransformer::release( void ) throw()
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir OWeakObject::release();
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir
readBytes(Sequence<sal_Int8> & aData,sal_Int32 nBytesToRead)1113cdf0e10cSrcweir sal_Int32 SAL_CALL InputStreamTransformer::readBytes( Sequence< sal_Int8 >& aData,sal_Int32 nBytesToRead )
1114cdf0e10cSrcweir throw( NotConnectedException,
1115cdf0e10cSrcweir BufferSizeExceededException,
1116cdf0e10cSrcweir IOException,
1117cdf0e10cSrcweir RuntimeException)
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir int curr,available_ = len-pos;
1122cdf0e10cSrcweir if( nBytesToRead <= available_ )
1123cdf0e10cSrcweir curr = nBytesToRead;
1124cdf0e10cSrcweir else
1125cdf0e10cSrcweir curr = available_;
1126cdf0e10cSrcweir
1127cdf0e10cSrcweir if( 0 <= curr && aData.getLength() < curr )
1128cdf0e10cSrcweir aData.realloc( curr );
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir for( int k = 0; k < curr; ++k )
1131cdf0e10cSrcweir aData[k] = buffer[pos++];
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir return curr > 0 ? curr : 0;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir
readSomeBytes(Sequence<sal_Int8> & aData,sal_Int32 nMaxBytesToRead)1137cdf0e10cSrcweir sal_Int32 SAL_CALL InputStreamTransformer::readSomeBytes( Sequence< sal_Int8 >& aData,sal_Int32 nMaxBytesToRead )
1138cdf0e10cSrcweir throw( NotConnectedException,
1139cdf0e10cSrcweir BufferSizeExceededException,
1140cdf0e10cSrcweir IOException,
1141cdf0e10cSrcweir RuntimeException)
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir return readBytes( aData,nMaxBytesToRead );
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir
1146cdf0e10cSrcweir
1147cdf0e10cSrcweir
skipBytes(sal_Int32 nBytesToSkip)1148cdf0e10cSrcweir void SAL_CALL InputStreamTransformer::skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException,
1149cdf0e10cSrcweir BufferSizeExceededException,
1150cdf0e10cSrcweir IOException,
1151cdf0e10cSrcweir RuntimeException )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1154cdf0e10cSrcweir while( nBytesToSkip-- ) ++pos;
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir
available(void)1159cdf0e10cSrcweir sal_Int32 SAL_CALL InputStreamTransformer::available( void ) throw( NotConnectedException,
1160cdf0e10cSrcweir IOException,
1161cdf0e10cSrcweir RuntimeException )
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1164cdf0e10cSrcweir return len-pos > 0 ? len - pos : 0 ;
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir
closeInput(void)1169cdf0e10cSrcweir void SAL_CALL InputStreamTransformer::closeInput( void ) throw( NotConnectedException,
1170cdf0e10cSrcweir IOException,
1171cdf0e10cSrcweir RuntimeException )
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir
seek(sal_Int64 location)1177cdf0e10cSrcweir void SAL_CALL InputStreamTransformer::seek( sal_Int64 location ) throw( IllegalArgumentException,
1178cdf0e10cSrcweir IOException,
1179cdf0e10cSrcweir RuntimeException )
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1182cdf0e10cSrcweir if( location < 0 )
1183cdf0e10cSrcweir throw IllegalArgumentException();
1184cdf0e10cSrcweir else
1185cdf0e10cSrcweir pos = sal::static_int_cast<sal_Int32>( location );
1186cdf0e10cSrcweir
1187cdf0e10cSrcweir if( pos > len )
1188cdf0e10cSrcweir pos = len;
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir
getPosition(void)1193cdf0e10cSrcweir sal_Int64 SAL_CALL InputStreamTransformer::getPosition( void ) throw( IOException,
1194cdf0e10cSrcweir RuntimeException )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1197cdf0e10cSrcweir return sal_Int64( pos );
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir
1201cdf0e10cSrcweir
getLength(void)1202cdf0e10cSrcweir sal_Int64 SAL_CALL InputStreamTransformer::getLength( void ) throw( IOException,RuntimeException )
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir return len;
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir
addToBuffer(const char * buffer_,int len_)1210cdf0e10cSrcweir void InputStreamTransformer::addToBuffer( const char* buffer_,int len_ )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex );
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir char* tmp = buffer;
1215cdf0e10cSrcweir buffer = new char[ len+len_ ];
1216cdf0e10cSrcweir rtl_copyMemory( (void*)(buffer),(void*)(tmp),sal_uInt32( len ) );
1217cdf0e10cSrcweir rtl_copyMemory( (void*)(buffer+len),(void*)(buffer_),sal_uInt32( len_ ) );
1218cdf0e10cSrcweir delete[] tmp;
1219cdf0e10cSrcweir len += len_;
1220cdf0e10cSrcweir }
1221