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