summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusobhan Ghosh <susobhang70@gmail.com>2016-07-30 02:42:50 +0530
committerTomaž Vajngerl <quikee@gmail.com>2016-08-01 13:29:04 +0000
commit0380a6408030ad9db85b4be81095219d5572749b (patch)
treec34ed06f55a0101aa0cb2766233e5af6a16b7ad0
parentf63a85d8f9437a634ddb6be1f858e28b5f7018e8 (diff)
tdf#93845: Style Preview Checkbox for Styles & Formatting sidebar
Change-Id: Id5862339bbe0c80002dfd99cbf19d981d1d42682 Reviewed-on: https://gerrit.libreoffice.org/27706 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/svtools/treelistbox.hxx2
-rw-r--r--sfx2/source/dialog/dialog.hrc1
-rw-r--r--sfx2/source/dialog/dialog.src5
-rw-r--r--sfx2/source/dialog/templdlg.cxx63
-rw-r--r--sfx2/source/inc/templdgi.hxx4
-rw-r--r--svtools/source/contnr/treelistbox.cxx4
6 files changed, 64 insertions, 15 deletions
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index 942170317d3c..fdbc9e622699 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -704,7 +704,7 @@ public:
short GetColumnsCount() const { return nColumns; }
short GetEntryHeight() const { return nEntryHeight; }
- void SetEntryHeight( short nHeight );
+ void SetEntryHeight( short nHeight, bool bForce = false );
short GetEntryWidth() const { return nEntryWidth; }
void SetEntryWidth( short nWidth );
Size GetOutputSizePixel() const;
diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc
index 2bfd1af5ea5b..551478a34e85 100644
--- a/sfx2/source/dialog/dialog.hrc
+++ b/sfx2/source/dialog/dialog.hrc
@@ -61,6 +61,7 @@
#define SFX_ST_EDIT ( RC_DIALOG_BEGIN + 124 )
#define STR_STYLE_ELEMTLIST ( RC_DIALOG_BEGIN + 125 )
#define STR_FONT_TABPAGE ( RC_DIALOG_BEGIN + 126 )
+#define STR_PREVIEW_CHECKBOX ( RC_DIALOG_BEGIN + 127 )
#endif
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index c66f4475858a..732a716b1ecd 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -121,6 +121,11 @@ String STR_FONT_TABPAGE
Text [ en-US ] = "Font" ;
};
+String STR_PREVIEW_CHECKBOX
+{
+ Text [ en-US ] = "Show Previews";
+};
+
Menu RID_MENU_NOTEBOOKBAR
{
ItemList =
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 5fc64430d176..e185487513a7 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -68,6 +68,9 @@
#include <sfx2/StyleManager.hxx>
#include <sfx2/StylePreviewRenderer.hxx>
#include <o3tl/make_unique.hxx>
+
+#define STD_ENTRY_HEIGHT 17
+
using namespace css;
using namespace css::beans;
using namespace css::frame;
@@ -322,10 +325,10 @@ SfxActionListBox::SfxActionListBox(SfxCommonTemplateDialog_Impl* pParent, WinBit
void SfxActionListBox::Recalc()
{
if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
- {
SetEntryHeight(32 * GetDPIScaleFactor());
- RecalcViewData();
- }
+ else
+ SetEntryHeight(STD_ENTRY_HEIGHT, true);
+ RecalcViewData();
}
VclPtr<PopupMenu> SfxActionListBox::CreateContextMenu()
@@ -509,10 +512,10 @@ StyleTreeListBox_Impl::StyleTreeListBox_Impl(SfxCommonTemplateDialog_Impl* pPare
void StyleTreeListBox_Impl::Recalc()
{
if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
- {
SetEntryHeight(32 * GetDPIScaleFactor());
- RecalcViewData();
- }
+ else
+ SetEntryHeight(STD_ENTRY_HEIGHT, true);
+ RecalcViewData();
}
/** Internal structure for the establishment of the hierarchical view */
@@ -653,6 +656,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
, aFmtLb( VclPtr<SfxActionListBox>::Create(this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH) )
, aFilterLb( VclPtr<ListBox>::Create(pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP) )
+ , aPreviewCheckbox( VclPtr<CheckBox>::Create( pW, WB_VCENTER ))
, nActFamily(0xffff)
, nActFilter(0)
@@ -682,6 +686,8 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
vcl::Font aFont = aFmtLb->GetFont();
aFont.SetWeight( WEIGHT_NORMAL );
aFmtLb->SetFont( aFont );
+ aPreviewCheckbox->Check(officecfg::Office::Common::StylesAndFormatting::Preview::get());
+ aPreviewCheckbox->SetText( SfxResId(STR_PREVIEW_CHECKBOX) );
memset(pBoundItems, 0, sizeof(pBoundItems));
memset(pFamilyState, 0, sizeof(pFamilyState));
@@ -847,11 +853,13 @@ void SfxCommonTemplateDialog_Impl::Initialize()
aFmtLb->SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, TreeListApplyHdl ) );
aFmtLb->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
aFmtLb->SetSelectionMode(SelectionMode::Multiple);
+ aPreviewCheckbox->SetClickHdl( LINK(this, SfxCommonTemplateDialog_Impl, PreviewHdl));
aFilterLb->Show();
if (!bHierarchical)
aFmtLb->Show();
+ aPreviewCheckbox->Show();
}
SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
@@ -874,6 +882,7 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
m_pDeletionWatcher->signal();
aFmtLb.disposeAndClear();
aFilterLb.disposeAndClear();
+ aPreviewCheckbox.disposeAndClear();
}
namespace SfxTemplate
@@ -1378,8 +1387,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
ppItem+=StyleNrToInfoOffset(n);
nAppFilter = (*ppItem)->GetValue();
- FamilySelect( StyleNrToInfoOffset(n)+1 );
-
+ FamilySelect( StyleNrToInfoOffset(n) + 1 );
pItem = *ppItem;
}
else if( bDocChanged )
@@ -1687,9 +1695,9 @@ IMPL_LINK_TYPED( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox&, rBox,
}
// Select-Handler for the Toolbox
-void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry)
+void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, bool bPreviewRefresh)
{
- if( nEntry != nActFamily )
+ if( nEntry != nActFamily || bPreviewRefresh )
{
CheckItem( nActFamily, false );
nActFamily = nEntry;
@@ -2065,6 +2073,30 @@ IMPL_LINK_NOARG_TYPED( SfxCommonTemplateDialog_Impl, ApplyHdl, LinkParamNone*, v
ResetFocus();
}
+IMPL_LINK_NOARG_TYPED( SfxCommonTemplateDialog_Impl, PreviewHdl, Button*, void)
+{
+ std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() );
+ officecfg::Office::Common::StylesAndFormatting::Preview::set( aPreviewCheckbox->IsChecked(), batch );
+ batch->commit();
+ if(!bHierarchical)
+ {
+ sal_uInt16 nSize = aFmtLb->GetEntryCount();
+ for (sal_uInt16 nPos = 0; nPos < nSize; ++nPos )
+ {
+ SvTreeListEntry* pTreeListEntry = aFmtLb->GetEntry(nPos);
+ OUString aEntryStr = aFmtLb->GetEntryText(pTreeListEntry);
+ const SfxStyleFamily eFam = aPreviewCheckbox->IsChecked() ? GetFamilyItem_Impl()->GetFamily(): SfxStyleFamily::None;
+ pTreeListEntry->ReplaceItem(o3tl::make_unique<StyleLBoxString>(aEntryStr, eFam), 1);
+ aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry);
+ aFmtLb->Recalc();
+ }
+ }
+ else
+ {
+ FamilySelect(nActFamily, true);
+ }
+}
+
// Selection of a template during the Watercan-Status
IMPL_LINK_TYPED( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox, void )
{
@@ -2364,6 +2396,13 @@ void SfxTemplateDialog_Impl::Resize()
Size aFilterSize(
m_pFloat->LogicToPixel(Size(nWidth,SFX_TEMPLDLG_FILTERHEIGHT)) );
+ Point aCheckBoxPos(
+ m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,
+ aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-2*nListHeight)) );
+
+ Size aCheckBoxSize(
+ m_pFloat->LogicToPixel(Size(nWidth, nListHeight)) );
+
Point aFmtPos(
m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, SFX_TEMPLDLG_VTOPFRAME +
SFX_TEMPLDLG_MIDVSPACE+aSizeATL.Height())) );
@@ -2371,13 +2410,14 @@ void SfxTemplateDialog_Impl::Resize()
m_pFloat->LogicToPixel(Size(nWidth,
aDlgSize.Height() - SFX_TEMPLDLG_VBOTFRAME -
SFX_TEMPLDLG_VTOPFRAME - 2*SFX_TEMPLDLG_MIDVSPACE-
- nListHeight-aSizeATL.Height())) );
+ 2*nListHeight-aSizeATL.Height())) );
// only change the position of the listbox, when the window is high enough
if(aDlgSize.Height() >= aMinSize.Height())
{
aFilterLb->SetPosPixel(aFilterPos);
aFmtLb->SetPosPixel( aFmtPos );
+ aPreviewCheckbox->SetPosPixel(aCheckBoxPos);
if(pTreeBox)
pTreeBox->SetPosPixel(aFmtPos);
}
@@ -2386,6 +2426,7 @@ void SfxTemplateDialog_Impl::Resize()
aFilterLb->SetSizePixel(aFilterSize);
aFmtLb->SetSizePixel( aFmtSize );
+ aPreviewCheckbox->SetSizePixel( aCheckBoxSize );
if(pTreeBox)
pTreeBox->SetSizePixel(aFmtSize);
}
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 0ffb548a11c7..385a40a5a1d1 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -186,6 +186,7 @@ protected:
VclPtr<SfxActionListBox> aFmtLb;
VclPtr<ListBox> aFilterLb;
+ VclPtr<CheckBox> aPreviewCheckbox;
sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
sal_uInt16 nActFilter; // FilterIdx
@@ -214,6 +215,7 @@ protected:
DECL_LINK_TYPED( TreeListApplyHdl, SvTreeListBox*, bool );
DECL_LINK_TYPED( DropHdl, StyleTreeListBox_Impl&, bool );
DECL_LINK_TYPED( TimeOut, Idle*, void );
+ DECL_LINK_TYPED( PreviewHdl, Button*, void);
virtual void EnableItem(sal_uInt16 /*nMesId*/, bool /*bCheck*/ = true)
{}
@@ -271,7 +273,7 @@ protected:
void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
- void FamilySelect( sal_uInt16 nId );
+ void FamilySelect( sal_uInt16 nId, bool bPreviewRefresh = false );
void SetFamily( sal_uInt16 nId );
void ActionSelect( sal_uInt16 nId );
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 4754c5114031..14d1efc6e158 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -2225,9 +2225,9 @@ void SvTreeListBox::SetEntryHeight( SvTreeListEntry* pEntry )
}
}
-void SvTreeListBox::SetEntryHeight( short nHeight )
+void SvTreeListBox::SetEntryHeight( short nHeight, bool bForce )
{
- if( nHeight > nEntryHeight )
+ if( nHeight > nEntryHeight || bForce )
{
nEntryHeight = nHeight;
if( nEntryHeight )