Kaydet (Commit) 998d11b4 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwFramePage

Change-Id: I12f868611860867df26bd29474aa19189c2b9a96
Reviewed-on: https://gerrit.libreoffice.org/63842
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 626504ee
......@@ -250,9 +250,6 @@
<glade-widget-class title="NUP Preview" name="vcllo-ShowNupOrderWindow"
generic-name="NUP Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Frame Preview" name="svxlo-SvxSwFrameExample"
generic-name="Frame Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Presentation Preview" name="sduilo-PresLayoutPreview"
generic-name="Presentation Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -27,7 +27,7 @@
#include <vcl/window.hxx>
#include <com/sun/star/text/WrapTextMode.hpp>
class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window
class SVX_DLLPUBLIC SwFrameExample : public weld::CustomWidgetController
{
Color m_aTransColor; ///< transparency
Color m_aBgCol; ///< background
......@@ -61,65 +61,6 @@ class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window
Point aRelPos;
void InitColors_Impl();
void InitAllRects_Impl(vcl::RenderContext& rRenderContext);
void CalcBoundRect_Impl(tools::Rectangle &rRect);
tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor);
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
virtual Size GetOptimalSize() const override;
protected:
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
public:
SvxSwFrameExample(vcl::Window* pParent, WinBits nStyle);
void SetWrap(css::text::WrapTextMode nW) { nWrap = nW; }
void SetHAlign(short nH) { nHAlign = nH; }
void SetHoriRel(short nR) { nHRel = nR; }
void SetVAlign(short nV) { nVAlign = nV; }
void SetVertRel(short nR) { nVRel = nR; }
void SetTransparent(bool bT) { bTrans = bT; }
void SetAnchor(RndStdIds nA) { nAnchor = nA; }
void SetRelPos(const Point& rP);
};
class SVX_DLLPUBLIC SwFrameExample : public weld::CustomWidgetController
{
Color m_aTransColor; ///< transparency
Color m_aBgCol; ///< background
Color m_aFrameColor; ///< graphic frame
Color m_aAlignColor; ///< align anchor
Color m_aBorderCol; ///< frame of doc
Color m_aPrintAreaCol; ///< frame of printable area of doc
Color m_aTxtCol; ///< symbolised text
Color m_aBlankCol; ///< area of symbol for blank
Color m_aBlankFrameCol; ///< frame of symbol for blank
tools::Rectangle aPage;
tools::Rectangle aPagePrtArea;
tools::Rectangle aTextLine;
tools::Rectangle aPara;
tools::Rectangle aParaPrtArea;
tools::Rectangle aFrameAtFrame;
tools::Rectangle aDrawObj;
tools::Rectangle aAutoCharFrame;
Size aFrmSize;
short nHAlign;
short nHRel;
short nVAlign;
short nVRel;
RndStdIds nAnchor;
Point aRelPos;
void InitColors_Impl();
void InitAllRects_Impl(vcl::RenderContext& rRenderContext);
void CalcBoundRect_Impl(vcl::RenderContext& rRenderContext, tools::Rectangle &rRect);
......@@ -133,12 +74,15 @@ public:
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
void SetWrap(css::text::WrapTextMode nW) { nWrap = nW; }
void SetHAlign(short nH) { nHAlign = nH; }
void SetHoriRel(short nR) { nHRel = nR; }
void SetVAlign(short nV) { nVAlign = nV; }
void SetVertRel(short nR) { nVRel = nR; }
void SetTransparent(bool bT) { bTrans = bT; }
void SetAnchor(RndStdIds nA) { nAnchor = nA; }
void SetRelPos(const Point& rP);
......
......@@ -510,7 +510,6 @@ custom_widgets = [
'SvxNoSpaceEdit',
'SvxPathControl',
'SvxRelativeField',
'SvxSwFrameExample',
'SvxTextEncodingBox',
'SvxTextEncodingBox',
'SwAddressPreview',
......
......@@ -558,8 +558,8 @@ void SwColumnPage::Reset(const SfxItemSet *rSet)
m_xDistEd1->SetMetric(aMetric);
m_xDistEd2->SetMetric(aMetric);
//default spacing between cols = 0.5cm
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
m_xDistEd2->SetPrcntValue(50, FieldUnit::CM);
m_xDistEd1->set_value(50, FieldUnit::CM);
m_xDistEd2->set_value(50, FieldUnit::CM);
m_xColMgr.reset(new SwColMgr(*rSet));
m_nCols = m_xColMgr->GetCount() ;
......@@ -963,7 +963,7 @@ IMPL_LINK(SwColumnPage, GapModify, weld::MetricSpinButton&, rMetricField, void)
if(nActValue > nMaxGap)
{
nActValue = nMaxGap;
m_xDistEd1->SetPrcntValue(m_xDistEd1->NormalizePercent(nMaxGap), FieldUnit::TWIP);
m_xDistEd1->set_value(m_xDistEd1->NormalizePercent(nMaxGap), FieldUnit::TWIP);
}
m_xColMgr->SetGutterWidth(static_cast<sal_uInt16>(nActValue));
for(sal_uInt16 i = 0; i < m_nCols; i++)
......@@ -1122,29 +1122,29 @@ void SwColumnPage::Update(const weld::MetricSpinButton* pInteractiveField)
//fdo#87612 if we're interacting with this widget and the value will be the same
//then leave it alone (i.e. don't change equivalent values of e.g. .8 -> 0.8)
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd1->get())
m_xEd1->SetPrcntValue(nNewValue, FieldUnit::TWIP);
m_xEd1->set_value(nNewValue, FieldUnit::TWIP);
nCurrentValue = m_xDistEd1->NormalizePercent(m_xDistEd1->DenormalizePercent(m_xDistEd1->get_value(FieldUnit::TWIP)));
nNewValue = m_xDistEd1->NormalizePercent(m_nColDist[m_nFirstVis]);
if (nNewValue != nCurrentValue || pInteractiveField != m_xDistEd1->get())
m_xDistEd1->SetPrcntValue(nNewValue, FieldUnit::TWIP);
m_xDistEd1->set_value(nNewValue, FieldUnit::TWIP);
nCurrentValue = m_xEd2->NormalizePercent(m_xEd2->DenormalizePercent(m_xEd2->get_value(FieldUnit::TWIP)));
nNewValue = m_xEd2->NormalizePercent(m_nColWidth[m_nFirstVis+1]);
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd2->get())
m_xEd2->SetPrcntValue(nNewValue, FieldUnit::TWIP);
m_xEd2->set_value(nNewValue, FieldUnit::TWIP);
if(m_nCols >= 3)
{
nCurrentValue = m_xDistEd2->NormalizePercent(m_xDistEd2->DenormalizePercent(m_xDistEd2->get_value(FieldUnit::TWIP)));
nNewValue = m_xDistEd2->NormalizePercent(m_nColDist[m_nFirstVis+1]);
if (nNewValue != nCurrentValue || pInteractiveField != m_xDistEd2->get())
m_xDistEd2->SetPrcntValue(nNewValue, FieldUnit::TWIP);
m_xDistEd2->set_value(nNewValue, FieldUnit::TWIP);
nCurrentValue = m_xEd3->NormalizePercent(m_xEd3->DenormalizePercent(m_xEd3->get_value(FieldUnit::TWIP)));
nNewValue = m_xEd3->NormalizePercent(m_nColWidth[m_nFirstVis+2]);
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd3->get())
m_xEd3->SetPrcntValue(nNewValue, FieldUnit::TWIP);
m_xEd3->set_value(nNewValue, FieldUnit::TWIP);
}
else
{
......@@ -1280,7 +1280,7 @@ IMPL_LINK(SwColumnPage, SetDefaultsHdl, SvtValueSet *, pVS, void)
{
m_xCLNrEdt->set_value(nItem);
m_xAutoWidthBox->set_active(true);
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
m_xDistEd1->set_value(50, FieldUnit::CM);
ColModify(nullptr);
}
else
......@@ -1288,18 +1288,18 @@ IMPL_LINK(SwColumnPage, SetDefaultsHdl, SvtValueSet *, pVS, void)
m_bLockUpdate = true;
m_xCLNrEdt->set_value(2);
m_xAutoWidthBox->set_active(false);
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
m_xDistEd1->set_value(50, FieldUnit::CM);
ColModify(nullptr);
// now set the width ratio to 2 : 1 or 1 : 2 respectively
const long nSmall = static_cast< long >(m_xColMgr->GetActualSize() / 3);
if(nItem == 4)
{
m_xEd2->SetPrcntValue(m_xEd2->NormalizePercent(nSmall), FieldUnit::TWIP);
m_xEd2->set_value(m_xEd2->NormalizePercent(nSmall), FieldUnit::TWIP);
m_pModifiedField = m_xEd2.get();
}
else
{
m_xEd1->SetPrcntValue(m_xEd1->NormalizePercent(nSmall), FieldUnit::TWIP);
m_xEd1->set_value(m_xEd1->NormalizePercent(nSmall), FieldUnit::TWIP);
m_pModifiedField = m_xEd1.get();
}
m_bLockUpdate = false;
......
This diff is collapsed.
......@@ -160,8 +160,8 @@ IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton&, rBtn, void
m_xRightMF->SetMetricFieldMin(0); //dito
m_xLeftMF->SetMetricFieldMax(99);
m_xRightMF->SetMetricFieldMax(99);
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(nLeft ), FieldUnit::TWIP );
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(nRight ), FieldUnit::TWIP );
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(nLeft ), FieldUnit::TWIP );
m_xRightMF->set_value(m_xRightMF->NormalizePercent(nRight ), FieldUnit::TWIP );
}
else
ModifyHdl(*m_xLeftMF->get()); //correct values again
......@@ -184,27 +184,27 @@ IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, void)
bOthers = true;
if (m_xFullBtn->get_active())
{
m_xLeftMF->SetPrcntValue(0);
m_xRightMF->SetPrcntValue(0);
m_xLeftMF->set_value(0);
m_xRightMF->set_value(0);
nSaveWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FieldUnit::TWIP);
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FieldUnit::TWIP);
bFull = true;
bRestore = false;
}
else if (m_xLeftBtn->get_active())
{
bRightEnable = bWidthEnable = true;
m_xLeftMF->SetPrcntValue(0);
m_xLeftMF->set_value(0);
}
else if (m_xFromLeftBtn->get_active())
{
bLeftEnable = bWidthEnable = true;
m_xRightMF->SetPrcntValue(0);
m_xRightMF->set_value(0);
}
else if (m_xRightBtn->get_active())
{
bLeftEnable = bWidthEnable = true;
m_xRightMF->SetPrcntValue(0);
m_xRightMF->set_value(0);
}
else if (m_xCenterBtn->get_active())
{
......@@ -233,7 +233,7 @@ IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, void)
//After being switched on automatic, the width was pinned
//in order to restore the width while switching back to.
bFull = false;
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(nSaveWidth ), FieldUnit::TWIP );
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(nSaveWidth ), FieldUnit::TWIP );
}
ModifyHdl(*m_xWidthMF->get());
bModified = true;
......@@ -358,9 +358,9 @@ void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit)
}
}
if (nCurWidth != nPrevWidth )
m_xWidthMF->SetPrcntValue( m_xWidthMF->NormalizePercent( nCurWidth ), FieldUnit::TWIP );
m_xRightMF->SetPrcntValue( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
m_xLeftMF->SetPrcntValue( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
m_xWidthMF->set_value( m_xWidthMF->NormalizePercent( nCurWidth ), FieldUnit::TWIP );
m_xRightMF->set_value( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
m_xLeftMF->set_value( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
bModified = true;
}
......@@ -451,14 +451,14 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
{
m_xRelWidthCB->set_active(true);
RelWidthClickHdl(*m_xRelWidthCB);
m_xWidthMF->SetPrcntValue(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
m_xWidthMF->set_value(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
m_xWidthMF->save_value();
nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FieldUnit::PERCENT));
}
else
{
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
pTableData->GetWidth()), FieldUnit::TWIP);
m_xWidthMF->save_value();
nSaveWidth = pTableData->GetWidth();
......@@ -467,9 +467,9 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
m_xWidthMF->SetRefValue(pTableData->GetSpace());
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
pTableData->GetLeftSpace()), FieldUnit::TWIP);
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
m_xRightMF->set_value(m_xRightMF->NormalizePercent(
pTableData->GetRightSpace()), FieldUnit::TWIP);
m_xLeftMF->save_value();
m_xRightMF->save_value();
......@@ -565,14 +565,14 @@ void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
if(pTableData->GetWidthPercent() == 0 &&
nCurWidth != m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)))
{
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
nCurWidth), FieldUnit::TWIP);
m_xWidthMF->save_value();
nSaveWidth = nCurWidth;
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
pTableData->GetLeftSpace()), FieldUnit::TWIP);
m_xLeftMF->save_value();
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
m_xRightMF->set_value(m_xRightMF->NormalizePercent(
pTableData->GetRightSpace()), FieldUnit::TWIP);
m_xRightMF->save_value();
}
......@@ -784,7 +784,7 @@ void SwTableColumnPage::Reset( const SfxItemSet* )
sal_Int64 nMaxTwips = m_aFieldArr[0].NormalizePercent( nTableWidth );
for( sal_uInt16 i = 0; (i < nMetFields) && (i < nNoOfVisibleCols); i++ )
{
m_aFieldArr[i].SetPrcntValue( m_aFieldArr[i].NormalizePercent(
m_aFieldArr[i].set_value( m_aFieldArr[i].NormalizePercent(
GetVisibleWidth(i) ), FieldUnit::TWIP );
m_aFieldArr[i].set_min(nMinTwips, FieldUnit::TWIP);
m_aFieldArr[i].set_max(nMaxTwips, FieldUnit::TWIP);
......@@ -1027,7 +1027,7 @@ void SwTableColumnPage::UpdateCols( sal_uInt16 nCurrentPos )
for( sal_uInt16 i = 0; ( i < nNoOfVisibleCols ) && ( i < nMetFields ); i++)
{
m_aFieldArr[i].SetPrcntValue(m_aFieldArr[i].NormalizePercent(
m_aFieldArr[i].set_value(m_aFieldArr[i].NormalizePercent(
GetVisibleWidth(aValueTable[i]) ), FieldUnit::TWIP);
}
}
......
......@@ -43,54 +43,6 @@ struct SwPosition;
// frame dialog
class SwFramePage: public SfxTabPage
{
// size
VclPtr<FixedText> m_pWidthFT;
VclPtr<FixedText> m_pWidthAutoFT;
PercentField m_aWidthED;
VclPtr<CheckBox> m_pRelWidthCB;
VclPtr<ListBox> m_pRelWidthRelationLB;
VclPtr<CheckBox> m_pAutoWidthCB;
VclPtr<FixedText> m_pHeightFT;
VclPtr<FixedText> m_pHeightAutoFT;
PercentField m_aHeightED;
VclPtr<CheckBox> m_pRelHeightCB;
VclPtr<ListBox> m_pRelHeightRelationLB;
VclPtr<CheckBox> m_pAutoHeightCB;
VclPtr<CheckBox> m_pFixedRatioCB;
VclPtr<PushButton> m_pRealSizeBT;
// anchor
VclPtr<VclContainer> m_pAnchorFrame;
VclPtr<RadioButton> m_pAnchorAtPageRB;
VclPtr<RadioButton> m_pAnchorAtParaRB;
VclPtr<RadioButton> m_pAnchorAtCharRB;
VclPtr<RadioButton> m_pAnchorAsCharRB;
VclPtr<RadioButton> m_pAnchorAtFrameRB;
// position
VclPtr<FixedText> m_pHorizontalFT;
VclPtr<ListBox> m_pHorizontalDLB;
VclPtr<FixedText> m_pAtHorzPosFT;
VclPtr<MetricField> m_pAtHorzPosED;
VclPtr<FixedText> m_pHoriRelationFT;
VclPtr<ListBox> m_pHoriRelationLB;
VclPtr<CheckBox> m_pMirrorPagesCB;
VclPtr<FixedText> m_pVerticalFT;
VclPtr<ListBox> m_pVerticalDLB;
VclPtr<FixedText> m_pAtVertPosFT;
VclPtr<MetricField> m_pAtVertPosED;
VclPtr<FixedText> m_pVertRelationFT;
VclPtr<ListBox> m_pVertRelationLB;
// #i18732# - check box for new option 'FollowTextFlow'
VclPtr<CheckBox> m_pFollowTextFlowCB;
// example
VclPtr<SvxSwFrameExample> m_pExampleWN;
bool m_bAtHorzPosModified;
bool m_bAtVertPosModified;
......@@ -126,48 +78,98 @@ class SwFramePage: public SfxTabPage
bool m_bIsMathOLE;
bool m_bIsMathBaselineAlignment;
SwFrameExample m_aExampleWN;
// size
std::unique_ptr<weld::Label> m_xWidthFT;
std::unique_ptr<weld::Label> m_xWidthAutoFT;
std::unique_ptr<weld::CheckButton> m_xRelWidthCB;
std::unique_ptr<weld::ComboBox> m_xRelWidthRelationLB;
std::unique_ptr<weld::CheckButton> m_xAutoWidthCB;
std::unique_ptr<weld::Label> m_xHeightFT;
std::unique_ptr<weld::Label> m_xHeightAutoFT;
std::unique_ptr<weld::CheckButton> m_xRelHeightCB;
std::unique_ptr<weld::ComboBox> m_xRelHeightRelationLB;
std::unique_ptr<weld::CheckButton> m_xAutoHeightCB;
std::unique_ptr<weld::CheckButton> m_xFixedRatioCB;
std::unique_ptr<weld::Button> m_xRealSizeBT;
// anchor
std::unique_ptr<weld::Widget> m_xAnchorFrame;
std::unique_ptr<weld::RadioButton> m_xAnchorAtPageRB;
std::unique_ptr<weld::RadioButton> m_xAnchorAtParaRB;
std::unique_ptr<weld::RadioButton> m_xAnchorAtCharRB;
std::unique_ptr<weld::RadioButton> m_xAnchorAsCharRB;
std::unique_ptr<weld::RadioButton> m_xAnchorAtFrameRB;
// position
std::unique_ptr<weld::Label> m_xHorizontalFT;
std::unique_ptr<weld::ComboBox> m_xHorizontalDLB;
std::unique_ptr<weld::Label> m_xAtHorzPosFT;
std::unique_ptr<weld::MetricSpinButton> m_xAtHorzPosED;
std::unique_ptr<weld::Label> m_xHoriRelationFT;
std::unique_ptr<weld::ComboBox> m_xHoriRelationLB;
std::unique_ptr<weld::CheckButton> m_xMirrorPagesCB;
std::unique_ptr<weld::Label> m_xVerticalFT;
std::unique_ptr<weld::ComboBox> m_xVerticalDLB;
std::unique_ptr<weld::Label> m_xAtVertPosFT;
std::unique_ptr<weld::MetricSpinButton> m_xAtVertPosED;
std::unique_ptr<weld::Label> m_xVertRelationFT;
std::unique_ptr<weld::ComboBox> m_xVertRelationLB;
// #i18732# - check box for new option 'FollowTextFlow'
std::unique_ptr<weld::CheckButton> m_xFollowTextFlowCB;
// example
std::unique_ptr<weld::CustomWeld> m_xExampleWN;
std::unique_ptr<SwPercentField> m_xWidthED;
std::unique_ptr<SwPercentField> m_xHeightED;
virtual void ActivatePage(const SfxItemSet& rSet) override;
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override;
DECL_LINK(RangeModifyLoseFocusHdl, Control&, void);
DECL_LINK(RangeModifyClickHdl, Button*, void);
DECL_LINK(RangeModifyClickHdl, weld::ToggleButton&, void);
void RangeModifyHdl();
DECL_LINK(AnchorTypeHdl, Button*, void);
DECL_LINK( PosHdl, ListBox&, void );
DECL_LINK( RelHdl, ListBox&, void );
DECL_LINK(AnchorTypeHdl, weld::ToggleButton&, void);
DECL_LINK(PosHdl, weld::ComboBox&, void);
DECL_LINK(RelHdl, weld::ComboBox&, void);
void InitPos(RndStdIds eId, sal_Int16 nH, sal_Int16 nHRel,
sal_Int16 nV, sal_Int16 nVRel,
long nX, long nY);
DECL_LINK(RealSizeHdl, Button *, void);
DECL_LINK( RelSizeClickHdl, Button *, void );
DECL_LINK(MirrorHdl, Button *, void);
DECL_LINK(RealSizeHdl, weld::Button&, void);
DECL_LINK(RelSizeClickHdl, weld::ToggleButton&, void);
DECL_LINK(MirrorHdl, weld::ToggleButton&, void);
DECL_LINK( AutoWidthClickHdl, Button *, void);
DECL_LINK( AutoHeightClickHdl, Button *, void);
DECL_LINK(AutoWidthClickHdl, weld::ToggleButton&, void);
DECL_LINK(AutoHeightClickHdl, weld::ToggleButton&, void);
// update example
void UpdateExample();
DECL_LINK( ModifyHdl, Edit&, void );
DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void);
void Init(const SfxItemSet& rSet, bool bReset = false);
void Init(const SfxItemSet& rSet);
// OD 12.11.2003 #i22341# - adjustment to handle maps, that are ambiguous
// in the alignment.
sal_Int32 FillPosLB( const FrameMap* _pMap,
const sal_Int16 _nAlign,
const sal_Int16 _nRel,
ListBox& _rLB );
weld::ComboBox& _rLB );
// OD 14.11.2003 #i22341# - adjustment to handle maps, that are ambiguous
// in their string entries.
void FillRelLB( const FrameMap* _pMap,
const sal_uInt16 _nLBSelPos,
const sal_Int16 _nAlign,
const sal_Int16 _nRel,
ListBox& _rLB,
FixedText& _rFT );
static sal_Int32 GetMapPos(const FrameMap *pMap, ListBox const &rAlignLB);
static sal_Int16 GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos, ListBox const &rRelationLB);
static sal_Int16 GetRelation(ListBox const &rRelationLB);
weld::ComboBox& _rLB,
weld::Label& _rFT );
static sal_Int32 GetMapPos(const FrameMap *pMap, const weld::ComboBox& rAlignLB);
static sal_Int16 GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos, const weld::ComboBox& rRelationLB);
static sal_Int16 GetRelation(const weld::ComboBox& rRelationLB);
RndStdIds GetAnchor();
void setOptimalFrameWidth();
......@@ -183,9 +185,8 @@ class SwFramePage: public SfxTabPage
static const sal_uInt16 aPageRg[];
public:
SwFramePage(vcl::Window *pParent, const SfxItemSet &rSet);
SwFramePage(TabPageParent pParent, const SfxItemSet &rSet);
virtual ~SwFramePage() override;
virtual void dispose() override;
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet *rSet);
static const sal_uInt16* GetRanges() { return aPageRg; }
......
......@@ -25,69 +25,6 @@
#include <swdllapi.h>
#include "uitool.hxx"
class SW_DLLPUBLIC PercentField
{
VclPtr<MetricField> m_pField;
sal_Int64 nRefValue; // 100% value for conversion (in Twips)
sal_Int64 nOldMax;
sal_Int64 nOldMin;
sal_Int64 nOldSpinSize;
sal_Int64 nOldBaseValue;
sal_Int64 nLastPercent;
sal_Int64 nLastValue;
sal_uInt16 nOldDigits;
FieldUnit eOldUnit;
bool bLockAutoCalculation; //prevent recalculation of percent values when the
//reference value is changed
SAL_DLLPRIVATE static sal_Int64 ImpPower10(sal_uInt16 n);
public:
PercentField();
void set(MetricField *pField);
const MetricField* get() const { return m_pField; }
MetricField* get() { return m_pField; }
void SetModifyHdl(const Link<Edit&,void>& rLink) { m_pField->SetModifyHdl(rLink); }
void SetLoseFocusHdl(const Link<Control&,void>& rLink) { m_pField->SetLoseFocusHdl(rLink); }
void SetMetric(FieldUnit eUnit) { ::SetMetric(*m_pField, eUnit); }
void Enable(bool bEnable = true) { m_pField->Enable(bEnable); }
void Disable() { m_pField->Disable(); }
void SetValue(sal_Int64 nNewValue) { m_pField->SetValue(nNewValue, FieldUnit::NONE); }
void SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
void SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit);
void SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit);
sal_Int64 GetValue(FieldUnit eOutUnit = FieldUnit::NONE);
bool IsValueModified();
void SetMax(sal_Int64 nNewMax, FieldUnit eInUnit);
void SetMin(sal_Int64 nNewMin, FieldUnit eInUnit);
sal_Int64 GetMin() const { return m_pField->GetMin(); }
sal_Int64 NormalizePercent(sal_Int64 nValue);
sal_Int64 DenormalizePercent(sal_Int64 nValue);
sal_Int64 Normalize( sal_Int64 nValue ) const { return m_pField->Normalize(nValue); }
void SetRefValue(sal_Int64 nValue);
sal_Int64 GetRealValue(FieldUnit eOutUnit);
sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
void ShowPercent(bool bPercent);
void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
};
class SW_DLLPUBLIC SwPercentField
{
std::unique_ptr<weld::MetricSpinButton> m_pField;
......@@ -101,6 +38,8 @@ class SW_DLLPUBLIC SwPercentField
int nLastValue;
sal_uInt16 nOldDigits;
FieldUnit eOldUnit;
bool bLockAutoCalculation; //prevent recalculation of percent values when the
//reference value is changed
SAL_DLLPRIVATE static int ImpPower10(sal_uInt16 n);
......@@ -121,16 +60,19 @@ public:
void SetMetricFieldMin(int nNewMin) { m_pField->set_min(nNewMin, FieldUnit::NONE); }
void SetMetricFieldMax(int nNewMax) { m_pField->set_max(nNewMax, FieldUnit::NONE); }
void SetPrcntValue(int nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
void set_value(int nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
int get_value(FieldUnit eOutUnit = FieldUnit::NONE);
void set_min(int nNewMin, FieldUnit eInUnit);
void set_max(int nNewMax, FieldUnit eInUnit);
int get_min(FieldUnit eOutUnit = FieldUnit::NONE) const { return m_pField->get_min(eOutUnit); }
int NormalizePercent(int nValue);
int DenormalizePercent(int nValue);
int normalize(int nValue) const { return m_pField->normalize(nValue); }
void SetRefValue(int nValue);
int GetRealValue(FieldUnit eOutUnit);
......@@ -138,6 +80,7 @@ public:
void ShowPercent(bool bPercent);
void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
};
......
......@@ -19,266 +19,6 @@
#include <prcntfld.hxx>
PercentField::PercentField()
: m_pField(nullptr)
, nRefValue(0)
, nOldMax(0)
, nOldMin(0)
, nOldSpinSize(0)
, nOldBaseValue(0)
, nLastPercent(-1)
, nLastValue(-1)
, nOldDigits(0)
, eOldUnit(FieldUnit::NONE)
, bLockAutoCalculation(false)
{
}
void PercentField::set(MetricField *pField)
{
m_pField = pField;
nOldSpinSize = m_pField->GetSpinSize();
nRefValue = DenormalizePercent(m_pField->GetMax(FieldUnit::TWIP));
nOldDigits = m_pField->GetDecimalDigits();
m_pField->SetCustomUnitText(OUString('%'));
}
void PercentField::SetRefValue(sal_Int64 nValue)
{
sal_Int64 nRealValue = GetRealValue(eOldUnit);
nRefValue = nValue;
if (!bLockAutoCalculation && (m_pField->GetUnit() == FieldUnit::CUSTOM))
SetPrcntValue(nRealValue, eOldUnit);
}
void PercentField::ShowPercent(bool bPercent)
{
if ((bPercent && m_pField->GetUnit() == FieldUnit::CUSTOM) ||
(!bPercent && m_pField->GetUnit() != FieldUnit::CUSTOM))
return;
sal_Int64 nOldValue;
if (bPercent)
{
sal_Int64 nCurrentWidth, nPercent;
nOldValue = GetValue();
eOldUnit = m_pField->GetUnit();
nOldDigits = m_pField->GetDecimalDigits();
nOldMin = m_pField->GetMin();
nOldMax = m_pField->GetMax();
nOldSpinSize = m_pField->GetSpinSize();
nOldBaseValue = m_pField->GetBaseValue();
m_pField->SetUnit(FieldUnit::CUSTOM);
m_pField->SetDecimalDigits( 0 );
nCurrentWidth = MetricField::ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
// round to 0.5 percent
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
m_pField->SetMin(std::max(static_cast< sal_Int64 >(1), nPercent));
m_pField->SetMax(100);
m_pField->SetSpinSize(5);
m_pField->SetBaseValue(0);
if (nOldValue != nLastValue)
{
nCurrentWidth = MetricField::ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
m_pField->SetValue(nPercent);
nLastPercent = nPercent;
nLastValue = nOldValue;
}
else
m_pField->SetValue(nLastPercent);
}
else
{
sal_Int64 nOldPercent = GetValue(FieldUnit::CUSTOM);
nOldValue = Convert(GetValue(), m_pField->GetUnit(), eOldUnit);
m_pField->SetUnit(eOldUnit);
m_pField->SetDecimalDigits(nOldDigits);
m_pField->SetMin(nOldMin);
m_pField->SetMax(nOldMax);
m_pField->SetSpinSize(nOldSpinSize);
m_pField->SetBaseValue(nOldBaseValue);
if (nOldPercent != nLastPercent)
{
SetPrcntValue(nOldValue, eOldUnit);
nLastPercent = nOldPercent;
nLastValue = nOldValue;
}
else
SetPrcntValue(nLastValue, eOldUnit);
}
}
void PercentField::SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM || eInUnit == FieldUnit::CUSTOM)
m_pField->SetValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()));
else
{
// Overwrite output value, do not restore later
sal_Int64 nPercent, nCurrentWidth;
if(eInUnit == FieldUnit::TWIP)
{
nCurrentWidth = MetricField::ConvertValue(nNewValue, 0, nOldDigits, FieldUnit::TWIP, FieldUnit::TWIP);
}
else
{
sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
}
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
m_pField->SetValue(nPercent);
}
}
void PercentField::SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit)
{
if (m_pField->GetUnit() == FieldUnit::CUSTOM)
nOldBaseValue = MetricField::ConvertValue(nNewValue, 0, nOldDigits, eInUnit, eOldUnit);
else
m_pField->SetBaseValue(nNewValue, eInUnit);
}
sal_Int64 PercentField::GetValue(FieldUnit eOutUnit)
{
return Convert(m_pField->GetValue(), m_pField->GetUnit(), eOutUnit);
}
void PercentField::SetMin(sal_Int64 nNewMin, FieldUnit eInUnit)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
m_pField->SetMin(nNewMin, eInUnit);
else
{
if (eInUnit == FieldUnit::NONE)
eInUnit = eOldUnit;
nOldMin = Convert(nNewMin, eInUnit, eOldUnit);
sal_Int64 nPercent = Convert(nNewMin, eInUnit, FieldUnit::CUSTOM);
m_pField->SetMin(std::max( static_cast< sal_Int64 >(1), nPercent));
}
}
void PercentField::SetMax(sal_Int64 nNewMax, FieldUnit eInUnit)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
m_pField->SetMax(nNewMax, eInUnit);
}
sal_Int64 PercentField::NormalizePercent(sal_Int64 nValue)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
nValue = m_pField->Normalize(nValue);
else
nValue = nValue * ImpPower10(nOldDigits);
return nValue;
}
sal_Int64 PercentField::DenormalizePercent(sal_Int64 nValue)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
nValue = m_pField->Denormalize(nValue);
else
{
sal_Int64 nFactor = ImpPower10(nOldDigits);
nValue = ((nValue+(nFactor/2)) / nFactor);
}
return nValue;
}
bool PercentField::IsValueModified()
{
if (m_pField->GetUnit() == FieldUnit::CUSTOM)
return true;
else
return m_pField->IsValueModified();
}
void PercentField::SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM || eInUnit == FieldUnit::CUSTOM)
m_pField->SetUserValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()),FieldUnit::NONE);
else
{
// Overwrite output value, do not restore later
sal_Int64 nPercent, nCurrentWidth;
if (eInUnit == FieldUnit::TWIP)
{
nCurrentWidth = MetricField::ConvertValue(nNewValue, 0, nOldDigits, FieldUnit::TWIP, FieldUnit::TWIP);
}
else
{
sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
}
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
m_pField->SetUserValue(nPercent,FieldUnit::NONE);
}
}
sal_Int64 PercentField::ImpPower10(sal_uInt16 n)
{
sal_Int64 nValue = 1;
for (sal_uInt16 i=0; i < n; ++i)
nValue *= 10;
return nValue;
}
sal_Int64 PercentField::GetRealValue(FieldUnit eOutUnit)
{
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
return GetValue(eOutUnit);
else
return Convert(GetValue(), m_pField->GetUnit(), eOutUnit);
}
sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit)
{
if (eInUnit == eOutUnit ||
(eInUnit == FieldUnit::NONE && eOutUnit == m_pField->GetUnit()) ||
(eOutUnit == FieldUnit::NONE && eInUnit == m_pField->GetUnit()))
return nValue;
if (eInUnit == FieldUnit::CUSTOM)
{
// Convert to metric
sal_Int64 nTwipValue = (nRefValue * nValue + 50) / 100;
if (eOutUnit == FieldUnit::TWIP) // Only convert if necessary
return NormalizePercent(nTwipValue);
else
return MetricField::ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FieldUnit::TWIP, eOutUnit);
}
if (eOutUnit == FieldUnit::CUSTOM)
{
// Convert to percent
sal_Int64 nCurrentWidth;
nValue = DenormalizePercent(nValue);
if (eInUnit == FieldUnit::TWIP) // Only convert if necessary
nCurrentWidth = nValue;
else
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, FieldUnit::TWIP);
// Round to 0.5 percent
return ((nCurrentWidth * 1000) / nRefValue + 5) / 10;
}
return MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit);
}
SwPercentField::SwPercentField(std::unique_ptr<weld::MetricSpinButton> pControl)
: m_pField(std::move(pControl))
, nOldMax(0)
......@@ -287,6 +27,7 @@ SwPercentField::SwPercentField(std::unique_ptr<weld::MetricSpinButton> pControl)
, nLastValue(-1)
, nOldDigits(m_pField->get_digits())
, eOldUnit(FieldUnit::NONE)
, bLockAutoCalculation(false)
{
int nMin, nMax;
m_pField->get_range(nMin, nMax, FieldUnit::TWIP);
......@@ -300,8 +41,8 @@ void SwPercentField::SetRefValue(int nValue)
nRefValue = nValue;
if (m_pField->get_unit() == FieldUnit::PERCENT)
SetPrcntValue(nRealValue, eOldUnit);
if (!bLockAutoCalculation && (m_pField->get_unit() == FieldUnit::PERCENT))
set_value(nRealValue, eOldUnit);
}
void SwPercentField::ShowPercent(bool bPercent)
......@@ -355,16 +96,16 @@ void SwPercentField::ShowPercent(bool bPercent)
if (nOldPercent != nLastPercent)
{
SetPrcntValue(nOldValue, eOldUnit);
set_value(nOldValue, eOldUnit);
nLastPercent = nOldPercent;
nLastValue = nOldValue;
}
else
SetPrcntValue(nLastValue, eOldUnit);
set_value(nLastValue, eOldUnit);
}
}
void SwPercentField::SetPrcntValue(int nNewValue, FieldUnit eInUnit)
void SwPercentField::set_value(int nNewValue, FieldUnit eInUnit)
{
if (m_pField->get_unit() != FieldUnit::PERCENT || eInUnit == FieldUnit::PERCENT)
m_pField->set_value(Convert(nNewValue, eInUnit, m_pField->get_unit()), FieldUnit::NONE);
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
......@@ -15,6 +15,18 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="lower">0.050000000000000003</property>
<property name="upper">99.989999999999995</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment4">
<property name="lower">-99.989999999999995</property>
<property name="upper">99.989999999999995</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkGrid" id="FrameTypePage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -56,9 +68,10 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkSpinButton" id="width:0.00cm">
<object class="GtkSpinButton" id="width">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
<property name="digits">2</property>
</object>
......@@ -95,7 +108,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|autowidthft">_Width (at least)</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">width:0.00cm</property>
<property name="mnemonic_widget">width</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -109,7 +122,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|widthft">_Width</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">width:0.00cm</property>
<property name="mnemonic_widget">width</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -180,10 +193,11 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkSpinButton" id="height:0.00cm">
<object class="GtkSpinButton" id="height">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment3</property>
<property name="digits">2</property>
</object>
<packing>
......@@ -219,7 +233,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|autoheightft">H_eight (at least)</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">height:0.00cm</property>
<property name="mnemonic_widget">height</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -233,7 +247,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|heightft">H_eight</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">height:0.00cm</property>
<property name="mnemonic_widget">height</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -351,7 +365,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="svxlo-SvxSwFrameExample" id="preview">
<object class="GtkDrawingArea" id="preview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
......@@ -398,7 +412,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">topara</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -414,7 +427,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">tochar</property>
<property name="group">topage</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -430,7 +443,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">aschar</property>
<property name="group">topage</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -446,7 +459,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">toframe</property>
<property name="group">topage</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -533,7 +546,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|horibyft">b_y</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">byhori:0.00cm</property>
<property name="mnemonic_widget">byhori</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -547,7 +560,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="frmtypepage|vertbyft">by</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">byvert:0.00cm</property>
<property name="mnemonic_widget">byvert</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -570,9 +583,10 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="byhori:0.00cm">
<object class="GtkSpinButton" id="byhori">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment2</property>
<property name="digits">2</property>
</object>
......@@ -626,10 +640,11 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="byvert:0.00cm">
<object class="GtkSpinButton" id="byvert">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment4</property>
<property name="digits">2</property>
</object>
<packing>
......
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