openoffice-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernard Marcelly <marce...@club-internet.fr>
Subject Re: Programmatically (C++) closing frame with chance to save
Date Tue, 28 Oct 2014 15:37:11 GMT
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-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: api-help@openoffice.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Mime
View raw message