00001
00002
00003
00004
00005
00006 #ifndef H_CPPSDFDoc
00007 #define H_CPPSDFDoc
00008
00009 #include <Common/Matrix2D.h>
00010 #include <Filters/FilterReader.h>
00011 #include <vector>
00012
00013 namespace pdftron {
00014 namespace Common {
00015 struct ProgressMonitor;
00016 }
00017
00018 namespace SDF {
00019
00020
00021
00022 class Obj;
00023 class SecurityHandler;
00024
00068 class SDFDoc
00069 {
00070 public:
00071
00078 SDFDoc ();
00079
00088 SDFDoc (const UString& filepath);
00089 SDFDoc (const char* filepath);
00090
00105 SDFDoc (Filters::Filter stream);
00106
00120 SDFDoc (unsigned char* buf, size_t buf_size);
00121
00125 ~SDFDoc ();
00126
00130 void Close();
00131
00135 bool IsEncrypted();
00136
00162 bool InitSecurityHandler ();
00163
00164 #ifndef SWIG
00165 bool InitSecurityHandler (void* custom_data);
00166 #endif
00167
00198 bool InitStdSecurityHandler (const char* password, int password_sz = 0);
00199
00203 bool IsModified () const;
00204
00208 bool IsFullSaveRequired () const;
00209
00214 Obj GetTrailer ();
00215
00221 Obj GetObj (const UInt32 obj_num) const;
00222
00237 Obj ImportObj (Obj obj, bool deep_copy);
00238
00253 std::vector<Obj> ImportObjs(const std::vector<Obj>& obj_list);
00254
00258 UInt32 XRefSize () const;
00259
00263 void ClearMarks ();
00264
00265 enum SaveOptions
00266 {
00267 e_incremental = 0x01,
00268 e_remove_unused = 0x02,
00269 e_hex_strings = 0x04,
00270 e_omit_xref = 0x08,
00271 e_linearized = 0x10,
00272 e_compatibility = 0x20
00273 };
00274
00297 void Save(const UString& path, UInt32 flags, const char* header);
00298
00299 #ifndef SWIG
00300 void Save(const UString& path, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
00301 #endif
00302
00318 std::vector<unsigned char> Save(UInt32 flags, const char* header);
00319
00320 #ifndef SWIG
00321 void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
00322 #endif
00323
00332 const char* GetHeader() const;
00333
00348 SecurityHandler GetSecurityHandler ();
00349
00361 void SetSecurityHandler (SecurityHandler handler);
00362
00366 void RemoveSecurity();
00367
00383 void Swap(UInt32 obj_num1, UInt32 obj_num2);
00384
00393 Obj CreateIndirectName(const char* name);
00394 Obj CreateIndirectArray();
00395 Obj CreateIndirectBool(bool value);
00396 Obj CreateIndirectDict();
00397 Obj CreateIndirectNull();
00398 Obj CreateIndirectNumber(double value);
00399 Obj CreateIndirectString(const UChar* value, UInt32 size);
00400 Obj CreateIndirectString(const UString& str);
00401
00405 Obj CreateIndirectStream(Filters::FilterReader& data, Filters::Filter filter_chain=Filters::Filter());
00406 Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain =Filters::Filter());
00407
00408
00428 bool IsLinearized() const;
00429
00436 SDF::Obj GetLinearizationDict() const;
00437
00444 SDF::Obj GetHintStream() const;
00445
00451 void Lock();
00452
00456 void Unlock();
00457
00461 bool IsLocked();
00462
00467 bool TryLock( int milliseconds = 0 );
00468
00474 UString GetFileName() const;
00475
00481 void EnableDiskCaching( bool use_cache_flag );
00482
00484 #ifndef SWIGHIDDEN
00485 SDFDoc(TRN_SDFDoc doc) : mp_doc(doc) {}
00486 TRN_SDFDoc mp_doc;
00487 private:
00488 SDFDoc(SDFDoc& other);
00489 SDFDoc& operator=(SDFDoc& other);
00490 #endif
00492 };
00493
00494
00495 };
00496 };
00497
00498
00499 #include <Impl/SDFDoc.inl>
00500 #endif
00501