Skip to main content
Inspiring
June 20, 2013
Answered

How to flow text from selected text frame?

  • June 20, 2013
  • 1 reply
  • 1165 views

Hi,

I have problem to flow a text from selected text frame to next.

The below code insert only on selected frame and not flow to nextframe

Please suggest any idea to go forward.

IDFile picFile;

                    picFile.SetPath(WideString(filepath.GrabCString()));

//parentUIDRef TextFrame UIDREF

  InterfacePtr<IHierarchy> hierarchy(parentUIDRef, UseDefaultIID());

                    ASSERT(hierarchy);

                    if (!hierarchy) {

  break;

                    }

 

  InterfacePtr<ITransform> transform(parentUIDRef, UseDefaultIID());

                    ASSERT(transform);

                    if (transform == nil) {

  break;

                    }

 

                    InterfacePtr<IGeometry> itemGeometry(parentUIDRef, IID_IGEOMETRY);

                    InterfacePtr<ITransform> pParentTransform(parentUIDRef, IID_ITRANSFORM);    // get the Transform boss

                    PMRect pRC = itemGeometry->GetPathBoundingBox(InnerToPasteboardMatrix(pParentTransform));

 

                    PMPointList points(2);

                    PMPoint StartPoint = PMPoint(pRC.Left(),    pRC.Top());

                    PMPoint EndPoint   = PMPoint(pRC.Right(),pRC.Bottom());

 

                    points.push_back(StartPoint);

                    points.push_back(EndPoint);

 

 

  // Create kImportAndPlaceCmdBoss.

  InterfacePtr<ICommand> importAndPlaceCmd(CmdUtils::CreateCommand(kImportAndPlaceCmdBoss));

                    ASSERT(importAndPlaceCmd != nil);

                    if (importAndPlaceCmd == nil) {

  break;

                    }

 

  // Set up the command's data interfaces.

                    InterfacePtr<IPlacePIData> placePIData(importAndPlaceCmd, UseDefaultIID());

                    ASSERT(placePIData != nil);

                    if (placePIData == nil) {

  break;

                    }

                    placePIData->Set(parentUIDRef, &points, kFalse);

 

                    URI tmpURI;

                    Utils<IURIUtils>()->IDFileToURI(picFile, tmpURI);

 

  InterfacePtr<IImportResourceCmdData> importResourceCmdData(importAndPlaceCmd, IID_IIMPORTRESOURCECMDDATA); // no kDefaultIID

                    ASSERT(importResourceCmdData != nil);

                    if (importResourceCmdData == nil) {

  break;

                    }

                    importResourceCmdData->Set(parentUIDRef.GetDataBase(), tmpURI, K2::kMinimalUI, kTrue, kTrue, kTrue, kFalse);

 

  // Process the command.

                    if (CmdUtils::ProcessCommand(importAndPlaceCmd) != kSuccess) {

  ASSERT_FAIL("kImportAndPlaceCmdBoss failed");

  break;

                    }

 

  // Get a reference to the created frame to the caller.

                    const UIDList& outItemList = importAndPlaceCmd->GetItemListReference();

                    ASSERT(outItemList.Length() > 0);

                    if (!(outItemList.Length() > 0)) {

  break;

                    }

 

 

  // Fit the frame to the text content we placed.

  InterfacePtr<ICommand> fitFrameToContentCmd(CmdUtils::CreateCommand(kFitFrameToContentCmdBoss));

                    ASSERT(fitFrameToContentCmd != nil);

                    if (fitFrameToContentCmd == nil) {

  break;

                    }

                    fitFrameToContentCmd->SetItemList(parentUIDRef);

                    if (CmdUtils::ProcessCommand(fitFrameToContentCmd) != kSuccess) {

  ASSERT_FAIL("kFitFrameToContentCmdBoss failed");

  break;

                    }

This topic has been closed for replies.
Correct answer ArunRath

I am using kReplaceCmdBoss.


Can you provide/mention any sample?

1 reply

Inspiring
June 21, 2013

This is known issue.

I am using kImportAndLoadPlaceGunCmdBoss and kReplaceCmdBoss instead.

ArunRathAuthor
Inspiring
June 21, 2013

I changed the code,

I am facing the problem of placed file(word/rtf) is added on mouse pointer not pasted on text frame.

whether i click the frame, then only passed on the document

InterfacePtr<ICommand> importAndLoadPlaceGunCmd(CmdUtils::CreateCommand(kImportAndLoadPlaceGunCmdBoss)) ;

                    if (importAndLoadPlaceGunCmd == nil)

                    {

  ASSERT_FAIL("importAndLoadPlaceGunCmd invalid");

                              break;

                    }

 

                    URI URIPath;

                    URIUTILS->IDFileToURI(contentFile, URIPath);

 

  // Set the IImportResourceCmdData Interface's data:

  InterfacePtr<IImportResourceCmdData> importFileCmdData(importAndLoadPlaceGunCmd, IID_IIMPORTRESOURCECMDDATA);

                    if (importFileCmdData == nil)

                    {

  ASSERT_FAIL("importFileCmdData invalid");

                              break;

                    }

 

                    importFileCmdData->Set(parentUIDRef.GetDataBase(), URIPath, (K2::UIFlags)0, kTrue, kFalse);

                    ErrorCode status = CmdUtils::ProcessCommand(importAndLoadPlaceGunCmd);

 

                    const UIDList* imageList = importAndLoadPlaceGunCmd->GetItemList();

                    if (!imageList || imageList -> Length() == 0)

  break;

 

 

  // Create an placeGraphicCmd:

  InterfacePtr<ICommand> placeGraphicCmd(CmdUtils::CreateCommand(kPlaceItemInGraphicFrameCmdBoss));

                    if (placeGraphicCmd == nil)

                    {

  ASSERT_FAIL("placeGraphicCmd invalid");

                              break;

                    }

                    placeGraphicCmd -> SetItemList(UIDList(frameUIDRef));

 

  // Set the IPlacePIData Interface's data:

  InterfacePtr<IPlacePIData> placePIData(placeGraphicCmd, IID_IPLACEPIDATA);

                    if (placePIData == nil)

                    {

  ASSERT_FAIL("placePIData invalid");

                              break;

                    }

                    placePIData -> Set(parentUIDRef, nil, kFalse);

  // Process the ImportAndPlaceCmd:

                    status = CmdUtils::ProcessCommand(placeGraphicCmd);

Inspiring
June 21, 2013

I am using kReplaceCmdBoss.