void PropertyWidget_TextColor::handleTextShade() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (strokeShade == sender()) { int b = strokeShade->getValue(); PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetStrokeShade(b, &tempSelection); } } else { int b = fillShade->getValue(); PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetFillShade(b, &tempSelection); } } }
void ItemAPI::move(double dx, double dy) { if (!checkHaveDocument()) return; if (item==NULL) return; // Grab the old selection - but use it only where is there any Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection); bool hadOrigSelection = (tempSelection.count() != 0); ScCore->primaryMainWindow()->doc->m_Selection->clear(); // Clear the selection ScCore->primaryMainWindow()->view->Deselect(); // Select the item, which will also select its group if // there is one. ScCore->primaryMainWindow()->view->SelectItem(item); // Move the item, or items if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1) { ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove); ScCore->primaryMainWindow()->doc->moveGroup(ValueToPoint(dx), ValueToPoint(dy)); ScCore->primaryMainWindow()->view->endGroupTransaction(); } else { ScCore->primaryMainWindow()->doc->MoveItem(ValueToPoint(dx), ValueToPoint(dy), item); } // Now restore the selection. ScCore->primaryMainWindow()->view->Deselect(); if (hadOrigSelection) *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection; }
void ItemAPI::moveAbs(double x, double y) { if (!checkHaveDocument()) return; if (item == NULL) return; // Grab the old selection - but use it only where is there any Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection); bool hadOrigSelection = (tempSelection.count() != 0); // Clear the selection ScCore->primaryMainWindow()->view->Deselect(); // Select the item, which will also select its group if // there is one. ScCore->primaryMainWindow()->view->SelectItem(item); // Move the item, or items if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1) { ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove); double x2, y2, w, h; ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h); ScCore->primaryMainWindow()->doc->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2); ScCore->primaryMainWindow()->view->endGroupTransaction(); } else ScCore->primaryMainWindow()->doc->MoveItem(pageUnitXToDocX(x) - item->xPos(), pageUnitYToDocY(y) - item->yPos(), item); // Now restore the selection. ScCore->primaryMainWindow()->view->Deselect(); if (hadOrigSelection) *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection; }
void PropertyWidget_Distance::handleTabs() { if (m_doc && m_item) { PageItem_TextFrame *tItem = m_item->asTextFrame(); if (tItem == 0) return; const ParagraphStyle& style(m_doc->appMode == modeEdit ? tItem->currentStyle() : tItem->itemText.defaultStyle()); TabManager *dia = new TabManager(this, m_doc->unitIndex(), style.tabValues(), tItem->columnWidth()); if (dia->exec()) { if (m_doc->appMode != modeEdit) { ParagraphStyle newStyle(m_item->itemText.defaultStyle()); newStyle.setTabValues(dia->tmpTab); Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); } else { ParagraphStyle newStyle; newStyle.setTabValues(dia->tmpTab); m_doc->itemSelection_ApplyParagraphStyle(newStyle); } m_item->update(); } delete dia; } }
void ImageAPI::offset(double x, double y) { if (!checkHaveDocument()) RAISE("No document open"); if (item == nullptr) return; if (! item->asImageFrame()) { RAISE("Specified item not an image frame."); return; } // Grab the old selection - but use it only where is there any Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection); bool hadOrigSelection = (tempSelection.count() != 0); ScCore->primaryMainWindow()->doc->m_Selection->clear(); // Clear the selection ScCore->primaryMainWindow()->view->Deselect(); // Select the item, which will also select its group if // there is one. ScCore->primaryMainWindow()->view->SelectItem(item); // offset double newOffsetX = x / ((item->imageXScale() != 0.0) ? item->imageXScale() : 1); double newOffsetY = y / ((item->imageYScale() != 0.0) ? item->imageYScale() : 1); ScCore->primaryMainWindow()->doc->itemSelection_SetImageOffset(newOffsetX, newOffsetY); //CB why when this is done above? ScCore->primaryMainWindow()->doc->updatePic(); // Now restore the selection. ScCore->primaryMainWindow()->view->Deselect(); if (hadOrigSelection) *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection; }
void ImageAPI::scale(double x, double y) { if (!checkHaveDocument()) RAISE("No document open"); if (item == nullptr) return; if (! item->asImageFrame()) { RAISE("Specified item not an image frame."); return; } Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection); bool hadOrigSelection = (tempSelection.count() != 0); ScCore->primaryMainWindow()->doc->m_Selection->clear(); ScCore->primaryMainWindow()->view->Deselect(); ScCore->primaryMainWindow()->view->SelectItem(item); ScCore->primaryMainWindow()->doc->itemSelection_SetImageScale(x, y); ScCore->primaryMainWindow()->doc->updatePic(); // Now restore the selection. ScCore->primaryMainWindow()->view->Deselect(); if (hadOrigSelection) *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection; }
void PropertiesPalette_Text::handleLineSpacing() { if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection); }
void PropertiesPalette_Text::handleFontSize() { if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection); }
void PropertiesPalette_Text::handleAlignement(int a) { if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetAlignment(a, &tempSelection); }
void PropertiesPalette_Text::doClearCStyle() { if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_EraseCharStyle(&tempSelection); }
void PropertiesPalette_Text::doClearPStyle() { if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_ClearBulNumStrings(&tempSelection); m_doc->itemSelection_EraseParagraphStyle(&tempSelection); CharStyle emptyCStyle; m_doc->itemSelection_SetCharStyle(emptyCStyle, &tempSelection); }
void PropertiesPalette_Text::changeLang(int id) { if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; QStringList languageList; LanguageManager::instance()->fillInstalledStringList(&languageList, true); QString abrv = LanguageManager::instance()->getAbbrevFromLang(languageList.value(id),false); Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetLanguage(abrv, &tempSelection); }
void PropertiesPalette_Text::handleLineSpacingMode(int id) { if ((m_haveDoc) && (m_haveItem)) { Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetLineSpacingMode(id, &tempSelection); updateStyle(((m_doc->appMode == modeEdit) || (m_doc->appMode == modeEditTable)) ? m_item->currentStyle() : m_item->itemText.defaultStyle()); m_doc->regionsChanged()->update(QRect()); } }
void PropertyWidget_Advanced::handleTracking() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetTracking(qRound(tracking->value() * 10.0), &tempSelection); } }
void PropertyWidget_OptMargins::resetOpticalMargins() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *item = m_item; if (m_doc->appMode == modeEditTable) item = m_item->asTable()->activeCell().textFrame(); if (item != NULL) { Selection tempSelection(this, false); tempSelection.addItem(item, true); m_doc->itemSelection_resetOpticalMargins(&tempSelection); } }
void PropertyWidget_TextColor::handleTextDirection() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetItemTextReversed(revertButton->isChecked(), &tempSelection); } }
void PropertyWidget_TextColor::handleTextStroke() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetStrokeColor(strokeColor->currentColor(), &tempSelection); } }
void PropertyWidget_TextColor::handleTypeStyle(int s) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetEffects(s, &tempSelection); m_ScMW->setStyleEffects(s); } }
void PropertyWidget_Advanced::handleMaxGlyphExtension() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); ParagraphStyle newStyle; newStyle.setMaxGlyphExtension(maxGlyphExtSpinBox->value() / 100.0); m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); } }
void PropertyWidget_TextColor::handleOutlineWidth() { int x = qRound(textEffects->OutlineVal->LWidth->value() * 10.0); if ((m_doc) && (m_item)) { PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetOutlineWidth(x, &tempSelection); } } }
void PropertyWidget_TextColor::handleShadowOffs() { if ((m_doc) && (m_item)) { int x = qRound(textEffects->ShadowVal->Xoffset->value() * 10.0); int y = qRound(textEffects->ShadowVal->Yoffset->value() * 10.0); PageItem *i2 = m_item; if (m_doc->appMode == modeEditTable) i2 = m_item->asTable()->activeCell().textFrame(); if (i2 != NULL) { Selection tempSelection(this, false); tempSelection.addItem(i2, true); m_doc->itemSelection_SetShadowOffsets(x, y, &tempSelection); } } }
void PropertyWidget_ParEffect::handleChanges(PageItem *item, ParagraphStyle &newStyle) { if (m_doc->appMode == modeEditTable) item = item->asTable()->activeCell().textFrame(); if (item != NULL) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); Selection tempSelection(this, false); tempSelection.addItem(item, true); m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); m_doc->updateNumbers(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } }
void BezierMode::deactivate(bool flag) { // qDebug() << "BezierMode::deactivate" << flag; // m_view->stopDragTimer(); PageItem* currItem = m_doc->m_Selection->itemAt(0); //When only one node(size=2) was created; it's not a valid line(min valid PoLine size is 6), delete it if (currItem) { currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2)); if (currItem->PoLine.size() < 4) { m_view->Deselect(false); Selection tempSelection(m_doc, false); tempSelection.addItem(currItem); m_doc->itemSelection_DeleteItem(&tempSelection, true); currItem = 0; } } undoManager->setUndoEnabled(true); if (currItem && UndoManager::undoEnabled()) { ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem"); is->set("CREATE_ITEM", "create_item"); is->setItem(currItem); //Undo target rests with the Page for object specific undo UndoObject *target = m_doc->Pages->at(0); if (currItem->OwnPage > -1) target = m_doc->Pages->at(currItem->OwnPage); undoManager->action(target, is); } m_view->setRedrawMarkerShown(false); if (!currItem) return; m_doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false); currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0))); m_doc->AdjustItemSize(currItem); currItem->ContourLine = currItem->PoLine.copy(); currItem->ClipEdited = true; currItem->FrameType = 3; }
void PropertiesPalette_Text::handleDirection(int d) { if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; Selection tempSelection(this, false); tempSelection.addItem(m_item, true); m_doc->itemSelection_SetDirection(d, &tempSelection); // If current text alignment is left or right, change it to match direction if (d == ParagraphStyle::RTL && textAlignment->selectedId() == ParagraphStyle::Leftaligned) { m_doc->itemSelection_SetAlignment(ParagraphStyle::Rightaligned, &tempSelection); textAlignment->setTypeStyle(ParagraphStyle::Rightaligned); } else if (d == ParagraphStyle::LTR && textAlignment->selectedId() == ParagraphStyle::Rightaligned) { m_doc->itemSelection_SetAlignment(ParagraphStyle::Leftaligned, &tempSelection); textAlignment->setTypeStyle(ParagraphStyle::Leftaligned); } }
void PropertyWidget_OptMargins::handleOpticalMargins() { if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning()) return; int omt(ParagraphStyle::OM_None); if (optMarginRadioBoth->isChecked()) omt = ParagraphStyle::OM_Default; else if (optMarginRadioLeft->isChecked()) omt = ParagraphStyle::OM_LeftHangingPunct; else if (optMarginRadioRight->isChecked()) omt = ParagraphStyle::OM_RightHangingPunct; PageItem *item = m_item; if (m_doc->appMode == modeEditTable) item = m_item->asTable()->activeCell().textFrame(); if (item != NULL) { Selection tempSelection(this, false); tempSelection.addItem(item, true); m_doc->itemSelection_SetOpticalMargins(omt, &tempSelection); } }
void Hruler::mouseReleaseEvent(QMouseEvent *m) { if (m_doc->isLoading()) { Mpressed = false; return; } if (textEditMode && currItem) { if ((m->y() < height()) && (m->y() > 0)) { bool mustApplyStyle = false; ParagraphStyle paraStyle; double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; switch (RulerCode) { case rc_leftFrameDist: m_doc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); emit DocChanged(false); break; case rc_rightFrameDist: m_doc->m_Selection->itemAt(0)->setTextToFrameDistRight(RExtra); emit DocChanged(false); break; case rc_indentFirst: paraStyle.setFirstIndent(First); mustApplyStyle = true; emit DocChanged(false); break; case rc_leftMargin: paraStyle.setLeftMargin(Indent); paraStyle.setFirstIndent(First); mustApplyStyle = true; emit DocChanged(false); break; case rc_rightMargin: paraStyle.setRightMargin(ColWidth - RMargin); mustApplyStyle = true; emit DocChanged(false); break; case rc_tab: if (m->button() == Qt::RightButton) { TabValues[ActTab].tabType += 1; if (TabValues[ActTab].tabType > 4) TabValues[ActTab].tabType = 0; } paraStyle.setTabValues(TabValues); mustApplyStyle = true; emit DocChanged(false); break; default: break; } if (mustApplyStyle) { Selection tempSelection(this, false); tempSelection.addItem(currItem); m_doc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); } else { currItem->update(); } } else { if (RulerCode == rc_tab) { TabValues.removeAt(ActTab); ActTab = 0; ParagraphStyle paraStyle; paraStyle.setTabValues(TabValues); Selection tempSelection(this, false); tempSelection.addItem(currItem); m_doc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); emit DocChanged(false); } } RulerCode = rc_none; m_view->DrawNew(); m_doc->m_Selection->itemAt(0)->emitAllToGUI(); } else { if (Mpressed) { rulerGesture->mouseReleaseEvent(m); Mpressed = false; } } Mpressed = false; qApp->restoreOverrideCursor(); }