Skip to main content
Inspiring
February 4, 2015
Question

How to check if there is a layout open for a document?

  • February 4, 2015
  • 1 reply
  • 244 views

I want to check whether the document I have is hidden in In-design or there is a layout window open for it.

Is there a API to check this?

I looked into IDocumentPresentation but did not found any helpful API. Can some one suggest?

This topic has been closed for replies.

1 reply

Trung_vu
Inspiring
February 5, 2015

you can try: if doc is opened then active it

PMString strActiveDocumentName("ExampDoc");

  // Get opening document list

  InterfacePtr<IDocumentList> oDocumentList(oApplication->QueryDocumentList());

  if (oDocumentList)

  {

  for(int32 i = 0; i < oDocumentList->GetDocCount() ; i++ )

  {

  // Check document name

  IDocument* oDocument = oDocumentList->GetNthDoc(i);

  PMString strDocName;

  oDocument->GetName(strDocName);

  if(strActiveDocumentName == strDocName)

  {

  // Get DocumentUIDRef

  UIDRef oDocumentUIDRef(nil, kInvalidUID);

  IDataBase* oDatabase = ::GetDataBase(oDocument);

  if (oDatabase == nil)

                            break;

  UID oDocumentUID = oDatabase->GetRootUID();

  if (oDocumentUID == kInvalidUID)

                            break;

  oDocumentUIDRef = UIDRef(oDatabase, oDocumentUID);

  // Make active document

  InterfacePtr<IPresentationList> oPresentationList(oDocumentUIDRef, UseDefaultIID());

  if( oPresentationList)

  {

  for(int32 j = 0, iMax =  oPresentationList->size(); j < iMax; j++)

  {

  IDocumentPresentation* oDocumentPresentation =  oPresentationList->At(j);

  oDocumentPresentation->MakeActive();

  return true;

  }

          }

  }

  }

  }