]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/configtool/src/configtooldoc.cpp
Fixes tex2rtf to search for files on current folder too. This is basically to test...
[wxWidgets.git] / utils / configtool / src / configtooldoc.cpp
index 2fad2cf31e2b847f29c905edbc1e25b075fb5a20..ff3308f98c3a0e94973f254ae276ecab45a0c24e 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "configtooldoc.h"
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -29,6 +25,7 @@
 #endif
 
 #include "wx/textfile.h"
+#include "wx/txtstrm.h"
 #include "wx/wfstream.h"
 #include "wx/config.h"
 #include "configtooldoc.h"
@@ -104,7 +101,7 @@ bool ctConfigToolDoc::Save()
 {
     if (!IsModified() && m_savedYet) return true;
 
-    bool ret = (m_documentFile == wxT("") || !m_savedYet) ?
+    bool ret = (m_documentFile.empty() || !m_savedYet) ?
                  SaveAs() :
                  OnSaveDocument(m_documentFile);
     if ( ret )
@@ -127,9 +124,9 @@ bool ctConfigToolDoc::OnCreate(const wxString& path, long flags)
         //rootItem->InitProperties();
         rootItem->GetProperties().AddProperty(
         new ctProperty(
-        wxT("The item description."),
-        wxVariant(wxT(""), wxT("description")),
-        wxT("multiline")));
+            wxT("The item description."),
+            wxVariant(wxEmptyString, wxT("description")),
+            wxT("multiline")));
 
         rootItem->SetPropertyString(_T("description"),
             _T("<B>This is the top-level configuration item.</B>"));
@@ -175,7 +172,7 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
     // This is the backup filename
     wxString backupFilename(filename);
     backupFilename += wxT(".bak");
-    
+
     // This is the temporary copy of the backup
     wxString tempFilename(filename);
     tempFilename += wxT(".tmp");
@@ -193,7 +190,7 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
         {
             wxRemoveFile(backupFilename);
         }
-        
+
         // Copy the old file to the .bak
 
         if (leaveBackup)
@@ -212,13 +209,13 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
             if (wxFileExists(filename))
                 wxRemoveFile(filename);
         }
-        
+
         // Finally, copy the temporary file to the proper filename
         if (!wxRenameFile(tempFilename, filename))
         {
             wxCopyFile(tempFilename, filename);
             wxRemoveFile(tempFilename);
-        }        
+        }
 
         Modify(false);
         ((ctConfigToolView*)GetFirstView())->OnChangeFilename();
@@ -262,32 +259,36 @@ bool ctConfigToolDoc::OnOpenDocument(const wxString& filename)
 /// Save the settings file
 bool ctConfigToolDoc::DoSave(const wxString& filename)
 {
-    wxFileOutputStream stream(filename);
-    if (!stream.Ok())
+    wxFileOutputStream osFile(filename);
+    if (!osFile.Ok())
         return false;
 
+    wxTextOutputStream stream(osFile);
+
     stream << wxT("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
     stream << wxT("<settings xmlns=\"http://www.wxwidgets.org/wxs\" version=\"2.5.0.1\">");
 
-    DoSave(m_topItem, stream, 1);
+    DoSave(m_topItem, osFile, 1);
 
     stream << wxT("\n</settings>\n");
 
     return true;
 }
 
-inline static void OutputIndentation(wxOutputStream& stream, int indent)
+inline static void OutputIndentation(wxOutputStream& osFile, int indent)
 {
+    wxTextOutputStream stream(osFile);
     wxString str = wxT("\n");
     for (int i = 0; i < indent; i++)
-        str << wxT(' ') << wxT(' ');
+        str << wxT("  ");
     stream << str ;
 }
 
 /// Recursive helper function for file saving
-bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int indent)
+bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& osFile, int indent)
 {
-    OutputIndentation(stream, indent*2);
+    OutputIndentation(osFile, indent*2);
+    wxTextOutputStream stream(osFile);
 
     wxString name(item->GetName());
     wxString s;
@@ -313,12 +314,12 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
 
     indent ++;
 
-    OutputIndentation(stream, indent*2);
+    OutputIndentation(osFile, indent*2);
     if (item->IsActive())
         stream << wxT("<active>1</active>");
     else
         stream << wxT("<active>0</active>");
-    OutputIndentation(stream, indent*2);
+    OutputIndentation(osFile, indent*2);
     if (item->IsEnabled())
         stream << wxT("<enabled>1</enabled>");
     else
@@ -329,9 +330,9 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
     while (node)
     {
         ctProperty* prop = (ctProperty*) node->GetData();
-        OutputIndentation(stream, indent*2);
+        OutputIndentation(osFile, indent*2);
         stream << wxT("<") << prop->GetName() ;
-        
+
         if (prop->IsCustom())
         {
             stream << wxT(" custom=\"true\"");
@@ -345,7 +346,7 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
                 stream << wxT(" choices=\"") << choices << wxT("\"");
             }
         }
-        
+
         stream << wxT(">");
 
         stream << ctEscapeHTMLCharacters(prop->GetVariant().GetString()) ;
@@ -359,14 +360,14 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
     while (node)
     {
         ctConfigItem* child = (ctConfigItem*) node->GetData();
-        DoSave(child, stream, indent);
+        DoSave(child, osFile, indent);
 
         node = node->GetNext();
     }
 
     indent --;
 
-    OutputIndentation(stream, indent*2);
+    OutputIndentation(osFile, indent*2);
     stream << wxT("</setting>");
 
     return true;
@@ -400,10 +401,10 @@ bool ctConfigToolDoc::DoOpen(const wxString& filename)
 
 static bool GetHtmlBoolValue(const wxString& value)
 {
-    if (value == wxT("true") || value == wxT("TRUE") || value == wxT("1"))
+    if (value.IsSameAs(wxT("true"),false) || value == wxT("1"))
         return true;
-     else
-         return false;
+    else
+        return false;
 }
 
 static int GetHtmlIntegerValue(const wxString& value)
@@ -500,7 +501,7 @@ bool ctConfigToolDoc::DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent)
                             wxString type(wxT("string"));
                             wxString choices;
                             wxString editorType(wxT("string"));
-                            wxString description(wxT(""));
+                            wxString description;
                             childTag->GetAttributeValue(type, wxT("type"));
                             childTag->GetAttributeValue(type, wxT("editor-type"));
                             childTag->GetAttributeValue(type, wxT("choices"));
@@ -513,7 +514,7 @@ bool ctConfigToolDoc::DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent)
                             else if (type == wxT("long"))
                                 prop->GetVariant() = wxVariant((long) 0, name);
                             else
-                                prop->GetVariant() = wxVariant(wxT(""), name);
+                                prop->GetVariant() = wxVariant(wxEmptyString, name);
                             prop->SetDescription(description);
                             prop->SetCustom(true);
                             prop->SetEditorType(editorType);
@@ -602,7 +603,7 @@ void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
     // parent is a check or radio group.
     ctConfigItem* parent = item->GetParent();
     if (parent &&
-        (parent->GetType() == ctTypeCheckGroup || 
+        (parent->GetType() == ctTypeCheckGroup ||
         parent->GetType() == ctTypeRadioGroup))
         requiresArr.Add(parent->GetName());
 
@@ -772,7 +773,7 @@ void ctConfigToolDoc::GenerateConfigureCommand(ctConfigItem* item, wxString& str
                 {
                     str << wxT(" ") << configureCommand;
                 }
-            }            
+            }
         }
     }
 
@@ -796,6 +797,8 @@ wxString ctConfigToolDoc::GetFrameworkDir(bool makeUnix)
 #ifdef __WXMSW__
         if (makeUnix)
             path.Replace(wxT("\\"), wxT("/"));
+#else
+        wxUnusedVar(makeUnix);
 #endif
     }
     return path;
@@ -914,7 +917,7 @@ bool ctConfigCommand::DoAndUndo(bool doCmd)
 
                 // This will delete the old clipboard contents, if any.
                 doc->SetClipboardItem(newItem);
-                
+
                 m_parent = m_activeState->GetParent();
                 m_insertBefore = m_activeState->FindNextSibling();
 
@@ -1082,7 +1085,7 @@ ctConfiguration::~ctConfiguration()
             wxGetApp().GetMainFrame()->GetDocument()->SetTopItem(NULL);
     }
 */
-    
+
     Clear();
 }
 
@@ -1250,5 +1253,3 @@ void ctConfiguration::DetachFromTree()
     }
 */
 }
-
-