/*! * 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; } } }
PD_DocumentRDFHandle AP_Dialog_RDFEditor::getRDF() { FV_View* view = getView(); PD_Document* doc = view->getDocument(); PD_DocumentRDFHandle rdf = doc->getDocumentRDF(); return rdf; }
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; }
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; }
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 }
/*! * Import graphic for cell background. */ void AP_Dialog_FormatFrame::askForGraphicPathName(void) { UT_return_if_fail(m_pApp); XAP_Frame * pFrame = m_pApp->getLastFocussedFrame(); UT_return_if_fail(pFrame); XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory()); UT_return_if_fail(pDialogFactory); XAP_Dialog_FileOpenSaveAs * pDialog = static_cast<XAP_Dialog_FileOpenSaveAs *>(pDialogFactory->requestDialog(XAP_DIALOG_ID_INSERT_PICTURE)); UT_return_if_fail (pDialog); pDialog->setCurrentPathname(NULL); pDialog->setSuggestFilename(false); // to fill the file types popup list, we need to convert AP-level // ImpGraphic descriptions, suffixes, and types into strings. UT_uint32 filterCount = IE_ImpGraphic::getImporterCount(); const char ** szDescList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); const char ** szSuffixList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); IEGraphicFileType * nTypeList = (IEGraphicFileType *) UT_calloc(filterCount + 1, sizeof(IEGraphicFileType)); UT_uint32 k = 0; while (IE_ImpGraphic::enumerateDlgLabels(k, &szDescList[k], &szSuffixList[k], &nTypeList[k])) k++; pDialog->setFileTypeList(szDescList, szSuffixList, static_cast<const UT_sint32 *>(nTypeList)); pDialog->runModal(pFrame); XAP_Dialog_FileOpenSaveAs::tAnswer ans = pDialog->getAnswer(); bool bOK = (ans == XAP_Dialog_FileOpenSaveAs::a_OK); if (bOK) { m_sImagePath = pDialog->getPathname(); UT_sint32 type = pDialog->getFileType(); // If the number is negative, it's a special type. // Some operating systems which depend solely on filename // suffixes to identify type (like Windows) will always // want auto-detection. if (type < 0) switch (type) { case XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO: // do some automagical detecting m_iGraphicType = IEGFT_Unknown; break; default: // it returned a type we don't know how to handle UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } else m_iGraphicType = static_cast<IEGraphicFileType>(pDialog->getFileType()); } FREEP(szDescList); FREEP(szSuffixList); FREEP(nTypeList); pDialogFactory->releaseDialog(pDialog); if(m_sImagePath.size() == 0) { return; } FG_Graphic* pFG = NULL; UT_Error errorCode; errorCode = IE_ImpGraphic::loadGraphic(m_sImagePath.c_str(), m_iGraphicType, &pFG); if(errorCode != UT_OK || !pFG) { ShowErrorBox(m_sImagePath, errorCode); return; } DELETEP(m_pGraphic); DELETEP(m_pImage); m_pGraphic = pFG->clone(); GR_Graphics * pG = m_pFormatFramePreview->getGraphics(); FV_View * pView = static_cast<FV_View *>(pFrame->getCurrentView()); UT_return_if_fail(pView && pView->getDocument()); UT_uint32 uid = pView->getDocument()->getUID(UT_UniqueId::Image); //see Bug 10851 m_sImagePath.clear(); m_sImagePath = UT_std_string_sprintf("%d",uid); m_pImage = _makeImageForRaster(m_sImagePath, pG, m_pGraphic); // draw the preview with the changed properties if(m_pFormatFramePreview) m_pFormatFramePreview->draw(); }