示例#1
0
/******************************************************************************
 * EncodingFilterMgr::Encoding	- sets/gets encoding
 *
 * ENT:	enc	- new encoding or 0 to simply get the current encoding
 *
 * RET: encoding
 */
char EncodingFilterMgr::Encoding(char enc) {
        if (enc && enc != encoding) {
                encoding = enc;
                SWFilter * oldfilter = targetenc;
                
                switch (encoding) {
                case ENC_LATIN1:
                        targetenc = new UTF8Latin1();
                        break;
                case ENC_UTF16:
                        targetenc = new UTF8UTF16();
                        break;
                case ENC_RTF:
                        targetenc = new UnicodeRTF();
                        break;
                case ENC_HTML:
                        targetenc = new UTF8HTML();
                        break;
                default: // i.e. case ENC_UTF8
                        targetenc = NULL;
                }

                ModMap::const_iterator module;

                if (oldfilter != targetenc) {
                        if (oldfilter) {
                                if (!targetenc) {
                                        for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
                                                module->second->RemoveRenderFilter(oldfilter);
                                }
                                else {
                                        for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
                                                module->second->ReplaceRenderFilter(oldfilter, targetenc);
                                }
                                delete oldfilter;
                        }
                        else if (targetenc) {
                                for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
                                        module->second->AddRenderFilter(targetenc);
                        }
                }

        }
        return encoding;
}
示例#2
0
char DiathekeFilterMgr::Markup(char mark) {
        if (mark && mark != markup) {
                markup = mark;
                ModMap::const_iterator module;

                SWFilter * oldplain = fromplain;
                SWFilter * oldthml = fromthml;
                SWFilter * oldgbf = fromgbf;
                SWFilter * oldosis = fromosis;

                CreateFilters(markup);

                for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
                        switch (module->second->getMarkup()) {
                        case FMT_THML:
                                if (oldthml != fromthml) {
                                        if (oldthml) {
                                                if (!fromthml) {
                                                        module->second->removeRenderFilter(oldthml);
                                                }
                                                else {
                                                        module->second->replaceRenderFilter(oldthml, fromthml);
                                                }
                                        }
                                        else if (fromthml) {
                                                module->second->addRenderFilter(fromthml);
                                        }
                                }
                                break;
                        case FMT_GBF:
                                if (oldgbf != fromgbf) {
                                        if (oldgbf) {
                                                if (!fromgbf) {
                                                        module->second->removeRenderFilter(oldgbf);
                                                }
                                                else {
                                                        module->second->replaceRenderFilter(oldgbf, fromgbf);
                                                }
                                        }
                                        else if (fromgbf) {
                                                module->second->addRenderFilter(fromgbf);
                                        }
                                        break;
                                }
                        case FMT_PLAIN:
                                if (oldplain != fromplain) {
                                        if (oldplain) {
                                                if (!fromplain) {
                                                        module->second->removeRenderFilter(oldplain);
                                                }
                                                else {
                                                        module->second->replaceRenderFilter(oldplain, fromplain);
                                                }
                                        }
                                        else if (fromplain) {
                                                module->second->addRenderFilter(fromplain);
                                        }
                                        break;
                                }
                        case FMT_OSIS:
                                if (oldosis != fromosis) {
                                        if (oldosis) {
                                                if (!fromosis) {
                                                        module->second->removeRenderFilter(oldosis);
                                                }
                                                else {
                                                        module->second->replaceRenderFilter(oldosis, fromosis);
                                                }
                                        }
                                        else if (fromosis) {
                                                module->second->addRenderFilter(fromosis);
                                        }
                                        break;
                                }
                        }

                if (oldthml)
                        delete oldthml;
                if (oldgbf)
                        delete oldgbf;
                if (oldplain)
                        delete oldplain;
                if (oldosis)
                        delete oldosis;
        }
        return markup;
}