xref: /trunk/main/sd/source/ui/func/fuparagr.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include "fuparagr.hxx"
33 #include <editeng/eeitem.hxx>
34 #ifndef _MSGBOX_HXX //autogen
35 #include <vcl/msgbox.hxx>
36 #endif
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/request.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <svx/svxids.hrc>
41 #include <editeng/editdata.hxx>
42 #include <editeng/lrspitem.hxx>
43 #include <svx/svdoutl.hxx>
44 
45 #include "app.hrc"
46 #include "View.hxx"
47 #include "ViewShell.hxx"
48 #include "drawdoc.hxx"
49 #include "sdabstdlg.hxx"
50 #include "paragr.hrc"
51 #include "sdattr.hrc"
52 
53 namespace sd {
54 
55 TYPEINIT1( FuParagraph, FuPoor );
56 
57 /*************************************************************************
58 |*
59 |* Konstruktor
60 |*
61 \************************************************************************/
62 
63 FuParagraph::FuParagraph (
64     ViewShell* pViewSh,
65     ::sd::Window* pWin,
66     ::sd::View* pView,
67     SdDrawDocument* pDoc,
68     SfxRequest& rReq)
69     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
70 {
71 }
72 
73 FunctionReference FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
74 {
75     FunctionReference xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
76     xFunc->DoExecute(rReq);
77     return xFunc;
78 }
79 
80 void FuParagraph::DoExecute( SfxRequest& rReq )
81 {
82     const SfxItemSet* pArgs = rReq.GetArgs();
83 
84     OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
85     ::Outliner* pOutliner = mpView->GetTextEditOutliner();
86 
87     if( !pArgs )
88     {
89         SfxItemSet aEditAttr( mpDoc->GetPool() );
90         mpView->GetAttributes( aEditAttr );
91         SfxItemPool *pPool =  aEditAttr.GetPool();
92         SfxItemSet aNewAttr( *pPool,
93                              EE_ITEMS_START, EE_ITEMS_END,
94                              SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
95                              ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
96                              0 );
97 
98         aNewAttr.Put( aEditAttr );
99 
100         // linker Rand als Offset
101         const long nOff = ( (SvxLRSpaceItem&)aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTxtLeft();
102         // Umrechnung, da TabulatorTabPage immer von Twips ausgeht !
103         SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
104         aNewAttr.Put( aOff );
105 
106         if( pOutlView && pOutliner )
107         {
108             ESelection eSelection = pOutlView->GetSelection();
109             aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
110             aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
111         }
112 
113         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
114         SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
115         if( pDlg )
116         {
117             sal_uInt16 nResult = pDlg->Execute();
118 
119             switch( nResult )
120             {
121                 case RET_OK:
122                 {
123                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
124 
125                     pArgs = rReq.GetArgs();
126                 }
127                 break;
128 
129                 default:
130                 {
131                     delete pDlg;
132                 }
133                 return; // Abbruch
134             }
135             delete( pDlg );
136         }
137     }
138     mpView->SetAttributes( *pArgs );
139 
140     if( pOutlView && pOutliner )
141     {
142         ESelection eSelection = pOutlView->GetSelection();
143 
144         const SfxPoolItem *pItem = 0;
145         if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, sal_False, &pItem ) )
146         {
147             const sal_Bool bNewStart = ((SfxBoolItem*)pItem)->GetValue() ? sal_True : sal_False;
148             pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
149         }
150 
151         if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, sal_False, &pItem ) )
152         {
153             const sal_Int16 nStartAt = ((SfxInt16Item*)pItem)->GetValue();
154             pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
155         }
156     }
157 
158     // invalidieren der Slots
159     static sal_uInt16 SidArray[] = {
160         SID_ATTR_TABSTOP,
161         SID_ATTR_PARA_ADJUST_LEFT,
162         SID_ATTR_PARA_ADJUST_RIGHT,
163         SID_ATTR_PARA_ADJUST_CENTER,
164         SID_ATTR_PARA_ADJUST_BLOCK,
165         SID_ATTR_PARA_LINESPACE_10,
166         SID_ATTR_PARA_LINESPACE_15,
167         SID_ATTR_PARA_LINESPACE_20,
168         SID_ATTR_PARA_LRSPACE,
169         SID_ATTR_PARA_LEFT_TO_RIGHT,
170         SID_ATTR_PARA_RIGHT_TO_LEFT,
171         SID_RULER_TEXT_RIGHT_TO_LEFT,
172         SID_PARASPACE_INCREASE,
173         SID_PARASPACE_DECREASE,
174         0 };
175 
176     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
177 }
178 
179 void FuParagraph::Activate()
180 {
181 }
182 
183 void FuParagraph::Deactivate()
184 {
185 }
186 
187 } // end of namespace sd
188