[Libreoffice-commits] core.git: 6 commits - include/sfx2 include/svtools include/svx sfx2/source svtools/source svx/Library_svxcore.mk svx/source sw/inc sw/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon Apr 20 18:10:28 PDT 2015


 include/sfx2/StyleManager.hxx                    |   47 ++++
 include/sfx2/StylePreviewRenderer.hxx            |   53 +++++
 include/sfx2/objsh.hxx                           |   12 -
 include/svtools/viewdataentry.hxx                |    5 
 include/svx/CommonStyleManager.hxx               |   41 +++
 include/svx/CommonStylePreviewRenderer.hxx       |   45 ++++
 sfx2/source/dialog/templdlg.cxx                  |  237 +++++++++++++++++------
 sfx2/source/doc/objcont.cxx                      |    5 
 sfx2/source/inc/templdgi.hxx                     |   11 -
 sfx2/source/inc/tplcitem.hxx                     |   15 -
 svtools/source/contnr/treelistbox.cxx            |    2 
 svtools/source/contnr/viewdataentry.cxx          |   22 +-
 svx/Library_svxcore.mk                           |    2 
 svx/source/styles/CommonStyleManager.cxx         |   41 +++
 svx/source/styles/CommonStylePreviewRenderer.cxx |  209 ++++++++++++++++++++
 sw/inc/docsh.hxx                                 |    5 
 sw/source/uibase/app/docsh.cxx                   |    5 
 sw/source/uibase/app/docshini.cxx                |    5 
 18 files changed, 688 insertions(+), 74 deletions(-)

New commits:
commit f8d55544a42abd0ddc7a0d97cce2aedd0487ca88
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Apr 20 20:43:52 2015 +0900

    cleanup templdlg.cxx (Style and Formatting)
    
    Change-Id: I94758b6462c589b1f7eea9bac634e2f33646651b

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 1c31a23..819af47 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <boost/noncopyable.hpp>
-#include <boost/scoped_ptr.hpp>
 
 #include <vcl/menu.hxx>
 #include <vcl/settings.hxx>
@@ -384,9 +383,9 @@ void SfxTemplatePanelControl::FreeResource()
 
 void SfxTemplatePanelControl::StateChanged( StateChangedType nStateChange )
 {
-    if ( nStateChange == StateChangedType::INITSHOW )
+    if (nStateChange == StateChangedType::INITSHOW)
     {
-        SfxViewFrame *pFrame = mpBindings->GetDispatcher_Impl()->GetFrame();
+        SfxViewFrame* pFrame = mpBindings->GetDispatcher_Impl()->GetFrame();
         vcl::Window* pEditWin = pFrame->GetViewShell()->GetWindow();
 
         Size aSize = pEditWin->GetSizePixel();
@@ -395,7 +394,7 @@ void SfxTemplatePanelControl::StateChanged( StateChangedType nStateChange )
         Size aWinSize = GetSizePixel();
         aPoint.X() += aSize.Width() - aWinSize.Width() - 20;
         aPoint.Y() += aSize.Height() / 2 - aWinSize.Height() / 2;
-        //      SetFloatingPos( aPoint );
+        // SetFloatingPos( aPoint );
     }
 
     DockingWindow::StateChanged( nStateChange );
@@ -992,7 +991,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
                     aFmtLb.MakeVisible( pEntry );
                     aFmtLb.SelectAll(false);
                     aFmtLb.Select( pEntry );
-                    bWaterDisabled = (pTreeBox || aFmtLb.GetSelectionCount() <= 1) ? sal_False : sal_True;
+                    bWaterDisabled = (pTreeBox || aFmtLb.GetSelectionCount() <= 1) ? false : true;
                     FmtSelectHdl( NULL );
                 }
             }
@@ -1045,24 +1044,27 @@ void SfxCommonTemplateDialog_Impl::EnableTreeDrag( bool bEnable )
 void SfxCommonTemplateDialog_Impl::FillTreeBox()
 {
     OSL_ENSURE( pTreeBox, "FillTreeBox() without treebox");
-    if(pStyleSheetPool && nActFamily != 0xffff)
+    if (pStyleSheetPool && nActFamily != 0xffff)
     {
-        const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
-        if(!pItem)
+        const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+        if (!pItem)
             return;
         pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL_VISIBLE);
         StyleTreeArr_Impl aArr;
-        SfxStyleSheetBase *pStyle = pStyleSheetPool->First();
+        SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
+
         if(pStyle && pStyle->HasParentSupport() && bTreeDrag )
             pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE);
         else
             pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE);
-        while(pStyle)
+
+        while (pStyle)
         {
             StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent());
             aArr.push_back(pNew);
             pStyle = pStyleSheetPool->Next();
         }
+
         MakeTree_Impl(aArr);
         ExpandedEntries_t aEntries;
         pTreeBox->MakeExpanded_Impl(aEntries);
@@ -1076,17 +1078,17 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
         }
         pTreeBox->Recalc();
 
-        EnableItem(SID_STYLE_WATERCAN,false);
+        EnableItem(SID_STYLE_WATERCAN, false);
 
-        SfxTemplateItem* pState = pFamilyState[nActFamily-1];
+        SfxTemplateItem* pState = pFamilyState[nActFamily - 1];
 
-        if ( nCount )
-            pTreeBox->Expand( pTreeBox->First() );
+        if (nCount)
+            pTreeBox->Expand(pTreeBox->First());
 
-        for ( SvTreeListEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next( pEntry ) )
+        for (SvTreeListEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next(pEntry))
         {
-            if ( IsExpanded_Impl( aEntries, pTreeBox->GetEntryText( pEntry ) ) )
-                pTreeBox->Expand( pEntry );
+            if (IsExpanded_Impl(aEntries, pTreeBox->GetEntryText(pEntry)))
+                pTreeBox->Expand(pEntry);
         }
 
         pTreeBox->SetUpdateMode( true );
@@ -1244,7 +1246,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
             mbIgnoreSelect = true; // in case we get a selection change
             // in anycase we should stop any preview
             Execute_Impl(SID_STYLE_END_PREVIEW,
-            String(), String(),
+            OUString(), OUString(),
             0, 0, 0, 0 );
 #endif
             SelectStyle(aStyle);
@@ -1740,7 +1742,7 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
                     nFilter=pStyleSheetPool->GetSearchMask();
                 pStyleSheetPool->SetSearchMask( eFam, SFXSTYLEBIT_USERDEF );
 
-                boost::scoped_ptr<SfxNewStyleDlg> pDlg(new SfxNewStyleDlg(pWindow, *pStyleSheetPool));
+                std::unique_ptr<SfxNewStyleDlg> pDlg(new SfxNewStyleDlg(pWindow, *pStyleSheetPool));
                     // why? : FloatingWindow must not be parent of a modal dialog
                 if(RET_OK == pDlg->Execute())
                 {
@@ -2102,14 +2104,14 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox
         if ( mbIgnoreSelect )
         {
             Execute_Impl(SID_STYLE_END_PREVIEW,
-            String(), String(),
+            OUString(), OUString(),
             0, 0, 0, 0 );
             mbIgnoreSelect = false;
         }
         else
         {
             Execute_Impl(SID_STYLE_PREVIEW,
-                     GetSelectedEntry(), String(),
+                     GetSelectedEntry(), OUString(),
                      ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(),
                      0, 0, &nModifier );
         }
@@ -2180,13 +2182,12 @@ PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu()
     return pMenu;
 }
 
-SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(
-    SfxBindings* pB, SfxTemplatePanelControl* pDlgWindow )
-    : SfxCommonTemplateDialog_Impl( pB, pDlgWindow, true ),
-      m_pFloat          ( pDlgWindow ),
-      m_bZoomIn         ( false ),
-      m_aActionTbL        ( pDlgWindow, this ),
-      m_aActionTbR      ( pDlgWindow, SfxResId( TB_ACTION ) )
+SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(SfxBindings* pB, SfxTemplatePanelControl* pDlgWindow)
+    : SfxCommonTemplateDialog_Impl(pB, pDlgWindow, true)
+    , m_pFloat(pDlgWindow)
+    , m_bZoomIn(false)
+    , m_aActionTbL(pDlgWindow, this)
+    , m_aActionTbR(pDlgWindow, SfxResId(TB_ACTION))
 {
     pDlgWindow->FreeResource();
     Initialize();
@@ -2202,9 +2203,9 @@ void SfxTemplateDialog_Impl::Initialize()
     m_aActionTbL.Show();
     m_aActionTbR.Show();
     vcl::Font aFont = aFilterLb.GetFont();
-    aFont.SetWeight( WEIGHT_NORMAL );
-    aFilterLb.SetFont( aFont );
-    m_aActionTbL.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT );
+    aFont.SetWeight(WEIGHT_NORMAL);
+    aFilterLb.SetFont(aFont);
+    m_aActionTbL.SetHelpId(HID_TEMPLDLG_TOOLBOX_LEFT);
 }
 
 void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, bool bEnable )
@@ -2232,8 +2233,8 @@ void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamil
 void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
 {
     m_aActionTbR.HideItem(SID_STYLE_UPDATE_BY_EXAMPLE);
-    m_aActionTbR.SetItemBits( SID_STYLE_NEW_BY_EXAMPLE,
-            ToolBoxItemBits::DROPDOWNONLY|m_aActionTbR.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE ));
+    m_aActionTbR.SetItemBits(SID_STYLE_NEW_BY_EXAMPLE,
+            ToolBoxItemBits::DROPDOWNONLY | m_aActionTbR.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE ));
 }
 
 void SfxTemplateDialog_Impl::updateFamilyImages()
@@ -2295,10 +2296,10 @@ void SfxTemplateDialog_Impl::Resize()
 {
     SfxDockingWindow* pDockingWindow = dynamic_cast<SfxDockingWindow*>(m_pFloat);
     FloatingWindow *pF = pDockingWindow!=NULL ? pDockingWindow->GetFloatingWindow() : NULL;
-    if ( pF )
+    if (pF)
     {
         m_bZoomIn = pF->IsRollUp();
-        if ( m_bZoomIn )
+        if (m_bZoomIn)
             return;
     }
 
@@ -2545,9 +2546,9 @@ void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl()
     bTreeDrag = true;
     bUpdateByExampleDisabled = false;
 
-    if ( pStyleSheetPool )
+    if (pStyleSheetPool)
     {
-        if(!pTreeBox)
+        if (!pTreeBox)
             UpdateStyles_Impl(UPDATE_FAMILY | UPDATE_FAMILY_LIST);
         else
         {
@@ -2558,11 +2559,15 @@ void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl()
 
     InvalidateBindings();
 
-    if ( IsCheckedItem( SID_STYLE_WATERCAN ) &&
+    if (IsCheckedItem(SID_STYLE_WATERCAN) &&
          // only if that area is allowed
-         0 != pFamilyState[ nActFamily - 1 ] )
-        Execute_Impl( SID_STYLE_APPLY, GetSelectedEntry(),
-                      OUString(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
+         0 != pFamilyState[nActFamily - 1])
+    {
+        Execute_Impl(SID_STYLE_APPLY,
+                     GetSelectedEntry(),
+                     OUString(),
+                     static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
+    }
 }
 
 void SfxCommonTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
commit ca95307638207db5d662059aa61594151a13e927
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Apr 20 20:41:20 2015 +0900

    preview of styles in "Style And Formatting" dialog
    
    Change-Id: Ic10025f8b27c87ae40f62cb04653cc8e6abc7fc1

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 633af8b..1c31a23 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -62,13 +62,110 @@
 #include "appdata.hxx"
 #include <sfx2/viewfrm.hxx>
 
+#include <svtools/svlbitm.hxx>
+#include <svtools/treelistentry.hxx>
 #include <comphelper/string.hxx>
 
+#include <sfx2/StyleManager.hxx>
+#include <sfx2/StylePreviewRenderer.hxx>
+
 using namespace css;
 using namespace css::beans;
 using namespace css::frame;
 using namespace css::uno;
 
+namespace
+{
+
+class StyleLBoxString : public SvLBoxString
+{
+    SfxStyleFamily meStyleFamily;
+    std::unique_ptr<sfx2::StylePreviewRenderer> mpStylePreviewRenderer;
+
+public:
+    StyleLBoxString(SvTreeListEntry* pEntry,
+                    sal_uInt16 nFlags,
+                    const OUString& sText,
+                    const SfxStyleFamily& eStyleFamily);
+
+    virtual ~StyleLBoxString();
+
+    virtual void Paint(const Point& aPos,
+                       SvTreeListBox& rDevice,
+                       const SvViewDataEntry* pView,
+                       const SvTreeListEntry* pEntry) SAL_OVERRIDE;
+
+    virtual void InitViewData(SvTreeListBox* pView,
+                              SvTreeListEntry* pEntry,
+                              SvViewDataItem* pViewData) SAL_OVERRIDE;
+};
+
+
+StyleLBoxString::StyleLBoxString(SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& sText, const SfxStyleFamily& eStyleFamily)
+    : SvLBoxString(pEntry, nFlags, sText)
+    , meStyleFamily(eStyleFamily)
+{}
+
+StyleLBoxString::~StyleLBoxString()
+{}
+
+void StyleLBoxString::InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
+{
+    if (!pViewData)
+    {
+        pViewData = pView->GetViewDataItem(pEntry, this);
+    }
+
+    SfxObjectShell* pShell = SfxObjectShell::Current();
+    if (!pShell)
+        return;
+
+    sfx2::StyleManager* pStyleManager = pShell->GetStyleManager();
+
+    if (!pStyleManager)
+    {
+        return;
+    }
+    mpStylePreviewRenderer.reset(pStyleManager->CreateStylePreviewRenderer(*pView, GetText(), meStyleFamily));
+
+    if (!mpStylePreviewRenderer)
+    {
+        return;
+    }
+
+    if (mpStylePreviewRenderer->recalculate())
+    {
+        pViewData->maSize = mpStylePreviewRenderer->getRenderSize();
+    }
+    else
+    {
+        SvLBoxString::InitViewData(pView, pEntry, pViewData);
+    }
+}
+
+void StyleLBoxString::Paint(
+    const Point& aPos, SvTreeListBox& rDevice,
+    const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
+{
+    if (!pEntry)
+        return;
+
+    bool bResult = false;
+
+    if (mpStylePreviewRenderer)
+    {
+        Rectangle aPaintRectangle = pView->GetPaintRectangle();
+        bResult = mpStylePreviewRenderer->render(aPaintRectangle);
+    }
+
+    if (!bResult)
+    {
+        rDevice.DrawText(aPos, GetText());
+    }
+}
+
+} // end anonymous namespace
+
 // Window is now created dynamically. So here margins, etc.
 
 #define SFX_TEMPLDLG_HFRAME         3
@@ -228,6 +325,12 @@ SfxActionListBox::SfxActionListBox(SfxCommonTemplateDialog_Impl* pParent, WinBit
     EnableContextMenuHandling();
 }
 
+void SfxActionListBox::Recalc()
+{
+    SetEntryHeight(32);
+    RecalcViewData();
+}
+
 PopupMenu* SfxActionListBox::CreateContextMenu()
 {
 
@@ -412,6 +515,12 @@ StyleTreeListBox_Impl::StyleTreeListBox_Impl(SfxCommonTemplateDialog_Impl* pPare
     EnableContextMenuHandling();
 }
 
+void StyleTreeListBox_Impl::Recalc()
+{
+    SetEntryHeight(32);
+    RecalcViewData();
+}
+
 /** Internal structure for the establishment of the hierarchical view */
 class StyleTree_Impl;
 typedef std::vector<StyleTree_Impl*> StyleTreeArr_Impl;
@@ -512,15 +621,25 @@ inline bool IsExpanded_Impl( const ExpandedEntries_t& rEntries,
     return false;
 }
 
-SvTreeListEntry* FillBox_Impl(SvTreeListBox *pBox,
-                                 StyleTree_Impl* pEntry,
-                                 const ExpandedEntries_t& rEntries,
-                                 SvTreeListEntry* pParent = 0)
+SvTreeListEntry* FillBox_Impl(SvTreeListBox* pBox,
+                              StyleTree_Impl* pEntry,
+                              const ExpandedEntries_t& rEntries,
+                              SfxStyleFamily eStyleFamily,
+                              SvTreeListEntry* pParent = nullptr)
 {
-    SvTreeListEntry* pNewEntry = pBox->InsertEntry(pEntry->getName(), pParent);
+    SvTreeListEntry* pTreeListEntry = pBox->InsertEntry(pEntry->getName(), pParent);
+
+    StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, pEntry->getName(), eStyleFamily);
+
+    pTreeListEntry->ReplaceItem(pStyleLBoxString, 1);
+
+    pBox->GetModel()->InvalidateEntry(pTreeListEntry);
+
     for(sal_uInt16 i = 0; i < pEntry->Count(); ++i)
-        FillBox_Impl(pBox, (*pEntry)[i], rEntries, pNewEntry);
-    return pNewEntry;
+    {
+        FillBox_Impl(pBox, (*pEntry)[i], rEntries, eStyleFamily, pTreeListEntry);
+    }
+    return pTreeListEntry;
 }
 
 // Constructor
@@ -950,8 +1069,12 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
         pTreeBox->SetUpdateMode( false );
         pTreeBox->Clear();
         const sal_uInt16 nCount = aArr.size();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
-            FillBox_Impl(pTreeBox, aArr[i], aEntries);
+
+        for (sal_uInt16 i = 0; i < nCount; ++i)
+        {
+            FillBox_Impl(pTreeBox, aArr[i], aEntries, pItem->GetFamily());
+        }
+        pTreeBox->Recalc();
 
         EnableItem(SID_STYLE_WATERCAN,false);
 
@@ -1103,8 +1226,13 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
                 aFmtLb.Clear();
 
                 for(nPos = 0; nPos < nCount; ++nPos)
-                    aFmtLb.InsertEntry(aStrings[nPos], 0, false, nPos);
-
+                {
+                    SvTreeListEntry* pTreeListEntry = aFmtLb.InsertEntry(aStrings[nPos], 0, false, nPos);
+                    StyleLBoxString* pStyleLBoxString = new StyleLBoxString(pTreeListEntry, 0, aStrings[nPos], eFam);
+                    pTreeListEntry->ReplaceItem(pStyleLBoxString, 1);
+                    aFmtLb.GetModel()->InvalidateEntry(pTreeListEntry);
+                }
+                aFmtLb.Recalc();
                 aFmtLb.SetUpdateMode(true);
             }
             // Selects the current style if any
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 8d20103..0cf88b1 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -114,6 +114,8 @@ protected:
 public:
     StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0);
 
+    void Recalc();
+
     void SetDoubleClickHdl(const Link &rLink)
     {
         aDoubleClickLink = rLink;
@@ -145,6 +147,7 @@ public:
     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
 
     virtual PopupMenu*  CreateContextMenu() SAL_OVERRIDE;
+    void Recalc();
 };
 
 class SfxCommonTemplateDialog_Impl : public SfxListener
commit 281278541bbbcaa9be78c67ff33dc9cd19e6e457
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Apr 20 19:51:40 2015 +0900

    highlight the whole entry in "Style And Formatting" tree/list
    
    Change-Id: I2968541be05aafbd39a161b48d840f7be66deee1

diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index c11a859..8d20103 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -64,13 +64,17 @@ public:
         : SvTreeListBox(pParent, rId)
         , pDialog(pD)
         , nModifier(0)
-    {}
+    {
+        SetHighlightRange();
+    }
 
     DropListBox_Impl(vcl::Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD)
         : SvTreeListBox(pParent, nWinBits)
         , pDialog(pD)
         , nModifier(0)
-    {}
+    {
+        SetHighlightRange();
+    }
 
     virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
     virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) SAL_OVERRIDE;
commit 0dac111a3249b65eb512403897855f9d9b226f39
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Apr 20 19:45:16 2015 +0900

    store the paint rect in the SvViewDataEntry for SvTreeListBox
    
    SvViewDataEntry is provided to the item when painting. If we send
    the whole rect to the item, it can make better decisions when
    painting. Extending or changing the method contract would be too
    risky so send this information this way.
    
    Change-Id: I985680a8d053990d992d77e4310853321c0de787

diff --git a/include/svtools/viewdataentry.hxx b/include/svtools/viewdataentry.hxx
index b24910b..8d39022 100644
--- a/include/svtools/viewdataentry.hxx
+++ b/include/svtools/viewdataentry.hxx
@@ -52,6 +52,7 @@ class SVT_DLLPUBLIC SvViewDataEntry
     bool mbFocused:1;
     bool mbCursored:1;
     bool mbSelectable:1;
+    Rectangle maPaintRectangle;
 
 public:
     SvViewDataEntry();
@@ -74,6 +75,10 @@ public:
 
     const SvViewDataItem* GetItem(size_t nPos) const;
     SvViewDataItem* GetItem(size_t nPos);
+
+    void SetPaintRectangle(Rectangle aRectangle);
+    Rectangle GetPaintRectangle() const;
+
 };
 
 #endif
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index c73321a..b30be93 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -3045,6 +3045,8 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry,long nLine,sal_uInt16 nT
             // draw item
             // center vertically
             aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2;
+            pViewDataEntry->SetPaintRectangle(aRect);
+
             pItem->Paint(aEntryPos, *this, pViewDataEntry, pEntry);
 
             // division line between tabs
diff --git a/svtools/source/contnr/viewdataentry.cxx b/svtools/source/contnr/viewdataentry.cxx
index 52f98db..98c0035 100644
--- a/svtools/source/contnr/viewdataentry.cxx
+++ b/svtools/source/contnr/viewdataentry.cxx
@@ -26,7 +26,8 @@ SvViewDataEntry::SvViewDataEntry() :
     mbExpanded(false),
     mbFocused(false),
     mbCursored(false),
-    mbSelectable(true)
+    mbSelectable(true),
+    maPaintRectangle()
 {
 }
 
@@ -37,7 +38,8 @@ SvViewDataEntry::SvViewDataEntry( const SvViewDataEntry& rData ) :
     mbExpanded(rData.mbExpanded),
     mbFocused(false),
     mbCursored(rData.mbCursored),
-    mbSelectable(rData.mbSelectable)
+    mbSelectable(rData.mbSelectable),
+    maPaintRectangle(rData.maPaintRectangle)
 {
 }
 
@@ -48,12 +50,6 @@ SvViewDataEntry::~SvViewDataEntry()
 #endif
 }
 
-
-
-
-
-
-
 void SvViewDataEntry::SetFocus( bool bFocus )
 {
     mbFocused = bFocus;
@@ -95,4 +91,14 @@ SvViewDataItem* SvViewDataEntry::GetItem(size_t nPos)
     return &maItems[nPos];
 }
 
+void SvViewDataEntry::SetPaintRectangle(Rectangle aRectangle)
+{
+    maPaintRectangle = aRectangle;
+}
+
+Rectangle SvViewDataEntry::GetPaintRectangle() const
+{
+    return maPaintRectangle;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 68d06f69b56611bc6c95c1c2e8af400c7985a8fc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Apr 20 12:23:23 2015 +0900

    StyleManager & StylePreviewRenderer + common implementation
    
    StyleManager is a new class responsible to handle document styles.
    The current implementation has only the responsibility to provide
    a implementation of StylePreviewReneder, but the idea is to move
    all style related functionallity to this class (and relieve the
    SfxObjectShell a bit). CommonStyleMAnager is the common impl.
    
    StylePreviewRenderer is responsible to render a preview of a style.
    As styles can be handled differently by each component it is
    possible to provide component specific StylePreviewRendered, but
    currently only the common one is implemented and used by sw.
    
    Change-Id: Id271485f571a777a3e94f855d3c614a2efc14628

diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx
new file mode 100644
index 0000000..66159f7
--- /dev/null
+++ b/include/sfx2/StyleManager.hxx
@@ -0,0 +1,47 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SFX2_STYLEMANAGER_HXX
+#define INCLUDED_SFX2_STYLEMANAGER_HXX
+
+#include <sfx2/dllapi.h>
+
+#include <vcl/outdev.hxx>
+
+#include <sfx2/StylePreviewRenderer.hxx>
+#include <rsc/rscsfx.hxx>
+
+#include <sfx2/objsh.hxx>
+
+namespace sfx2
+{
+
+class SFX2_DLLPUBLIC StyleManager
+{
+protected:
+    SfxObjectShell& mrShell;
+
+public:
+    StyleManager(SfxObjectShell& rShell)
+        : mrShell(rShell)
+    {}
+
+    virtual ~StyleManager()
+    {}
+
+    virtual StylePreviewRenderer* CreateStylePreviewRenderer(
+                    OutputDevice& /*rOutputDev*/, OUString /*rName*/,
+                    SfxStyleFamily /*eFamily*/, long /*nMaxHeight*/ = 32) = 0;
+};
+
+} // end namespace sfx2
+
+#endif //INCLUDED_SFX2_STYLEMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/StylePreviewRenderer.hxx b/include/sfx2/StylePreviewRenderer.hxx
new file mode 100644
index 0000000..bc77e20
--- /dev/null
+++ b/include/sfx2/StylePreviewRenderer.hxx
@@ -0,0 +1,53 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SFX2_STYLEPREVIEWRENDERER_HXX
+#define INCLUDED_SFX2_STYLEPREVIEWRENDERER_HXX
+
+#include <sfx2/dllapi.h>
+#include <vcl/outdev.hxx>
+#include <rsc/rscsfx.hxx>
+#include <svl/style.hxx>
+#include <sfx2/objsh.hxx>
+
+namespace sfx2
+{
+
+class SFX2_DLLPUBLIC StylePreviewRenderer
+{
+protected:
+    const SfxObjectShell& mrShell;
+    OutputDevice& mrOutputDev;
+    SfxStyleSheetBase* mpStyle;
+    long mnMaxHeight;
+
+public:
+    StylePreviewRenderer(const SfxObjectShell& rShell,
+                         OutputDevice& rOutputDev,
+                         SfxStyleSheetBase* pStyle,
+                         long nMaxHeight = 32)
+        : mrShell(rShell)
+        , mrOutputDev(rOutputDev)
+        , mpStyle(pStyle)
+        , mnMaxHeight(nMaxHeight)
+    {}
+
+    virtual ~StylePreviewRenderer()
+    {}
+
+    virtual bool recalculate() = 0;
+    virtual Size getRenderSize() = 0;
+    virtual bool render(const Rectangle& aRectangle) = 0;
+};
+
+} // end namespace sfx2
+
+#endif // INCLUDED_SVX_STYLEPREVIEWRENDERER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 152e864..041631e 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -97,6 +97,7 @@ enum class SfxModelFlags;
 namespace sfx2
 {
     class SvLinkSource;
+    class StyleManager;
 }
 
 namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
@@ -494,8 +495,14 @@ public:
 
     // Contents
     virtual SfxStyleSheetBasePool*  GetStyleSheetPool();
-    void                     SetStyleSheetPool(SfxStyleSheetBasePool *pBasePool ) {
-                                        pStyleSheetPool = pBasePool; }
+    void                     SetStyleSheetPool(SfxStyleSheetBasePool *pBasePool )
+    {
+        pStyleSheetPool = pBasePool;
+    }
+
+    virtual void                LoadStyles(SfxObjectShell &rSource);
+
+    virtual sfx2::StyleManager* GetStyleManager();
 
     // Determine the position of the "Automatic" filter in the stylist
     void                        SetAutoStyleFilterIndex(sal_uInt16 nSet);
@@ -510,7 +517,6 @@ public:
 
     virtual std::set<Color>     GetDocColors();
 
-    virtual void                LoadStyles( SfxObjectShell &rSource );
     void                        ReadNote( INote * );
     void                        UpdateNote( INote * );
 
diff --git a/include/svx/CommonStyleManager.hxx b/include/svx/CommonStyleManager.hxx
new file mode 100644
index 0000000..43346aa
--- /dev/null
+++ b/include/svx/CommonStyleManager.hxx
@@ -0,0 +1,41 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SVX_COMMONSTYLEMANAGER_HXX
+#define INCLUDED_SVX_COMMONSTYLEMANAGER_HXX
+
+#include <sfx2/StyleManager.hxx>
+
+#include <vcl/outdev.hxx>
+#include <svx/svxdllapi.h>
+#include <rsc/rscsfx.hxx>
+
+namespace svx
+{
+
+class SVX_DLLPUBLIC CommonStyleManager : public sfx2::StyleManager
+{
+public:
+    CommonStyleManager(SfxObjectShell& rShell)
+        : StyleManager(rShell)
+    {}
+
+    virtual ~CommonStyleManager()
+    {}
+
+    virtual sfx2::StylePreviewRenderer* CreateStylePreviewRenderer(
+                                            OutputDevice& rOutputDev, OUString sName,
+                                            SfxStyleFamily eFamily, long nMaxHeight = 32) SAL_OVERRIDE;
+};
+
+} // end namespace svx
+
+#endif // INCLUDED_SVX_COMMONSTYLEMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/CommonStylePreviewRenderer.hxx b/include/svx/CommonStylePreviewRenderer.hxx
new file mode 100644
index 0000000..1e7d54e
--- /dev/null
+++ b/include/svx/CommonStylePreviewRenderer.hxx
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SVX_COMMONSTYLEPREVIEWRENDERER_HXX
+#define INCLUDED_SVX_COMMONSTYLEPREVIEWRENDERER_HXX
+
+#include <vcl/outdev.hxx>
+#include <rsc/rscsfx.hxx>
+#include <editeng/svxfont.hxx>
+#include <svx/svxdllapi.h>
+
+#include <sfx2/StylePreviewRenderer.hxx>
+
+namespace svx
+{
+
+class SVX_DLLPUBLIC CommonStylePreviewRenderer : public sfx2::StylePreviewRenderer
+{
+    SvxFont maFont;
+    Color maFontColor;
+    Color maBackgroundColor;
+    Size maPixelSize;
+    OUString maStyleName;
+
+public:
+    CommonStylePreviewRenderer(const SfxObjectShell& rShell, OutputDevice& rOutputDev,
+                               SfxStyleSheetBase* pStyle, long nMaxHeight = 32);
+    virtual ~CommonStylePreviewRenderer();
+
+    virtual bool recalculate() SAL_OVERRIDE;
+    virtual Size getRenderSize() SAL_OVERRIDE;
+    virtual bool render(const Rectangle& aRectangle) SAL_OVERRIDE;
+};
+
+} // end namespace svx
+
+#endif // INCLUDED_SVX_COMMONSTYLEPREVIEWRENDERER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index f48433a..d2b4d3c 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -365,7 +365,10 @@ void SfxObjectShell::LoadStyles
     }
 }
 
-
+sfx2::StyleManager* SfxObjectShell::GetStyleManager()
+{
+    return nullptr;
+}
 
 void SfxObjectShell::UpdateFromTemplate_Impl(  )
 
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index ce93cc8..c73b42f 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -338,6 +338,8 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/svdraw/svdview \
     svx/source/svdraw/svdviter \
     svx/source/svdraw/svdxcgv \
+    svx/source/styles/CommonStylePreviewRenderer \
+    svx/source/styles/CommonStyleManager \
     svx/source/table/cell \
     svx/source/table/cellcursor \
     svx/source/table/cellrange \
diff --git a/svx/source/styles/CommonStyleManager.cxx b/svx/source/styles/CommonStyleManager.cxx
new file mode 100644
index 0000000..4b3b6d1
--- /dev/null
+++ b/svx/source/styles/CommonStyleManager.cxx
@@ -0,0 +1,41 @@
+/* -*- 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 <svx/CommonStyleManager.hxx>
+#include <svx/CommonStylePreviewRenderer.hxx>
+
+namespace svx
+{
+
+sfx2::StylePreviewRenderer* CommonStyleManager::CreateStylePreviewRenderer(
+                                            OutputDevice& rOutputDev, OUString sName,
+                                            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 (sName == pStyle->GetName())
+            return new CommonStylePreviewRenderer(mrShell, rOutputDev, pStyle, nMaxHeight);
+        pStyle = pPool->Next();
+    }
+
+    return nullptr;
+}
+
+} // end svx namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
new file mode 100644
index 0000000..9ef4ffd
--- /dev/null
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -0,0 +1,209 @@
+/* -*- 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 <svx/CommonStylePreviewRenderer.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <svl/style.hxx>
+#include <svl/itemset.hxx>
+
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <svx/xdef.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xcolit.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/contouritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/crossedoutitem.hxx>
+#include <editeng/emphasismarkitem.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/lineitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/svxfont.hxx>
+#include <editeng/cmapitem.hxx>
+
+#include <editeng/editids.hrc>
+
+using namespace css;
+
+namespace svx
+{
+
+CommonStylePreviewRenderer::CommonStylePreviewRenderer(
+                                const SfxObjectShell& rShell, OutputDevice& rOutputDev,
+                                SfxStyleSheetBase* pStyle, long nMaxHeight)
+    : StylePreviewRenderer(rShell, rOutputDev, pStyle, nMaxHeight)
+    , maFont()
+    , maFontColor(COL_AUTO)
+    , maBackgroundColor(COL_AUTO)
+    , maPixelSize()
+    , maStyleName(mpStyle->GetName())
+{
+}
+
+CommonStylePreviewRenderer::~CommonStylePreviewRenderer()
+{}
+
+bool CommonStylePreviewRenderer::recalculate()
+{
+    const SfxItemSet& aItemSet = mpStyle->GetItemSet();
+
+    maFont = SvxFont();
+
+    const SfxPoolItem* pItem;
+
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
+    {
+        maFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
+    {
+        maFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
+    {
+        maFont.SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
+    {
+        maFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
+    {
+        maFont.SetRelief(static_cast<FontRelief>(static_cast<const SvxCharReliefItem*>(pItem)->GetValue()));
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
+    {
+        maFont.SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
+    {
+        maFont.SetOverline(static_cast<FontUnderline>(static_cast<const SvxOverlineItem*>(pItem)->GetValue()));
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
+    {
+        maFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
+    {
+        maFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
+    {
+        maFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
+    }
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
+    {
+        maFontColor = Color(static_cast<const SvxColorItem*>(pItem)->GetValue());
+    }
+
+    if (mpStyle->GetFamily() == SFX_STYLE_FAMILY_PARA)
+    {
+        if ((pItem = aItemSet.GetItem(XATTR_FILLSTYLE)) != nullptr)
+        {
+            sal_uInt16 aFillStyle = static_cast<const XFillStyleItem*>(pItem)->GetValue();
+            if (aFillStyle == drawing::FillStyle_SOLID)
+            {
+                if ((pItem = aItemSet.GetItem(XATTR_FILLCOLOR)) != nullptr)
+                {
+                    maBackgroundColor = Color(static_cast<const XFillColorItem*>(pItem)->GetColorValue());
+                }
+            }
+        }
+    }
+
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
+    {
+        const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
+        maFont.SetName(pFontItem->GetFamilyName());
+        maFont.SetStyleName(pFontItem->GetStyleName());
+    }
+    else
+    {
+        return false;
+    }
+
+    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT)) != nullptr)
+    {
+        const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
+        Size aFontSize(0, pFontHeightItem->GetHeight());
+        maPixelSize = Size(mrOutputDev.LogicToPixel(aFontSize, mrShell.GetMapUnit()));
+        maFont.SetSize(maPixelSize);
+
+        vcl::Font aOldFont(mrOutputDev.GetFont());
+
+        mrOutputDev.SetFont(maFont);
+        Rectangle aTextRect;
+        mrOutputDev.GetTextBoundRect(aTextRect, mpStyle->GetName());
+        if (aTextRect.Bottom() > mnMaxHeight)
+        {
+            double ratio = double(mnMaxHeight) / aTextRect.Bottom();
+            maPixelSize.Width() *= ratio;
+            maPixelSize.Height() *= ratio;
+            maFont.SetSize(maPixelSize);
+        }
+        mrOutputDev.SetFont(aOldFont);
+    }
+    else
+    {
+        return false;
+    }
+
+    return true;
+}
+
+Size CommonStylePreviewRenderer::getRenderSize()
+{
+    maPixelSize = maFont.GetTxtSize(&mrOutputDev, maStyleName);
+    if (maPixelSize.Height() > mnMaxHeight)
+        maPixelSize.Height() = mnMaxHeight;
+    return maPixelSize;
+}
+
+bool CommonStylePreviewRenderer::render(const Rectangle& aRectangle)
+{
+    // setup the device & draw
+    vcl::Font aOldFont(mrOutputDev.GetFont());
+    Color aOldColor(mrOutputDev.GetTextColor());
+    Color aOldFillColor(mrOutputDev.GetFillColor());
+
+    if (maBackgroundColor != COL_AUTO)
+    {
+        mrOutputDev.SetFillColor(maBackgroundColor);
+        mrOutputDev.DrawRect(aRectangle);
+    }
+
+    mrOutputDev.SetFont(maFont);
+    if (maFontColor != COL_AUTO)
+        mrOutputDev.SetTextColor(maFontColor);
+
+    Point aFontDrawPosition = aRectangle.TopLeft();
+    if (aRectangle.GetHeight() > maPixelSize.Height())
+        aFontDrawPosition.Y() += ( aRectangle.GetHeight() - maPixelSize.Height() ) / 2;
+
+    mrOutputDev.DrawText(aFontDrawPosition, maStyleName);
+
+    mrOutputDev.SetFillColor(aOldFillColor);
+    mrOutputDev.SetTextColor(aOldColor);
+    mrOutputDev.SetFont(aOldFont);
+
+    return true;
+}
+
+} // end svx namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 704d066..50bfdf3 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -32,6 +32,8 @@
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
+#include <sfx2/StyleManager.hxx>
+
 class SwDoc;
 class SfxDocumentInfoDialog;
 class SfxStyleSheetBasePool;
@@ -67,6 +69,8 @@ class SW_DLLPUBLIC SwDocShell
     FontList*   m_pFontList;          ///< Current Fontlist.
     bool        m_IsInUpdateFontList; ///< prevent nested calls of UpdateFontList
 
+    std::unique_ptr<sfx2::StyleManager> m_pStyleManager;
+
     /** For "historical reasons" nothing can be done without the WrtShell.
      Back-pointer on View (again "for historical reasons").
      Back-pointer is valid until in Activate a new one is set
@@ -212,6 +216,7 @@ public:
 
     /// For Style PI.
     virtual SfxStyleSheetBasePool*  GetStyleSheetPool() SAL_OVERRIDE;
+    virtual sfx2::StyleManager* GetStyleManager() SAL_OVERRIDE;
 
     /// Set View for actions via Shell.
     void          SetView(SwView* pVw);
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index c364136..495412f 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1064,6 +1064,11 @@ SfxStyleSheetBasePool*  SwDocShell::GetStyleSheetPool()
     return m_xBasePool.get();
 }
 
+sfx2::StyleManager* SwDocShell::GetStyleManager()
+{
+    return m_pStyleManager.get();
+}
+
 void SwDocShell::SetView(SwView* pVw)
 {
     SetViewShell_Impl(pVw);
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
index 8a752ca..7537d0e 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -86,6 +86,8 @@
 #include <globals.hrc>
 #include <unochart.hxx>
 
+#include <svx/CommonStyleManager.hxx>
+
 // text grid
 #include <tgrditem.hxx>
 #include <boost/scoped_ptr.hpp>
@@ -326,6 +328,7 @@ SwDocShell::SwDocShell( SfxObjectCreateMode const eMode )
     , m_pDoc(nullptr)
     , m_pFontList(nullptr)
     , m_IsInUpdateFontList(false)
+    , m_pStyleManager(new svx::CommonStyleManager(*this))
     , m_pView(nullptr)
     , m_pWrtShell(nullptr)
     , m_pOLEChildList(nullptr)
@@ -342,6 +345,7 @@ SwDocShell::SwDocShell( const SfxModelFlags i_nSfxCreationFlags )
     , m_pDoc(nullptr)
     , m_pFontList(nullptr)
     , m_IsInUpdateFontList(false)
+    , m_pStyleManager(new svx::CommonStyleManager(*this))
     , m_pView(nullptr)
     , m_pWrtShell(nullptr)
     , m_pOLEChildList(nullptr)
@@ -358,6 +362,7 @@ SwDocShell::SwDocShell( SwDoc *const pD, SfxObjectCreateMode const eMode )
     , m_pDoc(pD)
     , m_pFontList(nullptr)
     , m_IsInUpdateFontList(false)
+    , m_pStyleManager(new svx::CommonStyleManager(*this))
     , m_pView(nullptr)
     , m_pWrtShell(nullptr)
     , m_pOLEChildList(nullptr)
commit a630f4f2e18bed78c1c1e4ef793b4636ce5ebcfc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sun Apr 19 10:07:42 2015 +0900

    cleanup SfxTemplateControllerItem
    
    Change-Id: Ia29d45ed1fe41c986bf7d15d4da4557011544daa

diff --git a/sfx2/source/inc/tplcitem.hxx b/sfx2/source/inc/tplcitem.hxx
index 1b17a3e..b6a4d8d 100644
--- a/sfx2/source/inc/tplcitem.hxx
+++ b/sfx2/source/inc/tplcitem.hxx
@@ -24,23 +24,22 @@
 
 class SfxCommonTemplateDialog_Impl;
 
-class SfxTemplateControllerItem: public SfxControllerItem {
-    SfxCommonTemplateDialog_Impl  &rTemplateDlg;
-    sal_uInt8                            nWaterCanState;
-    ImplSVEvent *                        nUserEventId;
+class SfxTemplateControllerItem : public SfxControllerItem {
+    SfxCommonTemplateDialog_Impl &rTemplateDlg;
+    sal_uInt8 nWaterCanState;
+    ImplSVEvent* nUserEventId;
 
     DECL_STATIC_LINK(SfxTemplateControllerItem, SetWaterCanStateHdl_Impl,
-                                SfxTemplateControllerItem*);
+                     SfxTemplateControllerItem*);
 
 protected:
-    virtual void    StateChanged( sal_uInt16, SfxItemState, const SfxPoolItem* pState ) SAL_OVERRIDE;
+    virtual void StateChanged(sal_uInt16, SfxItemState, const SfxPoolItem* pState) SAL_OVERRIDE;
 
 public:
-    SfxTemplateControllerItem( sal_uInt16 nId, SfxCommonTemplateDialog_Impl &rDlg, SfxBindings &);
+    SfxTemplateControllerItem(sal_uInt16 nId, SfxCommonTemplateDialog_Impl& rDialog, SfxBindings& rBindings);
     virtual ~SfxTemplateControllerItem();
 };
 
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list