bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / fuparagr.cxx
blobfc4031d03d8b932b512d33f6f436ed1fc518a711
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 "sdattr.hrc"
37 #include <boost/scoped_ptr.hpp>
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 rtl::Reference<FuPoor> FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
55 rtl::Reference<FuPoor> 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 = static_cast<const SvxLRSpaceItem&>(aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTextLeft();
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 boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0);
95 if (!pDlg)
96 return;
98 sal_uInt16 nResult = pDlg->Execute();
100 switch( nResult )
102 case RET_OK:
104 rReq.Done( *( pDlg->GetOutputItemSet() ) );
106 pArgs = rReq.GetArgs();
108 break;
110 default:
111 return; // Cancel
114 mpView->SetAttributes( *pArgs );
116 if( pOutlView && pOutliner )
118 ESelection eSelection = pOutlView->GetSelection();
120 const SfxPoolItem *pItem = 0;
121 if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, false, &pItem ) )
123 const bool bNewStart = static_cast<const SfxBoolItem*>(pItem)->GetValue();
124 pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
127 if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, false, &pItem ) )
129 const sal_Int16 nStartAt = static_cast<const SfxInt16Item*>(pItem)->GetValue();
130 pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
134 // invalidate slots
135 static sal_uInt16 SidArray[] = {
136 SID_ATTR_TABSTOP,
137 SID_ATTR_PARA_ADJUST_LEFT,
138 SID_ATTR_PARA_ADJUST_RIGHT,
139 SID_ATTR_PARA_ADJUST_CENTER,
140 SID_ATTR_PARA_ADJUST_BLOCK,
141 SID_ATTR_PARA_LINESPACE,
142 SID_ATTR_PARA_LINESPACE_10,
143 SID_ATTR_PARA_LINESPACE_15,
144 SID_ATTR_PARA_LINESPACE_20,
145 SID_ATTR_PARA_ULSPACE,
146 SID_ATTR_PARA_LRSPACE,
147 SID_ATTR_PARA_LEFT_TO_RIGHT,
148 SID_ATTR_PARA_RIGHT_TO_LEFT,
149 SID_RULER_TEXT_RIGHT_TO_LEFT,
150 SID_PARASPACE_INCREASE,
151 SID_PARASPACE_DECREASE,
152 0 };
154 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
157 void FuParagraph::Activate()
161 void FuParagraph::Deactivate()
165 } // end of namespace sd
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */