Index: xword/XWikiLib/XWiki/Space.cs =================================================================== --- xword/XWikiLib/XWiki/Space.cs (revision 19027) +++ xword/XWikiLib/XWiki/Space.cs (working copy) @@ -23,8 +23,16 @@ /// [XmlAttribute] public bool hidden; - + /// + /// Specifies if the space is published on wiki, or if it is a new local one. + /// Default is TRUE, since the majority of spaces are from the server. + /// FALSE only for new added spaces. + /// + [XmlAttribute] + public bool published=true; + + /// /// The list of documents in the space. /// public List documents; Index: xword/XWikiLib/XWiki/XWikiDocument.cs =================================================================== --- xword/XWikiLib/XWiki/XWikiDocument.cs (revision 19027) +++ xword/XWikiLib/XWiki/XWikiDocument.cs (working copy) @@ -25,6 +25,13 @@ public String space; /// + /// Specifies if the document is published on wiki or if it's a local one. + /// Default is TRUE, since the majority of pages are from the server. + /// FALSE only for new added (and not published) pages. + /// + public bool published=true; + + /// /// The rendered content of the document. /// [NonSerialized] Index: xword/XWord/AddinActions.cs =================================================================== --- xword/XWord/AddinActions.cs (revision 19027) +++ xword/XWord/AddinActions.cs (working copy) @@ -322,6 +322,28 @@ Log.Error("Failed to save page " + pageName + "on server " + addin.serverURL); MessageBox.Show("There was an error on the server when trying to save the page"); } + else + { + //mark the page from wiki structure as published + bool markedDone = false; + foreach (Space sp in addin.wiki.spaces) + { + foreach (XWikiDocument xwdoc in sp.documents) + { + if ((xwdoc.space + "." + xwdoc.name) == pageName) + { + sp.published = true; + xwdoc.published = true; + markedDone = true; + break;//inner foreach + } + } + if (markedDone) + { + break;//outer foreach + } + } + } } /// @@ -379,7 +401,6 @@ /// If current syntax is XWiki 2.0 and the page contains table(s), promt the user /// to switch to XHTML syntax with an Yes/No/Cancel message box. /// - /// Cleaned HTML source code. /// FALSE if the user presses 'Cancel', meaning the saving should not continue. TRUE in other cases. private bool ShowSwitchSyntaxDialog() { @@ -504,14 +525,14 @@ /// /// Starts editing a new wiki page. The page will not be created in the wiki until the fisrt save. /// - /// The name of the wiki space. + /// The name of the wiki space. /// The name of page. /// The title of the page. /// /// The instance of the fprm that started the action. /// This form need to be closed before swithing the Active Word Document. /// - public void AddNewPage(String space, String pageName, String pageTitle, Form sender) + public void AddNewPage(String spaceName, String pageName, String pageTitle, Form sender) { //Any modal dialog nust be closed before opening or closing active documents. if (sender != null) @@ -524,7 +545,7 @@ { Client.Login(addin.username, addin.password); } - String pageFullName = space + "." + pageName; + String pageFullName = spaceName + "." + pageName; String localFileName = pageFullName.Replace(".", "-"); String folder = addin.PagesRepository + "TempPages"; ConvertToNormalFolder(folder); @@ -549,6 +570,47 @@ //Open the file with Word Word.Document doc = OpenHTMLDocument(localFileName); + + + //If it's a new space, add it to the wiki structure and mark it as unpublished + List spaces = Globals.XWikiAddIn.wiki.spaces; + Space space=null; + foreach (Space sp in spaces) + { + if (sp.name == spaceName) + { + space = sp; + + //Add the new page to the wiki structure and mark it as unpublished + XWikiDocument xwdoc = new XWikiDocument(); + xwdoc.name = pageName; + xwdoc.published = false; + xwdoc.space = spaceName; + space.documents.Add(xwdoc); + + break; + } + } + + if (space==null) + { + space = new Space(); + space.name = spaceName; + space.published = false; + Globals.XWikiAddIn.wiki.spaces.Add(space); + + //Add the new page to the wiki structure and mark it as unpublished + XWikiDocument xwdoc = new XWikiDocument(); + xwdoc.name = pageName; + xwdoc.published = false; + xwdoc.space = spaceName; + space.documents.Add(xwdoc); + + } + + + //?? + } catch (IOException ex) { Index: xword/XWord/XWikiNavigationPane.cs =================================================================== --- xword/XWord/XWikiNavigationPane.cs (revision 19027) +++ xword/XWord/XWikiNavigationPane.cs (working copy) @@ -144,8 +144,61 @@ byte[] buffer = encoding.GetBytes(s); MemoryStream memoryStream = new MemoryStream(buffer, false); XmlSerializer serializer = new XmlSerializer(typeof(WikiStructure)); + + //keep unpublished spaces and pages + WikiStructure oldWikiStruct = null; + if (addin.wiki != null) + { + oldWikiStruct = new WikiStructure(); + foreach (Space sp in addin.wiki.spaces) + { + //space with unpublished pages? + if (!sp.published) + { + oldWikiStruct.spaces.Add(sp); + } + else + { + //or a space with local (unpublished) pages? + foreach (XWikiDocument xwdoc in sp.documents) + { + if (!xwdoc.published) + { + oldWikiStruct.spaces.Add(sp); + break; + } + } + } + } + } + wiki = (WikiStructure)serializer.Deserialize(memoryStream); addin.wiki = wiki; + + //add local spaces and pages + if (oldWikiStruct != null) + { + //add unexistent spaces from old structure + //and update existing spaces with unpublished pages + foreach (Space sp in oldWikiStruct.spaces) + { + if (wiki.spaces.Contains(sp)) + { + Space exstngWithUnpubPagesSpace = wiki.spaces[wiki.spaces.IndexOf(sp)]; + foreach (XWikiDocument xwd in sp.documents) + { + exstngWithUnpubPagesSpace.documents.Add(xwd); + } + exstngWithUnpubPagesSpace.published = true; + } + else + { + sp.published = false; + addin.wiki.spaces.Add(sp); + } + } + } + memoryStream.Close(); } @@ -161,10 +214,29 @@ { TreeNode node = treeView.Nodes.Add(space.name); node.ImageIndex = TREE_SPACE_LEVEL; + //mark unpublished spaces + + if (!space.published) + { + node.ForeColor = Color.Blue; + } + + foreach (XWikiDocument doc in space.documents) { TreeNode childNode = node.Nodes.Add(doc.space + "." + doc.name, doc.name); childNode.ImageIndex = TREE_PAGE_LEVEL; + if (!doc.published) + { + //mark unpublished pages + childNode.ForeColor = Color.Blue; + if (space.published) + { + //mark published spaces with unpublished pages + node.ForeColor = Color.BlueViolet; + //node.Text += "X"; + } + } } } } Index: xword/XWord/XWikiRibbon.cs =================================================================== --- xword/XWord/XWikiRibbon.cs (revision 19027) +++ xword/XWord/XWikiRibbon.cs (working copy) @@ -128,6 +128,7 @@ if (Addin.currentPageFullName == "" || Addin.currentPageFullName == null) { new AddPageForm(ref Addin.wiki, false, true).Show(); + } else {