// If the position is end-of-paragraph, then return the last line of
// of the paragraph.
- (range.GetEnd() == child->GetRange().GetEnd()-1) && (pos == child->GetRange().GetEnd()))
+ ((range.GetEnd() == child->GetRange().GetEnd()-1) && (pos == child->GetRange().GetEnd())))
return line;
node2 = node2->GetNext();
// we only want the paragraphs to hold this character style, then we _don't_ want to
// apply the character style. So we need to be able to choose.
- // if (!paragraphStyle && characterStyle && range.GetStart() != newPara->GetRange().GetEnd())
- if (!parasOnly && characterStyle && range.GetStart() != newPara->GetRange().GetEnd())
+ if (!parasOnly && (characterStyle|charactersOnly) && range.GetStart() != newPara->GetRange().GetEnd())
{
wxRichTextRange childRange(range);
childRange.LimitTo(newPara->GetRange());
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content.
-bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes)
+bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes)
{
+ absentStyleAttributes |= (~style.GetFlags() & wxTEXT_ATTR_ALL);
+ absentTextEffectAttributes |= (~style.GetTextEffectFlags() & 0xFFFF);
+
if (style.HasFont())
{
- if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_SIZE))
+ if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_SIZE))
{
if (currentStyle.HasFontSize())
{
}
}
- if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_ITALIC))
+ if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_ITALIC))
{
if (currentStyle.HasFontItalic())
{
}
}
- if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
+ if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
{
if (currentStyle.HasFontWeight())
{
}
}
- if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_FACE))
+ if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FACE))
{
if (currentStyle.HasFontFaceName())
{
}
}
- if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE))
+ if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE))
{
if (currentStyle.HasFontUnderlined())
{
}
}
- if (style.HasTextColour() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_TEXT_COLOUR))
+ if (style.HasTextColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TEXT_COLOUR))
{
if (currentStyle.HasTextColour())
{
currentStyle.SetTextColour(style.GetTextColour());
}
- if (style.HasBackgroundColour() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BACKGROUND_COLOUR))
+ if (style.HasBackgroundColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BACKGROUND_COLOUR))
{
if (currentStyle.HasBackgroundColour())
{
currentStyle.SetBackgroundColour(style.GetBackgroundColour());
}
- if (style.HasAlignment() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_ALIGNMENT))
+ if (style.HasAlignment() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_ALIGNMENT))
{
if (currentStyle.HasAlignment())
{
currentStyle.SetAlignment(style.GetAlignment());
}
- if (style.HasTabs() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_TABS))
+ if (style.HasTabs() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TABS))
{
if (currentStyle.HasTabs())
{
currentStyle.SetTabs(style.GetTabs());
}
- if (style.HasLeftIndent() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LEFT_INDENT))
+ if (style.HasLeftIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LEFT_INDENT))
{
if (currentStyle.HasLeftIndent())
{
currentStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent());
}
- if (style.HasRightIndent() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_RIGHT_INDENT))
+ if (style.HasRightIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_RIGHT_INDENT))
{
if (currentStyle.HasRightIndent())
{
currentStyle.SetRightIndent(style.GetRightIndent());
}
- if (style.HasParagraphSpacingAfter() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARA_SPACING_AFTER))
+ if (style.HasParagraphSpacingAfter() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_AFTER))
{
if (currentStyle.HasParagraphSpacingAfter())
{
currentStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter());
}
- if (style.HasParagraphSpacingBefore() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARA_SPACING_BEFORE))
+ if (style.HasParagraphSpacingBefore() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_BEFORE))
{
if (currentStyle.HasParagraphSpacingBefore())
{
currentStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore());
}
- if (style.HasLineSpacing() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LINE_SPACING))
+ if (style.HasLineSpacing() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LINE_SPACING))
{
if (currentStyle.HasLineSpacing())
{
currentStyle.SetLineSpacing(style.GetLineSpacing());
}
- if (style.HasCharacterStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_CHARACTER_STYLE_NAME))
+ if (style.HasCharacterStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_CHARACTER_STYLE_NAME))
{
if (currentStyle.HasCharacterStyleName())
{
currentStyle.SetCharacterStyleName(style.GetCharacterStyleName());
}
- if (style.HasParagraphStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME))
+ if (style.HasParagraphStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME))
{
if (currentStyle.HasParagraphStyleName())
{
currentStyle.SetParagraphStyleName(style.GetParagraphStyleName());
}
- if (style.HasListStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LIST_STYLE_NAME))
+ if (style.HasListStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LIST_STYLE_NAME))
{
if (currentStyle.HasListStyleName())
{
currentStyle.SetListStyleName(style.GetListStyleName());
}
- if (style.HasBulletStyle() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_STYLE))
+ if (style.HasBulletStyle() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_STYLE))
{
if (currentStyle.HasBulletStyle())
{
currentStyle.SetBulletStyle(style.GetBulletStyle());
}
- if (style.HasBulletNumber() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_NUMBER))
+ if (style.HasBulletNumber() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NUMBER))
{
if (currentStyle.HasBulletNumber())
{
currentStyle.SetBulletNumber(style.GetBulletNumber());
}
- if (style.HasBulletText() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_TEXT))
+ if (style.HasBulletText() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_TEXT))
{
if (currentStyle.HasBulletText())
{
}
}
- if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_NAME))
+ if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NAME))
{
if (currentStyle.HasBulletName())
{
}
}
- if (style.HasURL() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_URL))
+ if (style.HasURL() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_URL))
{
if (currentStyle.HasURL())
{
}
}
- if (style.HasTextEffects() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_EFFECTS))
+ if (style.HasTextEffects() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_EFFECTS))
{
if (currentStyle.HasTextEffects())
{
// We need to find the bits in the new style that are different:
// just look at those bits that are specified by the new style.
+ // We need to remove the bits and flags that are not common between current style
+ // and new style. In so doing we need to take account of the styles absent from one or more of the
+ // previous styles.
+
int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
currentStyle.SetTextEffects(style.GetTextEffects());
currentStyle.SetTextEffectFlags(style.GetTextEffectFlags());
}
+
+ // Mask out the flags and values that cannot be common because they were absent in one or more objecrs
+ // that we've looked at so far
+ currentStyle.SetTextEffects(currentStyle.GetTextEffects() & ~absentTextEffectAttributes);
+ currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~absentTextEffectAttributes);
+
+ if (currentStyle.GetTextEffectFlags() == 0)
+ currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_EFFECTS);
}
- if (style.HasOutlineLevel() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_OUTLINE_LEVEL))
+ if (style.HasOutlineLevel() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_OUTLINE_LEVEL))
{
if (currentStyle.HasOutlineLevel())
{
long multipleStyleAttributes = 0;
int multipleTextEffectAttributes = 0;
+ int absentStyleAttributesPara = 0;
+ int absentStyleAttributesChar = 0;
+ int absentTextEffectAttributesPara = 0;
+ int absentTextEffectAttributesChar = 0;
+
wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
while (node)
{
{
wxTextAttr paraStyle = para->GetCombinedAttributes();
- CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes);
+ CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
}
else
{
// First collect paragraph attributes only
wxTextAttr paraStyle = para->GetCombinedAttributes();
paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH);
- CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes);
+ CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
wxRichTextObjectList::compatibility_iterator childNode = para->GetChildren().GetFirst();
// Now collect character attributes only
childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER);
- CollectStyle(style, childStyle, multipleStyleAttributes, multipleTextEffectAttributes);
+ CollectStyle(style, childStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesChar, absentTextEffectAttributesChar);
}
childNode = childNode->GetNext();
text += textObj->GetTextForRange(range);
}
else
- return true;
+ {
+ text += wxT(" ");
+ }
}
node = node->GetNext();
text = textObj->GetTextForRange(range) + text;
}
else
- return true;
+ {
+ text = wxT(" ") + text;
+ }
}
node = node->GetPrevious();
{
if (para && para->GetRange().GetEnd() == pos)
pos1 ++;
+
+ // Now see if we need to number the paragraph.
if (newPara->GetAttributes().HasBulletNumber())
- newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1);
+ {
+ wxRichTextAttr numberingAttr;
+ if (FindNextParagraphNumber(para, numberingAttr))
+ wxRichTextApplyStyle(newPara->GetAttributes(), (const wxRichTextAttr&) numberingAttr);
+ }
}
action->SetPosition(pos);
}
}
}
+
+ // Also apply list style if present
+ if (lookUpNewParaStyle && !para->GetAttributes().GetListStyleName().IsEmpty() && GetStyleSheet())
+ {
+ wxRichTextListStyleDefinition* listDef = GetStyleSheet()->FindListStyle(para->GetAttributes().GetListStyleName());
+ if (listDef)
+ {
+ int thisIndent = para->GetAttributes().GetLeftIndent();
+ int thisLevel = para->GetAttributes().HasOutlineLevel() ? para->GetAttributes().GetOutlineLevel() : listDef->FindLevelForIndent(thisIndent);
+
+ // Apply the overall list style, and item style for this level
+ wxRichTextAttr listStyle(listDef->GetCombinedStyleForLevel(thisLevel, GetStyleSheet()));
+ wxRichTextApplyStyle(attr, listStyle);
+ attr.SetOutlineLevel(thisLevel);
+ if (para->GetAttributes().HasBulletNumber())
+ attr.SetBulletNumber(para->GetAttributes().GetBulletNumber());
+ }
+ }
+
if (!foundAttributes)
{
attr = para->GetAttributes();
attr.SetFlags(flags);
}
- // Now see if we need to number the paragraph.
- if (attr.HasBulletStyle())
- {
- wxTextAttr numberingAttr;
- if (FindNextParagraphNumber(para, numberingAttr))
- wxRichTextApplyStyle(attr, (const wxTextAttr&) numberingAttr);
- }
-
return attr;
}
else
while (node)
{
wxRichTextFileHandler* handler = (wxRichTextFileHandler*) node->GetData();
- if (handler->IsVisible() && ((save && handler->CanSave()) || !save && handler->CanLoad()))
+ if (handler->IsVisible() && ((save && handler->CanSave()) || (!save && handler->CanLoad())))
{
if (combine)
{
if (action->GetNewParagraphs().GetChildCount() == 1)
action->GetNewParagraphs().SetPartialParagraph(true);
- action->SetPosition(position);
+ action->SetPosition(position+1);
// Set the range we'll need to delete in Undo
- action->SetRange(wxRichTextRange(position, position));
+ action->SetRange(wxRichTextRange(position+1, position+1));
SubmitAction(action);
}
wxRichTextFontTable::wxRichTextFontTable(const wxRichTextFontTable& table)
+ : wxObject()
{
(*this) = table;
}