Thursday, June 24, 2004

Source code mismatch during debugging

When you are debugging an application, if the source executed by the debugger is different than the actual source code (i.e. the code executed is not the code showed in the source code) and you are sure the pdb is absolutely right for that dll/exe, it means one of these 2 things:

1. your source code is not up to date;

2. you may have non-dos line ending mixed in the file.

I did have this problem in the past days with code I've written pretty much from scratch, it turned up to be case number 2. Probably I copy-pasted a small portion from a mac code. A full conversion to DOS endings of the source file solved the problem. I was plagued by it since two weeks ago, but only in two files, that I didn't change very much in the last days, so I let the problem remain, but today I decided I had to solve the problem because there weren't any reasonable explanation of this weird problem. Fortunately I had the idea of checking the line endings of the file and that solved my problems.

Thursday, June 17, 2004

Indesign SDK - Query story metadata

How to query for story's metadata?

Simple, assuming storyRef is the UIDRef of the story:

    Utils inCopyWorkFlowUtils;

InterfacePtr model(storyRef, IID_ITEXTMODEL);
InterfacePtr iMetaData(inCopyWorkFlowUtils->QueryTextMetaDataBoss(model, kTrue));
if (iMetaData) {
InterfacePtr mdAcc(iMetaData, UseDefaultIID());
if (mdAcc) {
InterfacePtr mdPaths(mdAcc->Enumerate(0));
if (mdPaths) {
// iterate thru all paths
while (mdPaths->HasMorePaths()) {
PMString nspace, path;
// get the next path (by namespace and path)
mdPaths->GetNextPath(nspace, path);
PMString value;
MetaDataFeatures metaDataFeatures;
// inspect the node
if (mdAcc->Get(nspace, path, value, metaDataFeatures))


Wednesday, June 09, 2004

Indesign menus

It took me a while to figure it out how to add a submenu in the main File menu and position it whereever I want. The solution came from a Ken Sadahiro answer to a forum post, which point out to a Q & A session (login ASN web account required) on user interface.

I tried to do something similar, but the culprit is the 0 as the actionID for the sub-menu and the use of the delimiter ":" when adding the submenu.

Tuesday, June 08, 2004


I used to work for Tera until March 2003, recently I discovered a guy, Derek Lakin, who worked for NEP.

Nep (or I should say Nep's "this is" project) is a fantastic project that delivers all the regional news trough one big site, I was in charge of the part of the project that allow to transfer editorial content (pics and stories) from the editorial system to Nep's CMS.

Tuesday, June 01, 2004

Indesign SDK - custom draw palette

Indesign doesn't use windows to put together many panels into a palette or to draw the tab of a palette. It uses GDI (or the equivalent on the Mac) to draw everything on screen. IControlView is the interface for a "control", you can navigate the controls tree trough IWidgetParent interface (and GetParent method) and IPanelControlData or IPaletteControlData.

Suppose you have a panel that is subclassed by you, you can ask for the IPaletteControlData, this way:

IPaletteControlData* ppcd = nil;

InterfacePtr<IWidgetParent> parent(this, UseDefaultIID());

if( parent ) {

ppcd = static_cast<IPaletteControlData*>(parent->QueryParentFor(IID_IPALETTECONTROLDATA));


InterfacePtr<IPaletteControlData> pcd(ppcd);


Now you can use GetSectionCount and GetSection to retrieve the interface for the wanted control, the first one is the tab, the other is the entire panel. Suppose you want to enumerate the tabs in the palette, you need the PanelControlData for the tabs so:

InterfacePtr<IControlView> tabAreaView(pcd->GetSection(0), UseDefaultIID());


InterfacePtr<IPanelControlData> tabAreaCD(tabAreaView, UseDefaultIID());



for(int32 idx = 0; idx < tabAreaCD->Length(); idx++) {

InterfacePtr<IControlView> tabWidget(tabAreaCD->GetWidget(idx), UseDefaultIID());


And there you can draw whatever you want on the tab.