2011年4月27日星期三

patch file_Implement progress bar in windows

The patch file I have modified in the following spaces, to keep same with the source code:
==================1 ap_usb_ProgressListener======
create a class to deal with ProgressListener(the same as the gtk code). seperate from the statusBarListener
class ap_usb_ProgressListener : public AP_StatusBarFieldListener
{
public:
.............
virtual void notify();   //deal with progressbar update
protected:
HWND m_ProgressWND;
};
==================2======
and in the notify function deal with the update:   and i find the place to add pulse process bar
void ap_usb_ProgressListener::notify()
{  
if(pProgress->isDefinate())
{
double fraction = pProgress->getFraction();
SendMessage(m_ProgressWND,PBM_SETPOS,fraction*100,0);
}
else
{   //here pulse process bar  <--------------pulse process bar
}
}
===========================3============
In this situation, I need to build the connection between ap_usb_ProgressListener and ProcessBar in the createWindow()    in this place, your code have one error(the elseif is in the wrong place)
else if(pf->getFillMethod() == PROGRESS_BAR)
{
pf->setListener((AP_StatusBarFieldListener *)(new ap_usb_ProgressListener(pf, m_hwndProgressBar)));
}
===========================4============
Remove unused function and variables

Why should we expose the SpellCheck interface in Enchant

I have read much code about enchant and want to implement hyphenation using enchant
but I have one question  in the FL_DocLayout.cpp where spellcheck used.  I think the SpeellManager is enough to deal with our problem, Why should we expose the SpellCheck interface in Enchant. that is not safe


one more question, if we use enchant for abstraction of dictionaries. but most dictionaries have different format. how to  analysis the different format of dictionary
I think the analysis of  dictionary is done by the library the dictionay provide, the  enchant is just Responsible for call it

some different idea?

Share of some understanding about Source code

Recently I try to implement the process bar in windows. and I read a lot of source code, I make a summary of that. I want to share with you all, I hope that is helpfull to you all. 
Anyone interested in that pls disscus with me, Thank you.
 
the attachment is the class diagram in UML format. we can see that:
 
1. the AP_StatusBar is an abstract class represent the status bar.
 And the Windows AP_Win32StatusBar inherited from AP_StatusBar
And in the AP_StatusBar contain the interface elements——m_vecFields(vector of StatusBarField) and processField(processBar). 
But they are all the abstract class AP_StatusBarField. And the concreate class is AP_StatusBarFidld_ProcessBar / ap_sbf_pageInfo /ap_sbf_StatusMessage/ ap_sbf_InputMode / ap_sbf_Language.
 
AP_StatusBarField_ProcessBar: present the processBar
ap_sbf_pageInfo: present pageInfo
ap_sbf_StatusMessage:present StatusMessage
ap_sbf_InputMode: present InputMode
ap_sbf_Language: present Language
 
2. And the event-handler of the interface elements are all in the following format:
  firstly, creating the event-handler Listener 
  then build the connection between them
  override the notify function in the Listener to handler the event
 
  every interface element has Listener class:
AP_StatusBarFidld_ProcessBar: ap_usb_processListener
ap_sbf_pageInfo: ap_usb_TextListener
ap_sbf_StatusMessage: ap_usb_TextListener
ap_sbf_InputMode: ap_usb_TextListener
ap_sbf_Language: ap_usb_TextListener
 
all the listener are all inherit from the Ap_StatusBarFieldListener.  
and the event are all handled in the notify function.
 
3. in the AP_Win32StatusBar.
   the createWindow function create the HWNDs and make connection with their listener
AP_Win32StatusBar::createWindow:
for (UT_sint32 k = 0; k <  getFields()-> getItemCount(); k++) 
{  
    pf-> setListener(...));
}

libhyphenate

I use libhyphenate to implement the hyphenation sucessfully. And then refer to the source code of libhyphenate.
In libhyphenate, it is easy to carry out the hyphenation.
#include <libhyphenate\Hyphenator.h>
#include <iostream>
using namespace Hyphenate;
using namespace std;
int main () {
   Hyphenator(RFC_3066::Language("en")).hyphenate("example.txt","output.txt") ;
   return 0;
}
 
the input is the txt file, and the output file is correctly in the hyphenation format. now, I read the source code of libhyphenate to find what we can refer to libhyphenate.
 
But I found one problem, the dictionary is not enough in the libhyphenate. And I replace with Webster's New International Dictionary , also have some problems, because the interface is different. 
Although the author of libhyphenate make the algorithm and the dictionary seperately, so that you can add your own dictionary to deal with your language.

Some Open Source libraries about hyphenation

=============================1======================
I think hyphenation is locale dependent because in different languages, some data type such as number and date are different from each other. So we must find a method support for many different Languages besides English. AbiWord is the word processor for everybody, not just English speakers.

=============3 Some Open Source libraries about hyphenation =========================
I have searched some Open Source libraries we can use to determine word break points. 
There is a wide range of different free open source solutions for spell-checking and hyphenation by computer.
1.  libhyphenate- An hyphenation library for C++, LGPL Hyphenation Library. 
Developer Steve Wolter has released Version 1.0 of Libhyphenate, his C++ hyphenation library. Libhyphenate implements the hyphenation algorithm also used by the Tex layout system. The library currently supports hyphenation libraries for English, German and French. More languages can be generated from the corresponding Tex files. 
2.  In the thesis” Word Hyphenation by Computer” mention a lot of library. I think we can read that.
3.  wordaxe : Hyphenation by decomposition of compound words
4.  SyFi: A C++ library built on top of the symbolic math library GiNaC. 
===============some python and other language libraries we can refer to===============
1  PyHyphen: Hyphenation module for Python programs with the ability to automatically hyphenate words using an algorithm which is based on decomposition of compound words into base words, and is named DCWHyphenator in the code.
2  Pslib is a C-library to create PostScript files on the fly. It offers text rendering including hyphenation, kerning and ligatures. 
3  XHTML hyphenator: XHTML hyphenator is a hyphenation program for XHTML documents.
I will spend more time to care about the C++ hyphenation library. 
 

Time Plan about implementation of Hyphenation support in AbiWord

First version of my time plan. I will make a detailed disscusion with my mentor


Time Plan about implementation of Hyphenation support in AbiWord
Chen Xiajian

Date
Plan to do
Week 1
1 Read more about Enchant and get familiar with the use of Enchant in AbiWord (this step will make an abstraction of the hyphenation algorithm)
2 Search and find more libraries which can be used to determine the breakpoints within words. Includes:
Ø  Some TeX formatting system
Ø  Open Source libraries
Ø  If possible pull out just the code we need from some package. 
Ø  Care about the language factors(besides English)
3 Learn more about Hyphenation algorithm

Deliverable 1:
Make a summary about Enchant and the open source hyphenation libraries
Choose one most suitable for us
Week 2
(continue and finish) 
1 Some programming test about Open Source hyphenation libraries
2 Make a code framework about where to add code(to make code more flexible)
3 Design the data structures of Hyphenation
4 Building the hyphenationChecker using open source library in Enchant
hyphenationChecker is the name I define in Enchant to deal with hyphenation

Deliverable 2:
1 Summary Document
2 Patch about data structures of Hyphenation
3 Make an patch about hyphenationChecker
Week 3
1 Fix possibly remaining bugs to have a good foundation for the further.
2 Read source code and place hyphenation points called from the Enchant
The codes in src/text/fmt/xp/*.(h,cpp)
Ø  fb_LineBreaker.(h,cpp) and
Ø  fb_Alignment.(h,cpp)



Deliverable 3:
1 Make an patch about implementation of hyphenation points
2 Fix remaining bugs
Week 4
1 Draw the hyphenation characters in AbiWord
2 Find more good dictionary to have a good coverage of different language and words

Deliverable 4:
1 Make an patch about preliminary results
2 Make a summary of dictionary
Week 5
(continue and finish)
According to Martin, it seems that it's a difficult task. Time is needed.
1 Have more tests
2 Again, Fix possibly remaining bugs
3 Prepare some document that Google required in Mid Evaluation

Deliverable 5:
1 Fix remaining bugs
2 Some document that Google require
July 15
Mid Evaluation
Week 6
1 Care about some special languages and special words

Deliverable 6:
1 Have an more good result to support more language and words
Week 7
Rejoin hyphenated words as they get moved via the users editing.
Codes:  src/text/fmt/xp/fl_BlockLayout.cpp
More tests

Deliverable 7:
Patch about implementation of this function
More tests
Week 8
1 deal with the result: misspell words are correctly handled after hyphenation.
2 Test and Refactor

Deliverable 8:
1 Patch about implementation of this function
2 better version
Week 9
(continue and finish)
 1 Fix new or remaining bugs
 2 Some documents what GsoC needed
Week 10
(continue and finish)
Time for emergency
August 16
Suggested 'pencils down' date. Take to scrub code, write tests, improve documentation, etc.
August 26
End

Congratulations!

Get Selected~

Thank all the people who give me suggestion
I will make a good result in my GSoc2011

my GSoc2011: Add Hyphenation Support to AbiWord