Ejemplo n.º 1
0
VoidT setAttributes(StringT idStr, StringT nameStr)
{
	F_ObjHandleT docId, bodyPageId, pageFrameId, textFrameId, firstFlowId, highId;
	F_AttributesT attributes;

	/* get Id of the active document */
	docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveDoc);
	/* get Id of the BodyPage*/
	bodyPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstBodyPageInDoc);
	/* Get Id of the pageFrame of masterPage*/
	pageFrameId = F_ApiGetId(docId, bodyPageId, FP_PageFrame);
	/* Get Id of TextFrame of PageFrame */
	textFrameId = F_ApiGetId(docId, pageFrameId, FP_FirstGraphicInFrame);
	/* Get Id of First Flow in TextFrame */
	firstFlowId = F_ApiGetId(docId, textFrameId, FP_Flow);
	/* Get Id of the highest-level element in document */
	highId = F_ApiGetId(docId, firstFlowId, FP_HighestLevelElement);
	/* Create F_AttributesT structure to set values*/
	attributes.len = 2;
	attributes.val = (F_AttributeT *)F_Alloc(2*sizeof(F_AttributeT), DSE);
	attributes.val[0].name = F_StrCopyString("Id");
	attributes.val[0].values.len = 1;
	attributes.val[0].values.val = (StringT *)F_Alloc(sizeof(StringT), DSE);
	attributes.val[0].values.val[0] = F_StrCopyString(idStr);
	attributes.val[1].name = F_StrCopyString("Name");
	attributes.val[1].values.len = 1;
	attributes.val[1].values.val = (StringT *)F_Alloc(sizeof(StringT), DSE);
	attributes.val[1].values.val[0] = F_StrCopyString(nameStr);
	/* Set proper values */
	F_ApiSetAttributes(docId, highId, &attributes);
}
Ejemplo n.º 2
0
VoidT ReadStylesFromIniSect(StringT ininame, IntT sectnum)
{
	DesStyleT *curr = NULL;
	StringT section = StyleSections[sectnum];
	StringT sname = NULL;
	StringT props = NULL;
	StringT aname = NULL;


	/* scan DesStyles list for match, or add to end, and set props */
	GetIniSect(ininame, section);
	while ((sname = GetIniSectKey()) != NULL) {
		curr = FindStyleInDesStyles(sname);
		if (!curr) {
			curr = LastDesStyle;
			curr->next = CreateDesignerStyle(F_StrCopyString(sname));
			curr = (DesStyleT *) curr->next;
			curr->para = True;  /* we presume */
			curr->next = NULL;
			LastDesStyle = curr;
			DesStyleCount++;
		}
		aname = Fm2a(sname);
		GetIniString(ininame, section, aname, &props);
		F_Free(aname);
		GetIniStyleProps(ininame, sectnum, props, curr);
	}
}
Ejemplo n.º 3
0
VoidT SetupOMHIniDialog(StringT filename, F_ObjHandleT bookId)
{
	F_ObjHandleT dlgId = 0;
	F_ObjHandleT compId = 0;
	StringT basename = NULL;
	StringT compname = NULL;
	StringT topicfile = NULL;

	basename = BaseFileName(filename);

	/* open resource for OMH Settings dialog box. */
	dlgId = F_ApiOpenResource(FO_DialogResource, "m2rsetc");
	DlgIds[DLG_SETUP_OMH_INI - 1] = dlgId;

	/* set CurrProjectName and Path at top of dialog */
	SetDlgProject(dlgId, DLG_SC_PROJDESC);

	/* set up name for [MAP] file */
	CshMapFileSet = False;
	CshMapFile = NULL;
	//SetDlgText(dlgId, DLG_SC_CSHMAP, "resource.h");

	/* set checkboxes for TOC and IX inclusion and search generation */
	UseFmTOC = UseFmIX = False;
	UseFmGenFiles = True;
	UseOHTOC = UseOHIX = UseOHFTS = UseOHREL = True;

	/* these are always the same */
	GenTOC = GenIX = True;
	WrapAndShip = True;

	SetDlgState(dlgId, DLG_SC_FM_TOC, UseFmTOC);
	SetDlgState(dlgId, DLG_SC_FM_IX, UseFmIX);
	SetDlgState(dlgId, DLG_SC_FM_GEN, UseFmGenFiles);

	SetDlgState(dlgId, DLG_SC_USE_TOC, UseOHTOC);
	SetDlgState(dlgId, DLG_SC_USE_IX, UseOHIX);
	SetDlgState(dlgId, DLG_SC_USE_FTS, UseOHFTS);
	SetDlgState(dlgId, DLG_SC_USE_REL, UseOHREL);

#if 0
	SetDlgState(dlgId, DLG_SC_COPY_TO, WrapAndShip);
	SetDlgText(dlgId, DLG_SC_HP_PATH, WrapPath);
	SetDlgText(dlgId, DLG_SC_VW_PATH, OHVName);
#endif

	if (bookId) {  /* get basename of first file in book */
		compId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);
		compname = F_ApiGetString(bookId, compId, FP_Name);
		topicfile = BaseFileName(compname);
		F_StrFree(compname);
	}
	else
		topicfile = F_StrCopyString(basename);
	SetDlgText(dlgId, DLG_SC_CONTENTS, topicfile);
	DefaultTopicFile = NULL;
	TopicFileSet = False;

	SetDlgText(dlgId, DLG_SC_PROJECT, basename);

	/* put dummy title */
	SetDlgText(dlgId, DLG_SC_TITLE, HelpTitle);

	UseCSS = True;
	CssFileName = "ohmain.css";
	SetDlgText(dlgId, DLG_SC_CSS, CssFileName);

	/* turn off everything under template */
	SetFrameTemplateDlg(dlgId, DLG_SC_TPL_CK);

	SetupCancelled = True;  /* default if closed */
	F_ApiModalDialog(DLG_SETUP_OMH_INI, dlgId);

	WriteEqns = True;
	WriteAllGraphics = True;

	F_StrFree(basename);
}
Ejemplo n.º 4
0
VoidT GetIniStyleProps(StringT ininame, IntT sectnum, StringT props, DesStyleT *curr)
{
	DesStyleT *right;
	StringT pPr = NULL;
	StringT term = NULL;
	StringT pval = NULL;
	BoolT first = True;
	IntT i = 0;

	StringT aname = NULL;

	if (props == NULL)
		return;

	aname = Fm2a(curr->name);

	switch (sectnum) {
		case 0:  /* Styles */
			curr->remap = True;
			curr->rem_name = props;
			// add rem_name to list
			right = FindStyleInDesStyles(curr->rem_name);
			if (!right) {
				right = LastDesStyle;
				right->next = CreateDesignerStyle(F_StrCopyString(curr->rem_name));
				right = (DesStyleT *) right->next;
				right->next = NULL;
				LastDesStyle = right;
				DesStyleCount++;
			}
			// else error, should be new name
			right->para = curr->para;  /* we hope */
			break;

		case 1: /* StyleReplacements */
			curr->replace = True;
			curr->rep_name = props; 
			break;
	
		case 2: /* HelpStyles */
			pPr = props;
			term = props;
			first = True;
			curr->helptyp = 0;
			curr->ungreen = True;
			curr->nouline = True;
			while (*pPr) {
				while (*term
						&& (*term != ' '))
					term++;
				if (*term)
					*term++ = '\0';
				if (first) {
					for (i = 0; i < STY_START_COUNT; i++)
						if (!F_StrICmp(pPr, HelpStyleStart[i]))
							break;
					switch (i) {
						case 0:
							curr->helptyp = 1;
							curr->topictyp = 0;
							break;
						case 1:
							curr->helptyp = 1;
							curr->topictyp = 2;
							break;
						case 2:
							curr->helptyp = 2;
							curr->hotsptyp = 0;
							GetIniString(ininame, HelpStyleSects[5], aname,
													 &(curr->fixed_name));
							if (curr->fixed_name)
								curr->fixed = True;
							break;
						case 3:
							curr->helptyp = 2;
							curr->hotsptyp = 1;
							GetIniString(ininame, HelpStyleSects[5], aname,
													 &(curr->fixed_name));
							if (curr->fixed_name)
								curr->fixed = True;
							break;
						case 4:
							curr->helptyp = 2;
							curr->hotsptyp = 3;
							break;
						case 5:
							curr->helptyp = 3;
							break;
						case 6:
							curr->helptyp = 3;
							curr->pop_cont = True;
							break;
						case 7:
							curr->helptyp = 4;
							GetIniString(ininame, HelpStyleSects[2], aname,
													 &(curr->mac_name));
							break;
						case 8:
							curr->usekey = True;
							break;
						case 9:
							curr->akey = True;
							break;
						case 10:
							GetIniString(ininame, HelpStyleSects[9], aname,
													 &(curr->keys));
							break;
						case 11:
							curr->helptyp = 2;
							curr->hotsptyp = 2;
							curr->window = True;
							GetIniString(ininame, HelpStyleSects[1], aname,
													 &(curr->win_name));
							break;
						default:
							break;
					}
					first = False;
				}
				else {
					for (i = 0; i < STY_HKEY_COUNT; i++)
						if (!F_StrICmp(pPr, HelpStyleKeys[i]))
							break;
					if (i < STY_HSECT_COUNT)
						GetIniString(ininame, HelpStyleSects[i], aname, &pval);
					switch (i) {
						case 0:
							curr->browse = True;
							curr->br_px = pval;
							break;
						case 1:
							curr->window = True;
							curr->win_name = pval;
							break;
						case 2:
							curr->mac_name = pval;
							break;
						case 3:
							curr->build = True;
							curr->build_tag = pval;
							break;
						case 4:
							if (!pval)
								break;
							curr->cont = True;
							switch (*pval) {
								case 'V':
									curr->conttyp = 0;
									break;
								case 'H':
									curr->conttyp = 1;
									break;
								case 'T':
									curr->conttyp = 2;
									break;
								case 'B':
									curr->conttyp = 3;
									break;
								default:
									break;
							}
							curr->contlev = F_StrCopyString(pval + 1);
							F_StrFree(pval);
							break;
						case 5: // Refer (Topic only)
							curr->refer = True;
							break;
						case 6: // Suffix
							curr->refer = True;
							curr->ref_sx = pval;
							break;
						case 7:
							curr->titsx = True;
							curr->title_sx = pval;
							break;
						case 8:
							curr->fileref = True;
							curr->file_name = pval;
							break;
						case 9:
							curr->keys = pval;
							break;
						case 10:
							curr->usekey = True;
							break;
						case 11:
							curr->akey = True;
							break;
						case 12:
							curr->notitle = True;
							break;
						case 13:
							curr->topictyp = 1;
							break;
						case 14:
							curr->noscr_used = True;
							curr->noscroll = False;
							break;
						case 15:
							curr->noscr_used = True;
							curr->noscroll = True;
							break;
						case 16:
							curr->xtscr_used = True;
							curr->xtscroll = True;
							break;
						case 17:
							curr->xtscr_used = True;
							curr->xtscroll = False;
							break;
						case 18:
							curr->local = True;
							break;
						case 19:
							curr->ungreen = False;
							break;
						case 20:
							curr->nouline = False;
							break;
						default:
							break;
					}
				}
				pPr = term;
			}

			F_StrFree(props);
			break;

		default:
			F_StrFree(props);
			break;
	}

	F_Free(aname);
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
BoolT newSecondLevelSection(BoolT isFirst, StringT type, StringT *newFileName)
{
	F_ObjHandleT bookId, sectionDlgId, compId, elemId;
	StringT fileName;
	F_AttributesT attributes;
	F_ElementLocT elemLoc;

	/* Get Id of the book */
	//bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);
	bookId = getActiveBookID();
	/* Open resource for the Create new DocumentationCore || ProductDocumentation || ProductLine section dialog */
	sectionDlgId = F_ApiOpenResource(FO_DialogResource, "DOCCORE");	
	if (!isFirst)
		F_ApiSetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 5), FP_Visibility, False);
	else
		F_ApiSetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 5), FP_Visibility, True);
	if (F_StrIEqual(type, "ProductDocumentation"))
	{
		F_ApiSetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 0), FP_Label, "Type FileName attribute of new ProductDocumentation section:");	
		F_ApiSetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 5), FP_Label, "There is no ProductDocumentation section in project. New section will be created.");	
	}
	else if (F_StrIEqual(type, "ProductLine"))
	{
		F_ApiSetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 0), FP_Label, "Type FileName attribute of new ProductLine section:");
		F_ApiSetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 5), FP_Label, "There is no ProductLine section in project. New section will be created.");	
	}

	F_ApiModalDialog(SECTION_DLG, sectionDlgId);
	/* define which button was clicked */
	if((F_ApiGetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 4), FP_State) == True) ||
		(F_ApiGetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 3), FP_State) != True))
	{
		F_ApiClose (sectionDlgId, FF_CLOSE_MODIFIED);
		return False;
	}
	/* make sure that FileName attribute was typed in the text box */
	while (F_StrIsEmpty(F_ApiGetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 1), FP_Text)))
	{
		F_ApiAlert("You must type FileName attribute in the text field!", FF_ALERT_CONTINUE_NOTE);
		F_ApiModalDialog(SECTION_DLG, sectionDlgId);
		if((F_ApiGetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 4), FP_State) == True) ||
			(F_ApiGetInt(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 3), FP_State) != True))
		{
			F_ApiClose (sectionDlgId, FF_CLOSE_MODIFIED);
			return False;
		}
	}
	/* get fileName attribute value from dialog box*/
	fileName = F_StrCopyString(F_ApiGetString(sectionDlgId, F_ApiDialogItemId(sectionDlgId, 1), FP_Text));
	/* Get Id of Section Element definitions*/
	elemId = F_ApiGetNamedObject(bookId, FO_ElementDef, type);
	elemLoc.parentId = F_ApiGetId(FV_SessionId, bookId, FP_HighestLevelElement);
	elemLoc.childId = 0;
	elemLoc.offset = 0;
	compId = F_ApiNewElementInHierarchy(bookId, elemId, &elemLoc);
	/* Create F_AttributesT structure to set FileName value */
	attributes.len = 1;
	attributes.val = (F_AttributeT *)F_Alloc(sizeof(F_AttributeT), DSE);
	attributes.val[0].name = F_StrCopyString("FileName");
	attributes.val[0].values.len = 1;
	attributes.val[0].values.val = (StringT *)F_Alloc(sizeof(StringT), DSE);
	attributes.val[0].values.val[0] = F_StrCopyString(fileName);
	*newFileName = F_StrCopyString(fileName);
	/* Set proper values */
	F_ApiSetAttributes(bookId, compId, &attributes);
	F_ApiClose (sectionDlgId, FF_CLOSE_MODIFIED);
	return True;
}