Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Persistent embedded data conversion

New Here ,
Dec 13, 2007 Dec 13, 2007
[Content]
I have a InDesign plugin which is used to apply tag to text.
The tag's format is K1\=tagName1 R1\=tagValue1 K2\=tagName2 R2\=tagValue2,
which is saved by char array.
This plugin is devoloped by other person, and used a lot of c code.

So I devoloped a new version by c++ code.
And now the tag's format is K1=tagName1 R1=tagValue1 K2=tagName2
R2=tagValue2,which is saved by PMString.

My purpose now is want to convert the old version to new version.
So I add a conversion service to the new plugin,and implement my own
converter class.
I have read the [programming guide] about the [containers and embedded
data].

I added the boss to the ShouldConvertClass function in order to indicate
the boss to be converted.
And I wrote the code in the ConvertClass, the parameter [inLength] is
66, but the [oldData] is zero byte.

I still tried in ShouldConvertImplementation function and ConvertTag
function.But failed.

[Question]
How should I do if I want to convert embedded data from old version to
new version?
TOPICS
SDK
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 14, 2007 Dec 14, 2007
Have you incremented your plugin's persistent data version?
Sounds like that as you receive the calls at all.

Please also tell us what is outData.

I haven't yet had the need to write a converter myself, so I'm just speculating here, from reading IConversionProvider.h .

I would question your use of the class conversion rather than implementation conversion. There are rare cases where whole boss objects become embedded into the persistence stream of an implementation - I guess class conversion is mainly for those cases. Examples include text attributes that are deeply buried into their strands. In such a conversion, you'd have to read the stream in the same order used to build it originally, which should contain lenghts, implementation IDs, maybe checksums and who knows what else, before you finally get to your implementation data. Of course, you have to rebuild the data with the same format into the output stream.

If you just have to change the persistent data format of one implementation, stick to that tag conversion.

Dirk
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 14, 2007 Dec 14, 2007
I have a boss
Class
{
kVIE_DataTagBoss,
kAttrBossReferencingBoss,
{
IID_IVIE_DATATAGTEXTATTR, kVIE_DataTagTextAttrImpl,
IID_IATTRREPORT, kVIE_DataTagReportImpl,
IID_IATTRIMPORTEXPORT, kVIE_DataTagImportExportImpl,
}
}

The kVIE_DataTagTextAttrImpl has a ReadWrite function, which is to save the tag as PMString.

And I implement a converter,as follows:

ImplementationID ConvertTag(ImplementationID tag,ClassID forClass,int32 conversionIndex,int32 inLength,IPMStream* oldData,IPMStream* newData,IterationStatus whichIteration)
{
ImplementationID outImplID = tag;
switch(conversionIndex)
{
case 0:
if(tag == kVIE_PreferencesImpl)
ConvertPreference(oldData,newData);
break;
default:
break;
}
return outImplID;
}

ShouldConvertImplementation(ImplementationID tag, ClassID context, int32 conversionIndex) const
{
IConversionProvider::ConversionStatus status = IConversionProvider::kNothingToConvert;
switch(conversionIndex)
{
case 0:
if(tag == kVIE_PreferencesImpl)
status = IConversionProvider::kMustConvert;
break;
default:
break;
}
return status;
}

ShouldConvertClass (ClassID clsID, ImplementationID context, int32 conversionIndex) const
{
IConversionProvider::ConversionStatus status = IConversionProvider::kNothingToConvert;
switch(conversionIndex)
{
case 0:
if(clsID == kVIE_DataTagBoss)
status = IConversionProvider::kMustConvert;
break;
default:
break;
}
return status;
}

ConvertClass(ClassID clsID,ImplementationID embeddedContext,int32 conversionIndex,int32 inLength,IPMStream* oldData,IPMStream* newData,IterationStatus whichIteration)
{
ClassID outClsID = clsID;
switch(conversionIndex)
{
case 0:
if(clsID == kVIE_DataTagBoss)
ConvertTagName(oldData,newData);
break;
default:
break;
}
return outClsID;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 14, 2007 Dec 14, 2007
In ConvertTag function:
I have a document preference,which is used to save the infomation about the document. In old version, it had two char arrays. Now, I have changed it to PMString,so I need to convert it.
So I wrote the function ConvertPreference(IPMStream* oldData,IPMStream* newData), it was OK.

In ShouldConvertImplementaion function:
I made the kVIE_PreferencesImpl be converted.

In ShouldConvertClass function:
I made the kVIE_DataTagBoss be converted, because I can't be able to catch the kVIE_DataTagTextAttrImpl in both of ShouldConvertClass and ShouldConvertImplementaion.

In ConvertClass function:
I wrote the function ConvertTagName(IPMStream* oldData,IPMStream* newData),in this function,I got the old tags,and I changed it to new ones, and I wrote back to the newData. But it was wrong, I can't get the tags when I opened the document.

[Question]
How could I get the kVIE_DataTagTextAttrImpl in order to wrote the new tag to IPMStream?

Thank you! Dirk

In morning, I have tried to write mail to you, but it seems failed.
So I newed this topic.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 14, 2007 Dec 14, 2007
My question about the version number (in plugin resource) is unanswered, please revisit that point.

As I wrote, my post was just from reading through the header rather than from any actual experience with a conversion provider. That's as far as I can take it, maybe someone else has more to offer and is willing to share.

My submissions to this list and others, are copied without my agreement to sites outside Adobe, which are also harvested for email addresses. As a consequence, emails to my address as published on the forum are sorted to the other umpteen thousand spams that go there. You can get around a cascade of spam filters by putting my name into the subject, and not using a .cn domain as sender.

In general though, it makes no sense to contact me on issues from the forum, especially where I indicate limited experience. Besides to my postings here I have enough to do in consulting projects or own developments. Taking things off list reduces only the chance that others jump in with their experience or learn from yours. Of course it is different if you are a frequent contributor yourself, either here or in the wiki, or if you intend to hire a consultant. Another possibility would be to open a support case at Adobe.

Dirk
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 17, 2007 Dec 17, 2007
Thank you very much for your help,Dirk.
Now,I solve the problem.

The version number is not the problem,because I need to convert two persistent data,and one is successful.

The old version is kSDKDef_1J_PersistMajorVersionNumber,kSDKDef_1J_PersistMinorVersionNumber
And the new one is kVIE_FirstMajorFormatNumber,kVIE_FirstMinorFormatNumber,which are defined as follows:
#define kVIE_FirstMajorFormatNumber RezLong(1)
#define kVIE_FirstMinorFormatNumber RezLong(0)

But I still have a problem.
I change the new version tag format as old version but saved as PMString. And then I am able to find the implementation id of the tag attribute.

Why in old version,I am not able to get the implementation id?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 17, 2007 Dec 17, 2007
kSDKDef_1J_PersistMajorVersionNumber => kHotakaMajorFormatNumber => 2

So, in effect, you're downgrading your version from 2 to 1.
I would not do that. If any place in conversion manager assumes an ascending order it will become confused.

I do not yet understand your new problem. What do you mean with "get"?

When opening old documents, your conversion should read the old format and write the new, for all preexisting data. Then, when you instantiate the interface, it should read its data in the new format. Where in this process, do you expect an implementation id?

Do you encounter unconverted data in the new ReadWrite?
Are you sure there is original old data in your document, or is it already modified by some previous conversion attempts?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 17, 2007 Dec 17, 2007
The meaning of "get" is that when I implemented the function of ShouldConvertImplementation,I wrote that if(implementID) convert;
but the implementID statement is not processed.So I can't be able to write code in ConvertTag function in order to convert the old data to new ones,and passed the data to the interface of that implementID.

This is my problem.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 18, 2007 Dec 18, 2007
LATEST
We're running in circles here.

You haven't addressed my doubts that your document is still "original" in its old data.

Besides you haven't mentioned you fixed the order of the persistent version number. Order is relevant, see CConversionProvider.h with its InRange method. See CConversionProvider.h also for more methods and comments.

Eventually renumber your old implementation ID to a new implementation ID, but I think that's not the problem.

Make sure you've declared the matching VersionID pairs in the CountConversions/GetNthConversion methods. Compare them to the plugin specific data from the content manager, for both an old document with the old plugin, and a new document created by the new plugin. You reach kContentMgrBoss:IID_ICONTENTMGR via kDocBoss:IID_ICONTENTMGRACCESS .

Back to work ...
Dirk
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines