]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
Fix crash in wxMSW wxProgressDialog without wxPD_APP_MODAL style.
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index eccbc7dfb008026da4907d4278235bbee037102d..0a46f82d005298256d974c67cbdd2a32a472157e 100644 (file)
@@ -2654,6 +2654,13 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
             // So when changing a list style interactively, could retrieve level based on current style, then
             // set appropriate indent and apply new style.
 
+            int outline = -1;
+            int num = -1;
+            if (para->GetAttributes().HasOutlineLevel())
+                outline = para->GetAttributes().GetOutlineLevel();
+            if (para->GetAttributes().HasBulletNumber())
+                num = para->GetAttributes().GetBulletNumber();
+
             if (!para->GetAttributes().GetParagraphStyleName().IsEmpty() && !para->GetAttributes().GetListStyleName().IsEmpty())
             {
                 int currentIndent = para->GetAttributes().GetLeftIndent();
@@ -2704,6 +2711,11 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
                     foundCount ++;
                 }
             }
+
+            if (outline != -1)
+                para->GetAttributes().SetOutlineLevel(outline);
+            if (num != -1)
+                para->GetAttributes().SetBulletNumber(num);
         }
 
         node = node->GetNext();
@@ -3326,11 +3338,10 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     int lineSpacing = 0;
 
     // Let's assume line spacing of 10 is normal, 15 is 1.5, 20 is 2, etc.
-    if (attr.GetLineSpacing() != 10 && GetBuffer())
+    if (attr.HasLineSpacing() && attr.GetLineSpacing() > 0 && attr.GetFont().Ok())
     {
-        wxFont font(GetBuffer()->GetFontTable().FindFont(attr));
-        wxCheckSetFont(dc, font);
-        lineSpacing = (ConvertTenthsMMToPixels(dc, dc.GetCharHeight()) * attr.GetLineSpacing())/10;
+        wxCheckSetFont(dc, attr.GetFont());
+        lineSpacing = (int) (double(dc.GetCharHeight()) * (double(attr.GetLineSpacing())/10.0 - 1.0));
     }
 
     // Available space for text on each line differs.
@@ -3582,7 +3593,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     // Apply styles to wrapped lines
     ApplyParagraphStyle(attr, rect, dc);
 
-    SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara));
+    SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceAfterPara));
 
     m_dirty = false;
 
@@ -7423,11 +7434,7 @@ wxRichTextImageBlock::wxRichTextImageBlock(const wxRichTextImageBlock& block):wx
 
 wxRichTextImageBlock::~wxRichTextImageBlock()
 {
-    if (m_data)
-    {
-        delete[] m_data;
-        m_data = NULL;
-    }
+    wxDELETEA(m_data);
 }
 
 void wxRichTextImageBlock::Init()
@@ -7439,8 +7446,7 @@ void wxRichTextImageBlock::Init()
 
 void wxRichTextImageBlock::Clear()
 {
-    delete[] m_data;
-    m_data = NULL;
+    wxDELETEA(m_data);
     m_dataSize = 0;
     m_imageType = wxBITMAP_TYPE_INVALID;
 }
@@ -7539,11 +7545,7 @@ bool wxRichTextImageBlock::Write(const wxString& filename)
 void wxRichTextImageBlock::Copy(const wxRichTextImageBlock& block)
 {
     m_imageType = block.m_imageType;
-    if (m_data)
-    {
-        delete[] m_data;
-        m_data = NULL;
-    }
+    wxDELETEA(m_data);
     m_dataSize = block.m_dataSize;
     if (m_dataSize == 0)
         return;
@@ -7790,8 +7792,7 @@ bool wxRichTextBufferDataObject::GetDataHere(void *pBuf) const
 
 bool wxRichTextBufferDataObject::SetData(size_t WXUNUSED(len), const void *buf)
 {
-    delete m_richTextBuffer;
-    m_richTextBuffer = NULL;
+    wxDELETE(m_richTextBuffer);
 
     wxString bufXML((const char*) buf, wxConvUTF8);
 
@@ -7802,8 +7803,7 @@ bool wxRichTextBufferDataObject::SetData(size_t WXUNUSED(len), const void *buf)
     {
         wxLogError(wxT("Could not read the buffer from an XML stream.\nYou may have forgotten to add the XML file handler."));
 
-        delete m_richTextBuffer;
-        m_richTextBuffer = NULL;
+        wxDELETE(m_richTextBuffer);
 
         return false;
     }