summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-02 10:11:59 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-02 10:11:59 -0800
commit959a904f3877d338d784c573487d90de87cb25ac (patch)
tree1f79d3a84e1ff2104ed0d7e08c76aee10986a328
parentfa89a203151c3ea524fc4dfd7167e2a3baf332fa (diff)
downloadpdfium-959a904f3877d338d784c573487d90de87cb25ac.tar.xz
Tidy fx_stream.h
Group related IFX_ classes. Move #defines to .cpp file that uses them. Replace loose function with static method. Review-Url: https://codereview.chromium.org/2548583004
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp9
-rw-r--r--core/fxcrt/fx_extension.cpp2
-rw-r--r--core/fxcrt/fx_stream.h36
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp2
4 files changed, 26 insertions, 23 deletions
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index 308fc49048..b8757ae903 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -30,6 +30,15 @@
#define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
#define PDF_XREFSTREAM_MAXSIZE 10000
+#define FX_GETBYTEOFFSET32(a) 0
+#define FX_GETBYTEOFFSET40(a) 0
+#define FX_GETBYTEOFFSET48(a) 0
+#define FX_GETBYTEOFFSET56(a) 0
+#define FX_GETBYTEOFFSET24(a) ((uint8_t)(a >> 24))
+#define FX_GETBYTEOFFSET16(a) ((uint8_t)(a >> 16))
+#define FX_GETBYTEOFFSET8(a) ((uint8_t)(a >> 8))
+#define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
+
// TODO(ochang): Make helper for appending "objnum 0 R ".
namespace {
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index aa3841e31c..1bb9a3a5f6 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -408,7 +408,7 @@ bool CFX_MemoryStream::ExpandBlocks(size_t size) {
} // namespace
#ifdef PDF_ENABLE_XFA
-IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) {
+IFX_FileAccess* IFX_FileAccess::CreateDefault(const CFX_WideStringC& wsPath) {
if (wsPath.GetLength() == 0)
return nullptr;
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h
index e938ec18df..711b66472b 100644
--- a/core/fxcrt/fx_stream.h
+++ b/core/fxcrt/fx_stream.h
@@ -14,10 +14,11 @@
#include <direct.h>
class CFindFileDataA;
-
typedef CFindFileDataA FX_FileHandle;
#define FX_FILESIZE int32_t
+
#else
+
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -43,14 +44,6 @@ bool FX_GetNextFile(FX_FileHandle* handle,
void FX_CloseFolder(FX_FileHandle* handle);
FX_WCHAR FX_GetFolderSeparator();
-#define FX_GETBYTEOFFSET32(a) 0
-#define FX_GETBYTEOFFSET40(a) 0
-#define FX_GETBYTEOFFSET48(a) 0
-#define FX_GETBYTEOFFSET56(a) 0
-#define FX_GETBYTEOFFSET24(a) ((uint8_t)(a >> 24))
-#define FX_GETBYTEOFFSET16(a) ((uint8_t)(a >> 16))
-#define FX_GETBYTEOFFSET8(a) ((uint8_t)(a >> 8))
-#define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
#define FX_FILEMODE_Write 0
#define FX_FILEMODE_ReadOnly 1
#define FX_FILEMODE_Truncate 2
@@ -123,18 +116,6 @@ class IFX_SeekableStream : public IFX_SeekableReadStream,
bool Flush() override = 0;
};
-#ifdef PDF_ENABLE_XFA
-class IFX_FileAccess {
- public:
- virtual ~IFX_FileAccess() {}
- virtual void Release() = 0;
- virtual IFX_FileAccess* Retain() = 0;
- virtual void GetPath(CFX_WideString& wsPath) = 0;
- virtual IFX_SeekableStream* CreateFileStream(uint32_t dwModes) = 0;
-};
-IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath);
-#endif // PDF_ENABLE_XFA
-
class IFX_MemoryStream : public IFX_SeekableStream {
public:
static IFX_MemoryStream* Create(uint8_t* pBuffer,
@@ -165,6 +146,19 @@ class IFX_BufferedReadStream : public IFX_ReadStream {
virtual FX_FILESIZE GetBlockOffset() = 0;
};
+#ifdef PDF_ENABLE_XFA
+class IFX_FileAccess {
+ public:
+ static IFX_FileAccess* CreateDefault(const CFX_WideStringC& wsPath);
+
+ virtual ~IFX_FileAccess() {}
+ virtual void Release() = 0;
+ virtual IFX_FileAccess* Retain() = 0;
+ virtual void GetPath(CFX_WideString& wsPath) = 0;
+ virtual IFX_SeekableStream* CreateFileStream(uint32_t dwModes) = 0;
+};
+#endif // PDF_ENABLE_XFA
+
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
class CFindFileData {
public:
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 219e67dbc6..f211e64bc3 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -567,7 +567,7 @@ FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() {
}
IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) {
- IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC());
+ IFX_FileAccess* pAccess = IFX_FileAccess::CreateDefault(m_wsNext.AsStringC());
m_wsNext = GetNextFile().UTF8Decode();
pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr;
return pAccess;