Kaydet (Commit) 338e5626 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld ScAutoFormatDlg

Change-Id: I700034eefe9fb25ee331645283bd3611c88faf5b
Reviewed-on: https://gerrit.libreoffice.org/69052
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst dd552855
......@@ -189,9 +189,6 @@
<glade-widget-class title="Table Preview" name="swuilo-AutoFmtPreview"
generic-name="Table Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Calc Table Preview" name="sclo-ScAutoFmtPreview"
generic-name="Calc Table Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Extension List" name="deploymentgui-ExtensionBox"
generic-name="Extensions List" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -400,7 +400,7 @@ public:
virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) = 0;
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(vcl::Window* pParent,
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData *pViewData) = 0;
......
......@@ -32,9 +32,8 @@ class autoFormat(UITestCase):
alignmentcb = xDialog.getChild("alignmentcb")
autofitcb = xDialog.getChild("autofitcb")
props = {"TEXT": "Financial"}
actionProps = mkPropertyValues(props)
formatlb.executeAction("SELECT", actionProps)
entry = formatlb.getChild("7") #Financial
entry.executeAction("SELECT", tuple())
numformatcb.executeAction("CLICK", tuple())
bordercb.executeAction("CLICK", tuple())
fontcb.executeAction("CLICK", tuple())
......@@ -57,9 +56,8 @@ class autoFormat(UITestCase):
alignmentcb = xDialog.getChild("alignmentcb")
autofitcb = xDialog.getChild("autofitcb")
props = {"TEXT": "Financial"}
actionProps = mkPropertyValues(props)
formatlb.executeAction("SELECT", actionProps)
entry = formatlb.getChild("7") #Financial
entry.executeAction("SELECT", tuple())
self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false")
self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false")
self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false")
......
......@@ -71,7 +71,11 @@
#include <conditio.hxx>
IMPL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl);
short AbstractScAutoFormatDlg_Impl::Execute()
{
return m_xDlg->run();
}
short AbstractScColRowLabelDlg_Impl::Execute()
{
......@@ -269,15 +273,15 @@ void AbstractScImportAsciiDlg_Impl::SaveParameters()
sal_uInt16 AbstractScAutoFormatDlg_Impl::GetIndex() const
{
return pDlg->GetIndex();
return m_xDlg->GetIndex();
}
OUString AbstractScAutoFormatDlg_Impl::GetCurrFormatName()
{
return pDlg->GetCurrFormatName();
return m_xDlg->GetCurrFormatName();
}
bool AbstractScColRowLabelDlg_Impl::IsCol()
bool AbstractScColRowLabelDlg_Impl::IsCol()
{
return m_xDlg->IsCol();
}
......@@ -763,13 +767,12 @@ VclPtr<AbstractScTextImportOptionsDlg> ScAbstractDialogFactory_Impl::CreateScTex
return VclPtr<AbstractScTextImportOptionsDlg_Impl>::Create(std::make_unique<ScTextImportOptionsDlg>(pParent));
}
VclPtr<AbstractScAutoFormatDlg> ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(vcl::Window* pParent,
VclPtr<AbstractScAutoFormatDlg> ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData *pViewData)
{
VclPtr<ScAutoFormatDlg> pDlg = VclPtr<ScAutoFormatDlg>::Create(pParent, pAutoFormat, pSelFormatData, pViewData);
return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(pDlg);
return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(std::make_unique<ScAutoFormatDlg>(pParent, pAutoFormat, pSelFormatData, pViewData));
}
VclPtr<AbstractScColRowLabelDlg> ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg(weld::Window* pParent,
......
......@@ -105,7 +105,13 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg
class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg
{
DECL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl, ScAutoFormatDlg)
std::unique_ptr<ScAutoFormatDlg> m_xDlg;
public:
explicit AbstractScAutoFormatDlg_Impl(std::unique_ptr<ScAutoFormatDlg> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
virtual sal_uInt16 GetIndex() const override;
virtual OUString GetCurrFormatName() override;
};
......@@ -586,7 +592,7 @@ public:
virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) override;
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(vcl::Window* pParent,
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData *pViewData) override;
......
......@@ -22,7 +22,7 @@
#include <svx/framelinkarray.hxx>
#include <scdllapi.h>
#include <vcl/window.hxx>
#include <vcl/customweld.hxx>
namespace com { namespace sun { namespace star { namespace i18n { class XBreakIterator; } } } }
......@@ -33,13 +33,13 @@ class SvNumberFormatter;
class VirtualDevice;
class ScViewData;
class SC_DLLPUBLIC ScAutoFmtPreview : public vcl::Window
class SC_DLLPUBLIC ScAutoFmtPreview : public weld::CustomWidgetController
{
public:
ScAutoFmtPreview(vcl::Window* pParent);
ScAutoFmtPreview();
void DetectRTL(const ScViewData *pViewData);
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~ScAutoFmtPreview() override;
virtual void dispose() override;
void NotifyChange( ScAutoFormatData* pNewData );
......@@ -85,8 +85,8 @@ private:
SAL_DLLPRIVATE void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow);
SAL_DLLPRIVATE void DrawBackground(vcl::RenderContext& rRenderContext);
SAL_DLLPRIVATE void MakeFonts(sal_uInt16 nIndex, vcl::Font& rFont,
vcl::Font& rCJKFont, vcl::Font& rCTLFont );
SAL_DLLPRIVATE void MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex,
vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont);
};
#endif // INCLUDED_SC_SOURCE_UI_INC_AUTOFMT_HXX
......
......@@ -18,35 +18,23 @@
*/
#ifndef INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX
#define INCLUDED_SC_SOURCE_UI_INC_SCUIAUTOFMT_HXX
#include <vcl/customweld.hxx>
#include "autofmt.hxx"
class ScAutoFormatDlg : public ModalDialog
class ScAutoFormatDlg : public weld::GenericDialogController
{
public:
ScAutoFormatDlg(vcl::Window* pParent,
ScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
const ScViewData *pViewData);
virtual ~ScAutoFormatDlg() override;
virtual void dispose() override;
sal_uInt16 GetIndex() const { return nIndex; }
OUString GetCurrFormatName();
private:
VclPtr<ListBox> m_pLbFormat;
VclPtr<ScAutoFmtPreview> m_pWndPreview;
VclPtr<OKButton> m_pBtnOk;
VclPtr<CancelButton> m_pBtnCancel;
VclPtr<PushButton> m_pBtnAdd;
VclPtr<PushButton> m_pBtnRemove;
VclPtr<PushButton> m_pBtnRename;
VclPtr<CheckBox> m_pBtnNumFormat;
VclPtr<CheckBox> m_pBtnBorder;
VclPtr<CheckBox> m_pBtnFont;
VclPtr<CheckBox> m_pBtnPattern;
VclPtr<CheckBox> m_pBtnAlignment;
VclPtr<CheckBox> m_pBtnAdjust;
OUString const aStrTitle;
OUString const aStrLabel;
OUString const aStrClose;
......@@ -59,16 +47,31 @@ private:
bool bCoreDataChanged;
bool bFmtInserted;
ScAutoFmtPreview m_aWndPreview;
std::unique_ptr<weld::TreeView> m_xLbFormat;
std::unique_ptr<weld::Button> m_xBtnOk;
std::unique_ptr<weld::Button> m_xBtnCancel;
std::unique_ptr<weld::Button> m_xBtnAdd;
std::unique_ptr<weld::Button> m_xBtnRemove;
std::unique_ptr<weld::Button> m_xBtnRename;
std::unique_ptr<weld::CheckButton> m_xBtnNumFormat;
std::unique_ptr<weld::CheckButton> m_xBtnBorder;
std::unique_ptr<weld::CheckButton> m_xBtnFont;
std::unique_ptr<weld::CheckButton> m_xBtnPattern;
std::unique_ptr<weld::CheckButton> m_xBtnAlignment;
std::unique_ptr<weld::CheckButton> m_xBtnAdjust;
std::unique_ptr<weld::CustomWeld> m_xWndPreview;
void Init ();
void UpdateChecks ();
DECL_LINK( CheckHdl, Button*, void );
DECL_LINK( AddHdl, Button*, void );
DECL_LINK( RemoveHdl, Button*, void );
DECL_LINK( SelFmtHdl, ListBox&, void );
DECL_LINK( CloseHdl, Button *, void );
DECL_LINK( DblClkHdl, ListBox&, void );
DECL_LINK( RenameHdl, Button*, void );
DECL_LINK( CheckHdl, weld::ToggleButton&, void );
DECL_LINK( AddHdl, weld::Button&, void );
DECL_LINK( RemoveHdl, weld::Button&, void );
DECL_LINK( SelFmtHdl, weld::TreeView&, void );
DECL_LINK( CloseHdl, weld::Button&, void );
DECL_LINK( DblClkHdl, weld::TreeView&, void );
DECL_LINK( RenameHdl, weld::Button&, void );
};
#endif
......
......@@ -49,10 +49,8 @@
// ScAutoFmtPreview
ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent)
: Window(pParent)
, pCurData(nullptr)
, aVD(*this)
ScAutoFmtPreview::ScAutoFmtPreview()
: pCurData(nullptr)
, bFitWidth(false)
, mbRTL(false)
, aStrJan(ScResId(STR_JAN))
......@@ -67,11 +65,16 @@ ScAutoFmtPreview::ScAutoFmtPreview(vcl::Window* pParent)
Init();
}
VCL_BUILDER_FACTORY(ScAutoFmtPreview)
void ScAutoFmtPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
aVD.disposeAndReset(VclPtr<VirtualDevice>::Create(pDrawingArea->get_ref_device()));
CustomWidgetController::SetDrawingArea(pDrawingArea);
}
void ScAutoFmtPreview::Resize()
{
aPrvSize = Size(GetSizePixel().Width() - 6, GetSizePixel().Height() - 30);
Size aSize(GetOutputSizePixel());
aPrvSize = Size(aSize.Width() - 6, aSize.Height() - 30);
mnLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12;
mnDataColWidth1 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3;
mnDataColWidth2 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4;
......@@ -81,13 +84,6 @@ void ScAutoFmtPreview::Resize()
ScAutoFmtPreview::~ScAutoFmtPreview()
{
disposeOnce();
}
void ScAutoFmtPreview::dispose()
{
pNumFmt.reset();
vcl::Window::dispose();
}
static void lcl_SetFontProperties(
......@@ -105,12 +101,12 @@ static void lcl_SetFontProperties(
rFont.SetItalic ( rPostureItem.GetValue() );
}
void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont )
void ScAutoFmtPreview::MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont)
{
if ( pCurData )
{
rFont = rCJKFont = rCTLFont = GetFont();
Size aFontSize( rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor() );
rFont = rCJKFont = rCTLFont = rRenderContext.GetFont();
Size aFontSize(rFont.GetFontSize().Width(), 10 * rRenderContext.GetDPIScaleFactor());
const SvxFontItem* pFontItem = pCurData->GetItem( nIndex, ATTR_FONT );
const SvxWeightItem* pWeightItem = pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
......@@ -134,7 +130,7 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font
Color aColor( pColorItem->GetValue() );
if( aColor == COL_TRANSPARENT )
aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
#define SETONALLFONTS( MethodName, Value ) \
rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
......@@ -263,7 +259,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo
vcl::Font aFont, aCJKFont, aCTLFont;
Size theMaxStrSize;
MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
MakeFonts(rRenderContext, nFmtIndex, aFont, aCJKFont, aCTLFont);
theMaxStrSize = Size(basegfx::fround(cellRange.getWidth()), basegfx::fround(cellRange.getHeight()));
theMaxStrSize.AdjustWidth( -(FRAME_OFFSET) );
......@@ -413,9 +409,7 @@ void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
void ScAutoFmtPreview::Init()
{
SetBorderStyle( WindowBorderStyle::MONO );
maArray.Initialize( 5, 5 );
// maArray.SetUseDiagDoubleClipping( false );
mnLabelColWidth = 0;
mnDataColWidth1 = 0;
mnDataColWidth2 = 0;
......@@ -491,14 +485,15 @@ void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
CalcCellArray( bFitWidth );
CalcLineMap();
Invalidate(tools::Rectangle(Point(0,0), GetSizePixel()));
Invalidate();
}
void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext)
{
rRenderContext.Push(PushFlags::ALL);
DrawModeFlags nOldDrawMode = aVD->GetDrawMode();
Size aWndSize(GetSizePixel());
Size aWndSize(GetOutputSizePixel());
vcl::Font aFont(aVD->GetFont());
Color aBackCol(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor());
tools::Rectangle aRect(Point(), aWndSize);
......@@ -521,6 +516,7 @@ void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext)
aPos.setX( -aPos.X() );
rRenderContext.DrawOutDev(aPos, aWndSize, Point(), aWndSize, *aVD);
aVD->SetDrawMode(nOldDrawMode);
rRenderContext.Pop();
}
void ScAutoFmtPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
......
......@@ -819,7 +819,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
case SID_AUTOFORMAT:
{
vcl::Window* pDlgParent = pTabViewShell->GetDialogParent();
weld::Window* pDlgParent = pTabViewShell->GetFrameWeld();
SCCOL nStartCol;
SCROW nStartRow;
SCTAB nStartTab;
......@@ -877,7 +877,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
}
else
{
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pDlgParent ? pDlgParent->GetFrameWeld() : nullptr,
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pDlgParent,
VclMessageType::Warning, VclButtonsType::Ok,
ScResId(STR_INVALID_AFAREA)));
xErrorBox->run();
......
......@@ -470,7 +470,6 @@ custom_widgets = [
'RubyEdit',
'RubyPreview',
'SameContentListBox',
'ScAutoFmtPreview',
'ScCondFormatList',
'ScCsvTableBox',
'ScCursorRefEdit',
......
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