summaryrefslogtreecommitdiff
path: root/patches/dev300/sd-ruler-fix.diff (plain)
blob: 6f3b1c97fcd9fc4f3a7aa9880cc22be3860b34a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Fix the annoying post-3.0 ruler behaviour

From: Thorsten Behrens <thb@openoffice.org>


---

 sd/source/ui/view/drviews3.cxx |   82 +++++++++++++++++++++++++++++++++++++++-
 svx/source/outliner/outlvw.cxx |    4 +-
 2 files changed, 82 insertions(+), 4 deletions(-)


diff --git sd/source/ui/view/drviews3.cxx sd/source/ui/view/drviews3.cxx
index 0c5d284..a4f49aa 100644
--- sd/source/ui/view/drviews3.cxx
+++ sd/source/ui/view/drviews3.cxx
@@ -40,6 +40,7 @@
 #include <svx/protitem.hxx>
 #include <svx/frmdiritem.hxx>
 #include <svx/ruler.hxx>
+#include <svx/numitem.hxx>
 #ifndef _SVX_RULERITEM_HXX
 #include <svx/rulritem.hxx>
 #endif
@@ -692,14 +693,75 @@ void  DrawViewShell::ExecRuler(SfxRequest& rReq)
                 const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
                             pArgs->Get( nId );
 
-                SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
+                static const USHORT aWhichTable[]=
+                {
+                    EE_PARA_OUTLLEVEL, EE_PARA_OUTLLEVEL,
+                    EE_PARA_LRSPACE, EE_PARA_LRSPACE,
+                    EE_PARA_NUMBULLET, EE_PARA_NUMBULLET,
+                    0, 0
+                };
+
+				SfxItemSet aEditAttr( GetDoc()->GetPool(),
+                                      aWhichTable );
+				mpDrawView->GetAttributes( aEditAttr );
 
                 nId = EE_PARA_LRSPACE;
                 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
                         rItem.GetRight(), rItem.GetTxtLeft(),
                         rItem.GetTxtFirstLineOfst(), nId );
-                aEditAttr.Put( aLRSpaceItem );
-                mpDrawView->SetAttributes( aEditAttr );
+
+                const INT16 nOutlineLevel = ((const SfxInt16Item&)aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue();
+                const SvxLRSpaceItem& rOrigLRSpaceItem = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
+                const SvxNumBulletItem& rNumBulletItem = (const SvxNumBulletItem&) aEditAttr.Get( EE_PARA_NUMBULLET );
+                if( nOutlineLevel != -1 && 
+                    rNumBulletItem.GetNumRule() &&
+                    rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel )
+                {
+                    const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel);
+                    SvxNumberFormat aFormat(rFormat);
+
+                    // left margin always controls LRSpace item
+                    aLRSpaceItem.SetTxtLeft(rItem.GetTxtLeft() - aFormat.GetAbsLSpace());
+
+                    // negative first line indent goes to the number
+                    // format, positive to the lrSpace item
+                    if( rItem.GetTxtFirstLineOfst() < 0 )
+                    {
+                        aFormat.SetFirstLineOffset(
+                            rItem.GetTxtFirstLineOfst() 
+                            - rOrigLRSpaceItem.GetTxtFirstLineOfst() 
+                            + aFormat.GetCharTextDistance());
+                        aLRSpaceItem.SetTxtFirstLineOfst(0);
+                    }
+                    else
+                    {
+                        aFormat.SetFirstLineOffset(0);
+                        aLRSpaceItem.SetTxtFirstLineOfst(
+                            rItem.GetTxtFirstLineOfst()
+                            - aFormat.GetFirstLineOffset()
+                            + aFormat.GetCharTextDistance());
+                    }
+
+                    if( rFormat != aFormat )
+                    {
+                        // put all items
+                        SvxNumBulletItem aNumBulletItem(rNumBulletItem);
+                        aNumBulletItem.GetNumRule()->SetLevel(nOutlineLevel,aFormat);
+                        aEditAttr.Put( aNumBulletItem );
+                        aEditAttr.Put( aLRSpaceItem );
+                        mpDrawView->SetAttributes( aEditAttr );
+
+                        // #92557# Invalidate is missing here
+                        Invalidate(SID_ATTR_PARA_LRSPACE);
+                        break;
+                    }
+                }
+
+                // only put lrSpace item
+                SfxItemSet aEditAttrReduced( GetDoc()->GetPool(),
+                                             EE_PARA_LRSPACE, EE_PARA_LRSPACE );
+                aEditAttrReduced.Put( aLRSpaceItem );
+                mpDrawView->SetAttributes( aEditAttrReduced );
 
                 // #92557# Invalidate is missing here
                 Invalidate(SID_ATTR_PARA_LRSPACE);
@@ -785,6 +847,20 @@ void  DrawViewShell::GetRulerState(SfxItemSet& rSet)
                     SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(),
                             rLRSpaceItem.GetRight(), rLRSpaceItem.GetTxtLeft(),
                             rLRSpaceItem.GetTxtFirstLineOfst(), nId );
+
+                    const INT16 nOutlineLevel = ((const SfxInt16Item&)aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue();
+                    const SvxNumBulletItem& rNumBulletItem = (const SvxNumBulletItem&) aEditAttr.Get( EE_PARA_NUMBULLET );
+                    if( nOutlineLevel != -1 && 
+                        rNumBulletItem.GetNumRule() &&
+                        rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel )
+                    {
+                        const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel);
+                        aLRSpaceItem.SetTxtLeft(rFormat.GetAbsLSpace() + rLRSpaceItem.GetTxtLeft());
+                        aLRSpaceItem.SetTxtFirstLineOfst(
+                            rLRSpaceItem.GetTxtFirstLineOfst() + rFormat.GetFirstLineOffset() 
+                            - rFormat.GetCharTextDistance());
+                    }
+
                     rSet.Put( aLRSpaceItem );
 
                     Point aPos( aPagePos + maMarkRect.TopLeft() );
diff --git svx/source/outliner/outlvw.cxx svx/source/outliner/outlvw.cxx
index da5b549..be74aaf 100644
--- svx/source/outliner/outlvw.cxx
+++ svx/source/outliner/outlvw.cxx
@@ -530,7 +530,9 @@ void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
     for( USHORT nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
     {
         pOwner->ImplCheckNumBulletItem( nPara );
-        pOwner->ImplCalcBulletText( nPara, FALSE, FALSE );
+        // update following paras as well, numbering depends on
+        // previous paras
+		pOwner->ImplCalcBulletText( nPara, TRUE, FALSE );
 
         if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
             pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );