Kaydet (Commit) 8a5b3971 authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst 05f90a9a
...@@ -42,6 +42,7 @@ class SdStyleSheet; ...@@ -42,6 +42,7 @@ class SdStyleSheet;
class SdDrawDocument; class SdDrawDocument;
class SdPage; class SdPage;
class SfxStyleSheetBase; class SfxStyleSheetBase;
class SvxNumberFormat;
typedef std::map< const SdPage*, SdStyleFamilyRef > SdStyleFamilyMap; typedef std::map< const SdPage*, SdStyleFamilyRef > SdStyleFamilyMap;
...@@ -92,6 +93,7 @@ public: ...@@ -92,6 +93,7 @@ public:
static SdStyleSheetVector CreateChildList( SdStyleSheet* pSheet ); static SdStyleSheetVector CreateChildList( SdStyleSheet* pSheet );
static void setDefaultOutlineNumberFormatBulletAndIndent(sal_uInt16 i, SvxNumberFormat &rNumberFormat);
public: public:
void throwIfDisposed() throw(::com::sun::star::uno::RuntimeException); void throwIfDisposed() throw(::com::sun::star::uno::RuntimeException);
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include "prlayout.hxx"
class ModifyListenerForewarder; class ModifyListenerForewarder;
typedef cppu::ImplInheritanceHelper5< SfxUnoStyleSheet, typedef cppu::ImplInheritanceHelper5< SfxUnoStyleSheet,
...@@ -75,6 +77,12 @@ public: ...@@ -75,6 +77,12 @@ public:
static SdStyleSheet* CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily ); 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 // XInterface
virtual void SAL_CALL release( ) throw () SAL_OVERRIDE; virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
......
...@@ -1052,9 +1052,49 @@ void SdStyleSheetPool::UpdateStdNames() ...@@ -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, void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
Font& rBulletFont ) Font& rBulletFont )
{ {
...@@ -1134,12 +1174,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, ...@@ -1134,12 +1174,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
SVX_MAX_NUM, false ); SVX_MAX_NUM, false );
for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ ) for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
{ {
aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34 setDefaultOutlineNumberFormatBulletAndIndent(i, aNumberFormat);
aNumberFormat.SetBulletRelSize(45);
const short nLSpace = (i + 1) * 1200;
aNumberFormat.SetLSpace(nLSpace);
aNumberFormat.SetAbsLSpace(nLSpace);
short nFirstLineOffset = -600;
sal_uLong nFontSize = 20; sal_uLong nFontSize = 20;
switch(i) switch(i)
...@@ -1147,36 +1182,28 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, ...@@ -1147,36 +1182,28 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet,
case 0: case 0:
{ {
nFontSize = 32; nFontSize = 32;
nFirstLineOffset = -900;
} }
break; break;
case 1: case 1:
{ {
aNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
aNumberFormat.SetBulletRelSize(75);
nFontSize = 32; nFontSize = 32;
nFirstLineOffset = -900;
} }
break; break;
case 2: case 2:
{ {
nFontSize = 28; nFontSize = 28;
nFirstLineOffset = -800;
} }
break; break;
case 3: case 3:
{ {
aNumberFormat.SetBulletChar( 0x2013 ); // StarBats: 0xF000 + 150
aNumberFormat.SetBulletRelSize(75);
nFontSize = 24; nFontSize = 24;
} }
break; break;
} }
aNumberFormat.SetFirstLineOffset(nFirstLineOffset);
nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm nFontSize = (sal_uInt16)((nFontSize * 2540L) / 72); // Pt --> 1/100 mm
rBulletFont.SetSize(Size(0,846)); // 24 pt rBulletFont.SetSize(Size(0,846)); // 24 pt
aNumberFormat.SetBulletFont(&rBulletFont); aNumberFormat.SetBulletFont(&rBulletFont);
......
...@@ -1352,12 +1352,38 @@ Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) t ...@@ -1352,12 +1352,38 @@ Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) t
return aRet; return aRet;
} }
/** this is used because our property map is not sorted yet */ /** this is used because our property map is not sorted yet */
const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw (css::uno::RuntimeException) const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw (css::uno::RuntimeException)
{ {
return GetStylePropertySet().getPropertyMapEntry(rPropertyName); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -429,27 +429,8 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) ...@@ -429,27 +429,8 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
} }
} }
OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " ");
pStyleSheet->GetItemSet().Put(aTempSet); pStyleSheet->GetItemSet().Put(aTempSet);
SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet(); SdStyleSheet::BroadcastSdStyleSheetChange(pStyleSheet, ePO, pSSPool);
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));
}
}
}
} }
SfxItemSet& rAttr = pStyleSheet->GetItemSet(); SfxItemSet& rAttr = pStyleSheet->GetItemSet();
......
...@@ -57,10 +57,14 @@ ...@@ -57,10 +57,14 @@
#include <editeng/cmapitem.hxx> #include <editeng/cmapitem.hxx>
#include "app.hrc" #include "app.hrc"
#include "glob.hrc"
#include "sdresid.hxx"
#include "prlayout.hxx"
#include "ViewShell.hxx" #include "ViewShell.hxx"
#include "drawview.hxx" #include "drawview.hxx"
#include "drawdoc.hxx" #include "drawdoc.hxx"
#include "stlpool.hxx"
#include "stlsheet.hxx"
#include "OutlineView.hxx" #include "OutlineView.hxx"
#include "Window.hxx" #include "Window.hxx"
#include "futempl.hxx" #include "futempl.hxx"
...@@ -316,10 +320,74 @@ void TextObjectBar::Execute( SfxRequest &rReq ) ...@@ -316,10 +320,74 @@ void TextObjectBar::Execute( SfxRequest &rReq )
break; break;
case FN_NUM_BULLET_ON: case FN_NUM_BULLET_ON:
if( pOLV ) {
pOLV->ToggleBullets(); if (pOLV)
break; {
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_GROW_FONT_SIZE:
case SID_SHRINK_FONT_SIZE: case SID_SHRINK_FONT_SIZE:
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment