bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / func / fuparagr.cxx
blob7a0056a5ca0637bf47a8d30c90fba4d679159756
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fuparagr.hxx"
21 #include <editeng/eeitem.hxx>
22 #include <vcl/msgbox.hxx>
23 #include <sfx2/bindings.hxx>
24 #include <sfx2/request.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <svx/svxids.hrc>
27 #include <editeng/editdata.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <svx/svdoutl.hxx>
31 #include "app.hrc"
32 #include "View.hxx"
33 #include "ViewShell.hxx"
34 #include "drawdoc.hxx"
35 #include "sdabstdlg.hxx"
36 #include "paragr.hrc"
37 #include "sdattr.hrc"
39 namespace sd {
41 TYPEINIT1( FuParagraph, FuPoor );
43 FuParagraph::FuParagraph (
44 ViewShell* pViewSh,
45 ::sd::Window* pWin,
46 ::sd::View* pView,
47 SdDrawDocument* pDoc,
48 SfxRequest& rReq)
49 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
53 FunctionReference FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
55 FunctionReference xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
56 xFunc->DoExecute(rReq);
57 return xFunc;
60 void FuParagraph::DoExecute( SfxRequest& rReq )
62 const SfxItemSet* pArgs = rReq.GetArgs();
64 OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
65 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
67 if( !pArgs )
69 SfxItemSet aEditAttr( mpDoc->GetPool() );
70 mpView->GetAttributes( aEditAttr );
71 SfxItemPool *pPool = aEditAttr.GetPool();
72 SfxItemSet aNewAttr( *pPool,
73 EE_ITEMS_START, EE_ITEMS_END,
74 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
75 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
76 0 );
78 aNewAttr.Put( aEditAttr );
80 // left border is offset
81 const long nOff = ( (SvxLRSpaceItem&)aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTxtLeft();
82 // conversion since TabulatorTabPage always uses Twips!
83 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
84 aNewAttr.Put( aOff );
86 if( pOutlView && pOutliner )
88 ESelection eSelection = pOutlView->GetSelection();
89 aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
90 aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
93 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
94 SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
95 if( pDlg )
97 sal_uInt16 nResult = pDlg->Execute();
99 switch( nResult )
101 case RET_OK:
103 rReq.Done( *( pDlg->GetOutputItemSet() ) );
105 pArgs = rReq.GetArgs();
107 break;
109 default:
111 delete pDlg;
113 return; // Cancel
115 delete( pDlg );
118 mpView->SetAttributes( *pArgs );
120 if( pOutlView && pOutliner )
122 ESelection eSelection = pOutlView->GetSelection();
124 const SfxPoolItem *pItem = 0;
125 if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, sal_False, &pItem ) )
127 const sal_Bool bNewStart = ((SfxBoolItem*)pItem)->GetValue() ? sal_True : sal_False;
128 pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
131 if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, sal_False, &pItem ) )
133 const sal_Int16 nStartAt = ((SfxInt16Item*)pItem)->GetValue();
134 pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
138 // invalidate slots
139 static sal_uInt16 SidArray[] = {
140 SID_ATTR_TABSTOP,
141 SID_ATTR_PARA_LINESPACE,
142 SID_ATTR_PARA_ULSPACE,
143 SID_ATTR_PARA_ADJUST_LEFT,
144 SID_ATTR_PARA_ADJUST_RIGHT,
145 SID_ATTR_PARA_ADJUST_CENTER,
146 SID_ATTR_PARA_ADJUST_BLOCK,
147 SID_ATTR_PARA_LINESPACE_10,
148 SID_ATTR_PARA_LINESPACE_15,
149 SID_ATTR_PARA_LINESPACE_20,
150 SID_ATTR_PARA_LRSPACE,
151 SID_ATTR_PARA_LEFT_TO_RIGHT,
152 SID_ATTR_PARA_RIGHT_TO_LEFT,
153 SID_RULER_TEXT_RIGHT_TO_LEFT,
154 SID_PARASPACE_INCREASE,
155 SID_PARASPACE_DECREASE,
156 0 };
158 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
161 void FuParagraph::Activate()
165 void FuParagraph::Deactivate()
169 } // end of namespace sd
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */