[Libreoffice-commits] core.git: 2 commits - editeng/source include/editeng sd/inc sd/source

Caolán McNamara caolanm at redhat.com
Fri Jun 13 09:06:43 PDT 2014


 editeng/source/outliner/outliner.cxx |    9 +---
 editeng/source/outliner/outlvw.cxx   |    2 
 include/editeng/outliner.hxx         |    4 -
 sd/inc/stlpool.hxx                   |    2 
 sd/inc/stlsheet.hxx                  |    8 +++
 sd/source/core/stlpool.cxx           |   57 +++++++++++++++++++-------
 sd/source/core/stlsheet.cxx          |   30 ++++++++++++-
 sd/source/ui/func/futempl.cxx        |   21 ---------
 sd/source/ui/view/drtxtob1.cxx       |   76 +++++++++++++++++++++++++++++++++--
 9 files changed, 159 insertions(+), 50 deletions(-)

New commits:
commit 8a5b3971057237b178f7e65437deec766b56f9c4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 13 11:23:07 2014 +0100

    Resolves: fdo#78151 change style on toggling bullets on master page outliners
    
    "do what I mean"
    
    In master pages prior to this if we toggle bullets on and off the that changes
    the *level* of the paragraph. And because the paragraph is effectively a
    preview of the equivalent style level, changing the level disconnects it from
    the style which is useless for us.
    
    So instead turn the numbering off at the given outline level. In order to
    toggle the numbering back split the defaults-setting into a reusable piece that
    sets the numbering indent which we can call to toggle numbering back on
    
    Also split out the broadcast style change *and explicit child* broadcast code
    into a reusable method, the absence of which left me stumped for well over an
    hour as to why my changes only worked on level 1
    
    Change-Id: I311c7f35f1ca7dff1d151c6141ff5faa7f15c5a2

diff --git a/sd/inc/stlpool.hxx b/sd/inc/stlpool.hxx
index 31cb814..7af9fe9 100644
--- a/sd/inc/stlpool.hxx
+++ b/sd/inc/stlpool.hxx
@@ -42,6 +42,7 @@ class SdStyleSheet;
 class SdDrawDocument;
 class SdPage;
 class SfxStyleSheetBase;
+class SvxNumberFormat;
 
 typedef std::map< const SdPage*, SdStyleFamilyRef > SdStyleFamilyMap;
 
@@ -92,6 +93,7 @@ public:
 
     static  SdStyleSheetVector CreateChildList( SdStyleSheet* pSheet );
 
+    static void setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat);
 
 public:
     void throwIfDisposed() throw(::com::sun::star::uno::RuntimeException);
diff --git a/sd/inc/stlsheet.hxx b/sd/inc/stlsheet.hxx
index 0811142..c36d6e0 100644
--- a/sd/inc/stlsheet.hxx
+++ b/sd/inc/stlsheet.hxx
@@ -39,6 +39,8 @@
 
 #include <boost/scoped_ptr.hpp>
 
+#include "prlayout.hxx"
+
 class ModifyListenerForewarder;
 
 typedef cppu::ImplInheritanceHelper5< SfxUnoStyleSheet,
@@ -75,6 +77,12 @@ public:
 
     static SdStyleSheet* CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily );
 
+    //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
+    //which need to be explicitly broadcast as changing if their parent style was
+    //the one that changed
+    static void BroadcastSdStyleSheetChange(SfxStyleSheetBase* pStyleSheet, PresentationObjects ePO,
+        SfxStyleSheetBasePool* pSSPool);
+
     // XInterface
     virtual void SAL_CALL release(  ) throw () SAL_OVERRIDE;
 
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 3d1ee56..b4d26217 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -1052,9 +1052,49 @@ void SdStyleSheetPool::UpdateStdNames()
     }
 }
 
-// Set new SvxNumBulletItem for the respective style sheet
+void SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat)
+{
+    rNumberFormat.SetBulletChar( 0x25CF );  // StarBats: 0xF000 + 34
+    rNumberFormat.SetBulletRelSize(45);
+    const short nLSpace = (i + 1) * 1200;
+    rNumberFormat.SetLSpace(nLSpace);
+    rNumberFormat.SetAbsLSpace(nLSpace);
+    short nFirstLineOffset = -600;
+
+    switch(i)
+    {
+        case 0:
+        {
+            nFirstLineOffset = -900;
+        }
+        break;
 
+        case 1:
+        {
+            rNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
+            rNumberFormat.SetBulletRelSize(75);
+            nFirstLineOffset = -900;
+        }
+        break;
 
+        case 2:
+        {
+            nFirstLineOffset = -800;
+        }
+        break;
+
+        case 3:
+        {
+            rNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
+            rNumberFormat.SetBulletRelSize(75);
+        }
+        break;
+    }
+
+    rNumberFormat.SetFirstLineOffset(nFirstLineOffset);
+}
+
+// Set new SvxNumBulletItem for the respective style sheet
 void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
                                          Font& rBulletFont )
 {
@@ -1134,12 +1174,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
                                  SVX_MAX_NUM, false );
             for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
             {
-                aNumberFormat.SetBulletChar( 0x25CF );  // StarBats: 0xF000 + 34
-                aNumberFormat.SetBulletRelSize(45);
-                const short nLSpace = (i + 1) * 1200;
-                aNumberFormat.SetLSpace(nLSpace);
-                aNumberFormat.SetAbsLSpace(nLSpace);
-                short nFirstLineOffset = -600;
+                setDefaultOutlineNumberFormatBulletAndIndent(i, aNumberFormat);
 
                 sal_uLong nFontSize = 20;
                 switch(i)
@@ -1147,36 +1182,28 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
                     case 0:
                     {
                         nFontSize = 32;
-                        nFirstLineOffset = -900;
                     }
                     break;
 
                     case 1:
                     {
-                        aNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
-                        aNumberFormat.SetBulletRelSize(75);
                         nFontSize = 32;
-                        nFirstLineOffset = -900;
                     }
                     break;
 
                     case 2:
                     {
                         nFontSize = 28;
-                        nFirstLineOffset = -800;
                     }
                     break;
 
                     case 3:
                     {
-                        aNumberFormat.SetBulletChar( 0x2013 );  // StarBats: 0xF000 + 150
-                        aNumberFormat.SetBulletRelSize(75);
                         nFontSize = 24;
                     }
                     break;
                 }
 
-                aNumberFormat.SetFirstLineOffset(nFirstLineOffset);
                 nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72);  // Pt --> 1/100 mm
                 rBulletFont.SetSize(Size(0,846));       // 24 pt
                 aNumberFormat.SetBulletFont(&rBulletFont);
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index eb7862f..ec7512d 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -1352,12 +1352,38 @@ Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) t
     return aRet;
 }
 
-
-
 /** this is used because our property map is not sorted yet */
 const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw (css::uno::RuntimeException)
 {
     return GetStylePropertySet().getPropertyMapEntry(rPropertyName);
 }
 
+//Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
+//which need to be explicitly broadcast as changing if their parent style was
+//the one that changed
+void SdStyleSheet::BroadcastSdStyleSheetChange(SfxStyleSheetBase* pStyleSheet,
+    PresentationObjects ePO, SfxStyleSheetBasePool* pSSPool)
+{
+    SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet();
+    pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+
+    if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) )
+    {
+        OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " ");
+
+        for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ )
+        {
+            OUString aName( sStyleName + OUString::number(n) );
+
+            SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO);
+
+            if(pSheet)
+            {
+                SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet();
+                pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+            }
+        }
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx
index c6d1b6d..0c5444c 100644
--- a/sd/source/ui/func/futempl.cxx
+++ b/sd/source/ui/func/futempl.cxx
@@ -429,27 +429,8 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                                 }
                             }
 
-                            OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " ");
-
                             pStyleSheet->GetItemSet().Put(aTempSet);
-                            SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet();
-                            pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
-
-                            if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) )
-                            {
-                                for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ )
-                                {
-                                    OUString aName( sStyleName + OUString::number(n) );
-
-                                    SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO);
-
-                                    if(pSheet)
-                                    {
-                                        SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet();
-                                        pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
-                                    }
-                                }
-                            }
+                            SdStyleSheet::BroadcastSdStyleSheetChange(pStyleSheet, ePO, pSSPool);
                         }
 
                         SfxItemSet& rAttr = pStyleSheet->GetItemSet();
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index c51ab23..51cb6e5 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -57,10 +57,14 @@
 #include <editeng/cmapitem.hxx>
 
 #include "app.hrc"
-
+#include "glob.hrc"
+#include "sdresid.hxx"
+#include "prlayout.hxx"
 #include "ViewShell.hxx"
 #include "drawview.hxx"
 #include "drawdoc.hxx"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
 #include "OutlineView.hxx"
 #include "Window.hxx"
 #include "futempl.hxx"
@@ -316,10 +320,74 @@ void TextObjectBar::Execute( SfxRequest &rReq )
         break;
 
         case FN_NUM_BULLET_ON:
-            if( pOLV )
-                pOLV->ToggleBullets();
-            break;
+        {
+            if (pOLV)
+            {
+                bool bMasterPage = false;
+                SdrPageView* pPageView = mpView->GetSdrPageView();
+                if (pPageView)
+                {
+                    SdPage* pPage = (SdPage*)pPageView->GetPage();
+                    bMasterPage = pPage && (pPage->GetPageKind() == PK_STANDARD) && pPage->IsMasterPage();
+                }
 
+                if (!bMasterPage)
+                    pOLV->ToggleBullets();
+                else
+                {
+                    //Resolves: fdo#78151 in master pages if we toggle bullets on
+                    //and off then just disable/enable the bulleting, but do not
+                    //change the *level* of the paragraph, because the paragraph is
+                    //effectively a preview of the equivalent style level, and
+                    //changing the level disconnects it from the style
+
+                    ::Outliner* pOL = pOLV->GetOutliner();
+                    if (pOL)
+                    {
+                        const SvxNumBulletItem *pItem = NULL;
+                        SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
+                        OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " 1");
+                        SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find(sStyleName, SD_STYLE_FAMILY_PSEUDO);
+                        if( pFirstStyleSheet )
+                            pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, (const SfxPoolItem**)&pItem);
+
+                        if (pItem )
+                        {
+                            SvxNumRule aNewRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
+                            ESelection aSel = pOLV->GetSelection();
+                            aSel.Adjust();
+                            sal_Int32 nStartPara = aSel.nStartPara;
+                            sal_Int32 nEndPara = aSel.nEndPara;
+                            for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
+                            {
+                                sal_uInt16 nLevel = pOL->GetDepth(nPara);
+                                SvxNumberFormat aFmt(aNewRule.GetLevel(nLevel));
+
+                                if (aFmt.GetNumberingType() == SVX_NUM_NUMBER_NONE)
+                                {
+                                    aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
+                                    SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(nLevel, aFmt);
+                                }
+                                else
+                                {
+                                    aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
+                                    aFmt.SetLSpace(0);
+                                    aFmt.SetAbsLSpace(0);
+                                    aFmt.SetFirstLineOffset(0);
+                                }
+
+                                aNewRule.SetLevel(nLevel, aFmt);
+                            }
+
+                            pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET));
+
+                            SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PO_OUTLINE_1, pSSPool);
+                        }
+                    }
+                }
+            }
+            break;
+        }
         case SID_GROW_FONT_SIZE:
         case SID_SHRINK_FONT_SIZE:
         {
commit 05f90a9afe72c0fa7bcd7dbd30c27d4c41a556c4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 13 13:55:14 2014 +0100

    Paragraph argument never used in InvalidateBullet
    
    Change-Id: I07ba855e473fb137551e70de9cfa858c5e079324

diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 08f0b79..4dcab22 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -795,7 +795,6 @@ void Outliner::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
 
 bool Outliner::Expand( Paragraph* pPara )
 {
-
     if ( pParaList->HasHiddenChildren( pPara ) )
     {
         OLUndoExpand* pUndo = 0;
@@ -811,7 +810,7 @@ bool Outliner::Expand( Paragraph* pPara )
         bIsExpanding = true;
         pParaList->Expand( pPara );
         ExpandHdl();
-        InvalidateBullet( pPara, pParaList->GetAbsPos(pPara) );
+        InvalidateBullet(pParaList->GetAbsPos(pPara));
         if( bUndo )
         {
             InsertUndo( pUndo );
@@ -822,7 +821,6 @@ bool Outliner::Expand( Paragraph* pPara )
     return false;
 }
 
-
 bool Outliner::Collapse( Paragraph* pPara )
 {
     if ( pParaList->HasVisibleChildren( pPara ) ) // expanded
@@ -844,7 +842,7 @@ bool Outliner::Collapse( Paragraph* pPara )
         bIsExpanding = false;
         pParaList->Collapse( pPara );
         ExpandHdl();
-        InvalidateBullet( pPara, pParaList->GetAbsPos(pPara) );
+        InvalidateBullet(pParaList->GetAbsPos(pPara));
         if( bUndo )
         {
             InsertUndo( pUndo );
@@ -1105,9 +1103,8 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos,
     }
 }
 
-void Outliner::InvalidateBullet( Paragraph* /*pPara*/, sal_Int32 nPara )
+void Outliner::InvalidateBullet(sal_Int32 nPara)
 {
-
     long nLineHeight = (long)pEditEngine->GetLineHeight(nPara );
     for ( size_t i = 0, n = aViewList.size(); i < n; ++i )
     {
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 8684ea6..4d0b4b8 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -529,7 +529,7 @@ void OutlinerView::Indent( short nDiff )
                         pPrev = pOwner->pParaList->GetParent( pPrev );
 
                     pOwner->Expand( pPrev );
-                    pOwner->InvalidateBullet( pPrev, pOwner->pParaList->GetAbsPos( pPrev ) );
+                    pOwner->InvalidateBullet(pOwner->pParaList->GetAbsPos(pPrev));
                 }
             }
 
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index bcf1791..d2de33e 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -650,8 +650,8 @@ protected:
 
     virtual void    StyleSheetChanged( SfxStyleSheet* pStyle );
 
-    void        InvalidateBullet( Paragraph* pPara, sal_Int32 nPara );
-    void        PaintBullet( sal_Int32 nPara, const Point& rStartPos,
+    void            InvalidateBullet(sal_Int32 nPara);
+    void            PaintBullet( sal_Int32 nPara, const Point& rStartPos,
                     const Point& rOrigin, short nOrientation,
                     OutputDevice* pOutDev );
 


More information about the Libreoffice-commits mailing list