Thanks. So are you saying that I need to reprogram the actions that the Close menu item seems to invoke? I was hoping that there was more direct access to that functionality, perhaps by dispatching a .uno:CloseDoc somewhere. The xCloseable->close() in combination with CloseVetoException matches so well the Save/Discard/Cancel dialog that I imagined a shortcut.
2014-10-28 16:37 GMT+01:00 Bernard Marcelly <marce...@club-internet.fr>: > Hi Keith, > Method close() does what it says... > You have to verify if the document was modified. > Use method isModified() from interface com.sun.star.util.XModifiable. > Then you ask for saving, and store it with interface > com.sunstar.frame.XStorable. > > See > <https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Component/Models#XModifiable> > > Regards > Bernard > > Message de Keith Alcock date 2014-10-28 15:32 : >> >> API experts, >> >> I need to close some of the open document windows from within a C++ >> addon. Some of the documents may have been modified, so there should >> be a chance to save them or even abort the close, just like you get >> with the Close command from the UI. It seems like XCloseable is just >> the thing for this, but when I perform xCloseable->close() on either >> the XFrame or XModel, the window summarily closes even with a modified >> document. Am I calling it on the wrong object or is this not how the >> functionality should be implemented or is something else wrong? Here >> is an incomplete code that approximates what I'm doing: >> >> Reference<XEnumerationAccess> xEnumerationAccess = >> xDesktop->getComponents(); >> Reference<XEnumeration> xEnumeration = >> xEnumerationAccess->createEnumeration(); >> >> while (xEnumeration->hasMoreElements() == sal_True) { >> Reference<XComponent> xComponent; >> Any any = xEnumeration->nextElement(); >> any >>= xComponent; >> >> Reference<XModel> xModel(xComponent, UNO_QUERY); >> Reference<XController> xController = xModel->getCurrentController(); >> Reference<XFrame> xFrame = xController->getFrame(); >> >> Reference<XCloseable> xCloseableFrame(xFrame, UNO_QUERY); >> xCloseableFrame->close(sal_True); >> return; >> } >> >> The frame closes nicely, but no messages about needing to save the >> document appear. Any ideas? Thanks. >> >> Keith >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org >> For additional commands, e-mail: api-h...@openoffice.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org > For additional commands, e-mail: api-h...@openoffice.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org