コード例 #1
0
ファイル: ie_imp_EPUB.cpp プロジェクト: lokeshguddu/AbiWord
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
/*!
 * Autoupdater of the dialog.
 */
void AP_Dialog_SplitCells::autoUpdateMC(UT_Worker * pTimer)
{
	UT_return_if_fail(pTimer);
	
// this is a static callback method and does not have a 'this' pointer

	AP_Dialog_SplitCells * pDialog = static_cast<AP_Dialog_SplitCells *>(pTimer->getInstanceData());

	if (pDialog->m_bDestroy_says_stopupdating != true)
	{
		FV_View * pView = 0;
		PD_Document * pDoc = NULL;

		if (XAP_Frame * pFrame = pDialog->getApp()->getLastFocussedFrame())
		{
			pView = static_cast<FV_View *>(pFrame->getCurrentView());
		}
		if (pView)
		{
			pDoc = pView->getDocument();
		}
		if (!pView || (pDoc && !pDoc->isPieceTableChanging()))
		{
			pDialog->m_bAutoUpdate_happening_now = true;
			pDialog->setAllSensitivities();
			pDialog->m_bAutoUpdate_happening_now = false;
		}
	}
}
コード例 #3
0
ファイル: ap_UnixApp.cpp プロジェクト: lokeshguddu/AbiWord
bool AP_UnixApp::makePngPreview(const char * pszInFile, const char * pszPNGFile, UT_sint32 iWidth, UT_sint32 iHeight)
{
	cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, iWidth, iHeight);
	cairo_t *cr = cairo_create (surface);

	GR_UnixCairoAllocInfo ai(NULL, false);

	GR_CairoGraphics * pG = static_cast<GR_CairoGraphics*>(GR_UnixCairoGraphics::graphicsAllocator(ai));
	pG->setCairo(cr);
	pG->beginPaint(); // needed to avoid cairo reference loss

	UT_Error error = UT_OK;
	PD_Document * pNewDoc = new PD_Document();
	error = pNewDoc->readFromFile(pszInFile,IEFT_Unknown, NULL);

	if (error != UT_OK) 
	{
		return false;
	}
	AP_Preview_Abi * pPrevAbi = new AP_Preview_Abi(pG,iWidth,iHeight,NULL, PREVIEW_ZOOMED,pNewDoc);
	dg_DrawArgs da;
	memset(&da, 0, sizeof(da));
	da.pG = pG;
	GR_Painter * pPaint = new GR_Painter(pG);
	pPaint->clearArea(0,0,pG->tlu(iWidth),pG->tlu(iHeight));
	pPrevAbi->getView()->draw(0, &da);
	pG->endPaint();
	cairo_destroy(cr);
	DELETEP(pPaint);
	cairo_surface_write_to_png(surface, pszPNGFile);
	cairo_surface_destroy(surface);
	DELETEP(pG);
	DELETEP(pPrevAbi); // This deletes pNewDoc
	return true;
}
コード例 #4
0
bool AbiCollabSessionManager::_setupFrame(XAP_Frame** pFrame, PD_Document* pDoc)
{
	UT_return_val_if_fail(pFrame, false);
	
	if (*pFrame)
	{
		UT_DEBUGMSG(("Frame is non-NULL, NOT loading document in the frame\n"));
		return true;
	}
	
	// if the document doesn't belong to a frame already, then create a 
	// new frame for this session (except when the document in the current 
	// frame is not dirty, doesn't have a filename yet (which means it 
	// is a brand new empty document), and isn't being shared at the moment)
	XAP_Frame* pCurFrame = XAP_App::getApp()->getLastFocussedFrame();
	UT_return_val_if_fail(pCurFrame, false);

	bool isNewFrame = false;
	PD_Document * pFrameDoc = static_cast<PD_Document *>(pCurFrame->getCurrentDoc());
	if (pFrameDoc != pDoc)
	{
		if (!pFrameDoc || (pFrameDoc->getFilename().empty() && !pFrameDoc->isDirty() && !isInSession(pFrameDoc)))
		{
			// we can replace the document in this frame safely, as it is 
			// brand new, and doesn't have any contents yet
		}
		else
		{
			// the current frame has already a document loaded, let's create
			// a new frame
			pCurFrame = XAP_App::getApp()->newFrame();
			isNewFrame = true;
		}

	}
	else
    {
		UT_DEBUGMSG(("This document is already in the current frame; using this frame\n"));
    }
	
	UT_return_val_if_fail(pCurFrame, false);
	*pFrame = pCurFrame;
		
	// load the document in the frame; this will also delete the old document (or at least, it should)
	if (static_cast<PD_Document *>((*pFrame)->getCurrentDoc()) != pDoc)
	{
		UT_DEBUGMSG(("Loading the document in the frame\n"));
		(*pFrame)->loadDocument(pDoc);
	}
	else
    {
		UT_DEBUGMSG(("Not loading the document in the frame, as the frame already has it\n"));
    }
	
	if (isNewFrame)
		(*pFrame)->show();
	
	return true;
}
コード例 #5
0
PD_DocumentRDFHandle
AP_Dialog_RDFEditor::getRDF()
{
    FV_View* view = getView();
    PD_Document* doc = view->getDocument();
    PD_DocumentRDFHandle rdf = doc->getDocumentRDF();
    return rdf;
}
コード例 #6
0
bool s_abicollab_authors(AV_View* v, EV_EditMethodCallData* /*d*/)
{
	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_val_if_fail(pManager, false);
	FV_View * pView = static_cast<FV_View *>(v);
	PD_Document * pDoc = pView->getDocument();
	bool b = pDoc->isShowAuthors();
	pDoc->setShowAuthors(!b);
	return true;
}
コード例 #7
0
ファイル: fp_FieldTOCNum.cpp プロジェクト: Distrotech/abiword
bool fp_FieldTOCNumRun::calculateValue(void)
{
	UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1];
//
// First Find page number.
//
	PL_StruxDocHandle sdh = getBlock()->getStruxDocHandle();
	PD_Document * pDoc = getBlock()->getDocument();
	PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1;
	FL_DocLayout * pLayout = getBlock()->getDocLayout();
	fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos);
	if(pBlockInDoc == NULL)
	{
		sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
		sz_ucs_FieldValue[1] = 0;
		return _setValue(sz_ucs_FieldValue);
	}
	fp_Line * pLine =  static_cast<fp_Line *>(pBlockInDoc->getFirstContainer());
	if(pLine == NULL)
	{
		sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
		sz_ucs_FieldValue[1] = 0;
		return _setValue(sz_ucs_FieldValue);
	}
	fp_Page * pPage = pLine->getPage();
	UT_sint32 iPage = pLayout->findPage(pPage);
	if( iPage < 0)
	{
		sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
		sz_ucs_FieldValue[1] = 0;
		return _setValue(sz_ucs_FieldValue);
	}
	iPage++; // Start from Page 1.
	UT_String sVal("");
	FootnoteType iType = getBlock()->getTOCNumType();
	pLayout->getStringFromFootnoteVal(sVal,iPage,iType);
	const char * psz = sVal.c_str();
	bool bStop = false;
	UT_sint32 i = 0;
	sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
	for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++)
	{
		sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz);
		if(*psz == 0)
		{
			bStop = true;
		}
		else
		{
			psz++;
		}
	}
	return _setValue(sz_ucs_FieldValue);
}
コード例 #8
0
PD_RDFModelHandle
AP_Dialog_RDFEditor::getModel()
{
    if( m_restrictedModel )
        return m_restrictedModel;
    
    FV_View* view = getView();
    PD_Document* doc = view->getDocument();
    PD_DocumentRDFHandle model = doc->getDocumentRDF();
    return model;
}
コード例 #9
0
bool fp_FieldListLabelRun::calculateValue(void)
{
	UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1];
	UT_uint32 i = 0;
	UT_UCSChar *  listlabel = NULL;
	if(getBlock()->isContainedByTOC())
	{
		xxx_UT_DEBUGMSG(("!!!!!!------!!!! ListLabel in TOC!!!! \n"));
//
// First Find the block in the document.
//
		pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle();
		PD_Document * pDoc = getBlock()->getDocument();
		PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1;
		FL_DocLayout * pLayout = getBlock()->getDocLayout();
		fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos);
		if(pBlockInDoc == NULL)
		{
			sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
			sz_ucs_FieldValue[1] = 0;
			return _setValue(sz_ucs_FieldValue);
		}
		i = 0;
		listlabel = pBlockInDoc->getListLabel();

	}
	else
	{
		i = 0;
		listlabel = getBlock()->getListLabel();
	}
	if(listlabel == NULL)
	{
		sz_ucs_FieldValue[0] = 0;
	}
	else
	{
		//
		// This code is here because UT_UCS_copy_char is broken
		//
		i = 0;
		UT_uint32 len = UT_MIN( UT_UCS4_strlen(listlabel),FPFIELD_MAX_LENGTH + 1)  ;
		for(i=0; i<=len;i++)
		{
			sz_ucs_FieldValue[i] =  *listlabel++;
		}
//		sz_ucs_FieldValue[len] = 0;
//		m_sFieldValue[0] =  0; // Force an update!!!
	}
	return _setValue(sz_ucs_FieldValue);
}
コード例 #10
0
ファイル: ap_Win32App.cpp プロジェクト: lokeshguddu/AbiWord
bool AP_Win32App::_cacheClipboardDoc(PD_DocumentRange *pDocRange)
{
	UT_return_val_if_fail(m_pClipboard && pDocRange, false);

	UT_ByteBuf buf;
	UT_Error status;;
	UT_Byte b = 0;

	IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
	if (pExpRtf)
	{
		status = pExpRtf->copyToBuffer(pDocRange,&buf);

		if(status != UT_OK)
			return false;
			
		buf.append(&b,1);			// NULL terminate the string
		DELETEP(pExpRtf);
	}
	else
	{
		return false;
	}

	// now create a subdocument ...
	PD_Document * pDoc = new PD_Document();

	if(!pDoc)
		return false;
	
	pDoc->newDocument();
	
	PD_DocumentRange DocRange(pDoc, 2, 2);
	
	IE_Imp * pImp = 0;
	IE_Imp::constructImporter(pDoc, IE_Imp::fileTypeForSuffix(".rtf"),&pImp,0);

	if(pImp)
	{
		pImp->pasteFromBuffer(&DocRange,buf.getPointer(0),buf.getLength(),NULL);
		delete pImp;
	}
	else
	{
		return false;
	}
	
	m_pClipboard->setClipboardDoc(pDoc);
	return true;
}
コード例 #11
0
ファイル: AbiMathView.cpp プロジェクト: lokeshguddu/AbiWord
//
// AbiMathView_FileInsert
// -------------------
//   This is the function that we actually call to insert the MathML.
//
bool 
AbiMathView_FileInsert(AV_View* /*v*/, EV_EditMethodCallData* /*d*/)
{
	// Get the current view that the user is in.
	XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
	FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView());
	PD_Document * pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc());
	char* pNewFile = NULL;


	bool bOK = s_AskForMathMLPathname(pFrame,&pNewFile);
	
	if (!bOK || !pNewFile)
	{
		UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %s \n",bOK,pNewFile));
		return false;
	}
	UT_UTF8String sNewFile = pNewFile;

	// we own storage for pNewFile and must free it.
	FREEP(pNewFile);

	UT_DEBUGMSG(("fileInsertMathML: loading [%s]\n",sNewFile.utf8_str()));
   
	IE_Imp_MathML * pImpMathML = new IE_Imp_MathML(pDoc, pMathManager->EntityTable());
	UT_Error errorCode = pImpMathML->importFile(sNewFile.utf8_str());

	if (errorCode != UT_OK)
	{
		s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode);
		DELETEP(pImpMathML);
		return false;
	}

	/* Create the data item */
	UT_uint32 uid = pDoc->getUID(UT_UniqueId::Image);
	UT_UTF8String sUID;
	UT_UTF8String_sprintf(sUID,"%d",uid);
	pDoc->createDataItem(sUID.utf8_str(), false, pImpMathML->getByteBuf(), 
                         "application/mathml+xml", NULL);

	/* Insert the MathML Object */
	PT_DocPosition pos = pView->getPoint();
	pView->cmdInsertMathML(sUID.utf8_str(),pos);

	DELETEP(pImpMathML);

	return true;
}
コード例 #12
0
void fp_FrameContainer::setPreferedPageNo(UT_sint32 i)
{
     if(m_iPreferedPageNo == i)
       return;
     m_iPreferedPageNo =  i;
     fl_FrameLayout * pFL = static_cast<fl_FrameLayout *>(getSectionLayout());
     FL_DocLayout * pDL = pFL->getDocLayout();
     if(pDL->isLayoutFilling())
       return;
     PD_Document * pDoc = pDL->getDocument();
     UT_UTF8String sVal;
     UT_UTF8String_sprintf(sVal,"%d",i);
     const char * attr = PT_PROPS_ATTRIBUTE_NAME;
     UT_UTF8String sAttVal = "pref-page:";
     sAttVal += sVal.utf8_str();
     
     pDoc->changeStruxAttsNoUpdate(pFL->getStruxDocHandle(),attr,sAttVal.utf8_str());
}
コード例 #13
0
AbiCollab* AbiCollabSessionManager::getSessionFromDocumentId(const UT_UTF8String& sDocumentId)
{
	AbiCollab * pCollab = NULL;
	UT_sint32 i = 0;
	for(i = 0; i < m_vecSessions.getItemCount(); i++)
	{
		pCollab = m_vecSessions.getNthItem(i);
		if (pCollab)
		{
			PD_Document* pDoc = pCollab->getDocument();
			if (strcmp(pDoc->getDocUUIDString(), sDocumentId.utf8_str()) == 0)
			{
				return pCollab;
			}
		}
	}
	return NULL;
}
bool AP_UnixToolbar_StyleCombo::populate(void)
{
	// clear anything that's already there
	m_vecContents.clear();

	// populate the vector

#if 1
	// HACK: for now, just hardwire it
	// NB if you change the case of the labels, it will stop working
	// unless you also change all the places where the style appears!
	m_vecContents.addItem("Normal");
	m_vecContents.addItem("Heading 1");
	m_vecContents.addItem("Heading 2");
	m_vecContents.addItem("Heading 3");
	m_vecContents.addItem("Plain Text");
	m_vecContents.addItem("Block Text");
#else

	AD_Document * pAD_Doc = m_pFrame->getCurrentDoc();
	if(!pAD_Doc)
	{
		return false;
	}
	PD_Document *pDocument = static_cast<PD_Document *>(pAD_Doc);

	// TODO: need a view/doc pointer to get this right
	// ALSO: will need to repopulate as new styles added
	// HYP:  only call this method from shared code? 
	const char * szName;
	const PD_Style * pStyle;

	for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++)
	{
		if (pStyle && pStyle->isDisplayed()) {
			m_vecContents.addItem(szName);
		}
	}
#endif 

	return true;
}
コード例 #15
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;
}
コード例 #16
0
ファイル: ie_exp_MIF.cpp プロジェクト: lokeshguddu/AbiWord
bool s_MIF_Listener::populate(fl_ContainerLayout* /*sfh*/,
								  const PX_ChangeRecord * pcr)
{
	switch (pcr->getType())
	{
	case PX_ChangeRecord::PXT_InsertSpan:
		{
			const PX_ChangeRecord_Span * pcrs = static_cast<const PX_ChangeRecord_Span *> (pcr);

			PT_BufIndex bi = pcrs->getBufIndex();
			_outputData(m_pDocument->getPointer(bi),pcrs->getLength());

			return true;
		}

	case PX_ChangeRecord::PXT_InsertObject:
		{
#if 0
			// TODO decide how to indicate objects in MIF output.
			
			const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr);
			PT_AttrPropIndex api = pcr->getIndexAP();
			switch (pcro->getObjectType())
			{
			case PTO_Image:
				return true;

			case PTO_Field:
				return true;

				// todo: support these
			case PTO_Hyperlink:
			case PTO_Bookmark:
			  return true;

			default:
				UT_ASSERT(0);
				return false;
			}
#else
			return true;
#endif
		}

	case PX_ChangeRecord::PXT_InsertFmtMark:
		return true;

	default:
		UT_ASSERT(0);
		return false;
	}
}
コード例 #17
0
ファイル: ap_UnixApp.cpp プロジェクト: lokeshguddu/AbiWord
bool AP_UnixApp::makePngPreview(const char * pszInFile, const char * pszPNGFile, UT_sint32 iWidth, UT_sint32 iHeight)
{
	GdkPixmap*  pPixmap = gdk_pixmap_new(NULL,iWidth,iHeight,24);

	GR_UnixPixmapAllocInfo ai(pPixmap);

	GR_UnixPangoPixmapGraphics * pG = (GR_UnixPangoPixmapGraphics*) GR_UnixPangoPixmapGraphics::graphicsAllocator(ai);

	UT_Error error = UT_OK;
	PD_Document * pNewDoc = new PD_Document();
	error = pNewDoc->readFromFile(pszInFile,IEFT_Unknown, NULL);

	if (error != UT_OK) 
	{
		return false;
	}
	AP_Preview_Abi * pPrevAbi = new AP_Preview_Abi(pG,iWidth,iHeight,NULL, PREVIEW_ZOOMED,pNewDoc);
	dg_DrawArgs da;
	memset(&da, 0, sizeof(da));
	da.pG = pG;
	GR_Painter * pPaint = new GR_Painter(pG);
	pPaint->clearArea(0,0,pG->tlu(iWidth),pG->tlu(iHeight));
	pPrevAbi->getView()->draw(0, &da);
	UT_Rect r;
	r.left = 0;
	r.top = 0;
	r.width = pG->tlu(iWidth);
	r.height = pG->tlu(iHeight);
	GR_Image * pImage = pPaint->genImageFromRectangle(r);
	DELETEP(pPaint);
	static_cast<GR_UnixImage *>(pImage)->saveToPNG( pszPNGFile);
	DELETEP(pImage);
	DELETEP(pG);
	DELETEP(pPrevAbi); // This deletes pNewDoc
	return true;
}
コード例 #18
0
void AccountHandler::_handlePacket(Packet* packet, BuddyPtr buddy)
{
	// packet and buddy must always be set
	UT_return_if_fail(packet);
	UT_return_if_fail(buddy);
	
	// as must the session manager
	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_if_fail(pManager);
	
	// manager didn't handle it, see what we can do
	switch (packet->getClassType()) 
	{			
		case PCT_JoinSessionRequestEvent:
		{
			JoinSessionRequestEvent* jse = static_cast<JoinSessionRequestEvent*>(packet);
			
			// lookup session
			AbiCollab* pSession = pManager->getSessionFromSessionId(jse->getSessionId());
			UT_return_if_fail(pSession);

            // check if this buddy is allowed to access this document
            // TODO: this should be done for every session packet, not just join session packets
            if (!hasAccess(pSession->getAcl(), buddy))
            {
                // we should only reach this point if someone is brute forcing trying
                // out session IDs while not being on the ACL. Ban this uses.
                UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
                return;
            }
		
			// lookup exporter
			ABI_Collab_Export* pExport = pSession->getExport();
			UT_return_if_fail(pExport);
			
			// lookup adjusts
			const UT_GenericVector<ChangeAdjust *>* pExpAdjusts = pExport->getAdjusts();
			UT_return_if_fail(pExpAdjusts);
		
			PD_Document* pDoc = pSession->getDocument();

			// add this author to the document if we don't recognize him
			UT_sint32 iAuthorId = -1;
			UT_UTF8String buddyDescriptor = buddy->getDescriptor();
			UT_GenericVector<pp_Author*> authors = pDoc->getAuthors();
			UT_DEBUGMSG(("Scanning %d authors to see if we recognize this buddy\n", authors.getItemCount()));
			for (UT_sint32 i = 0; i < authors.getItemCount(); i++)
			{
				pp_Author* pAuthor = authors.getNthItem(i);
				UT_continue_if_fail(pAuthor);

				const gchar* szDescriptor = NULL;
				pAuthor->getProperty("abicollab-descriptor", szDescriptor);
				if (!szDescriptor)
					continue;

				if (buddyDescriptor != szDescriptor)
					continue;

				// yay, we know this author!
				iAuthorId = pAuthor->getAuthorInt();
				UT_DEBUGMSG(("Found known author with descriptior %s, id %d!\n", buddyDescriptor.utf8_str(), iAuthorId));
				break;
			}
			
			if (iAuthorId == -1)
			{
				// we don't know this author yet, create a new author object for him
				iAuthorId = pDoc->findFirstFreeAuthorInt();
				pp_Author * pA = pDoc->addAuthor(iAuthorId);
				PP_AttrProp * pPA = pA->getAttrProp();
				pPA->setProperty("abicollab-descriptor", buddyDescriptor.utf8_str());
				pDoc->sendAddAuthorCR(pA);
				UT_DEBUGMSG(("Added a new author to the documument with descriptor %s, id %d\n", buddyDescriptor.utf8_str(), iAuthorId));
			}
			
			// serialize entire document into string
			JoinSessionRequestResponseEvent jsre(jse->getSessionId(), iAuthorId);
			if (AbiCollabSessionManager::serializeDocument(pDoc, jsre.m_sZABW, false /* no base64 */) == UT_OK)
			{
				// set more document properties
				jsre.m_iRev = pDoc->getCRNumber();
				jsre.m_sDocumentId = pDoc->getDocUUIDString();
				if (pDoc->getFilename())
					jsre.m_sDocumentName = UT_go_basename_from_uri(pDoc->getFilename());
				
				// send to buddy!
				send(&jsre, buddy);
				
				// add this buddy to the collaboration session
				pSession->addCollaborator(buddy);
			}
			break;
		}
		
		case PCT_JoinSessionRequestResponseEvent:
		{
			JoinSessionRequestResponseEvent* jsre = static_cast<JoinSessionRequestResponseEvent*>( packet );
			PD_Document* pDoc = 0;
			if (AbiCollabSessionManager::deserializeDocument(&pDoc, jsre->m_sZABW, false) == UT_OK)
			{
				if (pDoc)
				{
					// NOTE: we could adopt the same document name here, but i'd
					// rather not at the moment - MARCM
					pDoc->forceDirty();
					if (jsre->m_sDocumentName.size() > 0)
					{
						gchar* fname = g_strdup(jsre->m_sDocumentName.utf8_str());
						pDoc->setFilename(fname);
					}
					// The default ownership when joining is FALSE, as that seems 
					// to make sense for the generic case. The person sharing the 
					// document by default owns the document (and is thus allowed
					// to modify the ACL).
					pManager->joinSession(jsre->getSessionId(), pDoc, jsre->m_sDocumentId, jsre->m_iRev, jsre->getAuthorId(), buddy, this, false, NULL);
				}
				else 
				{
					UT_DEBUGMSG(("AccountHandler::_handlePacket() - deserializing document failed!\n"));
				}
			}
			break;
		}
		
		case PCT_GetSessionsEvent:
		{
			GetSessionsResponseEvent gsre;
			const UT_GenericVector<AbiCollab *> sessions = pManager->getSessions();
			for (UT_sint32 i = 0; i < sessions.getItemCount(); i++)
			{
				AbiCollab* pSession = sessions.getNthItem(i);
				if (pSession && pSession->isLocallyControlled())
				{
                    // check if the buddy has access to this session
                    if (!hasAccess(pSession->getAcl(), buddy))
                    {
                        UT_DEBUGMSG(("Buddy %s denied access to session %s by ALC\n", buddy->getDescriptor(true).utf8_str(), pSession->getSessionId().utf8_str()));
                        continue;
                    }

					const PD_Document * pDoc = pSession->getDocument();
                    UT_continue_if_fail(pDoc);

                    // determine name
					UT_UTF8String documentBaseName;
					if (pDoc->getFilename())
						documentBaseName = UT_go_basename_from_uri(pDoc->getFilename());
					// set session info
					gsre.m_Sessions[ pSession->getSessionId() ] = documentBaseName;
				}
			}
			send(&gsre, buddy);
			break;
		}
		
		case PCT_GetSessionsResponseEvent:
		{
			GetSessionsResponseEvent* gsre = static_cast<GetSessionsResponseEvent*>( packet );
			UT_GenericVector<DocHandle*> vDocHandles;
			for (std::map<UT_UTF8String,UT_UTF8String>::iterator it=gsre->m_Sessions.begin(); it!=gsre->m_Sessions.end(); ++it) {
				DocHandle* pDocHandle = new DocHandle((*it).first, (*it).second);
				vDocHandles.addItem(pDocHandle);
			}
			pManager->setDocumentHandles(buddy, vDocHandles);
			break;
		}
		
		default:
		{
			UT_DEBUGMSG(("Unhandled packet class: 0x%x\n", packet->getClassType()));
			UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
			break;
		}
	}
}
コード例 #19
0
ファイル: fp_FieldTOCNum.cpp プロジェクト: tanya-guza/abiword
bool fp_FieldTOCNumRun::calculateValue(void)
{
    UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1];
//
// First Find page number.
//
    pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle();
    PD_Document * pDoc = getBlock()->getDocument();
    PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1;
    FL_DocLayout * pLayout = getBlock()->getDocLayout();
    fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos);
    if(pBlockInDoc == NULL)
    {
        sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
        sz_ucs_FieldValue[1] = 0;
        return _setValue(sz_ucs_FieldValue);
    }
    fp_Line * pLine =  static_cast<fp_Line *>(pBlockInDoc->getFirstContainer());
    UT_sint32 kk = 0;
    bool b_goodLine = false;
    while (pLine && !b_goodLine)
    {
        for (kk = 0; kk < pLine->getNumRunsInLine(); kk++)
        {
            if(pLine->getRunFromIndex(kk)->getType() == FPRUN_TEXT)
            {
                b_goodLine = true;
                break;
            }
        }
        if (!b_goodLine)
        {
            pLine = static_cast<fp_Line *>(pLine->getNext());
        }
    }
    if(pLine == NULL)
    {
        sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
        sz_ucs_FieldValue[1] = 0;
        return _setValue(sz_ucs_FieldValue);
    }

    fp_Page * pPage = pLine->getPage();
    UT_sint32 iPage = pPage->getFieldPageNumber();
    bool b_hasSetFieldPageNumber = false;
    if(iPage < 0)
    {
        pPage->resetFieldPageNumber();
        iPage = pPage->getFieldPageNumber();
        b_hasSetFieldPageNumber = true;
        if (iPage < 0)
        {
            sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
            sz_ucs_FieldValue[1] = 0;
            return _setValue(sz_ucs_FieldValue);
        }
    }
    UT_String sVal("");
    FootnoteType iType = getBlock()->getTOCNumType();
    pLayout->getStringFromFootnoteVal(sVal,iPage,iType);
    const char * psz = sVal.c_str();

    if (b_hasSetFieldPageNumber)
    {
        // We need to set the field page number value to -1 so that we
        // recalculate the page number next time we enter this function
        pPage->setFieldPageNumber(-1);
    }
    bool bStop = false;
    UT_sint32 i = 0;
    sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' ');
    for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++)
    {
        sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz);
        if(*psz == 0)
        {
            bStop = true;
        }
        else
        {
            psz++;
        }
    }
    return _setValue(sz_ucs_FieldValue);
}
コード例 #20
0
bool fp_FieldTableSumCols::calculateValue(void)
{
	FV_View * pView = _getView();
	pf_Frag_Strux* tableSDH= NULL;
	UT_sint32 numRows =0;
	UT_sint32 numCols = 0;
	bUseCurrency = false;
	cCurrency = '$';
	pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle();
	PD_Document * pDoc = getBlock()->getDocument();
	if(pDoc->isPieceTableChanging())
	{
		return false;
	}
	if(getLine() == NULL)
	{
		return false;
	}
	fp_Container * pCol = getLine()->getColumn();
	if(pCol == NULL)
	{
		return false;
	}
	fp_ShadowContainer * pShad =NULL;
	fl_HdrFtrShadow * pShadL = NULL;
	if(pCol->getContainerType() == FP_CONTAINER_COLUMN_SHADOW)
	{
		pShad = static_cast<fp_ShadowContainer *>(pCol);
		pShadL = pShad->getShadow();
	}
	PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1;
	pDoc->getStruxOfTypeFromPosition(pos,PTX_SectionTable,&tableSDH);
	pDoc-> getRowsColsFromTableSDH(tableSDH, pView->isShowRevisions(), pView->getRevisionLevel(), &numRows, &numCols);

	UT_UTF8String sValF;
	if(!pView->isInTable(pos))
	{
		sValF = "???";
		return _setValue(sValF.ucs4_str().ucs4_str());
	}

	fl_CellLayout * pCell = NULL;
	UT_sint32 myLeft,myRight,myTop,myBot;
	pView->getCellParams(pos,&myLeft,&myRight,&myTop,&myBot);
	UT_sint32 col = 0;
	UT_sint32 row = myTop;
	UT_sint32 lastCol = -1;
	double dSum = 0.0;
	for(col = 0; col < numCols; col++)
	{
		pf_Frag_Strux* sdhCell = pDoc->getCellSDHFromRowCol(tableSDH,true,99999,row,col);
		UT_sint32 i = getBlock()->getDocLayout()->getLID();
		fl_ContainerLayout* fmtCell = pDoc->getNthFmtHandle(sdhCell,i);
		pCell = static_cast<fl_CellLayout *>(fmtCell);
		if(pCell->getLeftAttach() == lastCol)
		{
			continue;
		}
		if((pCell->getTopAttach() == myTop) && (pCell->getLeftAttach() == myLeft))
		{
			continue;
		}
		UT_GrowBuf grText;
		pCell->appendTextToBuf(grText);
		if(grText.getLength() == 0)
		{
			fl_ContainerLayout * pC = pCell->getFirstLayout();
			while(pC)
			{
				if(pC->getContainerType() == FL_CONTAINER_BLOCK)
				{
					fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pC);
					if(pShadL)
					{
						pBL = static_cast<fl_BlockLayout *>(pShadL->findMatchingContainer(pBL));
					}
					if(pBL == NULL)
					{
						continue;
					}
					fp_Run * pRun = pBL->getFirstRun();
					while(pRun)
					{
						if(pRun->getType() == FPRUN_FIELD)
						{
							fp_FieldRun * pFRun = static_cast<fp_FieldRun *>(pRun);
							const  UT_UCS4Char * szVal = pFRun->getValue(); 
							sValF.clear();
							sValF.appendUCS4(szVal);
							dSum += dGetVal(sValF.utf8_str());
							pRun = NULL;
							pC = NULL;
							break;
						}
						pRun = pRun->getNextRun();
					}
				}
				if(pC)
				{
					pC = pC->getNext();
				}
			}
		}
		else
		{
			sValF.clear();
			sValF.appendUCS4(reinterpret_cast<const UT_UCS4Char *>(grText.getPointer(0)),grText.getLength());
			dSum += dGetVal(sValF.utf8_str());
		}
		lastCol = col;
	}
	sFormatDouble(sValF,dSum);
	return _setValue(sValF.ucs4_str().ucs4_str());
}
bool AP_UnixToolbar_StyleCombo::repopulate(void)
{
	// repopulate the vector from the current document
    // If ithere is one present

	AD_Document * pAD_Doc = m_pFrame->getCurrentDoc();
	if(!pAD_Doc)
	{
		return false;
	}

	PD_Document *pDocument = static_cast<PD_Document *>(pAD_Doc);

	GR_GraphicsFactory * pGF = XAP_App::getApp()->getGraphicsFactory();
	if(!pGF)
	{
		return false;
	}

	// clear anything that's already there
	m_vecContents.clear();
	freeStyles();

	// defaults for style combo
	if (m_pDefaultDesc == NULL)
	{
		// for now this is hardcoded
		m_pDefaultDesc = pango_font_description_new ();
		pango_font_description_set_family (m_pDefaultDesc, "Times");
		pango_font_description_set_size (m_pDefaultDesc, 12 * PANGO_SCALE);
	}

	const char * szName;
	const PD_Style * pStyle;
	GSList *list = NULL;

	for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++)
	{
		if (!pStyle) {
			UT_DEBUGMSG(("no style instance for '%s'\n", szName));
		}

		if (!pStyle->isDisplayed() && 
		    !(dynamic_cast<const PD_BuiltinStyle *>(pStyle) && pStyle->isList() && pStyle->isUsed())) {
			continue;
		}

		list = g_slist_prepend (list, (char *)szName);

		/* wysiwyg styles are disabled for now 
		PangoFontDescription *desc = pango_font_description_copy (m_pDefaultDesc);
		getPangoAttrs(pStyle, desc);
		m_mapStyles.insert(szName, desc);
		*/
	}

	// Ok, it's a bit hackish to put them in a list for sorting first
	// but somehow the vector's qsort totally failed for me
	if (list) 
	{
		list = g_slist_sort(list, (GCompareFunc)sort_cb);		
		do 
		{
			m_vecContents.addItem((const char *)list->data);

		} while (NULL != (list = g_slist_next(list)));
		g_slist_free(list);
	}		

	return true;
}
コード例 #22
0
ファイル: pd_Iterator.cpp プロジェクト: lokeshguddu/AbiWord
/*!     
    \param doc - the document which we want to iterate
    \param dpos - document position we want to start from
*/
PD_DocIterator::PD_DocIterator(const PD_Document &doc, PT_DocPosition dpos)
	: m_pt(*doc.getPieceTable()), m_pos(dpos), m_max_pos(0xffffffff), m_frag(NULL), m_status(UTIter_OK)
{
	// find the frag at requested postion
	_findFrag();
}
コード例 #23
0
/*!
 * This method copies the selection defined by pDocRange to ODT format
 * placed in the ByteBuf bufODT
 */
UT_Error IE_Exp_OpenDocument::copyToBuffer(PD_DocumentRange * pDocRange,UT_ByteBuf *  bufODT)
{
    //
    // First export selected range to a tempory document
    //
    PD_Document * outDoc = new PD_Document();
    outDoc->createRawDocument();
    IE_Exp_DocRangeListener * pRangeListener = new IE_Exp_DocRangeListener(pDocRange,outDoc);
    UT_DEBUGMSG(("DocumentRange low %d High %d \n",pDocRange->m_pos1,pDocRange->m_pos2));
    PL_ListenerCoupleCloser* pCloser = new PL_ListenerCoupleCloser();
    pDocRange->m_pDoc->tellListenerSubset(pRangeListener,pDocRange,pCloser);
    if( pCloser)
        delete pCloser;
    
    //
    // Grab the RDF triples while we are copying...
    //
    if( PD_DocumentRDFHandle outrdf = outDoc->getDocumentRDF() )
    {

        std::set< std::string > xmlids;
        PD_DocumentRDFHandle inrdf = pDocRange->m_pDoc->getDocumentRDF();
        inrdf->addRelevantIDsForRange( xmlids, pDocRange );

        if( !xmlids.empty() )
        {
            UT_DEBUGMSG(("MIQ: ODF export creating restricted RDF model xmlids.sz:%ld \n",(long)xmlids.size()));
            PD_RDFModelHandle subm = inrdf->createRestrictedModelForXMLIDs( xmlids );
            PD_DocumentRDFMutationHandle m = outrdf->createMutation();
            m->add( subm );
            m->commit();
            subm->dumpModel("copied rdf triples subm");
            outrdf->dumpModel("copied rdf triples result");
        }
        
        // PD_DocumentRDFMutationHandle m = outrdf->createMutation();
        // m->add( PD_URI("http://www.example.com/foo"),
        //         PD_URI("http://www.example.com/bar"),
        //         PD_Literal("copyToBuffer path") );
        // m->commit();
    }
    outDoc->finishRawCreation();
    //
    // OK now we have a complete and valid document containing our selected 
    // content. We export this to an in memory GSF buffer
    //
    IE_Exp * pNewExp = NULL; 
    char *szTempFileName = NULL;
    GError *err = NULL;
    g_file_open_tmp ("XXXXXX", &szTempFileName, &err);
    GsfOutput * outBuf =  gsf_output_stdio_new (szTempFileName,&err);
    IEFileType ftODT = IE_Exp::fileTypeForMimetype("application/vnd.oasis.opendocument.text");
    UT_Error aerr = IE_Exp::constructExporter(outDoc,outBuf,
					     ftODT,&pNewExp);
    if(pNewExp == NULL)
    {
         return aerr;
    }
    aerr = pNewExp->writeFile(szTempFileName);
    if(aerr != UT_OK)
    {
	delete pNewExp;
	delete pRangeListener;
	UNREFP( outDoc);
	g_remove(szTempFileName);
	g_free (szTempFileName);
	return aerr;
    }
    //
    // File is closed at the end of the export. Open it again.
    //

    GsfInput *  fData = gsf_input_stdio_new(szTempFileName,&err);
    UT_DebugOnly<UT_sint32> siz = gsf_input_size(fData);
    const UT_Byte * pData = gsf_input_read(fData,gsf_input_size(fData),NULL);
    UT_DEBUGMSG(("Writing %d bytes to clipboard \n", (UT_sint32)siz));
    bufODT->append( pData, gsf_input_size(fData));
    
    delete pNewExp;
    delete pRangeListener;
    UNREFP( outDoc);
    g_remove(szTempFileName);
    g_free (szTempFileName);
    return aerr;
}
コード例 #24
0
/*!
 * Return the nested List level of this structure.
 */
UT_sint32 fl_ContainerLayout::getLevelInList(void)
{
      fl_BlockLayout * pBList = NULL;
      if(getContainerType() == FL_CONTAINER_BLOCK)
      {
	   pBList = static_cast<fl_BlockLayout * >(this);
      }
      else
      {
	   pBList = getPrevBlockInDocument();
      }
      UT_sint32 iLevel = 0;
      bool bLoop = true;
      while(pBList && bLoop)
      {
	  while(pBList && !pBList->isListItem())
	  {
	       pBList = pBList->getPrevBlockInDocument();
	  }
	  if(pBList == NULL)
	  {
	       bLoop = false;
	       break;
	  }
	  const PP_AttrProp * pAP = NULL;
	  pBList->getAP(pAP);
	  const gchar * szLid=NULL;
	  UT_uint32 id=0;

	  if (!pAP || !pAP->getAttribute(PT_LISTID_ATTRIBUTE_NAME, szLid))
	       szLid = NULL;
	  if (szLid)
	  {
	       id = atoi(szLid);
		
	  }
	  else
	  {
		id = 0;
	  }
	  if(id == 0)
	  {
	        bLoop = false;
	        break;
	  }
	  PD_Document * pDoc = getDocLayout()->getDocument();
	  fl_AutoNum * pAuto = pDoc->getListByID( id);
	  if(pAuto->getLastItem() == pBList->getStruxDocHandle())
	  {
	        if(pAuto->getLastItem() == getStruxDocHandle())
		{
		     iLevel = pAuto->getLevel();
		     bLoop = false;
		     break;
		}
	        iLevel = pAuto->getLevel() -1;
		if(iLevel < 0)
		{
		      iLevel = 0;
		}
	  }
	  else
	  {
	        if(pBList == this)
	        { 
		      iLevel = pAuto->getLevel();
		}
		else
		{
		      iLevel = pAuto->getLevel() + 1;
		}
	  }
	  bLoop = false;
	  break;
      }
      return iLevel;
}
コード例 #25
0
void AP_Dialog_FormatFrame::setCurFrameProps(void)
{
	XAP_Frame * frame = m_pApp->getLastFocussedFrame();
	if (!frame) {
		if (m_bSensitive) {
			m_bSensitive = false;
			setAllSensitivities();
		}
		return;
	}

	FV_View * pView = static_cast<FV_View *>(frame->getCurrentView());
	if (!pView) {
		if (m_bSensitive) {
			m_bSensitive = false;
			setAllSensitivities();
		}
		return;
	}

	PT_DocPosition pos = pView->getPoint();

	if (/* m_bSettingsChanged || */ m_iOldPos == pos) {
		// comparing the actual cell pos would be even better; but who cares :)
		return;
	}
	m_iOldPos = pos;

	if (!pView->isInFrame(pos)) {
		if (m_bSensitive) {
			m_bSensitive = false;
			setAllSensitivities();
		}
		return;
	}

	m_bLineToggled = false;

	m_borderLineStyleRight  = LS_NORMAL;
	m_borderLineStyleLeft   = LS_NORMAL;
	m_borderLineStyleTop    = LS_NORMAL;
	m_borderLineStyleBottom = LS_NORMAL;

	UT_RGBColor black(0,0,0);
	UT_RGBColor white(255,255,255);

	m_borderColor = black;

	m_borderColorRight  = black;
	m_borderColorLeft   = black;
	m_borderColorTop    = black;
	m_borderColorBottom = black;

	m_borderThicknessRight  = 1.0f;
	m_borderThicknessLeft   = 1.0f;
	m_borderThicknessTop    = 1.0f;
	m_borderThicknessBottom = 1.0f;

	m_sBorderThickness = "1.00pt",
 
	m_sBorderThicknessRight  = "1.00pt";
	m_sBorderThicknessLeft   = "1.00pt";
	m_sBorderThicknessTop    = "1.00pt";
	m_sBorderThicknessBottom = "1.00pt";

	m_backgroundColor = white;

	m_bSetWrapping = false;

	m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK;

	PD_Document * pDoc = pView->getDocument();

	PL_StruxDocHandle sdh;

	m_bSensitive = false;

	if (pDoc->getStruxOfTypeFromPosition(pos, PTX_SectionFrame, &sdh))
		if (PT_AttrPropIndex api = pDoc->getAPIFromSDH(sdh)) {
			const PP_AttrProp * pAP = 0;
			if (pDoc->getAttrProp(api, &pAP))
				if (pAP) {
					m_bSensitive = true;

#define REPLACE_CELL_PROPERTY(X) \
	do { \
		const gchar * prop = 0; \
		if (pAP->getProperty(X, prop)) \
			m_vecProps.addOrReplaceProp(X, prop); \
		else \
			m_vecProps.removeProp(X); \
	} while (0)

					REPLACE_CELL_PROPERTY("right-style");
					REPLACE_CELL_PROPERTY("left-style");
					REPLACE_CELL_PROPERTY("top-style");
					REPLACE_CELL_PROPERTY("bot-style");

					REPLACE_CELL_PROPERTY("right-thickness");
					REPLACE_CELL_PROPERTY("left-thickness");
					REPLACE_CELL_PROPERTY("top-thickness");
					REPLACE_CELL_PROPERTY("bot-thickness");

					REPLACE_CELL_PROPERTY("right-color");
					REPLACE_CELL_PROPERTY("left-color");
					REPLACE_CELL_PROPERTY("top-color");
					REPLACE_CELL_PROPERTY("bot-color");

					REPLACE_CELL_PROPERTY("background-color");

					REPLACE_CELL_PROPERTY("wrap-mode");
					REPLACE_CELL_PROPERTY("position-to");
				}
		}
	if (!m_bSensitive) {
		setAllSensitivities();
		return;
	}

	if(pView->isImageAtStrux(m_iOldPos,PTX_SectionFrame))
	{
		if(true /* pView->isInFrame(pView->getPoint()) */)
		{
			fl_BlockLayout * pBL = pView->getCurrentBlock();
			fl_FrameLayout * pFrame = static_cast<fl_FrameLayout *>(pBL->myContainingLayout());
			if(pFrame->getContainerType() != FL_CONTAINER_FRAME)
			{
				UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
				DELETEP(m_pGraphic);
				DELETEP(m_pImage);
				m_sImagePath.clear();
			}
			else
			{
				FG_Graphic * pFG = FG_GraphicRaster::createFromStrux(pFrame);
				if(pFG)
				{
					DELETEP(m_pGraphic);
					DELETEP(m_pImage);
					m_sImagePath.clear();
					m_pGraphic = pFG;
					m_sImagePath = pFG->getDataId();

					GR_Graphics * pG = m_pFormatFramePreview->getGraphics();
                    m_pImage = _makeImageForRaster(m_sImagePath, pG, m_pGraphic);
				}
			}
		}
		else
		{
			DELETEP(m_pGraphic);
			DELETEP(m_pImage);
			m_sImagePath.clear();
		}
	}
	else
	{
		DELETEP(m_pGraphic);
		DELETEP(m_pImage);
		m_sImagePath.clear();
	}

	UT_String bstmp = UT_String_sprintf("%d", FS_FILL);
	m_vecProps.addOrReplaceProp("bg-style", bstmp.c_str()); // FIXME ??
		
	const gchar * pszStyle = 0;
	m_vecProps.getProp("background-color", pszStyle);
	if (pszStyle) {
		m_backgroundColor.setColor(pszStyle);
	}

	/* update border properties
	 */
	long linestyle;

	pszStyle = 0;
	m_vecProps.getProp("right-style", pszStyle);
	if (pszStyle) {
		linestyle = LS_NORMAL;
		sscanf(pszStyle, "%ld", &linestyle);
		m_borderLineStyleRight = linestyle;
	}
	pszStyle = 0;
	m_vecProps.getProp("left-style", pszStyle);
	if (pszStyle) {
		linestyle = LS_NORMAL;
		sscanf(pszStyle, "%ld", &linestyle);
		m_borderLineStyleLeft = linestyle;
	}
	pszStyle = 0;
	m_vecProps.getProp("top-style", pszStyle);
	if (pszStyle) {
		linestyle = LS_NORMAL;
		sscanf(pszStyle, "%ld", &linestyle);
		m_borderLineStyleTop = linestyle;
	}
	pszStyle = 0;
	m_vecProps.getProp("bot-style", pszStyle);
	if (pszStyle) {
		linestyle = LS_NORMAL;
		sscanf(pszStyle, "%ld", &linestyle);
		m_borderLineStyleBottom = linestyle;
	}

	pszStyle = 0;
	m_vecProps.getProp("right-color", pszStyle);
	if (pszStyle) {
		m_borderColorRight.setColor(pszStyle);
	}
	pszStyle = 0;
	m_vecProps.getProp("left-color", pszStyle);
	if (pszStyle) {
		m_borderColorLeft.setColor(pszStyle);
	}
	pszStyle = 0;
	m_vecProps.getProp("top-color", pszStyle);
	if (pszStyle) {
		m_borderColorTop.setColor(pszStyle);
	}
	pszStyle = 0;
	m_vecProps.getProp("bot-color", pszStyle);
	if (pszStyle) {
		m_borderColorBottom.setColor(pszStyle);
	}

	UT_UTF8String thickness;

	pszStyle = 0;
	m_vecProps.getProp("right-thickness", pszStyle);
	if (pszStyle) {
		thickness = pszStyle;
		setBorderThicknessRight(thickness);
	}
	pszStyle = 0;
	m_vecProps.getProp("left-thickness", pszStyle);
	if (pszStyle) {
		thickness = pszStyle;
		setBorderThicknessLeft(thickness);
	}
	pszStyle = 0;
	m_vecProps.getProp("top-thickness", pszStyle);
	if (pszStyle) {
		thickness = pszStyle;
		setBorderThicknessTop(thickness);
	}
	pszStyle = 0;
	m_vecProps.getProp("bot-thickness", pszStyle);
	if (pszStyle) {
		thickness = pszStyle;
		setBorderThicknessBottom(thickness);
	}

	/* update wrap properties
	 */
	pszStyle = 0;
	m_vecProps.getProp("wrap-mode", pszStyle);
	if (pszStyle) {
		if (strcmp (pszStyle, "wrapped-both") == 0) {
			m_bSetWrapping = true;
		}
	}

	/* update position properties
	 */
	pszStyle = 0;
	m_vecProps.getProp("position-to", pszStyle);
	if (pszStyle) {
		if (strcmp (pszStyle, "block-above-text") == 0) {
			m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK;
		}
		else if (strcmp (pszStyle, "column-above-text") == 0) {
			m_iFramePositionTo = FL_FRAME_POSITIONED_TO_COLUMN;
		}
		else if (strcmp (pszStyle, "page-above-text") == 0) {
			m_iFramePositionTo = FL_FRAME_POSITIONED_TO_PAGE;
		}
	}

	/* draw the preview with the changed properties
	 */
	if(m_pFormatFramePreview) {
		m_pFormatFramePreview->draw();
	}

	m_bSettingsChanged = false;
	setActiveFrame(frame); // this is just to trigger the subclass to update the dialog
}
コード例 #26
0
ファイル: ap_App.cpp プロジェクト: lokeshguddu/AbiWord
AP_App::AP_App (HINSTANCE hInstance, const char * szAppName)
  : XAP_App_BaseClass ( hInstance, szAppName )
#else
AP_App::AP_App (const char * szAppName)
  : XAP_App_BaseClass ( szAppName )
#endif
{
}

AP_App::~AP_App ()
{
}

/*!
 *  Open windows requested on commandline.
 * 
 * \return False if an unknown command line option was used, true
 * otherwise.  
 */
bool AP_App::openCmdLineFiles(const AP_Args * args)
{
	int kWindowsOpened = 0;
	const char *file = NULL;

	if (AP_Args::m_sFiles == NULL) {
		// no files to open, this is ok
		XAP_Frame * pFrame = newFrame();
		pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
		return true;
	}

	int i = 0;
	while ((file = AP_Args::m_sFiles[i++]) != NULL) {
		char * uri = NULL;

		uri = UT_go_shell_arg_to_uri (file);

		XAP_Frame * pFrame = newFrame();

		UT_Error error = pFrame->loadDocument (uri, IEFT_Unknown, true);
		g_free (uri);

		if (UT_IS_IE_SUCCESS(error))
		{
			kWindowsOpened++;
			if (error == UT_IE_TRY_RECOVER) {
				pFrame->showMessageBox(AP_STRING_ID_MSG_OpenRecovered,
                           XAP_Dialog_MessageBox::b_O,
                           XAP_Dialog_MessageBox::a_OK);
			}
		}
		else
		{
			// TODO we crash if we just delete this without putting something
			// TODO in it, so let's go ahead and open an untitled document
			// TODO for now.  this would cause us to get 2 untitled documents
			// TODO if the user gave us 2 bogus pathnames....

			// Because of the incremental loader, we should not crash anymore;
			// I've got other things to do now though.
			kWindowsOpened++;
			pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
			pFrame->raise();

			errorMsgBadFile (pFrame, file, error);
		}

		if (args->m_sMerge) {
			PD_Document * pDoc = static_cast<PD_Document*>(pFrame->getCurrentDoc());
			pDoc->setMailMergeLink(args->m_sMerge);
		}
	}

	if (kWindowsOpened == 0)
	{
		// no documents specified or openable, open an untitled one
		
		XAP_Frame * pFrame = newFrame();
		pFrame->loadDocument((const char *)NULL, IEFT_Unknown);
		if (args->m_sMerge) {
			PD_Document * pDoc = static_cast<PD_Document*>(pFrame->getCurrentDoc());
			pDoc->setMailMergeLink(args->m_sMerge);
		}
	}

	return true;
}
コード例 #27
0
ファイル: ie_imp_EPUB.cpp プロジェクト: lokeshguddu/AbiWord
UT_Error IE_Imp_EPUB::readStructure()
{
    getDoc()->createRawDocument();
    getDoc()->finishRawCreation();

    for (std::vector<std::string>::iterator i = m_spine.begin(); i
            != m_spine.end(); i++)
    {
        std::map<std::string, std::string>::iterator iter =
                m_manifestItems.find(*i);

        if (iter == m_manifestItems.end())
        {
            UT_DEBUGMSG(("Manifest item with id %s not found\n", (*i).c_str()));
            return UT_ERROR;
        }
	std::string itemPath = m_tmpDir + G_DIR_SEPARATOR_S + (iter->second);
        PT_DocPosition posEnd = 0;
        getDoc()->getBounds(true, posEnd);

        if (i != m_spine.begin())
        {
            getDoc()->insertStrux(posEnd, PTX_Section, NULL, NULL);
            getDoc()->insertStrux(posEnd+1, PTX_Block, NULL, NULL);
            posEnd+=2;
        }

        GsfInput* itemInput = UT_go_file_open(itemPath.c_str(), NULL);
        if (itemInput == NULL)
        {
            UT_DEBUGMSG(("Can`t open item for reading\n"));
            return UT_ERROR;
        }

        PD_Document *currentDoc = new PD_Document();
        currentDoc->createRawDocument();
        const char *suffix = strchr(itemPath.c_str(), '.');
        XAP_App::getApp()->getPrefs()->setIgnoreNextRecent();
        if (currentDoc->importFile(itemPath.c_str(),
                IE_Imp::fileTypeForSuffix(suffix), true, false, NULL) != UT_OK)
        {
            UT_DEBUGMSG(("Failed to import file %s\n", itemPath.c_str()));
            return UT_ERROR;
        }

        currentDoc->finishRawCreation();
        // const gchar * attributes[3] = {
        //     "listid",
        //     "0",
        //     0
        // };

        // PT_DocPosition pos;
        // currentDoc->getBounds(true, pos);
        // currentDoc->insertStrux(pos, PTX_Block, attributes, NULL, NULL);

        IE_Imp_PasteListener * pPasteListener = new IE_Imp_PasteListener(
                getDoc(), posEnd, currentDoc);
        currentDoc->tellListener(static_cast<PL_Listener *> (pPasteListener));


        DELETEP(pPasteListener);
        UNREFP(currentDoc);
        g_object_unref(G_OBJECT(itemInput));
    }

    return UT_OK;
}