LCOV - code coverage report
Current view: top level - sw/source/uibase/sidebar - StylePresetsPanel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 46 2.2 %
Date: 2015-06-13 12:38:46 Functions: 2 10 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  */
      10             : 
      11             : #include <sal/config.h>
      12             : 
      13             : #include "StylePresetsPanel.hxx"
      14             : 
      15             : #include <swtypes.hxx>
      16             : #include <cmdid.h>
      17             : 
      18             : #include <svl/intitem.hxx>
      19             : #include <svx/svxids.hrc>
      20             : #include <svx/dlgutil.hxx>
      21             : #include <svx/rulritem.hxx>
      22             : 
      23             : #include <sfx2/sidebar/ControlFactory.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : #include <sfx2/bindings.hxx>
      26             : #include <sfx2/viewsh.hxx>
      27             : #include <sfx2/objsh.hxx>
      28             : 
      29             : #include <com/sun/star/frame/XController.hpp>
      30             : #include <com/sun/star/frame/XModel.hpp>
      31             : #include <com/sun/star/frame/DocumentTemplates.hpp>
      32             : #include <com/sun/star/frame/XDocumentTemplates.hpp>
      33             : #include <com/sun/star/document/XUndoManagerSupplier.hpp>
      34             : 
      35             : #include <sfx2/doctempl.hxx>
      36             : 
      37             : #include "shellio.hxx"
      38             : #include "docsh.hxx"
      39             : 
      40             : #include <comphelper/processfactory.hxx>
      41             : #include <comphelper/documentconstants.hxx>
      42             : #include <comphelper/string.hxx>
      43             : 
      44             : namespace sw { namespace sidebar {
      45             : 
      46           0 : VclPtr<vcl::Window> StylePresetsPanel::Create (vcl::Window* pParent,
      47             :                                         const css::uno::Reference<css::frame::XFrame>& rxFrame,
      48             :                                         SfxBindings* pBindings)
      49             : {
      50           0 :     if (pParent == NULL)
      51           0 :         throw css::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", NULL, 0);
      52           0 :     if (!rxFrame.is())
      53           0 :         throw css::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", NULL, 1);
      54           0 :     if (pBindings == NULL)
      55           0 :         throw css::lang::IllegalArgumentException("no SfxBindings given to PagePropertyPanel::Create", NULL, 2);
      56             : 
      57           0 :     return VclPtr<StylePresetsPanel>::Create(pParent, rxFrame, pBindings);
      58             : }
      59             : 
      60           0 : StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent,
      61             :                                const css::uno::Reference<css::frame::XFrame>& rxFrame,
      62             :                                SfxBindings* pBindings)
      63             :     : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui", rxFrame)
      64           0 :     , mpBindings(pBindings)
      65             : {
      66             : 
      67           0 :     get(mpListBox, "listbox");
      68             : 
      69           0 :     mpListBox->SetDoubleClickHdl(LINK(this, StylePresetsPanel, DoubleClickHdl));
      70             : 
      71             : 
      72           0 :     SfxDocumentTemplates aTemplates;
      73             : 
      74           0 :     sal_uInt16 nCount = aTemplates.GetRegionCount();
      75           0 :     for (sal_uInt16 i = 0; i < nCount; ++i)
      76             :     {
      77           0 :         OUString aRegionName(aTemplates.GetFullRegionName(i));
      78           0 :         if (aRegionName == "styles")
      79             :         {
      80           0 :             for (sal_uInt16 j = 0; j < aTemplates.GetCount(i); ++j)
      81             :             {
      82           0 :                 OUString aName = aTemplates.GetName(i,j);
      83           0 :                 OUString aURL = aTemplates.GetPath(i,j);
      84           0 :                 sal_Int32 nIndex = mpListBox->InsertEntry(aName);
      85           0 :                 maTemplateEntries.push_back(std::unique_ptr<TemplateEntry>(new TemplateEntry(aName, aURL)));
      86           0 :                 mpListBox->SetEntryData(nIndex, maTemplateEntries.back().get());
      87           0 :             }
      88             :         }
      89           0 :     }
      90           0 : }
      91             : 
      92           0 : StylePresetsPanel::~StylePresetsPanel()
      93             : {
      94           0 :     disposeOnce();
      95           0 : }
      96             : 
      97           0 : void StylePresetsPanel::dispose()
      98             : {
      99           0 :     mpListBox.disposeAndClear();
     100             : 
     101           0 :     PanelLayout::dispose();
     102           0 : }
     103             : 
     104           0 : IMPL_LINK_NOARG(StylePresetsPanel, DoubleClickHdl)
     105             : {
     106           0 :     sal_Int32 nIndex = mpListBox->GetSelectEntryPos();
     107           0 :     TemplateEntry* pEntry = static_cast<TemplateEntry*>(mpListBox->GetEntryData(nIndex));
     108             : 
     109           0 :     SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
     110           0 :     if (pDocSh)
     111             :     {
     112           0 :         SwgReaderOption aOption;
     113           0 :         aOption.SetTextFormats(true);
     114           0 :         aOption.SetNumRules(true);
     115           0 :         pDocSh->LoadStylesFromFile(pEntry->maURL, aOption, false);
     116             :     }
     117             : 
     118           0 :     return 1;
     119             : }
     120             : 
     121           0 : void StylePresetsPanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/,
     122             :                                          const SfxItemState /*eState*/,
     123             :                                          const SfxPoolItem* /*pState*/,
     124             :                                          const bool /*bIsEnabled*/)
     125             : {
     126           0 : }
     127             : 
     128         177 : }} // end of namespace ::sw::sidebar
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11