include/sfx2/StyleManager.hxx | 6 + include/svx/CommonStyleManager.hxx | 4 - officecfg/registry/schema/org/openoffice/Office/Common.xcs | 13 +++ sfx2/Library_sfx.mk | 1 sfx2/source/dialog/templdlg.cxx | 52 ++++++++----- sfx2/source/styles/StyleManager.cxx | 38 +++++++++ svx/source/styles/CommonStyleManager.cxx | 21 ----- vcl/inc/unx/gtk/gtkgdi.hxx | 1 vcl/unx/generic/gdi/salgdi.cxx | 8 ++ vcl/unx/gtk/app/gtkdata.cxx | 19 ++++ vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 26 ++++++ 11 files changed, 148 insertions(+), 41 deletions(-)
New commits: commit 14257152b19c08618a107c6eb0f684de11483da8 Author: Tomaž Vajngerl <[email protected]> Date: Thu Jul 16 17:04:41 2015 +0900 use search from StyleManager in "Style & Formatting" Change-Id: I09fff1816b1d569cbfd50c7cafb19c9b169528bf diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 9446d0b..ab25ccd 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -132,21 +132,28 @@ void StyleLBoxString::Paint( if (pStyleManager) { - std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer(pStyleManager->CreateStylePreviewRenderer(rRenderContext, GetText(), meStyleFamily, 32 * rRenderContext.GetDPIScaleFactor())); + SfxStyleSheetBase* pStyleSheet = pStyleManager->Search(GetText(), meStyleFamily); - if (pStylePreviewRenderer) + if (pStyleSheet) { - if (pStylePreviewRenderer->recalculate()) - { - mpViewData->maSize = pStylePreviewRenderer->getRenderSize(); - } - else + sal_Int32 nSize = 32 * rRenderContext.GetDPIScaleFactor(); + std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer( + pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize)); + + if (pStylePreviewRenderer) { - SvLBoxString::InitViewData( &rDevice, const_cast<SvTreeListEntry*>(&rEntry), mpViewData); - } + if (pStylePreviewRenderer->recalculate()) + { + mpViewData->maSize = pStylePreviewRenderer->getRenderSize(); + } + else + { + SvLBoxString::InitViewData( &rDevice, const_cast<SvTreeListEntry*>(&rEntry), mpViewData); + } - Rectangle aPaintRectangle = pView->GetPaintRectangle(); - bPainted = pStylePreviewRenderer->render(aPaintRectangle); + Rectangle aPaintRectangle = pView->GetPaintRectangle(); + bPainted = pStylePreviewRenderer->render(aPaintRectangle); + } } } commit 53c40258d3572152b46e5ff5f51496ae6f32879b Author: Tomaž Vajngerl <[email protected]> Date: Wed Jul 15 16:19:12 2015 +0900 StyleManager: move style search to its own method And remove obsolete CreateStylePreviewRenderer method with style name as input parameter. Change-Id: I0fdf54fd40148b417250b5a6bf2453994eb83634 diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx index badc39c..c6e7c23 100644 --- a/include/sfx2/StyleManager.hxx +++ b/include/sfx2/StyleManager.hxx @@ -35,9 +35,7 @@ public: virtual ~StyleManager() {} - virtual StylePreviewRenderer* CreateStylePreviewRenderer( - OutputDevice& rOutputDev, OUString const & rName, - SfxStyleFamily eFamily, long nMaxHeight = 32) = 0; + SfxStyleSheetBase* Search(const OUString& rStyleName, SfxStyleFamily eFamily); virtual StylePreviewRenderer* CreateStylePreviewRenderer( OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, diff --git a/include/svx/CommonStyleManager.hxx b/include/svx/CommonStyleManager.hxx index 1fc22a6..97f1de9 100644 --- a/include/svx/CommonStyleManager.hxx +++ b/include/svx/CommonStyleManager.hxx @@ -30,10 +30,6 @@ public: {} virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer( - OutputDevice& rOutputDev, OUString const & rName, - SfxStyleFamily eFamily, long nMaxHeight = 32) SAL_OVERRIDE; - - virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer( OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, long nMaxHeight = 32) SAL_OVERRIDE; }; diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 5db89dd..b56f7f5 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -289,6 +289,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/sidebar/UnoDecks \ sfx2/source/sidebar/UnoSidebar \ sfx2/source/statbar/stbitem \ + sfx2/source/styles/StyleManager \ sfx2/source/toolbox/imgmgr \ sfx2/source/toolbox/tbxitem \ sfx2/source/view/frame \ diff --git a/sfx2/source/styles/StyleManager.cxx b/sfx2/source/styles/StyleManager.cxx new file mode 100644 index 0000000..aea80be --- /dev/null +++ b/sfx2/source/styles/StyleManager.cxx @@ -0,0 +1,38 @@ +/* -*- 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/. + */ + +#include <sfx2/StyleManager.hxx> + +namespace sfx2 +{ + +SfxStyleSheetBase* StyleManager::Search(const OUString& rStyleName, SfxStyleFamily eFamily) +{ + SfxStyleSheetBasePool* pPool = mrShell.GetStyleSheetPool(); + if (!pPool) + return nullptr; + + pPool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL); + SfxStyleSheetBase* pStyle = nullptr; + pStyle = pPool->First(); + + while (pStyle) + { + if (rStyleName == pStyle->GetName()) + return pStyle; + + pStyle = pPool->Next(); + } + + return nullptr; +} + +} // end namespace sfx2 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/styles/CommonStyleManager.cxx b/svx/source/styles/CommonStyleManager.cxx index 0cabafd..2dd825b 100644 --- a/svx/source/styles/CommonStyleManager.cxx +++ b/svx/source/styles/CommonStyleManager.cxx @@ -15,29 +15,6 @@ namespace svx { sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer( - OutputDevice& rOutputDev, OUString const & rName, - SfxStyleFamily eFamily, long nMaxHeight) -{ - SfxStyleSheetBasePool* pPool = mrShell.GetStyleSheetPool(); - if (!pPool) - return nullptr; - - pPool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL); - SfxStyleSheetBase* pStyle = nullptr; - pStyle = pPool->First(); - - while (pStyle) - { - if (rName == pStyle->GetName()) - return CreateStylePreviewRenderer(rOutputDev, pStyle, nMaxHeight); - - pStyle = pPool->Next(); - } - - return nullptr; -} - -sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer( OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, long nMaxHeight) { commit 76360c8de7bf6f0baef9c0440a2f721f15cc1564 Author: Tomaž Vajngerl <[email protected]> Date: Mon Jun 8 14:26:49 2015 +0900 create the stlye preview renderer with style as parameter Change-Id: Ie191467305279253f165f13980c125f6b7b9fdde diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx index 962fbb9..badc39c 100644 --- a/include/sfx2/StyleManager.hxx +++ b/include/sfx2/StyleManager.hxx @@ -38,6 +38,10 @@ public: virtual StylePreviewRenderer* CreateStylePreviewRenderer( OutputDevice& rOutputDev, OUString const & rName, SfxStyleFamily eFamily, long nMaxHeight = 32) = 0; + + virtual StylePreviewRenderer* CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + long nMaxHeight = 32) = 0; }; } // end namespace sfx2 diff --git a/include/svx/CommonStyleManager.hxx b/include/svx/CommonStyleManager.hxx index 0ce0a3d..1fc22a6 100644 --- a/include/svx/CommonStyleManager.hxx +++ b/include/svx/CommonStyleManager.hxx @@ -32,6 +32,10 @@ public: virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer( OutputDevice& rOutputDev, OUString const & rName, SfxStyleFamily eFamily, long nMaxHeight = 32) SAL_OVERRIDE; + + virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + long nMaxHeight = 32) SAL_OVERRIDE; }; } // end namespace svx diff --git a/svx/source/styles/CommonStyleManager.cxx b/svx/source/styles/CommonStyleManager.cxx index d452ba4..0cabafd 100644 --- a/svx/source/styles/CommonStyleManager.cxx +++ b/svx/source/styles/CommonStyleManager.cxx @@ -29,13 +29,21 @@ sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer( while (pStyle) { if (rName == pStyle->GetName()) - return new CommonStylePreviewRenderer(mrShell, rOutputDev, pStyle, nMaxHeight); + return CreateStylePreviewRenderer(rOutputDev, pStyle, nMaxHeight); + pStyle = pPool->Next(); } return nullptr; } +sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + long nMaxHeight) +{ + return new CommonStylePreviewRenderer(mrShell, rOutputDev, pStyle, nMaxHeight); +} + } // end svx namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 210f42a318cbac62de835ccacbc1fc0e36f713f6 Author: Tomaž Vajngerl <[email protected]> Date: Tue Jul 14 14:19:23 2015 +0900 tdf#91495 add property to turn off stlye previews Newly added property Office::Common::StylesAndFormatting::Preview can now be used to turn off "Style And Formatting" style preview. Change-Id: I2e01de2a74e2d295557c87022a7b745ce23b4800 diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 220a989..7e722ca 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2165,7 +2165,7 @@ <!-- UIHints: Tools Options - General Save - [Section] Save --> <info> <desc>Specifies whether to generate a thumbnail image and place it inside the - the odf archive file, which makes it possible to see a preview of the document.</desc> + the odf archive file, which makes it possible to see a preview of the document.</desc> <label>Store a preview of this document</label> </info> <value>true</value> @@ -6634,5 +6634,16 @@ </prop> </group> </group> + <group oor:name="StylesAndFormatting"> + <info> + <desc>Contains settings for Styles and Formatting.</desc> + </info> + <prop oor:name="Preview" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Specifies if the styles and formatting preview is enabled.</desc> + </info> + <value>true</value> + </prop> + </group> </component> </oor:component-schema> diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 5b91be9..9446d0b 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/frame/theUICommandDescription.hpp> +#include <officecfg/Office/Common.hxx> #include <sfx2/sfxhelp.hxx> #include <sfx2/app.hxx> @@ -515,8 +516,11 @@ StyleTreeListBox_Impl::StyleTreeListBox_Impl(SfxCommonTemplateDialog_Impl* pPare void StyleTreeListBox_Impl::Recalc() { - SetEntryHeight(32 * GetDPIScaleFactor()); - RecalcViewData(); + if (officecfg::Office::Common::StylesAndFormatting::Preview::get()) + { + SetEntryHeight(32 * GetDPIScaleFactor()); + RecalcViewData(); + } } /** Internal structure for the establishment of the hierarchical view */ @@ -627,9 +631,11 @@ SvTreeListEntry* FillBox_Impl(SvTreeListBox* pBox, { SvTreeListEntry* pTreeListEntry = pBox->InsertEntry(pEntry->getName(), pParent); - StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, pEntry->getName(), eStyleFamily); - - pTreeListEntry->ReplaceItem(pStyleLBoxString, 1); + if (officecfg::Office::Common::StylesAndFormatting::Preview::get()) + { + StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, pEntry->getName(), eStyleFamily); + pTreeListEntry->ReplaceItem(pStyleLBoxString, 1); + } pBox->GetModel()->InvalidateEntry(pTreeListEntry); @@ -1245,8 +1251,11 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) for(nPos = 0; nPos < nCount; ++nPos) { SvTreeListEntry* pTreeListEntry = aFmtLb->InsertEntry(aStrings[nPos], 0, false, nPos); - StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, aStrings[nPos], eFam); - pTreeListEntry->ReplaceItem(pStyleLBoxString, 1); + if (officecfg::Office::Common::StylesAndFormatting::Preview::get()) + { + StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, aStrings[nPos], eFam); + pTreeListEntry->ReplaceItem(pStyleLBoxString, 1); + } aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry); } aFmtLb->Recalc(); commit 9827eaeac51149c9c26abc4a8cca6f2029274ee5 Author: Tomaž Vajngerl <[email protected]> Date: Tue Jul 14 14:15:39 2015 +0900 force a specific DPI with SAL_FORCEDPI (GTK2 & GTK3 backends only) Change-Id: I2c154e4df060ade36744c6aa2fbffa8c6e665629 diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index ee68a0c..5561250 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -278,6 +278,14 @@ bool X11SalGraphics::GetDitherPixmap( SalColor nSalColor ) void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // const { + char* pForceDpi; + if ((pForceDpi = getenv("SAL_FORCEDPI"))) + { + OString sForceDPI(pForceDpi); + rDPIX = rDPIY = sForceDPI.toInt32(); + return; + } + const SalDisplay *pDisplay = GetDisplay(); if (!pDisplay) { diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 0e3b0f6..c593559 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -2102,6 +2102,14 @@ cairo_t* GtkSalGraphics::getCairoContext() const void GtkSalGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) { + char* pForceDpi; + if ((pForceDpi = getenv("SAL_FORCEDPI"))) + { + OString sForceDPI(pForceDpi); + rDPIX = rDPIY = sForceDPI.toInt32(); + return; + } + GdkScreen* pScreen = gtk_widget_get_screen(mpWindow); double fResolution = -1.0; g_object_get(pScreen, "resolution", &fResolution, nullptr); commit 2a19bb85cbe83aa031871a3689b9ff03629da548 Author: Tomaž Vajngerl <[email protected]> Date: Mon Jul 13 16:12:11 2015 +0900 GTK3 HiDPI: disable window scaling and get display DPI via GTK3 Change-Id: I66b92146757352408a331f9e23289839f443ff79 diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 80de62b..b533cb4 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -61,6 +61,7 @@ public: cairo_t* getCairoContext() const; + virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) SAL_OVERRIDE; private: GtkWidget *mpWindow; static GtkStyleContext *mpButtonStyle; diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index df4470b..6e0f711 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -46,6 +46,12 @@ #include <vcl/svapp.hxx> +#if GTK_CHECK_VERSION(3,10,0) +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif +#endif + using namespace vcl_sal; /*************************************************************** @@ -87,6 +93,19 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) : #else m_bX11Display = true; #endif + +#if GTK_CHECK_VERSION(3,10,0) +#ifdef GDK_WINDOWING_X11 + if (m_bX11Display) + { + if (!getenv("GDK_SCALE")) + { + gdk_x11_display_set_window_scale(m_pGdkDisplay, 1); + } + } +#endif +#endif + } GtkSalDisplay::~GtkSalDisplay() diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 9e05432..0e3b0f6 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -2100,4 +2100,22 @@ cairo_t* GtkSalGraphics::getCairoContext() const return mpFrame->getCairoContext(); } +void GtkSalGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) +{ + GdkScreen* pScreen = gtk_widget_get_screen(mpWindow); + double fResolution = -1.0; + g_object_get(pScreen, "resolution", &fResolution, nullptr); + + int nScaleFactor = 1; + +#if GTK_CHECK_VERSION(3, 10, 0) + nScaleFactor = gdk_window_get_scale_factor(widget_get_window(mpWindow)); +#endif + + if (fResolution > 0.0) + rDPIX = rDPIY = sal_Int32(fResolution * nScaleFactor); + else + rDPIX = rDPIY = 96; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
