FrameMaker 10とExtendedScriptのセミナーがAdobe eSeminarであったみたいです。
その時のサンプルデータとスライドが下のブログに上がっています。 http://frameautomation.com/2011/05/31/framemaker-10-extendscript-slides/
オブジェクトチェックにObjectValid()というメソッドがあったのか。
あと、イベント処理とかもいけるのか。
FrameMaker 10とExtendedScriptのセミナーがAdobe eSeminarであったみたいです。
その時のサンプルデータとスライドが下のブログに上がっています。 http://frameautomation.com/2011/05/31/framemaker-10-extendscript-slides/
オブジェクトチェックにObjectValid()というメソッドがあったのか。
あと、イベント処理とかもいけるのか。
スクリプトを使ってカーソルの位置にアンカー枠を作成してその中に画像を挿入する例。
オブジェクトビュアーの列挙型の情報がアレなので結局FDKリファレンスを見たほうが早いという罠。
(function(){ // Insert illust filename var InsertFile = "hogehoge.jpg"; var docObj = app.ActiveDoc; if (docObj.id === 0) { Alert("select document", Constants.FF_ALERT_CONTINUE_NOTE); return; } var selObj = docObj.TextSelection; if (selObj.beg.obj.id === selObj.end.obj.id && selObj.beg.offset === selObj.end.offset) { // Add Anchored frame var aframeObj = docObj.NewAnchoredAFrame(selObj.beg); aframeObj.AnchorType = Constants.FV_ANCHOR_BELOW; aframeObj.FP_Alignment = Constants.FV_ALIGN_CENTER; // Insert illust in anchored frame var graphicObj = docObj.NewGraphicObject (Constants.FO_Inset, aframeObj); graphicObj.InsetFile = InsertFile; graphicObj.InsetDpi = 150; // Fit anchored frame aframeObj.Width = graphicObj.Width; aframeObj.Height = graphicObj.Height; } else { Alert("select text insert location", Constants.FF_ALERT_CONTINUE_NOTE); } })();
var mMenu = app.GetNamedMenu("!MakerMainMenu"); var nMenu = mMenu.DefineAndAddMenu("APIMenu", "TextApi"); nMenu.DefineAndAddCommand(1, "GetTextCmd", "Get Text",""); nMenu.DefineAndAddCommand(2, "AddTextCmd","Insert Text","\\!GT"); nMenu.DefineAndAddCommand(3, "DeleteTextCmd", "Delete Text", "\\!IT"); nMenu.DefineAndAddCommand(4, "ColorTextCmd", "Color Text", "\\!DT"); nMenu.DefineAndAddCommand(5, "FontSizeCmd", "Change Font Size", "\\!CT"); UpdateMenus(); function Command(command) { var doc = app.ActiveDoc; if(doc.id === 0) Alert("Please selected Document.", Constants.FF_ALERT_CONTINUE_WARN); switch(command) { /* Get text from selection. */ case 1: var tr = doc.TextSelection; if (tr.beg.obj.id === 0 || ((tr.beg.obj.id === tr.end.obj.id) && (tr.beg.offset === tr.end.offset))) { Alert("Please select some text and try again.", Constants.FF_ALERT_CONTINUE_WARN); break; } var textItems = doc.GetTextForRange(tr, Constants.FTI_String); alert(CreateStringFromTextItems(textItems)); break; /* Add text. */ case 2: var tr = doc.TextSelection; if (tr.beg.obj.id === 0) { Alert("Please select an insertion point and try again.", Constants.FF_ALERT_CONTINUE_WARN); break; } if (!((tr.beg.obj.id === tr.end.obj.id) && (tr.beg.offset === tr.end.offset))) { if (Alert("Do you wish to overwrite the selected text?", Constants.FF_ALERT_NO_DEFAULT)) break; } doc.AddText(tr.beg, "The new CoffeeTool\011"); break; /* Delete selected text. */ case 3: var tr = doc.TextSelection; if (tr.beg.obj.id === 0 || ((tr.beg.obj.id === tr.end.obj.id) && (tr.beg.offset === tr.end.offset))) { Alert("Please select some text and try again.", Constants.FF_ALERT_CONTINUE_WARN); break; } doc.DeleteText(tr); break; /* Change the color of selected text to Red. */ case 4: var tr = doc.TextSelection; if (tr.beg.obj.id === 0 || ((tr.beg.obj.id === tr.end.obj.id) && (tr.beg.offset === tr.end.offset))) { Alert("Please select some text and try again.", Constants.FF_ALERT_CONTINUE_WARN); break; } var color = doc.GetNamedObject(Constants.FO_Color, "Red"); // Color name is different in each language. var props = doc.GetTextProps(tr.beg); var i = GetPropIndex(props, Constants.FP_Color); props[i].propVal.obj = color; doc.SetTextProps(tr, props); break; /* Change the font size of the selected text to 30 points. */ case 5: var tr = doc.TextSelection; if (tr.beg.obj.id === 0 || ((tr.beg.obj.id === tr.end.obj.id) && (tr.beg.offset === tr.end.offset))) { Alert("Please select some text and try again.", Constants.FF_ALERT_CONTINUE_WARN); break; } /* Allocate memory for the property list. */ props = AllocatePropVals(1); /* Set up the properties. */ props[0].propIdent.num = Constants.FP_FontSize; props[0].propVal.ival = 30 * 65536; props[0].propVal.valType = Constants.FT_Metric; /* Apply the property list to the text selection. */ doc.SetTextProps(tr, props); break; } } /*************************************************************** * Create a string from an TextItems structure. ****************************************************************/ function CreateStringFromTextItems(textItems) { var s = ""; for (var i = 0; i < textItems.length; i++) { if (textItems[i].dataType === Constants.FTI_String) { s += textItems[i].sdata; } } return s; }
FrameMaker 10の発表、そして出荷が始まったらしい。
昨年末に動画で登場していたときにはすでにマスターアップが完了していたということなのだろう。
アップグレード内容はS1000、DITA1.2対応、それに関連する機能の強化が主なんだろう。市販のCMS(SharePoint、Documentum)に対応といったところだ。
早速、体験版を入れてあれこれ触ってみて目についた新しい機能は
下は10分位で適当に作ったスクリプトです。選択した画像のアンカー枠の大きさを選択した画像の大きさに合わせるスクリプトです。
var docObj = app.ActiveDoc;
var selGfx = docObj.FirstSelectedGraphicInDoc;
var afrmObj = selGfx.FrameParent;
afrmObj.Width = selGfx.Width;
afrmObj.Height = selGfx.Height;
selGfx.LocX = 0;
selGfx.LocY = 0;
問題はバージョンアップできるのが8からということか。(TCS3だと7.xからできるが本体より高い)
まだ世の中で動いているシステムの大半が7.x以下ではないだろうか。
FrameMaker Developer's Forumで面白い投稿があったのでメモ。
画像が表示できませんやマスターページを適用しますかといったアラートをFDKで取得し、自動ではいを押すプログラムです。
ここで使用されているFP_ActiveAlertはリファレンスにも載っていない実験的なプロパティみたいです。
#include "fapi.h" #include "fdetypes.h" #include "futils.h" VoidT F_ApiInitialize(IntT init) { if (init == FA_Init_First) { F_ApiNotification(FA_Note_Alert, True); F_ApiBailOut(); } } VoidT F_ApiNotify(IntT notification, F_ObjHandleT docId, StringT filename, IntT iparm) { F_ObjHandleT alertId; IntT uniq; switch (notification) { case FA_Note_Alert: // Get the id of the alert. alertId = F_ApiGetId(0, FV_SessionId, FP_ActiveAlert); uniq = F_ApiGetInt(FV_SessionId, alertId, FP_Unique); // If the alert is "Cannot display some imported graphics...", supppress it. switch(uniq) { case 40086: //"Cannot display some imported graphics..." case 40090: //"Cannot display some imported graphics..." case 46001: //Suppress ApplyMasterpages message F_ApiReturnValue(FR_YesOperation); break ; case 0: //Unfortunately no ID for "The font information changed..." if (F_StrCmp(filename, (StringT)"The font information for your system has changed. This change may affect the format and output of your document(s).")) F_ApiReturnValue(FR_YesOperation); if (F_StrCmp(filename, (StringT)"Die Schriftinformation für Ihr System hat sich geändert. Diese Änderung kann sich auf Formatierung und Ausgabe Ihrer Dokumente auswirken.")) F_ApiReturnValue(FR_YesOperation); break; default: break; } break; default: break; } F_ApiBailOut(); }
文書にFDKを使用してマスターページの適用を行いたいがここにアクセスするためのAPIがbookファイルからしか用意されていない。
fcodeからのアクセス方法を調べてもないです。
しかし、ESC、M、Pと順番に入力するとマスターページの適用が実行されることが判ったので(ヘルプにすら書いていない)、キーコードを送信すれば・・・
static IntT fcodes[] = {FC_ESC, 'M', 'P'}; F_ApiFcodes(sizeof(fcodes)/sizeof(IntT), fcodes);
実行されますが、ダイアログが出てしまいます。
このダイアログは消せないので、Win32APIのSendMessage使って、OKボタンを押してやってください。
Windows NT系でOpenTypeフォントを使用していると、時々文字欠けをしてしまいます。(欠ける文字もランダムだから困っちゃう)
原因はOSのバグでHotFixが公開されています。XPはSP4、VistaはSP2で同梱されているらしいです。
http://support.microsoft.com/?id=952909 (HotFix詳細)
http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=952909&kbln=en-us (直リンク)
Hotfix for FrameMaker
FDKを新規作成方法です。VC2008Expressで説明だけど、ほかのバージョンでも大丈夫のはず。
// for FDK #define DONT_REDEFINE // Console app needs native types #define WBUFLEN 512 #include "fapi.h" #include "fdetypes.h" #include "futils.h" #include "fstrings.h"
hello=Standard, Greets user at startup,*fdk_install_dir\samples\hello\debug\hello.dll, all