Kaydet (Commit) 0af04819 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxHFPage

Change-Id: I9e39e276c64da4fca01ff79ebbb42d6f342f0379
Reviewed-on: https://gerrit.libreoffice.org/55863
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5d680efb
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <sfx2/tabdlg.hxx> #include <sfx2/tabdlg.hxx>
#include <vcl/customweld.hxx>
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
#include <vcl/field.hxx> #include <vcl/field.hxx>
#include <vcl/group.hxx> #include <vcl/group.hxx>
...@@ -47,7 +48,6 @@ public: ...@@ -47,7 +48,6 @@ public:
virtual void Reset( const SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override;
virtual ~SvxHFPage() override; virtual ~SvxHFPage() override;
virtual void dispose() override;
void DisableDeleteQueryBox() { mbDisableQueryBox = true; } void DisableDeleteQueryBox() { mbDisableQueryBox = true; }
...@@ -61,37 +61,36 @@ protected: ...@@ -61,37 +61,36 @@ protected:
virtual void ActivatePage( const SfxItemSet& rSet ) override; virtual void ActivatePage( const SfxItemSet& rSet ) override;
virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
SvxHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSetId ); SvxHFPage(TabPageParent pParent, const SfxItemSet& rSet, sal_uInt16 nSetId);
VclPtr<FixedText> m_pPageLbl;
VclPtr<CheckBox> m_pTurnOnBox;
VclPtr<CheckBox> m_pCntSharedBox;
VclPtr<CheckBox> m_pCntSharedFirstBox;
VclPtr<FixedText> m_pLMLbl;
VclPtr<MetricField> m_pLMEdit;
VclPtr<FixedText> m_pRMLbl;
VclPtr<MetricField> m_pRMEdit;
VclPtr<FixedText> m_pDistFT;
VclPtr<MetricField> m_pDistEdit;
VclPtr<CheckBox> m_pDynSpacingCB;
VclPtr<FixedText> m_pHeightFT;
VclPtr<MetricField> m_pHeightEdit;
VclPtr<CheckBox> m_pHeightDynBtn;
VclPtr<SvxPageWindow> m_pBspWin;
VclPtr<PushButton> m_pBackgroundBtn;
sal_uInt16 nId; sal_uInt16 nId;
std::unique_ptr<SfxItemSet> pBBSet; std::unique_ptr<SfxItemSet> pBBSet;
bool mbDisableQueryBox : 1; bool mbDisableQueryBox : 1;
bool mbEnableDrawingLayerFillStyles : 1; bool mbEnableDrawingLayerFillStyles : 1;
PageWindow m_aBspWin;
std::unique_ptr<weld::Label> m_xPageLbl;
std::unique_ptr<weld::CheckButton> m_xTurnOnBox;
std::unique_ptr<weld::CheckButton> m_xCntSharedBox;
std::unique_ptr<weld::CheckButton> m_xCntSharedFirstBox;
std::unique_ptr<weld::Label> m_xLMLbl;
std::unique_ptr<weld::MetricSpinButton>m_xLMEdit;
std::unique_ptr<weld::Label> m_xRMLbl;
std::unique_ptr<weld::MetricSpinButton> m_xRMEdit;
std::unique_ptr<weld::Label> m_xDistFT;
std::unique_ptr<weld::MetricSpinButton> m_xDistEdit;
std::unique_ptr<weld::CheckButton> m_xDynSpacingCB;
std::unique_ptr<weld::Label> m_xHeightFT;
std::unique_ptr<weld::MetricSpinButton> m_xHeightEdit;
std::unique_ptr<weld::CheckButton> m_xHeightDynBtn;
std::unique_ptr<weld::Button> m_xBackgroundBtn;
std::unique_ptr<weld::CustomWeld> m_xBspWin;
void InitHandler(); void InitHandler();
DECL_LINK(TurnOnHdl, Button*, void); void TurnOn(weld::ToggleButton* pButton);
DECL_LINK(DistModify, Edit&, void); DECL_LINK(TurnOnHdl, weld::ToggleButton&, void);
DECL_LINK(HeightModify, Edit&, void); DECL_LINK(BackgroundHdl, weld::Button&, void);
DECL_LINK(BorderModify, Edit&, void); DECL_LINK(ValueChangeHdl, weld::MetricSpinButton&, void);
DECL_LINK(BackgroundHdl, Button*, void);
DECL_LINK(RangeFocusHdl, Control&, void);
void RangeHdl(); void RangeHdl();
void UpdateExample(); void UpdateExample();
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#ifndef INCLUDED_SVX_PAGECTRL_HXX #ifndef INCLUDED_SVX_PAGECTRL_HXX
#define INCLUDED_SVX_PAGECTRL_HXX #define INCLUDED_SVX_PAGECTRL_HXX
#include <vcl/customweld.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <svx/sdr/attribute/sdrallfillattributeshelper.hxx> #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
...@@ -152,6 +153,128 @@ public: ...@@ -152,6 +153,128 @@ public:
virtual Size GetOptimalSize() const override; virtual Size GetOptimalSize() const override;
}; };
class SVX_DLLPUBLIC PageWindow : public weld::CustomWidgetController
{
private:
Size aWinSize;
Size aSize;
long nTop;
long nBottom;
long nLeft;
long nRight;
bool bResetBackground;
bool bFrameDirection;
SvxFrameDirection nFrameDirection;
long nHdLeft;
long nHdRight;
long nHdDist;
long nHdHeight;
long nFtLeft;
long nFtRight;
long nFtDist;
long nFtHeight;
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maHeaderFillAttributes;
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFooterFillAttributes;
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maPageFillAttributes;
bool bFooter : 1;
bool bHeader : 1;
bool bTable : 1;
bool bHorz : 1;
bool bVert : 1;
SvxPageUsage eUsage;
protected:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
virtual void DrawPage(vcl::RenderContext& rRenderContext, const Point& rPoint,
const bool bSecond, const bool bEnabled);
void drawFillAttributes(vcl::RenderContext& rRenderContext,
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
const tools::Rectangle& rPaintRange, const tools::Rectangle& rDefineRange);
public:
PageWindow();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~PageWindow() override;
void setHeaderFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes)
{
maHeaderFillAttributes = rFillAttributes;
}
void setFooterFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes)
{
maFooterFillAttributes = rFillAttributes;
}
void setPageFillAttributes(const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes)
{
maPageFillAttributes = rFillAttributes;
}
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& getPageFillAttributes() const
{
return maPageFillAttributes;
}
void SetSize(const Size& rSize)
{
aSize = rSize;
}
const Size& GetSize() const
{
return aSize;
}
void SetTop(long nNew) { nTop = nNew; }
void SetBottom(long nNew) { nBottom = nNew; }
void SetLeft(long nNew) { nLeft = nNew; }
void SetRight(long nNew) { nRight = nNew; }
long GetTop() const { return nTop; }
long GetBottom() const { return nBottom; }
long GetLeft() const { return nLeft; }
long GetRight() const { return nRight; }
void SetHdLeft(long nNew) { nHdLeft = nNew; }
void SetHdRight(long nNew) { nHdRight = nNew; }
void SetHdDist(long nNew) { nHdDist = nNew; }
void SetHdHeight(long nNew) { nHdHeight = nNew; }
long GetHdLeft() const { return nHdLeft; }
long GetHdRight() const { return nHdRight; }
long GetHdDist() const { return nHdDist; }
long GetHdHeight() const { return nHdHeight; }
void SetFtLeft(long nNew) { nFtLeft = nNew; }
void SetFtRight(long nNew) { nFtRight = nNew; }
void SetFtDist(long nNew) { nFtDist = nNew; }
void SetFtHeight(long nNew) { nFtHeight = nNew; }
long GetFtLeft() const { return nFtLeft; }
long GetFtRight() const { return nFtRight; }
long GetFtDist() const { return nFtDist; }
long GetFtHeight() const { return nFtHeight; }
void SetUsage(SvxPageUsage eU) { eUsage = eU; }
SvxPageUsage GetUsage() const { return eUsage; }
void SetHeader( bool bNew ) { bHeader = bNew; }
void SetFooter( bool bNew ) { bFooter = bNew; }
void SetTable( bool bNew ) { bTable = bNew; }
void SetHorz( bool bNew ) { bHorz = bNew; }
void SetVert( bool bNew ) { bVert = bNew; }
void EnableFrameDirection(bool bEnable);
void SetFrameDirection(SvxFrameDirection nDirection);
void ResetBackground();
};
#endif // INCLUDED_SVX_PAGECTRL_HXX #endif // INCLUDED_SVX_PAGECTRL_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -37,9 +37,7 @@ public: ...@@ -37,9 +37,7 @@ public:
void SetStyleDlg ( ScStyleDlg* pDlg ) { pStyleDlg = pDlg; } void SetStyleDlg ( ScStyleDlg* pDlg ) { pStyleDlg = pDlg; }
protected: protected:
ScHFPage( vcl::Window* pParent, ScHFPage(TabPageParent pParent, const SfxItemSet& rSet, sal_uInt16 nSetId);
const SfxItemSet& rSet,
sal_uInt16 nSetId );
virtual void ActivatePage() override; virtual void ActivatePage() override;
virtual void DeactivatePage() override; virtual void DeactivatePage() override;
...@@ -47,15 +45,15 @@ protected: ...@@ -47,15 +45,15 @@ protected:
virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
private: private:
VclPtr<PushButton> m_pBtnEdit;
SfxItemSet aDataSet; SfxItemSet aDataSet;
OUString aStrPageStyle; OUString aStrPageStyle;
SvxPageUsage nPageUsage; SvxPageUsage nPageUsage;
VclPtr<ScStyleDlg> pStyleDlg; VclPtr<ScStyleDlg> pStyleDlg;
std::unique_ptr<weld::Button> m_xBtnEdit;
DECL_LINK( BtnHdl, Button*, void ); DECL_LINK(BtnHdl, weld::Button&, void);
DECL_LINK( HFEditHdl, void*, void ); DECL_LINK( HFEditHdl, void*, void );
DECL_LINK( TurnOnHdl, Button*, void ); DECL_LINK(TurnOnHdl, weld::ToggleButton&, void);
}; };
class ScHeaderPage : public ScHFPage class ScHeaderPage : public ScHFPage
......
...@@ -41,24 +41,18 @@ ...@@ -41,24 +41,18 @@
// class ScHFPage // class ScHFPage
ScHFPage::ScHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSetId ) ScHFPage::ScHFPage(TabPageParent pParent, const SfxItemSet& rSet, sal_uInt16 nSetId)
: SvxHFPage(pParent, rSet, nSetId)
: SvxHFPage ( pParent, rSet, nSetId ), , aDataSet(*rSet.GetPool(), svl::Items<ATTR_PAGE, ATTR_PAGE, ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT>{})
aDataSet( , nPageUsage(SvxPageUsage::All)
*rSet.GetPool(), , pStyleDlg(nullptr)
svl::Items< , m_xBtnEdit(m_xBuilder->weld_button("buttonEdit"))
ATTR_PAGE, ATTR_PAGE,
ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT>{}),
nPageUsage ( SvxPageUsage::All ),
pStyleDlg ( nullptr )
{ {
get(m_pBtnEdit, "buttonEdit");
SetExchangeSupport(); SetExchangeSupport();
SfxViewShell* pSh = SfxViewShell::Current(); SfxViewShell* pSh = SfxViewShell::Current();
ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( pSh ); ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( pSh );
m_pBtnEdit->Show(); m_xBtnEdit->show();
aDataSet.Put( rSet ); aDataSet.Put( rSet );
...@@ -70,13 +64,13 @@ ScHFPage::ScHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSe ...@@ -70,13 +64,13 @@ ScHFPage::ScHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSe
aStrPageStyle = pDoc->GetPageStyle( rViewData.GetTabNo() ); aStrPageStyle = pDoc->GetPageStyle( rViewData.GetTabNo() );
} }
m_pBtnEdit->SetClickHdl ( LINK( this, ScHFPage, BtnHdl ) ); m_xBtnEdit->connect_clicked(LINK(this, ScHFPage, BtnHdl));
m_pTurnOnBox->SetClickHdl ( LINK( this, ScHFPage, TurnOnHdl ) ); m_xTurnOnBox->connect_toggled(LINK(this, ScHFPage, TurnOnHdl));
if ( nId == SID_ATTR_PAGE_HEADERSET ) if ( nId == SID_ATTR_PAGE_HEADERSET )
m_pBtnEdit->SetHelpId( HID_SC_HEADER_EDIT ); m_xBtnEdit->set_help_id(HID_SC_HEADER_EDIT);
else else
m_pBtnEdit->SetHelpId( HID_SC_FOOTER_EDIT ); m_xBtnEdit->set_help_id(HID_SC_FOOTER_EDIT);
} }
ScHFPage::~ScHFPage() ScHFPage::~ScHFPage()
...@@ -86,7 +80,6 @@ ScHFPage::~ScHFPage() ...@@ -86,7 +80,6 @@ ScHFPage::~ScHFPage()
void ScHFPage::dispose() void ScHFPage::dispose()
{ {
m_pBtnEdit.clear();
pStyleDlg.clear(); pStyleDlg.clear();
SvxHFPage::dispose(); SvxHFPage::dispose();
} }
...@@ -94,7 +87,7 @@ void ScHFPage::dispose() ...@@ -94,7 +87,7 @@ void ScHFPage::dispose()
void ScHFPage::Reset( const SfxItemSet* rSet ) void ScHFPage::Reset( const SfxItemSet* rSet )
{ {
SvxHFPage::Reset( rSet ); SvxHFPage::Reset( rSet );
TurnOnHdl( nullptr ); TurnOnHdl(*m_xTurnOnBox);
} }
bool ScHFPage::FillItemSet( SfxItemSet* rOutSet ) bool ScHFPage::FillItemSet( SfxItemSet* rOutSet )
...@@ -150,17 +143,17 @@ void ScHFPage::DeactivatePage() ...@@ -150,17 +143,17 @@ void ScHFPage::DeactivatePage()
// Handler: // Handler:
IMPL_LINK_NOARG(ScHFPage, TurnOnHdl, Button*, void) IMPL_LINK_NOARG(ScHFPage, TurnOnHdl, weld::ToggleButton&, void)
{ {
SvxHFPage::TurnOnHdl( m_pTurnOnBox ); SvxHFPage::TurnOnHdl(*m_xTurnOnBox);
if ( m_pTurnOnBox->IsChecked() ) if (m_xTurnOnBox->get_active())
m_pBtnEdit->Enable(); m_xBtnEdit->set_sensitive(true);
else else
m_pBtnEdit->Disable(); m_xBtnEdit->set_sensitive(false);
} }
IMPL_LINK_NOARG(ScHFPage, BtnHdl, Button*, void) IMPL_LINK_NOARG(ScHFPage, BtnHdl, weld::Button&, void)
{ {
// When the Edit-Dialog is directly called from the Button's Click-Handler, // When the Edit-Dialog is directly called from the Button's Click-Handler,
// the GrabFocus from the Edit-Dialog under OS/2 doesn't work.(Bug #41805#). // the GrabFocus from the Edit-Dialog under OS/2 doesn't work.(Bug #41805#).
...@@ -179,8 +172,7 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl, void*, void) ...@@ -179,8 +172,7 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl, void*, void)
return; return;
} }
if ( m_pCntSharedBox->IsEnabled() if (m_xCntSharedBox->get_sensitive() && !m_xCntSharedBox->get_active())
&& !m_pCntSharedBox->IsChecked() )
{ {
sal_uInt16 nResId = ( nId == SID_ATTR_PAGE_HEADERSET ) sal_uInt16 nResId = ( nId == SID_ATTR_PAGE_HEADERSET )
? RID_SCDLG_HFED_HEADER ? RID_SCDLG_HFED_HEADER
...@@ -200,8 +192,7 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl, void*, void) ...@@ -200,8 +192,7 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl, void*, void)
{ {
OUString aText; OUString aText;
VclPtrInstance< SfxSingleTabDialog > pDlg(this, aDataSet); VclPtrInstance< SfxSingleTabDialog > pDlg(this, aDataSet);
bool bRightPage = m_pCntSharedBox->IsChecked() bool bRightPage = m_xCntSharedBox->get_active() || (SvxPageUsage::Left != nPageUsage);
|| ( SvxPageUsage::Left != nPageUsage );
if ( nId == SID_ATTR_PAGE_HEADERSET ) if ( nId == SID_ATTR_PAGE_HEADERSET )
{ {
......
...@@ -130,99 +130,72 @@ SvxFooterPage::SvxFooterPage( vcl::Window* pParent, const SfxItemSet& rAttr ) : ...@@ -130,99 +130,72 @@ SvxFooterPage::SvxFooterPage( vcl::Window* pParent, const SfxItemSet& rAttr ) :
{ {
} }
SvxHFPage::SvxHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSetId ) : SvxHFPage::SvxHFPage(TabPageParent pParent, const SfxItemSet& rSet, sal_uInt16 nSetId)
SfxTabPage(pParent, "HFFormatPage", "svx/ui/headfootformatpage.ui", &rSet), : SfxTabPage(pParent, "svx/ui/headfootformatpage.ui", "HFFormatPage", &rSet)
nId(nSetId), , nId(nSetId)
pBBSet(nullptr), , pBBSet(nullptr)
mbDisableQueryBox(false), , mbDisableQueryBox(false)
mbEnableDrawingLayerFillStyles(false) , mbEnableDrawingLayerFillStyles(false)
, m_xCntSharedBox(m_xBuilder->weld_check_button("checkSameLR"))
, m_xCntSharedFirstBox(m_xBuilder->weld_check_button("checkSameFP"))
, m_xLMLbl(m_xBuilder->weld_label("labelLeftMarg"))
, m_xLMEdit(m_xBuilder->weld_metric_spin_button("spinMargLeft", FUNIT_CM))
, m_xRMLbl(m_xBuilder->weld_label("labelRightMarg"))
, m_xRMEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FUNIT_CM))
, m_xDistFT(m_xBuilder->weld_label("labelSpacing"))
, m_xDistEdit(m_xBuilder->weld_metric_spin_button("spinSpacing", FUNIT_CM))
, m_xDynSpacingCB(m_xBuilder->weld_check_button("checkDynSpacing"))
, m_xHeightFT(m_xBuilder->weld_label("labelHeight"))
, m_xHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FUNIT_CM))
, m_xHeightDynBtn(m_xBuilder->weld_check_button("checkAutofit"))
, m_xBackgroundBtn(m_xBuilder->weld_button("buttonMore"))
, m_xBspWin(new weld::CustomWeld(*m_xBuilder, "drawingareaPageHF", m_aBspWin))
{ {
get(m_pCntSharedBox,"checkSameLR");
get(m_pCntSharedFirstBox,"checkSameFP");
get(m_pLMEdit,"spinMargLeft");
get(m_pLMLbl,"labelLeftMarg");
get(m_pRMEdit,"spinMargRight");
get(m_pRMLbl,"labelRightMarg");
get(m_pDistEdit,"spinSpacing");
get(m_pDistFT,"labelSpacing");
get(m_pDynSpacingCB,"checkDynSpacing");
get(m_pHeightFT,"labelHeight");
get(m_pHeightEdit,"spinHeight");
get(m_pHeightDynBtn,"checkAutofit");
get(m_pBspWin,"drawingareaPageHF");
get(m_pBackgroundBtn,"buttonMore");
//swap header <-> footer in UI //swap header <-> footer in UI
if(nId == SID_ATTR_PAGE_FOOTERSET) if (nId == SID_ATTR_PAGE_FOOTERSET)
{ {
get(m_pPageLbl,"labelFooterFormat"); m_xPageLbl.reset(m_xBuilder->weld_label("labelFooterFormat"));
get(m_pTurnOnBox, "checkFooterOn"); m_xTurnOnBox.reset(m_xBuilder->weld_check_button("checkFooterOn"));
/* Set custom HIDs for the Footer help page (shared/01/05040400.xhp) /* Set custom HIDs for the Footer help page (shared/01/05040400.xhp)
otherwise it would display the same extended help otherwise it would display the same extended help
on both the Header and Footer tabs */ on both the Header and Footer tabs */
m_pCntSharedBox->SetHelpId( "SVX_HID_FOOTER_CHECKSAMELR" ); m_xCntSharedBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMELR" );
m_pCntSharedFirstBox->SetHelpId( "SVX_HID_FOOTER_CHECKSAMEFP" ); m_xCntSharedFirstBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMEFP" );
m_pLMEdit->SetHelpId( "SVX_HID_FOOTER_SPINMARGLEFT" ); m_xLMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGLEFT" );
m_pRMEdit->SetHelpId( "SVX_HID_FOOTER_SPINMARGRIGHT" ); m_xRMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGRIGHT" );
m_pDistEdit->SetHelpId( "SVX_HID_FOOTER_SPINSPACING" ); m_xDistEdit->set_help_id( "SVX_HID_FOOTER_SPINSPACING" );
m_pDynSpacingCB->SetHelpId( "SVX_HID_FOOTER_CHECKDYNSPACING" ); m_xDynSpacingCB->set_help_id( "SVX_HID_FOOTER_CHECKDYNSPACING" );
m_pHeightEdit->SetHelpId( "SVX_HID_FOOTER_SPINHEIGHT" ); m_xHeightEdit->set_help_id( "SVX_HID_FOOTER_SPINHEIGHT" );
m_pHeightDynBtn->SetHelpId( "SVX_HID_FOOTER_CHECKAUTOFIT" ); m_xHeightDynBtn->set_help_id( "SVX_HID_FOOTER_CHECKAUTOFIT" );
m_pBackgroundBtn->SetHelpId( "SVX_HID_FOOTER_BUTTONMORE" ); m_xBackgroundBtn->set_help_id( "SVX_HID_FOOTER_BUTTONMORE" );
} }
else //Header else //Header
{ {
get(m_pPageLbl,"labelHeaderFormat"); m_xPageLbl.reset(m_xBuilder->weld_label("labelHeaderFormat"));
get(m_pTurnOnBox, "checkHeaderOn"); m_xTurnOnBox.reset(m_xBuilder->weld_check_button("checkHeaderOn"));
} }
m_pTurnOnBox->Show(); m_xTurnOnBox->show();
m_pPageLbl->Show(); m_xPageLbl->show();
InitHandler(); InitHandler();
m_pBspWin->EnableRTL( false ); m_aBspWin.EnableRTL(false);
// This Page needs ExchangeSupport // This Page needs ExchangeSupport
SetExchangeSupport(); SetExchangeSupport();
// Set metrics // Set metrics
FieldUnit eFUnit = GetModuleFieldUnit( rSet ); FieldUnit eFUnit = GetModuleFieldUnit( rSet );
SetFieldUnit( *m_pDistEdit, eFUnit ); SetFieldUnit( *m_xDistEdit, eFUnit );
SetFieldUnit( *m_pHeightEdit, eFUnit ); SetFieldUnit( *m_xHeightEdit, eFUnit );
SetFieldUnit( *m_pLMEdit, eFUnit ); SetFieldUnit( *m_xLMEdit, eFUnit );
SetFieldUnit( *m_pRMEdit, eFUnit ); SetFieldUnit( *m_xRMEdit, eFUnit );
} }
SvxHFPage::~SvxHFPage() SvxHFPage::~SvxHFPage()
{ {
disposeOnce();
}
void SvxHFPage::dispose()
{
pBBSet.reset();
m_pPageLbl.clear();
m_pTurnOnBox.clear();
m_pCntSharedBox.clear();
m_pCntSharedFirstBox.clear();
m_pLMLbl.clear();
m_pLMEdit.clear();
m_pRMLbl.clear();
m_pRMEdit.clear();
m_pDistFT.clear();
m_pDistEdit.clear();
m_pDynSpacingCB.clear();
m_pHeightFT.clear();
m_pHeightEdit.clear();
m_pHeightDynBtn.clear();
m_pBspWin.clear();
m_pBackgroundBtn.clear();
SfxTabPage::dispose();
} }
bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
{ {
const sal_uInt16 nWSize = GetWhich(SID_ATTR_PAGE_SIZE); const sal_uInt16 nWSize = GetWhich(SID_ATTR_PAGE_SIZE);
...@@ -271,23 +244,23 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) ...@@ -271,23 +244,23 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
aSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
} }
aSet.Put( SfxBoolItem( nWOn, m_pTurnOnBox->IsChecked() ) ); aSet.Put( SfxBoolItem( nWOn, m_xTurnOnBox->get_active() ) );
aSet.Put( SfxBoolItem( nWDynamic, m_pHeightDynBtn->IsChecked() ) ); aSet.Put( SfxBoolItem( nWDynamic, m_xHeightDynBtn->get_active() ) );
aSet.Put( SfxBoolItem( nWShared, m_pCntSharedBox->IsChecked() ) ); aSet.Put( SfxBoolItem( nWShared, m_xCntSharedBox->get_active() ) );
if(m_pCntSharedFirstBox->IsVisible()) if(m_xCntSharedFirstBox->get_visible())
aSet.Put( SfxBoolItem( nWSharedFirst, m_pCntSharedFirstBox->IsChecked() ) ); aSet.Put(SfxBoolItem(nWSharedFirst, m_xCntSharedFirstBox->get_active()));
if (m_pDynSpacingCB->IsVisible() && SfxItemPool::IsWhich(nWDynSpacing)) if (m_xDynSpacingCB->get_visible() && SfxItemPool::IsWhich(nWDynSpacing))
{ {
std::unique_ptr<SfxBoolItem> pBoolItem(static_cast<SfxBoolItem*>(pPool->GetDefaultItem(nWDynSpacing).Clone())); std::unique_ptr<SfxBoolItem> pBoolItem(static_cast<SfxBoolItem*>(pPool->GetDefaultItem(nWDynSpacing).Clone()));
pBoolItem->SetValue(m_pDynSpacingCB->IsChecked()); pBoolItem->SetValue(m_xDynSpacingCB->get_active());
aSet.Put(*pBoolItem); aSet.Put(*pBoolItem);
} }
// Size // Size
SvxSizeItem aSizeItem( static_cast<const SvxSizeItem&>(rOldSet.Get( nWSize )) ); SvxSizeItem aSizeItem( static_cast<const SvxSizeItem&>(rOldSet.Get( nWSize )) );
Size aSize( aSizeItem.GetSize() ); Size aSize( aSizeItem.GetSize() );
long nDist = GetCoreValue( *m_pDistEdit, eUnit ); long nDist = GetCoreValue( *m_xDistEdit, eUnit );
long nH = GetCoreValue( *m_pHeightEdit, eUnit ); long nH = GetCoreValue( *m_xHeightEdit, eUnit );
nH += nDist; // add distance nH += nDist; // add distance
aSize.setHeight( nH ); aSize.setHeight( nH );
...@@ -296,8 +269,8 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) ...@@ -296,8 +269,8 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
// Margins // Margins
SvxLRSpaceItem aLR( nWLRSpace ); SvxLRSpaceItem aLR( nWLRSpace );
aLR.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_pLMEdit, eUnit )) ); aLR.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_xLMEdit, eUnit )) );
aLR.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_pRMEdit, eUnit )) ); aLR.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_xRMEdit, eUnit )) );
aSet.Put( aLR ); aSet.Put( aLR );
SvxULSpaceItem aUL( nWULSpace ); SvxULSpaceItem aUL( nWULSpace );
...@@ -374,7 +347,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -374,7 +347,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
const SfxPoolItem* pExt2 = GetItem(*rSet, SID_ATTR_PAGE_EXT2); const SfxPoolItem* pExt2 = GetItem(*rSet, SID_ATTR_PAGE_EXT2);
if (pExt1 && dynamic_cast<const SfxBoolItem*>(pExt1) != nullptr && pExt2 && dynamic_cast<const SfxBoolItem*>(pExt2) != nullptr ) if (pExt1 && dynamic_cast<const SfxBoolItem*>(pExt1) != nullptr && pExt2 && dynamic_cast<const SfxBoolItem*>(pExt2) != nullptr )
bIsCalc = true; bIsCalc = true;
m_pCntSharedFirstBox->Show(!bIsCalc); m_xCntSharedFirstBox->show(!bIsCalc);
// Evaluate header-/footer- attributes // Evaluate header-/footer- attributes
const SvxSetItem* pSetItem = nullptr; const SvxSetItem* pSetItem = nullptr;
...@@ -386,7 +359,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -386,7 +359,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
const SfxBoolItem& rHeaderOn = const SfxBoolItem& rHeaderOn =
static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON))); static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
m_pTurnOnBox->Check(rHeaderOn.GetValue()); m_xTurnOnBox->set_active(rHeaderOn.GetValue());
if ( rHeaderOn.GetValue() ) if ( rHeaderOn.GetValue() )
{ {
...@@ -403,33 +376,33 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -403,33 +376,33 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
static_cast<const SvxULSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); static_cast<const SvxULSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
const SvxLRSpaceItem& rLR = const SvxLRSpaceItem& rLR =
static_cast<const SvxLRSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); static_cast<const SvxLRSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
if(m_pDynSpacingCB->IsVisible()) if (m_xDynSpacingCB->get_visible())
{ {
const SfxBoolItem& rDynSpacing = const SfxBoolItem& rDynSpacing =
static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING))); static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING)));
m_pDynSpacingCB->Check(rDynSpacing.GetValue()); m_xDynSpacingCB->set_active(rDynSpacing.GetValue());
} }
if ( nId == SID_ATTR_PAGE_HEADERSET ) if ( nId == SID_ATTR_PAGE_HEADERSET )
{ // Header { // Header
SetMetricValue( *m_pDistEdit, rUL.GetLower(), eUnit ); SetMetricValue( *m_xDistEdit, rUL.GetLower(), eUnit );
SetMetricValue( *m_pHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit ); SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit );
} }
else else
{ // Footer { // Footer
SetMetricValue( *m_pDistEdit, rUL.GetUpper(), eUnit ); SetMetricValue( *m_xDistEdit, rUL.GetUpper(), eUnit );
SetMetricValue( *m_pHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit ); SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit );
} }
m_pHeightDynBtn->Check(rDynamic.GetValue()); m_xHeightDynBtn->set_active(rDynamic.GetValue());
SetMetricValue( *m_pLMEdit, rLR.GetLeft(), eUnit ); SetMetricValue( *m_xLMEdit, rLR.GetLeft(), eUnit );
SetMetricValue( *m_pRMEdit, rLR.GetRight(), eUnit ); SetMetricValue( *m_xRMEdit, rLR.GetRight(), eUnit );
m_pCntSharedBox->Check(rShared.GetValue()); m_xCntSharedBox->set_active(rShared.GetValue());
if (pSharedFirst) if (pSharedFirst)
m_pCntSharedFirstBox->Check(pSharedFirst->GetValue()); m_xCntSharedFirstBox->set_active(pSharedFirst->GetValue());
else else
m_pCntSharedFirstBox->Hide(); m_xCntSharedFirstBox->hide();
} }
else else
pSetItem = nullptr; pSetItem = nullptr;
...@@ -438,27 +411,27 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -438,27 +411,27 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
{ {
// defaults for distance and height // defaults for distance and height
long nDefaultDist = bIsCalc ? DEF_DIST_CALC : DEF_DIST_WRITER; long nDefaultDist = bIsCalc ? DEF_DIST_CALC : DEF_DIST_WRITER;
SetMetricValue( *m_pDistEdit, nDefaultDist, MapUnit::Map100thMM ); SetMetricValue( *m_xDistEdit, nDefaultDist, MapUnit::Map100thMM );
SetMetricValue( *m_pHeightEdit, 500, MapUnit::Map100thMM ); SetMetricValue( *m_xHeightEdit, 500, MapUnit::Map100thMM );
} }
if ( !pSetItem ) if ( !pSetItem )
{ {
m_pTurnOnBox->Check( false ); m_xTurnOnBox->set_active(false);
m_pHeightDynBtn->Check(); m_xHeightDynBtn->set_active(true);
m_pCntSharedBox->Check(); m_xCntSharedBox->set_active(true);
m_pCntSharedFirstBox->Check(); m_xCntSharedFirstBox->set_active(true);
} }
TurnOnHdl(nullptr); TurnOn(nullptr);
m_pTurnOnBox->SaveValue(); m_xTurnOnBox->save_state();
m_pDistEdit->SaveValue(); m_xDistEdit->save_value();
m_pHeightEdit->SaveValue(); m_xHeightEdit->save_value();
m_pHeightDynBtn->SaveValue(); m_xHeightDynBtn->save_state();
m_pLMEdit->SaveValue(); m_xLMEdit->save_value();
m_pRMEdit->SaveValue(); m_xRMEdit->save_value();
m_pCntSharedBox->SaveValue(); m_xCntSharedBox->save_state();
RangeHdl(); RangeHdl();
const SfxPoolItem* pItem = nullptr; const SfxPoolItem* pItem = nullptr;
...@@ -469,10 +442,10 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -469,10 +442,10 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
{ {
sal_uInt16 nHtmlMode = 0; sal_uInt16 nHtmlMode = 0;
nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
if(nHtmlMode & HTMLMODE_ON) if (nHtmlMode & HTMLMODE_ON)
{ {
m_pCntSharedBox->Hide(); m_xCntSharedBox->hide();
m_pBackgroundBtn->Hide(); m_xBackgroundBtn->hide();
} }
} }
...@@ -480,52 +453,46 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) ...@@ -480,52 +453,46 @@ void SvxHFPage::Reset( const SfxItemSet* rSet )
void SvxHFPage::InitHandler() void SvxHFPage::InitHandler()
{ {
m_pTurnOnBox->SetClickHdl(LINK(this, SvxHFPage, TurnOnHdl)); m_xTurnOnBox->connect_toggled(LINK(this, SvxHFPage, TurnOnHdl));
m_pDistEdit->SetModifyHdl(LINK(this, SvxHFPage, DistModify)); m_xDistEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
m_pDistEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl)); m_xHeightEdit->connect_value_changed(LINK(this,SvxHFPage,ValueChangeHdl));
m_pHeightEdit->SetModifyHdl(LINK(this, SvxHFPage, HeightModify)); m_xLMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
m_pHeightEdit->SetLoseFocusHdl(LINK(this,SvxHFPage,RangeFocusHdl)); m_xRMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
m_xBackgroundBtn->connect_clicked(LINK(this,SvxHFPage, BackgroundHdl));
m_pLMEdit->SetModifyHdl(LINK(this, SvxHFPage, BorderModify));
m_pLMEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl));
m_pRMEdit->SetModifyHdl(LINK(this, SvxHFPage, BorderModify));
m_pRMEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl));
m_pBackgroundBtn->SetClickHdl(LINK(this,SvxHFPage, BackgroundHdl));
} }
IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void ) void SvxHFPage::TurnOn(weld::ToggleButton* pBox)
{ {
CheckBox* pBox = static_cast<CheckBox*>(pButton); if (m_xTurnOnBox->get_active())
if ( m_pTurnOnBox->IsChecked() )
{ {
m_pDistFT->Enable(); m_xDistFT->set_sensitive(true);
m_pDistEdit->Enable(); m_xDistEdit->set_sensitive(true);
m_pDynSpacingCB->Enable(); m_xDynSpacingCB->set_sensitive(true);
m_pHeightFT->Enable(); m_xHeightFT->set_sensitive(true);
m_pHeightEdit->Enable(); m_xHeightEdit->set_sensitive(true);
m_pHeightDynBtn->Enable(); m_xHeightDynBtn->set_sensitive(true);
m_pLMLbl->Enable(); m_xLMLbl->set_sensitive(true);
m_pLMEdit->Enable(); m_xLMEdit->set_sensitive(true);
m_pRMLbl->Enable(); m_xRMLbl->set_sensitive(true);
m_pRMEdit->Enable(); m_xRMEdit->set_sensitive(true);
SvxPageUsage nUsage = m_pBspWin->GetUsage(); SvxPageUsage nUsage = m_aBspWin.GetUsage();
if( nUsage == SvxPageUsage::Right || nUsage == SvxPageUsage::Left ) if( nUsage == SvxPageUsage::Right || nUsage == SvxPageUsage::Left )
m_pCntSharedBox->Disable(); m_xCntSharedBox->set_sensitive(false);
else else
{ {
m_pCntSharedBox->Enable(); m_xCntSharedBox->set_sensitive(true);
m_pCntSharedFirstBox->Enable(); m_xCntSharedFirstBox->set_sensitive(true);
} }
m_pBackgroundBtn->Enable(); m_xBackgroundBtn->set_sensitive(true);
} }
else else
{ {
bool bDelete = true; bool bDelete = true;
if ( !mbDisableQueryBox && pBox && m_pTurnOnBox->GetSavedValue() == TRISTATE_TRUE ) if (!mbDisableQueryBox && pBox && m_xTurnOnBox->get_saved_state() == TRISTATE_TRUE)
{ {
short nResult; short nResult;
if (nId == SID_ATTR_PAGE_HEADERSET) if (nId == SID_ATTR_PAGE_HEADERSET)
...@@ -543,44 +510,34 @@ IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void ) ...@@ -543,44 +510,34 @@ IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void )
if ( bDelete ) if ( bDelete )
{ {
m_pDistFT->Disable(); m_xDistFT->set_sensitive(false);
m_pDistEdit->Disable(); m_xDistEdit->set_sensitive(false);
m_pDynSpacingCB->Enable(false); m_xDynSpacingCB->set_sensitive(false);
m_pHeightFT->Disable(); m_xHeightFT->set_sensitive(false);
m_pHeightEdit->Disable(); m_xHeightEdit->set_sensitive(false);
m_pHeightDynBtn->Disable(); m_xHeightDynBtn->set_sensitive(false);
m_pLMLbl->Disable(); m_xLMLbl->set_sensitive(false);
m_pLMEdit->Disable(); m_xLMEdit->set_sensitive(false);
m_pRMLbl->Disable(); m_xRMLbl->set_sensitive(false);
m_pRMEdit->Disable(); m_xRMEdit->set_sensitive(false);
m_pCntSharedBox->Disable(); m_xCntSharedBox->set_sensitive(false);
m_pBackgroundBtn->Disable(); m_xBackgroundBtn->set_sensitive(false);
m_pCntSharedFirstBox->Disable(); m_xCntSharedFirstBox->set_sensitive(false);
} }
else else
m_pTurnOnBox->Check(); m_xTurnOnBox->set_active(true);
} }
UpdateExample(); UpdateExample();
} }
IMPL_LINK_NOARG(SvxHFPage, DistModify, Edit&, void) IMPL_LINK(SvxHFPage, TurnOnHdl, weld::ToggleButton&, rBox, void)
{ {
UpdateExample(); TurnOn(&rBox);
} }
IMPL_LINK_NOARG(SvxHFPage, HeightModify, Edit&, void) IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, void)
{
UpdateExample();
}
IMPL_LINK_NOARG(SvxHFPage, BorderModify, Edit&, void)
{
UpdateExample();
}
IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void)
{ {
if(!pBBSet) if(!pBBSet)
{ {
...@@ -710,13 +667,13 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void) ...@@ -710,13 +667,13 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void)
if(SID_ATTR_PAGE_HEADERSET == nId) if(SID_ATTR_PAGE_HEADERSET == nId)
{ {
//m_pBspWin->SetHdColor(rItem.GetColor()); //m_aBspWin.SetHdColor(rItem.GetColor());
m_pBspWin->setHeaderFillAttributes(aFillAttributes); m_aBspWin.setHeaderFillAttributes(aFillAttributes);
} }
else else
{ {
//m_pBspWin->SetFtColor(rItem.GetColor()); //m_aBspWin.SetFtColor(rItem.GetColor());
m_pBspWin->setFooterFillAttributes(aFillAttributes); m_aBspWin.setFooterFillAttributes(aFillAttributes);
} }
} }
...@@ -729,21 +686,21 @@ void SvxHFPage::UpdateExample() ...@@ -729,21 +686,21 @@ void SvxHFPage::UpdateExample()
{ {
if ( nId == SID_ATTR_PAGE_HEADERSET ) if ( nId == SID_ATTR_PAGE_HEADERSET )
{ {
m_pBspWin->SetHeader( m_pTurnOnBox->IsChecked() ); m_aBspWin.SetHeader( m_xTurnOnBox->get_active() );
m_pBspWin->SetHdHeight( GetCoreValue( *m_pHeightEdit, MapUnit::MapTwip ) ); m_aBspWin.SetHdHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) );
m_pBspWin->SetHdDist( GetCoreValue( *m_pDistEdit, MapUnit::MapTwip ) ); m_aBspWin.SetHdDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) );
m_pBspWin->SetHdLeft( GetCoreValue( *m_pLMEdit, MapUnit::MapTwip ) ); m_aBspWin.SetHdLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) );
m_pBspWin->SetHdRight( GetCoreValue( *m_pRMEdit, MapUnit::MapTwip ) ); m_aBspWin.SetHdRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) );
} }
else else
{ {
m_pBspWin->SetFooter( m_pTurnOnBox->IsChecked() ); m_aBspWin.SetFooter( m_xTurnOnBox->get_active() );
m_pBspWin->SetFtHeight( GetCoreValue( *m_pHeightEdit, MapUnit::MapTwip ) ); m_aBspWin.SetFtHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) );
m_pBspWin->SetFtDist( GetCoreValue( *m_pDistEdit, MapUnit::MapTwip ) ); m_aBspWin.SetFtDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) );
m_pBspWin->SetFtLeft( GetCoreValue( *m_pLMEdit, MapUnit::MapTwip ) ); m_aBspWin.SetFtLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) );
m_pBspWin->SetFtRight( GetCoreValue( *m_pRMEdit, MapUnit::MapTwip ) ); m_aBspWin.SetFtRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) );
} }
m_pBspWin->Invalidate(); m_aBspWin.Invalidate();
} }
void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
...@@ -780,7 +737,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) ...@@ -780,7 +737,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
} }
} }
m_pBspWin->setHeaderFillAttributes(aHeaderFillAttributes); m_aBspWin.setHeaderFillAttributes(aHeaderFillAttributes);
} }
} }
...@@ -816,7 +773,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) ...@@ -816,7 +773,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
} }
} }
m_pBspWin->setFooterFillAttributes(aFooterFillAttributes); m_aBspWin.setFooterFillAttributes(aFooterFillAttributes);
} }
} }
...@@ -842,7 +799,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) ...@@ -842,7 +799,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
} }
} }
m_pBspWin->setPageFillAttributes(aPageFillAttributes); m_aBspWin.setPageFillAttributes(aPageFillAttributes);
} }
void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
...@@ -854,13 +811,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -854,13 +811,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
// Set left and right margins // Set left and right margins
const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem); const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem);
m_pBspWin->SetLeft( rLRSpace.GetLeft() ); m_aBspWin.SetLeft( rLRSpace.GetLeft() );
m_pBspWin->SetRight( rLRSpace.GetRight() ); m_aBspWin.SetRight( rLRSpace.GetRight() );
} }
else else
{ {
m_pBspWin->SetLeft( 0 ); m_aBspWin.SetLeft( 0 );
m_pBspWin->SetRight( 0 ); m_aBspWin.SetRight( 0 );
} }
pItem = GetItem( rSet, SID_ATTR_ULSPACE ); pItem = GetItem( rSet, SID_ATTR_ULSPACE );
...@@ -870,13 +827,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -870,13 +827,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
// Set top and bottom margins // Set top and bottom margins
const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem); const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem);
m_pBspWin->SetTop( rULSpace.GetUpper() ); m_aBspWin.SetTop( rULSpace.GetUpper() );
m_pBspWin->SetBottom( rULSpace.GetLower() ); m_aBspWin.SetBottom( rULSpace.GetLower() );
} }
else else
{ {
m_pBspWin->SetTop( 0 ); m_aBspWin.SetTop( 0 );
m_pBspWin->SetBottom( 0 ); m_aBspWin.SetBottom( 0 );
} }
SvxPageUsage nUsage = SvxPageUsage::All; SvxPageUsage nUsage = SvxPageUsage::All;
...@@ -885,14 +842,14 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -885,14 +842,14 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
if ( pItem ) if ( pItem )
nUsage = static_cast<const SvxPageItem*>(pItem)->GetPageUsage(); nUsage = static_cast<const SvxPageItem*>(pItem)->GetPageUsage();
m_pBspWin->SetUsage( nUsage ); m_aBspWin.SetUsage( nUsage );
if ( SvxPageUsage::Right == nUsage || SvxPageUsage::Left == nUsage ) if ( SvxPageUsage::Right == nUsage || SvxPageUsage::Left == nUsage )
m_pCntSharedBox->Disable(); m_xCntSharedBox->set_sensitive(false);
else else
{ {
m_pCntSharedBox->Enable(); m_xCntSharedBox->set_sensitive(true);
m_pCntSharedFirstBox->Enable(); m_xCntSharedFirstBox->set_sensitive(true);
} }
pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE ); pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
...@@ -901,7 +858,7 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -901,7 +858,7 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
// Orientation and Size from the PageItem // Orientation and Size from the PageItem
const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(*pItem); const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(*pItem);
// if the size is already swapped (Landscape) // if the size is already swapped (Landscape)
m_pBspWin->SetSize( rSize.GetSize() ); m_aBspWin.SetSize( rSize.GetSize() );
} }
// Evaluate Header attribute // Evaluate Header attribute
...@@ -925,11 +882,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -925,11 +882,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
long nDist = rUL.GetLower(); long nDist = rUL.GetLower();
m_pBspWin->SetHdHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
m_pBspWin->SetHdDist( nDist ); m_aBspWin.SetHdDist( nDist );
m_pBspWin->SetHdLeft( rLR.GetLeft() ); m_aBspWin.SetHdLeft( rLR.GetLeft() );
m_pBspWin->SetHdRight( rLR.GetRight() ); m_aBspWin.SetHdRight( rLR.GetRight() );
m_pBspWin->SetHeader( true ); m_aBspWin.SetHeader( true );
} }
else else
pSetItem = nullptr; pSetItem = nullptr;
...@@ -937,12 +894,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -937,12 +894,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
if ( !pSetItem ) if ( !pSetItem )
{ {
m_pBspWin->SetHeader( false ); m_aBspWin.SetHeader( false );
if ( SID_ATTR_PAGE_HEADERSET == nId ) if ( SID_ATTR_PAGE_HEADERSET == nId )
{ {
m_pCntSharedBox->Disable(); m_xCntSharedBox->set_sensitive(false);
m_pCntSharedFirstBox->Disable(); m_xCntSharedFirstBox->set_sensitive(false);
} }
} }
pSetItem = nullptr; pSetItem = nullptr;
...@@ -965,11 +922,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -965,11 +922,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
long nDist = rUL.GetUpper(); long nDist = rUL.GetUpper();
m_pBspWin->SetFtHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
m_pBspWin->SetFtDist( nDist ); m_aBspWin.SetFtDist( nDist );
m_pBspWin->SetFtLeft( rLR.GetLeft() ); m_aBspWin.SetFtLeft( rLR.GetLeft() );
m_pBspWin->SetFtRight( rLR.GetRight() ); m_aBspWin.SetFtRight( rLR.GetRight() );
m_pBspWin->SetFooter( true ); m_aBspWin.SetFooter( true );
} }
else else
pSetItem = nullptr; pSetItem = nullptr;
...@@ -977,12 +934,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -977,12 +934,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
if ( !pSetItem ) if ( !pSetItem )
{ {
m_pBspWin->SetFooter( false ); m_aBspWin.SetFooter( false );
if ( SID_ATTR_PAGE_FOOTERSET == nId ) if ( SID_ATTR_PAGE_FOOTERSET == nId )
{ {
m_pCntSharedBox->Disable(); m_xCntSharedBox->set_sensitive(false);
m_pCntSharedFirstBox->Disable(); m_xCntSharedFirstBox->set_sensitive(false);
} }
} }
...@@ -990,16 +947,16 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) ...@@ -990,16 +947,16 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr ) if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr )
{ {
m_pBspWin->SetTable( true ); m_aBspWin.SetTable( true );
m_pBspWin->SetHorz( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); m_aBspWin.SetHorz( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
} }
pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 ); pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr ) if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr )
{ {
m_pBspWin->SetTable( true ); m_aBspWin.SetTable( true );
m_pBspWin->SetVert( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); m_aBspWin.SetVert( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
} }
ResetBackground_Impl( rSet ); ResetBackground_Impl( rSet );
RangeHdl(); RangeHdl();
...@@ -1012,22 +969,24 @@ DeactivateRC SvxHFPage::DeactivatePage( SfxItemSet* _pSet ) ...@@ -1012,22 +969,24 @@ DeactivateRC SvxHFPage::DeactivatePage( SfxItemSet* _pSet )
return DeactivateRC::LeavePage; return DeactivateRC::LeavePage;
} }
IMPL_LINK_NOARG(SvxHFPage, RangeFocusHdl, Control&, void) IMPL_LINK_NOARG(SvxHFPage, ValueChangeHdl, weld::MetricSpinButton&, void)
{ {
UpdateExample();
RangeHdl(); RangeHdl();
} }
void SvxHFPage::RangeHdl() void SvxHFPage::RangeHdl()
{ {
long nHHeight = m_pBspWin->GetHdHeight(); long nHHeight = m_aBspWin.GetHdHeight();
long nHDist = m_pBspWin->GetHdDist(); long nHDist = m_aBspWin.GetHdDist();
long nFHeight = m_pBspWin->GetFtHeight(); long nFHeight = m_aBspWin.GetFtHeight();
long nFDist = m_pBspWin->GetFtDist(); long nFDist = m_aBspWin.GetFtDist();
long nHeight = std::max( long(MINBODY), long nHeight = std::max(long(MINBODY),
static_cast<long>(m_pHeightEdit->Denormalize( m_pHeightEdit->GetValue( FUNIT_TWIP ) ) ) ); static_cast<long>(m_xHeightEdit->denormalize(m_xHeightEdit->get_value(FUNIT_TWIP))));
long nDist = m_pTurnOnBox->IsChecked() ? long nDist = m_xTurnOnBox->get_active() ?
static_cast<long>(m_pDistEdit->Denormalize( m_pDistEdit->GetValue( FUNIT_TWIP ) )) : 0; static_cast<long>(m_xDistEdit->denormalize(m_xDistEdit->get_value(FUNIT_TWIP))) : 0;
long nMin; long nMin;
long nMax; long nMax;
...@@ -1044,13 +1003,13 @@ void SvxHFPage::RangeHdl() ...@@ -1044,13 +1003,13 @@ void SvxHFPage::RangeHdl()
} }
// Current values of the side edges // Current values of the side edges
long nBT = m_pBspWin->GetTop(); long nBT = m_aBspWin.GetTop();
long nBB = m_pBspWin->GetBottom(); long nBB = m_aBspWin.GetBottom();
long nBL = m_pBspWin->GetLeft(); long nBL = m_aBspWin.GetLeft();
long nBR = m_pBspWin->GetRight(); long nBR = m_aBspWin.GetRight();
long nH = m_pBspWin->GetSize().Height(); long nH = m_aBspWin.GetSize().Height();
long nW = m_pBspWin->GetSize().Width(); long nW = m_aBspWin.GetSize().Width();
// Borders // Borders
if ( nId == SID_ATTR_PAGE_HEADERSET ) if ( nId == SID_ATTR_PAGE_HEADERSET )
...@@ -1059,11 +1018,11 @@ void SvxHFPage::RangeHdl() ...@@ -1059,11 +1018,11 @@ void SvxHFPage::RangeHdl()
nMin = ( nH - nBB - nBT ) / 5; // 20% nMin = ( nH - nBB - nBT ) / 5; // 20%
nMax = std::max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT, nMax = std::max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT,
nMin ); nMin );
m_pHeightEdit->SetMax( m_pHeightEdit->Normalize( nMax ), FUNIT_TWIP ); m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FUNIT_TWIP);
nMin = ( nH - nBB - nBT ) / 5; // 20% nMin = ( nH - nBB - nBT ) / 5; // 20%
nDist = std::max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT, nDist = std::max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT,
long(0) ); long(0) );
m_pDistEdit->SetMax( m_pDistEdit->Normalize( nDist ), FUNIT_TWIP ); m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FUNIT_TWIP);
} }
else else
{ {
...@@ -1071,53 +1030,33 @@ void SvxHFPage::RangeHdl() ...@@ -1071,53 +1030,33 @@ void SvxHFPage::RangeHdl()
nMin = ( nH - nBT - nBB ) / 5; // 20% nMin = ( nH - nBT - nBB ) / 5; // 20%
nMax = std::max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB, nMax = std::max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB,
nMin ); nMin );
m_pHeightEdit->SetMax( m_pHeightEdit->Normalize( nMax ), FUNIT_TWIP ); m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FUNIT_TWIP);
nMin = ( nH - nBT - nBB ) / 5; // 20% nMin = ( nH - nBT - nBB ) / 5; // 20%
nDist = std::max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB, nDist = std::max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB,
long(0) ); long(0) );
m_pDistEdit->SetMax( m_pDistEdit->Normalize( nDist ), FUNIT_TWIP ); m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FUNIT_TWIP);
} }
// Limit Indentation // Limit Indentation
nMax = nW - nBL - nBR - nMax = nW - nBL - nBR -
static_cast<long>(m_pRMEdit->Denormalize( m_pRMEdit->GetValue( FUNIT_TWIP ) )) - MINBODY; static_cast<long>(m_xRMEdit->denormalize(m_xRMEdit->get_value(FUNIT_TWIP))) - MINBODY;
m_pLMEdit->SetMax( m_pLMEdit->Normalize( nMax ), FUNIT_TWIP ); m_xLMEdit->set_max(m_xLMEdit->normalize(nMax), FUNIT_TWIP);
nMax = nW - nBL - nBR - nMax = nW - nBL - nBR -
static_cast<long>(m_pLMEdit->Denormalize( m_pLMEdit->GetValue( FUNIT_TWIP ) )) - MINBODY; static_cast<long>(m_xLMEdit->denormalize(m_xLMEdit->get_value(FUNIT_TWIP))) - MINBODY;
m_pRMEdit->SetMax( m_pLMEdit->Normalize( nMax ), FUNIT_TWIP ); m_xRMEdit->set_max(m_xLMEdit->normalize(nMax), FUNIT_TWIP);
}
static void lcl_Move(vcl::Window& rWin, sal_Int32 nDiff)
{
Point aPos(rWin.GetPosPixel());
aPos.AdjustY( -nDiff );
rWin.SetPosPixel(aPos);
} }
void SvxHFPage::EnableDynamicSpacing() void SvxHFPage::EnableDynamicSpacing()
{ {
m_pDynSpacingCB->Show(); m_xDynSpacingCB->show();
//move all following controls
vcl::Window* aMoveWindows[] =
{
m_pHeightFT,
m_pHeightEdit,
m_pHeightDynBtn,
m_pBackgroundBtn,
nullptr
};
sal_Int32 nOffset = m_pTurnOnBox->GetPosPixel().Y() - m_pCntSharedBox->GetPosPixel().Y();
sal_Int32 nIdx = 0;
while(aMoveWindows[nIdx])
lcl_Move(*aMoveWindows[nIdx++], nOffset);
} }
void SvxHFPage::PageCreated(const SfxAllItemSet &rSet) void SvxHFPage::PageCreated(const SfxAllItemSet &rSet)
{ {
const SfxBoolItem* pSupportDrawingLayerFillStyleItem = rSet.GetItem<SfxBoolItem>(SID_DRAWINGLAYER_FILLSTYLES, false); const SfxBoolItem* pSupportDrawingLayerFillStyleItem = rSet.GetItem<SfxBoolItem>(SID_DRAWINGLAYER_FILLSTYLES, false);
if(pSupportDrawingLayerFillStyleItem) if (pSupportDrawingLayerFillStyleItem)
{ {
const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue()); const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue());
......
...@@ -413,4 +413,379 @@ Size SvxPageWindow::GetOptimalSize() const ...@@ -413,4 +413,379 @@ Size SvxPageWindow::GetOptimalSize() const
return LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont)); return LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont));
} }
PageWindow::PageWindow() :
aWinSize(),
aSize(),
nTop(0),
nBottom(0),
nLeft(0),
nRight(0),
bResetBackground(false),
bFrameDirection(false),
nFrameDirection(SvxFrameDirection::Horizontal_LR_TB),
nHdLeft(0),
nHdRight(0),
nHdDist(0),
nHdHeight(0),
nFtLeft(0),
nFtRight(0),
nFtDist(0),
nFtHeight(0),
maHeaderFillAttributes(),
maFooterFillAttributes(),
maPageFillAttributes(),
bFooter(false),
bHeader(false),
bTable(false),
bHorz(false),
bVert(false),
eUsage(SvxPageUsage::All)
{
}
PageWindow::~PageWindow()
{
}
void PageWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
rRenderContext.Push(PushFlags::MAPMODE);
rRenderContext.SetMapMode(MapMode(MapUnit::MapTwip));
Fraction aXScale(aWinSize.Width(), std::max(long(aSize.Width() * 2 + aSize.Width() / 8), 1L));
Fraction aYScale(aWinSize.Height(), std::max(aSize.Height(), 1L));
MapMode aMapMode(rRenderContext.GetMapMode());
if(aYScale < aXScale)
{
aMapMode.SetScaleX(aYScale);
aMapMode.SetScaleY(aYScale);
}
else
{
aMapMode.SetScaleX(aXScale);
aMapMode.SetScaleY(aXScale);
}
rRenderContext.SetMapMode(aMapMode);
Size aSz(rRenderContext.PixelToLogic(GetOutputSizePixel()));
long nYPos = (aSz.Height() - aSize.Height()) / 2;
if (eUsage == SvxPageUsage::All)
{
// all pages are equal -> draw one page
if (aSize.Width() > aSize.Height())
{
// Draw Landscape page of the same size
Fraction aX = aMapMode.GetScaleX();
Fraction aY = aMapMode.GetScaleY();
Fraction a2(1.5);
aX *= a2;
aY *= a2;
aMapMode.SetScaleX(aX);
aMapMode.SetScaleY(aY);
rRenderContext.SetMapMode(aMapMode);
aSz = rRenderContext.PixelToLogic(GetOutputSizePixel());
nYPos = (aSz.Height() - aSize.Height()) / 2;
long nXPos = (aSz.Width() - aSize.Width()) / 2;
DrawPage(rRenderContext, Point(nXPos,nYPos),true,true);
}
else
// Portrait
DrawPage(rRenderContext, Point((aSz.Width() - aSize.Width()) / 2,nYPos),true,true);
}
else
{
// Left and right page are different -> draw two pages if possible
DrawPage(rRenderContext, Point(0, nYPos), false,
eUsage == SvxPageUsage::Left || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror);
DrawPage(rRenderContext, Point(aSize.Width() + aSize.Width() / 8, nYPos), true,
eUsage == SvxPageUsage::Right || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror);
}
rRenderContext.Pop();
}
void PageWindow::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOrg, const bool bSecond, const bool bEnabled)
{
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
const Color& rFieldColor = rStyleSettings.GetFieldColor();
const Color& rFieldTextColor = rStyleSettings.GetFieldTextColor();
const Color& rDisableColor = rStyleSettings.GetDisableColor();
const Color& rDlgColor = rStyleSettings.GetDialogColor();
// background
if (!bSecond || bResetBackground)
{
rRenderContext.SetLineColor(COL_TRANSPARENT);
rRenderContext.SetFillColor(rDlgColor);
Size winSize(rRenderContext.GetOutputSize());
rRenderContext.DrawRect(tools::Rectangle(Point(0,0), winSize));
if (bResetBackground)
bResetBackground = false;
}
rRenderContext.SetLineColor(rFieldTextColor);
// Shadow
Size aTempSize = aSize;
// Page
if (!bEnabled)
{
rRenderContext.SetFillColor(rDisableColor);
rRenderContext.DrawRect(tools::Rectangle(rOrg, aTempSize));
return;
}
rRenderContext.SetFillColor(rFieldColor);
rRenderContext.DrawRect(tools::Rectangle(rOrg, aTempSize));
long nL = nLeft;
long nR = nRight;
if (eUsage == SvxPageUsage::Mirror && !bSecond)
{
// turn for mirrored
nL = nRight;
nR = nLeft;
}
tools::Rectangle aRect;
aRect.SetLeft( rOrg.X() + nL );
aRect.SetRight( rOrg.X() + aTempSize.Width() - nR );
aRect.SetTop( rOrg.Y() + nTop );
aRect.SetBottom( rOrg.Y() + aTempSize.Height() - nBottom );
tools::Rectangle aHdRect(aRect);
tools::Rectangle aFtRect(aRect);
if (bHeader || bFooter)
{
// Header and/or footer used
const Color aLineColor(rRenderContext.GetLineColor());
// draw PageFill first and on the whole page, no outline
rRenderContext.SetLineColor();
drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect);
rRenderContext.SetLineColor(aLineColor);
if (bHeader)
{
// show headers if possible
aHdRect.AdjustLeft(nHdLeft );
aHdRect.AdjustRight( -(nHdRight) );
aHdRect.SetBottom( aRect.Top() + nHdHeight );
aRect.AdjustTop(nHdHeight + nHdDist );
// draw header over PageFill, plus outline
drawFillAttributes(rRenderContext, maHeaderFillAttributes, aHdRect, aHdRect);
}
if (bFooter)
{
// show footer if possible
aFtRect.AdjustLeft(nFtLeft );
aFtRect.AdjustRight( -(nFtRight) );
aFtRect.SetTop( aRect.Bottom() - nFtHeight );
aRect.AdjustBottom( -(nFtHeight + nFtDist) );
// draw footer over PageFill, plus outline
drawFillAttributes(rRenderContext, maFooterFillAttributes, aFtRect, aFtRect);
}
// draw page's reduced outline, only outline
drawFillAttributes(rRenderContext, drawinglayer::attribute::SdrAllFillAttributesHelperPtr(), aRect, aRect);
}
else
{
// draw PageFill and outline
drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect);
}
if (bFrameDirection && !bTable)
{
Point aPos;
vcl::Font aFont(rRenderContext.GetFont());
const Size aSaveSize = aFont.GetFontSize();
Size aDrawSize(0,aRect.GetHeight() / 6);
aFont.SetFontSize(aDrawSize);
rRenderContext.SetFont(aFont);
OUString sText("ABC");
Point aMove(1, rRenderContext.GetTextHeight());
sal_Unicode cArrow = 0x2193;
long nAWidth = rRenderContext.GetTextWidth(sText.copy(0,1));
switch (nFrameDirection)
{
case SvxFrameDirection::Horizontal_LR_TB:
aPos = aRect.TopLeft();
aPos.AdjustX(rRenderContext.PixelToLogic(Point(1,1)).X() );
aMove.setY( 0 );
cArrow = 0x2192;
break;
case SvxFrameDirection::Horizontal_RL_TB:
aPos = aRect.TopRight();
aPos.AdjustX( -nAWidth );
aMove.setY( 0 );
aMove.setX( aMove.X() * -1 );
cArrow = 0x2190;
break;
case SvxFrameDirection::Vertical_LR_TB:
aPos = aRect.TopLeft();
aPos.AdjustX(rRenderContext.PixelToLogic(Point(1,1)).X() );
aMove.setX( 0 );
break;
case SvxFrameDirection::Vertical_RL_TB:
aPos = aRect.TopRight();
aPos.AdjustX( -nAWidth );
aMove.setX( 0 );
break;
default: break;
}
sText += OUStringLiteral1(cArrow);
for (sal_Int32 i = 0; i < sText.getLength(); i++)
{
OUString sDraw(sText.copy(i,1));
long nHDiff = 0;
long nCharWidth = rRenderContext.GetTextWidth(sDraw);
bool bHorizontal = 0 == aMove.Y();
if (!bHorizontal)
{
nHDiff = (nAWidth - nCharWidth) / 2;
aPos.AdjustX(nHDiff );
}
rRenderContext.DrawText(aPos,sDraw);
if (bHorizontal)
{
aPos.AdjustX(aMove.X() < 0 ? -nCharWidth : nCharWidth );
}
else
{
aPos.AdjustX( -nHDiff );
aPos.AdjustY(aMove.Y() );
}
}
aFont.SetFontSize(aSaveSize);
rRenderContext.SetFont(aFont);
}
if (bTable)
{
// Paint Table, if necessary center it
rRenderContext.SetLineColor(COL_LIGHTGRAY);
long nW = aRect.GetWidth();
long nH = aRect.GetHeight();
long const nTW = CELL_WIDTH * 3;
long const nTH = CELL_HEIGHT * 3;
long _nLeft = bHorz ? aRect.Left() + ((nW - nTW) / 2) : aRect.Left();
long _nTop = bVert ? aRect.Top() + ((nH - nTH) / 2) : aRect.Top();
tools::Rectangle aCellRect(Point(_nLeft, _nTop),Size(CELL_WIDTH, CELL_HEIGHT));
for (sal_uInt16 i = 0; i < 3; ++i)
{
aCellRect.SetLeft( _nLeft );
aCellRect.SetRight( _nLeft + CELL_WIDTH );
if(i > 0)
aCellRect.Move(0,CELL_HEIGHT);
for (sal_uInt16 j = 0; j < 3; ++j)
{
if (j > 0)
aCellRect.Move(CELL_WIDTH,0);
rRenderContext.DrawRect(aCellRect);
}
}
}
}
void PageWindow::drawFillAttributes(vcl::RenderContext& rRenderContext,
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
const tools::Rectangle& rPaintRange,
const tools::Rectangle& rDefineRange)
{
const basegfx::B2DRange aPaintRange(
rPaintRange.Left(),
rPaintRange.Top(),
rPaintRange.Right(),
rPaintRange.Bottom());
if(!aPaintRange.isEmpty() &&
!basegfx::fTools::equalZero(aPaintRange.getWidth()) &&
!basegfx::fTools::equalZero(aPaintRange.getHeight()))
{
const basegfx::B2DRange aDefineRange(
rDefineRange.Left(),
rDefineRange.Top(),
rDefineRange.Right(),
rDefineRange.Bottom());
// prepare primitive sequence
drawinglayer::primitive2d::Primitive2DContainer aSequence;
// create fill geometry if there is something to fill
if (rFillAttributes.get() && rFillAttributes->isUsed())
{
aSequence = rFillAttributes->getPrimitive2DSequence(aPaintRange, aDefineRange);
}
// create line geometry if a LineColor is set at the target device
if (rRenderContext.IsLineColor())
{
const drawinglayer::primitive2d::Primitive2DReference xOutline(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
basegfx::utils::createPolygonFromRect(aPaintRange), rRenderContext.GetLineColor().getBColor()));
aSequence.push_back(xOutline);
}
// draw that if we have something to draw
if (!aSequence.empty())
{
const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
basegfx::B2DHomMatrix(), rRenderContext.GetViewTransformation(), aPaintRange, nullptr,
0.0, css::uno::Sequence<css::beans::PropertyValue >());
std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor;
pProcessor.reset(drawinglayer::processor2d::createProcessor2DFromOutputDevice(rRenderContext, aViewInformation2D));
if (pProcessor)
{
pProcessor->process(aSequence);
}
}
}
}
void PageWindow::EnableFrameDirection(bool bEnable)
{
bFrameDirection = bEnable;
}
void PageWindow::SetFrameDirection(SvxFrameDirection nDirection)
{
nFrameDirection = nDirection;
}
void PageWindow::ResetBackground()
{
bResetBackground = true;
}
void PageWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
OutputDevice& rRefDevice = pDrawingArea->get_ref_device();
// Count in Twips by default
rRefDevice.Push(PushFlags::MAPMODE);
rRefDevice.SetMapMode(MapMode(MapUnit::MapTwip));
aWinSize = rRefDevice.LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont));
pDrawingArea->set_size_request(aWinSize.Width(), aWinSize.Height());
CustomWidgetController::SetDrawingArea(pDrawingArea);
aWinSize.AdjustHeight( -4 );
aWinSize.AdjustWidth( -4 );
aWinSize = rRefDevice.PixelToLogic(aWinSize);
rRefDevice.Pop();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="svx"> <interface domain="svx">
<!-- interface-requires gtk+ 3.0 --> <requires lib="gtk+" version="3.18"/>
<!-- interface-requires LibreOffice 1.0 -->
<object class="GtkAdjustment" id="adjustment1"> <object class="GtkAdjustment" id="adjustment1">
<property name="upper">99.989999999999995</property> <property name="upper">99.989999999999995</property>
<property name="step_increment">0.10000000000000001</property> <property name="step_increment">0.10000000000000001</property>
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
<property name="step_increment">0.10000000000000001</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property> <property name="page_increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">99.989999999999995</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment4">
<property name="upper">99.989999999999995</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property>
</object>
<object class="GtkGrid" id="HFFormatPage"> <object class="GtkGrid" id="HFFormatPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -123,7 +133,6 @@ ...@@ -123,7 +133,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -132,8 +141,8 @@ ...@@ -132,8 +141,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="use_underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </object>
...@@ -141,7 +150,6 @@ ...@@ -141,7 +150,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -149,31 +157,28 @@ ...@@ -149,31 +157,28 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelLeftMarg">_Left margin:</property> <property name="label" translatable="yes" context="headfootformatpage|labelLeftMarg">_Left margin:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">spinMargLeft:0.00cm</property> <property name="mnemonic_widget">spinMargLeft</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="spinMargLeft:0.00cm"> <object class="GtkSpinButton" id="spinMargLeft">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment1</property> <property name="adjustment">adjustment1</property>
<property name="digits">2</property> <property name="digits">2</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -181,31 +186,28 @@ ...@@ -181,31 +186,28 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelRightMarg">R_ight margin:</property> <property name="label" translatable="yes" context="headfootformatpage|labelRightMarg">R_ight margin:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">spinMargRight:0.00cm</property> <property name="mnemonic_widget">spinMargRight</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">3</property> <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="spinMargRight:0.00cm"> <object class="GtkSpinButton" id="spinMargRight">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="adjustment">adjustment1</property> <property name="activates_default">True</property>
<property name="adjustment">adjustment3</property>
<property name="digits">2</property> <property name="digits">2</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">3</property> <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -213,31 +215,28 @@ ...@@ -213,31 +215,28 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelSpacing">_Spacing:</property> <property name="label" translatable="yes" context="headfootformatpage|labelSpacing">_Spacing:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">spinSpacing:0.00cm</property> <property name="mnemonic_widget">spinSpacing</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="spinSpacing:0.00cm"> <object class="GtkSpinButton" id="spinSpacing">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="adjustment">adjustment1</property> <property name="activates_default">True</property>
<property name="adjustment">adjustment4</property>
<property name="digits">2</property> <property name="digits">2</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -254,7 +253,6 @@ ...@@ -254,7 +253,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">5</property> <property name="top_attach">5</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -262,32 +260,29 @@ ...@@ -262,32 +260,29 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelHeight">_Height:</property> <property name="label" translatable="yes" context="headfootformatpage|labelHeight">_Height:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">spinHeight:0.00cm</property> <property name="mnemonic_widget">spinHeight</property>
<property name="ellipsize">end</property> <property name="ellipsize">end</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">6</property> <property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="spinHeight:0.00cm"> <object class="GtkSpinButton" id="spinHeight">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment2</property> <property name="adjustment">adjustment2</property>
<property name="digits">2</property> <property name="digits">2</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">6</property> <property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -305,7 +300,6 @@ ...@@ -305,7 +300,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">7</property> <property name="top_attach">7</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -347,7 +341,6 @@ ...@@ -347,7 +341,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">8</property> <property name="top_attach">8</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -372,8 +365,8 @@ ...@@ -372,8 +365,8 @@
<object class="GtkLabel" id="labelHeaderFormat"> <object class="GtkLabel" id="labelHeaderFormat">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelHeaderFormat">Header</property> <property name="label" translatable="yes" context="headfootformatpage|labelHeaderFormat">Header</property>
<property name="xalign">0</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
...@@ -388,8 +381,8 @@ ...@@ -388,8 +381,8 @@
<object class="GtkLabel" id="labelFooterFormat"> <object class="GtkLabel" id="labelFooterFormat">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="headfootformatpage|labelFooterFormat">Footer</property> <property name="label" translatable="yes" context="headfootformatpage|labelFooterFormat">Footer</property>
<property name="xalign">0</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
...@@ -406,8 +399,6 @@ ...@@ -406,8 +399,6 @@
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -423,7 +414,7 @@ ...@@ -423,7 +414,7 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="svxlo-SvxPageWindow" id="drawingareaPageHF"> <object class="GtkDrawingArea" id="drawingareaPageHF">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">center</property> <property name="halign">center</property>
...@@ -432,7 +423,7 @@ ...@@ -432,7 +423,7 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
...@@ -443,18 +434,16 @@ ...@@ -443,18 +434,16 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<object class="GtkSizeGroup" id="sizegroup1"> <object class="GtkSizeGroup" id="sizegroup1">
<property name="ignore_hidden">True</property> <property name="ignore_hidden">True</property>
<widgets> <widgets>
<widget name="spinMargLeft:0.00cm"/> <widget name="spinMargLeft"/>
<widget name="spinMargRight:0.00cm"/> <widget name="spinMargRight"/>
<widget name="spinSpacing:0.00cm"/> <widget name="spinSpacing"/>
<widget name="spinHeight:0.00cm"/> <widget name="spinHeight"/>
</widgets> </widgets>
</object> </object>
</interface> </interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment