summaryrefslogtreecommitdiff
path: root/sw/source/uibase/sidebar/StylePresetsPanel.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-08-27 10:08:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-08-27 10:08:26 +0200
commit79d1033f95fda0e7985f4c658811751b30aae21e (patch)
tree558bb71c9b263855a00bca27de6b6cdb81d7d5dd /sw/source/uibase/sidebar/StylePresetsPanel.cxx
parenta3e3fac0ec0339015374adc1531fab8964b2d837 (diff)
loplugin:staticmethods
Change-Id: I8ccaf0e8eea9c47257561e66114972bebf16e3af
Diffstat (limited to 'sw/source/uibase/sidebar/StylePresetsPanel.cxx')
-rw-r--r--sw/source/uibase/sidebar/StylePresetsPanel.cxx132
1 files changed, 68 insertions, 64 deletions
diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.cxx b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
index 192b9f4aa1a2..51137958338b 100644
--- a/sw/source/uibase/sidebar/StylePresetsPanel.cxx
+++ b/sw/source/uibase/sidebar/StylePresetsPanel.cxx
@@ -43,69 +43,7 @@
namespace sw { namespace sidebar {
-VclPtr<vcl::Window> StylePresetsPanel::Create (vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame,
- SfxBindings* pBindings)
-{
- if (pParent == NULL)
- throw css::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", NULL, 0);
- if (!rxFrame.is())
- throw css::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", NULL, 1);
- if (pBindings == NULL)
- throw css::lang::IllegalArgumentException("no SfxBindings given to PagePropertyPanel::Create", NULL, 2);
-
- return VclPtr<StylePresetsPanel>::Create(pParent, rxFrame, pBindings);
-}
-
-StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame,
- SfxBindings* pBindings)
- : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui", rxFrame)
- , mpBindings(pBindings)
-{
- get(mpValueSet, "valueset");
-
- mpValueSet->SetColCount(2);
-
- mpValueSet->SetDoubleClickHdl(LINK(this, StylePresetsPanel, DoubleClickHdl));
-
- RefreshList();
-}
-
-void StylePresetsPanel::RefreshList()
-{
- SfxDocumentTemplates aTemplates;
- sal_uInt16 nCount = aTemplates.GetRegionCount();
- for (sal_uInt16 i = 0; i < nCount; ++i)
- {
- OUString aRegionName(aTemplates.GetFullRegionName(i));
- if (aRegionName == "styles")
- {
- for (sal_uInt16 j = 0; j < aTemplates.GetCount(i); ++j)
- {
- OUString aName = aTemplates.GetName(i,j);
- OUString aURL = aTemplates.GetPath(i,j);
- BitmapEx aPreview = CreatePreview(aURL, aName);
- mpValueSet->InsertItem(j, Image(aPreview), aName);
- maTemplateEntries.push_back(std::unique_ptr<TemplateEntry>(new TemplateEntry(aName, aURL)));
- mpValueSet->SetItemData(j, maTemplateEntries.back().get());
- }
- }
- }
-}
-
-BitmapEx StylePresetsPanel::CreatePreview(OUString& aUrl, OUString& aName)
-{
- SfxMedium aMedium(aUrl, STREAM_STD_READWRITE);
- SfxObjectShell* pObjectShell = SfxObjectShell::Current();
- SfxObjectShellLock xTemplDoc = SfxObjectShell::CreateObjectByFactoryName(pObjectShell->GetFactory().GetFactoryName(), SfxObjectCreateMode::ORGANIZER);
- xTemplDoc->DoInitNew(0);
- if (xTemplDoc->LoadFrom(aMedium))
- {
- return GenerateStylePreview(*xTemplDoc, aName);
- }
- return BitmapEx();
-}
+namespace {
void renderPreview(sfx2::StyleManager* pStyleManager, OutputDevice& aOutputDevice,
OUString const & sName, sal_Int32 nHeight, Rectangle& aRect)
@@ -122,7 +60,7 @@ void renderPreview(sfx2::StyleManager* pStyleManager, OutputDevice& aOutputDevic
}
}
-BitmapEx StylePresetsPanel::GenerateStylePreview(SfxObjectShell& rSource, OUString& aName)
+BitmapEx GenerateStylePreview(SfxObjectShell& rSource, OUString& aName)
{
sfx2::StyleManager* pStyleManager = rSource.GetStyleManager();
@@ -191,6 +129,72 @@ BitmapEx StylePresetsPanel::GenerateStylePreview(SfxObjectShell& rSource, OUStri
return pVirtualDev->GetBitmapEx(Point(), aSize);
}
+BitmapEx CreatePreview(OUString& aUrl, OUString& aName)
+{
+ SfxMedium aMedium(aUrl, STREAM_STD_READWRITE);
+ SfxObjectShell* pObjectShell = SfxObjectShell::Current();
+ SfxObjectShellLock xTemplDoc = SfxObjectShell::CreateObjectByFactoryName(pObjectShell->GetFactory().GetFactoryName(), SfxObjectCreateMode::ORGANIZER);
+ xTemplDoc->DoInitNew(0);
+ if (xTemplDoc->LoadFrom(aMedium))
+ {
+ return GenerateStylePreview(*xTemplDoc, aName);
+ }
+ return BitmapEx();
+}
+
+}
+
+VclPtr<vcl::Window> StylePresetsPanel::Create (vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+{
+ if (pParent == NULL)
+ throw css::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", NULL, 0);
+ if (!rxFrame.is())
+ throw css::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", NULL, 1);
+ if (pBindings == NULL)
+ throw css::lang::IllegalArgumentException("no SfxBindings given to PagePropertyPanel::Create", NULL, 2);
+
+ return VclPtr<StylePresetsPanel>::Create(pParent, rxFrame, pBindings);
+}
+
+StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ SfxBindings* pBindings)
+ : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui", rxFrame)
+ , mpBindings(pBindings)
+{
+ get(mpValueSet, "valueset");
+
+ mpValueSet->SetColCount(2);
+
+ mpValueSet->SetDoubleClickHdl(LINK(this, StylePresetsPanel, DoubleClickHdl));
+
+ RefreshList();
+}
+
+void StylePresetsPanel::RefreshList()
+{
+ SfxDocumentTemplates aTemplates;
+ sal_uInt16 nCount = aTemplates.GetRegionCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ OUString aRegionName(aTemplates.GetFullRegionName(i));
+ if (aRegionName == "styles")
+ {
+ for (sal_uInt16 j = 0; j < aTemplates.GetCount(i); ++j)
+ {
+ OUString aName = aTemplates.GetName(i,j);
+ OUString aURL = aTemplates.GetPath(i,j);
+ BitmapEx aPreview = CreatePreview(aURL, aName);
+ mpValueSet->InsertItem(j, Image(aPreview), aName);
+ maTemplateEntries.push_back(std::unique_ptr<TemplateEntry>(new TemplateEntry(aName, aURL)));
+ mpValueSet->SetItemData(j, maTemplateEntries.back().get());
+ }
+ }
+ }
+}
+
StylePresetsPanel::~StylePresetsPanel()
{
disposeOnce();