Copy link to clipboard
Copied
Hi All,
I have tried more than one week to update the modified link through C++ plugin code. After executing the below code, It shows yellow highlighted modified icon. But the link is not updated.
ILinkManager::QueryResult linkQueryResult;
uint32 count=iLinkManager->QueryResources(linkQuery,linkQueryResult);
for (ILinkManager::QueryResult::const_iterator linkIter(linkQueryResult.begin()), end(linkQueryResult.end()); linkIter != end; ++linkIter)
{
InterfacePtr<ILinkResource> iLinkResource(iDatabase, *linkIter ,UseDefaultIID());
if(iLinkResource!=nil)
{
URI newURI = iLinkResource->GetURI();
newURI.SetComponent(URI::kScheme, targetScheme);
Utils<Facade::ILinkFacade>()->ReinitResource(UIDRef(iDatabase, *linkIter), newURI);
}
}
Could anyone help me to resolve this issue?
Thanks.
I tested this code snippet and it does update the resource but the link is out of date, we need to explicitly update the link. So either you use the RelinkLink method as I demonstrated in another thread or call the link update method explicitly. Try the following, I am still using the path change method and not scheme change, that should also work the same.
IDocument * doc = GetExecutionContextSession()->GetActiveContext()->GetContextDocument();
InterfacePtr<ILinkManager> linkManager(doc,UseDefa
...
Copy link to clipboard
Copied
I tested this code snippet and it does update the resource but the link is out of date, we need to explicitly update the link. So either you use the RelinkLink method as I demonstrated in another thread or call the link update method explicitly. Try the following, I am still using the path change method and not scheme change, that should also work the same.
IDocument * doc = GetExecutionContextSession()->GetActiveContext()->GetContextDocument();
InterfacePtr<ILinkManager> linkManager(doc,UseDefaultIID());
ILinkManager::QueryResult linkQueryResult;
LinkResourceQuery linkResQuery;
uint32 count=linkManager->QueryResources(linkResQuery, kIDLinkClientID, linkQueryResult);
for (ILinkManager::QueryResult::const_iterator linkIter(linkQueryResult.begin()), end(linkQueryResult.end()); linkIter != end; ++linkIter)
{
InterfacePtr<ILinkResource> iLinkResource(::GetDataBase(doc), *linkIter, UseDefaultIID());
if(iLinkResource!=nil)
{
URI newURI = iLinkResource->GetURI();
newURI.SetComponent(URI::kPath, WideString("/Users/manan/Downloads/test.pdf"));
Utils<Facade::ILinkFacade>()->ReinitResource(UIDRef(::GetDataBase(doc), *linkIter), newURI);
UIDList lnks(::GetDataBase(doc));
Utils<Facade::ILinkFacade>()->GetResourceLinks(::GetUIDRef(iLinkResource), true, lnks);
for(int i = 0 ; i < lnks.Length(); i++)
{
InterfacePtr<ILink> iLink(lnks.GetDataBase(), lnks.At(i), UseDefaultIID());
UID newLinkUID;
iLink->Update(true, UIFlags::kSuppressUI, newLinkUID);
}
}
}
P.S.:- Could you tell the scheme change source and destination values that you are trying to manipulate
-Manan
Copy link to clipboard
Copied
I tested the code with in my plugin. It is working well. Fantastic!!
Thank you so much Manan.