weld ScHFEditPage

Change-Id: Icf40e51ed40659cc79b61798de47132162e86541
Reviewed-on: https://gerrit.libreoffice.org/70414
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2019-04-07 21:45:01 +01:00
parent 6e7bfc896e
commit 2fb6e8365c
10 changed files with 480 additions and 412 deletions

View File

@@ -328,10 +328,6 @@
generic-name="Cursor Reference Edit" parent="foruilo-RefEdit" generic-name="Cursor Reference Edit" parent="foruilo-RefEdit"
icon-name="widget-gtk-textentry"/> 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="Open Document ListBox" name="dbulo-OpenDocumentListBox" <glade-widget-class title="Open Document ListBox" name="dbulo-OpenDocumentListBox"
generic-name="Open Document ListBox" parent="GtkComboBox" generic-name="Open Document ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/> icon-name="widget-gtk-combobox"/>

View File

@@ -38,6 +38,7 @@ public:
virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); } virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); }
virtual FactoryFunction GetUITestFactory() const { return nullptr; } virtual FactoryFunction GetUITestFactory() const { return nullptr; }
virtual OUString RequestHelp(tools::Rectangle&) { return OUString(); } virtual OUString RequestHelp(tools::Rectangle&) { return OUString(); }
virtual OUString GetHelpText() const { return m_pDrawingArea->get_tooltip_text(); }
Size const& GetOutputSizePixel() const { return m_aSize; } Size const& GetOutputSizePixel() const { return m_aSize; }
void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; } void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; }
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; } virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; }
@@ -124,6 +125,8 @@ public:
void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); } void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); }
bool get_sensitive() const { return m_xDrawingArea->get_sensitive(); } bool get_sensitive() const { return m_xDrawingArea->get_sensitive(); }
bool get_visible() const { return m_xDrawingArea->get_visible(); } bool get_visible() const { return m_xDrawingArea->get_visible(); }
void set_grid_left_attach(int nAttach) { m_xDrawingArea->set_grid_left_attach(nAttach); }
int get_grid_left_attach() const { return m_xDrawingArea->get_grid_left_attach(); }
}; };
} }
#endif #endif

View File

@@ -241,6 +241,12 @@ public:
void void
CommitChange(const css::accessibility::AccessibleEventObject& rEvent) const; CommitChange(const css::accessibility::AccessibleEventObject& rEvent) const;
/// Use this method to set initial Name without notification
void SetName(const OUString& rName) { msName = rName; }
/// Use this method to set initial Description without notification
void SetDescription(const OUString& rDesc) { msDescription = rDesc; }
protected: protected:
/// Calls all FocusListener to tell they that the focus is gained. /// Calls all FocusListener to tell they that the focus is gained.
void CommitFocusGained() const; void CommitFocusGained() const;
@@ -253,11 +259,6 @@ protected:
/// @throws css::lang::DisposedException /// @throws css::lang::DisposedException
void IsObjectValid() const; void IsObjectValid() const;
/// Use this method to set initial Name without notification
void SetName(const OUString& rName) { msName = rName; }
/// Use this method to set initial Description without notification
void SetDescription(const OUString& rDesc) { msDescription = rDesc; }
/// Reference to the parent object. /// Reference to the parent object.
css::uno::Reference<css::accessibility::XAccessible> mxParent; css::uno::Reference<css::accessibility::XAccessible> mxParent;

View File

@@ -21,8 +21,8 @@
#define INCLUDED_SC_SOURCE_UI_INC_SCUITPHFEDIT_HXX #define INCLUDED_SC_SOURCE_UI_INC_SCUITPHFEDIT_HXX
#include "tphfedit.hxx" #include "tphfedit.hxx"
#include <sfx2/tabdlg.hxx> #include <vcl/customweld.hxx>
#include <vcl/menubtn.hxx> #include <vcl/weld.hxx>
enum ScHFEntryId enum ScHFEntryId
{ {
@@ -54,40 +54,48 @@ public:
void ClearTextAreas(); void ClearTextAreas();
protected: protected:
ScHFEditPage( vcl::Window* pParent, ScHFEditPage( TabPageParent pParent,
const SfxItemSet& rCoreSet, const SfxItemSet& rCoreSet,
sal_uInt16 nWhich, sal_uInt16 nWhich,
bool bHeader ); bool bHeader );
virtual ~ScHFEditPage() override; virtual ~ScHFEditPage() override;
virtual void dispose() override;
private: private:
VclPtr<ScEditWindow> m_pWndLeft; sal_uInt16 const nWhich;
VclPtr<ScEditWindow> m_pWndCenter; bool m_bDropDownActive;
VclPtr<ScEditWindow> m_pWndRight; sal_Int64 m_nTimeToggled;
VclPtr<FixedText> m_pFtDefinedHF;
VclPtr<ListBox> m_pLbDefined;
VclPtr<FixedText> m_pFtCustomHF;
VclPtr<PushButton> m_pBtnText;
VclPtr<MenuButton> m_pBtnFile;
VclPtr<PushButton> m_pBtnTable;
VclPtr<PushButton> m_pBtnPage;
VclPtr<PushButton> m_pBtnLastPage;
VclPtr<PushButton> m_pBtnDate;
VclPtr<PushButton> m_pBtnTime;
VclPtr<FixedText> m_pFtConfidential; std::unique_ptr<weld::Label> m_xFtDefinedHF;
VclPtr<FixedText> m_pFtPage; std::unique_ptr<weld::ComboBox> m_xLbDefined;
VclPtr<FixedText> m_pFtOfQuestion; std::unique_ptr<weld::Label> m_xFtCustomHF;
VclPtr<FixedText> m_pFtOf; std::unique_ptr<weld::Button> m_xBtnText;
VclPtr<FixedText> m_pFtNone; std::unique_ptr<weld::MenuButton> m_xBtnFile;
VclPtr<FixedText> m_pFtCreatedBy; std::unique_ptr<weld::Button> m_xBtnTable;
VclPtr<FixedText> m_pFtCustomized; std::unique_ptr<weld::Button> m_xBtnPage;
std::unique_ptr<weld::Button> m_xBtnLastPage;
std::unique_ptr<weld::Button> m_xBtnDate;
std::unique_ptr<weld::Button> m_xBtnTime;
std::unique_ptr<weld::Label> m_xFtConfidential;
std::unique_ptr<weld::Label> m_xFtPage;
std::unique_ptr<weld::Label> m_xFtOfQuestion;
std::unique_ptr<weld::Label> m_xFtOf;
std::unique_ptr<weld::Label> m_xFtNone;
std::unique_ptr<weld::Label> m_xFtCreatedBy;
std::unique_ptr<weld::Label> m_xFtCustomized;
std::unique_ptr<weld::Widget> m_xLeft;
std::unique_ptr<weld::Widget> m_xRight;
std::unique_ptr<ScEditWindow> m_xWndLeft;
std::unique_ptr<ScEditWindow> m_xWndCenter;
std::unique_ptr<ScEditWindow> m_xWndRight;
std::unique_ptr<weld::CustomWeld> m_xWndLeftWnd;
std::unique_ptr<weld::CustomWeld> m_xWndCenterWnd;
std::unique_ptr<weld::CustomWeld> m_xWndRightWnd;
ScEditWindow * m_pEditFocus; ///one of m_pWndLeft, m_pWndCenter, m_pWndRight ScEditWindow * m_pEditFocus; ///one of m_pWndLeft, m_pWndCenter, m_pWndRight
sal_uInt16 const nWhich;
DECL_LINK( ObjectSelectHdl, ScEditWindow&, void ); DECL_LINK( ObjectSelectHdl, ScEditWindow&, void );
private: private:
@@ -99,9 +107,10 @@ private:
bool IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextObj); bool IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextObj);
static bool IsDateEntry(const EditTextObject* pTextObj); static bool IsDateEntry(const EditTextObject* pTextObj);
static bool IsExtFileNameEntry(const EditTextObject* pTextObj); static bool IsExtFileNameEntry(const EditTextObject* pTextObj);
DECL_LINK( ListHdl_Impl, ListBox&, void); DECL_LINK( ListHdl_Impl, weld::ComboBox&, void);
DECL_LINK( ClickHdl, Button*, void ); DECL_LINK( ListToggleHdl_Impl, weld::ComboBox&, void);
DECL_LINK( MenuHdl, MenuButton*, void ); DECL_LINK( ClickHdl, weld::Button&, void );
DECL_LINK( MenuHdl, const OString&, void );
}; };
class ScRightHeaderEditPage : public ScHFEditPage class ScRightHeaderEditPage : public ScHFEditPage
@@ -111,7 +120,7 @@ public:
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet ); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet );
private: private:
ScRightHeaderEditPage( vcl::Window* pParent, const SfxItemSet& rSet ); ScRightHeaderEditPage( TabPageParent pParent, const SfxItemSet& rSet );
}; };
class ScLeftHeaderEditPage : public ScHFEditPage class ScLeftHeaderEditPage : public ScHFEditPage
@@ -121,7 +130,7 @@ public:
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet ); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet );
private: private:
ScLeftHeaderEditPage( vcl::Window* pParent, const SfxItemSet& rSet ); ScLeftHeaderEditPage( TabPageParent pParent, const SfxItemSet& rSet );
}; };
class ScRightFooterEditPage : public ScHFEditPage class ScRightFooterEditPage : public ScHFEditPage
@@ -131,7 +140,7 @@ public:
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet ); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet );
private: private:
ScRightFooterEditPage( vcl::Window* pParent, const SfxItemSet& rSet ); ScRightFooterEditPage( TabPageParent pParent, const SfxItemSet& rSet );
}; };
class ScLeftFooterEditPage : public ScHFEditPage class ScLeftFooterEditPage : public ScHFEditPage
@@ -141,7 +150,7 @@ public:
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet ); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rCoreSet );
private: private:
ScLeftFooterEditPage( vcl::Window* pParent, const SfxItemSet& rSet ); ScLeftFooterEditPage( TabPageParent pParent, const SfxItemSet& rSet );
}; };
#endif #endif

View File

@@ -23,9 +23,9 @@
#include <scdllapi.h> #include <scdllapi.h>
#include <cppuhelper/weakref.hxx> #include <cppuhelper/weakref.hxx>
#include <tools/wintypes.hxx> #include <tools/wintypes.hxx>
#include <editeng/editview.hxx>
#include <editeng/svxenum.hxx> #include <editeng/svxenum.hxx>
#include <vcl/ctrl.hxx> #include <vcl/customweld.hxx>
#include <vcl/menu.hxx>
#include <functional> #include <functional>
@@ -46,16 +46,15 @@ enum ScEditWindowLocation
Right Right
}; };
class SC_DLLPUBLIC ScEditWindow : public Control class SC_DLLPUBLIC ScEditWindow : public weld::CustomWidgetController
, public EditViewCallbacks
{ {
public: public:
ScEditWindow( vcl::Window* pParent, WinBits nBits , ScEditWindowLocation eLoc ); ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pParent);
virtual void SetDrawingArea(weld::DrawingArea* pArea) override;
virtual ~ScEditWindow() override; virtual ~ScEditWindow() override;
virtual void dispose() override;
using Control::SetFont;
void SetFont( const ScPatternAttr& rPattern ); void SetFont( const ScPatternAttr& rPattern );
using Control::SetText;
void SetText( const EditTextObject& rTextObject ); void SetText( const EditTextObject& rTextObject );
std::unique_ptr<EditTextObject> CreateTextObject(); std::unique_ptr<EditTextObject> CreateTextObject();
void SetCharAttributes(); void SetCharAttributes();
@@ -73,20 +72,37 @@ public:
void SetLocation(ScEditWindowLocation eLoc) { eLocation = eLoc; } void SetLocation(ScEditWindowLocation eLoc) { eLocation = eLoc; }
protected: protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
virtual void MouseMove( const MouseEvent& rMEvt ) override; virtual bool MouseMove( const MouseEvent& rMEvt ) override;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
virtual void KeyInput( const KeyEvent& rKEvt ) override; virtual bool KeyInput( const KeyEvent& rKEvt ) override;
virtual void Command( const CommandEvent& rCEvt ) override;
virtual void GetFocus() override; virtual void GetFocus() override;
virtual void LoseFocus() override; virtual void LoseFocus() override;
virtual void Resize() override; virtual void Resize() override;
virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override
{
weld::DrawingArea* pDrawingArea = GetDrawingArea();
pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
}
virtual void EditViewSelectionChange() const override
{
weld::DrawingArea* pDrawingArea = GetDrawingArea();
pDrawingArea->queue_draw();
}
virtual OutputDevice& EditViewOutputDevice() const override
{
return GetDrawingArea()->get_ref_device();
}
private: private:
std::unique_ptr<ScHeaderEditEngine> pEdEngine; std::unique_ptr<ScHeaderEditEngine> pEdEngine;
std::unique_ptr<EditView> pEdView; std::unique_ptr<EditView> pEdView;
ScEditWindowLocation eLocation; ScEditWindowLocation eLocation;
bool mbRTL; bool mbRTL;
weld::Window* mpDialog;
css::uno::WeakReference< css::accessibility::XAccessible > xAcc; css::uno::WeakReference< css::accessibility::XAccessible > xAcc;
ScAccessibleEditObject* pAcc; ScAccessibleEditObject* pAcc;

View File

@@ -24,6 +24,7 @@
#include <editeng/editobj.hxx> #include <editeng/editobj.hxx>
#include <editeng/flditem.hxx> #include <editeng/flditem.hxx>
#include <osl/time.h>
#include <sfx2/tabdlg.hxx> #include <sfx2/tabdlg.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
@@ -41,108 +42,92 @@
// class ScHFEditPage // class ScHFEditPage
ScHFEditPage::ScHFEditPage( vcl::Window* pParent, ScHFEditPage::ScHFEditPage(TabPageParent pParent,
const SfxItemSet& rCoreAttrs, const SfxItemSet& rCoreAttrs,
sal_uInt16 nWhichId, sal_uInt16 nWhichId,
bool bHeader) bool bHeader)
: SfxTabPage( pParent, "HeaderFooterContent", "modules/scalc/ui/headerfootercontent.ui", &rCoreAttrs ) : SfxTabPage(pParent, "modules/scalc/ui/headerfootercontent.ui", "HeaderFooterContent", &rCoreAttrs)
, m_pEditFocus(nullptr)
, nWhich( nWhichId ) , nWhich( nWhichId )
, m_bDropDownActive(false)
, m_nTimeToggled(-1)
, m_xFtDefinedHF(m_xBuilder->weld_label(!bHeader ? "labelFT_F_DEFINED" : "labelFT_H_DEFINED"))
, m_xLbDefined(m_xBuilder->weld_combo_box("comboLB_DEFINED"))
, m_xFtCustomHF(m_xBuilder->weld_label(!bHeader ? "labelFT_F_CUSTOM" : "labelFT_H_CUSTOM"))
, m_xBtnText(m_xBuilder->weld_button("buttonBTN_TEXT"))
, m_xBtnFile(m_xBuilder->weld_menu_button("buttonBTN_FILE"))
, m_xBtnTable(m_xBuilder->weld_button("buttonBTN_TABLE"))
, m_xBtnPage(m_xBuilder->weld_button("buttonBTN_PAGE"))
, m_xBtnLastPage(m_xBuilder->weld_button("buttonBTN_PAGES"))
, m_xBtnDate(m_xBuilder->weld_button("buttonBTN_DATE"))
, m_xBtnTime(m_xBuilder->weld_button("buttonBTN_TIME"))
, m_xFtConfidential(m_xBuilder->weld_label("labelSTR_HF_CONFIDENTIAL"))
, m_xFtPage(m_xBuilder->weld_label("labelSTR_PAGE"))
, m_xFtOfQuestion(m_xBuilder->weld_label("labelSTR_HF_OF_QUESTION"))
, m_xFtOf(m_xBuilder->weld_label("labelSTR_HF_OF"))
, m_xFtNone(m_xBuilder->weld_label("labelSTR_HF_NONE_IN_BRACKETS"))
, m_xFtCreatedBy(m_xBuilder->weld_label("labelSTR_HF_CREATED_BY"))
, m_xFtCustomized(m_xBuilder->weld_label("labelSTR_HF_CUSTOMIZED"))
, m_xLeft(m_xBuilder->weld_widget("labelFT_LEFT"))
, m_xRight(m_xBuilder->weld_widget("labelFT_RIGHT"))
, m_xWndLeft(new ScEditWindow(Left, pParent.GetFrameWeld()))
, m_xWndCenter(new ScEditWindow(Center, pParent.GetFrameWeld()))
, m_xWndRight(new ScEditWindow(Right, pParent.GetFrameWeld()))
, m_xWndLeftWnd(new weld::CustomWeld(*m_xBuilder, "textviewWND_LEFT", *m_xWndLeft))
, m_xWndCenterWnd(new weld::CustomWeld(*m_xBuilder, "textviewWND_CENTER", *m_xWndCenter))
, m_xWndRightWnd(new weld::CustomWeld(*m_xBuilder, "textviewWND_RIGHT", *m_xWndRight))
, m_pEditFocus(nullptr)
{ {
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");
// tdf#114695 override natural size with a small value // tdf#114695 override natural size with a small value
// we expect this to get stretched to some larger but // we expect this to get stretched to some larger but
// limited size based on surrounding widgets // limited size based on surrounding widgets
m_pLbDefined->set_width_request(m_pLbDefined->approximate_digit_width() * 20); m_xLbDefined->set_size_request(m_xLbDefined->get_approximate_digit_width() * 20, -1);
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? //! use default style from current document?
//! if font color is used, header/footer background color must be set //! if font color is used, header/footer background color must be set
ScPatternAttr aPatAttr( rCoreAttrs.GetPool() ); ScPatternAttr aPatAttr( rCoreAttrs.GetPool() );
m_pBtnFile->SetPopupMenu(get_menu("popup")); m_xLbDefined->connect_popup_toggled( LINK( this, ScHFEditPage, ListToggleHdl_Impl) );
m_xLbDefined->connect_changed( LINK( this, ScHFEditPage, ListHdl_Impl ) );
m_xBtnFile->connect_selected( LINK( this, ScHFEditPage, MenuHdl ) );
m_xBtnText->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnPage->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnLastPage->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnDate->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnTime->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnFile->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_xBtnTable->connect_clicked( LINK( this, ScHFEditPage, ClickHdl ) );
m_pLbDefined->SetSelectHdl( LINK( this, ScHFEditPage, ListHdl_Impl ) ); m_xFtDefinedHF->show();
m_pBtnFile->SetSelectHdl( LINK( this, ScHFEditPage, MenuHdl ) ); m_xFtCustomHF->show();
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 ) );
get(m_pFtDefinedHF,!bHeader ? "labelFT_F_DEFINED" : "labelFT_H_DEFINED");
get(m_pFtCustomHF, !bHeader ? "labelFT_F_CUSTOM" : "labelFT_H_CUSTOM");
m_pFtDefinedHF->Show();
m_pFtCustomHF->Show();
//swap left/right areas and their labels in RTL mode //swap left/right areas and their labels in RTL mode
if( AllSettings::GetLayoutRTL() ) if( AllSettings::GetLayoutRTL() )
{ {
vcl::Window *pLeft = get<vcl::Window>("labelFT_LEFT"); sal_Int32 nOldLeftAttach = m_xLeft->get_grid_left_attach();
vcl::Window *pRight = get<vcl::Window>("labelFT_RIGHT"); sal_Int32 nOldRightAttach = m_xRight->get_grid_left_attach();
sal_Int32 nOldLeftAttach = pLeft->get_grid_left_attach(); m_xLeft->set_grid_left_attach(nOldRightAttach);
sal_Int32 nOldRightAttach = pRight->get_grid_left_attach(); m_xRight->set_grid_left_attach(nOldLeftAttach);
pLeft->set_grid_left_attach(nOldRightAttach);
pRight->set_grid_left_attach(nOldLeftAttach);
pLeft = m_pWndLeft; nOldLeftAttach = m_xWndLeftWnd->get_grid_left_attach();
pRight = m_pWndRight; nOldRightAttach = m_xWndRightWnd->get_grid_left_attach();
nOldLeftAttach = pLeft->get_grid_left_attach(); m_xWndLeftWnd->set_grid_left_attach(nOldRightAttach);
nOldRightAttach = pRight->get_grid_left_attach(); m_xWndRightWnd->set_grid_left_attach(nOldLeftAttach);
pLeft->set_grid_left_attach(nOldRightAttach);
pRight->set_grid_left_attach(nOldLeftAttach);
} }
m_pWndLeft->SetFont( aPatAttr ); m_xWndLeft->SetFont( aPatAttr );
m_pWndCenter->SetFont( aPatAttr ); m_xWndCenter->SetFont( aPatAttr );
m_pWndRight->SetFont( aPatAttr ); m_xWndRight->SetFont( aPatAttr );
// Set size request for all 3 widgets m_xWndLeft->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
Size aSize = LogicToPixel(Size(80, 120), MapMode(MapUnit::MapAppFont)); m_xWndCenter->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
VclPtr<ScEditWindow> aEditWindows[] = {m_pWndLeft, m_pWndCenter, m_pWndRight}; m_xWndRight->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
for (auto &pEditWindow : aEditWindows)
{
pEditWindow->set_width_request(aSize.Width());
pEditWindow->set_height_request(aSize.Height());
}
m_pWndLeft->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
m_pWndCenter->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
m_pWndRight->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) );
auto setEditFocus = [this](ScEditWindow & rEdit) { this->m_pEditFocus = &rEdit; }; auto setEditFocus = [this](ScEditWindow & rEdit) { this->m_pEditFocus = &rEdit; };
m_pWndLeft->SetGetFocusHdl(setEditFocus); m_xWndLeft->SetGetFocusHdl(setEditFocus);
m_pWndCenter->SetGetFocusHdl(setEditFocus); m_xWndCenter->SetGetFocusHdl(setEditFocus);
m_pWndRight->SetGetFocusHdl(setEditFocus); m_xWndRight->SetGetFocusHdl(setEditFocus);
m_pWndLeft->GrabFocus(); m_xWndLeft->GrabFocus();
m_pEditFocus = m_pWndLeft; // there's no event from GrabFocus() m_pEditFocus = m_xWndLeft.get(); // there's no event from grab_focus()
InitPreDefinedList(); InitPreDefinedList();
@@ -150,7 +135,7 @@ ScHFEditPage::ScHFEditPage( vcl::Window* pParent,
IMPL_LINK_NOARG( ScHFEditPage, ObjectSelectHdl, ScEditWindow&, void ) IMPL_LINK_NOARG( ScHFEditPage, ObjectSelectHdl, ScEditWindow&, void )
{ {
m_pBtnText->GrabFocus(); m_xBtnText->grab_focus();
} }
ScHFEditPage::~ScHFEditPage() ScHFEditPage::~ScHFEditPage()
@@ -158,36 +143,11 @@ ScHFEditPage::~ScHFEditPage()
disposeOnce(); disposeOnce();
} }
void ScHFEditPage::dispose()
{
m_pWndLeft.clear();
m_pWndCenter.clear();
m_pWndRight.clear();
m_pFtDefinedHF.clear();
m_pLbDefined.clear();
m_pFtCustomHF.clear();
m_pBtnText.clear();
m_pBtnFile.clear();
m_pBtnTable.clear();
m_pBtnPage.clear();
m_pBtnLastPage.clear();
m_pBtnDate.clear();
m_pBtnTime.clear();
m_pFtConfidential.clear();
m_pFtPage.clear();
m_pFtOfQuestion.clear();
m_pFtOf.clear();
m_pFtNone.clear();
m_pFtCreatedBy.clear();
m_pFtCustomized.clear();
SfxTabPage::dispose();
}
void ScHFEditPage::SetNumType(SvxNumType eNumType) void ScHFEditPage::SetNumType(SvxNumType eNumType)
{ {
m_pWndLeft->SetNumType(eNumType); m_xWndLeft->SetNumType(eNumType);
m_pWndCenter->SetNumType(eNumType); m_xWndCenter->SetNumType(eNumType);
m_pWndRight->SetNumType(eNumType); m_xWndRight->SetNumType(eNumType);
} }
void ScHFEditPage::Reset( const SfxItemSet* rCoreSet ) void ScHFEditPage::Reset( const SfxItemSet* rCoreSet )
@@ -198,11 +158,11 @@ void ScHFEditPage::Reset( const SfxItemSet* rCoreSet )
const ScPageHFItem& rItem = static_cast<const ScPageHFItem&>(*pItem); const ScPageHFItem& rItem = static_cast<const ScPageHFItem&>(*pItem);
if( const EditTextObject* pLeft = rItem.GetLeftArea() ) if( const EditTextObject* pLeft = rItem.GetLeftArea() )
m_pWndLeft->SetText( *pLeft ); m_xWndLeft->SetText( *pLeft );
if( const EditTextObject* pCenter = rItem.GetCenterArea() ) if( const EditTextObject* pCenter = rItem.GetCenterArea() )
m_pWndCenter->SetText( *pCenter ); m_xWndCenter->SetText( *pCenter );
if( const EditTextObject* pRight = rItem.GetRightArea() ) if( const EditTextObject* pRight = rItem.GetRightArea() )
m_pWndRight->SetText( *pRight ); m_xWndRight->SetText( *pRight );
SetSelectDefinedList(); SetSelectDefinedList();
} }
@@ -211,9 +171,9 @@ void ScHFEditPage::Reset( const SfxItemSet* rCoreSet )
bool ScHFEditPage::FillItemSet( SfxItemSet* rCoreSet ) bool ScHFEditPage::FillItemSet( SfxItemSet* rCoreSet )
{ {
ScPageHFItem aItem( nWhich ); ScPageHFItem aItem( nWhich );
std::unique_ptr<EditTextObject> pLeft = m_pWndLeft->CreateTextObject(); std::unique_ptr<EditTextObject> pLeft = m_xWndLeft->CreateTextObject();
std::unique_ptr<EditTextObject> pCenter = m_pWndCenter->CreateTextObject(); std::unique_ptr<EditTextObject> pCenter = m_xWndCenter->CreateTextObject();
std::unique_ptr<EditTextObject> pRight = m_pWndRight->CreateTextObject(); std::unique_ptr<EditTextObject> pRight = m_xWndRight->CreateTextObject();
aItem.SetLeftArea ( *pLeft ); aItem.SetLeftArea ( *pLeft );
aItem.SetCenterArea( *pCenter ); aItem.SetCenterArea( *pCenter );
@@ -232,64 +192,64 @@ void ScHFEditPage::InitPreDefinedList()
boost::optional<Color> pFldColour; boost::optional<Color> pFldColour;
// Get the all field values at the outset. // Get the all field values at the outset.
OUString aPageFieldValue(m_pWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); OUString aPageFieldValue(m_xWndLeft->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 aSheetFieldValue(m_xWndLeft->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 aFileFieldValue(m_xWndLeft->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 aExtFileFieldValue(m_xWndLeft->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)); OUString aDateFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
m_pLbDefined->Clear(); m_xLbDefined->clear();
m_pLbDefined->InsertEntry(m_pFtNone->GetText()); m_xLbDefined->append_text(m_xFtNone->get_label());
OUString aPageEntry(m_pFtPage->GetText() + " " + aPageFieldValue); OUString aPageEntry(m_xFtPage->get_label() + " " + aPageFieldValue);
m_pLbDefined->InsertEntry(aPageEntry); m_xLbDefined->append_text(aPageEntry);
OUString aPageOfEntry(aPageEntry + " " + m_pFtOfQuestion->GetText()); OUString aPageOfEntry(aPageEntry + " " + m_xFtOfQuestion->get_label());
m_pLbDefined->InsertEntry( aPageOfEntry); m_xLbDefined->append_text( aPageOfEntry);
m_pLbDefined->InsertEntry(aSheetFieldValue); m_xLbDefined->append_text(aSheetFieldValue);
OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText() + ", " + aDateFieldValue + ", " + aPageEntry); OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_xFtConfidential->get_label() + ", " + aDateFieldValue + ", " + aPageEntry);
m_pLbDefined->InsertEntry( aConfidentialEntry); m_xLbDefined->append_text( aConfidentialEntry);
OUString aFileNamePageEntry(aFileFieldValue + ", " + aPageEntry); OUString aFileNamePageEntry(aFileFieldValue + ", " + aPageEntry);
m_pLbDefined->InsertEntry( aFileNamePageEntry); m_xLbDefined->append_text( aFileNamePageEntry);
m_pLbDefined->InsertEntry( aExtFileFieldValue); m_xLbDefined->append_text( aExtFileFieldValue);
OUString aPageSheetNameEntry(aPageEntry + ", " + aSheetFieldValue); OUString aPageSheetNameEntry(aPageEntry + ", " + aSheetFieldValue);
m_pLbDefined->InsertEntry( aPageSheetNameEntry); m_xLbDefined->append_text( aPageSheetNameEntry);
OUString aPageFileNameEntry(aPageEntry + ", " + aFileFieldValue); OUString aPageFileNameEntry(aPageEntry + ", " + aFileFieldValue);
m_pLbDefined->InsertEntry( aPageFileNameEntry); m_xLbDefined->append_text( aPageFileNameEntry);
OUString aPagePathNameEntry(aPageEntry + ", " + aExtFileFieldValue); OUString aPagePathNameEntry(aPageEntry + ", " + aExtFileFieldValue);
m_pLbDefined->InsertEntry( aPagePathNameEntry); m_xLbDefined->append_text( aPagePathNameEntry);
OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", " + aPageEntry + ", " + aDateFieldValue); OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", " + aPageEntry + ", " + aDateFieldValue);
m_pLbDefined->InsertEntry( aUserNameEntry); m_xLbDefined->append_text( aUserNameEntry);
OUString aCreatedByEntry( m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", "); OUString aCreatedByEntry( m_xFtCreatedBy->get_label() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName() + ", ");
aCreatedByEntry += aDateFieldValue + ", " + aPageEntry; aCreatedByEntry += aDateFieldValue + ", " + aPageEntry;
m_pLbDefined->InsertEntry( aCreatedByEntry); m_xLbDefined->append_text( aCreatedByEntry);
} }
void ScHFEditPage::InsertToDefinedList() void ScHFEditPage::InsertToDefinedList()
{ {
const sal_Int32 nCount = m_pLbDefined->GetEntryCount(); const sal_Int32 nCount = m_xLbDefined->get_count();
if(nCount == eEntryCount) if(nCount == eEntryCount)
{ {
m_pLbDefined->InsertEntry( m_pFtCustomized->GetText() ); m_xLbDefined->append_text( m_xFtCustomized->get_label() );
m_pLbDefined->SelectEntryPos(eEntryCount); m_xLbDefined->set_active(eEntryCount);
} }
} }
void ScHFEditPage::RemoveFromDefinedList() void ScHFEditPage::RemoveFromDefinedList()
{ {
const sal_Int32 nCount = m_pLbDefined->GetEntryCount(); const sal_Int32 nCount = m_xLbDefined->get_count();
if(nCount > eEntryCount ) if(nCount > eEntryCount )
m_pLbDefined->RemoveEntry( nCount-1); m_xLbDefined->remove( nCount-1);
} }
// determine if the header/footer exists in our predefined list and set select to it. // determine if the header/footer exists in our predefined list and set select to it.
@@ -308,13 +268,13 @@ void ScHFEditPage::SetSelectDefinedList()
OUString aCenterEntry; OUString aCenterEntry;
OUString aRightEntry; OUString aRightEntry;
pLeftObj = m_pWndLeft->GetEditEngine()->CreateTextObject(); pLeftObj = m_xWndLeft->GetEditEngine()->CreateTextObject();
pCenterObj = m_pWndCenter->GetEditEngine()->CreateTextObject(); pCenterObj = m_xWndCenter->GetEditEngine()->CreateTextObject();
pRightObj = m_pWndRight->GetEditEngine()->CreateTextObject(); pRightObj = m_xWndRight->GetEditEngine()->CreateTextObject();
bool bFound = false; bool bFound = false;
const sal_Int32 nCount = m_pLbDefined->GetEntryCount(); const sal_Int32 nCount = m_xLbDefined->get_count();
for(sal_Int32 i = 0; i < nCount && !bFound; ++i) for(sal_Int32 i = 0; i < nCount && !bFound; ++i)
{ {
switch(static_cast<ScHFEntryId>(i)) switch(static_cast<ScHFEntryId>(i))
@@ -339,7 +299,7 @@ void ScHFEditPage::SetSelectDefinedList()
aRightEntry = pRightObj->GetText(0); aRightEntry = pRightObj->GetText(0);
if(aLeftEntry == EMPTY_OUSTRING && aRightEntry == EMPTY_OUSTRING) if(aLeftEntry == EMPTY_OUSTRING && aRightEntry == EMPTY_OUSTRING)
{ {
if(IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get())) if(IsPageEntry(m_xWndCenter->GetEditEngine(), pCenterObj.get()))
{ {
eSelectEntry = ePageEntry; eSelectEntry = ePageEntry;
bFound = true; bFound = true;
@@ -379,10 +339,10 @@ void ScHFEditPage::SetSelectDefinedList()
case eConfidentialEntry: case eConfidentialEntry:
{ {
if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_pWndRight->GetEditEngine(), pRightObj.get())) if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_xWndRight->GetEditEngine(), pRightObj.get()))
{ {
OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText()); OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_xFtConfidential->get_label());
if(aConfidentialEntry == m_pWndLeft->GetEditEngine()->GetText(0)) if(aConfidentialEntry == m_xWndLeft->GetEditEngine()->GetText(0))
{ {
eSelectEntry = eConfidentialEntry; eSelectEntry = eConfidentialEntry;
bFound = true; bFound = true;
@@ -425,7 +385,7 @@ void ScHFEditPage::SetSelectDefinedList()
case ePageExtFileNameEntry: case ePageExtFileNameEntry:
{ {
aLeftEntry = pLeftObj->GetText(0); aLeftEntry = pLeftObj->GetText(0);
if(IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get()) && if(IsPageEntry(m_xWndCenter->GetEditEngine(), pCenterObj.get()) &&
IsExtFileNameEntry(pRightObj.get()) && aLeftEntry == EMPTY_OUSTRING) IsExtFileNameEntry(pRightObj.get()) && aLeftEntry == EMPTY_OUSTRING)
{ {
eSelectEntry = ePageExtFileNameEntry; eSelectEntry = ePageExtFileNameEntry;
@@ -436,11 +396,11 @@ void ScHFEditPage::SetSelectDefinedList()
case eUserNameEntry: case eUserNameEntry:
{ {
if(IsDateEntry(pRightObj.get()) && IsPageEntry(m_pWndCenter->GetEditEngine(), pCenterObj.get())) if(IsDateEntry(pRightObj.get()) && IsPageEntry(m_xWndCenter->GetEditEngine(), pCenterObj.get()))
{ {
OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName()); OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
if(aUserNameEntry == m_pWndLeft->GetEditEngine()->GetText(0)) if(aUserNameEntry == m_xWndLeft->GetEditEngine()->GetText(0))
{ {
eSelectEntry = eUserNameEntry; eSelectEntry = eUserNameEntry;
bFound = true; bFound = true;
@@ -451,11 +411,11 @@ void ScHFEditPage::SetSelectDefinedList()
case eCreatedByEntry: case eCreatedByEntry:
{ {
if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_pWndRight->GetEditEngine(), pRightObj.get())) if(IsDateEntry(pCenterObj.get()) && IsPageEntry(m_xWndRight->GetEditEngine(), pRightObj.get()))
{ {
OUString aCreatedByEntry(m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName()); OUString aCreatedByEntry(m_xFtCreatedBy->get_label() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
if(aCreatedByEntry == m_pWndLeft->GetEditEngine()->GetText(0)) if(aCreatedByEntry == m_xWndLeft->GetEditEngine()->GetText(0))
{ {
eSelectEntry = eCreatedByEntry; eSelectEntry = eCreatedByEntry;
bFound = true; bFound = true;
@@ -474,7 +434,7 @@ void ScHFEditPage::SetSelectDefinedList()
if(eSelectEntry == eEntryCount) if(eSelectEntry == eEntryCount)
InsertToDefinedList(); InsertToDefinedList();
m_pLbDefined->SelectEntryPos( sal::static_int_cast<sal_uInt16>( eSelectEntry ) ); m_xLbDefined->set_active( sal::static_int_cast<sal_uInt16>( eSelectEntry ) );
} }
bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextObj) bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextObj)
@@ -490,7 +450,7 @@ bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextOb
pEngine->GetPortions(0,aPosList); pEngine->GetPortions(0,aPosList);
if(aPosList.size() == 2) if(aPosList.size() == 2)
{ {
OUString aPageEntry(m_pFtPage->GetText() + " "); OUString aPageEntry(m_xFtPage->get_label() + " ");
ESelection aSel(0,0,0,0); ESelection aSel(0,0,0,0);
aSel.nEndPos = aPageEntry.getLength(); aSel.nEndPos = aPageEntry.getLength();
if(aPageEntry == pEngine->GetText(aSel)) if(aPageEntry == pEngine->GetText(aSel))
@@ -561,17 +521,17 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
case eNoneEntry: case eNoneEntry:
ClearTextAreas(); ClearTextAreas();
if(!bTravelling) if(!bTravelling)
m_pWndLeft->GrabFocus(); m_xWndLeft->GrabFocus();
break; break;
case ePageEntry: case ePageEntry:
{ {
ClearTextAreas(); ClearTextAreas();
OUString aPageEntry( m_pFtPage->GetText() + " " ); OUString aPageEntry( m_xFtPage->get_label() + " " );
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
} }
break; break;
@@ -579,42 +539,42 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
{ {
ClearTextAreas(); ClearTextAreas();
ESelection aSel(0,0,0,0); ESelection aSel(0,0,0,0);
OUString aPageEntry( m_pFtPage->GetText() + " "); OUString aPageEntry( m_xFtPage->get_label() + " ");
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
aSel.nEndPos = aPageEntry.getLength(); aSel.nEndPos = aPageEntry.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
++aSel.nEndPos; ++aSel.nEndPos;
OUString aPageOfEntry(" " + m_pFtOf->GetText() + " "); OUString aPageOfEntry(" " + m_xFtOf->get_label() + " ");
m_pWndCenter->GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
aSel.nEndPos = aSel.nEndPos + aPageOfEntry.getLength(); aSel.nEndPos = aSel.nEndPos + aPageOfEntry.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject(); pTextObj = m_xWndCenter->GetEditEngine()->CreateTextObject();
m_pWndCenter->SetText(*pTextObj); m_xWndCenter->SetText(*pTextObj);
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
} }
break; break;
case eSheetEntry: case eSheetEntry:
ClearTextAreas(); ClearTextAreas();
m_pWndCenter->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
break; break;
case eConfidentialEntry: case eConfidentialEntry:
{ {
ClearTextAreas(); ClearTextAreas();
OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_pFtConfidential->GetText()); OUString aConfidentialEntry(aUserOpt.GetCompany() + " " + m_xFtConfidential->get_label());
m_pWndLeft->GetEditEngine()->SetText(aConfidentialEntry); m_xWndLeft->GetEditEngine()->SetText(aConfidentialEntry);
m_pWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) );
OUString aPageEntry( m_pFtPage->GetText() + " "); OUString aPageEntry( m_xFtPage->get_label() + " ");
m_pWndRight->GetEditEngine()->SetText(aPageEntry); m_xWndRight->GetEditEngine()->SetText(aPageEntry);
m_pWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); m_xWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
if(!bTravelling) if(!bTravelling)
m_pWndRight->GrabFocus(); m_xWndRight->GrabFocus();
} }
break; break;
@@ -622,46 +582,46 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
{ {
ClearTextAreas(); ClearTextAreas();
ESelection aSel(0,0,0,0); ESelection aSel(0,0,0,0);
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ), aSel ); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ), aSel );
++aSel.nEndPos; ++aSel.nEndPos;
OUString aPageEntry(", " + m_pFtPage->GetText() + " "); OUString aPageEntry(", " + m_xFtPage->get_label() + " ");
m_pWndCenter->GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
aSel.nStartPos = aSel.nEndPos; aSel.nStartPos = aSel.nEndPos;
aSel.nEndPos = aSel.nEndPos + aPageEntry.getLength(); aSel.nEndPos = aSel.nEndPos + aPageEntry.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject(); pTextObj = m_xWndCenter->GetEditEngine()->CreateTextObject();
m_pWndCenter->SetText(*pTextObj); m_xWndCenter->SetText(*pTextObj);
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
} }
break; break;
case eExtFileNameEntry: case eExtFileNameEntry:
ClearTextAreas(); ClearTextAreas();
m_pWndCenter->InsertField( SvxFieldItem( SvxExtFileField( m_xWndCenter->InsertField( SvxFieldItem( SvxExtFileField(
EMPTY_OUSTRING, SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) ); EMPTY_OUSTRING, SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) );
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
break; break;
case ePageSheetEntry: case ePageSheetEntry:
{ {
ClearTextAreas(); ClearTextAreas();
ESelection aSel(0,0,0,0); ESelection aSel(0,0,0,0);
OUString aPageEntry( m_pFtPage->GetText() + " " ); OUString aPageEntry( m_xFtPage->get_label() + " " );
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
aSel.nEndPos = aPageEntry.getLength(); aSel.nEndPos = aPageEntry.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
++aSel.nEndPos; ++aSel.nEndPos;
OUString aCommaSpace(", "); OUString aCommaSpace(", ");
m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength(); aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject(); pTextObj = m_xWndCenter->GetEditEngine()->CreateTextObject();
m_pWndCenter->SetText(*pTextObj); m_xWndCenter->SetText(*pTextObj);
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
} }
break; break;
@@ -669,32 +629,32 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
{ {
ClearTextAreas(); ClearTextAreas();
ESelection aSel(0,0,0,0); ESelection aSel(0,0,0,0);
OUString aPageEntry( m_pFtPage->GetText() + " " ); OUString aPageEntry( m_xFtPage->get_label() + " " );
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
aSel.nEndPos = aPageEntry.getLength(); aSel.nEndPos = aPageEntry.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
++aSel.nEndPos; ++aSel.nEndPos;
OUString aCommaSpace(", "); OUString aCommaSpace(", ");
m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength(); aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos)); m_xWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject(); pTextObj = m_xWndCenter->GetEditEngine()->CreateTextObject();
m_pWndCenter->SetText(*pTextObj); m_xWndCenter->SetText(*pTextObj);
if(!bTravelling) if(!bTravelling)
m_pWndCenter->GrabFocus(); m_xWndCenter->GrabFocus();
} }
break; break;
case ePageExtFileNameEntry: case ePageExtFileNameEntry:
{ {
ClearTextAreas(); ClearTextAreas();
OUString aPageEntry( m_pFtPage->GetText() + " " ); OUString aPageEntry( m_xFtPage->get_label() + " " );
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
m_pWndRight->InsertField( SvxFieldItem( SvxExtFileField( m_xWndRight->InsertField( SvxFieldItem( SvxExtFileField(
EMPTY_OUSTRING, SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) ); EMPTY_OUSTRING, SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) );
if(!bTravelling) if(!bTravelling)
m_pWndRight->GrabFocus(); m_xWndRight->GrabFocus();
} }
break; break;
@@ -702,29 +662,29 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
{ {
ClearTextAreas(); ClearTextAreas();
OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName()); OUString aUserNameEntry(aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
m_pWndLeft->GetEditEngine()->SetText(aUserNameEntry); m_xWndLeft->GetEditEngine()->SetText(aUserNameEntry);
OUString aPageEntry( m_pFtPage->GetText() + " "); OUString aPageEntry( m_xFtPage->get_label() + " ");
//aPageEntry += " "; //aPageEntry += " ";
m_pWndCenter->GetEditEngine()->SetText(aPageEntry); m_xWndCenter->GetEditEngine()->SetText(aPageEntry);
m_pWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
m_pWndRight->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) ); m_xWndRight->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) );
if(!bTravelling) if(!bTravelling)
m_pWndRight->GrabFocus(); m_xWndRight->GrabFocus();
} }
break; break;
case eCreatedByEntry: case eCreatedByEntry:
{ {
ClearTextAreas(); ClearTextAreas();
OUString aCreatedByEntry( m_pFtCreatedBy->GetText() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName()); OUString aCreatedByEntry( m_xFtCreatedBy->get_label() + " " + aUserOpt.GetFirstName() + " " + aUserOpt.GetLastName());
m_pWndLeft->GetEditEngine()->SetText(aCreatedByEntry); m_xWndLeft->GetEditEngine()->SetText(aCreatedByEntry);
m_pWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) ); m_xWndCenter->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SvxDateType::Var), EE_FEATURE_FIELD) );
OUString aPageEntry( m_pFtPage->GetText() ); OUString aPageEntry( m_xFtPage->get_label() );
aPageEntry += " "; aPageEntry += " ";
m_pWndRight->GetEditEngine()->SetText(aPageEntry); m_xWndRight->GetEditEngine()->SetText(aPageEntry);
m_pWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); m_xWndRight->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
if(!bTravelling) if(!bTravelling)
m_pWndRight->GrabFocus(); m_xWndRight->GrabFocus();
} }
break; break;
@@ -735,83 +695,92 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
void ScHFEditPage::ClearTextAreas() void ScHFEditPage::ClearTextAreas()
{ {
m_pWndLeft->GetEditEngine()->SetText(EMPTY_OUSTRING); m_xWndLeft->GetEditEngine()->SetText(EMPTY_OUSTRING);
m_pWndLeft->Invalidate(); m_xWndLeft->Invalidate();
m_pWndCenter->GetEditEngine()->SetText(EMPTY_OUSTRING); m_xWndCenter->GetEditEngine()->SetText(EMPTY_OUSTRING);
m_pWndCenter->Invalidate(); m_xWndCenter->Invalidate();
m_pWndRight->GetEditEngine()->SetText(EMPTY_OUSTRING); m_xWndRight->GetEditEngine()->SetText(EMPTY_OUSTRING);
m_pWndRight->Invalidate(); m_xWndRight->Invalidate();
} }
// Handler: // Handler:
IMPL_LINK_NOARG(ScHFEditPage, ListToggleHdl_Impl, weld::ComboBox&, void)
{
m_bDropDownActive = !m_bDropDownActive;
TimeValue aNow;
osl_getSystemTime(&aNow);
m_nTimeToggled = sal_Int64(aNow.Seconds) * 1000000000L + aNow.Nanosec;
}
IMPL_LINK( ScHFEditPage, ListHdl_Impl, ListBox&, rList, void ) IMPL_LINK_NOARG(ScHFEditPage, ListHdl_Impl, weld::ComboBox&, void)
{ {
if ( &rList == m_pLbDefined ) ScHFEntryId eSel = static_cast<ScHFEntryId>(m_xLbDefined->get_active());
{
ScHFEntryId eSel = static_cast<ScHFEntryId>(m_pLbDefined->GetSelectedEntryPos());
if(!m_pLbDefined->IsTravelSelect())
{
ProcessDefinedListSel(eSel, false);
TimeValue aNow;
osl_getSystemTime(&aNow);
sal_Int64 nNow = sal_Int64(aNow.Seconds) * 1000000000L + aNow.Nanosec;
// order of dropdown vs select not guaranteed
bool bDiscrepency = m_xLbDefined->get_popup_shown() != m_bDropDownActive;
if (bDiscrepency)
ListToggleHdl_Impl(*m_xLbDefined);
bool bFocusToTarget = !m_xLbDefined->get_popup_shown() && m_nTimeToggled != -1 && (nNow - m_nTimeToggled < 800000000L);
ProcessDefinedListSel(eSel, !bFocusToTarget);
// check if we need to remove the customized entry. // check if we need to remove the customized entry.
if(eSel < eEntryCount) if (!m_bDropDownActive && eSel < eEntryCount)
RemoveFromDefinedList(); RemoveFromDefinedList();
}
else // keep balanced
{ if (bDiscrepency)
ProcessDefinedListSel(eSel, true); ListToggleHdl_Impl(*m_xLbDefined);
}
}
} }
IMPL_LINK( ScHFEditPage, ClickHdl, Button*, pBtn, void ) IMPL_LINK( ScHFEditPage, ClickHdl, weld::Button&, rBtn, void )
{ {
if (!m_pEditFocus) if (!m_pEditFocus)
return; return;
if ( pBtn == m_pBtnText ) if (&rBtn == m_xBtnText.get())
{ {
m_pEditFocus->SetCharAttributes(); m_pEditFocus->SetCharAttributes();
} }
else else
{ {
if ( pBtn == m_pBtnPage ) if ( &rBtn == m_xBtnPage.get() )
m_pEditFocus->InsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD));
else if ( pBtn == m_pBtnLastPage ) else if ( &rBtn == m_xBtnLastPage.get() )
m_pEditFocus->InsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD));
else if ( pBtn == m_pBtnDate ) else if ( &rBtn == m_xBtnDate.get() )
m_pEditFocus->InsertField(SvxFieldItem(SvxDateField(Date(Date::SYSTEM),SvxDateType::Var), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxDateField(Date(Date::SYSTEM),SvxDateType::Var), EE_FEATURE_FIELD));
else if ( pBtn == m_pBtnTime ) else if ( &rBtn == m_xBtnTime.get() )
m_pEditFocus->InsertField(SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD));
else if ( pBtn == m_pBtnFile ) else if ( &rBtn == m_xBtnFile.get() )
{ {
m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD));
} }
else if ( pBtn == m_pBtnTable ) else if ( &rBtn == m_xBtnTable.get() )
m_pEditFocus->InsertField(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD));
} }
InsertToDefinedList(); InsertToDefinedList();
m_pEditFocus->GrabFocus(); m_pEditFocus->GrabFocus();
} }
IMPL_LINK(ScHFEditPage, MenuHdl, MenuButton*, pBtn, void) IMPL_LINK(ScHFEditPage, MenuHdl, const OString&, rSelectedId, void)
{ {
if (!m_pEditFocus) if (!m_pEditFocus)
return; return;
OString sSelectedId = pBtn->GetCurItemIdent(); if (rSelectedId == "title")
if (sSelectedId == "title")
{ {
m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD)); m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD));
} }
else if (sSelectedId == "filename") else if (rSelectedId == "filename")
{ {
m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField( m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField(
OUString(), SvxFileType::Var, SvxFileFormat::NameAndExt ), EE_FEATURE_FIELD ) ); OUString(), SvxFileType::Var, SvxFileFormat::NameAndExt ), EE_FEATURE_FIELD ) );
} }
else if (sSelectedId == "pathname") else if (rSelectedId == "pathname")
{ {
m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField( m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField(
OUString(), SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) ); OUString(), SvxFileType::Var, SvxFileFormat::PathFull ), EE_FEATURE_FIELD ) );
@@ -820,7 +789,7 @@ IMPL_LINK(ScHFEditPage, MenuHdl, MenuButton*, pBtn, void)
// class ScRightHeaderEditPage // class ScRightHeaderEditPage
ScRightHeaderEditPage::ScRightHeaderEditPage( vcl::Window* pParent, const SfxItemSet& rCoreSet ) ScRightHeaderEditPage::ScRightHeaderEditPage( TabPageParent pParent, const SfxItemSet& rCoreSet )
: ScHFEditPage( pParent, : ScHFEditPage( pParent,
rCoreSet, rCoreSet,
rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT ), rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT ),
@@ -829,12 +798,12 @@ ScRightHeaderEditPage::ScRightHeaderEditPage( vcl::Window* pParent, const SfxIte
VclPtr<SfxTabPage> ScRightHeaderEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet ) VclPtr<SfxTabPage> ScRightHeaderEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet )
{ {
return VclPtr<ScRightHeaderEditPage>::Create( pParent.pParent, *rCoreSet ); return VclPtr<ScRightHeaderEditPage>::Create( pParent, *rCoreSet );
} }
// class ScLeftHeaderEditPage // class ScLeftHeaderEditPage
ScLeftHeaderEditPage::ScLeftHeaderEditPage( vcl::Window* pParent, const SfxItemSet& rCoreSet ) ScLeftHeaderEditPage::ScLeftHeaderEditPage( TabPageParent pParent, const SfxItemSet& rCoreSet )
: ScHFEditPage( pParent, : ScHFEditPage( pParent,
rCoreSet, rCoreSet,
rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT ), rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT ),
@@ -843,12 +812,12 @@ ScLeftHeaderEditPage::ScLeftHeaderEditPage( vcl::Window* pParent, const SfxItemS
VclPtr<SfxTabPage> ScLeftHeaderEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet ) VclPtr<SfxTabPage> ScLeftHeaderEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet )
{ {
return VclPtr<ScLeftHeaderEditPage>::Create( pParent.pParent, *rCoreSet ); return VclPtr<ScLeftHeaderEditPage>::Create( pParent, *rCoreSet );
} }
// class ScRightFooterEditPage // class ScRightFooterEditPage
ScRightFooterEditPage::ScRightFooterEditPage( vcl::Window* pParent, const SfxItemSet& rCoreSet ) ScRightFooterEditPage::ScRightFooterEditPage( TabPageParent pParent, const SfxItemSet& rCoreSet )
: ScHFEditPage( pParent, : ScHFEditPage( pParent,
rCoreSet, rCoreSet,
rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT ), rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT ),
@@ -857,12 +826,12 @@ ScRightFooterEditPage::ScRightFooterEditPage( vcl::Window* pParent, const SfxIte
VclPtr<SfxTabPage> ScRightFooterEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet ) VclPtr<SfxTabPage> ScRightFooterEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet )
{ {
return VclPtr<ScRightFooterEditPage>::Create( pParent.pParent, *rCoreSet ); return VclPtr<ScRightFooterEditPage>::Create( pParent, *rCoreSet );
} }
// class ScLeftFooterEditPage // class ScLeftFooterEditPage
ScLeftFooterEditPage::ScLeftFooterEditPage( vcl::Window* pParent, const SfxItemSet& rCoreSet ) ScLeftFooterEditPage::ScLeftFooterEditPage( TabPageParent pParent, const SfxItemSet& rCoreSet )
: ScHFEditPage( pParent, : ScHFEditPage( pParent,
rCoreSet, rCoreSet,
rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT ), rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT ),
@@ -871,7 +840,7 @@ ScLeftFooterEditPage::ScLeftFooterEditPage( vcl::Window* pParent, const SfxItemS
VclPtr<SfxTabPage> ScLeftFooterEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet ) VclPtr<SfxTabPage> ScLeftFooterEditPage::Create( TabPageParent pParent, const SfxItemSet* rCoreSet )
{ {
return VclPtr<ScLeftFooterEditPage>::Create( pParent.pParent, *rCoreSet ); return VclPtr<ScLeftFooterEditPage>::Create( pParent, *rCoreSet );
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -59,26 +59,39 @@ static void lcl_GetFieldData( ScHeaderFieldData& rData )
// class ScEditWindow // class ScEditWindow
ScEditWindow::ScEditWindow( vcl::Window* pParent, WinBits nBits, ScEditWindowLocation eLoc ) ScEditWindow::ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pDialog)
: Control( pParent, nBits ), : eLocation(eLoc)
eLocation(eLoc), , mbRTL(ScGlobal::IsSystemRTL())
pAcc(nullptr) , mpDialog(pDialog)
, pAcc(nullptr)
{ {
}
void ScEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
OutputDevice& rDevice = pDrawingArea->get_ref_device();
Size aSize = rDevice.LogicToPixel(Size(80, 120), MapMode(MapUnit::MapAppFont));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
SetOutputSizePixel(aSize);
weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
EnableRTL(false); EnableRTL(false);
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor(); Color aBgColor = rStyleSettings.GetWindowColor();
SetMapMode(MapMode(MapUnit::MapTwip)); rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
SetPointer( PointerStyle::Text ); rDevice.SetBackground(aBgColor);
SetBackground( aBgColor );
Size aSize( GetOutputSize() ); Size aOutputSize(rDevice.PixelToLogic(aSize));
aSize = aOutputSize;
aSize.setHeight( aSize.Height() * 4 ); aSize.setHeight( aSize.Height() * 4 );
pEdEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool() ) ); pEdEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool() ) );
pEdEngine->SetPaperSize( aSize ); pEdEngine->SetPaperSize( aSize );
pEdEngine->SetRefDevice( this ); pEdEngine->SetRefDevice( &rDevice );
ScHeaderFieldData aData; ScHeaderFieldData aData;
lcl_GetFieldData( aData ); lcl_GetFieldData( aData );
@@ -86,33 +99,34 @@ ScEditWindow::ScEditWindow( vcl::Window* pParent, WinBits nBits, ScEditWindowLoc
// fields // fields
pEdEngine->SetData( aData ); pEdEngine->SetData( aData );
pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS ); pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS );
mbRTL = ScGlobal::IsSystemRTL();
if (mbRTL) if (mbRTL)
pEdEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L); pEdEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L);
pEdView.reset( new EditView( pEdEngine.get(), this ) ); pEdView.reset(new EditView(pEdEngine.get(), nullptr));
pEdView->SetOutputArea( tools::Rectangle( Point(0,0), GetOutputSize() ) ); pEdView->setEditViewCallbacks(this);
pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
pEdView->SetBackgroundColor( aBgColor ); pEdView->SetBackgroundColor( aBgColor );
pEdEngine->InsertView( pEdView.get() ); pEdEngine->InsertView( pEdView.get() );
pDrawingArea->set_text_cursor();
if (pAcc)
pAcc->SetDescription(pDrawingArea->get_tooltip_text());
} }
void ScEditWindow::Resize() void ScEditWindow::Resize()
{ {
Size aOutputSize(GetOutputSize()); OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
Size aSize(aOutputSize); Size aSize(aOutputSize);
aSize.setHeight( aSize.Height() * 4 ); aSize.setHeight( aSize.Height() * 4 );
pEdEngine->SetPaperSize(aSize); pEdEngine->SetPaperSize(aSize);
pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize)); pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
Control::Resize(); weld::CustomWidgetController::Resize();
} }
ScEditWindow::~ScEditWindow() ScEditWindow::~ScEditWindow()
{
disposeOnce();
}
void ScEditWindow::dispose()
{ {
// delete Accessible object before deleting EditEngine and EditView // delete Accessible object before deleting EditEngine and EditView
if (pAcc) if (pAcc)
@@ -123,12 +137,6 @@ void ScEditWindow::dispose()
} }
pEdEngine.reset(); pEdEngine.reset();
pEdView.reset(); pEdView.reset();
Control::dispose();
}
extern "C" SAL_DLLPUBLIC_EXPORT void makeScEditWindow(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
{
rRet = VclPtr<ScEditWindow>::Create(pParent, WB_BORDER|WB_TABSTOP, Left);
} }
void ScEditWindow::SetNumType(SvxNumType eNumType) void ScEditWindow::SetNumType(SvxNumType eNumType)
@@ -196,9 +204,8 @@ void ScEditWindow::SetCharAttributes()
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
vcl::Window* pWin = GetParent();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScCharDlg( ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScCharDlg(
pWin ? pWin->GetFrameWeld() : nullptr, &aSet, pDocSh)); mpDialog, &aSet, pDocSh));
pDlg->SetText( ScResId( STR_TEXTATTRS ) ); pDlg->SetText( ScResId( STR_TEXTATTRS ) );
if ( pDlg->Execute() == RET_OK ) if ( pDlg->Execute() == RET_OK )
{ {
@@ -213,62 +220,81 @@ void ScEditWindow::SetCharAttributes()
void ScEditWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) void ScEditWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
{ {
//note: ClassificationEditView::Paint is similar
rRenderContext.Push(PushFlags::ALL);
rRenderContext.SetClipRegion();
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor(); Color aBgColor = rStyleSettings.GetWindowColor();
pEdView->SetBackgroundColor( aBgColor ); pEdView->SetBackgroundColor( aBgColor );
SetBackground( aBgColor ); rRenderContext.SetBackground( aBgColor );
Control::Paint(rRenderContext, rRect); tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
pEdView->Paint(aLogicRect, &rRenderContext);
pEdView->Paint(rRect);
if (HasFocus()) if (HasFocus())
pEdView->ShowCursor();
}
void ScEditWindow::MouseMove( const MouseEvent& rMEvt )
{ {
pEdView->MouseMove( rMEvt ); pEdView->ShowCursor();
vcl::Cursor* pCursor = pEdView->GetCursor();
pCursor->DrawToDevice(rRenderContext);
} }
void ScEditWindow::MouseButtonDown( const MouseEvent& rMEvt ) std::vector<tools::Rectangle> aLogicRects;
// get logic selection
pEdView->GetSelectionRectangles(aLogicRects);
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(COL_BLACK);
rRenderContext.SetRasterOp(RasterOp::Invert);
for (const auto &rSelectionRect : aLogicRects)
rRenderContext.DrawRect(rSelectionRect);
rRenderContext.Pop();
}
bool ScEditWindow::MouseMove( const MouseEvent& rMEvt )
{
return pEdView->MouseMove( rMEvt );
}
bool ScEditWindow::MouseButtonDown( const MouseEvent& rMEvt )
{ {
if ( !HasFocus() ) if ( !HasFocus() )
GrabFocus(); GrabFocus();
pEdView->MouseButtonDown( rMEvt ); return pEdView->MouseButtonDown( rMEvt );
} }
void ScEditWindow::MouseButtonUp( const MouseEvent& rMEvt ) bool ScEditWindow::MouseButtonUp( const MouseEvent& rMEvt )
{ {
pEdView->MouseButtonUp( rMEvt ); return pEdView->MouseButtonUp( rMEvt );
} }
void ScEditWindow::KeyInput( const KeyEvent& rKEvt ) bool ScEditWindow::KeyInput( const KeyEvent& rKEvt )
{ {
sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier() sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier()
+ rKEvt.GetKeyCode().GetCode(); + rKEvt.GetKeyCode().GetCode();
if ( nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT ) if ( nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT )
{ {
Control::KeyInput( rKEvt ); return false;
} }
else if ( !pEdView->PostKeyEvent( rKEvt ) ) else if ( !pEdView->PostKeyEvent( rKEvt ) )
{ {
Control::KeyInput( rKEvt ); return false;
} }
else if ( !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsShift() && else if ( !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsShift() &&
rKEvt.GetKeyCode().IsMod2() && rKEvt.GetKeyCode().GetCode() == KEY_DOWN ) rKEvt.GetKeyCode().IsMod2() && rKEvt.GetKeyCode().GetCode() == KEY_DOWN )
{ {
aObjectSelectLink.Call(*this); aObjectSelectLink.Call(*this);
return true;
} }
} return false;
void ScEditWindow::Command( const CommandEvent& rCEvt )
{
pEdView->Command( rCEvt );
} }
void ScEditWindow::GetFocus() void ScEditWindow::GetFocus()
@@ -286,7 +312,7 @@ void ScEditWindow::GetFocus()
else else
pAcc = nullptr; pAcc = nullptr;
Control::GetFocus(); weld::CustomWidgetController::GetFocus();
} }
void ScEditWindow::LoseFocus() void ScEditWindow::LoseFocus()
@@ -298,13 +324,13 @@ void ScEditWindow::LoseFocus()
} }
else else
pAcc = nullptr; pAcc = nullptr;
Control::LoseFocus(); weld::CustomWidgetController::LoseFocus();
Invalidate(); // redraw without cursor
} }
css::uno::Reference< css::accessibility::XAccessible > ScEditWindow::CreateAccessible() css::uno::Reference< css::accessibility::XAccessible > ScEditWindow::CreateAccessible()
{ {
OUString sName; OUString sName;
OUString sDescription(GetHelpText());
switch (eLocation) switch (eLocation)
{ {
case Left: case Left:
@@ -323,10 +349,13 @@ css::uno::Reference< css::accessibility::XAccessible > ScEditWindow::CreateAcces
} }
break; break;
} }
#if 0
//TODO
pAcc = new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), pEdView.get(), this, pAcc = new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), pEdView.get(), this,
sName, sDescription, ScAccessibleEditObject::EditControl); sName, OUString(), ScAccessibleEditObject::EditControl);
css::uno::Reference< css::accessibility::XAccessible > xAccessible = pAcc; css::uno::Reference< css::accessibility::XAccessible > xAccessible = pAcc;
xAcc = xAccessible; xAcc = xAccessible;
#endif
return pAcc; return pAcc;
} }

View File

@@ -2,7 +2,6 @@
<!-- Generated with glade 3.22.1 --> <!-- Generated with glade 3.22.1 -->
<interface domain="sc"> <interface domain="sc">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkImage" id="imageBTN_DATE"> <object class="GtkImage" id="imageBTN_DATE">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@@ -38,6 +37,34 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">sc/res/time.png</property> <property name="icon_name">sc/res/time.png</property>
</object> </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" context="headerfootercontent|title">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" context="headerfootercontent|filename">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" context="headerfootercontent|pathname">Path/File Name</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<object class="GtkBox" id="HeaderFooterContent"> <object class="GtkBox" id="HeaderFooterContent">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@@ -94,11 +121,24 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="sclo-ScEditWindow" id="textviewWND_LEFT"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="wrap_mode">word</property> <property name="border_width">0</property>
<property name="overwrite">True</property> <property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="textviewWND_LEFT">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
</object>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -106,9 +146,24 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="sclo-ScEditWindow" id="textviewWND_CENTER"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="border_width">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="textviewWND_CENTER">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
</object>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@@ -116,9 +171,24 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="sclo-ScEditWindow" id="textviewWND_RIGHT"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="border_width">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="textviewWND_RIGHT">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
</object>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
@@ -247,6 +317,8 @@
<property name="tooltip_text" translatable="yes" context="headerfootercontent|buttonBTN_FILE|tooltip_text">Title</property> <property name="tooltip_text" translatable="yes" context="headerfootercontent|buttonBTN_FILE|tooltip_text">Title</property>
<property name="image">imageBTN_FILE</property> <property name="image">imageBTN_FILE</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="popup">popup</property>
<property name="use_popover">False</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -487,32 +559,4 @@
</packing> </packing>
</child> </child>
</object> </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" context="headerfootercontent|title">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" context="headerfootercontent|filename">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" context="headerfootercontent|pathname">Path/File Name</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</interface> </interface>

View File

@@ -471,7 +471,6 @@ custom_widgets = [
'ScCursorRefEdit', 'ScCursorRefEdit',
'ScDataTableView', 'ScDataTableView',
'ScDoubleField', 'ScDoubleField',
'ScEditWindow',
'ScPivotLayoutTreeList', 'ScPivotLayoutTreeList',
'ScPivotLayoutTreeListData', 'ScPivotLayoutTreeListData',
'ScPivotLayoutTreeListLabel', 'ScPivotLayoutTreeListLabel',

View File

@@ -128,6 +128,8 @@ void ClassificationEditView::InvertSelectionWeight()
void ClassificationEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) void ClassificationEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{ {
//note: ScEditWindow::Paint is similar
rRenderContext.Push(PushFlags::ALL); rRenderContext.Push(PushFlags::ALL);
rRenderContext.SetClipRegion(); rRenderContext.SetClipRegion();