Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
b5475c7a
Kaydet (Commit)
b5475c7a
authored
Eki 08, 2015
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sot: prefix members of StgCache
Change-Id: If406303ec1685c9d7eebefaf172db0bbf0cd723b
üst
0147e744
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
91 deletions
+91
-91
stgcache.cxx
sot/source/sdstor/stgcache.cxx
+70
-70
stgcache.hxx
sot/source/sdstor/stgcache.hxx
+17
-17
stgio.cxx
sot/source/sdstor/stgio.cxx
+4
-4
No files found.
sot/source/sdstor/stgcache.cxx
Dosyayı görüntüle @
b5475c7a
...
@@ -87,16 +87,16 @@ static sal_Int32 lcl_GetPageCount( sal_uLong nFileSize, short nPageSize )
...
@@ -87,16 +87,16 @@ static sal_Int32 lcl_GetPageCount( sal_uLong nFileSize, short nPageSize )
}
}
StgCache
::
StgCache
()
StgCache
::
StgCache
()
:
nError
(
SVSTREAM_OK
)
:
m_
nError
(
SVSTREAM_OK
)
,
nPages
(
0
)
,
m_
nPages
(
0
)
,
nRef
(
0
)
,
m_
nRef
(
0
)
,
nReplaceIdx
(
0
)
,
m_
nReplaceIdx
(
0
)
,
maLRUPages
(
8
)
// entries in the LRU lookup
,
maLRUPages
(
8
)
// entries in the LRU lookup
,
nPageSize
(
512
)
,
m_
nPageSize
(
512
)
,
pStorageStream
(
NULL
)
,
m_
pStorageStream
(
NULL
)
,
pStrm
(
NULL
)
,
m_
pStrm
(
NULL
)
,
bMyStream
(
false
)
,
m_
bMyStream
(
false
)
,
bFile
(
false
)
,
m_
bFile
(
false
)
{
{
}
}
...
@@ -111,11 +111,11 @@ void StgCache::SetPhysPageSize( short n )
...
@@ -111,11 +111,11 @@ void StgCache::SetPhysPageSize( short n )
OSL_ENSURE
(
n
>=
512
,
"Unexpecte page size is provided!"
);
OSL_ENSURE
(
n
>=
512
,
"Unexpecte page size is provided!"
);
if
(
n
>=
512
)
if
(
n
>=
512
)
{
{
nPageSize
=
n
;
m_
nPageSize
=
n
;
sal_uLong
nPos
=
pStrm
->
Tell
();
sal_uLong
nPos
=
m_
pStrm
->
Tell
();
sal_uLong
nFileSize
=
pStrm
->
Seek
(
STREAM_SEEK_TO_END
);
sal_uLong
nFileSize
=
m_
pStrm
->
Seek
(
STREAM_SEEK_TO_END
);
nPages
=
lcl_GetPageCount
(
nFileSize
,
nPageSize
);
m_nPages
=
lcl_GetPageCount
(
nFileSize
,
m_
nPageSize
);
pStrm
->
Seek
(
nPos
);
m_
pStrm
->
Seek
(
nPos
);
}
}
}
}
...
@@ -123,8 +123,8 @@ void StgCache::SetPhysPageSize( short n )
...
@@ -123,8 +123,8 @@ void StgCache::SetPhysPageSize( short n )
rtl
::
Reference
<
StgPage
>
StgCache
::
Create
(
sal_Int32
nPg
)
rtl
::
Reference
<
StgPage
>
StgCache
::
Create
(
sal_Int32
nPg
)
{
{
rtl
::
Reference
<
StgPage
>
xElem
(
StgPage
::
Create
(
nPageSize
,
nPg
)
);
rtl
::
Reference
<
StgPage
>
xElem
(
StgPage
::
Create
(
m_
nPageSize
,
nPg
)
);
maLRUPages
[
nReplaceIdx
++
%
maLRUPages
.
size
()
]
=
xElem
;
maLRUPages
[
m_
nReplaceIdx
++
%
maLRUPages
.
size
()
]
=
xElem
;
return
xElem
;
return
xElem
;
}
}
...
@@ -230,8 +230,8 @@ bool StgCache::Commit()
...
@@ -230,8 +230,8 @@ bool StgCache::Commit()
maDirtyPages
.
clear
();
maDirtyPages
.
clear
();
pStrm
->
Flush
();
m_
pStrm
->
Flush
();
SetError
(
pStrm
->
GetError
()
);
SetError
(
m_
pStrm
->
GetError
()
);
return
true
;
return
true
;
}
}
...
@@ -240,36 +240,36 @@ bool StgCache::Commit()
...
@@ -240,36 +240,36 @@ bool StgCache::Commit()
void
StgCache
::
SetStrm
(
SvStream
*
p
,
bool
bMy
)
void
StgCache
::
SetStrm
(
SvStream
*
p
,
bool
bMy
)
{
{
if
(
pStorageStream
)
if
(
m_
pStorageStream
)
{
{
pStorageStream
->
ReleaseRef
();
m_
pStorageStream
->
ReleaseRef
();
pStorageStream
=
NULL
;
m_
pStorageStream
=
NULL
;
}
}
if
(
bMyStream
)
if
(
m_
bMyStream
)
delete
pStrm
;
delete
m_
pStrm
;
pStrm
=
p
;
m_
pStrm
=
p
;
bMyStream
=
bMy
;
m_
bMyStream
=
bMy
;
}
}
void
StgCache
::
SetStrm
(
UCBStorageStream
*
pStgStream
)
void
StgCache
::
SetStrm
(
UCBStorageStream
*
pStgStream
)
{
{
if
(
pStorageStream
)
if
(
m_
pStorageStream
)
pStorageStream
->
ReleaseRef
();
m_
pStorageStream
->
ReleaseRef
();
pStorageStream
=
pStgStream
;
m_
pStorageStream
=
pStgStream
;
if
(
bMyStream
)
if
(
m_
bMyStream
)
delete
pStrm
;
delete
m_
pStrm
;
pStrm
=
NULL
;
m_
pStrm
=
NULL
;
if
(
pStorageStream
)
if
(
m_
pStorageStream
)
{
{
pStorageStream
->
AddFirstRef
();
m_
pStorageStream
->
AddFirstRef
();
pStrm
=
pStorageStream
->
GetModifySvStream
();
m_pStrm
=
m_
pStorageStream
->
GetModifySvStream
();
}
}
bMyStream
=
false
;
m_
bMyStream
=
false
;
}
}
void
StgCache
::
SetDirty
(
const
rtl
::
Reference
<
StgPage
>
&
rPage
)
void
StgCache
::
SetDirty
(
const
rtl
::
Reference
<
StgPage
>
&
rPage
)
...
@@ -296,23 +296,23 @@ bool StgCache::Open( const OUString& rName, StreamMode nMode )
...
@@ -296,23 +296,23 @@ bool StgCache::Open( const OUString& rName, StreamMode nMode )
SetStrm
(
pFileStrm
,
true
);
SetStrm
(
pFileStrm
,
true
);
if
(
pFileStrm
->
IsOpen
()
)
if
(
pFileStrm
->
IsOpen
()
)
{
{
sal_uLong
nFileSize
=
pStrm
->
Seek
(
STREAM_SEEK_TO_END
);
sal_uLong
nFileSize
=
m_
pStrm
->
Seek
(
STREAM_SEEK_TO_END
);
nPages
=
lcl_GetPageCount
(
nFileSize
,
nPageSize
);
m_nPages
=
lcl_GetPageCount
(
nFileSize
,
m_
nPageSize
);
pStrm
->
Seek
(
0L
);
m_
pStrm
->
Seek
(
0L
);
}
}
else
else
nPages
=
0
;
m_
nPages
=
0
;
bFile
=
true
;
m_
bFile
=
true
;
SetError
(
bAccessDenied
?
ERRCODE_IO_ACCESSDENIED
:
pStrm
->
GetError
()
);
SetError
(
bAccessDenied
?
ERRCODE_IO_ACCESSDENIED
:
m_
pStrm
->
GetError
()
);
return
Good
();
return
Good
();
}
}
void
StgCache
::
Close
()
void
StgCache
::
Close
()
{
{
if
(
bFile
)
if
(
m_
bFile
)
{
{
static_cast
<
SvFileStream
*>
(
pStrm
)
->
Close
();
static_cast
<
SvFileStream
*>
(
m_
pStrm
)
->
Close
();
SetError
(
pStrm
->
GetError
()
);
SetError
(
m_
pStrm
->
GetError
()
);
}
}
}
}
...
@@ -326,28 +326,28 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
...
@@ -326,28 +326,28 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
last valid page (see document attached to the issue). In that case
last valid page (see document attached to the issue). In that case
(if nPage==nPages), just do nothing here and let the caller work on
(if nPage==nPages), just do nothing here and let the caller work on
the empty zero-filled buffer. */
the empty zero-filled buffer. */
if
(
nPage
>
nPages
)
if
(
nPage
>
m_
nPages
)
SetError
(
SVSTREAM_READ_ERROR
);
SetError
(
SVSTREAM_READ_ERROR
);
else
if
(
nPage
<
nPages
)
else
if
(
nPage
<
m_
nPages
)
{
{
sal_uInt32
nPos
=
Page2Pos
(
nPage
);
sal_uInt32
nPos
=
Page2Pos
(
nPage
);
sal_Int32
nPg2
=
(
(
nPage
+
nPg
)
>
nPages
)
?
nPages
-
nPage
:
nPg
;
sal_Int32
nPg2
=
(
(
nPage
+
nPg
)
>
m_nPages
)
?
m_
nPages
-
nPage
:
nPg
;
sal_uInt32
nBytes
=
nPg2
*
nPageSize
;
sal_uInt32
nBytes
=
nPg2
*
m_
nPageSize
;
// fixed address and size for the header
// fixed address and size for the header
if
(
nPage
==
-
1
)
if
(
nPage
==
-
1
)
{
{
nPos
=
0L
,
nBytes
=
512
;
nPos
=
0L
,
nBytes
=
512
;
nPg2
=
nPg
;
nPg2
=
nPg
;
}
}
if
(
pStrm
->
Tell
()
!=
nPos
)
if
(
m_
pStrm
->
Tell
()
!=
nPos
)
{
{
pStrm
->
Seek
(
nPos
);
m_
pStrm
->
Seek
(
nPos
);
}
}
pStrm
->
Read
(
pBuf
,
nBytes
);
m_
pStrm
->
Read
(
pBuf
,
nBytes
);
if
(
nPg
!=
nPg2
)
if
(
nPg
!=
nPg2
)
SetError
(
SVSTREAM_READ_ERROR
);
SetError
(
SVSTREAM_READ_ERROR
);
else
else
SetError
(
pStrm
->
GetError
()
);
SetError
(
m_
pStrm
->
GetError
()
);
}
}
}
}
return
Good
();
return
Good
();
...
@@ -359,22 +359,22 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
...
@@ -359,22 +359,22 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
{
{
sal_uInt32
nPos
=
Page2Pos
(
nPage
);
sal_uInt32
nPos
=
Page2Pos
(
nPage
);
sal_uInt32
nBytes
=
0
;
sal_uInt32
nBytes
=
0
;
if
(
SAL_MAX_INT32
/
nPg
>
nPageSize
)
if
(
SAL_MAX_INT32
/
nPg
>
m_
nPageSize
)
nBytes
=
nPg
*
nPageSize
;
nBytes
=
nPg
*
m_
nPageSize
;
// fixed address and size for the header
// fixed address and size for the header
// nPageSize must be >= 512, otherwise the header can not be written here, we check it on import
// nPageSize must be >= 512, otherwise the header can not be written here, we check it on import
if
(
nPage
==
-
1
)
if
(
nPage
==
-
1
)
nPos
=
0L
,
nBytes
=
512
;
nPos
=
0L
,
nBytes
=
512
;
if
(
pStrm
->
Tell
()
!=
nPos
)
if
(
m_
pStrm
->
Tell
()
!=
nPos
)
{
{
pStrm
->
Seek
(
nPos
);
m_
pStrm
->
Seek
(
nPos
);
}
}
sal_uLong
nRes
=
pStrm
->
Write
(
pBuf
,
nBytes
);
sal_uLong
nRes
=
m_
pStrm
->
Write
(
pBuf
,
nBytes
);
if
(
nRes
!=
nBytes
)
if
(
nRes
!=
nBytes
)
SetError
(
SVSTREAM_WRITE_ERROR
);
SetError
(
SVSTREAM_WRITE_ERROR
);
else
else
SetError
(
pStrm
->
GetError
()
);
SetError
(
m_
pStrm
->
GetError
()
);
}
}
return
Good
();
return
Good
();
}
}
...
@@ -384,31 +384,31 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
...
@@ -384,31 +384,31 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
bool
StgCache
::
SetSize
(
sal_Int32
n
)
bool
StgCache
::
SetSize
(
sal_Int32
n
)
{
{
// Add the file header
// Add the file header
sal_Int32
nSize
=
n
*
nPageSize
+
512
;
sal_Int32
nSize
=
n
*
m_
nPageSize
+
512
;
pStrm
->
SetStreamSize
(
nSize
);
m_
pStrm
->
SetStreamSize
(
nSize
);
SetError
(
pStrm
->
GetError
()
);
SetError
(
m_
pStrm
->
GetError
()
);
if
(
!
nError
)
if
(
!
m_
nError
)
nPages
=
n
;
m_
nPages
=
n
;
return
Good
();
return
Good
();
}
}
void
StgCache
::
SetError
(
sal_uLong
n
)
void
StgCache
::
SetError
(
sal_uLong
n
)
{
{
if
(
n
&&
!
nError
)
if
(
n
&&
!
m_
nError
)
nError
=
n
;
m_
nError
=
n
;
}
}
void
StgCache
::
ResetError
()
void
StgCache
::
ResetError
()
{
{
nError
=
SVSTREAM_OK
;
m_
nError
=
SVSTREAM_OK
;
pStrm
->
ResetError
();
m_
pStrm
->
ResetError
();
}
}
void
StgCache
::
MoveError
(
StorageBase
&
r
)
void
StgCache
::
MoveError
(
StorageBase
&
r
)
{
{
if
(
nError
!=
SVSTREAM_OK
)
if
(
m_
nError
!=
SVSTREAM_OK
)
{
{
r
.
SetError
(
nError
);
r
.
SetError
(
m_
nError
);
ResetError
();
ResetError
();
}
}
}
}
...
@@ -418,7 +418,7 @@ void StgCache::MoveError( StorageBase& r )
...
@@ -418,7 +418,7 @@ void StgCache::MoveError( StorageBase& r )
sal_Int32
StgCache
::
Page2Pos
(
sal_Int32
nPage
)
sal_Int32
StgCache
::
Page2Pos
(
sal_Int32
nPage
)
{
{
if
(
nPage
<
0
)
nPage
=
0
;
if
(
nPage
<
0
)
nPage
=
0
;
return
(
nPage
*
nPageSize
)
+
nPageSize
;
return
(
nPage
*
m_nPageSize
)
+
m_
nPageSize
;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sot/source/sdstor/stgcache.hxx
Dosyayı görüntüle @
b5475c7a
...
@@ -45,36 +45,36 @@ class StgCache
...
@@ -45,36 +45,36 @@ class StgCache
typedef
std
::
vector
<
rtl
::
Reference
<
StgPage
>
>
LRUList
;
typedef
std
::
vector
<
rtl
::
Reference
<
StgPage
>
>
LRUList
;
sal_uLong
nError
;
// error code
sal_uLong
m_
nError
;
// error code
sal_Int32
nPages
;
// size of data area in pages
sal_Int32
m_
nPages
;
// size of data area in pages
sal_uInt16
nRef
;
// reference count
sal_uInt16
m_
nRef
;
// reference count
IndexToStgPage
maDirtyPages
;
// hash of all dirty pages
IndexToStgPage
maDirtyPages
;
// hash of all dirty pages
int
nReplaceIdx
;
// index into maLRUPages to replace next
int
m_
nReplaceIdx
;
// index into maLRUPages to replace next
LRUList
maLRUPages
;
// list of last few non-dirty pages.
LRUList
maLRUPages
;
// list of last few non-dirty pages.
short
nPageSize
;
// page size of the file
short
m_
nPageSize
;
// page size of the file
UCBStorageStream
*
pStorageStream
;
// holds reference to UCB storage stream
UCBStorageStream
*
m_
pStorageStream
;
// holds reference to UCB storage stream
void
Erase
(
const
rtl
::
Reference
<
StgPage
>&
);
// delete a cache element
void
Erase
(
const
rtl
::
Reference
<
StgPage
>&
);
// delete a cache element
rtl
::
Reference
<
StgPage
>
Create
(
sal_Int32
);
// create a cached page
rtl
::
Reference
<
StgPage
>
Create
(
sal_Int32
);
// create a cached page
protected
:
protected
:
SvStream
*
pStrm
;
// physical stream
SvStream
*
m_
pStrm
;
// physical stream
bool
bMyStream
;
// true: delete stream in dtor
bool
m_
bMyStream
;
// true: delete stream in dtor
bool
bFile
;
// true: file stream
bool
m_
bFile
;
// true: file stream
sal_Int32
Page2Pos
(
sal_Int32
);
// page address --> file position
sal_Int32
Page2Pos
(
sal_Int32
);
// page address --> file position
public
:
public
:
StgCache
();
StgCache
();
~
StgCache
();
~
StgCache
();
void
IncRef
()
{
nRef
++
;
}
void
IncRef
()
{
m_
nRef
++
;
}
sal_uInt16
DecRef
()
{
return
--
nRef
;
}
sal_uInt16
DecRef
()
{
return
--
m_
nRef
;
}
void
SetPhysPageSize
(
short
);
void
SetPhysPageSize
(
short
);
sal_Int32
GetPhysPages
()
{
return
nPages
;
}
sal_Int32
GetPhysPages
()
{
return
m_
nPages
;
}
short
GetPhysPageSize
()
{
return
nPageSize
;
}
short
GetPhysPageSize
()
{
return
m_
nPageSize
;
}
SvStream
*
GetStrm
()
{
return
pStrm
;
}
SvStream
*
GetStrm
()
{
return
m_
pStrm
;
}
void
SetStrm
(
SvStream
*
,
bool
);
void
SetStrm
(
SvStream
*
,
bool
);
void
SetStrm
(
UCBStorageStream
*
);
void
SetStrm
(
UCBStorageStream
*
);
bool
IsWritable
()
{
return
(
pStrm
&&
pStrm
->
IsWritable
()
);
}
bool
IsWritable
()
{
return
(
m_pStrm
&&
m_
pStrm
->
IsWritable
()
);
}
bool
Good
()
{
return
nError
==
SVSTREAM_OK
;
}
bool
Good
()
{
return
m_
nError
==
SVSTREAM_OK
;
}
sal_uLong
GetError
()
{
return
nError
;
}
sal_uLong
GetError
()
{
return
m_
nError
;
}
void
MoveError
(
StorageBase
&
);
void
MoveError
(
StorageBase
&
);
void
SetError
(
sal_uLong
);
void
SetError
(
sal_uLong
);
void
ResetError
();
void
ResetError
();
...
...
sot/source/sdstor/stgio.cxx
Dosyayı görüntüle @
b5475c7a
...
@@ -51,7 +51,7 @@ StgIo::~StgIo()
...
@@ -51,7 +51,7 @@ StgIo::~StgIo()
bool
StgIo
::
Load
()
bool
StgIo
::
Load
()
{
{
if
(
pStrm
)
if
(
m_
pStrm
)
{
{
if
(
aHdr
.
Load
(
*
this
)
)
if
(
aHdr
.
Load
(
*
this
)
)
{
{
...
@@ -126,8 +126,8 @@ bool StgIo::CommitAll()
...
@@ -126,8 +126,8 @@ bool StgIo::CommitAll()
aHdr
.
SetTOCStart
(
pTOC
->
GetStart
()
);
aHdr
.
SetTOCStart
(
pTOC
->
GetStart
()
);
if
(
aHdr
.
Store
(
*
this
)
)
if
(
aHdr
.
Store
(
*
this
)
)
{
{
pStrm
->
Flush
();
m_
pStrm
->
Flush
();
sal_uLong
n
=
pStrm
->
GetError
();
sal_uLong
n
=
m_
pStrm
->
GetError
();
SetError
(
n
);
SetError
(
n
);
#ifdef DBG_UTIL
#ifdef DBG_UTIL
if
(
n
==
0
)
ValidateFATs
();
if
(
n
==
0
)
ValidateFATs
();
...
@@ -350,7 +350,7 @@ const Link<StgLinkArg&,void>& StgIo::GetErrorLink()
...
@@ -350,7 +350,7 @@ const Link<StgLinkArg&,void>& StgIo::GetErrorLink()
sal_uLong
StgIo
::
ValidateFATs
()
sal_uLong
StgIo
::
ValidateFATs
()
{
{
if
(
bFile
)
if
(
m_
bFile
)
{
{
Validator
*
pV
=
new
Validator
(
*
this
);
Validator
*
pV
=
new
Validator
(
*
this
);
bool
bRet1
=
!
pV
->
IsError
(),
bRet2
=
true
;
bool
bRet1
=
!
pV
->
IsError
(),
bRet2
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment