-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move props code to DocProperites.[h|cpp]
- Loading branch information
Showing
32 changed files
with
134 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* Copyright 2022 the SumatraPDF project authors (see AUTHORS file). | ||
License: Simplified BSD (see COPYING.BSD) */ | ||
|
||
#include "utils/BaseUtil.h" | ||
|
||
#include "DocProperties.h" | ||
|
||
const char* kPropTitle = "title"; | ||
const char* kPropAuthor = "author"; | ||
const char* kPropCopyright = "copyright"; | ||
const char* kPropSubject = "subject"; | ||
const char* kPropCreationDate = "creationDate"; | ||
const char* kPropModificationDate = "modDate"; | ||
const char* kPropCreatorApp = "creatorApp"; | ||
const char* kPropUnsupportedFeatures = "unsupportedFeatures"; | ||
const char* kPropFontList = "fontList"; | ||
const char* kPropPdfVersion = "pdfVersion"; | ||
const char* kPropPdfProducer = "pdfProducer"; | ||
const char* kPropPdfFileStructure = "pdfFileStructure"; | ||
|
||
int PropsCount(const Props& props) { | ||
int n = props.Size(); | ||
CrashIf(n < 0 || (n % 2) != 0); | ||
return n / 2; | ||
} | ||
|
||
int FindPropIdx(const Props& props, const char* key) { | ||
int n = PropsCount(props); | ||
for (int i = 0; i < n; i++) { | ||
int idx = i * 2; | ||
char* v = props.At(idx); | ||
if (str::Eq(v, key)) { | ||
return idx; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
char* FindProp(const Props& props, const char* key) { | ||
int idx = FindPropIdx(props, key); | ||
if (idx < 0) { | ||
return nullptr; | ||
} | ||
char* v = props.At(idx); | ||
return v; | ||
} | ||
|
||
void AddProp(Props& props, const char* key, const char* val, bool replaceIfExists) { | ||
CrashIf(!key || !val); | ||
int idx = FindPropIdx(props, key); | ||
if (idx < 0) { | ||
// doesn't exsit | ||
props.Append(key); | ||
props.Append(val); | ||
return; | ||
} | ||
if (!replaceIfExists) { | ||
return; | ||
} | ||
props.SetAt(idx + 1, val); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Copyright 2022 the SumatraPDF project authors (see AUTHORS file). | ||
License: Simplified BSD (see COPYING.BSD) */ | ||
|
||
extern const char* kPropTitle; | ||
extern const char* kPropAuthor; | ||
extern const char* kPropCopyright; | ||
extern const char* kPropSubject; | ||
extern const char* kPropCreationDate; | ||
extern const char* kPropModificationDate; | ||
extern const char* kPropCreatorApp; | ||
extern const char* kPropUnsupportedFeatures; | ||
extern const char* kPropFontList; | ||
extern const char* kPropPdfVersion; | ||
extern const char* kPropPdfProducer; | ||
extern const char* kPropPdfFileStructure; | ||
|
||
// Props are stored in StrVec as key, value sequentially | ||
using Props = StrVec; | ||
int PropsCount(const Props& props); | ||
int FindPropIdx(const Props& props, const char* key); | ||
char* FindProp(const Props& props, const char* key); | ||
void AddProp(Props& props, const char* key, const char* val, bool replaceIfExists = false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.