Skip to content

Commit

Permalink
CSS: adds "-cr-only-if: txt-document" and other formats (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
poire-z authored Nov 27, 2021
1 parent e5cb5bf commit 08dc3d4
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2734,6 +2734,14 @@ static const char * css_cr_only_if_names[]={
"full-featured",
"epub-document",
"fb2-document",
"html-document",
"txt-document",
"rtf-document",
"chm-document",
"doc-document",
"docx-document",
"odt-document",
"pdb-document",
NULL
};
enum cr_only_if_t {
Expand All @@ -2750,6 +2758,14 @@ enum cr_only_if_t {
cr_only_if_full_featured,
cr_only_if_epub_document,
cr_only_if_fb2_document, // fb2 or fb3
cr_only_if_html_document,
cr_only_if_txt_document,
cr_only_if_rtf_document,
cr_only_if_chm_document,
cr_only_if_doc_document,
cr_only_if_docx_document,
cr_only_if_odt_document,
cr_only_if_pdb_document,
};

bool LVCssDeclaration::parse( const char * &decl, bool higher_importance, lxmlDocBase * doc, lString32 codeBase )
Expand Down Expand Up @@ -2864,6 +2880,54 @@ bool LVCssDeclaration::parse( const char * &decl, bool higher_importance, lxmlDo
match = !match;
}
}
else if ( name == cr_only_if_html_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_html;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_txt_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_txt;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_rtf_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_rtf;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_chm_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_chm;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_doc_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_doc;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_docx_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_docx;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_odt_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_odt;
if (invert) {
match = !match;
}
}
else if ( name == cr_only_if_pdb_document ) {
match = doc->getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, doc_format_none) == doc_format_pdb;
if (invert) {
match = !match;
}
}
else { // unknown option: ignore
match = false;
}
Expand Down

0 comments on commit 08dc3d4

Please sign in to comment.