[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-dev] Text fixes (2)
- From: Martin Wuerthner <lists@xxxxxxxxxxxxxxx>
- Date: Thu, 20 Jul 2006 17:52:45 +0200
- Subject: [XaraXtreme-dev] Text fixes (2)
Find attached below a patch that disables an over-zealous optimization
that did not quite work in the light of attribute optimisation - I had
assumed that an applied attribute would either change (in which case
the object would be notified) or remain at the same place, so you
could keep a cached pointer. Of course, attribute optimisation spoils
this, so the text line now caches the currently applied ruler in its
entirety rather than keeping a pointer to it.
This was likely to be the cause of problems when editing successive
lines with different ruler settings (e.g., bug #1301).
Martin
Index: Kernel/nodetxtl.h
===================================================================
--- Kernel/nodetxtl.h (Revision 1488)
+++ Kernel/nodetxtl.h (Arbeitskopie)
@@ -288,7 +288,8 @@
CC_DECLARE_DYNAMIC(TextLine)
public:
- TextLine();
+ TextLine();
+ ~TextLine();
TextLine(Node* ContextNode, AttachNodeDirection Direction);
void Init();
@@ -378,7 +379,7 @@
void SetParaLeftMargin( MILLIPOINT Margin) { mLeftMargin = Margin; }
void SetParaFirstIndent(MILLIPOINT Indent) { mFirstIndent = Indent; }
void SetParaRightMargin(MILLIPOINT Margin) { mRightMargin = Margin; }
- void SetRuler( const TxtRuler* pRuler) { mpRuler = pRuler; }
+ void SetRuler( const TxtRuler* pRuler) { if (*mpRuler != *pRuler) *mpRuler = *pRuler; }
MILLIPOINT GetPosInStory() { return mPosInStory; }
void SetPosInStory(MILLIPOINT pos) { mPosInStory=pos; }
@@ -396,10 +397,8 @@
MILLIPOINT mLeftMargin; // cache for value read from attr stack
MILLIPOINT mFirstIndent; // cache for value read from attr stack
MILLIPOINT mRightMargin; // cache for value read from attr stack
- const TxtRuler* mpRuler; // cache for value read from attr stack
- // NB - this is a shared pointer to a list object owned by the attribute!
- // this only works because applying a different attribute will cause
- // our cached value to be updated
+ TxtRuler* mpRuler; // cache for value read from attr stack
+ // NB - this is a list object owned by this object
MILLIPOINT mPosInStory; // y position of base of line relative to story
};
Index: Kernel/nodetxtl.cpp
===================================================================
--- Kernel/nodetxtl.cpp (Revision 1488)
+++ Kernel/nodetxtl.cpp (Arbeitskopie)
@@ -178,19 +178,19 @@
mJustification = JLEFT;
mLineSpacing = 0;
mLineSpaceRatio = 1;
+ mpRuler = new TxtRuler;
mPosInStory = 0;
}
-
+
/********************************************************************************************
> TextLine::TextLine()
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 21/12/94
Purpose: Simple TextLine constructor, it is required so that SimpleCopy will work.
- You should not normally call this constructor as it does not initialise
- the object.
+
********************************************************************************************/
TextLine::TextLine(): BaseTextClass() // Call the base class
@@ -198,6 +198,19 @@
Init();
}
+/********************************************************************************************
+> TextLine::~TextLine()
+
+ Author: Martin Wuerthner <xara@xxxxxxxxxxxxxxx>
+ Created: 20/07/06
+ Purpose: Destructor
+
+********************************************************************************************/
+
+TextLine::~TextLine()
+{
+ delete mpRuler;
+}
/********************************************************************************************
> TextLine::TextLine(Node* ContextNode, AttachNodeDirection Direction)
@@ -379,7 +392,7 @@
NodeCopy->mLeftMargin = mLeftMargin;
NodeCopy->mFirstIndent = mFirstIndent;
NodeCopy->mRightMargin = mRightMargin;
- NodeCopy->mpRuler = mpRuler;
+ *NodeCopy->mpRuler = *mpRuler;
NodeCopy->mPosInStory = mPosInStory;
}
@@ -714,6 +727,7 @@
BOOL TextLine::ReCacheMetrics(FormatRegion* pFormatRegion)
{
+ TRACEUSER("wuerthne", _T("TextLine::ReCacheMetrics"));
SetJustification( pFormatRegion->GetJustification());
SetLineSpacing( pFormatRegion->GetLineSpacing());
SetLineSpaceRatio(pFormatRegion->GetLineSpaceRatio());
@@ -722,6 +736,33 @@
SetParaFirstIndent(pFormatRegion->GetFirstIndent());
SetParaRightMargin(pFormatRegion->GetRightMargin());
SetRuler(pFormatRegion->GetRuler());
+#if defined(_DEBUG) && 0
+ String_256 TempStr;
+ String Str(_T(" "));
+ for (TxtTabStopIterator It = mpRuler->begin(); It != mpRuler->end(); ++It)
+ {
+ switch((*It).GetType())
+ {
+ case LeftTab:
+ TempStr._MakeMsg( TEXT("L(#1%ld)"), (*It).GetPosition());
+ Str += TempStr;
+ break;
+ case RightTab:
+ TempStr._MakeMsg( TEXT("R(#1%ld)"), (*It).GetPosition());
+ Str += TempStr;
+ break;
+ case CentreTab:
+ TempStr._MakeMsg( TEXT("C(#1%ld)"), (*It).GetPosition());
+ Str += TempStr;
+ break;
+ case DecimalTab:
+ TempStr._MakeMsg( TEXT("D(#1%ld)"), (*It).GetPosition());
+ Str += TempStr;
+ break;
+ }
+ }
+ TRACEUSER("wuerthne", _T("ruler at %08x:%s"), mpRuler, (TCHAR*)Str);
+#endif
return TRUE;
}