Exemple #1
0
DocRange copy_range(Doc* doc,
                    const DocRange& from,
                    const DocRange& to,
                    const DocRangePlace place,
                    const TagsHandling tagsHandling)
{
  return drop_range_op(doc, Copy, from, place,
                       tagsHandling, DocRange(to));
}
DocRange CmdTransaction::calcDocRange() const
{
#ifdef ENABLE_UI
  // TODO We cannot use Context::activeSite() because it losts
  //      important information about the DocRange() (type and
  //      flags).
  if (App::instance()) {
    Timeline* timeline = App::instance()->timeline();
    if (timeline)
      return timeline->range();
  }
#endif
  return DocRange();
}
Exemple #3
0
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;
}
Exemple #4
0
void FV_Selection::pasteRowOrCol(void)
{
    pf_Frag_Strux* cellSDH, *tableSDH;
    PT_DocPosition pos = m_pView->getPoint();
    if(m_iPrevSelectionMode == FV_SelectionMode_TableColumn)
    {
//
// GLOB stuff together so it undo's in one go.
//
        getDoc()->beginUserAtomicGlob();
//
// Insert a column after the current column
//
        m_pView->cmdInsertCol(m_pView->getPoint(),false);
//
// Now do all the encapsulating stuff for piecetable manipulations.
//
        // Signal PieceTable Change
        m_pView->_saveAndNotifyPieceTableChange();

        // Turn off list updates

        getDoc()->disableListUpdates();
        if (!m_pView->isSelectionEmpty())
        {
            m_pView->_clearSelection();
        }
        getDoc()->setDontImmediatelyLayout(true);
        pos = m_pView->getPoint();
        PT_DocPosition posTable,posCell;
        UT_sint32 iLeft,iRight,iTop,iBot;
        posCell = 0;
        m_pView->getCellParams(pos, &iLeft, &iRight,&iTop,&iBot);
        bool bRes = getDoc()->getStruxOfTypeFromPosition(pos,PTX_SectionCell,&cellSDH);
        bRes = getDoc()->getStruxOfTypeFromPosition(pos,PTX_SectionTable,&tableSDH);
        UT_return_if_fail(bRes);
        posTable = getDoc()->getStruxPosition(tableSDH) + 1;
        UT_sint32 numRows = 0;
        UT_sint32 numCols = 0;
        UT_sint32 i = 0;
        getDoc()-> getRowsColsFromTableSDH(tableSDH, m_pView->isShowRevisions(), m_pView->getRevisionLevel(),
                                           &numRows, &numCols);

        PD_DocumentRange DocRange(getDoc(),posCell,posCell);
        for(i=0; i<getNumSelections(); i++)
        {
            posCell = m_pView->findCellPosAt(posTable,i,iLeft)+2;
            m_pView->setPoint(posCell);
            PD_DocumentRange * pR = getNthSelection(i);
            if(pR->m_pos1 == pR->m_pos2)
            {
//
// Dont paste empty cells
//
                continue;
            }
            UT_ByteBuf * pBuf = m_vecSelRTFBuffers.getNthItem(i);
            const unsigned char * pData = pBuf->getPointer(0);
            UT_uint32 iLen = pBuf->getLength();
            DocRange.m_pos1 = posCell;
            DocRange.m_pos2 = posCell;
            IE_Imp_RTF * pImpRTF = new IE_Imp_RTF(getDoc());
            pImpRTF->pasteFromBuffer(&DocRange,pData,iLen);
            DELETEP(pImpRTF);
            fl_SectionLayout * pSL = m_pView->getCurrentBlock()->getSectionLayout();
            pSL->checkAndAdjustCellSize();
        }
        getDoc()->endUserAtomicGlob();
        getDoc()->setDontImmediatelyLayout(false);
        m_pView->_generalUpdate();


        // restore updates and clean up dirty lists
        getDoc()->enableListUpdates();
        getDoc()->updateDirtyLists();

        // Signal PieceTable Changes have finished
        m_pView->_restorePieceTableState();
// Put the insertion point in a legal position
//
        m_pView->notifyListeners(AV_CHG_MOTION);
        m_pView->_fixInsertionPointCoords();
        m_pView->_ensureInsertionPointOnScreen();

    }
    else
    {
    }
}