Пример #1
0
bool IE_Imp_EPUB::pasteFromBuffer(PD_DocumentRange* pDocRange,
				  const unsigned char* pData, UT_uint32 lenData, const char* /*szEncoding*/)
{
    UT_return_val_if_fail(getDoc() == pDocRange->m_pDoc,false);
    UT_return_val_if_fail(pDocRange->m_pos1 == pDocRange->m_pos2,false);

    PD_Document * newDoc = new PD_Document();
    newDoc->createRawDocument();
    IE_Imp_EPUB * pEPUBImp = new IE_Imp_EPUB(newDoc);
    //
    // Turn pData into something that can be imported by the open documenb
    // importer.
    //
    GsfInput * pInStream = gsf_input_memory_new((const guint8 *) pData,
            (gsf_off_t) lenData, FALSE);
    pEPUBImp->loadFile(newDoc, pInStream);

    newDoc->finishRawCreation();

    IE_Imp_PasteListener * pPasteListen = new IE_Imp_PasteListener(getDoc(),
            pDocRange->m_pos1, newDoc);
    newDoc->tellListener(static_cast<PL_Listener *> (pPasteListen));
    delete pPasteListen;
    delete pEPUBImp;
    UNREFP( newDoc);
    return true;
}
Пример #2
0
UT_Error IE_Imp_WordPerfect::_updateDocumentUnorderedListDefinition(ABI_ListDefinition *pListDefinition, int iLevel)
{
	UT_DEBUGMSG(("AbiWordPerfect: Updating document list definition (iLevel: %i)\n", iLevel));
	
	// finally, set the document's list identification info..
	fl_AutoNum * pAuto = getDoc()->getListByID(pListDefinition->getListID(iLevel));
	// not in document yet, we should create a list for it
	if (pAuto == NULL) 
	{	
		UT_DEBUGMSG(("AbiWordPerfect: pAuto is NULL: creating a list\n"));
		if (iLevel > 1) 
		{	
			pAuto = new fl_AutoNum(pListDefinition->getListID(iLevel), pListDefinition->getListID((iLevel-1)), 
								   pListDefinition->getListType(1), 0, const_cast<gchar*>(reinterpret_cast<const gchar*>("%L")), ".", getDoc(), NULL);
		}   
		else
			pAuto = new fl_AutoNum(pListDefinition->getListID(iLevel), 0, pListDefinition->getListType(iLevel), 0, 
								   const_cast<gchar*>(reinterpret_cast<const gchar*>("%L")), ".", getDoc(), NULL);
		  
		getDoc()->addList(pAuto);
	}
	// we should update what we have
	else 
	{	
		UT_DEBUGMSG(("AbiWordPerfect: pAuto already exists\n"));
	}

	pAuto->fixHierarchy();

	return UT_OK;
}
Пример #3
0
void AP_Win32Dialog_Styles::runModal(XAP_Frame * pFrame)
{
	UT_return_if_fail (pFrame);
//
// Get View and Document pointers. Place them in member variables
//
	setFrame(pFrame);

	setView((FV_View *) pFrame->getCurrentView());
	UT_return_if_fail (getView());

	setDoc(getView()->getLayout()->getDocument());
	UT_return_if_fail (getDoc());


	// raise the dialog
	_win32Dialog.runModal(pFrame, AP_DIALOG_ID_STYLES, AP_RID_DIALOG_STYLES_TOP, this);
	
	
	if (m_answer == AP_Dialog_Styles::a_OK)
	{
		const char* szStyle = getCurrentStyle();
		if (szStyle)
		{
			getDoc()->updateDocForStyleChange(szStyle, true);
			getView()->getCurrentBlock()->setNeedsRedraw();
			getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
		}
	}

}
Пример #4
0
UT_Error IE_Exp_WordPerfect::_writeDocument(void)
{
	UT_DEBUGMSG(("WordPerfect Exporter: _writeDocument\n"));
	
	if (_writeHeader() != UT_OK)
			return UT_ERROR;
	
	m_pListener = _constructListener();
	if (!m_pListener)
		return UT_IE_NOMEMORY;
	
	if (getDocRange())
		getDoc()->tellListenerSubset(static_cast<PL_Listener *>(m_pListener),getDocRange());
	else
		getDoc()->tellListener(static_cast<PL_Listener *>(m_pListener));
	DELETEP(m_pListener);

	if (m_error == UT_OK)
	  {
	    _UT_String_overwrite(*m_buffer, PTR_TO_DOCUMENT_INDEX, m_ptrToDocument);
	    _UT_String_overwrite(*m_buffer, PTR_TO_FILESIZE_INDEX, m_buffer->length());
	    _UT_String_overwrite(*m_buffer, m_ptrDesiredFontUseCount, m_desiredFontUseCount);
	    
	    write(m_buffer->c_str(), m_buffer->length());

	    DELETEP(m_buffer);
	  }

	return ((m_error) ? UT_IE_COULDNOTWRITE : UT_OK);
}
UT_Error IE_Exp_Text::_writeDocument(void)
{
	// Don't call base method if user cancels encoding dialog
	if (!(!m_bIsEncoded || m_bExplicitlySetEncoding || _doEncodingDialog(m_szEncoding)))
		return UT_SAVE_CANCELLED;

	// TODO If we're going to the clipboard and the OS supports unicode, set encoding.
	// TODO Only supports Windows so far.
	// TODO Should use a finer-grain technique than IsWinNT() since Win98 supports unicode clipboard.
	if (getDocRange())
	{
#ifdef WIN32
		if (UT_IsWinNT())
			_setEncoding(XAP_EncodingManager::get_instance()->getNativeUnicodeEncodingName());
#endif
	}

	m_pListener = _constructListener();
	if (!m_pListener)
		return UT_IE_NOMEMORY;

	if (getDocRange())
		getDoc()->tellListenerSubset(static_cast<PL_Listener *>(m_pListener),getDocRange());
	else
		getDoc()->tellListener(static_cast<PL_Listener *>(m_pListener));
	DELETEP(m_pListener);

	return ((m_error) ? UT_IE_COULDNOTWRITE : UT_OK);
}
Пример #6
0
UT_Error IE_Exp_XSL_FO::_writeDocument()
{
	m_pListener = new s_XSL_FO_Listener(getDoc(),this);
	if (!m_pListener)
		return UT_IE_NOMEMORY;
	if (!getDoc()->tellListener(static_cast<PL_Listener *>(m_pListener)))
		return UT_ERROR;
	DELETEP(m_pListener);
	
	return ((m_error) ? UT_IE_COULDNOTWRITE : UT_OK);
}  
Пример #7
0
// NB: AbiWord-2.0 doesn't properly support nested lists with different nested styles: only "1" style
// really looks proper. We hack around this be only using the style given at level "1"
// NB: AbiWord-2.0 doesn't properly support setting list delimeters at levels greater than 1,
// we hack around this by using only "plain" (e.g.: NULL) list delimeters on levels greater than 1.
UT_Error IE_Imp_WordPerfect::_updateDocumentOrderedListDefinition(ABI_ListDefinition *pListDefinition, int iLevel, 
																  const char /*listType*/, const UT_UTF8String &sTextBeforeNumber, 
																  const UT_UTF8String &sTextAfterNumber, int iStartingNumber)
{
	UT_DEBUGMSG(("AbiWordPerfect: Updating document list definition (iLevel: %i)\n", iLevel));

	if (iLevel > 1) {
        UT_DEBUGMSG(("WLACH: Parent's list id is.. %i\n", pListDefinition->getListID((iLevel-1))));
    }

	// finally, set the document's list identification info..
	fl_AutoNum * pAuto = getDoc()->getListByID(pListDefinition->getListID(iLevel));
	// not in document yet, we should create a list for it
	if (pAuto == NULL) 
	{	
		UT_DEBUGMSG(("AbiWordPerfect: pAuto is NULL: creating a list\n"));
		if (iLevel > 1) 
		{	
			pAuto = new fl_AutoNum(pListDefinition->getListID(iLevel), 
								   pListDefinition->getListID((iLevel-1)), 
								   pListDefinition->getListType(1), 
								   iStartingNumber, 
								   const_cast<gchar*>(reinterpret_cast<const gchar*>("%L")), 
								   ".", 
								   getDoc(), 
								   NULL);
		}   
		else 
		{
			UT_UTF8String sNumberingString;
			UT_UTF8String sNumber("%L", (size_t)0);
			
			sNumberingString += sTextBeforeNumber;
			sNumberingString += sNumber;
			sNumberingString += sTextAfterNumber;
	
			pAuto = new fl_AutoNum(pListDefinition->getListID(iLevel), 0, pListDefinition->getListType(iLevel), iStartingNumber, 
								   const_cast<gchar*>(reinterpret_cast<const gchar*>(sNumberingString.utf8_str())), ".", getDoc(), NULL);
		}
		getDoc()->addList(pAuto);
	}
	// we should update what we have
	else 
	{
		UT_DEBUGMSG(("AbiWordPerfect: pAuto already exists\n"));
	}

	pAuto->fixHierarchy();

	return UT_OK;
}
Пример #8
0
void AP_Win32Dialog_Styles::_populateCList(void)
{
	const PD_Style * pStyle;
	const char * name = NULL;
	const char*	pLocalised = NULL;
	int nIndex;
	UT_UTF8String utf8;
	UT_String str;						 

	size_t nStyles = getDoc()->getStyleCount();
	xxx_UT_DEBUGMSG(("DOM: we have %d styles\n", nStyles));

	_win32Dialog.resetContent(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES);
	
	UT_GenericVector<PD_Style*> * pStyles = NULL;
	getDoc()->enumStyles(pStyles);
	UT_return_if_fail( pStyles );
	
	for (UT_uint32 i = 0; i < nStyles; i++)
	{
	    const char * data[1];

		pStyle = pStyles->getNthItem(i);
		
		// style has been deleted probably
		if (!pStyle)
			continue;

		name = pStyle->getName();

	    // all of this is safe to do... append should take a const char **
	    data[0] = name;	    

	    if ((m_whichType == ALL_STYLES) || 
			(m_whichType == USED_STYLES && pStyle->isUsed()) ||
			(m_whichType == USER_STYLES && pStyle->isUserDefined()))
		{

			pt_PieceTable::s_getLocalisedStyleName(*data, utf8);
			pLocalised = utf8.utf8_str();
			/*str = AP_Win32App::s_fromUTF8ToWinLocale(pLocalised);
			pLocalised = str.c_str();*/
			
			nIndex = _win32Dialog.addItemToList(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, pLocalised);						
			_win32Dialog.setListDataItem(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, nIndex, i);							
			
		}
	}

	delete pStyles;
}
Пример #9
0
UT_Error IE_Exp_MIF::_writeDocument(void)
{
	m_pListener = new s_MIF_Listener(getDoc(),this);
	if (!m_pListener)
		return UT_IE_NOMEMORY;

	if (getDocRange())
		getDoc()->tellListenerSubset(static_cast<PL_Listener *>(m_pListener),getDocRange());
	else
		getDoc()->tellListener(static_cast<PL_Listener *>(m_pListener));
	DELETEP(m_pListener);
	
	return ((m_error) ? UT_IE_COULDNOTWRITE : UT_OK);
}
Пример #10
0
/**
 * Handle the manifest file.
 */
UT_Error IE_Imp_OpenDocument::_handleManifestStream() {
    // clear the cryptography state
    m_cryptoInfo.clear();
    m_sPassword = "";

	GsfInput* pMetaInf = gsf_infile_child_by_name(m_pGsfInfile, "META-INF");
    ODi_ManifestStream_ListenerState manifestListener(getDoc(),
                                          *(m_pStreamListener->getElementStack()),
                                           m_cryptoInfo);

	m_pStreamListener->setState(&manifestListener, false);

    UT_Error error = _handleStream (GSF_INFILE(pMetaInf), "manifest.xml", *m_pStreamListener);

    g_object_unref (G_OBJECT (pMetaInf));
    
    if (error != UT_OK) {
        return error;
    }

    if (m_cryptoInfo.size() > 0) {
        // there is at least one entry in the manifest that is encrypted, so
        // ask the user for a password
        m_sPassword = GetPassword();
        if (m_sPassword.size() == 0)
            return UT_IE_PROTECTED;
    }
	
    return UT_OK;
}
Пример #11
0
std::map<std::string, std::string>			XMLParser::parseFile(std::string filename)
{
  QDomElement				dom_elem;
  QDomNode				node;
  std::map<std::string, std::string>	map;
  std::pair<std::string, std::string>	pair;

  if (openFile(filename) == false)
    return (map);
  dom_elem = getDoc().documentElement();
  node = dom_elem.firstChild();
  while (!node.isNull())
    {
      QDomElement			elem;

      elem = node.toElement();
      if (!elem.isNull())
	{
	  pair = std::make_pair(elem.tagName().toStdString(), elem.text().toStdString());
	  map.insert(map.end(), pair);
	}
      node = node.nextSibling();
    }
  return (map);
}
Пример #12
0
std::map<char, std::vector<unsigned char> >	XMLParser::getCommandArgs(std::string filename)
{
  std::map<char, std::vector<unsigned char> >		map;
  QDomElement						dom_elem;
  QDomNode						node;
  QDomElement						elem;
  QDomElement						childelem;
  QDomNode						childnode;

  if (openFile(filename) == false)
    return (map);
  dom_elem = getDoc().documentElement();
  node = dom_elem.firstChild();
  while (!node.isNull())
    {
      elem = node.toElement();
      if (!elem.isNull())
	{
	  std::vector<unsigned char>			vec;
	  childnode = elem.firstChild().toElement().firstChild();
	  while (!childnode.isNull())
	    {
	      childelem = childnode.toElement();
	      vec.push_back(childelem.text().toInt());
	      childnode = childnode.nextSibling();
	    }
	  map[node.toElement().attribute("nb").toInt()] = vec;
	}
      node = node.nextSibling();
    }
  return (map);
}
Пример #13
0
	UT_Error _runConversion(const UT_String& pdf_on_disk, const UT_String& output_on_disk, size_t which)
	{
		UT_Error rval = UT_ERROR;

		const char * pdftoabw_argv[4];
		
		int argc = 0;
		pdftoabw_argv[argc++] = pdf_conversion_programs[which].conversion_program;
		pdftoabw_argv[argc++] = pdf_on_disk.c_str ();
		pdftoabw_argv[argc++] = output_on_disk.c_str ();
		pdftoabw_argv[argc++] = NULL;
		
		// run conversion
		if (g_spawn_sync (NULL,
						  (gchar **)pdftoabw_argv,
						  NULL,
						  (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL),
						  NULL,
						  NULL,
						  NULL,
						  NULL,
						  NULL,
						  NULL))
			{
				char * uri = UT_go_filename_to_uri (output_on_disk.c_str ());
				if (uri)
					{
						// import the document
						rval = IE_Imp::loadFile (getDoc (), uri, IE_Imp::fileTypeForSuffix (pdf_conversion_programs[which].extension));
						g_free (uri);
					}
			}

		return rval;
	}
//takes in an array of search terms, gets the docID, score, and which list it should be added in
//and passes the information to the function addScoreToList to be added to the list
//
//PSEUDO CODE
//for all searchterms
//    get the docIDs associated with the word and add the score to the list but factor in a WEIGHT
//    if the prev searchterm is not OR
//	 add to list with weight
//    else
//	 add to the list
void processSearchTerms(INVERTED_INDEX* index, char* searchterms) {
    int docID;
    int score;
    char* prevterm = NULL;
    char* currentterm;
    int pos;
    DOCNODE* d;
    while (searchterms != NULL) {
        currentterm = searchterms;
        pos = 0;
        if(isSearchTerm(currentterm) == TRUE) { //if it's a search term, normalize it and search for it
            NormalizeWord(currentterm);
            while((d = getDoc(index, currentterm, &pos)) != NULL) {
                docID = d->doc_id;
                score = d->page_word_freq;
                if(isNotOR(prevterm) == TRUE) { //add with weighteded score because it must be ADD
                    addScoreToList(querylist, TRUE, docID, (score*WEIGHT));
                }
                else//add with regular score
                    addScoreToList(querylist, FALSE, docID, score);
            }
        }
        prevterm = currentterm;
        searchterms = strtok(NULL, " "); //get next searchterm
    }
    if (querylist->start != NULL) {
        slist = NEW(SORTLIST);
        MALLOC_CHECK(slist);
        BZERO(slist, sizeof(SORTLIST));
        sortList(slist, querylist);
        printList(slist);
    }
}
Пример #15
0
UT_Error IE_Exp_EPUB::EPUB3_writeStructure()
{
    m_oebpsDir = m_baseTempDir + G_DIR_SEPARATOR_S;
    m_oebpsDir += "OEBPS";

    UT_go_directory_create(m_oebpsDir.c_str(), NULL);

    std::string indexPath = m_oebpsDir + G_DIR_SEPARATOR_S;
    indexPath += "index.xhtml";

    // Exporting document to XHTML using HTML export plugin 
    char *szIndexPath = (char*) g_malloc(strlen(indexPath.c_str()) + 1);
    strcpy(szIndexPath, indexPath.c_str());
    IE_Exp_HTML_WriterFactory *pWriterFactory = new IE_Exp_EPUB_EPUB3WriterFactory();
    m_pHmtlExporter = new IE_Exp_HTML(getDoc());
    m_pHmtlExporter->setWriterFactory(pWriterFactory);
    m_pHmtlExporter->suppressDialog(true);
    m_pHmtlExporter->setProps(
        "embed-css:no;html4:no;use-awml:no;declare-xml:yes;add-identifiers:yes;");
    
    m_pHmtlExporter->set_SplitDocument(m_exp_opt.bSplitDocument);
    m_pHmtlExporter->set_MathMLRenderPNG(m_exp_opt.bRenderMathMLToPNG);
    m_pHmtlExporter->writeFile(szIndexPath);
    g_free(szIndexPath);
    DELETEP(pWriterFactory);
    return UT_OK;
}
Пример #16
0
UT_Error IE_Exp_EPUB::EPUB2_writeStructure()
{
    m_oebpsDir = m_baseTempDir + G_DIR_SEPARATOR_S;
    m_oebpsDir += "OEBPS";

    UT_go_directory_create(m_oebpsDir.c_str(), NULL);

    std::string indexPath = m_oebpsDir + G_DIR_SEPARATOR_S;
    indexPath += "index.xhtml";

    // Exporting document to XHTML using HTML export plugin 
	// We need to setup options for HTML exporter according to current settings of EPUB exporter
	std::string htmlProps = 
	UT_std_string_sprintf("embed-css:no;html4:no;use-awml:no;declare-xml:yes;mathml-render-png:%s;split-document:%s;add-identifiers:yes;",
		m_exp_opt.bRenderMathMLToPNG ? "yes" : "no",
		m_exp_opt.bSplitDocument ? "yes" : "no");

    m_pHmtlExporter = new IE_Exp_HTML(getDoc());
    m_pHmtlExporter->suppressDialog(true);
    m_pHmtlExporter->setProps(htmlProps.c_str());
    m_pHmtlExporter->writeFile(indexPath.c_str());
 

    return UT_OK;
}
Пример #17
0
/*!  
 * Append all styles from the Psion Word Styles Section.
 */
UT_Error IE_Imp_Psion::applyStyles(const psiconv_word_styles_section style_sec)
{
	UT_UTF8String props;

	int i;
	gchar *stylename;
	psiconv_word_style style;
	UT_Error res;

	// Iterate through all defined styles.
	// Index -1 is misused to represent the default "Normal" style.
	for (i = -1; i < (int) psiconv_list_length(style_sec->styles); i++) {

		if (i == -1)
			style = style_sec->normal;
		else if (!(style = (psiconv_word_style)
		                    psiconv_list_get(style_sec->styles,i)))
			return UT_IE_IMPORTERROR;

		// Get the style paragraph and character attributes.
		props.clear();
		if ((res = getParagraphAttributes(style->paragraph,props)))
			return res;

		if ((res = getCharacterAttributes(style->character,props)))
			return res;

		// Not yet implemented: hotkey
		// Not yet implemented: built_in
		// Not yet implemented: outline_level
		// The three unimplemented features above are not yet available
		// within AbiWord.

		// Get the style name.
		if (i == -1)
			stylename = (gchar *) strdup("Normal");
		else
			stylename = prepare_style_name(style->name);
		if (!stylename)
			return UT_IE_NOMEMORY;

		UT_DEBUGMSG(("PSION: Importing style %s\n",stylename));
		UT_DEBUGMSG(("PSION: Style attributes: %s\n",props.utf8_str()));

		const PP_PropertyVector propsArray = {
			"props", props.utf8_str(),
			"name", stylename,
			// All Psion styles are based upon the Normal style
			"basedon", "Normal"
		};

		if (!(getDoc()->appendStyle(propsArray))) {
			UT_DEBUGMSG(("PSION: AppendStyle failed...\n"));
			free(stylename);
			return UT_IE_IMPORTERROR;
		}
		free(stylename);
	}
	return UT_OK;
}
Пример #18
0
bool px_ChangeHistory::getCRRange(PX_ChangeRecord * pcr,PT_DocPosition & posLow, PT_DocPosition &posHigh) const
{
	PT_DocPosition length = 0;
	length = static_cast<PT_DocPosition>(abs(getDoc()->getAdjustmentForCR(pcr)));
	posLow = pcr->getPosition();
	posHigh = posLow+length;
	return true;
}
Пример #19
0
void CShowGrafView::initScale() {
  const InitialOptions &options = getDoc()->getOptions();
  const GraphArray     &ga      = getDoc()->getGraphArray();
  DataRange             dr;
  const AxisType        xt      = theApp.getMainWindow()->getXAxisType();
  const AxisType        yt      = theApp.getMainWindow()->getYAxisType();
  if(options.m_rangeSpecified) {
    dr = options.m_explicitRange;
  } else if(ga.size() == 0) {
    dr = CCoordinateSystem::getDefaultDataRange(xt, yt);
  } else {
    dr = ga.getDataRange();
  }
  int makeSpaceFlags = ((xt == AXIS_LINEAR) ? X_AXIS : 0) | ((yt == AXIS_LINEAR) ? Y_AXIS : 0);
  m_coordinateSystem.setFromRectangle(dr, makeSpaceFlags);
  setXAxisType(xt);
  setYAxisType(yt);
}
Пример #20
0
/*!
 * Add a cell to the list of selected regions.
 */
void FV_Selection::addCellToSelection(fl_CellLayout * pCell)
{
	UT_ASSERT((m_iSelectionMode == 	FV_SelectionMode_TableColumn) 
			  || ( m_iSelectionMode == 	FV_SelectionMode_TableRow));
	PL_StruxDocHandle sdhEnd = NULL;
	PL_StruxDocHandle sdhStart = pCell->getStruxDocHandle();
	PT_DocPosition posLow = getDoc()->getStruxPosition(sdhStart) +1; // First block

	bool bres;
	bres = getDoc()->getNextStruxOfType(sdhStart,PTX_EndCell,&sdhEnd);
	PT_DocPosition posHigh = getDoc()->getStruxPosition(sdhEnd) -1;
	UT_ASSERT(bres && sdhEnd);
	PD_DocumentRange * pDocRange = new PD_DocumentRange(getDoc(),posLow,posHigh);
	m_vecSelRanges.addItem(pDocRange);
	IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
	UT_ByteBuf * pByteBuf = new UT_ByteBuf;
    if (pExpRtf)
    {
		if(posLow < posHigh)
		{
			pDocRange->m_pos1++;
			pDocRange->m_pos2++;
		}
		pExpRtf->copyToBuffer(pDocRange,pByteBuf);
		if(posLow < posHigh)
		{
			pDocRange->m_pos1--;
			pDocRange->m_pos2--;
		}
		DELETEP(pExpRtf);
    }
	m_vecSelRTFBuffers.addItem(pByteBuf);
	FV_SelectionCellProps * pCellProps = new FV_SelectionCellProps;
	UT_sint32 iLeft,iRight,iTop,iBot;
	m_pView->getCellParams(posLow,&iLeft,&iRight,&iTop,&iBot);
	UT_DEBUGMSG(("In Selection left %d right %d top %d bot %d \n",iLeft,iRight,iTop,iBot));
	pCellProps->m_iLeft = iLeft;
	pCellProps->m_iRight = iRight;
	pCellProps->m_iTop = iTop;
	pCellProps->m_iBot = iBot;
	m_vecSelCellProps.addItem(pCellProps);
	setSelectAll(false);
}
Пример #21
0
bool IE_Imp_OpenDocument::pasteFromBuffer(PD_DocumentRange * pDocRange,
				    const unsigned char * pData, 
				    UT_uint32 lenData, 
					  const char * /*szEncoding*/)
{
    UT_return_val_if_fail(getDoc() == pDocRange->m_pDoc,false);
    UT_return_val_if_fail(pDocRange->m_pos1 == pDocRange->m_pos2,false);
	
    PD_Document * newDoc = new PD_Document();
    newDoc->createRawDocument();
    IE_Imp_OpenDocument * pODImp = new IE_Imp_OpenDocument(newDoc);
    //
    // Turn pData into something that can be imported by the open documenb
    // importer.
    //
    GsfInput * pInStream =  gsf_input_memory_new((const guint8 *) pData, 
						 (gsf_off_t) lenData,
						 FALSE);
    pODImp->loadFile(newDoc, pInStream);
    // pInStream deleted after load.
    newDoc->finishRawCreation();

    // Handle RDF for the newdoc
    {
        PD_DocumentRDFHandle rdf = newDoc->getDocumentRDF();
        rdf->dumpModel("about to broadcast...");
        PD_DocumentRDFMutationHandle m = getDoc()->getDocumentRDF()->createMutation();
        m->add( rdf );
        m->commit();
    }
    
    //
    // OK Broadcast from the just filled source document into our current
    // doc via the paste listener
    //
    IE_Imp_PasteListener * pPasteListen = new  IE_Imp_PasteListener(getDoc(),pDocRange->m_pos1,newDoc);
    newDoc->tellListener(static_cast<PL_Listener *>(pPasteListen));
    delete pPasteListen;
    delete pODImp;
    UNREFP( newDoc);
    return true;
}
/*!
  Insert a Block into the document

 Uses appropriate function for clipboard or file
 */
bool IE_Imp_Text::_insertBlock()
{
	bool ret = false;
	m_bBlockDirectionPending = true;
	m_bFirstBlockData = true;
	
	if (isClipboard ()) // intentional - don't append style
						// information
	{		
		ret = appendStrux(PTX_Block, NULL);
	}
	else
	{
	    // text gets applied in the Normal style
	    const gchar * propsArray[3];
	    propsArray[0] = "style";
	    propsArray[1] = "Normal";
	    propsArray[2] = 0;

	    ret = appendStrux(PTX_Block, static_cast<const gchar **>(&propsArray[0]));
	}
	if(!isPasting())
	{
		pf_Frag * pf = getDoc()->getPieceTable()->getFragments().getLast();
		UT_return_val_if_fail( pf->getType() == pf_Frag::PFT_Strux, false);
		m_pBlock = (pf_Frag_Strux *) pf;
		UT_return_val_if_fail( m_pBlock->getStruxType() == PTX_Block, false);
	}
	else
	{
		PL_StruxDocHandle sdh = NULL;
		if(getDoc()->getStruxOfTypeFromPosition(getDocPos(), PTX_Block,&sdh))
		{
			m_pBlock = static_cast<pf_Frag_Strux *>(const_cast<void *>(sdh));
		}
		else
		{
			m_pBlock = NULL;
		}
	}
	return ret;
}
Пример #23
0
std::string IE_Exp_EPUB::getLanguage() const
{
    std::string property("");

    if (getDoc()->getMetaDataProp(PD_META_KEY_LANGUAGE, property)
            && property.size())
    {
        return property;
    }
    return "en_US";
}
Пример #24
0
std::string IE_Exp_EPUB::getTitle() const
{
    std::string property("");

    if (getDoc()->getMetaDataProp(PD_META_KEY_TITLE, property)
            && property.size())
    {
        return property;
    }
    return "Untitled";
}
Пример #25
0
std::string IE_Exp_EPUB::getAuthor() const
{
    std::string property("");

    if (getDoc()->getMetaDataProp(PD_META_KEY_CREATOR, property)
            && property.size())
    {
        return property;
    }
    return "Converted by AbiWord(http://www.abisource.com/)";
}
PL_Listener * IE_Exp_Text::_constructListener(void)
{
	if (!m_bExplicitlySetEncoding) {
		const std::string & prop = getProperty ("encoding");
		if (!prop.empty()) {
			_setEncoding (prop.c_str());
		}
	}

	return new Text_Listener(getDoc(),this,(getDocRange()!=NULL),m_szEncoding,
							 m_bIs16Bit,m_bUnicode,m_bUseBOM,m_bBigEndian);
}
Пример #27
0
bool IE_Imp_Object::pasteFromBuffer(PD_DocumentRange * pDocRange,
								  const unsigned char * pData, UT_uint32 lenData,
								  const char * /* encoding */)
{
	UT_return_val_if_fail(getDoc() == pDocRange->m_pDoc,false);
	UT_return_val_if_fail(pDocRange->m_pos1 == pDocRange->m_pos2,false);

	ImportStreamClipboard stream(pData, lenData);
	setClipboard (pDocRange->m_pos1);
	stream.init(NULL);
	_parseStream(&stream);
	return true;
}
UT_Error IE_Imp_GraphicAsDocument::_loadFile(GsfInput * input)
{
	UT_Error error;

   	UT_DEBUGMSG(("trying to open an image as a document...\n"));
   
	if (!getDoc()->appendStrux(PTX_Section, NULL) ||
	    !getDoc()->appendStrux(PTX_Block, NULL))
     		return UT_IE_NOMEMORY;
   
   	FG_Graphic* pFG;
   	error = m_pGraphicImporter->importGraphic(input, &pFG);
   	DELETEP(m_pGraphicImporter);

   	if (error != UT_OK) return error;
   
   	const UT_ByteBuf * buf;
    buf = pFG->getBuffer();

   	const gchar* propsArray[3];
   	propsArray[0] = "dataid";
   	propsArray[1] = "image_0";
   	propsArray[2] = NULL;
   
   	if (!getDoc()->appendObject(PTO_Image, propsArray)) {
	   delete pFG;
	   return UT_IE_NOMEMORY;
	}

   	if (!getDoc()->createDataItem("image_0", false,
					buf, pFG->getMimeType(), NULL)) {
	   delete pFG;
	   return UT_IE_NOMEMORY;
	}

   	delete pFG;

	return UT_OK;
}
Пример #29
0
void AP_UnixDialog_Styles::event_DeleteClicked(void)
{
	if (m_selectedStyle)
    {
		m_sNewStyleName = "";
        gchar * style = NULL;
		
		GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_tvStyles));
		GtkTreeIter iter;
		gtk_tree_model_get_iter(model, &iter, m_selectedStyle);
		gtk_tree_model_get(model, &iter, 0, &style, -1);

		if (!style)
			return; // ok, nothing's selected. that's fine

		UT_DEBUGMSG(("DOM: attempting to delete style %s\n", style));

		if (!getDoc()->removeStyle(style)) // actually remove the style
		{
			const XAP_StringSet * pSS = m_pApp->getStringSet();
			UT_UTF8String s;
			pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete,s);
			const gchar * msg = s.utf8_str();
		
			getFrame()->showMessageBox (static_cast<const char *>(msg),
										XAP_Dialog_MessageBox::b_O,
										XAP_Dialog_MessageBox::a_OK);
			return;
		}

		g_free(style);

		getFrame()->repopulateCombos();
		_populateWindowData(); // force a refresh
		getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
    }
}
Пример #30
0
void CShowGrafView::OnRButtonDown(UINT nFlags, CPoint point) {
  GraphArray &ga = getDoc()->getGraphArray();
  if(ga.OnLButtonDown(nFlags, point, m_coordinateSystem.getTransformation())) {
    CMenu menu;
    if(!menu.LoadMenu(IDR_MENUSELECTGRAF)) {
      showWarning(_T("Loadmenu failed"));
      return;
    }
    removeMenuItem(menu, ga.getSelectedItem()->getGraph().isVisible() ? ID_SELECTMENU_SHOW : ID_SELECTMENU_HIDE);
    ClientToScreen(&point);
    menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x+10,point.y, theApp.getMainWindow());
  } else {
    __super::OnRButtonDown(nFlags, point);
  }
}