summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-03-13 10:21:36 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-03-13 22:07:48 +0100
commit99aaa4b0b88100c8db03b32e072cff0193ad0953 (patch)
tree7b090b06efbdbffd67ac253c4a4869e85d95210e
parent5504dcc6987ffb41e9077d468df42c6af94c38ea (diff)
weld insert table dialog
Change-Id: I17bdbba38a74ea05b0d6869ee04f01f870a3b17b Reviewed-on: https://gerrit.libreoffice.org/51219 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--cui/source/dialogs/splitcelldlg.cxx4
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--include/vcl/weld.hxx12
-rw-r--r--sfx2/source/view/viewsh.cxx5
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx10
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx9
-rw-r--r--sw/source/ui/table/autoformatpreview.cxx458
-rw-r--r--sw/source/ui/table/instable.cxx191
-rw-r--r--sw/source/ui/table/tautofmt.cxx15
-rw-r--r--sw/source/uibase/inc/autoformatpreview.hxx57
-rw-r--r--sw/source/uibase/inc/instable.hxx49
-rw-r--r--sw/source/uibase/inc/tautofmt.hxx2
-rw-r--r--sw/uiconfig/swriter/ui/autoformattable.ui2
-rw-r--r--sw/uiconfig/swriter/ui/inserttable.ui54
14 files changed, 215 insertions, 655 deletions
diff --git a/cui/source/dialogs/splitcelldlg.cxx b/cui/source/dialogs/splitcelldlg.cxx
index 4248f2fe3956..b869045d8799 100644
--- a/cui/source/dialogs/splitcelldlg.cxx
+++ b/cui/source/dialogs/splitcelldlg.cxx
@@ -61,9 +61,7 @@ IMPL_LINK(SvxSplitTableDlg, ClickHdl, weld::Button&, rButton, void)
const bool bIsVert = &rButton == m_xVertBox.get();
long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal;
m_xPropCB->set_sensitive(!bIsVert);
- int nMin, dummy;
- m_xCountEdit->get_range(nMin, dummy);
- m_xCountEdit->set_range(nMin, nMax);
+ m_xCountEdit->set_max(nMax);
}
bool SvxSplitTableDlg::IsHorizontal() const
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e7a0f6d7fec1..416b177a662b 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -49,6 +49,7 @@ class SfxBaseController;
class Size;
class Fraction;
namespace vcl { class Window; }
+namespace weld { class Window; }
class KeyEvent;
class WorkWindow;
class SvBorder;
@@ -232,6 +233,7 @@ public:
// Viewing Interface
vcl::Window* GetWindow() const { return pWindow; }
+ weld::Window* GetFrameWeld() const;
void SetWindow( vcl::Window *pViewPort );
virtual void AdjustPosSizePixel( const Point &rOfs, const Size &rSize );
const SvBorder& GetBorderPixel() const;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 86a61b75f194..6ef22f521a43 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -344,6 +344,18 @@ public:
virtual int get_value() const = 0;
virtual void set_range(int min, int max) = 0;
virtual void get_range(int& min, int& max) const = 0;
+ void set_min(int min)
+ {
+ int dummy, max;
+ get_range(dummy, max);
+ set_range(min, max);
+ }
+ void set_max(int max)
+ {
+ int min, dummy;
+ get_range(min, dummy);
+ set_range(min, max);
+ }
virtual void set_increments(int step, int page) = 0;
virtual void get_increments(int& step, int& page) const = 0;
virtual void set_digits(unsigned int digits) = 0;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index e17dfacb7deb..8925c8aca469 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2013,4 +2013,9 @@ void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransf
}
}
+weld::Window* SfxViewShell::GetFrameWeld() const
+{
+ return pWindow ? pWindow->GetFrameWeld() : nullptr;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index c283f4fec404..f499678ab988 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -119,7 +119,10 @@ IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractGlossaryDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractFieldInputDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractInsFootNoteDlg_Impl);
-IMPL_ABSTDLG_BASE(AbstractInsTableDlg_Impl);
+short AbstractInsTableDlg_Impl::Execute()
+{
+ return m_xDlg->run();
+}
IMPL_ABSTDLG_BASE(AbstractJavaEditDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractMailMergeDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractMailMergeCreateFromDlg_Impl);
@@ -453,7 +456,7 @@ void AbstractInsTableDlg_Impl::GetValues( OUString& rName, sal_uInt16& rRow, sal
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
SwTableAutoFormat *& prTAFormat )
{
- pDlg->GetValues( rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat);
+ m_xDlg->GetValues(rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat);
}
OUString AbstractJavaEditDialog_Impl::GetScriptText() const
@@ -930,8 +933,7 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateVclSwViewDialog(Sw
VclPtr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView)
{
- VclPtr<SwInsTableDlg> pDlg = VclPtr<SwInsTableDlg>::Create(rView);
- return VclPtr<AbstractInsTableDlg_Impl>::Create( pDlg );
+ return VclPtr<AbstractInsTableDlg_Impl>::Create(new SwInsTableDlg(rView));
}
VclPtr<AbstractJavaEditDialog> SwAbstractDialogFactory_Impl::CreateJavaEditDialog(
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 13a25e8d9948..ca03c363c1a4 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -289,7 +289,14 @@ class AbstractInsFootNoteDlg_Impl : public AbstractInsFootNoteDlg
class SwInsTableDlg;
class AbstractInsTableDlg_Impl : public AbstractInsTableDlg
{
- DECL_ABSTDLG_BASE(AbstractInsTableDlg_Impl,SwInsTableDlg)
+protected:
+ std::unique_ptr<SwInsTableDlg> m_xDlg;
+public:
+ explicit AbstractInsTableDlg_Impl(SwInsTableDlg* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
SwTableAutoFormat *& prTAFormat ) override;
diff --git a/sw/source/ui/table/autoformatpreview.cxx b/sw/source/ui/table/autoformatpreview.cxx
index 83aa97e90970..e4d892b54392 100644
--- a/sw/source/ui/table/autoformatpreview.cxx
+++ b/sw/source/ui/table/autoformatpreview.cxx
@@ -27,10 +27,9 @@
#define FRAME_OFFSET 4
-AutoFormatPreviewWindow::AutoFormatPreviewWindow(vcl::Window* pParent, WinBits nStyle)
- : Window(pParent, nStyle)
+AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea)
+ : mxDrawingArea(pDrawingArea)
, aCurData(OUString())
- , aVD(VclPtr<VirtualDevice>::Create(*this))
, bFitWidth(false)
, mbRTL(false)
, aStrJan(SwResId(STR_JAN))
@@ -43,16 +42,17 @@ AutoFormatPreviewWindow::AutoFormatPreviewWindow(vcl::Window* pParent, WinBits n
{
uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
m_xBreak = i18n::BreakIterator::create(xContext);
- pNumFormat = new SvNumberFormatter(xContext, LANGUAGE_SYSTEM);
+ mxNumFormat.reset(new SvNumberFormatter(xContext, LANGUAGE_SYSTEM));
Init();
-}
-VCL_BUILDER_FACTORY_CONSTRUCTOR(AutoFormatPreviewWindow, 0)
+ mxDrawingArea->connect_size_allocate(LINK(this, AutoFormatPreview, DoResize));
+ mxDrawingArea->connect_draw(LINK(this, AutoFormatPreview, DoPaint));
+}
-void AutoFormatPreviewWindow::Resize()
+IMPL_LINK(AutoFormatPreview, DoResize, const Size&, rSize, void)
{
- aPrvSize = Size(GetSizePixel().Width() - 6, GetSizePixel().Height() - 30);
+ aPrvSize = Size(rSize.Width() - 6, rSize.Height() - 30);
nLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12;
nDataColWidth1 = (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 3;
nDataColWidth2 = (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 4;
@@ -60,7 +60,7 @@ void AutoFormatPreviewWindow::Resize()
NotifyChange(aCurData);
}
-void AutoFormatPreviewWindow::DetectRTL(SwWrtShell const* pWrtShell)
+void AutoFormatPreview::DetectRTL(SwWrtShell const* pWrtShell)
{
if (!pWrtShell->IsCursorInTable()) // We haven't created the table yet
mbRTL = AllSettings::GetLayoutRTL();
@@ -68,14 +68,6 @@ void AutoFormatPreviewWindow::DetectRTL(SwWrtShell const* pWrtShell)
mbRTL = pWrtShell->IsTableRightToLeft();
}
-AutoFormatPreviewWindow::~AutoFormatPreviewWindow() { disposeOnce(); }
-
-void AutoFormatPreviewWindow::dispose()
-{
- delete pNumFormat;
- vcl::Window::dispose();
-}
-
static void lcl_SetFontProperties(vcl::Font& rFont, const SvxFontItem& rFontItem,
const SvxWeightItem& rWeightItem,
const SvxPostureItem& rPostureItem)
@@ -94,432 +86,6 @@ static void lcl_SetFontProperties(vcl::Font& rFont, const SvxFontItem& rFontItem
rCJKFont.MethodName(Value); \
rCTLFont.MethodName(Value);
-void AutoFormatPreviewWindow::MakeFonts(sal_uInt8 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont,
- vcl::Font& rCTLFont)
-{
- const SwBoxAutoFormat& rBoxFormat = aCurData.GetBoxFormat(nIndex);
-
- rFont = rCJKFont = rCTLFont = GetFont();
- Size aFontSize(rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor());
-
- lcl_SetFontProperties(rFont, rBoxFormat.GetFont(), rBoxFormat.GetWeight(),
- rBoxFormat.GetPosture());
- lcl_SetFontProperties(rCJKFont, rBoxFormat.GetCJKFont(), rBoxFormat.GetCJKWeight(),
- rBoxFormat.GetCJKPosture());
- lcl_SetFontProperties(rCTLFont, rBoxFormat.GetCTLFont(), rBoxFormat.GetCTLWeight(),
- rBoxFormat.GetCTLPosture());
-
- SETONALLFONTS(SetUnderline, rBoxFormat.GetUnderline().GetValue());
- SETONALLFONTS(SetOverline, rBoxFormat.GetOverline().GetValue());
- SETONALLFONTS(SetStrikeout, rBoxFormat.GetCrossedOut().GetValue());
- SETONALLFONTS(SetOutline, rBoxFormat.GetContour().GetValue());
- SETONALLFONTS(SetShadow, rBoxFormat.GetShadowed().GetValue());
- SETONALLFONTS(SetColor, rBoxFormat.GetColor().GetValue());
- SETONALLFONTS(SetFontSize, aFontSize);
- SETONALLFONTS(SetTransparent, true);
-}
-
-sal_uInt8 AutoFormatPreviewWindow::GetFormatIndex(size_t nCol, size_t nRow) const
-{
- static const sal_uInt8 pnFormatMap[]
- = { 0, 1, 2, 1, 3, 4, 5, 6, 5, 7, 8, 9, 10, 9, 11, 4, 5, 6, 5, 7, 12, 13, 14, 13, 15 };
- return pnFormatMap[maArray.GetCellIndex(nCol, nRow, mbRTL)];
-}
-
-void AutoFormatPreviewWindow::DrawString(vcl::RenderContext& rRenderContext, size_t nCol,
- size_t nRow)
-{
- // Output of the cell text:
- sal_uLong nNum;
- double nVal;
- OUString cellString;
- sal_uInt8 nIndex = static_cast<sal_uInt8>(maArray.GetCellIndex(nCol, nRow, mbRTL));
-
- switch (nIndex)
- {
- case 1:
- cellString = aStrJan;
- break;
- case 2:
- cellString = aStrFeb;
- break;
- case 3:
- cellString = aStrMar;
- break;
- case 5:
- cellString = aStrNorth;
- break;
- case 10:
- cellString = aStrMid;
- break;
- case 15:
- cellString = aStrSouth;
- break;
- case 4:
- case 20:
- cellString = aStrSum;
- break;
- case 6:
- case 8:
- case 16:
- case 18:
- nVal = nIndex;
- nNum = 5;
- goto MAKENUMSTR;
- case 17:
- case 7:
- nVal = nIndex;
- nNum = 6;
- goto MAKENUMSTR;
- case 11:
- case 12:
- case 13:
- nVal = nIndex;
- nNum = 12 == nIndex ? 10 : 9;
- goto MAKENUMSTR;
- case 9:
- nVal = 21;
- nNum = 7;
- goto MAKENUMSTR;
- case 14:
- nVal = 36;
- nNum = 11;
- goto MAKENUMSTR;
- case 19:
- nVal = 51;
- nNum = 7;
- goto MAKENUMSTR;
- case 21:
- nVal = 33;
- nNum = 13;
- goto MAKENUMSTR;
- case 22:
- nVal = 36;
- nNum = 14;
- goto MAKENUMSTR;
- case 23:
- nVal = 39;
- nNum = 13;
- goto MAKENUMSTR;
- case 24:
- nVal = 108;
- nNum = 15;
- goto MAKENUMSTR;
-
- MAKENUMSTR:
- if (aCurData.IsValueFormat())
- {
- OUString sFormat;
- LanguageType eLng, eSys;
- aCurData.GetBoxFormat(sal_uInt8(nNum)).GetValueFormat(sFormat, eLng, eSys);
-
- SvNumFormatType nType;
- bool bNew;
- sal_Int32 nCheckPos;
- sal_uInt32 nKey = pNumFormat->GetIndexPuttingAndConverting(sFormat, eLng, eSys,
- nType, bNew, nCheckPos);
- Color* pDummy;
- pNumFormat->GetOutputString(nVal, nKey, cellString, &pDummy);
- }
- else
- cellString = OUString::number(sal_Int32(nVal));
- break;
- }
-
- if (cellString.isEmpty())
- return;
-
- SvtScriptedTextHelper aScriptedText(rRenderContext);
- Size aStrSize;
- sal_uInt8 nFormatIndex = GetFormatIndex(nCol, nRow);
- const basegfx::B2DRange aCellRange(maArray.GetCellRange(nCol, nRow, true));
- const tools::Rectangle cellRect(
- basegfx::fround(aCellRange.getMinX()), basegfx::fround(aCellRange.getMinY()),
- basegfx::fround(aCellRange.getMaxX()), basegfx::fround(aCellRange.getMaxY()));
- Point aPos = cellRect.TopLeft();
- long nRightX = 0;
-
- Size theMaxStrSize(cellRect.GetWidth() - FRAME_OFFSET, cellRect.GetHeight() - FRAME_OFFSET);
- if (aCurData.IsFont())
- {
- vcl::Font aFont, aCJKFont, aCTLFont;
- MakeFonts(nFormatIndex, aFont, aCJKFont, aCTLFont);
- aScriptedText.SetFonts(&aFont, &aCJKFont, &aCTLFont);
- }
- else
- aScriptedText.SetDefaultFont();
-
- aScriptedText.SetText(cellString, m_xBreak);
- aStrSize = aScriptedText.GetTextSize();
-
- if (aCurData.IsFont() && theMaxStrSize.Height() < aStrSize.Height())
- {
- // If the string in this font does not
- // fit into the cell, the standard font
- // is taken again:
- aScriptedText.SetDefaultFont();
- aStrSize = aScriptedText.GetTextSize();
- }
-
- while (theMaxStrSize.Width() <= aStrSize.Width() && cellString.getLength() > 1)
- {
- cellString = cellString.copy(0, cellString.getLength() - 1);
- aScriptedText.SetText(cellString, m_xBreak);
- aStrSize = aScriptedText.GetTextSize();
- }
-
- nRightX = cellRect.GetWidth() - aStrSize.Width() - FRAME_OFFSET;
-
- // vertical (always centering):
- aPos.AdjustY((nRowHeight - aStrSize.Height()) / 2);
-
- // horizontal
- if (mbRTL)
- aPos.AdjustX(nRightX);
- else if (aCurData.IsJustify())
- {
- const SvxAdjustItem& rAdj = aCurData.GetBoxFormat(nFormatIndex).GetAdjust();
- switch (rAdj.GetAdjust())
- {
- case SvxAdjust::Left:
- aPos.AdjustX(FRAME_OFFSET);
- break;
- case SvxAdjust::Right:
- aPos.AdjustX(nRightX);
- break;
- default:
- aPos.AdjustX((cellRect.GetWidth() - aStrSize.Width()) / 2);
- break;
- }
- }
- else
- {
- // Standard align:
- if (nCol == 0 || nIndex == 4)
- {
- // Text-Label left or sum left aligned
- aPos.AdjustX(FRAME_OFFSET);
- }
- else
- {
- // numbers/dates right aligned
- aPos.AdjustX(nRightX);
- }
- }
-
- aScriptedText.DrawText(aPos);
-}
-
-void AutoFormatPreviewWindow::DrawBackground(vcl::RenderContext& rRenderContext)
-{
- for (size_t nRow = 0; nRow < 5; ++nRow)
- {
- for (size_t nCol = 0; nCol < 5; ++nCol)
- {
- SvxBrushItem aBrushItem(
- aCurData.GetBoxFormat(GetFormatIndex(nCol, nRow)).GetBackground());
-
- rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
- rRenderContext.SetLineColor();
- rRenderContext.SetFillColor(aBrushItem.GetColor());
- const basegfx::B2DRange aCellRange(maArray.GetCellRange(nCol, nRow, true));
- rRenderContext.DrawRect(tools::Rectangle(
- basegfx::fround(aCellRange.getMinX()), basegfx::fround(aCellRange.getMinY()),
- basegfx::fround(aCellRange.getMaxX()), basegfx::fround(aCellRange.getMaxY())));
- rRenderContext.Pop();
- }
- }
-}
-
-void AutoFormatPreviewWindow::PaintCells(vcl::RenderContext& rRenderContext)
-{
- // 1) background
- if (aCurData.IsBackground())
- DrawBackground(rRenderContext);
-
- // 2) values
- for (size_t nRow = 0; nRow < 5; ++nRow)
- for (size_t nCol = 0; nCol < 5; ++nCol)
- DrawString(rRenderContext, nCol, nRow);
-
- // 3) border
- if (aCurData.IsFrame())
- {
- const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
- std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
- drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
- rRenderContext, aNewViewInformation2D));
-
- if (pProcessor2D)
- {
- pProcessor2D->process(maArray.CreateB2DPrimitiveArray());
- pProcessor2D.reset();
- }
- }
-}
-
-void AutoFormatPreviewWindow::Init()
-{
- SetBorderStyle(GetBorderStyle() | WindowBorderStyle::MONO);
- maArray.Initialize(5, 5);
- nLabelColWidth = 0;
- nDataColWidth1 = 0;
- nDataColWidth2 = 0;
- nRowHeight = 0;
- CalcCellArray(false);
- CalcLineMap();
-}
-
-void AutoFormatPreviewWindow::CalcCellArray(bool _bFitWidth)
-{
- maArray.SetXOffset(2);
- maArray.SetAllColWidths(_bFitWidth ? nDataColWidth2 : nDataColWidth1);
- maArray.SetColWidth(0, nLabelColWidth);
- maArray.SetColWidth(4, nLabelColWidth);
-
- maArray.SetYOffset(2);
- maArray.SetAllRowHeights(nRowHeight);
-
- aPrvSize.setWidth(maArray.GetWidth() + 4);
- aPrvSize.setHeight(maArray.GetHeight() + 4);
-}
-
-inline void lclSetStyleFromBorder(svx::frame::Style& rStyle,
- const ::editeng::SvxBorderLine* pBorder)
-{
- rStyle.Set(pBorder, 0.05, 5);
-}
-
-void AutoFormatPreviewWindow::CalcLineMap()
-{
- for (size_t nRow = 0; nRow < 5; ++nRow)
- {
- for (size_t nCol = 0; nCol < 5; ++nCol)
- {
- svx::frame::Style aStyle;
-
- const SvxBoxItem& rItem = aCurData.GetBoxFormat(GetFormatIndex(nCol, nRow)).GetBox();
- lclSetStyleFromBorder(aStyle, rItem.GetLeft());
- maArray.SetCellStyleLeft(nCol, nRow, aStyle);
- lclSetStyleFromBorder(aStyle, rItem.GetRight());
- maArray.SetCellStyleRight(nCol, nRow, aStyle);
- lclSetStyleFromBorder(aStyle, rItem.GetTop());
- maArray.SetCellStyleTop(nCol, nRow, aStyle);
- lclSetStyleFromBorder(aStyle, rItem.GetBottom());
- maArray.SetCellStyleBottom(nCol, nRow, aStyle);
-
- // FIXME - uncomment to draw diagonal borders
- // lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
- // maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
- // lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
- // maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
- }
- }
-}
-
-void AutoFormatPreviewWindow::NotifyChange(const SwTableAutoFormat& rNewData)
-{
- aCurData = rNewData;
- bFitWidth = aCurData.IsJustify(); // true; //???
- CalcCellArray(bFitWidth);
- CalcLineMap();
- Invalidate(tools::Rectangle(Point(0, 0), GetSizePixel()));
-}
-
-void AutoFormatPreviewWindow::DoPaint(vcl::RenderContext& rRenderContext)
-{
- DrawModeFlags nOldDrawMode = aVD->GetDrawMode();
- if (rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode())
- aVD->SetDrawMode(DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill
- | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient);
-
- Bitmap thePreview;
- Point aCenterPos;
- Size theWndSize = GetSizePixel();
- Color oldColor;
- vcl::Font aFont;
-
- aFont = aVD->GetFont();
- aFont.SetTransparent(true);
-
- aVD->SetFont(aFont);
- aVD->SetLineColor();
- const Color& rWinColor = rRenderContext.GetSettings().GetStyleSettings().GetWindowColor();
- aVD->SetBackground(Wallpaper(rWinColor));
- aVD->SetFillColor(rWinColor);
- aVD->SetOutputSizePixel(aPrvSize);
-
- // Draw cells on virtual device
- // and save the result
- PaintCells(*aVD.get());
- thePreview = aVD->GetBitmap(Point(0, 0), aPrvSize);
-
- // Draw the Frame and center the preview:
- // (virtual Device for window output)
- aVD->SetOutputSizePixel(theWndSize);
- oldColor = aVD->GetLineColor();
- aVD->SetLineColor();
- aVD->DrawRect(tools::Rectangle(Point(0, 0), theWndSize));
-
- rRenderContext.SetLineColor(oldColor);
-
- aCenterPos = Point((theWndSize.Width() - aPrvSize.Width()) / 2,
- (theWndSize.Height() - aPrvSize.Height()) / 2);
- aVD->DrawBitmap(aCenterPos, thePreview);
-
- // Output in the preview window:
- rRenderContext.DrawBitmap(Point(0, 0), aVD->GetBitmap(Point(0, 0), theWndSize));
-
- aVD->SetDrawMode(nOldDrawMode);
-}
-
-void AutoFormatPreviewWindow::Paint(vcl::RenderContext& rRenderContext,
- const tools::Rectangle& /*rRect*/)
-{
- DoPaint(rRenderContext);
-}
-
-AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea)
- : mxDrawingArea(pDrawingArea)
- , aCurData(OUString())
- , bFitWidth(false)
- , mbRTL(false)
- , aStrJan(SwResId(STR_JAN))
- , aStrFeb(SwResId(STR_FEB))
- , aStrMar(SwResId(STR_MAR))
- , aStrNorth(SwResId(STR_NORTH))
- , aStrMid(SwResId(STR_MID))
- , aStrSouth(SwResId(STR_SOUTH))
- , aStrSum(SwResId(STR_SUM))
-{
- uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
- m_xBreak = i18n::BreakIterator::create(xContext);
- mxNumFormat.reset(new SvNumberFormatter(xContext, LANGUAGE_SYSTEM));
-
- Init();
-
- mxDrawingArea->connect_size_allocate(LINK(this, AutoFormatPreview, DoResize));
- mxDrawingArea->connect_draw(LINK(this, AutoFormatPreview, DoPaint));
-}
-
-IMPL_LINK(AutoFormatPreview, DoResize, const Size&, rSize, void)
-{
- aPrvSize = Size(rSize.Width() - 6, rSize.Height() - 30);
- nLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12;
- nDataColWidth1 = (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 3;
- nDataColWidth2 = (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 4;
- nRowHeight = (aPrvSize.Height() - 4) / 5;
- NotifyChange(aCurData);
-}
-
-void AutoFormatPreview::DetectRTL(SwWrtShell const* pWrtShell)
-{
- if (!pWrtShell->IsCursorInTable()) // We haven't created the table yet
- mbRTL = AllSettings::GetLayoutRTL();
- else
- mbRTL = pWrtShell->IsTableRightToLeft();
-}
-
void AutoFormatPreview::MakeFonts(vcl::RenderContext& rRenderContext, sal_uInt8 nIndex,
vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont)
{
@@ -806,6 +372,12 @@ void AutoFormatPreview::CalcCellArray(bool _bFitWidth)
aPrvSize.setHeight(maArray.GetHeight() + 4);
}
+inline void lclSetStyleFromBorder(svx::frame::Style& rStyle,
+ const ::editeng::SvxBorderLine* pBorder)
+{
+ rStyle.Set(pBorder, 0.05, 5);
+}
+
void AutoFormatPreview::CalcLineMap()
{
for (size_t nRow = 0; nRow < 5; ++nRow)
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index 1cb841d5ef01..535ba075a15c 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -32,17 +32,17 @@ void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rC
SwTableAutoFormat *& prTAFormat )
{
sal_uInt16 nInsMode = 0;
- rName = m_pNameEdit->GetText();
- rRow = static_cast<sal_uInt16>(m_pRowNF->GetValue());
- rCol = static_cast<sal_uInt16>(m_pColNF->GetValue());
+ rName = m_xNameEdit->get_text();
+ rRow = m_xRowNF->get_value();
+ rCol = m_xColNF->get_value();
- if (m_pHeaderCB->IsChecked())
+ if (m_xHeaderCB->get_active())
nInsMode |= tabopts::HEADLINE;
- if (m_pRepeatHeaderCB->IsEnabled() && m_pRepeatHeaderCB->IsChecked())
- rInsTableOpts.mnRowsToRepeat = sal_uInt16( m_pRepeatHeaderNF->GetValue() );
+ if (m_xRepeatHeaderCB->get_sensitive() && m_xRepeatHeaderCB->get_active())
+ rInsTableOpts.mnRowsToRepeat = m_xRepeatHeaderNF->get_value();
else
rInsTableOpts.mnRowsToRepeat = 0;
- if (!m_pDontSplitCB->IsChecked())
+ if (!m_xDontSplitCB->get_active())
nInsMode |= tabopts::SPLIT_LAYOUT;
if( pTAutoFormat )
{
@@ -53,35 +53,45 @@ void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rC
rInsTableOpts.mnInsMode = nInsMode;
}
-SwInsTableDlg::SwInsTableDlg( SwView& rView )
- : SfxModalDialog(rView.GetWindow(), "InsertTableDialog", "modules/swriter/ui/inserttable.ui")
+IMPL_LINK(SwInsTableDlg, TextFilterHdl, OUString&, rTest, bool)
+{
+ rTest = m_aTextFilter.filter(rTest);
+ return true;
+}
+
+SwInsTableDlg::SwInsTableDlg(SwView& rView)
+ : weld::GenericDialogController(rView.GetFrameWeld(), "modules/swriter/ui/inserttable.ui", "InsertTableDialog")
+ , m_xNameEdit(m_xBuilder->weld_entry("nameedit"))
+ , m_xColNF(m_xBuilder->weld_spin_button("colspin"))
+ , m_xRowNF(m_xBuilder->weld_spin_button("rowspin"))
+ , m_xHeaderCB(m_xBuilder->weld_check_button("headercb"))
+ , m_xRepeatHeaderCB(m_xBuilder->weld_check_button("repeatcb"))
+ , m_xRepeatHeaderNF(m_xBuilder->weld_spin_button("repeatheaderspin"))
+ , m_xRepeatGroup(m_xBuilder->weld_widget("repeatgroup"))
+ , m_xDontSplitCB(m_xBuilder->weld_check_button("dontsplitcb"))
+ , m_xInsertBtn(m_xBuilder->weld_button("ok"))
+ , m_xLbFormat(m_xBuilder->weld_tree_view("formatlbinstable"))
+ , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("previewinstable")))
, m_aTextFilter(" .<>")
, pShell(&rView.GetWrtShell())
, pTAutoFormat(nullptr)
, nEnteredValRepeatHeaderNF(-1)
{
- get(m_pNameEdit, "nameedit");
- m_pNameEdit->SetTextFilter(&m_aTextFilter);
- get(m_pColNF, "colspin");
- get(m_pRowNF, "rowspin");
- get(m_pHeaderCB, "headercb");
- get(m_pRepeatHeaderCB, "repeatcb");
- get(m_pDontSplitCB, "dontsplitcb");
- get(m_pInsertBtn, "ok");
- get(m_pRepeatGroup, "repeatgroup");
- get(m_pRepeatHeaderNF, "repeatheaderspin");
- get(m_pLbFormat, "formatlbinstable");
- get(m_pWndPreview, "previewinstable");
-
- m_pNameEdit->SetText(pShell->GetUniqueTableName());
- m_pNameEdit->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyName));
- m_pColNF->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
- m_pRowNF->SetModifyHdl(LINK(this, SwInsTableDlg, ModifyRowCol));
-
- m_pRowNF->SetMax(ROW_COL_PROD/m_pColNF->GetValue());
- m_pColNF->SetMax(ROW_COL_PROD/m_pRowNF->GetValue());
-
- m_pInsertBtn->SetClickHdl(LINK(this, SwInsTableDlg, OKHdl));
+ const int nWidth = m_xLbFormat->get_approximate_char_width() * 32;
+ const int nHeight = m_xLbFormat->get_height_rows(8);
+ m_xLbFormat->set_size_request(nWidth, nHeight);
+ m_xWndPreview->set_size_request(nWidth, nHeight);
+
+ m_xNameEdit->connect_insert_text(LINK(this, SwInsTableDlg, TextFilterHdl));
+ m_xNameEdit->set_text(pShell->GetUniqueTableName());
+ m_xNameEdit->connect_changed(LINK(this, SwInsTableDlg, ModifyName));
+ m_xColNF->connect_value_changed(LINK(this, SwInsTableDlg, ModifyRowCol));
+ m_xRowNF->connect_value_changed(LINK(this, SwInsTableDlg, ModifyRowCol));
+
+ m_xRowNF->set_max(ROW_COL_PROD/m_xColNF->get_value());
+ m_xColNF->set_max(ROW_COL_PROD/m_xRowNF->get_value());
+
+ m_xInsertBtn->connect_clicked(LINK(this, SwInsTableDlg, OKHdl));
bool bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
@@ -89,47 +99,47 @@ SwInsTableDlg::SwInsTableDlg( SwView& rView )
SwInsertTableOptions aInsOpts = pModOpt->GetInsTableFlags(bHTMLMode);
sal_uInt16 nInsTableFlags = aInsOpts.mnInsMode;
- m_pHeaderCB->Check( 0 != (nInsTableFlags & tabopts::HEADLINE) );
- m_pRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
- if(bHTMLMode)
- m_pDontSplitCB->Hide();
+ m_xHeaderCB->set_active(0 != (nInsTableFlags & tabopts::HEADLINE));
+ m_xRepeatHeaderCB->set_active(aInsOpts.mnRowsToRepeat > 0);
+ if (bHTMLMode)
+ m_xDontSplitCB->hide();
else
- m_pDontSplitCB->Check( 0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT) );
+ m_xDontSplitCB->set_active(0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT));
- m_pRepeatHeaderNF->SetModifyHdl( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
- m_pHeaderCB->SetClickHdl( LINK( this, SwInsTableDlg, CheckBoxHdl ) );
- m_pRepeatHeaderCB->SetClickHdl( LINK( this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl ) );
- ReapeatHeaderCheckBoxHdl(nullptr);
- CheckBoxHdl(nullptr);
+ m_xRepeatHeaderNF->connect_value_changed( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
+ m_xHeaderCB->connect_toggled( LINK( this, SwInsTableDlg, CheckBoxHdl ) );
+ m_xRepeatHeaderCB->connect_toggled( LINK( this, SwInsTableDlg, RepeatHeaderCheckBoxHdl ) );
+ RepeatHeaderCheckBoxHdl(*m_xRepeatHeaderCB);
+ CheckBoxHdl(*m_xHeaderCB);
- sal_Int64 nMax = m_pRowNF->GetValue();
+ sal_Int64 nMax = m_xRowNF->get_value();
if( nMax <= 1 )
nMax = 1;
else
--nMax;
- m_pRepeatHeaderNF->SetMax( nMax );
+ m_xRepeatHeaderNF->set_max( nMax );
InitAutoTableFormat();
}
void SwInsTableDlg::InitAutoTableFormat()
{
- m_pWndPreview->DetectRTL(pShell);
+ m_xWndPreview->DetectRTL(pShell);
- m_pLbFormat->SetSelectHdl( LINK( this, SwInsTableDlg, SelFormatHdl ) );
+ m_xLbFormat->connect_changed(LINK(this, SwInsTableDlg, SelFormatHdl));
pTableTable = new SwTableAutoFormatTable;
pTableTable->Load();
// Add "- none -" style autoformat table.
- m_pLbFormat->InsertEntry( SwViewShell::GetShellRes()->aStrNone ); // Insert to listbox
+ m_xLbFormat->append( SwViewShell::GetShellRes()->aStrNone ); // Insert to listbox
// Add other styles of autoformat tables.
for (sal_uInt8 i = 0, nCount = static_cast<sal_uInt8>(pTableTable->size());
i < nCount; i++)
{
SwTableAutoFormat const& rFormat = (*pTableTable)[ i ];
- m_pLbFormat->InsertEntry(rFormat.GetName());
+ m_xLbFormat->append(rFormat.GetName());
if (pTAutoFormat && rFormat.GetName() == pTAutoFormat->GetName())
lbIndex = i;
}
@@ -138,10 +148,10 @@ void SwInsTableDlg::InitAutoTableFormat()
minTableIndexInLb = 1;
maxTableIndexInLb = minTableIndexInLb + static_cast<sal_uInt8>(pTableTable->size());
lbIndex = 1;
- m_pLbFormat->SelectEntryPos( lbIndex );
+ m_xLbFormat->select( lbIndex );
tbIndex = lbIndexToTableIndex(lbIndex);
- SelFormatHdl( *m_pLbFormat );
+ SelFormatHdl( *m_xLbFormat );
}
sal_uInt8 SwInsTableDlg::lbIndexToTableIndex( const sal_uInt8 listboxIndex )
@@ -156,30 +166,6 @@ sal_uInt8 SwInsTableDlg::lbIndexToTableIndex( const sal_uInt8 listboxIndex )
return 255;
}
-SwInsTableDlg::~SwInsTableDlg()
-{
- disposeOnce();
-}
-
-void SwInsTableDlg::dispose()
-{
- delete pTAutoFormat;
- m_pLbFormat.clear();
- m_pNameEdit.clear();
- m_pColNF.clear();
- m_pRowNF.clear();
- m_pHeaderCB.clear();
- m_pRepeatHeaderCB.clear();
- m_pRepeatHeaderNF.clear();
- m_pRepeatGroup.clear();
- m_pDontSplitCB.clear();
- m_pInsertBtn.clear();
- m_pWndPreview.clear();
- pTableTable->Save();
- delete pTableTable;
- SfxModalDialog::dispose();
-}
-
static void lcl_SetProperties( SwTableAutoFormat* pTableAutoFormat, bool bVal )
{
pTableAutoFormat->SetFont( bVal );
@@ -190,27 +176,26 @@ static void lcl_SetProperties( SwTableAutoFormat* pTableAutoFormat, bool bVal )
pTableAutoFormat->SetWidthHeight( bVal );
}
-
-IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void)
{
// Get index of selected item from the listbox
- lbIndex = static_cast<sal_uInt8>(m_pLbFormat->GetSelectedEntryPos());
+ lbIndex = static_cast<sal_uInt8>(m_xLbFormat->get_selected_index());
tbIndex = lbIndexToTableIndex( lbIndex );
// To understand this index maping, look InitAutoTableFormat function to
// see how listbox item is implemented.
if( tbIndex < 255 )
- m_pWndPreview->NotifyChange( (*pTableTable)[tbIndex] );
+ m_xWndPreview->NotifyChange( (*pTableTable)[tbIndex] );
else
{
SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone );
lcl_SetProperties( &aTmp, false );
- m_pWndPreview->NotifyChange( aTmp );
+ m_xWndPreview->NotifyChange( aTmp );
}
}
-IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, Button*, void)
+IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, weld::Button&, void)
{
if( tbIndex < 255 )
pShell->SetTableStyle((*pTableTable)[tbIndex]);
@@ -229,64 +214,58 @@ IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, Button*, void)
lcl_SetProperties( pTAutoFormat, false );
}
- EndDialog(RET_OK);
+ m_xDialog->response(RET_OK);
}
-IMPL_LINK( SwInsTableDlg, ModifyName, Edit&, rEdit, void )
+IMPL_LINK( SwInsTableDlg, ModifyName, weld::Entry&, rEdit, void )
{
- OUString sTableName = rEdit.GetText();
- if (sTableName.indexOf(' ') != -1)
- {
- sTableName = sTableName.replaceAll(" ", "");
- rEdit.SetText(sTableName);
- }
-
- m_pInsertBtn->Enable(pShell->GetTableStyle( sTableName ) == nullptr);
+ OUString sTableName = rEdit.get_text();
+ m_xInsertBtn->set_sensitive(pShell->GetTableStyle(sTableName) == nullptr);
}
-IMPL_LINK( SwInsTableDlg, ModifyRowCol, Edit&, rEdit, void )
+IMPL_LINK( SwInsTableDlg, ModifyRowCol, weld::SpinButton&, rEdit, void )
{
- if(&rEdit == m_pColNF)
+ if(&rEdit == m_xColNF.get())
{
- sal_Int64 nCol = m_pColNF->GetValue();
+ sal_Int64 nCol = m_xColNF->get_value();
if(!nCol)
nCol = 1;
- m_pRowNF->SetMax(ROW_COL_PROD/nCol);
+ m_xRowNF->set_max(ROW_COL_PROD/nCol);
}
else
{
- sal_Int64 nRow = m_pRowNF->GetValue();
+ sal_Int64 nRow = m_xRowNF->get_value();
if(!nRow)
nRow = 1;
- m_pColNF->SetMax(ROW_COL_PROD/nRow);
+ m_xColNF->set_max(ROW_COL_PROD/nRow);
// adjust depending NF for repeated rows
sal_Int64 nMax = ( nRow == 1 )? 1 : nRow - 1 ;
- sal_Int64 nActVal = m_pRepeatHeaderNF->GetValue();
+ sal_Int64 nActVal = m_xRepeatHeaderNF->get_value();
- m_pRepeatHeaderNF->SetMax( nMax );
+ m_xRepeatHeaderNF->set_max( nMax );
if( nActVal > nMax )
- m_pRepeatHeaderNF->SetValue( nMax );
+ m_xRepeatHeaderNF->set_value( nMax );
else if( nActVal < nEnteredValRepeatHeaderNF )
- m_pRepeatHeaderNF->SetValue( std::min( nEnteredValRepeatHeaderNF, nMax ) );
+ m_xRepeatHeaderNF->set_value(std::min(nEnteredValRepeatHeaderNF, nMax));
}
}
-IMPL_LINK_NOARG(SwInsTableDlg, CheckBoxHdl, Button*, void)
+IMPL_LINK_NOARG(SwInsTableDlg, CheckBoxHdl, weld::ToggleButton&, void)
{
- m_pRepeatHeaderCB->Enable(m_pHeaderCB->IsChecked());
- ReapeatHeaderCheckBoxHdl(nullptr);
+ m_xRepeatHeaderCB->set_sensitive(m_xHeaderCB->get_active());
+ RepeatHeaderCheckBoxHdl(*m_xRepeatHeaderCB);
}
-IMPL_LINK_NOARG(SwInsTableDlg, ReapeatHeaderCheckBoxHdl, Button*, void)
+IMPL_LINK_NOARG(SwInsTableDlg, RepeatHeaderCheckBoxHdl, weld::ToggleButton&, void)
{
- m_pRepeatGroup->Enable(m_pHeaderCB->IsChecked() && m_pRepeatHeaderCB->IsChecked());
+ m_xRepeatGroup->set_sensitive(m_xHeaderCB->get_active() && m_xRepeatHeaderCB->get_active());
}
-IMPL_LINK_NOARG(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl, Edit&, void)
+IMPL_LINK_NOARG(SwInsTableDlg, ModifyRepeatHeaderNF_Hdl, weld::SpinButton&, void)
{
- nEnteredValRepeatHeaderNF = m_pRepeatHeaderNF->GetValue();
+ nEnteredValRepeatHeaderNF = m_xRepeatHeaderNF->get_value();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 5adc8ca51fcd..d66969e539cb 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -65,7 +65,7 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell,
, m_xBtnAdd(m_xBuilder->weld_button("add"))
, m_xBtnRemove(m_xBuilder->weld_button("remove"))
, m_xBtnRename(m_xBuilder->weld_button("rename"))
- , m_aWndPreview(m_xBuilder->weld_drawing_area("preview"))
+ , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("preview")))
, m_xTableTable(new SwTableAutoFormatTable)
, aStrTitle(SwResId(STR_ADD_AUTOFORMAT_TITLE))
, aStrLabel(SwResId(STR_ADD_AUTOFORMAT_LABEL))
@@ -80,9 +80,14 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell,
, bCoreDataChanged(false)
, bSetAutoFormat(bAutoFormat)
{
- m_aWndPreview.DetectRTL(pWrtShell);
+ m_xWndPreview->DetectRTL(pWrtShell);
m_xTableTable->Load();
+ const int nWidth = m_xLbFormat->get_approximate_char_width() * 32;
+ const int nHeight = m_xLbFormat->get_height_rows(8);
+ m_xLbFormat->set_size_request(nWidth, nHeight);
+ m_xWndPreview->set_size_request(nWidth, nHeight);
+
Init(pSelFormat);
}
@@ -201,7 +206,7 @@ IMPL_LINK(SwAutoFormatDlg, CheckHdl, weld::ToggleButton&, rBtn, void)
bCoreDataChanged = true;
}
- m_aWndPreview.NotifyChange(rData);
+ m_xWndPreview->NotifyChange(rData);
}
}
@@ -370,7 +375,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void)
if (nSelPos >= nDfltStylePos)
{
m_nIndex = nSelPos - nDfltStylePos;
- m_aWndPreview.NotifyChange((*m_xTableTable)[m_nIndex]);
+ m_xWndPreview->NotifyChange((*m_xTableTable)[m_nIndex]);
bBtnEnable = 0 != m_nIndex;
UpdateChecks( (*m_xTableTable)[m_nIndex], true );
}
@@ -382,7 +387,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void)
lcl_SetProperties( &aTmp, false );
if (nOldIdx != m_nIndex)
- m_aWndPreview.NotifyChange(aTmp);
+ m_xWndPreview->NotifyChange(aTmp);
UpdateChecks( aTmp, false );
}
diff --git a/sw/source/uibase/inc/autoformatpreview.hxx b/sw/source/uibase/inc/autoformatpreview.hxx
index 50bf28074edc..c509a698a227 100644
--- a/sw/source/uibase/inc/autoformatpreview.hxx
+++ b/sw/source/uibase/inc/autoformatpreview.hxx
@@ -44,6 +44,11 @@ public:
void DetectRTL(SwWrtShell const* pWrtShell);
+ void set_size_request(int nWidth, int nHeight)
+ {
+ mxDrawingArea->set_size_request(nWidth, nHeight);
+ }
+
private:
std::unique_ptr<weld::DrawingArea> mxDrawingArea;
SwTableAutoFormat aCurData;
@@ -82,58 +87,6 @@ private:
vcl::Font& rCJKFont, vcl::Font& rCTLFont);
};
-class AutoFormatPreviewWindow : public vcl::Window
-{
-public:
- AutoFormatPreviewWindow(vcl::Window* pParent, WinBits nStyle);
- virtual ~AutoFormatPreviewWindow() override;
- virtual void dispose() override;
-
- void NotifyChange(const SwTableAutoFormat& rNewData);
-
- void DetectRTL(SwWrtShell const* pWrtShell);
-
- virtual void Resize() override;
-
-protected:
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
-
-private:
- SwTableAutoFormat aCurData;
- ScopedVclPtr<VirtualDevice> aVD;
- svx::frame::Array maArray; /// Implementation to draw the frame borders.
- bool bFitWidth;
- bool mbRTL;
- Size aPrvSize;
- long nLabelColWidth;
- long nDataColWidth1;
- long nDataColWidth2;
- long nRowHeight;
- const OUString aStrJan;
- const OUString aStrFeb;
- const OUString aStrMar;
- const OUString aStrNorth;
- const OUString aStrMid;
- const OUString aStrSouth;
- const OUString aStrSum;
- SvNumberFormatter* pNumFormat;
-
- uno::Reference<i18n::XBreakIterator> m_xBreak;
-
- void Init();
- void DoPaint(vcl::RenderContext& rRenderContext);
- void CalcCellArray(bool bFitWidth);
- void CalcLineMap();
- void PaintCells(vcl::RenderContext& rRenderContext);
-
- sal_uInt8 GetFormatIndex(size_t nCol, size_t nRow) const;
-
- void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow);
- void DrawBackground(vcl::RenderContext& rRenderContext);
-
- void MakeFonts(sal_uInt8 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont);
-};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx
index 288f9debb7f1..febda4e77613 100644
--- a/sw/source/uibase/inc/instable.hxx
+++ b/sw/source/uibase/inc/instable.hxx
@@ -35,26 +35,20 @@
#include <tblafmt.hxx>
#include <itabenum.hxx>
-class SwInsTableDlg : public SfxModalDialog
+class SwInsTableDlg : public weld::GenericDialogController
{
+ std::unique_ptr<weld::Entry> m_xNameEdit;
+ std::unique_ptr<weld::SpinButton> m_xColNF;
+ std::unique_ptr<weld::SpinButton> m_xRowNF;
+ std::unique_ptr<weld::CheckButton> m_xHeaderCB;
+ std::unique_ptr<weld::CheckButton> m_xRepeatHeaderCB;
+ std::unique_ptr<weld::SpinButton> m_xRepeatHeaderNF;
+ std::unique_ptr<weld::Widget> m_xRepeatGroup;
+ std::unique_ptr<weld::CheckButton> m_xDontSplitCB;
+ std::unique_ptr<weld::Button> m_xInsertBtn;
+ std::unique_ptr<weld::TreeView> m_xLbFormat;
+ std::unique_ptr<AutoFormatPreview> m_xWndPreview;
TextFilter m_aTextFilter;
- VclPtr<Edit> m_pNameEdit;
-
- VclPtr<NumericField> m_pColNF;
- VclPtr<NumericField> m_pRowNF;
-
- VclPtr<CheckBox> m_pHeaderCB;
- VclPtr<CheckBox> m_pRepeatHeaderCB;
- VclPtr<NumericField> m_pRepeatHeaderNF;
- VclPtr<VclContainer> m_pRepeatGroup;
-
- VclPtr<CheckBox> m_pDontSplitCB;
-
- VclPtr<PushButton> m_pInsertBtn;
-
- VclPtr<ListBox> m_pLbFormat;
-
- VclPtr<AutoFormatPreviewWindow> m_pWndPreview;
SwWrtShell* pShell;
SwTableAutoFormatTable* pTableTable;
@@ -71,18 +65,17 @@ class SwInsTableDlg : public SfxModalDialog
sal_uInt8 lbIndexToTableIndex( const sal_uInt8 listboxIndex );
void InitAutoTableFormat();
- DECL_LINK( SelFormatHdl, ListBox&, void );
- DECL_LINK( ModifyName, Edit&, void );
- DECL_LINK( ModifyRowCol, Edit&, void );
- DECL_LINK( OKHdl, Button*, void );
- DECL_LINK( CheckBoxHdl, Button*, void );
- DECL_LINK( ReapeatHeaderCheckBoxHdl, Button*, void );
- DECL_LINK( ModifyRepeatHeaderNF_Hdl, Edit&, void );
+ DECL_LINK(TextFilterHdl, OUString&, bool);
+ DECL_LINK(SelFormatHdl, weld::TreeView&, void);
+ DECL_LINK(ModifyName, weld::Entry&, void);
+ DECL_LINK(ModifyRowCol, weld::SpinButton&, void);
+ DECL_LINK(OKHdl, weld::Button&, void);
+ DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void);
+ DECL_LINK(RepeatHeaderCheckBoxHdl, weld::ToggleButton&, void);
+ DECL_LINK(ModifyRepeatHeaderNF_Hdl, weld::SpinButton&, void);
public:
- SwInsTableDlg( SwView& rView );
- virtual ~SwInsTableDlg() override;
- virtual void dispose() override;
+ SwInsTableDlg(SwView& rView);
void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableOpts, OUString& rTableAutoFormatName,
diff --git a/sw/source/uibase/inc/tautofmt.hxx b/sw/source/uibase/inc/tautofmt.hxx
index 984554a80467..d4b6a27f3b9f 100644
--- a/sw/source/uibase/inc/tautofmt.hxx
+++ b/sw/source/uibase/inc/tautofmt.hxx
@@ -48,7 +48,7 @@ class SwAutoFormatDlg : public weld::GenericDialogController
std::unique_ptr<weld::Button> m_xBtnAdd;
std::unique_ptr<weld::Button> m_xBtnRemove;
std::unique_ptr<weld::Button> m_xBtnRename;
- AutoFormatPreview m_aWndPreview;
+ std::unique_ptr<AutoFormatPreview> m_xWndPreview;
std::unique_ptr<SwTableAutoFormatTable> m_xTableTable;
OUString aStrTitle;
OUString aStrLabel;
diff --git a/sw/uiconfig/swriter/ui/autoformattable.ui b/sw/uiconfig/swriter/ui/autoformattable.ui
index 01b26163ff6a..f1c785e89968 100644
--- a/sw/uiconfig/swriter/ui/autoformattable.ui
+++ b/sw/uiconfig/swriter/ui/autoformattable.ui
@@ -103,8 +103,6 @@
<property name="column_spacing">12</property>
<child>
<object class="GtkGrid" id="grid2">
- <property name="width_request">450</property>
- <property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
diff --git a/sw/uiconfig/swriter/ui/inserttable.ui b/sw/uiconfig/swriter/ui/inserttable.ui
index c436a72b5357..a670ca54f60e 100644
--- a/sw/uiconfig/swriter/ui/inserttable.ui
+++ b/sw/uiconfig/swriter/ui/inserttable.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="adjustment1">
@@ -23,11 +23,19 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="InsertTableDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="inserttable|InsertTableDialog">Insert Table</property>
<property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -95,6 +103,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
@@ -233,19 +242,24 @@
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid" id="grid4">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkCheckButton" id="headercb">
@@ -340,16 +354,14 @@
</child>
<child>
<object class="GtkGrid" id="grid1">
- <property name="width_request">400</property>
- <property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
- <object class="swuilo-AutoFormatPreviewWindow" id="previewinstable">
- <property name="width_request">200</property>
- <property name="height_request">200</property>
+ <object class="GtkDrawingArea" id="previewinstable">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -361,17 +373,36 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindowinstable">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="formatlbinstable:border">
+ <object class="GtkTreeView" id="formatlbinstable">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="enable_search">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="treeviewinstable-selection1"/>
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -422,5 +453,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>