Ejemplo n.º 1
0
void KWFrameGeometry::updateShape()
{
    if (m_blockSignals) return;
    KWFrame *frame = m_frame;
    if (frame == 0) {
        frame = m_state->frame();
        m_state->markFrameUsed();
    }
    Q_ASSERT(frame);
    frame->shape()->update();
    KShape *shape = frame->shape();
    QPointF currentPos(shape->absolutePosition(widget.positionSelector->position()));
    QPointF pos(widget.xPos->value(), widget.yPos->value() + m_topOfPage);
    QPointF moved = pos - currentPos;
    QPointF prev(moved);
    m_state->document()->clipToDocument(frame->shape(), moved);
    pos = currentPos + moved;

    frame->shape()->setAbsolutePosition(pos, widget.positionSelector->position());
    QSizeF size(widget.width->value(), widget.height->value());
    frame->shape()->setSize(size);

    KWTextFrame *tfs = dynamic_cast <KWTextFrame*>(frame);
    if (tfs) {
        KInsets insets(widget.topMargin->value(), widget.leftMargin->value(),
                widget.bottomMargin->value(), widget.rightMargin->value());
        tfs->setInsets(insets);
    }

    frame->shape()->update();
}
Ejemplo n.º 2
0
void TestFrameLayout::testCopyShapes()
{
    Helper helper;
    m_frames.clear();
    KWPage page = helper.pageManager->page(1);
    KWFrameLayout bfl(helper.pageManager, m_frames);
    connect(&bfl, SIGNAL(newFrameSet(KWFrameSet*)), this, SLOT(addFS(KWFrameSet*)));

    KWTextFrameSet *fs = bfl.getOrCreate(Words::OddPagesHeaderTextFrameSet, page);
    m_frames.append(fs);
    bfl.m_setup = false;

    helper.pageStyle.setHeaderPolicy(Words::HFTypeEvenOdd);

    KWTextFrame *tf = createFrame(QPointF(0,0), *fs);
    KWFrame *cf = createCopyFrame(QPointF(0,300), tf->shape(), *fs);
    QVERIFY(fs->frameCount()==2);
    //FIXME QVERIFY(bfl.hasFrameOn(fs, 1));
    delete tf->shape();

    QVERIFY(fs->frameCount()==1);
    //FIXME QVERIFY(!bfl.hasFrameOn(fs, 1));

    //now try and add a copyframe without crashing
    //sebsauer; it's not crashing but asserting at KWFrameLayout.cpp:750 now
    //bfl.createNewFramesForPage(1);
}
Ejemplo n.º 3
0
void KWFrameGeometry::open(KWFrame *frame)
{
    m_frame = frame;
    open(frame->shape());

    KWTextFrame *tfs = dynamic_cast<KWTextFrame*>(frame);
    if (tfs) {
        KInsets insets(tfs->insets());
        widget.marginsGB->setVisible(true);
        widget.leftMargin->changeValue(insets.left);
        widget.rightMargin->changeValue(insets.right);
        widget.topMargin->changeValue(insets.top);
        widget.bottomMargin->changeValue(insets.bottom);
    } else {
        widget.marginsGB->setVisible(false);
    }
}
Ejemplo n.º 4
0
void TestFrames::testCopyShapes()
{
    KWTextFrameSet *fs = new KWTextFrameSet(0, KWord::OddPagesHeaderTextFrameSet);
    MockShape *orig = new MockShape();
    orig->setUserData(new KTextShapeData());
    KWTextFrame *tf = new KWTextFrame(orig, fs);
    orig->setPosition(QPointF(10, 10));

    KWCopyShape *copy = new KWCopyShape(orig);
    new KWFrame(copy, fs);
    copy->setPosition(QPointF(20, 100));
    QCOMPARE(fs->frameCount(), 2);

    delete tf->shape(); // causes the first frame to be deleted.
    QCOMPARE(fs->frameCount(), 1);

    // the deletion of the orig should have caused the copy shape to be disconnected
    QVERIFY(copy->original() == 0);

    // please don't crash..
    copy->outline();
}
Ejemplo n.º 5
0
void KWFrameGeometry::open(KShape *shape)
{
    KWPage page = m_state->document()->pageManager()->page(shape);
    m_topOfPage = page.offsetInDocument();
    m_originalPosition = shape->position();
    m_originalSize = shape->size();
    QPointF position = shape->absolutePosition(widget.positionSelector->position());

    widget.xPos->changeValue(position.x());
    widget.yPos->changeValue(position.y() - m_topOfPage);
    widget.width->changeValue(m_originalSize.width());
    widget.height->changeValue(m_originalSize.height());

    if (m_frame == 0) {
        // default values for new frames
        widget.leftMargin->changeValue(MM_TO_POINT(3));
        widget.rightMargin->changeValue(MM_TO_POINT(3));
        widget.topMargin->changeValue(MM_TO_POINT(3));
        widget.bottomMargin->changeValue(MM_TO_POINT(3));
    }

    connect(widget.protectSize, SIGNAL(stateChanged(int)),
            this, SLOT(protectSizeChanged(int)));

    m_originalGeometryLock = shape->isGeometryProtected();
    if (m_originalGeometryLock) {
        widget.protectSize->setCheckState(Qt::Checked);
        KWTextFrame *tf = dynamic_cast<KWTextFrame*>(shape->applicationData());
        if (tf && static_cast<KWTextFrameSet*>(tf->frameSet())->textFrameSetType() != KWord::OtherTextFrameSet)
            widget.protectSize->setEnabled(false); // auto-generated frame, can't edit
    }

    connect(widget.xPos, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.yPos, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.width, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
    connect(widget.height, SIGNAL(valueChanged(double)), this, SLOT(updateShape()));
}