Пример #1
0
void KWDocStructTextFrameItem::speakItem()
{
    KoTextParag* textParag = 0;
    KoTextParag* lastParag = 0;
    int index = 0;
    // Get upper left corner of the frame and get coordinates just inside it.
    KoPoint dPoint = m_frame->topLeft() + KoPoint(2,2);
    // Get the first paragraph of the frame.
    m_frameset->findPosition(dPoint, textParag, index);
    // Get lower right corner of the frame and get coordinate just inside it.
    dPoint = m_frame->bottomRight() - KoPoint(2,2);
    // Get the last paragraph of the frame.
    m_frameset->findPosition(dPoint, lastParag, index);
    bool first = true;
    if (textParag && lastParag) {
        while (textParag) {
            KWTextParag* parag = dynamic_cast<KWTextParag *>(textParag);
            if (parag) {
                // Don't speak an empty paragraph.
                QString text = parag->toString().stripWhiteSpace();
                if ( text.length() > 0) {
                    kospeaker->queueSpeech(text, parag->paragraphFormat()->language(), first);
                    first = false;
                }
            }
            if (textParag == lastParag)
                textParag = 0;
            else
                textParag = textParag->next();
        }
        kospeaker->startSpeech();
    }
}
Пример #2
0
void KWDocStructTextFrameItem::editItem()
{
    KoTextParag* parag = 0L;
    int index = 0;
    // Get upperleft corner of the frame and get coordinates just inside it.
    KoPoint dPoint = m_frame->topLeft() + KoPoint(2,2);
    m_frameset->findPosition(dPoint, parag, index);
    gui()->canvasWidget()->editTextFrameSet(m_frameset, parag, 0);
}
Пример #3
0
void KWordViewIface::insertPictureFromFile( QString fileName, double x, double y, int w, int h )
{
    view->getGUI()->canvasWidget()->insertPictureDirect( picture( fileName ), KoPoint( x, y ), QSize(w, h) );
}
Пример #4
0
void SelectTool::continueResizing(const QPoint &pos, bool ignoreGridGuides)
{
  KivioCanvas* canvas = view()->canvasWidget();
  KoPoint pagePoint = canvas->mapFromScreen(pos);
  
  if(!ignoreGridGuides) {
    pagePoint = canvas->snapToGridAndGuides( pagePoint );
  }
  
  KivioSelectDragData *pData = m_lstOldGeometry.first();

/*  QWMatrix m;
  double w2 = m_pResizingStencil->w() / 2.0;
  double h2 = m_pResizingStencil->h() / 2.0;
  m.translate(m_pResizingStencil->x(), m_pResizingStencil->y());
  m.translate(m_pResizingStencil->pinPoint().x(), m_pResizingStencil->pinPoint().y());
  m.rotate(-m_pResizingStencil->rotation());
  m.translate(-m_pResizingStencil->pinPoint().x(), -m_pResizingStencil->pinPoint().y());
  m.translate(-m_pResizingStencil->x(), -m_pResizingStencil->y());
  m.invert();
  
  double x = pagePoint.x() * m.m11() + pagePoint.y() * m.m21() + m.dx();
  double y = pagePoint.x() * m.m12() + pagePoint.y() * m.m22() + m.dy();*/
  
  if( !pData )
  {
      kdDebug(43000) << "SelectTool::continueResizing() - Original geometry not found" << endl;
      return;
  }

  double dx = pagePoint.x() - m_origPoint.x();
  double dy = pagePoint.y() - m_origPoint.y();
      
  if((dx > 0) || (dy > 0) || (dx < 0) || (dy < 0)) { // Do we really need to redraw?
    // Undraw the old outline
    if(!m_firstTime) {
      canvas->drawStencilXOR( m_pResizingStencil );
    } else {
      m_pResizingStencil->setHidden(true);
      canvas->repaint();
      m_firstTime = false;
    }
  
    double sx = pData->rect.x();
    double sy = pData->rect.y();
    double sw = pData->rect.width();
    double sh = pData->rect.height();
    double ratio = sw / sh;
  
    switch( m_resizeHandle )
    {
      case 1: // top left
        if( m_pResizingStencil->protection()->testBit( kpWidth )==false &&
          m_pResizingStencil->protection()->testBit( kpHeight )==false )
        {
          if((dx > dy) && (dx != 0)) {
            dy = dx / ratio;
          } else {
            dx = dy * ratio;
          }
  
          m_pResizingStencil->setX( sx + dx );
          m_pResizingStencil->setW( sw - dx );
  
          m_pResizingStencil->setY( sy + dy );
          m_pResizingStencil->setH( sh - dy );
        }
        break;
  
      case 2: // top
        if( m_pResizingStencil->protection()->testBit( kpHeight )==false )
        {
          m_pResizingStencil->setY( sy + dy );
          m_pResizingStencil->setH( sh - dy );
        }
        break;
  
      case 3: // top right
        if( m_pResizingStencil->protection()->testBit( kpHeight )==false &&
          m_pResizingStencil->protection()->testBit( kpWidth )==false )
        {
          if((dx > dy) && (dx != 0)) {
            dy = -(dx / ratio);
          } else {
            dx = -(dy * ratio);
          }
  
          m_pResizingStencil->setY( sy + dy );
          m_pResizingStencil->setH( sh - dy );
  
          m_pResizingStencil->setW( sw + dx );
        }
        break;
  
      case 4: // right
        if( m_pResizingStencil->protection()->testBit( kpWidth )==false )
        {
          // see old kivio source when snaptogrid gets implemented
          //setX( SnapToGrid(sx+sw+dx)-sx )
          m_pResizingStencil->setW( sw + dx );
        }
        break;
  
      case 5: // bottom right
        if( m_pResizingStencil->protection()->testBit( kpWidth )==false &&
          m_pResizingStencil->protection()->testBit( kpHeight )==false )
        {
          if((dx > dy) && (dx != 0)) {
            dy = dx / ratio;
          } else {
            dx = dy * ratio;
          }
  
          m_pResizingStencil->setW( sw + dx );
          m_pResizingStencil->setH( sh + dy );
        }
        break;
  
      case 6: // bottom
        if( m_pResizingStencil->protection()->testBit( kpHeight )==false )
        {
          m_pResizingStencil->setH( sh + dy );
        }
        break;
  
      case 7: // bottom left
        if( m_pResizingStencil->protection()->testBit( kpWidth )==false &&
          m_pResizingStencil->protection()->testBit( kpHeight )==false )
        {
          if((dx > dy) && (dx != 0)) {
            dy = -(dx / ratio);
          } else {
            dx = -(dy * ratio);
          }
  
          m_pResizingStencil->setX( sx + dx );
          m_pResizingStencil->setW( sw - dx );
  
          m_pResizingStencil->setH( sh + dy );
        }
        break;
  
      case 8: // left
        if( m_pResizingStencil->protection()->testBit( kpWidth )==false )
        {
          KoPoint pinPoint = m_pResizingStencil->pinPoint();
          m_pResizingStencil->setPinPoint(KoPoint(pinPoint.x() - (dx / 2.0), pinPoint.y()));
          m_pResizingStencil->setX( sx + dx );
          m_pResizingStencil->setW( sw - dx );
        }
        break;
  
      default:
        kdDebug(43000) << "SelectTool::continueResizing() - unknown resize handle: " <<  m_resizeHandle << endl;
        break;
    }
  
    canvas->drawStencilXOR( m_pResizingStencil );
    view()->updateToolBars();
  }
}
Пример #5
0
void SelectTool::keyPress(QKeyEvent* e)
{
  KivioCanvas* canvas = view()->canvasWidget();
  
  canvas->setEnabled(false);

  // Create a new painter object
  canvas->beginUnclippedSpawnerPainter();

  // Build the list of old geometry
  KivioSelectDragData *pData;
  m_lstOldGeometry.clear();
  KivioStencil* pStencil = canvas->activePage()->selectedStencils()->first();

  while( pStencil )
  {
    pData = new KivioSelectDragData;
    pData->rect = pStencil->rect();
    m_lstOldGeometry.append(pData);


    pStencil = canvas->activePage()->selectedStencils()->next();
  }

  m_selectedRect = view()->activePage()->getRectForAllSelectedStencils();
  // Set the mode
  m_mode = stmDragging;
  canvas->setEnabled(true);
  m_origPoint = m_selectedRect.topLeft();
  KivioGridData gd = view()->doc()->grid();
  bool ignoreGridGuides = e->state() & ShiftButton;
  double distX, distY;
  
  if(ignoreGridGuides || !view()->doc()->grid().isSnap) {
    distX = view()->zoomHandler()->unzoomItX(1);
    distY = view()->zoomHandler()->unzoomItY(1);
  } else {
    distX = gd.freq.width();
    distY = gd.freq.height();
  }
  
  switch(e->key()) {
    case Key_Left:
      continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x() - distX,
        m_selectedRect.y())), ignoreGridGuides);
      break;
    case Key_Up:
      continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x(),
        m_selectedRect.y() - distY)), ignoreGridGuides);
      break;
    case Key_Right:
      continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x() + distX,
        m_selectedRect.y())), ignoreGridGuides);
      break;
    case Key_Down:
      continueDragging(canvas->mapToScreen(KoPoint(m_selectedRect.x(),
        m_selectedRect.y() + distY)), ignoreGridGuides);
      break;
    default:
      break;
  }
  
  endDragging(QPoint());
  canvas->guideLines().repaintAfterSnapping();
  canvas->setFocus();
}
Пример #6
0
void KWDocStructTextFrameItem::setupTextParags()
{
    // Build a list of pointers to paragraphs.
    QPtrList<KWTextParag> paragPtrs;
    paragPtrs.setAutoDelete(false);
    KoTextParag* textParag = 0;
    KoTextParag* lastParag = 0;
    int index = 0;
    // Get upper left corner of the frame and get coordinates just inside it.
    KoPoint dPoint = m_frame->topLeft() + KoPoint(2,2);
    // Get the first paragraph of the frame.
    m_frameset->findPosition(dPoint, textParag, index);
    // Get lower right corner of the frame and get coordinate just inside it.
    dPoint = m_frame->bottomRight() - KoPoint(2,2);
    // Get the last paragraph of the frame.
    m_frameset->findPosition(dPoint, lastParag, index);
    if (lastParag) {
        while (textParag) {
            KWTextParag* parag = dynamic_cast<KWTextParag *>(textParag);
            if (parag) {
                // Don't display an empty paragraph.
                QString text = parag->toString().stripWhiteSpace();
                if ( text.length() > 0)
                    paragPtrs.append(parag);
            }
            if (textParag == lastParag)
                textParag = 0;
            else
                textParag = textParag->next();
        }
    }

    // Remove deleted paragraphs from the listview.
    KWDocStructParagItem* item = dynamic_cast<KWDocStructParagItem *>(firstChild());
    KWDocStructParagItem* delItem;
    while (item) {
        delItem = item;
        item = dynamic_cast<KWDocStructParagItem *>(item->nextSibling());
        if (paragPtrs.containsRef(delItem->parag()) == 0) delete delItem;
    }

    // Add new paragraphs to the list or update existing ones.
    KWDocStructParagItem* after = 0;
    for (uint j = 0; j < paragPtrs.count(); j++) {
        KWTextParag* parag = paragPtrs.at(j);
        QString text = parag->toString().stripWhiteSpace();
        QString name = text.left(20);
        KoParagCounter* tmpCounter = parag->counter();
        if (tmpCounter)
            name.prepend(tmpCounter->text(parag) + " ");
        KWDocStructParagItem* child = findTextParagItem(parag);
        if (child)
            child->setText(0, name);
        else {
            if (after)
                child = new KWDocStructParagItem(this, after, name, parag);
            else
                child = new KWDocStructParagItem(this, name, parag);
        }
        after = child;
    }
}