Kirix Support Forums

SaveCurrent() ignores changes trough DOM

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

SaveCurrent() ignores changes trough DOM

Postby xzminx on Mon Oct 24, 2011 8:54 am

Hi guys, I have a template html that I first load. Then I add a bunch of other content trough DOM.

I want to save this changed content but SaveCurrent() saves only the file loaded with OpenURI(), not the content that is shown in the webcontrol. Is this a bug? Is there a fix available?

Tnx,
Zoran
xzminx
Registered User
 
Posts: 12
Joined: Tue Apr 26, 2011 1:51 pm

Re: SaveCurrent() ignores changes trough DOM

Postby Ben on Mon Oct 24, 2011 12:00 pm

SaveCurrent() is pretty much a direct passthrough to XR SaveURI():

Code: Select all
    nsresult res = persist->SaveURI(nsnull, // url - nsnull equals "this document"
                                    nsnull, // cache key
                                    nsnull, // nsIURI referrer
                                    nsnull, // post data
                                    nsnull, // extra headers
                                    file.p); // target file


So searching for answers via SaveURI() is probably going to get you farther in your quest. I'd be willing to implement any changes to make this work better.

Best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: SaveCurrent() ignores changes trough DOM

Postby xzminx on Mon Oct 31, 2011 11:18 am

Meh, I just made my own DOM printer, it was quicker than tracing and fixing the XR's SaveURI().
xzminx
Registered User
 
Posts: 12
Joined: Tue Apr 26, 2011 1:51 pm

Re: SaveCurrent() ignores changes trough DOM

Postby rbalean on Wed Sep 19, 2012 10:17 am

Here's how I did it:

As pointed out, the SaveURI method doesn't show any changes to the document since it was loaded. However there is another ns method called SaveDocument which will do the trick. I created a new method called SaveDocument in webControl.cpp where I added the following code (and of course the corresponding declaration in the header):

Code: Select all
bool wxWebControl::SaveDocument(
                const wxString& filename)
{
    ns_smartptr<nsIWebBrowserPersist> persist = m_ptrs->m_web_browser;
   
    if (persist.empty())
    {
        wxFAIL_MSG(wxT("wxWebControl::SaveDocument(): nsIWebBrowserPersist interface not available"));
        return false;
    }
       
   
    ns_smartptr<nsILocalFile> file = nsNewLocalFile(filename);
   
    if (file.empty())
    {
        wxFAIL_MSG(wxT("wxWebControl::SaveDocument(): could not create temporary file"));
        return false;
    }   
   
   
   nsresult res = persist->SaveDocument(   
      nsnull, //in nsIDOMDocument aDocument,
      file.p,   //in nsISupports aFile,
      nsnull, //in nsISupports aDataPath,
      nsnull, //in string aOutputContentType,
      nsnull, //in unsigned long aEncodingFlags,
      nsnull //in unsigned long aWrapColumn
   );

   if (NS_FAILED(res))
        return false;

   return true;

}


Regards,
Robin
rbalean
Registered User
 
Posts: 4
Joined: Thu Sep 13, 2012 3:12 am

Return to wxWebConnect Questions, Thoughts & Feedback