Convert Calc page header/footer content to Widget UI

Change-Id: I26465f69a7fa50fa58643c00225376a82ba8a7fc
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 2b012b8..01b23c8 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -214,6 +214,14 @@
                        generic-name="Cursor Reference Edit" parent="foruilo-RefEdit"
                        icon-name="widget-gtk-textentry"/>

    <glade-widget-class title="Text View" name="sclo-ScEditWindow"
                        generic-name="Text View" parent="GtkTextView"
                        icon-name="widget-gtk-textentry"/>

    <glade-widget-class title="Combo Image Button" name="sclo-ScExtIButton"
                        generic-name="Combo Image Button" parent="GtkButton"
                        icon-name="widget-gtk-button"/>

    <glade-widget-class title="Open Document ListBox" name="dbulo-OpenDocumentListBox"
                        generic-name="Open Document ListBox" parent="GtkComboBox"
                        icon-name="widget-gtk-combobox"/>
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 48a8da0..b9ecfbb 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -68,11 +68,12 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
	sc/uiconfig/scalc/ui/externaldata \
	sc/uiconfig/scalc/ui/formatcellsdialog \
	sc/uiconfig/scalc/ui/goalseekdlg \
	sc/uiconfig/scalc/ui/headerfootercontent \
	sc/uiconfig/scalc/ui/insertname \
	sc/uiconfig/scalc/ui/insertsheet \
	sc/uiconfig/scalc/ui/managenamesdialog \
	sc/uiconfig/scalc/ui/printeroptions \
	sc/uiconfig/scalc/ui/protectsheetdlg \
        sc/uiconfig/scalc/ui/protectsheetdlg \
	sc/uiconfig/scalc/ui/sheetprintpage \
	sc/uiconfig/scalc/ui/selectrange \
	sc/uiconfig/scalc/ui/selectsource \
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 24727b7..ae9629f 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -509,13 +509,13 @@
#define STR_CHANGED_MOVE_REJECTION_WARNING      402
#define STR_CHANGED_DELETE_REJECTION_WARNING    403

#define STR_HF_NONE_IN_BRACKETS     404
#define STR_HF_OF                   405
#define STR_HF_OF_QUESTION          406
#define STR_HF_CREATED_BY           407
#define STR_HF_CONFIDENTIAL         408
#define STR_HF_CUSTOMIZED           409
#define STR_HF_CUSTOM_FOOTER        410
// #define STR_HF_NONE_IN_BRACKETS     404
// #define STR_HF_OF                   405
// #define STR_HF_OF_QUESTION          406
// #define STR_HF_CREATED_BY           407
// #define STR_HF_CONFIDENTIAL         408
// #define STR_HF_CUSTOMIZED           409
//#define STR_HF_CUSTOM_FOOTER        410

#define STR_ERR_DATAPILOT_INPUT     411

diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index ef6e849..8300e45 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -142,12 +142,6 @@
#define HID_SCPAGE_OPREDLINE                                    "SC_HID_SCPAGE_OPREDLINE"
#define HID_SC_REDLIN_CTR                                       "SC_HID_SC_REDLIN_CTR"

//Kopf/FusszeilenDlg: Contextmenue fuer Dateiname
#define HID_FCOMMAND_TITEL                                      "SC_HID_FCOMMAND_TITEL"
#define HID_FCOMMAND_FILENAME                                   "SC_HID_FCOMMAND_FILENAME"
#define HID_FCOMMAND_PATH                                       "SC_HID_FCOMMAND_PATH"


// Hilfe IDs fuer Objekt- und Werkzeugleisten (max.10) -----------------------

#define HID_SC_TOOLBOX_TOOLS                                    "SC_HID_SC_TOOLBOX_TOOLS"
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 1832839..efa6f55 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -979,7 +979,7 @@
#define RID_SCPAGE_AREAS        (SC_DIALOGS_START + 44)
#define RID_SCDLG_STYLES_PAR    (SC_DIALOGS_START + 46)
#define RID_SCDLG_STYLES_PAGE   (SC_DIALOGS_START + 48)
#define RID_HFBASE              (SC_DIALOGS_START + 49)

#define RID_SCDLG_HFEDIT        (SC_DIALOGS_START + 50)
#define RID_SCDLG_HFEDIT_ALL    (SC_DIALOGS_START + 51)
#define RID_SCDLG_HFED_HEADER   (SC_DIALOGS_START + 52)
diff --git a/sc/source/ui/inc/hfedtdlg.hxx b/sc/source/ui/inc/hfedtdlg.hxx
index 9674118..56a50a9 100644
--- a/sc/source/ui/inc/hfedtdlg.hxx
+++ b/sc/source/ui/inc/hfedtdlg.hxx
@@ -37,7 +37,7 @@ public:
                         Window*            pParent,
                         const SfxItemSet&  rCoreSet,
                         const String&      rPageStyle,
                         sal_uInt16             nResId = RID_SCDLG_HFEDIT );
                         sal_uInt16         nResId = RID_SCDLG_HFEDIT );

            ~ScHFEditDlg();

diff --git a/sc/source/ui/inc/popmenu.hxx b/sc/source/ui/inc/popmenu.hxx
index e3c10b3..70bfeed 100644
--- a/sc/source/ui/inc/popmenu.hxx
+++ b/sc/source/ui/inc/popmenu.hxx
@@ -32,7 +32,9 @@ protected:
    virtual void Select();
public:
    ScPopupMenu() : nSel(0),bHit(false) {}

    ScPopupMenu(const ResId& rRes) : PopupMenu(rRes),nSel(0),bHit(false) {}

    sal_uInt16  GetSelected() const { return nSel; }
    sal_Bool    WasHit() const      { return bHit; }
};
diff --git a/sc/source/ui/inc/scuitphfedit.hxx b/sc/source/ui/inc/scuitphfedit.hxx
index b95a3a0..0c3a0d8 100644
--- a/sc/source/ui/inc/scuitphfedit.hxx
+++ b/sc/source/ui/inc/scuitphfedit.hxx
@@ -21,6 +21,7 @@
#define SCUI_TPHFEDIT_HXX

#include "tphfedit.hxx"
//#include <boost/graph/graph_concepts.hpp>

//===================================================================
enum ScHFEntryId
@@ -47,41 +48,46 @@ class ScHFEditPage : public SfxTabPage
{
public:
    virtual sal_Bool    FillItemSet ( SfxItemSet& rCoreSet );
    virtual void    Reset       ( const SfxItemSet& rCoreSet );
    virtual void        Reset       ( const SfxItemSet& rCoreSet );

    void            SetNumType(SvxNumType eNumType);
    void            ClearTextAreas();

protected:
                ScHFEditPage( Window*           pParent,
                              sal_uInt16            nResId,
                              const SfxItemSet& rCoreSet,
                              sal_uInt16            nWhich, bool bHeader );
                              sal_uInt16        nWhich,
                              bool              bHeader );
    virtual     ~ScHFEditPage();

private:
    FixedText       aFtLeft;
    ScEditWindow    aWndLeft;
    FixedText       aFtCenter;
    ScEditWindow    aWndCenter;
    FixedText       aFtRight;
    ScEditWindow    aWndRight;
    FixedText       maFtDefinedHF;
        ListBox                 maLbDefined;
    FixedText       maFtCustomHF;
    ImageButton     aBtnText;
    ScExtIButton    aBtnFile;
    ImageButton     aBtnTable;
    ImageButton     aBtnPage;
    ImageButton     aBtnLastPage;
    ImageButton     aBtnDate;
    ImageButton     aBtnTime;
    FixedLine       aFlInfo;
    FixedInfo       aFtInfo;
    ScPopupMenu     aPopUpFile;
    //FixedText       aFtLeft;
    ScEditWindow*    m_pWndLeft;
    //FixedText       aFtCenter;
    ScEditWindow*    m_pWndCenter;
    //FixedText       aFtRight;
    ScEditWindow*    m_pWndRight;
    FixedText*       m_pFtDefinedHF;
    ListBox*         m_pLbDefined;
    FixedText*       m_pFtCustomHF;
    PushButton*      m_pBtnText;
    ScExtIButton*    m_pBtnFile;
    PushButton*      m_pBtnTable;
    PushButton*      m_pBtnPage;
    PushButton*      m_pBtnLastPage;
    PushButton*      m_pBtnDate;
    PushButton*      m_pBtnTime;

    sal_uInt16          nWhich;
    String          aCmdArr[6];
    FixedText*       m_pFtConfidential;
    FixedText*       m_pFtPage;
    FixedText*       m_pFtOfQuestion;
    FixedText*       m_pFtOf;
    FixedText*       m_pFtNone;
    FixedText*       m_pFtCreatedBy;
    FixedText*       m_pFtCustomized;

    sal_uInt16       nWhich;
    OUString         aCmdArr[6];

private:
#ifdef _TPHFEDIT_CXX
@@ -95,7 +101,7 @@ private:
    bool IsDateEntry(EditTextObject* pTextObj);
    bool IsExtFileNameEntry(EditTextObject* pTextObj);
    DECL_LINK( ListHdl_Impl, ListBox* );
    DECL_LINK( ClickHdl, ImageButton* );
    DECL_LINK( ClickHdl,  PushButton* );
    DECL_LINK( MenuHdl, ScExtIButton* );
#endif
};
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
index f3d5e33..5a0c899 100644
--- a/sc/source/ui/inc/tphfedit.hxx
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -56,6 +56,7 @@ class SC_DLLPUBLIC ScEditWindow : public Control
{
public:
            ScEditWindow( Window* pParent, const ResId& rResId, ScEditWindowLocation eLoc );
            ScEditWindow( Window* pParent,  WinBits nBits , ScEditWindowLocation eLoc );
            ~ScEditWindow();

    using Control::SetFont;
@@ -72,6 +73,8 @@ public:
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();

    inline ScHeaderEditEngine*  GetEditEngine() const {return pEdEngine;}

    void SetLocation(ScEditWindowLocation eLoc) { eLocation = eLoc; }
protected:
    virtual void    Paint( const Rectangle& rRect );
    virtual void    MouseMove( const MouseEvent& rMEvt );
@@ -81,6 +84,7 @@ protected:
    virtual void    Command( const CommandEvent& rCEvt );
    virtual void    GetFocus();
    virtual void    LoseFocus();
    virtual void    Resize();

private:
    ScHeaderEditEngine* pEdEngine;
@@ -116,6 +120,7 @@ protected:
public:

    ScExtIButton(Window* pParent, const ResId& rResId );
    ScExtIButton(Window* pParent, WinBits nBits );

    void            SetPopupMenu(PopupMenu* pPopUp);

diff --git a/sc/source/ui/pagedlg/hfedtdlg.cxx b/sc/source/ui/pagedlg/hfedtdlg.cxx
index 61096a6..a74e267 100644
--- a/sc/source/ui/pagedlg/hfedtdlg.cxx
+++ b/sc/source/ui/pagedlg/hfedtdlg.cxx
@@ -54,7 +54,7 @@ ScHFEditDlg::ScHFEditDlg( SfxViewFrame*     pFrameP,
                          Window*           pParent,
                          const SfxItemSet& rCoreSet,
                          const String&     rPageStyle,
                          sal_uInt16            nResIdP )
                          sal_uInt16        nResIdP )
    :   SfxTabDialog( pFrameP, pParent, ScResId( nResIdP ), &rCoreSet )
{
    eNumType = ((const SvxPageItem&)rCoreSet.Get(ATTR_PAGE)).GetNumType();
diff --git a/sc/source/ui/pagedlg/hfedtdlg.hrc b/sc/source/ui/pagedlg/hfedtdlg.hrc
index 0193049..ff78535 100644
--- a/sc/source/ui/pagedlg/hfedtdlg.hrc
+++ b/sc/source/ui/pagedlg/hfedtdlg.hrc
@@ -19,25 +19,9 @@

#include "sc.hrc"

#define FT_LEFT 1
#define FT_CENTER 2
#define FT_RIGHT 3
#define FT_INFO 4
#define WND_LEFT 1
#define WND_CENTER 2
#define WND_RIGHT 3
#define BTN_TEXT 1
#define BTN_PAGE 2
#define BTN_PAGES 3
#define BTN_DATE 4
#define BTN_TIME 5
#define BTN_FILE 6
#define BTN_TABLE 7

#define RID_POPUP_FCOMMAND      10
#define FILE_COMMAND_TITEL      11
#define FILE_COMMAND_FILENAME   12
#define FILE_COMMAND_PATH       13

#define FL_INFO                 14

diff --git a/sc/source/ui/pagedlg/hfedtdlg.src b/sc/source/ui/pagedlg/hfedtdlg.src
index ef84d42..489a138 100644
--- a/sc/source/ui/pagedlg/hfedtdlg.src
+++ b/sc/source/ui/pagedlg/hfedtdlg.src
@@ -429,190 +429,8 @@ TabDialog RID_SCDLG_HFEDIT_LEFTFOOTER
    };
};

 //------------------------------------------------------------------------
 //  ScTpHFEdit
 //------------------------------------------------------------------------
TabPage RID_HFBASE
{
    Hide = TRUE ;
    HelpId = HID_SCPAGE_HFEDIT ;
    Pos = MAP_APPFONT ( 0 , 0 ) ;
    Size = MAP_APPFONT ( TP_WIDTH , TP_HEIGHT ) ;
    FixedText FT_LEFT
    {
        Pos = MAP_APPFONT ( 6 , 6 ) ;
        Size = MAP_APPFONT ( 75 , 10 ) ;
        Text [ en-US ] = "~Left area" ;
    };
    FixedText FT_CENTER
    {
        Pos = MAP_APPFONT ( 90 , 6 ) ;
        Size = MAP_APPFONT ( 75 , 10 ) ;
        Text [ en-US ] = "~Center area" ;
    };
    FixedText FT_RIGHT
    {
        Pos = MAP_APPFONT ( 174 , 6 ) ;
        Size = MAP_APPFONT ( 75 , 10 ) ;
        Text [ en-US ] = "R~ight area" ;
    };
    FixedText FT_HF_DEFINED
    {
        Pos = MAP_APPFONT ( 12 , 102 ) ;
        Size = MAP_APPFONT ( 76 , 10 ) ;
        Text [ en-US ] = "Hea~der" ;
    };

    FixedText FT_HF_CUSTOM
    {
        Pos = MAP_APPFONT ( 12 , 124 ) ;
        Size = MAP_APPFONT ( 76 , 10 ) ;
        Text [ en-US ] = "Custom header" ;
    };

    ImageButton BTN_TEXT
    {
        HelpId = HID_SC_HF_TEXT ;
        Pos = MAP_APPFONT ( 90 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Text Attributes" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "text.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    ImageButton BTN_FILE
    {
        HelpId = HID_SC_HF_FILE ;
        Pos = MAP_APPFONT ( 113 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Title" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "file.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    Menu RID_POPUP_FCOMMAND
    {
        ItemList =
        {
            MenuItem
            {
                Identifier = FILE_COMMAND_TITEL ;
                HelpID = HID_FCOMMAND_TITEL ;
                Text [ en-US ] = "Title";
            };
            MenuItem
            {
                Identifier = FILE_COMMAND_FILENAME;
                HelpID = HID_FCOMMAND_FILENAME;
                RadioCheck = TRUE ;
                Text [ en-US ] = "File Name";
            };
            MenuItem
            {
                Identifier = FILE_COMMAND_PATH;
                HelpID = HID_FCOMMAND_PATH;
                RadioCheck = TRUE ;
                Text [ en-US ] = "Path/File Name";
            };
        };
    };

    ImageButton BTN_TABLE
    {
        HelpId = HID_SC_HF_TABLE ;
        Pos = MAP_APPFONT ( 130 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Sheet Name" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "table.png" ; };
            MaskColor = STD_MASKCOLOR;
        };
    };

    ImageButton BTN_PAGE
    {
        HelpId = HID_SC_HF_PAGE ;
        Pos = MAP_APPFONT ( 150 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Page" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "page.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    ImageButton BTN_PAGES
    {
        HelpId = HID_SC_HF_PAGES ;
        Pos = MAP_APPFONT ( 167 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Pages" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "pages.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    ImageButton BTN_DATE
    {
        HelpId = HID_SC_HF_DATE ;
        Pos = MAP_APPFONT ( 187 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Date" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "date.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    ImageButton BTN_TIME
    {
        HelpId = HID_SC_HF_TIME ;
        Pos = MAP_APPFONT ( 204 , 122 ) ;
        Size = MAP_APPFONT ( 15 , 15 ) ;
        TabStop = TRUE ;
        QuickHelpText [ en-US ] = "Time" ;
        ButtonImage = Image
        {
            ImageBitmap = Bitmap { File = "time.png" ; };
            MaskColor = STD_MASKCOLOR ;
        };
    };

    FixedText FT_INFO
    {
        Pos = MAP_APPFONT ( 12 , 155 ) ;
        Size = MAP_APPFONT ( 240 , 24 ) ;
        WordBreak = TRUE ;
        Text [ en-US ] = "Use the buttons to change the font or insert field commands such as date, time, etc." ;
    };
    FixedLine FL_INFO
    {
        Pos = MAP_APPFONT ( 6 , 144 ) ;
        Size = MAP_APPFONT ( 248 , 8 ) ;
        Text [ en-US ] = "Note" ;
    };
};

 // Kombinationen: Header/Footer links/rechts
 // die Eingabefenster jeweils mit eigener ID, sonst aus RID_HFBASE kopiert
TabPage RID_SCPAGE_HFED_HL < RID_HFBASE
TabPage RID_SCPAGE_HFED_HL
{
    Hide = TRUE ;
    HelpId = HID_SCPAGE_HFED_HL ;
@@ -651,7 +469,7 @@ TabPage RID_SCPAGE_HFED_HL < RID_HFBASE
    };
};

TabPage RID_SCPAGE_HFED_HR < RID_HFBASE
TabPage RID_SCPAGE_HFED_HR
{
    Hide = TRUE ;
    HelpId = HID_SCPAGE_HFED_HR ;
@@ -690,7 +508,7 @@ TabPage RID_SCPAGE_HFED_HR < RID_HFBASE
    };
};

TabPage RID_SCPAGE_HFED_FL < RID_HFBASE
TabPage RID_SCPAGE_HFED_FL
{
    Hide = TRUE ;
    HelpId = HID_SCPAGE_HFED_FL ;
@@ -729,7 +547,7 @@ TabPage RID_SCPAGE_HFED_FL < RID_HFBASE
    };
};

TabPage RID_SCPAGE_HFED_FR < RID_HFBASE
TabPage RID_SCPAGE_HFED_FR
{
    Hide = TRUE ;
    HelpId = HID_SCPAGE_HFED_FR ;
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index 5a084d3..342774a 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -63,80 +63,84 @@ static ScEditWindow* pActiveEdWnd = NULL;
//

ScHFEditPage::ScHFEditPage( Window*             pParent,
                            sal_uInt16              nResId,
                            const SfxItemSet&   rCoreAttrs,
                            sal_uInt16              nWhichId,
                            bool bHeader  )

    :   SfxTabPage      ( pParent, ScResId( nResId ), rCoreAttrs ),

        aFtLeft         ( this, ScResId( FT_LEFT ) ),
        aWndLeft        ( this, ScResId( WND_LEFT ), Left ),
        aFtCenter       ( this, ScResId( FT_CENTER ) ),
        aWndCenter      ( this, ScResId( WND_CENTER ), Center ),
        aFtRight        ( this, ScResId( FT_RIGHT ) ),
        aWndRight       ( this, ScResId( WND_RIGHT ), Right ),
        maFtDefinedHF       ( this, ScResId( FT_HF_DEFINED ) ),
        maLbDefined     ( this, ScResId( LB_DEFINED ) ),
        maFtCustomHF        ( this, ScResId( FT_HF_CUSTOM ) ),
        aBtnText        ( this, ScResId( BTN_TEXT ) ),
        aBtnFile        ( this, ScResId( BTN_FILE ) ),
        aBtnTable       ( this, ScResId( BTN_TABLE ) ),
        aBtnPage        ( this, ScResId( BTN_PAGE ) ),
        aBtnLastPage    ( this, ScResId( BTN_PAGES ) ),
        aBtnDate        ( this, ScResId( BTN_DATE ) ),
        aBtnTime        ( this, ScResId( BTN_TIME ) ),
        aFlInfo         ( this, ScResId( FL_INFO ) ),
        aFtInfo         ( this, ScResId( FT_INFO ) ),
        aPopUpFile      ( ScResId( RID_POPUP_FCOMMAND) ),
        nWhich          ( nWhichId )
                            sal_uInt16          nWhichId,
                            bool                bHeader  )
    : SfxTabPage( pParent, "HeaderFooterContent", "modules/scalc/ui/headerfootercontent.ui", rCoreAttrs )
    , nWhich( nWhichId )
{
    get(m_pWndLeft,"textviewWND_LEFT");
    m_pWndLeft->SetLocation(Left);
    get(m_pWndCenter,"textviewWND_CENTER");
    m_pWndCenter->SetLocation(Center);
    get(m_pWndRight,"textviewWND_RIGHT");
    m_pWndRight->SetLocation(Right);

    get(m_pLbDefined,"comboLB_DEFINED");

    get(m_pBtnText,"buttonBTN_TEXT");
    get(m_pBtnTable,"buttonBTN_TABLE");
    get(m_pBtnPage,"buttonBTN_PAGE");
    get(m_pBtnLastPage,"buttonBTN_PAGES");
    get(m_pBtnDate,"buttonBTN_DATE");
    get(m_pBtnTime,"buttonBTN_TIME");

    get(m_pBtnFile,"buttonBTN_FILE");

    get(m_pFtConfidential,"labelSTR_HF_CONFIDENTIAL");
    get(m_pFtPage,"labelSTR_PAGE");
    get(m_pFtOfQuestion,"labelSTR_HF_OF_QUESTION");
    get(m_pFtOf,"labelSTR_HF_OF");
    get(m_pFtNone,"labelSTR_HF_NONE_IN_BRACKETS");
    get(m_pFtCreatedBy,"labelSTR_HF_CREATED_BY");
    get(m_pFtCustomized,"labelSTR_HF_CUSTOMIZED");


    //! use default style from current document?
    //! if font color is used, header/footer background color must be set

    ScPatternAttr   aPatAttr( rCoreAttrs.GetPool() );

    m_pBtnFile->SetPopupMenu(get_menu("popup"));

    aBtnFile.SetPopupMenu(&aPopUpFile);
    m_pLbDefined->SetSelectHdl( LINK( this, ScHFEditPage, ListHdl_Impl ) );
    m_pBtnFile->SetMenuHdl( LINK( this, ScHFEditPage, MenuHdl ) );
    m_pBtnText->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnPage->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnLastPage->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnDate->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnTime->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnFile->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    m_pBtnTable->SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );

    maLbDefined.SetSelectHdl( LINK( this, ScHFEditPage, ListHdl_Impl ) );
    aBtnFile.SetMenuHdl( LINK( this, ScHFEditPage, MenuHdl ) );
    aBtnText    .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnPage    .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnLastPage.SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnDate    .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnTime    .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnFile    .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    aBtnTable   .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
    get(m_pFtDefinedHF,!bHeader ? "labelFT_F_DEFINED" : "labelFT_H_DEFINED");
    get(m_pFtCustomHF, !bHeader ? "labelFT_F_CUSTOM" : "labelFT_H_CUSTOM");

    if(!bHeader)
    {
        maFtDefinedHF.SetText(ScGlobal::GetRscString( STR_FOOTER ));
        maFtCustomHF.SetText(ScGlobal::GetRscString( STR_HF_CUSTOM_FOOTER ));
    }
    if( Application::GetSettings().GetLayoutRTL() )
    {
        Point pt1 = aWndLeft.GetPosPixel();
        Point pt2 = aWndRight.GetPosPixel();
        aWndLeft.SetPosPixel(pt2);
        aWndRight.SetPosPixel(pt1);
    m_pFtDefinedHF->Show();
    m_pFtCustomHF->Show();

        pt1 = aFtLeft.GetPosPixel();
        pt2 = aFtRight.GetPosPixel();
        aFtLeft.SetPosPixel(pt2);
        aFtRight.SetPosPixel(pt1);
    }
    aWndLeft.   SetFont( aPatAttr );
    aWndCenter. SetFont( aPatAttr );
    aWndRight.  SetFont( aPatAttr );
//     if( Application::GetSettings().GetLayoutRTL() )
//     {
//         Point pt1 = m_pWndLeft->GetPosPixel();
//         Point pt2 = m_pWndRight->GetPosPixel();
//         m_pWndLeft->SetPosPixel(pt2);
//         m_pWndRight->SetPosPixel(pt1);
//
//         pt1 = aFtLeft.GetPosPixel();
//         pt2 = aFtRight.GetPosPixel();
//         aFtLeft.SetPosPixel(pt2);
//         aFtRight.SetPosPixel(pt1);
//    }
    m_pWndLeft->SetFont( aPatAttr );
    m_pWndCenter->SetFont( aPatAttr );
    m_pWndRight->SetFont( aPatAttr );

    FillCmdArr();

    aWndLeft.GrabFocus();
    m_pWndLeft->GrabFocus();

    InitPreDefinedList();

    FreeResource();
}

// -----------------------------------------------------------------------
@@ -147,9 +151,9 @@ ScHFEditPage::~ScHFEditPage()

void ScHFEditPage::SetNumType(SvxNumType eNumType)
{
    aWndLeft.SetNumType(eNumType);
    aWndCenter.SetNumType(eNumType);
    aWndRight.SetNumType(eNumType);
    m_pWndLeft->SetNumType(eNumType);
    m_pWndCenter->SetNumType(eNumType);
    m_pWndRight->SetNumType(eNumType);
}

void ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
@@ -160,11 +164,11 @@ void ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
        const ScPageHFItem& rItem = static_cast<const ScPageHFItem&>(*pItem);

        if( const EditTextObject* pLeft = rItem.GetLeftArea() )
            aWndLeft.SetText( *pLeft );
            m_pWndLeft->SetText( *pLeft );
        if( const EditTextObject* pCenter = rItem.GetCenterArea() )
            aWndCenter.SetText( *pCenter );
            m_pWndCenter->SetText( *pCenter );
        if( const EditTextObject* pRight = rItem.GetRightArea() )
            aWndRight.SetText( *pRight );
            m_pWndRight->SetText( *pRight );

        SetSelectDefinedList();
    }
@@ -173,9 +177,9 @@ void ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
sal_Bool ScHFEditPage::FillItemSet( SfxItemSet& rCoreSet )
{
    ScPageHFItem    aItem( nWhich );
    EditTextObject* pLeft   = aWndLeft  .CreateTextObject();
    EditTextObject* pCenter = aWndCenter.CreateTextObject();
    EditTextObject* pRight  = aWndRight .CreateTextObject();
    EditTextObject* pLeft   = m_pWndLeft->CreateTextObject();
    EditTextObject* pCenter = m_pWndCenter->CreateTextObject();
    EditTextObject* pRight  = m_pWndRight->CreateTextObject();

    aItem.SetLeftArea  ( *pLeft );
    aItem.SetCenterArea( *pCenter );
@@ -201,8 +205,8 @@ sal_Bool ScHFEditPage::FillItemSet( SfxItemSet& rCoreSet )

void ScHFEditPage::FillCmdArr()
{
    String aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) );
    String aCmd;
    OUString aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) );
    OUString aCmd;

    SET_CMD( 0, STR_HFCMD_PAGE )
    SET_CMD( 1, STR_HFCMD_PAGES )
@@ -222,96 +226,64 @@ void ScHFEditPage::InitPreDefinedList()
    Color* pFldColour = NULL;

    // Get the all field values at the outset.
    String aPageFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    String aSheetFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    String aFileFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    String aExtFileFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxExtFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    String aDateFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    OUString aPageFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    OUString aSheetFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    OUString aFileFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    OUString aExtFileFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxExtFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
    OUString aDateFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));

    maLbDefined.Clear();
    m_pLbDefined->Clear();

    maLbDefined.InsertEntry( ScGlobal::GetRscString( STR_HF_NONE_IN_BRACKETS ));
    m_pLbDefined->InsertEntry(m_pFtNone->GetText());

    String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
    aPageEntry += ' ';
    aPageEntry += aPageFieldValue;
    maLbDefined.InsertEntry(aPageEntry);
    OUString aPageEntry(m_pFtPage->GetText() + " " + aPageFieldValue);
    m_pLbDefined->InsertEntry(aPageEntry);

    String aPageOfEntry(aPageEntry);
    aPageOfEntry += ' ';
    aPageOfEntry += ScGlobal::GetRscString( STR_HF_OF_QUESTION );
    maLbDefined.InsertEntry( aPageOfEntry);
    OUString aPageOfEntry(aPageEntry + " " + m_pFtOfQuestion->GetText());
    m_pLbDefined->InsertEntry( aPageOfEntry);

    maLbDefined.InsertEntry(aSheetFieldValue);
    m_pLbDefined->InsertEntry(aSheetFieldValue);

    String aConfidentialEntry(aUserOpt.GetCompany());
    aConfidentialEntry += ' ';
    aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
    aConfidentialEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aConfidentialEntry += aDateFieldValue;
    aConfidentialEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aConfidentialEntry += aPageEntry;
    maLbDefined.InsertEntry( aConfidentialEntry);
    OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText() + ", " + aDateFieldValue + ", " + aPageEntry);
    m_pLbDefined->InsertEntry( aConfidentialEntry);

    String aFileNamePageEntry(aFileFieldValue);
    aFileNamePageEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aFileNamePageEntry += aPageEntry;
    maLbDefined.InsertEntry( aFileNamePageEntry);
    OUString aFileNamePageEntry(aFileFieldValue + ", " + aPageEntry);
    m_pLbDefined->InsertEntry( aFileNamePageEntry);

    maLbDefined.InsertEntry( aExtFileFieldValue);
    m_pLbDefined->InsertEntry( aExtFileFieldValue);

    String aPageSheetNameEntry(aPageEntry);
    aPageSheetNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aPageSheetNameEntry += aSheetFieldValue;
    maLbDefined.InsertEntry( aPageSheetNameEntry);
    OUString aPageSheetNameEntry(aPageEntry + ", " + aSheetFieldValue);
    m_pLbDefined->InsertEntry( aPageSheetNameEntry);

    String aPageFileNameEntry(aPageEntry);
    aPageFileNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aPageFileNameEntry += aFileFieldValue;
    maLbDefined.InsertEntry( aPageFileNameEntry);
    OUString aPageFileNameEntry(aPageEntry + ", " + aFileFieldValue);
    m_pLbDefined->InsertEntry( aPageFileNameEntry);

    String aPagePathNameEntry(aPageEntry);
    aPagePathNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aPagePathNameEntry += aExtFileFieldValue;
    maLbDefined.InsertEntry( aPagePathNameEntry);
    OUString aPagePathNameEntry(aPageEntry + ", " + aExtFileFieldValue);
    m_pLbDefined->InsertEntry( aPagePathNameEntry);

    String aUserNameEntry(aUserOpt.GetFirstName());
    aUserNameEntry += ' ';
    aUserNameEntry += (String)aUserOpt.GetLastName();
    aUserNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aUserNameEntry += aPageEntry;
    aUserNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aUserNameEntry += aDateFieldValue;
    maLbDefined.InsertEntry( aUserNameEntry);
    OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", " + aPageEntry + ", " + aDateFieldValue);
    m_pLbDefined->InsertEntry( aUserNameEntry);

    String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
    aCreatedByEntry += ' ';
    aCreatedByEntry += (String)aUserOpt.GetFirstName();
    aCreatedByEntry += ' ';
    aCreatedByEntry += (String)aUserOpt.GetLastName();
    aCreatedByEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aCreatedByEntry += aDateFieldValue;
    aCreatedByEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
    aCreatedByEntry += aPageEntry;
    maLbDefined.InsertEntry( aCreatedByEntry);
    OUString aCreatedByEntry( m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", ");
    aCreatedByEntry += aDateFieldValue + ", " + aPageEntry;
    m_pLbDefined->InsertEntry( aCreatedByEntry);
}

void ScHFEditPage::InsertToDefinedList()
{
    sal_uInt16 nCount =  maLbDefined.GetEntryCount();
    sal_uInt16 nCount =  m_pLbDefined->GetEntryCount();
    if(nCount == eEntryCount)
    {
        String aCustomizedEntry(ScGlobal::GetRscString( STR_HF_CUSTOMIZED ) );
        maLbDefined.InsertEntry( aCustomizedEntry);
        maLbDefined.SelectEntryPos(eEntryCount);
        m_pLbDefined->InsertEntry( m_pFtCustomized->GetText() );
        m_pLbDefined->SelectEntryPos(eEntryCount);
    }
}

void ScHFEditPage::RemoveFromDefinedList()
{
    sal_uInt16 nCount =  maLbDefined.GetEntryCount();
    sal_uInt16 nCount =  m_pLbDefined->GetEntryCount();
    if(nCount > eEntryCount )
        maLbDefined.RemoveEntry( nCount-1);
        m_pLbDefined->RemoveEntry( nCount-1);
}

// determine if the header/footer exists in our predefined list and set select to it.
@@ -328,18 +300,18 @@ void ScHFEditPage::SetSelectDefinedList()
    ::std::auto_ptr< EditTextObject > pRightObj;
    SAL_WNODEPRECATED_DECLARATIONS_POP

    XubString aLeftEntry;
    XubString aCenterEntry;
    XubString aRightEntry;
    OUString aLeftEntry;
    OUString aCenterEntry;
    OUString aRightEntry;

    pLeftObj.reset(aWndLeft.GetEditEngine()->CreateTextObject());
    pCenterObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
    pRightObj.reset(aWndRight.GetEditEngine()->CreateTextObject());
    pLeftObj.reset(m_pWndLeft->GetEditEngine()->CreateTextObject());
    pCenterObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
    pRightObj.reset(m_pWndRight->GetEditEngine()->CreateTextObject());

    bool bFound = false;

    sal_uInt16 i;
    sal_uInt16 nCount =  maLbDefined.GetEntryCount();
    sal_uInt16 nCount =  m_pLbDefined->GetEntryCount();
    for(i = 0; i < nCount && !bFound; i++)
    {
        switch(static_cast<ScHFEntryId>(i))
@@ -364,7 +336,7 @@ void ScHFEditPage::SetSelectDefinedList()
                aRightEntry = pRightObj->GetText(0);
                if(aLeftEntry == EMPTY_STRING && aRightEntry == EMPTY_STRING)
                {
                    if(IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()))
                    if(IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get()))
                    {
                        eSelectEntry = ePageEntry;
                        bFound = true;
@@ -405,12 +377,10 @@ void ScHFEditPage::SetSelectDefinedList()

            case eConfidentialEntry:
            {
                if(IsDateEntry(pCenterObj.get()) && IsPageEntry(aWndRight.GetEditEngine(), pRightObj.get()))
                if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_pWndRight->GetEditEngine(), pRightObj.get()))
                {
                    String aConfidentialEntry(aUserOpt.GetCompany());
                    aConfidentialEntry += ' ';
                    aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
                    if(aConfidentialEntry == aWndLeft.GetEditEngine()->GetText(0))
                    OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText());
                    if(aConfidentialEntry == m_pWndLeft->GetEditEngine()->GetText(0))
                    {
                        eSelectEntry = eConfidentialEntry;
                        bFound = true;
@@ -453,7 +423,7 @@ void ScHFEditPage::SetSelectDefinedList()
            case ePageExtFileNameEntry:
            {
                aLeftEntry = pLeftObj->GetText(0);
                if(IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()) &&
                if(IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get()) &&
                    IsExtFileNameEntry(pRightObj.get()) && aLeftEntry == EMPTY_STRING)
                {
                    eSelectEntry = ePageExtFileNameEntry;
@@ -464,12 +434,11 @@ void ScHFEditPage::SetSelectDefinedList()

            case eUserNameEntry:
            {
                if(IsDateEntry(pRightObj.get()) && IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()))
                if(IsDateEntry(pRightObj.get()) && IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get()))
                {
                    String aUserNameEntry(aUserOpt.GetFirstName());
                    aUserNameEntry += ' ';
                    aUserNameEntry += (String)aUserOpt.GetLastName();
                    if(aUserNameEntry == aWndLeft.GetEditEngine()->GetText(0))
                    OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());

                    if(aUserNameEntry == m_pWndLeft->GetEditEngine()->GetText(0))
                    {
                        eSelectEntry = eUserNameEntry;
                        bFound = true;
@@ -480,14 +449,11 @@ void ScHFEditPage::SetSelectDefinedList()

            case eCreatedByEntry:
            {
                if(IsDateEntry(pCenterObj.get()) && IsPageEntry(aWndRight.GetEditEngine(), pRightObj.get()))
                if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_pWndRight->GetEditEngine(), pRightObj.get()))
                {
                    String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
                    aCreatedByEntry += ' ';
                    aCreatedByEntry += (String)aUserOpt.GetFirstName();
                    aCreatedByEntry += ' ';
                    aCreatedByEntry += (String)aUserOpt.GetLastName();
                    if(aCreatedByEntry == aWndLeft.GetEditEngine()->GetText(0))
                    OUString aCreatedByEntry(m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());

                    if(aCreatedByEntry == m_pWndLeft->GetEditEngine()->GetText(0))
                    {
                        eSelectEntry = eCreatedByEntry;
                        bFound = true;
@@ -506,7 +472,7 @@ void ScHFEditPage::SetSelectDefinedList()
    if(eSelectEntry == eEntryCount)
        InsertToDefinedList();

    maLbDefined.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eSelectEntry ) );
    m_pLbDefined->SelectEntryPos( sal::static_int_cast<sal_uInt16>( eSelectEntry ) );
}

bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, EditTextObject* pTextObj)
@@ -522,10 +488,9 @@ bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, EditTextObject* pTextObj)
        pEngine->GetPortions(0,aPosList);
        if(aPosList.size() == 2)
        {
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            OUString aPageEntry(m_pFtPage->GetText() + " ");
            ESelection aSel(0,0,0,0);
            aSel.nEndPos = aPageEntry.Len();
            aSel.nEndPos = aPageEntry.getLength();
            if(aPageEntry == pEngine->GetText(aSel))
            {
                aSel.nStartPos = aSel.nEndPos;
@@ -599,18 +564,17 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
        case eNoneEntry:
            ClearTextAreas();
            if(!bTravelling)
                aWndLeft.GrabFocus();
                m_pWndLeft->GrabFocus();
        break;

        case ePageEntry:
        {
            ClearTextAreas();
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            OUString aPageEntry( m_pFtPage->GetText() + " " );
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        }
        break;

@@ -618,46 +582,42 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
        {
            ClearTextAreas();
            ESelection aSel(0,0,0,0);
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.Len();
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            OUString aPageEntry( m_pFtPage->GetText() + " ");
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            ++aSel.nEndPos;
            String aPageOfEntry = OUStringBuffer().append(' ').
                append(ScGlobal::GetRscString( STR_HF_OF )).append(' ').
                makeStringAndClear();
            aWndCenter.GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageOfEntry.Len() );
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
            aWndCenter.SetText(*pTextObj);

            OUString aPageOfEntry(" " + m_pFtOf->GetText() + " ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageOfEntry.getLength() );
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        }
        break;

        case eSheetEntry:
            ClearTextAreas();
            aWndCenter.InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
            m_pWndCenter->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        break;

        case eConfidentialEntry:
        {
            ClearTextAreas();
            String aConfidentialEntry(aUserOpt.GetCompany());
            aConfidentialEntry += ' ';
            aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
            aWndLeft.GetEditEngine()->SetText(aConfidentialEntry);
            aWndCenter.InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndRight.GetEditEngine()->SetText(aPageEntry);
            aWndRight.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText());
            m_pWndLeft->GetEditEngine()->SetText(aConfidentialEntry);
            m_pWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );

            OUString aPageEntry( m_pFtPage->GetText() + " ");
            m_pWndRight->GetEditEngine()->SetText(aPageEntry);
            m_pWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            if(!bTravelling)
                aWndRight.GrabFocus();
                m_pWndRight->GrabFocus();
        }
        break;

@@ -665,48 +625,46 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
        {
            ClearTextAreas();
            ESelection aSel(0,0,0,0);
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ), aSel );
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ), aSel );
            ++aSel.nEndPos;
            String aPageEntry(RTL_CONSTASCII_USTRINGPARAM(", "));
            aPageEntry += ScGlobal::GetRscString( STR_PAGE ) ;
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            OUString aPageEntry(", " + m_pFtPage->GetText() + " ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nStartPos = aSel.nEndPos;
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageEntry.Len() );
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
            aWndCenter.SetText(*pTextObj);
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageEntry.getLength() );
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        }
        break;

        case eExtFileNameEntry:
            ClearTextAreas();
            aWndCenter.InsertField( SvxFieldItem( SvxExtFileField(
            m_pWndCenter->InsertField( SvxFieldItem( SvxExtFileField(
                EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        break;

        case ePageSheetEntry:
        {
            ClearTextAreas();
            ESelection aSel(0,0,0,0);
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.Len();
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            OUString aPageEntry( m_pFtPage->GetText() + " " );
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            ++aSel.nEndPos;
            String aCommaSpace(RTL_CONSTASCII_USTRINGPARAM(", "));
            aWndCenter.GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.Len() );
            aWndCenter.GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
            aWndCenter.SetText(*pTextObj);

            OUString aCommaSpace(", ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.getLength() );
            m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        }
        break;

@@ -714,70 +672,62 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
        {
            ClearTextAreas();
            ESelection aSel(0,0,0,0);
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.Len();
            aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            OUString aPageEntry( m_pFtPage->GetText() + " " );
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            aSel.nEndPos = aPageEntry.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            ++aSel.nEndPos;
            String aCommaSpace(RTL_CONSTASCII_USTRINGPARAM(", "));
            aWndCenter.GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.Len() );
            aWndCenter.GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
            aWndCenter.SetText(*pTextObj);
            OUString aCommaSpace(", ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.getLength() );
            m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
            if(!bTravelling)
                aWndCenter.GrabFocus();
                m_pWndCenter->GrabFocus();
        }
        break;

        case ePageExtFileNameEntry:
        {
            ClearTextAreas();
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            aWndRight.InsertField( SvxFieldItem( SvxExtFileField(
            OUString aPageEntry( m_pFtPage->GetText() + " " );
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            m_pWndRight->InsertField( SvxFieldItem( SvxExtFileField(
                EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
            if(!bTravelling)
                aWndRight.GrabFocus();
                m_pWndRight->GrabFocus();
        }
        break;

        case eUserNameEntry:
        {
            ClearTextAreas();
            String aUserNameEntry(aUserOpt.GetFirstName());
            aUserNameEntry += ' ';
            aUserNameEntry += (String)aUserOpt.GetLastName();
            aWndLeft.GetEditEngine()->SetText(aUserNameEntry);
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndCenter.GetEditEngine()->SetText(aPageEntry);
            aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            aWndRight.InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
            OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
            m_pWndLeft->GetEditEngine()->SetText(aUserNameEntry);
            OUString aPageEntry( m_pFtPage->GetText() + " ");
            //aPageEntry += " ";
            m_pWndCenter->GetEditEngine()->SetText(aPageEntry);
            m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            m_pWndRight->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
            if(!bTravelling)
                aWndRight.GrabFocus();
                m_pWndRight->GrabFocus();
        }
        break;

        case eCreatedByEntry:
        {
            ClearTextAreas();
            String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
            aCreatedByEntry += ' ';
            aCreatedByEntry += (String)aUserOpt.GetFirstName();
            aCreatedByEntry += ' ';
            aCreatedByEntry += (String)aUserOpt.GetLastName();
            aWndLeft.GetEditEngine()->SetText(aCreatedByEntry);
            aWndCenter.InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
            String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
            aPageEntry += ' ';
            aWndRight.GetEditEngine()->SetText(aPageEntry);
            aWndRight.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            OUString aCreatedByEntry( m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
            m_pWndLeft->GetEditEngine()->SetText(aCreatedByEntry);
            m_pWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
            OUString aPageEntry( m_pFtPage->GetText() );
            aPageEntry += " ";
            m_pWndRight->GetEditEngine()->SetText(aPageEntry);
            m_pWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
            if(!bTravelling)
                aWndRight.GrabFocus();
                m_pWndRight->GrabFocus();
        }
        break;

@@ -788,12 +738,12 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)

void ScHFEditPage::ClearTextAreas()
{
    aWndLeft.GetEditEngine()->SetText(EMPTY_STRING);
    aWndLeft.Invalidate();
    aWndCenter.GetEditEngine()->SetText(EMPTY_STRING);
    aWndCenter.Invalidate();
    aWndRight.GetEditEngine()->SetText(EMPTY_STRING);
    aWndRight.Invalidate();
    m_pWndLeft->GetEditEngine()->SetText(EMPTY_STRING);
    m_pWndLeft->Invalidate();
    m_pWndCenter->GetEditEngine()->SetText(EMPTY_STRING);
    m_pWndCenter->Invalidate();
    m_pWndRight->GetEditEngine()->SetText(EMPTY_STRING);
    m_pWndRight->Invalidate();
}

//-----------------------------------------------------------------------
@@ -802,10 +752,10 @@ void ScHFEditPage::ClearTextAreas()

IMPL_LINK( ScHFEditPage, ListHdl_Impl, ListBox*, pList )
{
    if ( pList && pList == &maLbDefined )
    if ( pList && pList == m_pLbDefined )
    {
        ScHFEntryId eSel = static_cast<ScHFEntryId>(maLbDefined.GetSelectEntryPos());
        if(!maLbDefined.IsTravelSelect())
        ScHFEntryId eSel = static_cast<ScHFEntryId>(m_pLbDefined->GetSelectEntryPos());
        if(!m_pLbDefined->IsTravelSelect())
        {
            ProcessDefinedListSel(eSel);

@@ -821,31 +771,31 @@ IMPL_LINK( ScHFEditPage, ListHdl_Impl, ListBox*, pList )
    return 0;
}

IMPL_LINK( ScHFEditPage, ClickHdl, ImageButton*, pBtn )
IMPL_LINK( ScHFEditPage, ClickHdl, PushButton*, pBtn )
{
    pActiveEdWnd = ::GetScEditWindow();
    if ( !pActiveEdWnd )
        return 0;

    if ( pBtn == &aBtnText )
    if ( pBtn == m_pBtnText )
    {
        pActiveEdWnd->SetCharAttriutes();
    }
    else
    {
        if ( pBtn == &aBtnPage )
        if ( pBtn == m_pBtnPage )
            pActiveEdWnd->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
        else if ( pBtn == &aBtnLastPage )
        else if ( pBtn == m_pBtnLastPage )
            pActiveEdWnd->InsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD) );
        else if ( pBtn == &aBtnDate )
        else if ( pBtn == m_pBtnDate )
            pActiveEdWnd->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
        else if ( pBtn == &aBtnTime )
        else if ( pBtn == m_pBtnTime )
            pActiveEdWnd->InsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD) );
        else if ( pBtn == &aBtnFile )
        else if ( pBtn == m_pBtnFile )
        {
            pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) );
        }
        else if ( pBtn == &aBtnTable )
        else if ( pBtn == m_pBtnTable )
            pActiveEdWnd->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
    }
    InsertToDefinedList();
@@ -862,19 +812,22 @@ IMPL_LINK( ScHFEditPage, MenuHdl, ScExtIButton*, pBtn )

    if(pBtn!=NULL)
    {
        switch(pBtn->GetSelected())
        OSL_ENSURE( true, pBtn->GetSelected());
        OString sSelectedId = pBtn->GetSelectedIdent();

        if (sSelectedId == "title")
        {
            case FILE_COMMAND_TITEL:
                pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) );
                break;
            case FILE_COMMAND_FILENAME:
                pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
                        EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ), EE_FEATURE_FIELD ) );
                break;
            case FILE_COMMAND_PATH:
                pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
                        EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
                break;
            pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) );
        }
        else if (sSelectedId == "filename")
        {
            pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
                OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ), EE_FEATURE_FIELD ) );
        }
        else if (sSelectedId == "pathname")
        {
            pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
                OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
        }
    }
    return 0;
@@ -885,8 +838,10 @@ IMPL_LINK( ScHFEditPage, MenuHdl, ScExtIButton*, pBtn )
//========================================================================

ScRightHeaderEditPage::ScRightHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
    : ScHFEditPage( pParent, RID_SCPAGE_HFED_HR, rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT ), true )
    : ScHFEditPage( pParent,
                    rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT ),
                    true )
    {}

// -----------------------------------------------------------------------
@@ -899,8 +854,10 @@ SfxTabPage* ScRightHeaderEditPage::Create( Window* pParent, const SfxItemSet& rC
//========================================================================

ScLeftHeaderEditPage::ScLeftHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
    : ScHFEditPage( pParent, RID_SCPAGE_HFED_HL, rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT ), true )
    : ScHFEditPage( pParent,
                    rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT ),
                    true )
    {}

// -----------------------------------------------------------------------
@@ -913,8 +870,10 @@ SfxTabPage* ScLeftHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCo
//========================================================================

ScRightFooterEditPage::ScRightFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
    : ScHFEditPage( pParent, RID_SCPAGE_HFED_FR, rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT ), false )
    : ScHFEditPage( pParent,
                    rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT ),
                    false )
    {}

// -----------------------------------------------------------------------
@@ -927,8 +886,10 @@ SfxTabPage* ScRightFooterEditPage::Create( Window* pParent, const SfxItemSet& rC
//========================================================================

ScLeftFooterEditPage::ScLeftFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
    : ScHFEditPage( pParent, RID_SCPAGE_HFED_FL, rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT ), false )
    : ScHFEditPage( pParent,
                    rCoreSet,
                    rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT ),
                    false )
    {}

// -----------------------------------------------------------------------
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index a6fc37d..717c493 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -111,6 +111,54 @@ ScEditWindow::ScEditWindow( Window* pParent, const ResId& rResId, ScEditWindowLo
    pEdEngine->InsertView( pEdView );
}

ScEditWindow::ScEditWindow( Window* pParent, WinBits nBits, ScEditWindowLocation eLoc )
    :   Control( pParent, nBits ),
    eLocation(eLoc),
    pAcc(NULL)
{
    EnableRTL(false);

    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    Color aBgColor = rStyleSettings.GetWindowColor();

    SetMapMode( MAP_TWIP );
    SetPointer( POINTER_TEXT );
    SetBackground( aBgColor );

    Size aSize( GetOutputSize() );
    aSize.Height() *= 4;

    pEdEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), sal_True );
    pEdEngine->SetPaperSize( aSize );
    pEdEngine->SetRefDevice( this );

    ScHeaderFieldData aData;
    lcl_GetFieldData( aData );

        //  Feldbefehle:
    pEdEngine->SetData( aData );
    pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EE_CNTRL_MARKFIELDS );
    mbRTL = ScGlobal::IsSystemRTL();
    if (mbRTL)
        pEdEngine->SetDefaultHorizontalTextDirection(EE_HTEXTDIR_R2L);

    pEdView = new EditView( pEdEngine, this );
    pEdView->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );

    pEdView->SetBackgroundColor( aBgColor );
    pEdEngine->InsertView( pEdView );
}

void ScEditWindow::Resize()
{
    Size aOutputSize(GetOutputSize());
    Size aSize(aOutputSize);
    aSize.Height() *= 4;
    pEdEngine->SetPaperSize(aSize);
    pEdView->SetOutputArea(Rectangle(Point(0,0), aOutputSize));
    Control::Resize();
}

// -----------------------------------------------------------------------

ScEditWindow::~ScEditWindow()
@@ -126,6 +174,11 @@ ScEditWindow::~ScEditWindow()
    delete pEdView;
}

extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScEditWindow(Window *pParent, VclBuilder::stringmap &)
{
    return new ScEditWindow (pParent, WB_BORDER|WB_TABSTOP, Left);
}

// -----------------------------------------------------------------------

void ScEditWindow::SetNumType(SvxNumType eNumType)
@@ -340,13 +393,24 @@ void ScEditWindow::LoseFocus()
}

ScExtIButton::ScExtIButton(Window* pParent, const ResId& rResId )
:   ImageButton(pParent,rResId),
    pPopupMenu(NULL)
    : ImageButton(pParent,rResId), pPopupMenu(NULL)
{
    nSelected=0;
    aTimer.SetTimeout(600);
    SetDropDown( true);
}
ScExtIButton::ScExtIButton(Window* pParent, WinBits nBits )
    : ImageButton(pParent,nBits), pPopupMenu(NULL)
{
    nSelected=0;
    aTimer.SetTimeout(600);
    SetDropDown( true);
}

extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScExtIButton(Window *pParent, VclBuilder::stringmap &)
{
    return new ScExtIButton (pParent, 0);// WB_BORDER|WB_TABSTOP);
}

void ScExtIButton::SetPopupMenu(PopupMenu* pPopUp)
{
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 375db7b..a4a6018 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1619,40 +1619,40 @@ Resource RID_GLOBSTR
        Text[ en-US ] = "WARNING: This action may have resulted in references to the deleted area not being restored.";
    };

    String STR_HF_NONE_IN_BRACKETS
    {
        Text [ en-US ] = "(none)";
    };
//     String STR_HF_NONE_IN_BRACKETS
//     {
//         Text [ en-US ] = "(none)";
//     };
//
//     String STR_HF_OF
//     {
//         Text [ en-US ] = "of";
//     };
//
//     String STR_HF_OF_QUESTION
//     {
//         Text [ en-US ] = "of ?";
//     };
//
//     String STR_HF_CREATED_BY
//     {
//         Text [ en-US ] = "Created by";
//     };
//
//     String STR_HF_CONFIDENTIAL
//     {
//         Text [ en-US ] = "Confidential";
//     };
//
//     String STR_HF_CUSTOMIZED
//     {
//         Text [ en-US ] = "Customized";
//     };

    String STR_HF_OF
    {
        Text [ en-US ] = "of";
    };

    String STR_HF_OF_QUESTION
    {
        Text [ en-US ] = "of ?";
    };

    String STR_HF_CREATED_BY
    {
        Text [ en-US ] = "Created by";
    };

    String STR_HF_CONFIDENTIAL
    {
        Text [ en-US ] = "Confidential";
    };

    String STR_HF_CUSTOMIZED
    {
        Text [ en-US ] = "Customized";
    };

    String STR_HF_CUSTOM_FOOTER
    {
        Text [ en-US ] = "Custom footer";
    };
//     String STR_HF_CUSTOM_FOOTER
//     {
//         Text [ en-US ] = "Custom footer";
//     };

    String STR_UNDO_CHINESE_TRANSLATION
    {
diff --git a/sc/uiconfig/scalc/ui/headerfootercontent.ui b/sc/uiconfig/scalc/ui/headerfootercontent.ui
new file mode 100644
index 0000000..d7f5642
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/headerfootercontent.ui
@@ -0,0 +1,536 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <!-- interface-requires LibreOffice 1.0 -->
  <object class="GtkVBox" id="HeaderFooterContent">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="spacing">6</property>
    <child>
      <object class="GtkGrid" id="grid1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="row_spacing">12</property>
        <property name="column_spacing">6</property>
        <property name="column_homogeneous">True</property>
        <child>
          <object class="GtkLabel" id="labelFT_LEFT">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="xalign">0</property>
            <property name="label" translatable="yes">_Left area</property>
            <property name="use_underline">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelFT_CENTER">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="xalign">0</property>
            <property name="label" translatable="yes">_Center area</property>
            <property name="use_underline">True</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelFT_RIGHT">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="xalign">0</property>
            <property name="label" translatable="yes">R_ight area</property>
            <property name="use_underline">True</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="sclo-ScEditWindow" id="textviewWND_LEFT">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="wrap_mode">word</property>
            <property name="overwrite">True</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="sclo-ScEditWindow" id="textviewWND_CENTER">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="sclo-ScEditWindow" id="textviewWND_RIGHT">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">0</property>
      </packing>
    </child>
    <child>
      <object class="GtkGrid" id="grid2">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="row_spacing">12</property>
        <property name="column_spacing">6</property>
        <child>
          <object class="GtkVBox" id="box2">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkLabel" id="labelFT_H_DEFINED">
                <property name="can_focus">False</property>
                <property name="vexpand">True</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">_Header</property>
                <property name="use_underline">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="labelFT_F_DEFINED">
                <property name="can_focus">False</property>
                <property name="vexpand">True</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">_Footer</property>
                <property name="use_underline">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkVBox" id="box3">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="spacing">6</property>
            <child>
              <object class="GtkLabel" id="labelFT_H_CUSTOM">
                <property name="can_focus">False</property>
                <property name="vexpand">True</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">Custom header</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="labelFT_F_CUSTOM">
                <property name="can_focus">False</property>
                <property name="vexpand">True</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">Custom footer</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkHBox" id="box">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="spacing">12</property>
            <child>
              <object class="GtkButton" id="buttonBTN_TEXT">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Text Attributes</property>
                <property name="tooltip_text" translatable="yes">Text Attributes</property>
                <property name="image">imageBTN_TEXT</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="sclo-ScExtIButton" id="buttonBTN_FILE">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="receives_default">True</property>
                <property name="tooltip_text" translatable="yes">Title</property>
                <property name="image">imageBTN_FILE</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="buttonBTN_TABLE">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Sheet Name</property>
                <property name="tooltip_text" translatable="yes">Sheet Name</property>
                <property name="image">imageBTN_TABLE</property>
                <property name="yalign">0.47999998927116394</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="buttonBTN_PAGE">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Page</property>
                <property name="tooltip_text" translatable="yes">Page</property>
                <property name="image">imageBTN_PAGE</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">3</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="buttonBTN_PAGES">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Pages</property>
                <property name="tooltip_text" translatable="yes">Pages</property>
                <property name="image">imageBTN_PAGES</property>
                <property name="yalign">0.49000000953674316</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">4</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="buttonBTN_DATE">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Date</property>
                <property name="tooltip_text" translatable="yes">Date</property>
                <property name="image">imageBTN_DATE</property>
                <property name="yalign">0.37000000476837158</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">5</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="buttonBTN_TIME">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="has_tooltip">True</property>
                <property name="tooltip_markup" translatable="yes">Time</property>
                <property name="tooltip_text" translatable="yes">Time</property>
                <property name="image">imageBTN_TIME</property>
                <property name="yalign">0.41999998688697815</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">6</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkComboBox" id="comboLB_DEFINED">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">1</property>
      </packing>
    </child>
    <child>
      <object class="GtkFrame" id="frame1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label_xalign">0</property>
        <property name="shadow_type">none</property>
        <child>
          <object class="GtkAlignment" id="alignment1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="top_padding">6</property>
            <property name="left_padding">12</property>
            <child>
              <object class="GtkLabel" id="label2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Use the buttons to change the font or insert field commands such as date, time, etc.</property>
              </object>
            </child>
          </object>
        </child>
        <child type="label">
          <object class="GtkLabel" id="label1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Note</property>
            <attributes>
              <attribute name="weight" value="bold"/>
            </attributes>
          </object>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">3</property>
      </packing>
    </child>
    <child>
      <object class="GtkVBox" id="box4">
        <property name="can_focus">False</property>
        <property name="spacing">6</property>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_NONE_IN_BRACKETS">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">(none)</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_PAGE">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Page</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_OF_QUESTION">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">of ?</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_CONFIDENTIAL">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Confidential</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_CREATED_BY">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Created by</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_CUSTOMIZED">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">Customized</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="labelSTR_HF_OF">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">of</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">6</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">4</property>
      </packing>
    </child>
  </object>
  <object class="GtkImage" id="imageBTN_DATE">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/date.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_FILE">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/file.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_PAGE">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/page.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_PAGES">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/pages.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_TABLE">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/table.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_TEXT">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/text.png</property>
  </object>
  <object class="GtkImage" id="imageBTN_TIME">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="pixbuf">sc/res/time.png</property>
  </object>
  <object class="GtkMenu" id="popup">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <child>
      <object class="GtkMenuItem" id="title">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">Title</property>
        <property name="use_underline">True</property>
      </object>
    </child>
    <child>
      <object class="GtkMenuItem" id="filename">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">File Name</property>
        <property name="use_underline">True</property>
      </object>
    </child>
    <child>
      <object class="GtkMenuItem" id="pathname">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">Path/File Name</property>
        <property name="use_underline">True</property>
      </object>
    </child>
  </object>
</interface>