Kaydet (Commit) 7958091b authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxPageDescPage

Change-Id: I5e2457b51a294cbdacc5c78db4ec0a048567b93d
Reviewed-on: https://gerrit.libreoffice.org/55877
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst d60d695f
......@@ -25,6 +25,7 @@
#include <vcl/group.hxx>
#include <vcl/lstbox.hxx>
#include <svx/pagectrl.hxx>
#include <svx/pagenumberlistbox.hxx>
#include <svx/papersizelistbox.hxx>
#include <svx/frmdirlbox.hxx>
#include <editeng/svxenum.hxx>
......@@ -74,55 +75,7 @@ class SvxPageDescPage : public SfxTabPage
static const sal_uInt16 pRanges[];
private:
// paper format
VclPtr<PaperSizeListBox> m_pPaperSizeBox;
VclPtr<MetricField> m_pPaperWidthEdit;
VclPtr<MetricField> m_pPaperHeightEdit;
VclPtr<FixedText> m_pOrientationFT;
VclPtr<RadioButton> m_pPortraitBtn;
VclPtr<RadioButton> m_pLandscapeBtn;
VclPtr<SvxPageWindow> m_pBspWin;
VclPtr<FixedText> m_pTextFlowLbl;
VclPtr<svx::FrameDirectionListBox> m_pTextFlowBox;
VclPtr<ListBox> m_pPaperTrayBox;
// Margins
VclPtr<FixedText> m_pLeftMarginLbl;
VclPtr<MetricField> m_pLeftMarginEdit;
VclPtr<FixedText> m_pRightMarginLbl;
VclPtr<MetricField> m_pRightMarginEdit;
VclPtr<MetricField> m_pTopMarginEdit;
VclPtr<MetricField> m_pBottomMarginEdit;
// layout settings
VclPtr<FixedText> m_pPageText;
VclPtr<ListBox> m_pLayoutBox;
VclPtr<ListBox> m_pNumberFormatBox;
//Extras Calc
VclPtr<FixedText> m_pTblAlignFT;
VclPtr<CheckBox> m_pHorzBox;
VclPtr<CheckBox> m_pVertBox;
// Impress and Draw
VclPtr<CheckBox> m_pAdaptBox;
//Register Writer
VclPtr<CheckBox> m_pRegisterCB;
VclPtr<FixedText> m_pRegisterFT;
VclPtr<ListBox> m_pRegisterLB;
OUString sStandardRegister;
VclPtr<FixedText> m_pInsideLbl;
VclPtr<FixedText> m_pOutsideLbl;
VclPtr<FixedText> m_pPrintRangeQueryText;
OUString sStandardRegister;
long nFirstLeftMargin;
long nFirstRightMargin;
long nFirstTopMargin;
......@@ -143,38 +96,76 @@ private:
bool mbDelPrinter : 1;
bool mbEnableDrawingLayerFillStyles : 1;
PageWindow m_aBspWin;
// paper format
std::unique_ptr<SvxPaperSizeListBox> m_xPaperSizeBox;
std::unique_ptr<weld::MetricSpinButton> m_xPaperWidthEdit;
std::unique_ptr<weld::MetricSpinButton> m_xPaperHeightEdit;
std::unique_ptr<weld::Label> m_xOrientationFT;
std::unique_ptr<weld::RadioButton> m_xPortraitBtn;
std::unique_ptr<weld::RadioButton> m_xLandscapeBtn;
std::unique_ptr<weld::Label> m_xTextFlowLbl;
std::unique_ptr<svx::SvxFrameDirectionListBox> m_xTextFlowBox;
std::unique_ptr<weld::ComboBoxText> m_xPaperTrayBox;
// Margins
std::unique_ptr<weld::Label> m_xLeftMarginLbl;
std::unique_ptr<weld::MetricSpinButton> m_xLeftMarginEdit;
std::unique_ptr<weld::Label> m_xRightMarginLbl;
std::unique_ptr<weld::MetricSpinButton> m_xRightMarginEdit;
std::unique_ptr<weld::MetricSpinButton> m_xTopMarginEdit;
std::unique_ptr<weld::MetricSpinButton> m_xBottomMarginEdit;
// layout settings
std::unique_ptr<weld::Label> m_xPageText;
std::unique_ptr<weld::ComboBoxText> m_xLayoutBox;
std::unique_ptr<SvxPageNumberListBox> m_xNumberFormatBox;
//Extras Calc
std::unique_ptr<weld::Label> m_xTblAlignFT;
std::unique_ptr<weld::CheckButton> m_xHorzBox;
std::unique_ptr<weld::CheckButton> m_xVertBox;
// Impress and Draw
std::unique_ptr<weld::CheckButton> m_xAdaptBox;
//Register Writer
std::unique_ptr<weld::CheckButton> m_xRegisterCB;
std::unique_ptr<weld::Label> m_xRegisterFT;
std::unique_ptr<weld::ComboBoxText> m_xRegisterLB;
std::unique_ptr<weld::Label> m_xInsideLbl;
std::unique_ptr<weld::Label> m_xOutsideLbl;
std::unique_ptr<weld::Label> m_xPrintRangeQueryText;
std::unique_ptr<weld::CustomWeld> m_xBspWin;
void Init_Impl();
DECL_LINK( LayoutHdl_Impl, ListBox&, void);
DECL_LINK( PaperBinHdl_Impl, Control&, void);
DECL_LINK( SwapOrientation_Impl, Button*, void );
void SwapFirstValues_Impl( bool bSet );
DECL_LINK( BorderModify_Impl, Edit&, void);
void InitHeadFoot_Impl( const SfxItemSet& rSet );
DECL_LINK( CenterHdl_Impl, Button*, void);
void UpdateExample_Impl( bool bResetbackground = false );
DECL_LINK(LayoutHdl_Impl, weld::ComboBoxText&, void);
DECL_LINK(PaperBinHdl_Impl, weld::ComboBoxText&, void);
DECL_LINK(SwapOrientation_Impl, weld::ToggleButton&, void);
void SwapFirstValues_Impl( bool bSet );
DECL_LINK(BorderModify_Impl, weld::MetricSpinButton&, void);
void InitHeadFoot_Impl( const SfxItemSet& rSet );
DECL_LINK(CenterHdl_Impl, weld::ToggleButton&, void);
void UpdateExample_Impl( bool bResetbackground = false );
DECL_LINK( PaperSizeSelect_Impl, ListBox&, void );
DECL_LINK( PaperSizeModify_Impl, Edit&, void);
DECL_LINK(PaperSizeSelect_Impl, weld::ComboBoxText&, void );
DECL_LINK(PaperSizeModify_Impl, weld::MetricSpinButton&, void);
DECL_LINK( FrameDirectionModify_Impl, ListBox&, void );
DECL_LINK(FrameDirectionModify_Impl, weld::ComboBoxText&, void );
void ResetBackground_Impl( const SfxItemSet& rSet );
void ResetBackground_Impl( const SfxItemSet& rSet );
DECL_LINK( RangeHdl_Impl, Control&, void );
void CalcMargin_Impl();
void RangeHdl_Impl();
void CalcMargin_Impl();
DECL_LINK( RegisterModify, Button*, void );
DECL_LINK(RegisterModify, weld::ToggleButton&, void);
// page direction
/** Disables vertical page direction entries in the text flow listbox. */
void DisableVerticalPageDir();
bool IsPrinterRangeOverflow( MetricField& rField, long nFirstMargin,
long nLastMargin, MarginPosition nPos );
bool IsPrinterRangeOverflow(weld::MetricSpinButton& rField, long nFirstMargin,
long nLastMargin, MarginPosition nPos);
void CheckMarginEdits( bool _bClear );
bool IsMarginOutOfRange();
SvxPageDescPage( vcl::Window* pParent, const SfxItemSet& rSet );
SvxPageDescPage(TabPageParent pParent, const SfxItemSet& rSet);
protected:
virtual void ActivatePage( const SfxItemSet& rSet ) override;
......
This diff is collapsed.
......@@ -365,9 +365,6 @@
<glade-widget-class title="Paragraph Preview" name="svxlo-SvxParaPrevWindow"
generic-name="Paragraph Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Page Preview" name="svxlo-SvxPageWindow"
generic-name="Page Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Page Preview" name="swlo-SwPageGridExample"
generic-name="Grid Page Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -23,6 +23,7 @@
#include <com/sun/star/text/DefaultNumberingProvider.hpp>
#include <com/sun/star/text/XNumberingTypeInfo.hpp>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
#include <svx/svxdllapi.h>
using namespace css::uno;
......@@ -44,7 +45,8 @@ public:
Pass ::std::numeric_limits<sal_uInt16>::max() if there is no such
restriction.
*/
static void GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove );
static void GetI18nNumbering(ListBox& rFmtLB, sal_uInt16 nDoNotRemove);
static void GetI18nNumbering(weld::ComboBoxText& rFmtLB, sal_uInt16 nDoNotRemove);
};
#endif
......
......@@ -66,10 +66,14 @@ public:
}
bool get_visible() const { return m_xControl->get_visible(); }
void save_value() { m_xControl->save_value(); }
bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
SvxFrameDirection get_active_id() const { return static_cast<SvxFrameDirection>(m_xControl->get_active_id().toUInt32()); }
void set_active_id(SvxFrameDirection eDir) { m_xControl->set_active_id(OUString::number(static_cast<sal_uInt32>(eDir))); }
void save_value() { m_xControl->save_value(); }
void remove_id(SvxFrameDirection eDir) { m_xControl->remove_id(OUString::number(static_cast<sal_uInt32>(eDir))); }
void hide() { m_xControl->hide(); }
void show() { m_xControl->show(); }
int get_count() const { return m_xControl->get_count(); }
/** Inserts a string with corresponding direction enum into the listbox. */
void append(SvxFrameDirection eDirection, const OUString& rString)
{
......
......@@ -22,6 +22,7 @@
#include <svx/svxdllapi.h>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
class SVX_DLLPUBLIC PageNumberListBox : public ListBox
{
......@@ -33,5 +34,21 @@ public:
Size GetOptimalSize() const override;
};
class SVX_DLLPUBLIC SvxPageNumberListBox
{
private:
std::unique_ptr<weld::ComboBoxText> m_xControl;
public:
SvxPageNumberListBox(weld::ComboBoxText* pControl);
void SetSelection( sal_uInt16 );
int get_count() const { return m_xControl->get_count(); }
OUString get_id(int pos) const { return m_xControl->get_id(pos); }
int get_active() const { return m_xControl->get_active(); }
void set_active(int pos) { m_xControl->set_active(pos); }
void save_value() { m_xControl->save_value(); }
bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
weld::ComboBoxText& get_widget() const { return *m_xControl; }
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -23,6 +23,7 @@
#include <i18nutil/paper.hxx>
#include <svx/svxdllapi.h>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
enum class PaperSizeApp
{
......@@ -42,5 +43,24 @@ public:
Size GetOptimalSize() const override;
};
class SVX_DLLPUBLIC SvxPaperSizeListBox
{
private:
std::unique_ptr<weld::ComboBoxText> m_xControl;
public:
SvxPaperSizeListBox(weld::ComboBoxText *pControl);
void FillPaperSizeEntries(PaperSizeApp eApp);
void SetSelection(Paper eSize);
Paper GetSelection() const;
void connect_changed(const Link<weld::ComboBoxText&, void>& rLink) { m_xControl->connect_changed(rLink); }
void clear() { m_xControl->clear(); }
void save_value() { return m_xControl->save_value(); }
bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
weld::ComboBoxText& get_widget() const { return *m_xControl; }
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -255,6 +255,7 @@ public:
virtual void remove(int pos) = 0;
void remove_text(const OUString& rText) { remove(find_text(rText)); }
virtual int find_text(const OUString& rStr) const = 0;
void remove_id(const OUString& rId) { remove(find_id(rId)); }
virtual int find_id(const OUString& rId) const = 0;
virtual int get_count() const = 0;
virtual void make_sorted() = 0;
......@@ -590,21 +591,30 @@ public:
update_width_chars();
}
int convert_value_to(int nValue, FieldUnit eValueUnit) const
{
return ConvertValue(nValue, m_eSrcUnit, eValueUnit);
}
int convert_value_from(int nValue, FieldUnit eValueUnit) const
{
return ConvertValue(nValue, eValueUnit, m_eSrcUnit);
}
void set_value(int nValue, FieldUnit eValueUnit)
{
m_xSpinButton->set_value(ConvertValue(nValue, eValueUnit, m_eSrcUnit));
m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit));
}
int get_value(FieldUnit eDestUnit) const
{
int nValue = m_xSpinButton->get_value();
return ConvertValue(nValue, m_eSrcUnit, eDestUnit);
return convert_value_to(m_xSpinButton->get_value(), eDestUnit);
}
void set_range(int min, int max, FieldUnit eValueUnit)
{
min = ConvertValue(min, eValueUnit, m_eSrcUnit);
max = ConvertValue(max, eValueUnit, m_eSrcUnit);
min = convert_value_from(min, eValueUnit);
max = convert_value_from(max, eValueUnit);
m_xSpinButton->set_range(min, max);
update_width_chars();
}
......@@ -612,8 +622,8 @@ public:
void get_range(int& min, int& max, FieldUnit eDestUnit) const
{
m_xSpinButton->get_range(min, max);
min = ConvertValue(min, m_eSrcUnit, eDestUnit);
max = ConvertValue(max, m_eSrcUnit, eDestUnit);
min = convert_value_to(min, eDestUnit);
max = convert_value_to(max, eDestUnit);
}
void set_min(int min, FieldUnit eValueUnit)
......@@ -646,16 +656,16 @@ public:
void set_increments(int step, int page, FieldUnit eValueUnit)
{
step = ConvertValue(step, eValueUnit, m_eSrcUnit);
page = ConvertValue(page, eValueUnit, m_eSrcUnit);
step = convert_value_from(step, eValueUnit);
page = convert_value_from(page, eValueUnit);
m_xSpinButton->set_increments(step, page);
}
void get_increments(int& step, int& page, FieldUnit eDestUnit) const
{
m_xSpinButton->get_increments(step, page);
step = ConvertValue(step, m_eSrcUnit, eDestUnit);
page = ConvertValue(page, m_eSrcUnit, eDestUnit);
step = convert_value_to(step, eDestUnit);
page = convert_value_to(page, eDestUnit);
}
void connect_value_changed(const Link<MetricSpinButton&, void>& rLink)
......
......@@ -219,8 +219,8 @@ cui/uiconfig/ui/optsavepage.ui://GtkLabel[@id='autosave_mins'] orphan-label
cui/uiconfig/ui/optviewpage.ui://GtkComboBoxText[@id='iconsize'] duplicate-mnemonic
cui/uiconfig/ui/optviewpage.ui://GtkComboBoxText[@id='sidebariconsize'] no-labelled-by
cui/uiconfig/ui/optviewpage.ui://GtkComboBoxText[@id='notebookbariconsize'] no-labelled-by
cui/uiconfig/ui/pageformatpage.ui://GtkSpinButton[@id='spinMargLeft:0.00cm'] duplicate-mnemonic
cui/uiconfig/ui/pageformatpage.ui://GtkSpinButton[@id='spinMargRight:0.00cm'] duplicate-mnemonic
cui/uiconfig/ui/pageformatpage.ui://GtkSpinButton[@id='spinMargLeft'] duplicate-mnemonic
cui/uiconfig/ui/pageformatpage.ui://GtkSpinButton[@id='spinMargRight'] duplicate-mnemonic
cui/uiconfig/ui/paraindentspacing.ui://GtkComboBox[@id='comboLB_LINEDIST'] no-labelled-by
cui/uiconfig/ui/paraindentspacing.ui://GtkLabel[@id='labelFT_LINEDIST'] orphan-label
cui/uiconfig/ui/paraindentspacing.ui://GtkSpinButton[@id='spinED_LINEDISTPERCENT'] no-labelled-by
......
......@@ -89,4 +89,56 @@ void SvxNumOptionsTabPageHelper::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 n
}
}
void SvxNumOptionsTabPageHelper::GetI18nNumbering(weld::ComboBoxText& rFmtLB, sal_uInt16 nDoNotRemove)
{
Reference<XDefaultNumberingProvider> xDefNum = GetNumberingProvider();
Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY);
// Extended numbering schemes present in the resource but not offered by
// the i18n framework per configuration must be removed from the listbox.
// Do not remove a special entry matching nDoNotRemove.
const sal_uInt16 nDontRemove = SAL_MAX_UINT16;
::std::vector< sal_uInt16> aRemove( rFmtLB.get_count(), nDontRemove);
for (size_t i=0; i<aRemove.size(); ++i)
{
sal_uInt16 nEntryData = rFmtLB.get_id(i).toInt32();
if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove)
aRemove[i] = nEntryData;
}
if(xInfo.is())
{
Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes( );
const sal_Int16* pTypes = aTypes.getConstArray();
for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
{
sal_Int16 nCurrent = pTypes[nType];
if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
{
bool bInsert = true;
for (int nEntry = 0; nEntry < rFmtLB.get_count(); ++nEntry)
{
sal_uInt16 nEntryData = rFmtLB.get_id(nEntry).toInt32();
if (nEntryData == static_cast<sal_uInt16>(nCurrent))
{
bInsert = false;
aRemove[nEntry] = nDontRemove;
break;
}
}
if(bInsert)
{
OUString aIdent = xInfo->getNumberingIdentifier( nCurrent );
rFmtLB.append(OUString::number(nCurrent), aIdent);
}
}
}
}
for (unsigned short i : aRemove)
{
if (i == nDontRemove)
continue;
rFmtLB.remove_id(OUString::number(i));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -86,8 +86,6 @@ SvxPageWindow::~SvxPageWindow()
disposeOnce();
}
VCL_BUILDER_FACTORY(SvxPageWindow)
void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
Fraction aXScale(aWinSize.Width(), std::max(long(aSize.Width() * 2 + aSize.Width() / 8), 1L));
......
......@@ -74,4 +74,48 @@ Size PageNumberListBox::GetOptimalSize() const
return Size(150, ListBox::GetOptimalSize().Height());
}
SvxPageNumberListBox::SvxPageNumberListBox(weld::ComboBoxText* pControl)
: m_xControl(pControl)
{
m_xControl->set_size_request(150, -1);
for (size_t i = 0; i < SAL_N_ELEMENTS(RID_SVXSTRARY_NUMBERINGTYPE); ++i)
{
sal_uInt16 nData = RID_SVXSTRARY_NUMBERINGTYPE[i].second;
switch (nData)
{
// String list array is also used in Writer and contains strings
// for Bullet and Graphics, ignore those here.
case css::style::NumberingType::CHAR_SPECIAL:
case css::style::NumberingType::BITMAP:
case css::style::NumberingType::BITMAP | LINK_TOKEN:
break;
default:
{
OUString aStr = SvxResId(RID_SVXSTRARY_NUMBERINGTYPE[i].first);
m_xControl->append(OUString::number(nData), aStr);
break;
}
}
}
}
void SvxPageNumberListBox::SetSelection( sal_uInt16 nPos )
{
int nEntryCount = m_xControl->get_count();
int nSelPos = -1;
for (sal_Int32 i = 0; i < nEntryCount; ++i)
{
sal_uInt16 nTmp = static_cast<sal_uInt16>(m_xControl->get_id(i).toInt32());
if (nTmp == nPos)
{
nSelPos = i;
break;
}
}
m_xControl->set_active(nSelPos);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -83,5 +83,55 @@ Size PaperSizeListBox::GetOptimalSize() const
{
return Size(150, ListBox::GetOptimalSize().Height());
}
SvxPaperSizeListBox::SvxPaperSizeListBox(weld::ComboBoxText* pControl)
: m_xControl(pControl)
{
m_xControl->set_size_request(150, -1);
}
void SvxPaperSizeListBox::FillPaperSizeEntries( PaperSizeApp eApp )
{
const std::pair<const char*, int>* pPaperAry = eApp == PaperSizeApp::Std ?
RID_SVXSTRARY_PAPERSIZE_STD : RID_SVXSTRARY_PAPERSIZE_DRAW;
sal_uInt32 nCnt = eApp == PaperSizeApp::Std ?
SAL_N_ELEMENTS(RID_SVXSTRARY_PAPERSIZE_STD) : SAL_N_ELEMENTS(RID_SVXSTRARY_PAPERSIZE_DRAW);
for ( sal_uInt32 i = 0; i < nCnt; ++i )
{
OUString aStr = SvxResId(pPaperAry[i].first);
Paper eSize = static_cast<Paper>(pPaperAry[i].second);
m_xControl->append(OUString::number(static_cast<sal_Int32>(eSize)), aStr);
}
}
void SvxPaperSizeListBox::SetSelection( Paper ePreselectPaper )
{
int nEntryCount = m_xControl->get_count();
int nSelPos = -1;
int nUserPos = -1;
for (int i = 0; i < nEntryCount; ++i)
{
Paper eTmp = static_cast<Paper>(m_xControl->get_id(i).toInt32());
if (eTmp == ePreselectPaper)
{
nSelPos = i;
break;
}
if (eTmp == PAPER_USER)
nUserPos = i;
}
// preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
m_xControl->set_active((nSelPos != -1) ? nSelPos : nUserPos);
}
Paper SvxPaperSizeListBox::GetSelection() const
{
return static_cast<Paper>(m_xControl->get_active_id().toInt32());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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