xref: /trunk/main/tools/inc/tools/cachestr.hxx (revision 8b851043)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CACHESTR_HXX
25 #define _CACHESTR_HXX
26 
27 #include <tools/stream.hxx>
28 #include <tools/string.hxx>
29 #include <tools/link.hxx>
30 #include "tools/toolsdllapi.h"
31 
32 // -----------------
33 // - SvCacheStream -
34 // -----------------
35 
36 class TempFile;
37 class TOOLS_DLLPUBLIC SvCacheStream : public SvStream
38 {
39 private:
40     String          aFileName;
41     sal_uIntPtr           nMaxSize;
42     int             bPersistent;
43 
44     SvStream*       pSwapStream;
45     SvStream*       pCurrentStream;
46     TempFile*       pTempFile;
47 
48     Link    		aFilenameLinkHdl;
49 
50     TOOLS_DLLPRIVATE virtual sal_uIntPtr   GetData( void* pData, sal_uIntPtr nSize );
51     TOOLS_DLLPRIVATE virtual sal_uIntPtr   PutData( const void* pData, sal_uIntPtr nSize );
52     TOOLS_DLLPRIVATE virtual sal_uIntPtr   SeekPos( sal_uIntPtr nPos );
53     TOOLS_DLLPRIVATE virtual void    FlushData();
54     TOOLS_DLLPRIVATE virtual void    SetSize( sal_uIntPtr nSize );
55 
56 public:
57                     SvCacheStream( sal_uIntPtr nMaxMemSize = 0 );
58                     SvCacheStream( const String &rFileName,
59 					               sal_uIntPtr nExpectedSize = 0,
60                     			   sal_uIntPtr nMaxMemSize = 0 );
61                     ~SvCacheStream();
62 
63 	void			SetFilenameHdl( const Link& rLink);
64 	const Link&     GetFilenameHdl() const;
SetFilename(const String & rFN)65 	void			SetFilename( const String& rFN )
66  	            { aFileName = rFN; } // darf nur vom FilenameHdl gerufen werden!
GetFilename() const67 	const String&   GetFilename() const { return aFileName;	}
68 
69     void            SwapOut();
70     const void*     GetBuffer();
71     sal_uIntPtr           GetSize();
72 
IsPersistent()73 	sal_Bool			IsPersistent() { return bPersistent != 0; }
SetPersistence(sal_Bool b=sal_True)74 	void			SetPersistence( sal_Bool b = sal_True ) { bPersistent = b; }
SetSwapStream(SvStream * p)75 	void			SetSwapStream( SvStream *p )
76  	            { pSwapStream = p; } // darf nur vom FilenameHdl gerufen werden!
77 };
78 
79 #endif
80