mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
.CtrlCore/EncodeRTF: bug fix in interpretation of \pard; added optional context parameter
.RichEdit/RichEdit.h, Editor.cpp, Mouse.cpp: new callback WhenBar / StdBar member enables local editor menu customization git-svn-id: svn://ultimatepp.org/upp/trunk@3993 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
208f408cdb
commit
02cc7f40ff
5 changed files with 59 additions and 23 deletions
|
|
@ -1578,9 +1578,11 @@ bool (*&DisplayErrorFn())(const Value& v);
|
|||
inline bool DisplayError(const Value& v) { return DisplayErrorFn()(v); }
|
||||
|
||||
void EncodeRTF(Stream& stream, const RichText& richtext, byte charset,
|
||||
Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472));
|
||||
Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472),
|
||||
void *context = NULL);
|
||||
String EncodeRTF(const RichText& richtext, byte charset,
|
||||
Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472));
|
||||
Size dot_page_size = Size(4960, 7015), const Rect& dot_margin = Rect(472, 472, 472, 472),
|
||||
void *context = NULL);
|
||||
String EncodeRTF(const RichText& richtext, byte charset, int dot_page_width);
|
||||
String EncodeRTF(const RichText& richtext);
|
||||
RichText ParseRTF(const char *rtf);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ static int GetParaHeight(const Array<RichPara::Part>& parts)
|
|||
|
||||
class RTFEncoder {
|
||||
public:
|
||||
RTFEncoder(Stream& stream, const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins);
|
||||
RTFEncoder(Stream& stream, const RichText& richtext, byte charset,
|
||||
Size dot_page_size, const Rect& dot_margins, void *context);
|
||||
|
||||
void Run();
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ private:
|
|||
byte charset;
|
||||
Size dot_page_size;
|
||||
Rect dot_margins;
|
||||
|
||||
void *context;
|
||||
|
||||
RichPara::CharFormat charfmt;
|
||||
RichPara::Format parafmt;
|
||||
|
|
@ -94,15 +95,15 @@ private:
|
|||
};
|
||||
|
||||
void EncodeRTF(Stream& stream, const RichText& richtext, byte charset,
|
||||
Size dot_page_size, const Rect& dot_margins)
|
||||
Size dot_page_size, const Rect& dot_margins, void *context)
|
||||
{
|
||||
RTFEncoder(stream, richtext, charset, dot_page_size, dot_margins).Run();
|
||||
RTFEncoder(stream, richtext, charset, dot_page_size, dot_margins, context).Run();
|
||||
}
|
||||
|
||||
String EncodeRTF(const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins)
|
||||
String EncodeRTF(const RichText& richtext, byte charset, Size dot_page_size, const Rect& dot_margins, void *context)
|
||||
{
|
||||
StringStream out;
|
||||
EncodeRTF(out, richtext, charset, dot_page_size, dot_margins);
|
||||
EncodeRTF(out, richtext, charset, dot_page_size, dot_margins, context);
|
||||
String s = out.GetResult();
|
||||
LLOG("EncodeRTF <<<<<\n" << s << "\n>>>>> EncodeRTF");
|
||||
return s;
|
||||
|
|
@ -123,12 +124,13 @@ String EncodeRTF(const RichText& richtext)
|
|||
}
|
||||
|
||||
RTFEncoder::RTFEncoder(Stream& stream_, const RichText& richtext_, byte charset_,
|
||||
Size dot_page_size_, const Rect& dot_margins_)
|
||||
Size dot_page_size_, const Rect& dot_margins_, void *context_)
|
||||
: stream(stream_)
|
||||
, richtext(richtext_)
|
||||
, charset(charset_)
|
||||
, dot_page_size(dot_page_size_)
|
||||
, dot_margins(dot_margins_)
|
||||
, context(context_)
|
||||
{
|
||||
for(int i = 0; i < richtext.GetStyleCount(); i++)
|
||||
styleid.Add(richtext.GetStyleId(i));
|
||||
|
|
@ -295,7 +297,7 @@ void RTFEncoder::PutObject(const RichObject& object)
|
|||
else {
|
||||
Command("wmetafile", 8);
|
||||
WinMetaFileDraw wmd(log_size.cx, log_size.cy);
|
||||
object.Paint(wmd, log_size);
|
||||
object.Paint(wmd, log_size, context);
|
||||
WinMetaFile wmf = wmd.Close();
|
||||
HENHMETAFILE hemf = wmf.GetHEMF();
|
||||
int size = GetWinMetaFileBits(hemf, 0, 0, MM_ANISOTROPIC, ScreenHDC());
|
||||
|
|
@ -670,8 +672,10 @@ void RTFEncoder::PutTxt(const RichTxt& txt, int nesting, int dot_width)
|
|||
Command("intbl");
|
||||
if(nesting > 1)
|
||||
Command("itap", nesting);
|
||||
parafmt = RichPara::Format();
|
||||
charfmt = RichPara::CharFormat();
|
||||
// parafmt = RichPara::Format();
|
||||
// bool isul = charfmt.IsUnderline();
|
||||
// charfmt = RichPara::CharFormat();
|
||||
// charfmt.Underline(isul);
|
||||
para_ht = 0;
|
||||
}
|
||||
if(para.format.bullet == RichPara::BULLET_TEXT) {
|
||||
|
|
|
|||
|
|
@ -622,6 +622,8 @@ RichEdit::RichEdit()
|
|||
AddFrame(sb);
|
||||
RefreshBar();
|
||||
|
||||
WhenBar = THISBACK(StdBar);
|
||||
|
||||
ruler.WhenBeginTrack = THISBACK(BeginRulerTrack);
|
||||
ruler.WhenTrack = THISBACK(RulerTrack);
|
||||
ruler.WhenEndTrack = THISBACK(ReadFormat);
|
||||
|
|
|
|||
|
|
@ -182,28 +182,22 @@ void RichEdit::MouseMove(Point p, dword flags)
|
|||
}
|
||||
}
|
||||
|
||||
void RichEdit::RightDown(Point p, dword flags)
|
||||
void RichEdit::StdBar(Bar& menu)
|
||||
{
|
||||
useraction = true;
|
||||
NextUndo();
|
||||
MenuBar menu;
|
||||
int l, h;
|
||||
Rect ocr = GetCaretRect();
|
||||
int c = GetMousePos(p);
|
||||
int fieldpos = -1;
|
||||
Id field;
|
||||
String fieldparam;
|
||||
String ofieldparam;
|
||||
RichObject object, o;
|
||||
if(GetSelection(l, h)) {
|
||||
if(c >= l && c < h) {
|
||||
CopyTool(menu);
|
||||
CutTool(menu);
|
||||
}
|
||||
// if(c >= l && c < h) {
|
||||
CopyTool(menu);
|
||||
CutTool(menu);
|
||||
// }
|
||||
PasteTool(menu);
|
||||
}
|
||||
else {
|
||||
LeftDown(p, flags);
|
||||
if(objectpos >= 0) {
|
||||
object = GetObject();
|
||||
if(!object) return;
|
||||
|
|
@ -258,6 +252,37 @@ void RichEdit::RightDown(Point p, dword flags)
|
|||
}
|
||||
LoadImageTool(menu);
|
||||
}
|
||||
}
|
||||
|
||||
void RichEdit::RightDown(Point p, dword flags)
|
||||
{
|
||||
useraction = true;
|
||||
NextUndo();
|
||||
MenuBar menu;
|
||||
int l, h;
|
||||
Rect ocr = GetCaretRect();
|
||||
int c = GetMousePos(p);
|
||||
int fieldpos = -1;
|
||||
Id field;
|
||||
String fieldparam;
|
||||
String ofieldparam;
|
||||
RichObject object, o;
|
||||
if(!GetSelection(l, h)) {
|
||||
LeftDown(p, flags);
|
||||
if(objectpos >= 0)
|
||||
o = object = GetObject();
|
||||
else {
|
||||
RichPos p = cursorp;
|
||||
field = p.field;
|
||||
fieldparam = p.fieldparam;
|
||||
RichPara::FieldType *ft = RichPara::fieldtype().Get(field, NULL);
|
||||
if(ft) {
|
||||
ofieldparam = fieldparam;
|
||||
fieldpos = cursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
WhenBar(menu);
|
||||
Rect r = GetCaretRect();
|
||||
Refresh(r);
|
||||
Refresh(ocr);
|
||||
|
|
|
|||
|
|
@ -626,6 +626,7 @@ public:
|
|||
Callback WhenStartEvaluating;
|
||||
Callback2<String&, WString&> WhenHyperlink;
|
||||
Callback1<String&> WhenLabel;
|
||||
Callback1<Bar&> WhenBar;
|
||||
|
||||
void SerializeSettings(Stream& s);
|
||||
|
||||
|
|
@ -671,6 +672,8 @@ public:
|
|||
bool Print();
|
||||
void DoPrint() { Print(); }
|
||||
|
||||
void StdBar(Bar& bar);
|
||||
|
||||
void StyleTool(Bar& bar, int width = 120);
|
||||
void FaceTool(Bar& bar, int width = 130);
|
||||
void HeightTool(Bar& bar, int width = 50);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue