include/svtools/treelistbox.hxx | 2 - sfx2/source/dialog/dialog.hrc | 1 sfx2/source/dialog/dialog.src | 5 ++ sfx2/source/dialog/templdlg.cxx | 63 ++++++++++++++++++++++++++++------ sfx2/source/inc/templdgi.hxx | 4 +- svtools/source/contnr/treelistbox.cxx | 4 +- 6 files changed, 64 insertions(+), 15 deletions(-)
New commits: commit 0380a6408030ad9db85b4be81095219d5572749b Author: Susobhan Ghosh <susobhan...@gmail.com> Date: Sat Jul 30 02:42:50 2016 +0530 tdf#93845: Style Preview Checkbox for Styles & Formatting sidebar Change-Id: Id5862339bbe0c80002dfd99cbf19d981d1d42682 Reviewed-on: https://gerrit.libreoffice.org/27706 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx index 9421703..fdbc9e6 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 2bfd1af..551478a 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 c66f447..732a716 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 5fc6443..e185487 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 0ffb548..385a40a 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 4754c51..14d1efc 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 )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits