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

[IDCS5] Change to inline make a strange behavior

New Here ,
Nov 04, 2010 Nov 04, 2010

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.

TOPICS
SDK

Views

608

Translate

Translate

Report

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 ,
Nov 05, 2010 Nov 05, 2010

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 :

inline.jpg

and you see what I means.

Votes

Translate

Translate

Report

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
Participant ,
Nov 09, 2010 Nov 09, 2010

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);


#endif
        status = this->ChangeToInline(storyUIDRef, whereTextIndex, newFrameUIDRef);
        ASSERT(status == kSuccess);
    } while (false);
    if (status != kSuccess)
        ErrorUtils::PMSetGlobalErrorCode(status);
    return status;
}

Votes

Translate

Translate

Report

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 ,
Nov 09, 2010 Nov 09, 2010

Copy link to clipboard

Copied

LATEST

It seems to be OK.

But, use IHierarchyUtils->RemoveFromHierarchy to detach from hierarchy.

For not change model without command.

Thanks for help Jacques.

Votes

Translate

Translate

Report

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