Kaydet (Commit) f7bf3cf5 authored tarafından Furkan Tokac's avatar Furkan Tokac Kaydeden (comit) Samuel Mehrbrodt

tdf#113558: Replace 'AutoFormat' button in insert table dialog.

Writer > Table > Insert Table... > AutoFormat part is moved to
"Insert Table..." dialog box with realtime style preview.

Change-Id: I72ed46401fb053156a4787450fc974951923d049
Reviewed-on: https://gerrit.libreoffice.org/49886Reviewed-by: 's avatarFurkan Tokac <furkantokac34@gmail.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
Tested-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst e07a1a5d
......@@ -146,6 +146,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\
sw/source/ui/misc/titlepage \
sw/source/ui/table/colwd \
sw/source/ui/table/convert \
sw/source/ui/table/autoformatpreview \
sw/source/ui/table/instable \
sw/source/ui/table/mergetbl \
sw/source/ui/table/rowht \
......
This diff is collapsed.
......@@ -17,21 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/msgbox.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <itabenum.hxx>
#include <instable.hxx>
#include <tblafmt.hxx>
#include <shellres.hxx>
#include <modcfg.hxx>
#include <swmodule.hxx>
#include <sfx2/htmlmode.hxx>
#include <viewopt.hxx>
#include <swabstdlg.hxx>
#include <swuiexp.hxx>
#include <memory>
#define ROW_COL_PROD 16384
......@@ -44,8 +36,6 @@ void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rC
rRow = static_cast<sal_uInt16>(m_pRowNF->GetValue());
rCol = static_cast<sal_uInt16>(m_pColNF->GetValue());
if (m_pBorderCB->IsChecked())
nInsMode |= tabopts::DEFAULT_BORDER;
if (m_pHeaderCB->IsChecked())
nInsMode |= tabopts::HEADLINE;
if (m_pRepeatHeaderCB->IsEnabled() && m_pRepeatHeaderCB->IsChecked())
......@@ -77,11 +67,11 @@ SwInsTableDlg::SwInsTableDlg( SwView& rView )
get(m_pHeaderCB, "headercb");
get(m_pRepeatHeaderCB, "repeatcb");
get(m_pDontSplitCB, "dontsplitcb");
get(m_pBorderCB, "bordercb");
get(m_pAutoFormatBtn, "autoformat");
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));
......@@ -90,7 +80,6 @@ SwInsTableDlg::SwInsTableDlg( SwView& rView )
m_pRowNF->SetMax(ROW_COL_PROD/m_pColNF->GetValue());
m_pColNF->SetMax(ROW_COL_PROD/m_pRowNF->GetValue());
m_pAutoFormatBtn->SetClickHdl(LINK(this, SwInsTableDlg, AutoFormatHdl));
m_pInsertBtn->SetClickHdl(LINK(this, SwInsTableDlg, OKHdl));
......@@ -103,19 +92,13 @@ SwInsTableDlg::SwInsTableDlg( SwView& rView )
m_pHeaderCB->Check( 0 != (nInsTableFlags & tabopts::HEADLINE) );
m_pRepeatHeaderCB->Check(aInsOpts.mnRowsToRepeat > 0);
if(bHTMLMode)
{
m_pDontSplitCB->Hide();
m_pBorderCB->SetPosPixel(m_pDontSplitCB->GetPosPixel());
}
else
{
m_pDontSplitCB->Check( 0 == (nInsTableFlags & tabopts::SPLIT_LAYOUT) );
}
m_pBorderCB->Check( 0 != (nInsTableFlags & tabopts::DEFAULT_BORDER) );
m_pRepeatHeaderNF->SetModifyHdl( LINK( this, SwInsTableDlg, ModifyRepeatHeaderNF_Hdl ) );
m_pHeaderCB->SetClickHdl(LINK(this, SwInsTableDlg, CheckBoxHdl));
m_pRepeatHeaderCB->SetClickHdl(LINK(this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl));
m_pHeaderCB->SetClickHdl( LINK( this, SwInsTableDlg, CheckBoxHdl ) );
m_pRepeatHeaderCB->SetClickHdl( LINK( this, SwInsTableDlg, ReapeatHeaderCheckBoxHdl ) );
ReapeatHeaderCheckBoxHdl(nullptr);
CheckBoxHdl(nullptr);
......@@ -125,11 +108,52 @@ SwInsTableDlg::SwInsTableDlg( SwView& rView )
else
--nMax;
m_pRepeatHeaderNF->SetMax( nMax );
InitAutoTableFormat();
}
IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, Button*, void)
void SwInsTableDlg::InitAutoTableFormat()
{
EndDialog(RET_OK);
m_pWndPreview->DetectRTL(pShell);
m_pLbFormat->SetSelectHdl( LINK( this, SwInsTableDlg, SelFormatHdl ) );
pTableTable = new SwTableAutoFormatTable;
pTableTable->Load();
// Add "- none -" style autoformat table.
m_pLbFormat->InsertEntry( 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());
if (pTAutoFormat && rFormat.GetName() == pTAutoFormat->GetName())
lbIndex = i;
}
// Change this min variable if you add autotable manually.
minTableIndexInLb = 1;
maxTableIndexInLb = minTableIndexInLb + static_cast<sal_uInt8>(pTableTable->size());
lbIndex = 1;
m_pLbFormat->SelectEntryPos( lbIndex );
tbIndex = lbIndexToTableIndex(lbIndex);
SelFormatHdl( *m_pLbFormat );
}
sal_uInt8 SwInsTableDlg::lbIndexToTableIndex( const sal_uInt8 listboxIndex )
{
if( minTableIndexInLb != maxTableIndexInLb &&
minTableIndexInLb <= listboxIndex &&
listboxIndex < maxTableIndexInLb )
{
return listboxIndex - minTableIndexInLb;
}
return 255;
}
SwInsTableDlg::~SwInsTableDlg()
......@@ -140,6 +164,7 @@ SwInsTableDlg::~SwInsTableDlg()
void SwInsTableDlg::dispose()
{
delete pTAutoFormat;
m_pLbFormat.clear();
m_pNameEdit.clear();
m_pColNF.clear();
m_pRowNF.clear();
......@@ -148,12 +173,65 @@ void SwInsTableDlg::dispose()
m_pRepeatHeaderNF.clear();
m_pRepeatGroup.clear();
m_pDontSplitCB.clear();
m_pBorderCB.clear();
m_pInsertBtn.clear();
m_pAutoFormatBtn.clear();
m_pWndPreview.clear();
pTableTable->Save();
delete pTableTable;
SfxModalDialog::dispose();
}
static void lcl_SetProperties( SwTableAutoFormat* pTableAutoFormat, bool bVal )
{
pTableAutoFormat->SetFont( bVal );
pTableAutoFormat->SetJustify( bVal );
pTableAutoFormat->SetFrame( bVal );
pTableAutoFormat->SetBackground( bVal );
pTableAutoFormat->SetValueFormat( bVal );
pTableAutoFormat->SetWidthHeight( bVal );
}
IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, ListBox&, void)
{
// Get index of selected item from the listbox
lbIndex = static_cast<sal_uInt8>(m_pLbFormat->GetSelectedEntryPos());
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] );
else
{
SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone );
lcl_SetProperties( &aTmp, false );
m_pWndPreview->NotifyChange( aTmp );
}
}
IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, Button*, void)
{
if( tbIndex < 255 )
pShell->SetTableStyle((*pTableTable)[tbIndex]);
if( tbIndex < 255 )
{
if( pTAutoFormat )
*pTAutoFormat = (*pTableTable)[ tbIndex ];
else
pTAutoFormat = new SwTableAutoFormat( (*pTableTable)[ tbIndex ] );
}
else
{
delete pTAutoFormat;
pTAutoFormat = new SwTableAutoFormat( SwViewShell::GetShellRes()->aStrNone );
lcl_SetProperties( pTAutoFormat, false );
}
EndDialog(RET_OK);
}
IMPL_LINK( SwInsTableDlg, ModifyName, Edit&, rEdit, void )
{
OUString sTableName = rEdit.GetText();
......@@ -194,16 +272,6 @@ IMPL_LINK( SwInsTableDlg, ModifyRowCol, Edit&, rEdit, void )
m_pRepeatHeaderNF->SetValue( std::min( nEnteredValRepeatHeaderNF, nMax ) );
}
}
IMPL_LINK( SwInsTableDlg, AutoFormatHdl, Button*, pButton, void )
{
SwAbstractDialogFactory* pFact = swui::GetFactory();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton,pShell, false, pTAutoFormat));
OSL_ENSURE(pDlg, "Dialog creation failed!");
if( RET_OK == pDlg->Execute())
pDlg->FillAutoFormatOfIndex( pTAutoFormat );
}
IMPL_LINK_NOARG(SwInsTableDlg, CheckBoxHdl, Button*, void)
{
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_AUTOFORMATPREVIEW_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_AUTOFORMATPREVIEW_HXX
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <sal/types.h>
#include <svx/framelinkarray.hxx>
#include <svl/zforlist.hxx>
#include <tools/gen.hxx>
#include <tools/link.hxx>
#include <rtl/ustring.hxx>
#include <vcl/outdev.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/virdev.hxx>
#include <vcl/font.hxx>
#include "wrtsh.hxx"
#include <tblafmt.hxx>
class AutoFormatPreview : public vcl::Window
{
public:
AutoFormatPreview(vcl::Window* pParent, WinBits nStyle);
virtual ~AutoFormatPreview() 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: */
......@@ -19,48 +19,64 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_INSTABLE_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_INSTABLE_HXX
#include <sfx2/basedlgs.hxx>
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <tools/link.hxx>
#include <vcl/vclreferencebase.hxx>
#include <vcl/button.hxx>
#include <vcl/field.hxx>
#include <vcl/edit.hxx>
#include <vcl/field.hxx>
#include <vcl/layout.hxx>
#include <sfx2/basedlgs.hxx>
#include "actctrl.hxx"
class SwWrtShell;
class SwTableAutoFormat;
class SwView;
struct SwInsertTableOptions;
#include "wrtsh.hxx"
#include "autoformatpreview.hxx"
#include <view.hxx>
#include <tblafmt.hxx>
#include <itabenum.hxx>
class SwInsTableDlg : public SfxModalDialog
{
VclPtr<Edit> m_pNameEdit;
TextFilter m_aTextFilter;
VclPtr<Edit> m_pNameEdit;
VclPtr<NumericField> m_pColNF;
VclPtr<NumericField> m_pRowNF;
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_pHeaderCB;
VclPtr<CheckBox> m_pRepeatHeaderCB;
VclPtr<NumericField> m_pRepeatHeaderNF;
VclPtr<VclContainer> m_pRepeatGroup;
VclPtr<CheckBox> m_pDontSplitCB;
VclPtr<CheckBox> m_pBorderCB;
VclPtr<CheckBox> m_pDontSplitCB;
VclPtr<PushButton> m_pInsertBtn;
VclPtr<PushButton> m_pAutoFormatBtn;
VclPtr<PushButton> m_pInsertBtn;
VclPtr<ListBox> m_pLbFormat;
VclPtr<AutoFormatPreview> m_pWndPreview;
SwWrtShell* pShell;
SwTableAutoFormat* pTAutoFormat;
SwTableAutoFormatTable* pTableTable;
SwTableAutoFormat* pTAutoFormat;
sal_uInt8 lbIndex;
sal_uInt8 tbIndex;
sal_uInt8 minTableIndexInLb;
sal_uInt8 maxTableIndexInLb;
sal_Int64 nEnteredValRepeatHeaderNF;
// Returns 255 if mapping is not possible.
// This means there cannot be more than 255 autotable style.
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( AutoFormatHdl, Button*, void );
DECL_LINK( OKHdl, Button*, void);
DECL_LINK( CheckBoxHdl, Button*, void);
DECL_LINK( ReapeatHeaderCheckBoxHdl, Button*, void);
DECL_LINK( OKHdl, Button*, void );
DECL_LINK( CheckBoxHdl, Button*, void );
DECL_LINK( ReapeatHeaderCheckBoxHdl, Button*, void );
DECL_LINK( ModifyRepeatHeaderNF_Hdl, Edit&, void );
public:
......
......@@ -18,20 +18,21 @@
*/
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_TAUTOFMT_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_TAUTOFMT_HXX
#include <sfx2/basedlgs.hxx>
#include <vcl/fixed.hxx>
#include <vcl/lstbox.hxx>
#include <tools/link.hxx>
#include <sfx2/basedlgs.hxx>
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <vcl/vclreferencebase.hxx>
#include <vcl/button.hxx>
#include <vcl/layout.hxx>
#include <vcl/window.hxx>
#include <vcl/morebtn.hxx>
#include <vcl/virdev.hxx>
#include "wrtsh.hxx"
#include "autoformatpreview.hxx"
#include <tblafmt.hxx>
class SwTableAutoFormat;
class AutoFormatPreview;
class SwTableAutoFormatTable;
class SwWrtShell;
......@@ -61,7 +62,7 @@ class SwAutoFormatDlg : public SfxModalDialog
VclPtr<AutoFormatPreview> m_pWndPreview;
SwWrtShell* pShell;
SwTableAutoFormatTable* pTableTable;
SwTableAutoFormatTable* pTableTable;
sal_uInt8 nIndex;
sal_uInt8 nDfltStylePos;
bool bCoreDataChanged : 1;
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.18.3 -->
<interface domain="sw">
<requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="adjustment1">
......@@ -48,7 +48,7 @@
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
......@@ -277,22 +277,6 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="bordercb">
<property name="label" translatable="yes" context="inserttable|bordercb">_Border</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="dontsplitcb">
<property name="label" translatable="yes" context="inserttable|dontsplitcb">Don’t _split table over pages</property>
......@@ -351,19 +335,52 @@
</packing>
</child>
<child>
<object class="GtkButton" id="autoformat">
<property name="label" translatable="yes" context="inserttable|autoformat">Auto_Format</property>
<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">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="hexpand">True</property>
<property name="use_underline">True</property>
<property name="image_position">right</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="swuilo-AutoFormatPreview" id="previewinstable">
<property name="width_request">200</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>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindowinstable">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="formatlbinstable:border">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeviewinstable-selection1"/>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">4</property>
</packing>
</child>
</object>
......
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