Exemple #1
0
void MetaEditor::selectElement()
{
    QStringList codes;
    {
         AddMetadata addelement(GetElementMap(), this);
         if (addelement.exec() == QDialog::Accepted) {
            codes = addelement.GetSelectedEntries();
         }
    }
    foreach(QString code, codes) {
        if (code == "dc:language") {
            QStringList langcodes;
            AddMetadata addvalue(Language::instance()->GetLangMap(), this);
            if (addvalue.exec() == QDialog::Accepted) {
                 langcodes = addvalue.GetSelectedEntries();
            }
            QString lang = "en";
            if (!langcodes.isEmpty()) {
                lang = langcodes.at(0);
            }
            insertRow(code, lang);
        } else if (code == "dc:identifier-isbn") {
            QString content = "urn:isbn:[No data]";
            code = "dc:identifier";
            insertRow(code, content);
        } else if (code == "dc:identifier-issn") {
            QString content = "urn:issn:[No data]";
            code = "dc:identifier";
            insertRow(code, content);
        } else if (code == "dc:identifier-doi") {
            QString content = "urn:doi:[No data]";
            code = "dc:identifier";
            insertRow(code, content);
        } else if (code == "dc:identifier-uuid") {
            QString content = "urn:uuid:[No data]";
            code = "dc:identifier";
            insertRow(code, content);
        } else if ((code == "dc:date") || (code == "dcterms:issued") || (code == "dcterms:created")) {
            QString content = QDate::currentDate().toString(Qt::ISODate);
            insertRow(code, content);
        } else if (code == "dc:type") {
            QString content = "[dictionary,index]";
            insertRow(code, content);
        } else if (code == "dc:creator-aut") {
            code = "dc:creator";
            insertRow(code);
            insertChild(QString("role"),QString("aut"));
            insertChild(QString("scheme"),QString("marc:relators"));
        } else {
            insertRow(code);
        }
    }
}
Exemple #2
0
void CRCFile::ProcessStringTable(UINT uiStringGroupID, std::vector<CString>::iterator *init)
{
    element_map* pElementMap = GetElementMap(uiStringGroupID);
    if(!pElementMap)
        return;

    CString str;
    for (; (*init) != m_vInRCFile.end(); (*init)++)
    {
        str=**init;
        str.TrimLeft(_T(" \t"));
        str.TrimRight(_T(" \t"));

        if ( str == _T("END") )
            return;
        else if ( str != _T("BEGIN") )
        {
            // the first stuff is ID, the second is text
            int iPos=str.Find(_T("\""), 0);
            if (iPos == -1)
            {
                (*init)++;
                str+=**init;
                iPos=str.Find(_T("\""), 0);
            }

            if (iPos != -1)
            {
                CString strID=str.Left(iPos);
                strID.TrimRight(_T(" \"\t\n\r"));

                CString strText=str.Mid(iPos+1);
                strText.Replace(_T("\"\""), _T("\""));
                strText=strText.Left(strText.ReverseFind(_T('\"')));

                UINT uiID = GetResourceID(strID);
                pElementMap->insert(std::make_pair(uiID, strText));

                str=**init;
                str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
            }
        }
    }
}
Exemple #3
0
void MetaEditor::selectE2Element()
{
    QStringList codes;
    {
         AddMetadata addelement(GetElementMap(), this);
         if (addelement.exec() == QDialog::Accepted) {
            codes = addelement.GetSelectedEntries();
         }
    }
    foreach(QString code, codes) {
        if (code == "dc:language") {
            QStringList langcodes;
            AddMetadata addvalue(Language::instance()->GetLangMap(), this);
            if (addvalue.exec() == QDialog::Accepted) {
                 langcodes = addvalue.GetSelectedEntries();
            }
            QString lang = "en";
            if (!langcodes.isEmpty()) {
                lang = langcodes.at(0);
            }
            insertRow(code, lang);
        } else if (code == "dc:identifier-isbn") {
            QString content = tr("[ISBN here]");
            code = "dc:identifier";
            insertRow(code, content);
            insertChild(QString("opf:scheme"), QString("ISBN"));
        } else if (code == "dc:identifier-issn") {
            QString content = tr("[ISSN here]");
            code = "dc:identifier";
            insertRow(code, content);
            insertChild(QString("opf:scheme"), QString("ISSN"));
        } else if (code == "dc:identifier-doi") {
            QString content = tr("[DOI here]");
            code = "dc:identifier";
            insertRow(code, content);
            insertChild(QString("opf:scheme"), QString("DOI"));
        } else if (code == "dc:identifier-uuid") {
            QString content = tr("[UUID here]");
            code = "dc:identifier";
            insertRow(code, content);
            insertChild(QString("opf:scheme"), QString("UUID"));
        } else if (code == "dc:identifier-custom") {
            QString content = tr("[Custom identifier here]");
            code = "dc:identifier";
            insertRow(code, content);
            insertChild(QString("opf:scheme"));
        } else if (code.startsWith("dc:date-")) {
            QStringList parts = code.split('-');
            QString dc_event = parts.at(1);
            code = "dc:date";
            QString content = QDate::currentDate().toString(Qt::ISODate);
            insertRow(code,content);
            insertChild(QString("opf:event"),dc_event);
        } else if (code == "dc:creator-aut") {
            code = "dc:creator";
            QString content = tr("[Author name here]");
            insertRow(code, content);
            insertChild(QString("opf:role"),QString("aut"));
        } else if (code == "dc:creator") {
            code = "dc:creator";
            QString content = tr("[Creator name here]");
            insertRow(code, content);
        } else if (code == "dc:contributor") {
            code = "dc:contributor";
            QString content = tr("[Contributor name here]");
            insertRow(code, content);
        } else {
            insertRow(code);
        }
    }
}
Exemple #4
0
void CRCFile::ProcessDialog(UINT uiDialogID, std::vector<CString>::iterator *init)
{
    element_map* pElementMap = GetElementMap(uiDialogID);
    if(!pElementMap)
        return;

    CString str;
    for (; (*init) != m_vInRCFile.end(); (*init)++)
    {
        str=**init;
        str.TrimLeft(_T(" "));
        str.TrimRight(_T(" "));

        // check for exit
        if ( str == _T("END") )
        {
            // add the line to the outrc wo changes
            m_vOutRCFile.push_back(**init);
            return;
        }
        else if ( str.Left(7) == _T("CAPTION") )
        {
            // read the caption
            CString strText=str.Mid(7);
            strText.TrimLeft(_T(" \t\""));
            strText.TrimRight(_T(" \t\""));

            pElementMap->insert(std::make_pair(0, strText));

            // save to rc wo title
            str=**init;
            str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
            m_vOutRCFile.push_back(str);
        }
        else if ( str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT") || str.Left(13) == _T("DEFPUSHBUTTON") || str.Left(10) == _T("PUSHBUTTON") || str.Left(7) == _T("CONTROL") || str.Left(8) == _T("GROUPBOX") )
        {
            // needed only 2 commas (outside the '\"')
            if ( GetCommasCount(str) < 3 )
                str+=*((*init)+1);

            // the first thing after LTEXT(and other) is the caption
            CString strText;
            bool bControl = false;

            if (str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT"))
                str=str.Mid(5);
            else if (str.Left(13) == _T("DEFPUSHBUTTON"))
                str=str.Mid(13);
            else if (str.Left(10) == _T("PUSHBUTTON"))
                str=str.Mid(10);
            else if (str.Left(7) == _T("CONTROL"))
            {
                bControl = true;
                str=str.Mid(7);
            }
            else if (str.Left(8) == _T("GROUPBOX"))
                str=str.Mid(8);

            str=str.Mid(str.Find(_T("\""))+1);
            int iPos=str.Find(_T("\""), 0);
            if (iPos != -1)
                strText=str.Left(iPos);
            else
                THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);

            str = str.Mid(iPos+1);

            // after the first comma there is an ID
            iPos=str.Find(_T(","), 0);
            CString strID;
            if (iPos != -1)
            {
                str=str.Mid(iPos+1);
                iPos=str.Find(_T(","), 0);
                if (iPos != -1)
                    strID=str.Left(iPos);
                else
                    THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);

                strID.TrimLeft(_T(" \t"));
                strID.TrimRight(_T(" \t"));
            }
            else
                THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);

            bool bSkip = false;
            if(bControl)
            {
                str = str.Mid(iPos+1);
                iPos = str.Find(_T(","), 0);
                if(iPos == -1)
                    THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);

                CString strType = str.Left(iPos);
                strType.Trim(_T("\""));
                if(strType == _T("SysListView32") || strType == _T("msctls_progress32") ||
                        strType == _T("ComboBoxEx32") || strType == _T("msctls_updown32") ||
                        strType == _T("SysDateTimePick32"))
                {
                    bSkip = true;
                }
            }

            if(!bSkip)
            {
                // find id
                UINT uiID = GetResourceID(strID);
                CString out;
                pElementMap->insert(std::make_pair(uiID, strText));
            }

            // now add the data to output rc
            str=**init;
            str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));

            m_vOutRCFile.push_back(str);
        }
        else
            m_vOutRCFile.push_back(**init);
    }
}
Exemple #5
0
void CRCFile::ProcessMenu(UINT uiMenuID, std::vector<CString>::iterator *init)
{
    element_map* pElementMap = GetElementMap(uiMenuID);
    if(!pElementMap)
        return;

    CString str;
    for (; (*init) != m_vInRCFile.end(); (*init)++)
    {
        str=**init;
        str.TrimLeft(_T(" "));
        str.TrimRight(_T(" "));

        // check for exit
        if ( str == _T("END") )
        {
            // add the line to the outrc wo changes
            m_vOutRCFile.push_back(**init);
            return;
        }
        else if (str.Left(5) == _T("POPUP")) // if that is the popup string - call the function once more
        {
            // add the line to the outrc with changes - replace string inside "" with P
            str=**init;

            // processing menuitem - find the text
            int iPos=str.Find(_T("\""), 0);
            CString strText;
            if (iPos != -1)
            {
                strText=str.Mid(iPos+1);
                int iPos2=strText.Find(_T("\""));
                if (iPos2 != -1)
                    strText=strText.Left(iPos2);
            }

            // now find the | that separates the text from the pseudo-ID
            int iBar=strText.ReverseFind(_T('|'));
            if (iBar != -1)
            {
                // there is a text with an ID
                CString strID=strText.Mid(iBar+1);
                strText=strText.Left(iBar);

                // put the id and text in the translation file
                // find the equiv for the id
                UINT uiID = GetResourceID(strID);
                pElementMap->insert(std::make_pair(uiID, strText));

                // put the found ID as output text
                CString out;
                out.Format(_T("\"%lu\""), uiID);
                str=str.Left(iPos)+out;
            }
            else
            {
                // no pseudoID in menu name
                str=str.Left(iPos)+_T("\"P\"");
            }

            m_vOutRCFile.push_back(str);

            (*init)++;
            ProcessMenu(uiMenuID, init);
        }
        else
        {
            // if the line has MENUITEM
            if (str.Left(8) == _T("MENUITEM") && str.Right(9) != _T("SEPARATOR"))
            {
                // restore original
                str=**init;

                // check if there is any text after the comma
                int iPos=str.Find(_T(","), 0);
                CString strTest=str.Mid(iPos);
                strTest.TrimLeft(_T(" ,\t\r\n"));
                if (strTest.IsEmpty())
                {
                    (*init)++;

                    CString tmp=**init;
                    tmp.Trim(_T(" ,\t\r\n"));
                    str+=tmp;
                }

                // processing menuitem - find the text
                iPos=str.Find(_T("\""), 0);
                CString strText;
                if (iPos != -1)
                {
                    strText=str.Mid(iPos+1);
                    int iPos2=strText.Find(_T("\""));
                    if (iPos2 != -1)
                        strText=strText.Left(iPos2);
                }

                // find the ID
                iPos=str.Find(_T(","), 0);
                CString strID;
                if (iPos != -1)
                {
                    strID=str.Mid(iPos+1);
                    int iPos2=strID.Find(_T(","), 0);
                    if (iPos2 != -1)
                        strID=strID.Left(iPos2);
                }
                strID.TrimLeft(_T(" \t"));
                strID.TrimRight(_T(" \t"));

                // find the equiv for the id
                UINT uiID = GetResourceID(strID);
                pElementMap->insert(std::make_pair(uiID, strText));
                CString out = str;
                //				out=**init;
                out.Replace(_T("\"")+strText+_T("\""), _T("\"i\""));
                m_vOutRCFile.push_back(out);
            }
            else
                m_vOutRCFile.push_back(**init);
        }
    }
}