Copy link to clipboard
Copied
Hi,
I am writing a ChangeToInline function with kChangeILGCmdBoss command, exactly like SnpManipulateInline::ChangeToInline.
But, the command has a strange behavior. Item is anchored inline, but a copy of it rest on the page.
This copy is like a phantom item. I can't select it and I can't delete it, it's not in a locked layer, but appears on the page.
Can anyone tell me how could I delete it ?
Thanks.
Copy link to clipboard
Copied
Let me explain a little more my problem.
Just modify the SnpManipulateInline::CreateFrame function like this :
#include "FileUtils.h"
#include "ISpreadList.h"
#include "ISpread.h"
ErrorCode SnpManipulateInline::CreateFrame(IDataBase* database, UIDRef& newFrameUIDRef)
{
// You can make any type of frame into an inline. Here we make a new graphic frame.
PMRect bounds(0, 0, 100, 100);
SDKLayoutHelper layoutHelper;
IDFile imageFile;
FileUtils::PMStringToIDFile("c:\\tmp\\colorbars.tif",imageFile);
// Get reference to spread layer
InterfacePtr<ISpreadList> iSpreadList(database,database->GetRootUID(),UseDefaultIID());
InterfacePtr<ISpread> iSpread(database,(iSpreadList->GetNthSpreadUID(0)),UseDefaultIID());
SDKLayoutHelper helper;
UIDRef spreadLayerRef=helper.GetSpreadLayerRef(::GetUIDRef(iSpread));
// Place image
newFrameUIDRef=layoutHelper.PlaceFileInFrame(imageFile,spreadLayerRef,bounds, K2::kSuppressUI);
//newFrameUIDRef = layoutHelper.CreateRectangleFrame(UIDRef(database, kInvalidUID), bounds);
if (newFrameUIDRef)
return kSuccess;
else
return kFailure;
}
Then try it in SnippetRunner. This is the result :
and you see what I means.
Copy link to clipboard
Copied
Just detach object to be placed inline from it's father.
Here's sample code from SnpManipulateInline.cpp
ErrorCode
SnpManipulateInline::InsertInline(const UIDRef& storyUIDRef, const TextIndex& whereTextIndex)
{
ErrorCode status = kFailure;
CmdUtils::SequencePtr cmdSeq;
do {
#if 0
UIDRef newFrameUIDRef;
status = this->CreateFrame(storyUIDRef.GetDataBase(), newFrameUIDRef);
ASSERT(status == kSuccess);
if (status != kSuccess) {
break;
}
#else
UIDRef newFrameUIDRef(storyUIDRef.GetDataBase(),230); // 230 : UID of a 'normal' existing object
// Get father
InterfacePtr<IHierarchy> iHierarchy(newFrameUIDRef, UseDefaultIID());
IHierarchy *iParentHierarchy = iHierarchy->QueryParent();
// Detach it
iParentHierarchy->Remove(iHierarchy);
Copy link to clipboard
Copied
It seems to be OK.
But, use IHierarchyUtils->RemoveFromHierarchy to detach from hierarchy.
For not change model without command.
Thanks for help Jacques.