1 Fix the annoying post-3.0 ruler behaviour
3 From: Thorsten Behrens <thb@openoffice.org>
8 sd/source/ui/view/drviews3.cxx | 82 +++++++++++++++++++++++++++++++++++++-
9 svx/source/outliner/outliner.cxx | 6 ++-
10 svx/source/outliner/outlvw.cxx | 4 +-
11 3 files changed, 86 insertions(+), 6 deletions(-)
14 diff --git sd/source/ui/view/drviews3.cxx sd/source/ui/view/drviews3.cxx
15 index 1491ee0..90ee1fc 100644
16 --- sd/source/ui/view/drviews3.cxx
17 +++ sd/source/ui/view/drviews3.cxx
19 #include <svx/protitem.hxx>
20 #include <svx/frmdiritem.hxx>
21 #include <svx/ruler.hxx>
22 +#include <svx/numitem.hxx>
23 #ifndef _SVX_RULERITEM_HXX
24 #include <svx/rulritem.hxx>
26 @@ -692,14 +693,75 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq)
27 const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
30 - SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
31 + static const USHORT aWhichTable[]=
33 + EE_PARA_OUTLLEVEL, EE_PARA_OUTLLEVEL,
34 + EE_PARA_LRSPACE, EE_PARA_LRSPACE,
35 + EE_PARA_NUMBULLET, EE_PARA_NUMBULLET,
39 + SfxItemSet aEditAttr( GetDoc()->GetPool(),
41 + mpDrawView->GetAttributes( aEditAttr );
43 nId = EE_PARA_LRSPACE;
44 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
45 rItem.GetRight(), rItem.GetTxtLeft(),
46 rItem.GetTxtFirstLineOfst(), nId );
47 - aEditAttr.Put( aLRSpaceItem );
48 - mpDrawView->SetAttributes( aEditAttr );
50 + const INT16 nOutlineLevel = ((const SfxInt16Item&)aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue();
51 + const SvxLRSpaceItem& rOrigLRSpaceItem = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
52 + const SvxNumBulletItem& rNumBulletItem = (const SvxNumBulletItem&) aEditAttr.Get( EE_PARA_NUMBULLET );
53 + if( nOutlineLevel != -1 &&
54 + rNumBulletItem.GetNumRule() &&
55 + rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel )
57 + const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel);
58 + SvxNumberFormat aFormat(rFormat);
60 + // left margin always controls LRSpace item
61 + aLRSpaceItem.SetTxtLeft(rItem.GetTxtLeft() - aFormat.GetAbsLSpace());
63 + // negative first line indent goes to the number
64 + // format, positive to the lrSpace item
65 + if( rItem.GetTxtFirstLineOfst() < 0 )
67 + aFormat.SetFirstLineOffset(
68 + rItem.GetTxtFirstLineOfst()
69 + - rOrigLRSpaceItem.GetTxtFirstLineOfst()
70 + + aFormat.GetCharTextDistance());
71 + aLRSpaceItem.SetTxtFirstLineOfst(0);
75 + aFormat.SetFirstLineOffset(0);
76 + aLRSpaceItem.SetTxtFirstLineOfst(
77 + rItem.GetTxtFirstLineOfst()
78 + - aFormat.GetFirstLineOffset()
79 + + aFormat.GetCharTextDistance());
82 + if( rFormat != aFormat )
85 + SvxNumBulletItem aNumBulletItem(rNumBulletItem);
86 + aNumBulletItem.GetNumRule()->SetLevel(nOutlineLevel,aFormat);
87 + aEditAttr.Put( aNumBulletItem );
88 + aEditAttr.Put( aLRSpaceItem );
89 + mpDrawView->SetAttributes( aEditAttr );
91 + // #92557# Invalidate is missing here
92 + Invalidate(SID_ATTR_PARA_LRSPACE);
97 + // only put lrSpace item
98 + SfxItemSet aEditAttrReduced( GetDoc()->GetPool(),
99 + EE_PARA_LRSPACE, EE_PARA_LRSPACE );
100 + aEditAttrReduced.Put( aLRSpaceItem );
101 + mpDrawView->SetAttributes( aEditAttrReduced );
103 // #92557# Invalidate is missing here
104 Invalidate(SID_ATTR_PARA_LRSPACE);
105 @@ -785,6 +847,20 @@ void DrawViewShell::GetRulerState(SfxItemSet& rSet)
106 SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(),
107 rLRSpaceItem.GetRight(), rLRSpaceItem.GetTxtLeft(),
108 rLRSpaceItem.GetTxtFirstLineOfst(), nId );
110 + const INT16 nOutlineLevel = ((const SfxInt16Item&)aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue();
111 + const SvxNumBulletItem& rNumBulletItem = (const SvxNumBulletItem&) aEditAttr.Get( EE_PARA_NUMBULLET );
112 + if( nOutlineLevel != -1 &&
113 + rNumBulletItem.GetNumRule() &&
114 + rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel )
116 + const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel);
117 + aLRSpaceItem.SetTxtLeft(rFormat.GetAbsLSpace() + rLRSpaceItem.GetTxtLeft());
118 + aLRSpaceItem.SetTxtFirstLineOfst(
119 + rLRSpaceItem.GetTxtFirstLineOfst() + rFormat.GetFirstLineOffset()
120 + - rFormat.GetCharTextDistance());
123 rSet.Put( aLRSpaceItem );
125 Point aPos( aPagePos + maMarkRect.TopLeft() );
126 diff --git svx/source/outliner/outliner.cxx svx/source/outliner/outliner.cxx
127 index 73aa6f0..5c0a1a6 100644
128 --- svx/source/outliner/outliner.cxx
129 +++ svx/source/outliner/outliner.cxx
130 @@ -1897,8 +1897,10 @@ sal_uInt16 Outliner::ImplGetNumbering( USHORT nPara, const SvxNumberFormat* pPar
133 const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
134 - if( pFmt == 0 || (*pFmt != *pParaFmt) )
135 - break; // change in number format, stop here
137 + pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL ||
138 + pFmt->GetNumberingType() == SVX_NUM_NUMBER_NONE )
139 + break; // no number format, or no numbering - stop here
141 const SfxBoolItem& rBulletState = (const SfxBoolItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE );
143 diff --git svx/source/outliner/outlvw.cxx svx/source/outliner/outlvw.cxx
144 index 0be153e..7aadc39 100644
145 --- svx/source/outliner/outlvw.cxx
146 +++ svx/source/outliner/outlvw.cxx
147 @@ -530,7 +530,9 @@ void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
148 for( USHORT nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
150 pOwner->ImplCheckNumBulletItem( nPara );
151 - pOwner->ImplCalcBulletText( nPara, FALSE, FALSE );
152 + // update following paras as well, numbering depends on
154 + pOwner->ImplCalcBulletText( nPara, TRUE, FALSE );
156 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
157 pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );