Exemple #1
0
std::map<CPLString, GDALPDFObject*>& GDALPDFDictionaryPoppler::GetValues()
{
    int i = 0;
    int nLength = m_poDict->getLength();
    for(i=0;i<nLength;i++)
    {
        Get((const char*)m_poDict->getKey(i));
    }
    return m_map;
}
void Word::complete(const Dict &d){

	cout << "Word completion for: " << key << endl;

	cout << "--------------------------------" << endl;

	int wordSize = d.getLength(1);
	
	int found = 0;

	for(int j = 0; j < wordSize; j++)
	{
		int tester = 1;

		string dWord = d.getWord(j);
	
			for(unsigned int i = 0; i < key.length(); i++)
			{

				if(key[i] != dWord[i])
				{
			
					tester = 0;

					break;
				} 		
		
			}

		if (tester == 1)
		{
			cout << dWord << endl;

			found = 1;
		}		
	
	}
	
	if(found != 1)
		cout << "no completion found " << endl << " " << endl; 
	
}
void Word::check(const Dict &d){
	
	int wordSize = d.getLength(1); 

	string closeWords[wordSize];

	int distanceVector[wordSize];

	cout << endl << "WORD correction for: " << key << endl;

	cout << "--------------------------------" << endl;

	for(int k = 0; k < wordSize; k++)
	{
		
		dWord = d.getWord(k);

		int greater = 0;

		int dLength = dWord.length();
		
		int kLength = key.length()-1;

		if(dLength>kLength)
		{
			greater = dLength;
		}
		else
		{
			greater = kLength;
		}

		int distance = 0; 

		for(int j = 0; j < greater; j++)
		{
			if(key[j] != dWord[j])
				distance++;		

		}

		if(k < 10)
		{
			distanceVector[k] = distance;
			closeWords[k] = dWord;
		}
		else
		{
			for(int z = 0; z<10; z++)
			{
				if(distance < distanceVector[z])
				{
					for(int y = 11; y > z; y--)
					{
						distanceVector[y] = distanceVector[y-1];
					
						closeWords[y] = closeWords[y-1];
					}
				
					distanceVector[z] = distance;

					closeWords[z] = dWord;

					break;
				}
			}
		}

	} //end outer for

	for(int u = 0; u < 10; u++)
		print[u].assign(closeWords[u]); 
	
} //end check
Exemple #4
0
bool PdfExport::addPopplerPage(XojPopplerPage* pdf, XojPopplerDocument doc)
{
    XOJ_CHECK_TYPE(PdfExport);

    Page* page = pdf->getPage();
    static int otherObjectId = 1;

    this->resources = page->getResourceDict();

    GList* replacementList = NULL;

    Dict* dict = page->getResourceDict();
    for (int i = 0; i < dict->getLength(); i++)
    {
        const char* cDictName = dict->getKey(i);
        PdfRefList* refList = (PdfRefList*) g_hash_table_lookup(this->refListsOther,
                              cDictName);
        if (!refList)
        {
            char* indexName = NULL;
            if (strcmp(cDictName, "Font") == 0)
            {
                indexName = g_strdup("F");
            }
            else if (strcmp(cDictName, "XObject") == 0)
            {
                indexName = g_strdup("I");
            }
            else if (strcmp(cDictName, "ExtGState") == 0)
            {
                indexName = g_strdup("Gs");
            }
            else if (strcmp(cDictName, "Pattern") == 0)
            {
                indexName = g_strdup("p");
            }
            else
            {
                indexName = g_strdup_printf("o%i-", otherObjectId++);
            }

            refList = new PdfRefList(this->xref, this->objectWriter, this->writer,
                                     indexName);
            char* dictName = g_strdup(dict->getKey(i));

            // insert the new RefList into the hash table
            g_hash_table_insert(this->refListsOther, dictName, refList);
        }

        refList->parse(dict, i, doc, replacementList);

    }

    Object* o = new Object();
    page->getContents(o);

    if (o->getType() == objStream)
    {
        Dict* dict = o->getStream()->getDict();

        Object filter;
        dict->lookup("Filter", &filter);
        //			// this may would be better, but not working...:-/
        //			Object oDict;
        //			oDict.initDict(dict);
        //			Stream * txtStream = stream->addFilters(oDict);
        //			writePlainStream(txtStream);

        if (filter.isNull())
        {
            writePlainStream(o->getStream(), replacementList);
        }
        else if (filter.isName("FlateDecode"))
        {
            writeGzStream(o->getStream(), replacementList);
        }
        else if (filter.isName())
        {
            g_warning("Unhandled stream filter: %s\n", filter.getName());
        }
    }
    else
    {
        g_warning("other poppler type: %i\n", o->getType());
    }

    for (GList* l = replacementList; l != NULL; l = l->next)
    {
        RefReplacement* f = (RefReplacement*) l->data;
        delete f;
    }
    g_list_free(replacementList);

    o->free();
    delete o;
    this->resources = NULL;

    return true;
}