• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files

fv_View.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 1998-2000 AbiSource, Inc.
00004  * Copyright (c) 2001,2002 Tomas Frydrych
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 #ifndef FV_VIEW_H
00022 #define FV_VIEW_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027 
00028 #include "xap_Features.h"
00029 #include "ut_types.h"
00030 #include "xav_View.h"
00031 #include "pt_Types.h"
00032 #include "fp_types.h"
00033 #include "fl_Squiggles.h"
00034 #include "ev_EditBits.h"
00035 
00036 // have to include these as they are instantiated in the FV_View
00037 // class definition
00038 #include "fv_FrameEdit.h"
00039 #include "fv_Selection.h"
00040 #include "fv_InlineImage.h"
00041 
00042 #ifdef TOOLKIT_GTK
00043 #include "fv_UnixVisualDrag.h"
00044 #include "fv_UnixFrameEdit.h"
00045 #include "fv_UnixInlineImage.h"
00046 #else
00047 #include "fv_VisualDragText.h"
00048 #endif
00049 
00050 #define AUTO_SCROLL_MSECS   100
00051 
00052 class FL_DocLayout;
00053 class FV_Caret_Listener;
00054 
00055 class fl_DocSectionLayout;
00056 class fl_HdrFtrSectionLayout;
00057 class fl_DocListener;
00058 class fl_BlockLayout;
00059 class fl_PartOfBlock;
00060 class fl_AutoNum;
00061 class fl_EndnoteLayout;
00062 
00063 class fp_PageSize;
00064 class fp_Page;
00065 class fp_Run;
00066 class fp_HyperlinkRun;
00067 class fp_CellContainer;
00068 
00069 class FG_Graphic;
00070 
00071 class PD_Document;
00072 class PP_AttrProp;
00073 class PP_RevisionAttr;
00074 
00075 class GR_Graphics;
00076 struct dg_DrawArgs;
00077 
00078 class UT_Worker;
00079 class UT_Timer;
00080 class UT_UTF8String;
00081 
00082 class AP_TopRulerInfo;
00083 class AP_LeftRulerInfo;
00084 class AP_TopRuler;
00085 class AP_LeftRuler;
00086 
00087 class AP_Dialog_SplitCells;
00088 
00089 class XAP_App;
00090 class XAP_Prefs;
00091 
00092 class SpellChecker;
00093 
00094 class CellLine;
00095 
00096 typedef enum
00097 {
00098     hori_left,
00099     hori_mid,
00100     hori_right,
00101     vert_above,
00102     vert_mid,
00103     vert_below
00104 } AP_CellSplitType;
00105 
00106 
00107 typedef enum _AP_JumpTarget
00108 {
00109     AP_JUMPTARGET_PAGE,             // beginning of page
00110     AP_JUMPTARGET_LINE,
00111     AP_JUMPTARGET_BOOKMARK,
00112     AP_JUMPTARGET_PICTURE // TODO
00113 } AP_JumpTarget;
00114 
00115 struct fv_ChangeState
00116 {
00117     bool                bUndo;
00118     bool                bRedo;
00119     bool                bDirty;
00120     bool                bSelection;
00121     UT_uint32           iColumn;
00122     const gchar **  propsChar;
00123     const gchar **  propsBlock;
00124     const gchar **  propsSection;
00125 };
00126 
00127 struct FV_DocCount
00128 {
00129     UT_uint32 word;
00130     UT_uint32 para;
00131     UT_uint32 ch_no;
00132     UT_uint32 ch_sp;
00133     UT_uint32 line;
00134     UT_uint32 page;
00135        // sometimes people want to have a word count without header/footers included
00136     UT_uint32 words_no_hdrftr;
00137 };
00138 
00139 class ABI_EXPORT fv_PropCache
00140 {
00141 public:
00142     fv_PropCache(void);
00143     ~fv_PropCache(void);
00144     UT_uint32         getTick(void) const;
00145     void              setTick(UT_uint32 iTick);
00146     bool              isValid(void) const;
00147     const gchar ** getCopyOfProps(void) const;
00148     void              fillProps(UT_uint32 numProps, const gchar ** props);
00149     void              clearProps(void);
00150 private:
00151     UT_uint32         m_iTick;
00152     UT_uint32         m_iNumProps;
00153     gchar **       m_pszProps;
00154 };
00155 
00156 enum FV_BIDI_Order
00157 {
00158     FV_Order_Visual = 0,
00159     FV_Order_Logical_LTR = UT_BIDI_LTR,
00160     FV_Order_Logical_RTL = UT_BIDI_RTL
00161 };
00162 
00163 class ABI_EXPORT fv_CaretProps
00164 {
00165 public:
00166         fv_CaretProps(FV_View * pView, PT_DocPosition InsPoint);
00167     virtual ~fv_CaretProps(void);
00168     PT_DocPosition              m_iInsPoint;
00169     UT_sint32           m_xPoint;
00170     UT_sint32           m_yPoint;
00171     UT_sint32           m_xPoint2;
00172     UT_sint32           m_yPoint2;
00173     bool                    m_bPointDirection;
00174     bool                m_bDefaultDirectionRtl;
00175     bool                m_bUseHebrewContextGlyphs;
00176     bool                            m_bPointEOL;
00177     UT_uint32           m_iPointHeight;
00178     UT_RGBColor                     m_caretColor;
00179     FV_Caret_Listener *             m_PropCaretListner;
00180     GR_Caret *                      m_pCaret;
00181     UT_uint32                       m_ListenerID;
00182     FV_View *                       m_pView;
00183     UT_sint32                       m_iAuthorId;
00184 };
00185                                 
00186 class ABI_EXPORT FV_View : public AV_View
00187 {
00188     friend class fl_DocListener;
00189     friend class fl_BlockLayout;
00190     friend class FL_DocLayout;
00191     friend class fl_Squiggles;
00192     friend class fl_DocSectionLayout;
00193     friend class GR_Caret;
00194     friend class FV_FrameEdit;
00195     friend class FV_VisualDragText;
00196     friend class FV_VisualInlineImage;
00197     friend class FV_Selection;
00198     friend class CellLine;
00199 
00200 public:
00201     FV_View(XAP_App*, void*, FL_DocLayout*);
00202     virtual ~FV_View();
00203 
00204     virtual inline GR_Graphics*    getGraphics(void) const { return m_pG; }
00205     void  setGraphics(GR_Graphics *pG);
00206     void  replaceGraphics(GR_Graphics *pG);
00207 
00208     virtual inline PT_DocPosition   getPoint(void) const { return m_iInsPoint; }
00209     PT_DocPosition  getSelectionAnchor(void) const;
00210     PT_DocPosition  getSelectionLeftAnchor(void);
00211     PT_DocPosition  getSelectionRightAnchor(void) ;
00212     UT_uint32       getSelectionLength(void) const;
00213 
00214     UT_sint32       getFrameMargin(void) const;
00215 
00216     virtual void focusChange(AV_Focus focus);
00217     virtual bool    isActive(void);
00218 
00219     virtual void    setXScrollOffset(UT_sint32);
00220     virtual void    setYScrollOffset(UT_sint32);
00221     virtual void    cmdScroll(AV_ScrollCmd cmd, UT_uint32 iPos = 0);
00222 
00223     virtual void    cmdHyperlinkJump(UT_sint32 xPos, UT_sint32 yPos);
00224     void            cmdHyperlinkJump(PT_DocPosition pos);
00225     void            cmdHyperlinkCopyLocation(PT_DocPosition pos);
00226 
00227     virtual void    draw(const UT_Rect* pRect=static_cast<UT_Rect*>(NULL));
00228     virtual void    drawSelectionBox(UT_Rect & box, bool drawHandles);
00229 private: 
00230     inline void     _drawResizeHandle(UT_Rect & box);
00231     
00232 public:
00233     const PP_AttrProp * getAttrPropForPoint();
00234 
00235     virtual bool    notifyListeners(const AV_ChangeMask hint);
00236 
00237     virtual bool    canDo(bool bUndo) const;
00238     virtual UT_uint32 undoCount (bool bUndo) const;
00239     virtual void    cmdUndo(UT_uint32 count);
00240     virtual void    cmdRedo(UT_uint32 count);
00241     virtual UT_Error    cmdSave(void);
00242     virtual UT_Error    cmdSaveAs(const char * szFilename, int ieft);
00243     virtual UT_Error        cmdSaveAs(const char * szFilename, int ieft, bool cpy);
00244 
00245     UT_Error        cmdInsertField(const char* szName, const gchar ** extra_attrs = NULL, const gchar ** extra_props = NULL);
00246     UT_Error        cmdInsertBookmark(const char* szName);
00247     UT_Error        cmdDeleteBookmark(const char* szName);
00248     UT_Error        cmdInsertHyperlink(const char* szName);
00249     fp_Run *        getHyperLinkRun(PT_DocPosition pos);
00250     UT_Error        cmdDeleteHyperlink();
00251     bool                    cmdInsertMathML(const char * szFileName,
00252                         PT_DocPosition pos);
00253     bool            cmdInsertEmbed(UT_ByteBuf * pBuf,PT_DocPosition pos,const char * szMime,const char * szProps);
00254     bool            cmdUpdateEmbed(UT_ByteBuf * pBuf, const char * szMime, const char * szProps);
00255     bool            cmdUpdateEmbed(fp_Run * pRun, UT_ByteBuf * pBuf, const char * szMime, const char * szProps);
00256     bool            cmdDeleteEmbed(fp_Run * pRun);
00257 
00258     bool                    cmdInsertLatexMath(UT_UTF8String & sLatex,
00259                            UT_UTF8String & sMath);
00260 
00261     UT_Error        cmdInsertTOC(void);
00262     UT_Error        cmdHyperlinkStatusBar(UT_sint32 xPos, UT_sint32 yPos);
00263 
00264     UT_Error        cmdInsertGraphic(FG_Graphic*);
00265     UT_Error        cmdInsertGraphicAtStrux(FG_Graphic* pFG, PT_DocPosition iPos, PTStruxType iStruxType);
00266     virtual void    toggleCase(ToggleCase c);
00267     virtual void    setPaperColor(const gchar * clr);
00268 
00269     virtual bool    isDocumentPresent(void);
00270     virtual void    cmdCopy(bool bToClipboard = true);
00271     virtual void    cmdCut(void);
00272     virtual void    cmdPaste(bool bHonorFormatting = true);
00273     virtual void    cmdPasteSelectionAt(UT_sint32 xPos, UT_sint32 yPos);
00274 
00275     void            pasteFromLocalTo(PT_DocPosition pos);
00276     void            _pasteFromLocalTo(PT_DocPosition pos);
00277     void            copyToLocal(PT_DocPosition pos1, PT_DocPosition pos2);
00278     void        copyTextToClipboard(const UT_UCS4String sIncoming, bool useClipboard=true);
00279 
00280     virtual void    getTopRulerInfo(AP_TopRulerInfo * pInfo);
00281     virtual void    getTopRulerInfo(PT_DocPosition pos, AP_TopRulerInfo * pInfo);
00282     virtual void    getLeftRulerInfo(AP_LeftRulerInfo * pInfo);
00283     virtual void    getLeftRulerInfo(PT_DocPosition pos, AP_LeftRulerInfo * pInfo);
00284         virtual void    setCursorWait(void);
00285     virtual void    clearCursorWait(void);
00286     virtual void    setCursorToContext(void);
00287     EV_EditMouseContext         getLastMouseContext(void);
00288     void                getMousePos(UT_sint32 * x, UT_sint32 * y);
00289 
00290     virtual EV_EditMouseContext getMouseContext(UT_sint32 xPos, UT_sint32 yPos);
00291     EV_EditMouseContext _getMouseContext(UT_sint32 xPos, UT_sint32 yPos);
00292     virtual EV_EditMouseContext getInsertionPointContext(UT_sint32 * pxPos, UT_sint32 * pyPos);
00293     void                setPrevMouseContext(EV_EditMouseContext  emc)
00294     {m_prevMouseContext = emc;}
00295 
00296     virtual void        updateLayout(void);
00297     virtual void        rebuildLayout(void);
00298     virtual void        remeasureCharsWithoutRebuild();
00299     virtual void        fontMetricsChange();
00300     virtual bool        isSelectionEmpty(void) const;
00301     bool                isSelectAll(void)
00302     { return m_Selection.isSelectAll();}
00303     virtual void        cmdUnselectSelection(void);
00304     void                getDocumentRangeOfCurrentSelection(PD_DocumentRange * pdr);
00305     PT_DocPosition      mapDocPos( FV_DocPos dp );
00306     PT_DocPosition      mapDocPosSimple( FV_DocPos dp );
00307     PT_DocPosition saveSelectedImage (const char * toFile );
00308     PT_DocPosition saveSelectedImage (const UT_ByteBuf ** outByteBuf);
00309     PT_DocPosition getSelectedImage(const char **dataId);
00310     fp_Run *getSelectedObject(void);
00311 
00312     void            getTextInCurrentBlock(UT_GrowBuf & buf);
00313     void            getTextInCurrentSection(UT_GrowBuf & buf);
00314     void            getTextInDocument(UT_GrowBuf & buf);
00315     bool            getLineBounds(PT_DocPosition pos, PT_DocPosition *start, PT_DocPosition *end);
00316     UT_UCSChar getChar(PT_DocPosition pos, UT_sint32 *x = NULL, UT_sint32 *y = NULL, UT_uint32 *width = NULL, UT_uint32 *height = NULL);
00317 
00318 // ----------------------
00319     FL_DocLayout*   getLayout() const;
00320     UT_uint32       getCurrentPageNumForStatusBar(void) const;
00321     fp_Page*        getCurrentPage(void) const;
00322     fl_BlockLayout* getCurrentBlock(void);
00323 
00324     void draw(int page, dg_DrawArgs* da);
00325 
00326     // TODO some of these functions should move into protected
00327 
00328     void    getPageScreenOffsets(const fp_Page* pPage, UT_sint32& xoff, UT_sint32& yoff);
00329     void    getPageYOffset(fp_Page* pPage, UT_sint32& yoff)const;
00330     virtual UT_sint32 getPageViewLeftMargin(void) const;
00331     virtual UT_sint32 getPageViewTopMargin(void) const;
00332     virtual UT_sint32 getPageViewSep(void) const;
00333 
00334     bool    setSectionFormat(const gchar * properties[]);
00335     bool    getSectionFormat(const gchar *** properties);
00336 
00337     bool    setBlockIndents(bool doLists, double indentChange, double page_size);
00338     bool    setCollapsedRange(PT_DocPosition posLow,PT_DocPosition posHigh, const gchar * properties[]);
00339     bool    setBlockFormat(const gchar * properties[]);
00340     bool    getBlockFormat(const gchar *** properties,bool bExpandStyles=true);
00341     bool    removeStruxAttrProps(PT_DocPosition ipos1, PT_DocPosition ipos2, PTStruxType iStrux,const gchar * attributes[] ,const gchar * properties[]);
00342     bool    isImageAtStrux(PT_DocPosition ipos1, PTStruxType iStrux);
00343 
00344     bool    processPageNumber(HdrFtrType hfType, const gchar ** atts);
00345 
00346 #ifdef ENABLE_SPELL
00347     bool    isTextMisspelled()const ;
00348 #endif
00349     bool    isTabListBehindPoint(UT_sint32 & iNumToDelete);
00350     bool    isTabListAheadPoint(void);
00351     void    processSelectedBlocks(FL_ListType listType);
00352     void    getBlocksInSelection(UT_GenericVector<fl_BlockLayout*> * vBlock);
00353     UT_sint32 getNumColumnsInSelection(void);
00354     UT_sint32 getNumRowsInSelection(void);
00355     void    getAllBlocksInList(UT_GenericVector<fl_BlockLayout *> * vBlock);
00356     bool    isPointBeforeListLabel(void);
00357     bool    isCurrentListBlockEmpty(void);
00358     bool    cmdStartList(const gchar * style);
00359     bool    cmdStopList(void);
00360     void    changeListStyle(fl_AutoNum* pAuto,
00361                             FL_ListType lType,
00362                             UT_uint32 startv,
00363                             const gchar* pszDelim,
00364                             const gchar* pszDecimal,
00365                             const gchar* pszFormat,
00366                             float Aligm,
00367                             float Indent);
00368 
00369     void    setDontChangeInsPoint(void);
00370     void    allowChangeInsPoint(void);
00371 
00372     bool    getAttributes(const PP_AttrProp ** ppSpanAP, const PP_AttrProp ** ppBlockAP = NULL, PT_DocPosition posStart = 0);
00373 
00374     /* Experimental, for the moment; use with caution. - fjf, 24th Oct. '04
00375      */
00376     // - begin
00377     bool    getAllAttrProp(const PP_AttrProp *& pSpanAP, const PP_AttrProp *& pBlockAP, const PP_AttrProp *& pSectionAP, const PP_AttrProp *& pDocAP) const;
00378     bool    queryCharFormat(const gchar * szProperty, UT_UTF8String & szValue, bool & bExplicitlyDefined, bool & bMixedSelection) const;
00379     bool    queryCharFormat(const gchar * szProperty, UT_UTF8String & szValue, bool & bExplicitlyDefined, PT_DocPosition position) const;
00380     // - end
00381 
00382     bool    setCharFormat(const gchar * properties[], const gchar * attribs[] = NULL);
00383     bool    resetCharFormat(bool bAll);
00384     bool    getCharFormat(const gchar *** properties,bool bExpandStyles=true);
00385     bool    getCharFormat(const gchar *** properties,bool bExpandStyles, PT_DocPosition posStart);
00386     fl_BlockLayout * getBlockFromSDH(PL_StruxDocHandle sdh);
00387     bool    setStyle(const gchar * style, bool bDontGeneralUpdate=false);
00388     bool    setStyleAtPos(const gchar * style, PT_DocPosition posStart, PT_DocPosition posEnd, bool bDontGeneralUpdate=false);
00389     bool    isNumberedHeadingHere(fl_BlockLayout * pBlock);
00390     bool    getStyle(const gchar ** style);
00391     bool appendStyle(const gchar ** style);
00392 
00393     UT_uint32       getCurrentPageNumber(void);
00394 
00395     bool    getEditableBounds(bool bEnd, PT_DocPosition & docPos, bool bOverride=false)const;
00396 
00397     bool    isParaBreakNeededAtPos(PT_DocPosition pos);
00398     bool    insertParaBreakIfNeededAtPos(PT_DocPosition pos);
00399     void    insertParagraphBreak(void);
00400     void    insertParagraphBreaknoListUpdate(void);
00401     void    insertSectionBreak( BreakSectionType type);
00402     void    insertSectionBreak(void);
00403     void    insertSymbol(UT_UCSChar c, const gchar * symfont);
00404 
00405     // ----------------------
00406     bool            isLeftMargin(UT_sint32 xPos, UT_sint32 yPos);
00407     void            cmdSelect(UT_sint32 xPos, UT_sint32 yPos, FV_DocPos dpBeg, FV_DocPos dpEnd);
00408     void            cmdSelectTOC(UT_sint32 xPos, UT_sint32 yPos);
00409     bool            isTOCSelected(void);
00410     bool            setTOCProps(PT_DocPosition pos, const char * szProps);
00411 
00412     void            cmdSelect(PT_DocPosition dpBeg, PT_DocPosition dpEnd);
00413     void            cmdCharMotion(bool bForward, UT_uint32 count);
00414     bool            cmdCharInsert(const UT_UCSChar * text, UT_uint32 count, bool bForce = false);
00415     void            cmdCharDelete(bool bForward, UT_uint32 count);
00416     void            delTo(FV_DocPos dp);
00417     void            getSelectionText(UT_UCS4Char *& text);
00418 
00419     UT_UCSChar *    getTextBetweenPos(PT_DocPosition pos1, PT_DocPosition pos2);
00420     inline PT_DocPosition  getInsPoint () const { return m_iInsPoint; }
00421     void            warpInsPtToXY(UT_sint32 xPos, UT_sint32 yPos, bool bClick);
00422     void            moveInsPtTo(FV_DocPos dp, bool bClearSelection = true);
00423     void            moveInsPtTo(PT_DocPosition dp);
00424     void            warpInsPtNextPrevPage(bool bNext);
00425     void            warpInsPtNextPrevLine(bool bNext);
00426     void            warpInsPtNextPrevScreen(bool bNext);
00427     void            extSelHorizontal(bool bForward, UT_uint32 count);
00428     void            extSelToXY(UT_sint32 xPos, UT_sint32 yPos, bool bDrag);
00429     void            extSelToXYword(UT_sint32 xPos, UT_sint32 yPos, bool bDrag);
00430     void            extSelTo(FV_DocPos dp);
00431 
00432 #ifdef ENABLE_SPELL
00433     SpellChecker * getDictForSelection ();
00434 #endif
00435     void            extSelNextPrevLine(bool bNext);
00436     void            extSelNextPrevPage(bool bNext);
00437     void            extSelNextPrevScreen(bool bNext);
00438     void            endDrag(UT_sint32 xPos, UT_sint32 yPos);
00439 
00440     void endDragSelection(UT_sint32 xPos, UT_sint32 yPos);
00441 
00442     PT_DocPosition  getDocPositionFromXY(UT_sint32 xpos, UT_sint32 ypos, bool bNotFrames = false);
00443     PT_DocPosition  getDocPositionFromLastXY(void);
00444 
00445     fl_BlockLayout* getBlockAtPosition(PT_DocPosition pos) const {return _findBlockAtPosition(pos);};
00446     virtual void    updateScreen(bool bDirtyRunsOnly=true);
00447     bool            isInDocSection(PT_DocPosition pos = 0);
00448 
00449 //---------
00450 //Visual Drag stuff
00451 //
00452     void            cutVisualText(UT_sint32 x, UT_sint32 y);
00453     void            copyVisualText(UT_sint32 x, UT_sint32 y);
00454     void            dragVisualText(UT_sint32 x, UT_sint32 y);
00455     void            pasteVisualText(UT_sint32 x, UT_sint32 y);
00456     void            btn0VisualDrag(UT_sint32 x, UT_sint32 y);
00457     FV_VisualDragText * getVisualText(void)
00458       { return &m_VisualDragText;}
00459     const UT_ByteBuf * getLocalBuf(void);
00460 
00461 //---------
00462 //Visual Inline Image Drag stuff
00463 //
00464     void            btn0InlineImage(UT_sint32 x, UT_sint32 y);
00465     void            btn1InlineImage(UT_sint32 x, UT_sint32 y);
00466     void            btn1CopyImage(UT_sint32 x, UT_sint32 y);
00467     void            dragInlineImage(UT_sint32 x, UT_sint32 y);
00468     void            releaseInlineImage(UT_sint32 x, UT_sint32 y);
00469 
00470 // -------
00471 // Frame stuff
00472 //
00473     FV_FrameEdit *  getFrameEdit(void);
00474     void            btn0Frame(UT_sint32 x, UT_sint32 y);
00475     void            btn1Frame(UT_sint32 x, UT_sint32 y);
00476     void            dragFrame(UT_sint32 x, UT_sint32 y);
00477     void            releaseFrame(UT_sint32 x, UT_sint32 y);
00478     bool            isInFrame(PT_DocPosition pos);
00479     void            deleteFrame(void);
00480     void            cutFrame(void);
00481     void            selectFrame(void);
00482     fl_FrameLayout * getFrameLayout(PT_DocPosition pos);
00483     fl_FrameLayout * getFrameLayout(void);
00484     void            setFrameFormat(const gchar ** props);
00485     void            setFrameFormat(const gchar ** attribs, const gchar ** props);
00486     void            setFrameFormat(const gchar ** props,FG_Graphic * pFG, UT_String & dataID);
00487     void            convertInLineToPositioned(PT_DocPosition pos, 
00488                                             const gchar ** attribs);
00489 
00490     bool            convertPositionedToInLine(fl_FrameLayout * pFrame);
00491     UT_Error        cmdInsertPositionedGraphic(FG_Graphic* pFG,UT_sint32 mouseX, UT_sint32 mouseY);
00492     UT_Error        cmdInsertPositionedGraphic(FG_Graphic* pFG);
00493 
00494 // ----------------------
00495 
00496     bool            isPosSelected(PT_DocPosition pos) const;
00497     bool            isXYSelected(UT_sint32 xPos, UT_sint32 yPos) const;
00498     FV_SelectionMode getSelectionMode(void) const;
00499     FV_SelectionMode getPrevSelectionMode(void) const;
00500     PD_DocumentRange * getNthSelection(UT_sint32 i);
00501     UT_sint32          getNumSelections(void) const;
00502     void            setSelectionMode(FV_SelectionMode selMode);
00503 #ifdef ENABLE_SPELL
00504 // ----------------------
00505 // Stuff for spellcheck context menu
00506 //
00507     UT_UCSChar *    getContextSuggest(UT_uint32 ndx);
00508     void            cmdContextSuggest(UT_uint32 ndx, fl_BlockLayout * ppBL = NULL, fl_PartOfBlock * ppPOB = NULL);
00509     void            cmdContextIgnoreAll(void);
00510     void            cmdContextAdd(void);
00511 #endif
00512 // ----------------------
00513 // Stuff for edittable Headers/Footers
00514 //
00515     bool                isInHdrFtr(PT_DocPosition pos);
00516     void                setHdrFtrEdit(fl_HdrFtrShadow * pShadow);
00517     void                clearHdrFtrEdit(void);
00518     bool                isHdrFtrEdit(void);
00519     fl_HdrFtrShadow *   getEditShadow(void);
00520     void                rememberCurrentPosition(void);
00521     PT_DocPosition      getSavedPosition(void);
00522     void                clearSavedPosition(void);
00523     void                markSavedPositionAsNeeded(void);
00524     bool                needSavedPosition(void);
00525     void                insertHeaderFooter(HdrFtrType hfType);
00526     bool                insertHeaderFooter(const gchar ** props, HdrFtrType hfType, fl_DocSectionLayout * pDSL=NULL);
00527 
00528     void                cmdEditHeader(void);
00529     void                cmdEditFooter(void);
00530 
00531     void                cmdRemoveHdrFtr(bool isHeader);
00532     bool                isFooterOnPage(void);
00533     bool                isHeaderOnPage(void);
00534 
00535     void                SetupSavePieceTableState(void);
00536     void                RestoreSavedPieceTableState(void);
00537     void                removeThisHdrFtr(HdrFtrType hfType, bool bSkipPTSaves = false);
00538     void                createThisHdrFtr(HdrFtrType hfType, bool bSkipPTSaves = false);
00539     void                populateThisHdrFtr(HdrFtrType hfType, bool bSkipPTSaves = false);
00540     void                _populateThisHdrFtr(fl_HdrFtrSectionLayout * pHdrFtrSrc, fl_HdrFtrSectionLayout * pHdrFtrDest);
00541 
00542 //
00543 // ----------------------
00544 // Stuff for edittable Footnote/Endnotes
00545 //
00546     bool                insertFootnote(bool bFootnote);
00547     bool                insertFootnoteSection(bool bFootnote,const gchar * enpid);
00548     bool                isInFootnote(PT_DocPosition pos);
00549     bool                isInFootnote(void);
00550     bool                isInEndnote(PT_DocPosition pos);
00551     bool                isInEndnote(void);
00552     bool                isInAnnotation(PT_DocPosition pos);
00553     bool                isInAnnotation(void);
00554     fl_FootnoteLayout * getClosestFootnote(PT_DocPosition pos);
00555     fl_EndnoteLayout *  getClosestEndnote(PT_DocPosition pos);
00556     fl_AnnotationLayout *  getClosestAnnotation(PT_DocPosition pos);
00557     UT_sint32           getEmbedDepth(PT_DocPosition pos);
00558     //
00559     // ----------------------------------
00560     // Stuff for Annotaions
00561     //  
00562     bool                insertAnnotation(UT_sint32 iAnnotation,
00563                                          UT_UTF8String * sDescr,
00564                                          UT_UTF8String * sAuthor,
00565                                          UT_UTF8String * sTitle,
00566                                          bool bReplace);
00567     bool                getAnnotationText(UT_uint32 iAnnotaion, UT_UTF8String & sText);
00568     bool                setAnnotationText(UT_uint32 iAnnotaion, UT_UTF8String & sText);
00569     bool                setAnnotationText(UT_uint32 iAnnotaion, UT_UTF8String & sText,UT_UTF8String & sAuthor, UT_UTF8String & sTitle);
00570     bool                getAnnotationRichText(UT_uint32 iAnnotation, UT_UTF8String & sRTF);
00571     bool                setAnnotationRichText(UT_uint32 iAnnotaion, UT_UTF8String &sRTF);
00572     // TODO getters and setters to implement/change/add as judged necessary
00573     bool                getAnnotationTitle(UT_uint32 iAnnotaion, UT_UTF8String & sTitle);
00574     bool                setAnnotationTitle(UT_uint32 iAnnotaion, UT_UTF8String & sTitle);
00575     bool                getAnnotationAuthor(UT_uint32 iAnnotaion, UT_UTF8String & sAuthor);
00576     bool                setAnnotationAuthor(UT_uint32 iAnnotaion, UT_UTF8String & sAuthor);
00577 
00578     bool                isAnnotationPreviewActive(void) { return m_bAnnotationPreviewActive;}
00579     void                setAnnotationPreviewActive(bool b) { m_bAnnotationPreviewActive = b;}
00580     UT_uint32           getActivePreviewAnnotationID() { return m_iAnnPviewID;}
00581     void                setActivePreviewAnnotationID(UT_uint32 iID) { m_iAnnPviewID = iID;}
00582     void                killAnnotationPreview();
00583     bool                cmdEditAnnotationWithDialog(UT_uint32 aID);
00584     fl_AnnotationLayout * getAnnotationLayout(UT_uint32 iAnnotation);
00585 // ----------------------
00586 
00587     bool        gotoTarget(AP_JumpTarget type, UT_UCSChar * data);
00588 
00589     void            changeNumColumns(UT_uint32 iNumColumns);
00590 
00591 // ----------------------
00592 
00593     // find and replace
00594 
00595     void            findSetFindString   (const UT_UCSChar* string);
00596     void            findSetReplaceString(const UT_UCSChar* string);
00597     void            findSetReverseFind  (bool newValue);
00598     void            findSetMatchCase    (bool newValue);
00599     void            findSetWholeWord    (bool newValue);
00600     UT_UCSChar *    findGetFindString   (void);
00601     UT_UCSChar *    findGetReplaceString(void);
00602     bool            findGetReverseFind  ();
00603     bool            findGetMatchCase    ();
00604     bool            findGetWholeWord    ();
00605 
00606     bool            findAgain(void);
00607 
00608     void            findSetStartAt(PT_DocPosition pos);
00609     void            findSetStartAtInsPoint(void);
00610 
00611     bool            findNext(bool& bDoneEntireDocument);
00612     bool            findNext(const UT_UCSChar* pFind, bool& bDoneEntireDocument);
00613     
00614     UT_uint32*      _computeFindPrefix(const UT_UCSChar* pFind);
00615 
00616     bool            _findNext(UT_uint32* pPrefix,
00617                              bool& bDoneEntireDocument);
00618 
00619     bool            findPrev(bool& bDoneEntireDocument);
00620     bool            findPrev(const UT_UCSChar* pFind, bool& bDoneEntireDocument);
00621 
00622     bool            _findPrev(UT_uint32* pPrefix,
00623                               bool& bDoneEntireDocument);
00624 
00625     bool            findReplaceReverse(bool& bDoneEntireDocument);
00626 
00627     bool            _findReplaceReverse(UT_uint32* pPrefix,
00628                                         bool& bDoneEntireDocument,
00629                                         bool bNoUpdate);
00630 
00631     bool            _findReplace(UT_uint32* pPrefix,
00632                                  bool& bDoneEntireDocument,
00633                                  bool bNoUpdate);
00634 
00635 
00636     bool            findReplace(bool& bDoneEntireDocument);
00637 
00638     UT_uint32       findReplaceAll();
00639 
00640 // ----------------------
00641 
00642 #if defined(PT_TEST) || defined(FMT_TEST) || defined(UT_TEST)
00643     void            Test_Dump(void);
00644 #endif
00645 
00646 // ----------------------
00647 
00648     FV_DocCount         countWords(void);
00649 
00650 // -----------------------
00651 
00652     bool                insertPageNum(const gchar ** props, HdrFtrType hfType);
00653     virtual void        setPoint(UT_uint32 pt);
00654     void                ensureInsertionPointOnScreen(void);
00655         void                removeCaret(UT_UTF8String & sDocUUID);
00656         void                addCaret(PT_DocPosition docPos,UT_sint32 iAuthorId);
00657     void                setPointRemote(PT_DocPosition docPos);
00658     void                updateCarets(PT_DocPosition docPos, UT_sint32 iLen);   
00659     void            fixInsertionPointCoords(void);
00660 
00661 // -----------------------
00662     void                killBlink(void);
00663     void                setShowPara(bool);
00664     inline bool     getShowPara(void) const { return m_bShowPara; };
00665 
00666     const fp_PageSize&  getPageSize(void) const;
00667     UT_uint32           calculateZoomPercentForPageWidth();
00668     UT_uint32           calculateZoomPercentForPageHeight();
00669     UT_uint32           calculateZoomPercentForWholePage();
00670     void                setViewMode (ViewMode vm);
00671     inline ViewMode         getViewMode (void) const  {return m_viewMode;}
00672     bool                isPreview(void) const {return VIEW_PREVIEW == m_viewMode;}
00673     void                setPreviewMode(PreViewMode pre) {m_previewMode = pre;}
00674     PreViewMode         getPreviewMode(void) { return m_previewMode;}
00675 
00676     UT_uint32           getTabToggleAreaWidth() const;
00677     UT_sint32           getNormalModeXOffset() const;
00678     
00679     void                setScreenUpdateOnGeneralUpdate( bool bDoit)
00680         {m_bDontUpdateScreenOnGeneralUpdate = !bDoit;}
00681     bool                shouldScreenUpdateOnGeneralUpdate(void) const
00682         { return !m_bDontUpdateScreenOnGeneralUpdate;}
00683 
00684     inline PD_Document * getDocument (void) const {return m_pDoc;}
00685 
00686     /* Revision related functions */
00687     void                toggleMarkRevisions();
00688     void                cmdAcceptRejectRevision(bool bReject, UT_sint32 x, UT_sint32 y);
00689     // NB: 'mark revisions' state is document-wide
00690     bool                isMarkRevisions() const;
00691     // NB: 'show revisions' state is view-specific
00692     bool                isShowRevisions() const {return m_bShowRevisions;}
00693     void                toggleShowRevisions();
00694     void                setShowRevisions(bool bShow);
00695     
00696     void                cmdSetRevisionLevel(UT_uint32 i);
00697     UT_uint32           getRevisionLevel()const;
00698     void                setRevisionLevel(UT_uint32 i);
00699 
00700     bool                cmdFindRevision(bool bNext, UT_sint32 xPos, UT_sint32 yPos);
00701     bool                doesSelectionContainRevision() const;
00702 
00703     void                updateRevisionMode();
00704   protected:
00705     void                _fixInsertionPointAfterRevision();
00706     bool                _makePointLegal(void);
00707   public:
00708   
00709     /* Table related functions */
00710     bool                isPointLegal(PT_DocPosition pos);
00711