1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27
28 #include "fuparagr.hxx"
29 #include <editeng/eeitem.hxx>
30 #ifndef _MSGBOX_HXX //autogen
31 #include <vcl/msgbox.hxx>
32 #endif
33 #include <sfx2/bindings.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <svx/svxids.hrc>
37 #include <editeng/editdata.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <svx/svdoutl.hxx>
40
41 #include "app.hrc"
42 #include "View.hxx"
43 #include "ViewShell.hxx"
44 #include "drawdoc.hxx"
45 #include "sdabstdlg.hxx"
46 #include "paragr.hrc"
47 #include "sdattr.hrc"
48
49 namespace sd {
50
51 TYPEINIT1( FuParagraph, FuPoor );
52
53 /*************************************************************************
54 |*
55 |* Konstruktor
56 |*
57 \************************************************************************/
58
FuParagraph(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)59 FuParagraph::FuParagraph (
60 ViewShell* pViewSh,
61 ::sd::Window* pWin,
62 ::sd::View* pView,
63 SdDrawDocument* pDoc,
64 SfxRequest& rReq)
65 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
66 {
67 }
68
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)69 FunctionReference FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
70 {
71 FunctionReference xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
72 xFunc->DoExecute(rReq);
73 return xFunc;
74 }
75
DoExecute(SfxRequest & rReq)76 void FuParagraph::DoExecute( SfxRequest& rReq )
77 {
78 const SfxItemSet* pArgs = rReq.GetArgs();
79
80 OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
81 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
82
83 if( !pArgs )
84 {
85 SfxItemSet aEditAttr( mpDoc->GetPool() );
86 mpView->GetAttributes( aEditAttr );
87 SfxItemPool *pPool = aEditAttr.GetPool();
88 SfxItemSet aNewAttr( *pPool,
89 EE_ITEMS_START, EE_ITEMS_END,
90 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
91 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
92 0 );
93
94 aNewAttr.Put( aEditAttr );
95
96 // linker Rand als Offset
97 const long nOff = ( (SvxLRSpaceItem&)aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTxtLeft();
98 // Umrechnung, da TabulatorTabPage immer von Twips ausgeht !
99 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
100 aNewAttr.Put( aOff );
101
102 if( pOutlView && pOutliner )
103 {
104 ESelection eSelection = pOutlView->GetSelection();
105 aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
106 aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
107 }
108
109 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
110 SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
111 if( pDlg )
112 {
113 sal_uInt16 nResult = pDlg->Execute();
114
115 switch( nResult )
116 {
117 case RET_OK:
118 {
119 rReq.Done( *( pDlg->GetOutputItemSet() ) );
120
121 pArgs = rReq.GetArgs();
122 }
123 break;
124
125 default:
126 {
127 delete pDlg;
128 }
129 return; // Abbruch
130 }
131 delete( pDlg );
132 }
133 }
134 mpView->SetAttributes( *pArgs );
135
136 if( pOutlView && pOutliner )
137 {
138 ESelection eSelection = pOutlView->GetSelection();
139
140 const SfxPoolItem *pItem = 0;
141 if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, sal_False, &pItem ) )
142 {
143 const sal_Bool bNewStart = ((SfxBoolItem*)pItem)->GetValue() ? sal_True : sal_False;
144 pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
145 }
146
147 if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, sal_False, &pItem ) )
148 {
149 const sal_Int16 nStartAt = ((SfxInt16Item*)pItem)->GetValue();
150 pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
151 }
152 }
153
154 // invalidieren der Slots
155 static sal_uInt16 SidArray[] = {
156 SID_ATTR_TABSTOP,
157 SID_ATTR_PARA_LINESPACE,
158 SID_ATTR_PARA_ULSPACE,
159 SID_ATTR_PARA_ADJUST_LEFT,
160 SID_ATTR_PARA_ADJUST_RIGHT,
161 SID_ATTR_PARA_ADJUST_CENTER,
162 SID_ATTR_PARA_ADJUST_BLOCK,
163 SID_ATTR_PARA_LINESPACE_10,
164 SID_ATTR_PARA_LINESPACE_15,
165 SID_ATTR_PARA_LINESPACE_20,
166 SID_ATTR_PARA_LRSPACE,
167 SID_ATTR_PARA_LEFT_TO_RIGHT,
168 SID_ATTR_PARA_RIGHT_TO_LEFT,
169 SID_RULER_TEXT_RIGHT_TO_LEFT,
170 SID_PARASPACE_INCREASE,
171 SID_PARASPACE_DECREASE,
172 0 };
173
174 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
175 }
176
Activate()177 void FuParagraph::Activate()
178 {
179 }
180
Deactivate()181 void FuParagraph::Deactivate()
182 {
183 }
184
185 } // end of namespace sd
186