VoidT createNewDocLineBook() { F_ObjHandleT bookId; StringT path, bookPath; IntT err; /* Choose workspace for new docline project */ err = F_ApiChooseFile(&path, "Choose directory to save new docline project", "", "", FV_ChooseOpenDir, ""); if (err) return; /* Open template book and save it to the selected directory*/ bookId = F_ApiSimpleOpen("C:\\Program Files\\Adobe\\FrameMaker8\\Structure\\xml\\docline\\docline_book_template.book",False); bookPath = F_Alloc(F_StrLen(path)+F_StrLen(defaultBookName)+3,NO_DSE); F_Sprintf(bookPath,"%s\\%s\0", path, defaultBookName); F_ApiDeallocateString(&path); F_ApiSimpleSave(bookId, bookPath, False); F_ApiDeallocateString(&bookPath); }
VoidT GetDocStyles(F_ObjHandleT docId, BoolT isPara) { F_ObjHandleT compId = 0; StringT sname = NULL; StringT vname = NULL; StringT fname = NULL; IntT fnum = 0; DesStyleT *curr = NULL; compId = F_ApiGetId(FV_SessionId, docId, isPara ? FP_FirstPgfFmtInDoc : FP_FirstCharFmtInDoc); while (compId) { sname = F_ApiGetString(docId, compId, FP_Name); if (InDesList(sname)) F_StrFree(sname); else { curr = CreateDesignerStyle(sname); curr->para = isPara; if (isPara || (F_ApiGetInt(docId, compId, FP_UseFontVariation) && F_ApiGetInt(docId, compId, FP_UseFontFamily))) { vname = F_ApiGetString(docId, compId, FP_FontVariation); if (vname && *vname) { if (F_StrICmp(vname, "Regular")) { fnum = F_ApiGetInt(docId, compId, FP_FontFamily); fname = F_StrNew(F_StrLen(vname) + F_StrLen(FontFamilies.val[fnum]) + 1); F_StrCpy(fname, FontFamilies.val[fnum]); F_StrCat(fname, vname); AddDesFont(fname); F_StrFree(fname); } F_StrFree(vname); } } LastDesStyle->next = curr; LastDesStyle = curr; DesStyleCount++; } compId = F_ApiGetId(docId, compId, isPara ? FP_NextPgfFmtInDoc : FP_NextCharFmtInDoc); } }
VoidT PutGraphExportP(VoidT) { IntT i = 0; StringT pname = NULL; M2GIniPutSetting(CurrIniName, "GraphExport", "ImportGraphics", ImpGraphicsVals[ImpGraphics]); M2GIniPutSetting(CurrIniName, "GraphExport", "ExportNameChars", ImpGraphicsNameChars); M2GIniPutSetting(CurrIniName, "GraphExport", "ExportNumDigits", ImpGraphicsDigits); for (i = 0; i <= (DLG_SA_GX_LAST - DLG_SA_GX_BASE); i++) { if (GxDef[i] != GxUsage[i]) { pname = F_StrNew(F_StrLen(ImportDesNames[i + 1]) + 12); F_Sprintf(pname, "Export%sFiles", ImportDesNames[i + 1]); M2GIniPutBool(CurrIniName, "GraphExport", pname, GxUsage[i]); F_StrFree(pname); } } }
VoidT PutGraphExport(FILE *fini) { IntT i = 0; StringT pname = NULL; fprintf(fini, "\n[GraphExport]\n"); fprintf(fini, "ImportGraphics=%s\n", ImpGraphicsVals[ImpGraphics]); fprintf(fini, "ExportNameChars=%s\n", ImpGraphicsNameChars); fprintf(fini, "ExportNumDigits=%s\n", ImpGraphicsDigits); for (i = 0; i <= (DLG_SA_GX_LAST - DLG_SA_GX_BASE); i++) { if (GxDef[i] != GxUsage[i]) { pname = F_StrNew(F_StrLen(ImportDesNames[i + 1]) + 16); F_Sprintf(pname, "Export%sFiles=%s", ImportDesNames[i + 1], GxUsage[i] ? "Yes" : "No"); fprintf(fini, "%s\n", pname); F_StrFree(pname); } } fprintf(fini, "\n"); }
VoidT WriteStylesToIni(StringT ininame, BoolT confirm) { DesStyleT *curr = NULL; UCharT helpStyle[MAX_PROFILE]; StringT hsPtr = NULL; UCharT contType[3]; UCharT contTypes[4] = { 'V', 'H', 'T', 'B' }; StringT aname = NULL; StringT temp1; if (TextChanged) SetIniTF(ininame, SubOptions, "RemoveUnusedStyles", CurrDesText.rem_unused_sty); if (!StylesChanged) return; for (curr = DesStyles; curr; curr = (DesStyleT *) curr->next) { aname = Fm2a(curr->name); if (curr->remap) { temp1 = curr->rem_name; SetIniStr(ininame, StyleSections[0], aname, temp1); //F_Free(temp1); } else SetIniStr(ininame, StyleSections[0], aname, NULL); if (curr->remap) { temp1 = curr->rep_name; SetIniStr(ininame, StyleSections[1], aname, temp1); //F_Free(temp1); } else SetIniStr(ininame, StyleSections[1], aname, NULL); helpStyle[0] = '\0'; hsPtr = NULL; switch (curr->helptyp) { case 1: if (curr->topictyp == 0) hsPtr = "Topic "; else if (curr->topictyp == 1) hsPtr = "Topic Slide "; else if (curr->topictyp == 2) hsPtr = "Resume "; break; case 2: if (curr->hotsptyp == 0) hsPtr = "JumpHot "; else if (curr->hotsptyp == 1) hsPtr = "PopHot "; else if (curr->hotsptyp == 2) hsPtr = "Window "; else if (curr->hotsptyp == 3) hsPtr = "PopOver "; break; case 3: hsPtr = curr->pop_cont ? "PopContent " : "JumpTarget "; break; case 4: hsPtr = "MacroHot "; break; case 0: default: break; } if (hsPtr) F_StrCpy(helpStyle, hsPtr); if (curr->usekey) F_StrCat(helpStyle, "Key "); if (curr->akey) F_StrCat(helpStyle, "AKey "); if (curr->keys && *curr->keys) { F_StrCat(helpStyle, "SpKey "); SetIniStr(ininame, "HelpKeywordStyles", aname, curr->keys); } if (curr->helptyp == 1) { if (curr->browse) { F_StrCat(helpStyle, "Browse "); SetIniStr(ininame, "HelpBrowsePrefixStyles", aname, (curr->br_px && *curr->br_px) ? curr->br_px : NULL); } if (curr->cont) { F_StrCat(helpStyle, "Contents "); contType[0] = contTypes[curr->conttyp]; contType[1] = *curr->contlev; contType[2] = '\0'; SetIniStr(ininame, "HelpCntStyles", aname, contType); } if (curr->mac_name && *curr->mac_name) { F_StrCat(helpStyle, "Macro "); SetIniStr(ininame, "HelpMacroStyles", aname, curr->mac_name); } if (curr->build) { F_StrCat(helpStyle, "Build "); SetIniStr(ininame, "HelpTopicBuildStyles", aname, curr->build_tag); } if (curr->window) { F_StrCat(helpStyle, "Window "); SetIniStr(ininame, "HelpWindowStyles", aname, curr->win_name); } if (curr->notitle) F_StrCat(helpStyle, "NoTitle "); else if (curr->titsx) { F_StrCat(helpStyle, "TitleSuf "); SetIniStr(ininame, "HelpTitleSufStyles", aname, curr->title_sx); } if (curr->refer) { F_StrCat(helpStyle, "Refer "); if (curr->ref_sx && *curr->ref_sx) { F_StrCat(helpStyle, "Suffix "); SetIniStr(ininame, "HelpSuffixStyles", aname, curr->ref_sx); } } if (curr->noscr_used) F_StrCat(helpStyle, curr->noscroll ? "NoScroll " : "Scroll "); if (curr->xtscr_used) F_StrCat(helpStyle, curr->xtscroll ? "XScroll " : "NoXScroll "); } else if (curr->helptyp == 2) { if (curr->window) { if (curr->hotsptyp != 2) F_StrCat(helpStyle, "Window "); SetIniStr(ininame, "HelpWindowStyles", aname, curr->win_name); } if (curr->fileref) { F_StrCat(helpStyle, "File "); SetIniStr(ininame, "HelpJumpFileStyles", aname, curr->file_name); } if (curr->local) F_StrCat(helpStyle, "Local "); if (curr->fixed) SetIniStr(ininame, "HelpRefStyles", aname, curr->fixed_name); else if (curr->ref_sx && *curr->ref_sx) { F_StrCat(helpStyle, "Suffix "); SetIniStr(ininame, "HelpSuffixStyles", aname, curr->ref_sx); } if (!curr->ungreen) F_StrCat(helpStyle, "Green "); if (!curr->nouline) F_StrCat(helpStyle, "Uline "); } else if (curr->helptyp == 3) { if (curr->local) F_StrCat(helpStyle, "Local "); if (curr->refer) { F_StrCat(helpStyle, "Suffix "); SetIniStr(ininame, "HelpSuffixStyles", aname, curr->ref_sx); } if (curr->cont) { F_StrCat(helpStyle, "Contents "); contType[0] = contTypes[curr->conttyp]; contType[1] = *curr->contlev; contType[2] = '\0'; SetIniStr(ininame, "HelpCntStyles", aname, contType); } } else if (curr->helptyp == 4) { if (curr->mac_name && *curr->mac_name) SetIniStr(ininame, "HelpMacroStyles", aname, curr->mac_name); if (!curr->ungreen) F_StrCat(helpStyle, "Green "); if (!curr->nouline) F_StrCat(helpStyle, "Uline "); } hsPtr = helpStyle + F_StrLen(helpStyle); if (*hsPtr == ' ') *hsPtr = '\0'; SetIniStr(ininame, "HelpStyles", aname, *helpStyle ? helpStyle : NULL); F_Free(aname); } StylesChanged = False; }
VoidT newDocCoreChild(IntT type) { F_ObjHandleT bookId, docId, childEdefId, compId, elemId, dlgId, childId; F_ElementLocT elemLoc; StringT bookPath, savePath, edefName, nameStr, idStr, elemName, selectedDocCore; IntT len; BoolT compExists, compFound; F_AttributesT docCoreAttr; F_StringsT doccores; UIntT j; /* Open resource for the dialogs */ dlgId = F_ApiOpenResource(FO_DialogResource, "docline"); /* Get Id and path of the book */ //bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook); bookId = getActiveBookID(); bookPath = F_ApiGetString(FV_SessionId, bookId, FP_Name); pathFilename(bookPath); /* Check whether document has Docline section*/ compId = F_ApiGetId(FV_SessionId, bookId, FP_HighestLevelElement); if (!compId) { F_ApiAlert("Highest element error",FF_ALERT_CONTINUE_NOTE); F_ApiClose (dlgId, FF_CLOSE_MODIFIED); return; } else { /* Check which DocumentationCore sections already exist */ compId = F_ApiGetId(bookId, compId, FP_FirstChildElement); compExists = False; /* Initiallze list for dialog's pop-up*/ doccores.val = (StringT*) F_Alloc(2*sizeof(StringT), NO_DSE); doccores.len = 2; doccores.val[0] = F_StrCopyString("..."); doccores.val[1] = F_StrCopyString("New..."); while (compId) { elemId = F_ApiGetId(bookId, compId, FP_ElementDef); if (F_StrIEqual(F_ApiGetString(bookId, elemId, FP_Name), "DocumentationCore")) { compExists = True; break; } compId = F_ApiGetId(bookId, compId, FP_NextSiblingElement); } if (!compExists) // There is no "DocumentationCore" section { /* Create DocumentationCore section */ if(!newSecondLevelSection(True, "DocumentationCore", NULL)) { F_ApiClose (dlgId, FF_CLOSE_MODIFIED); return; } } compId = F_ApiGetId(FV_SessionId, bookId, FP_HighestLevelElement); compId = F_ApiGetId(bookId, compId, FP_FirstChildElement); while (compId) { elemId = F_ApiGetId(bookId, compId, FP_ElementDef); if (F_StrIEqual(F_ApiGetString(bookId, elemId, FP_Name), "DocumentationCore")) { docCoreAttr = F_ApiGetAttributes(bookId, compId); for(j=0; j<docCoreAttr.len; j++) { if (F_StrEqual("FileName", docCoreAttr.val[j].name)) { /* Allocate space for new string in dialog's popup */ doccores.len++; doccores.val = (StringT *) F_Realloc(doccores.val, doccores.len*sizeof(StringT), NO_DSE); /* Add string to the Pop-Up. */ doccores.val[doccores.len-1] = F_StrCopyString(docCoreAttr.val[j].values.val[0]); break; } } } compId = F_ApiGetId(bookId, compId, FP_NextSiblingElement); } F_ApiSetStrings(dlgId, F_ApiDialogItemId(dlgId, 7), FP_Labels, &doccores); /* Make the first item the default. */ F_ApiSetInt(dlgId, F_ApiDialogItemId(dlgId, 7), FP_State, 1); } /* show modal dialog with prompt for attributes */ F_ApiModalDialog(NEW_DLG, dlgId); if ((F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, CANCELDLG), FP_State) == True) || (F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, OKDLG), FP_State) != True)) { F_ApiClose (dlgId, FF_CLOSE_MODIFIED); return; } /* make sure that all attributes are typed in the text box*/ while (F_StrIsEmpty(F_ApiGetString(dlgId, F_ApiDialogItemId(dlgId, 1), FP_Text)) || F_StrIsEmpty(F_ApiGetString(dlgId, F_ApiDialogItemId(dlgId, 3), FP_Text))) { F_ApiAlert("You must type Id and Name in text fields!", FF_ALERT_CONTINUE_NOTE); F_ApiModalDialog(NEW_DLG, dlgId); if ((F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, CANCELDLG), FP_State) == True) || (F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, OKDLG), FP_State) != True)) { F_ApiClose (dlgId, FF_CLOSE_MODIFIED); return; } } /* get Id and Name values from dialog box*/ idStr = F_StrCopyString(F_ApiGetString(dlgId, F_ApiDialogItemId(dlgId, 1), FP_Text)); nameStr = F_StrCopyString(F_ApiGetString(dlgId, F_ApiDialogItemId(dlgId, 3), FP_Text)); if (F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, 7), FP_State) == 1) { if(!newSecondLevelSection(True, "DocumentationCore", &selectedDocCore)) { F_ApiClose (dlgId, FF_CLOSE_MODIFIED); return; } } else { /* get Id of selected DocumentationCore section */ selectedDocCore = doccores.val[F_ApiGetInt(dlgId, F_ApiDialogItemId(dlgId, 7), FP_State)]; } compId = F_ApiGetId(FV_SessionId, bookId, FP_HighestLevelElement); compId = F_ApiGetId(bookId, compId, FP_FirstChildElement); compFound = False; while (True) { elemId = F_ApiGetId(bookId, compId, FP_ElementDef); if (F_StrIEqual(F_ApiGetString(bookId, elemId, FP_Name), "DocumentationCore")) { docCoreAttr = F_ApiGetAttributes(bookId, compId); for(j=0; j<docCoreAttr.len; j++) { if (F_StrEqual("FileName", docCoreAttr.val[j].name)) { if (F_StrEqual(selectedDocCore, docCoreAttr.val[j].values.val[0])) compFound = True; break; } } if (compFound) break; } compId = F_ApiGetId(bookId, compId, FP_NextSiblingElement); } /* Choose what type of element we add*/ switch (type) { case DICTION: savePath = F_Alloc(F_StrLen(bookPath)+F_StrLen(idStr)+F_StrLen("dictionary_.fm")+1, NO_DSE); len = F_Sprintf(savePath, "%sdictionary_%s.fm", (StringT)bookPath, (StringT)idStr); edefName = F_StrCopyString("Dictionary"); break; case DIRECT: savePath = F_Alloc(F_StrLen(bookPath)+F_StrLen(idStr)+F_StrLen("directory_.fm")+1, NO_DSE); len = F_Sprintf(savePath, "%sdirectory_%s.fm", (StringT)bookPath, (StringT)idStr); edefName = F_StrCopyString("Directory"); break; case DIRTEMP: savePath = F_Alloc(F_StrLen(bookPath)+F_StrLen(idStr)+F_StrLen("dir_template_.fm")+1, NO_DSE); len = F_Sprintf(savePath, "%sdir_template_%s.fm", (StringT)bookPath, (StringT)idStr); edefName = F_StrCopyString("DirTemplate"); break; case INFELEM: savePath = F_Alloc(F_StrLen(bookPath)+F_StrLen(idStr)+F_StrLen("inf_element_.fm")+1, NO_DSE); len = F_Sprintf(savePath, "%sinf_element_%s.fm", (StringT)bookPath, (StringT)idStr); edefName = F_StrCopyString("InfElement"); break; case INFPROD: savePath = F_Alloc(F_StrLen(bookPath)+F_StrLen(idStr)+F_StrLen("inf_product_.fm")+1, NO_DSE); len = F_Sprintf(savePath, "%sinf_product_%s.fm", (StringT)bookPath, (StringT)idStr); edefName = F_StrCopyString("InfProduct"); break; } /* Create document from template */ docId = F_ApiSimpleNewDoc("C:\\Program Files\\Adobe\\FrameMaker8\\Structure\\xml\\docline\\docline_doc_template.fm", False); /* Get Id of the highest-level element definition for created document */ childEdefId = F_ApiGetNamedObject(docId, FO_ElementDef, edefName); /* Insert new Highest-level element into the document, i.e. InfElement, InfProduct, etc. */ F_ApiWrapElement(docId, childEdefId); /* Save the doc with the specific name */ F_ApiSimpleSave(docId, savePath, False); /* Set correct values of attributes */ setAttributes(idStr, nameStr); /* Update header of the document */ editHeader(); /* Insert Book component in DocumentationCore section*/ childId = F_ApiGetId(bookId, compId, FP_FirstChildElement); while (childId) { elemId = F_ApiGetId(bookId, childId, FP_ElementDef); elemName = F_ApiGetString(bookId, elemId, FP_Name); if (F_StrIEqual(elemName, "Dictionary")) { if (type == DICTION) break; } else if (F_StrIEqual(elemName, "Directory")) { if (type <= DIRECT) break; } else if (F_StrIEqual(elemName, "DirTemplate")) { if (type <= DIRTEMP) break; } else if (F_StrIEqual(elemName, "InfElement")) { if (type <= INFELEM) break; } else if (F_StrIEqual(elemName, "InfProduct")) { if (type <= INFPROD) break; } childId = F_ApiGetId(bookId, childId, FP_NextSiblingElement); } elemLoc.childId = childId; elemLoc.parentId = compId; elemLoc.offset = 0; compId = F_ApiNewBookComponentInHierarchy(bookId, savePath, &elemLoc); /* Update book */ F_ApiSimpleGenerate(bookId, False, True); bookPath = F_ApiGetString(FV_SessionId, bookId, FP_Name); /* Save book and docs after update */ F_ApiSimpleSave(docId, savePath, False); F_ApiSimpleSave(bookId, bookPath, False); /* Deallocating memory */ F_ApiDeallocateString(&bookPath); F_ApiDeallocateString(&savePath); F_ApiDeallocateString(&edefName); F_ApiClose (dlgId, FF_CLOSE_MODIFIED); }
VoidT editHeader() { F_ObjHandleT docId, bodyPageId, masterPageId, pageFrameId, textFrameId, paraHeaderId, headerVarId, varFmtId, nextParaId, highId, firstFlowId, edefId; F_TextLocT headerLoc; StringT headerText, idText, elemName; F_AttributesT attributes; UIntT j; /* get Id of the active document */ docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveDoc); /* get Id of the Right MasterPage*/ masterPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstMasterPageInDoc); /* Get Id of the first Page masterPage */ masterPageId = F_ApiGetId(FV_SessionId, masterPageId, FP_PageNext); /* Get Id of the pageFrame of masterPage*/ pageFrameId = F_ApiGetId(FV_SessionId, masterPageId, FP_PageFrame); /* Get Id of TextFrame of PageFrame */ textFrameId = F_ApiGetId(FV_SessionId, pageFrameId, FP_FirstGraphicInFrame); /* Get Id of First Paragraph of TextFrame */ paraHeaderId = F_ApiGetId(FV_SessionId, textFrameId, FP_FirstPgf); /* Insert new first paragraph and delete old first */ nextParaId = F_ApiNewSeriesObject(docId, FO_Pgf, paraHeaderId); F_ApiDelete(docId, paraHeaderId); /* Create insertion point in new paragraph */ headerLoc.objId = nextParaId; headerLoc.offset = 0; //headerLoc = F_ApiAddText(docId, &headerLoc, "Test text\'s header"); /* Create new variable format for header string */ varFmtId = F_ApiGetNamedObject(docId, FO_VarFmt, "userVarFormat"); if (FA_errno == FE_NameNotFound) { varFmtId = F_ApiNewNamedObject(docId, FO_VarFmt, "userVarFormat"); FA_errno = FE_Success; } bodyPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstBodyPageInDoc); pageFrameId = F_ApiGetId(docId, bodyPageId, FP_PageFrame); textFrameId = F_ApiGetId(docId, pageFrameId, FP_FirstGraphicInFrame); firstFlowId = F_ApiGetId(docId, textFrameId, FP_Flow); highId = F_ApiGetId(docId, firstFlowId, FP_HighestLevelElement); edefId = F_ApiGetId(docId, highId, FP_ElementDef); elemName = F_ApiGetString(docId, edefId, FP_Name); //F_Printf(NULL, "%s\n", elemName); attributes = F_ApiGetAttributes(docId, highId); for(j=0; j<attributes.len; j++) { if (F_StrEqual("Name", attributes.val[j].name)) { idText = F_StrCopyString(attributes.val[j].values.val[0]); F_StrStripTrailingSpaces(idText); F_StrStripLeadingSpaces(idText); break; } } headerText = F_StrCopyString(elemName); headerText = F_Realloc(headerText, F_StrLen(headerText)+F_StrLen(" <Emphasis>")+1, NO_DSE); F_StrCat(headerText," <Emphasis>"); //F_Printf(NULL, "A%sA\n", idText); //F_Printf(NULL, "%s\n", headerText); if (!F_StrIsEmpty(idText)) { headerText = F_Realloc(headerText, F_StrLen(headerText)+F_StrLen(idText)+1,NO_DSE); F_StrCat(headerText,idText); //F_Printf(NULL, "%s\n", headerText); //F_ApiPrintFAErrno(); } F_StrStripTrailingSpaces(headerText); //F_ApiAlert(headerText,FF_ALERT_CONTINUE_NOTE); F_ApiSetString(docId, varFmtId, FP_Fmt, headerText); //F_ApiPrintFAErrno(); /* Insert variable with created format into header */ headerVarId = F_ApiNewAnchoredFormattedObject(docId, FO_Var, "userVarFormat", &headerLoc); }