Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / fuparagr.cxx
blob48d61597d26b1842d355b0aaa65c8e6fbc6b20be
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 <sfx2/bindings.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svx/svxids.hrc>
26 #include <editeng/editdata.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <svx/svdoutl.hxx>
30 #include <app.hrc>
31 #include <View.hxx>
32 #include <ViewShell.hxx>
33 #include <Window.hxx>
34 #include <drawdoc.hxx>
35 #include <sdabstdlg.hxx>
36 #include <sdattr.hrc>
37 #include <memory>
39 namespace sd {
42 FuParagraph::FuParagraph (
43 ViewShell* pViewSh,
44 ::sd::Window* pWin,
45 ::sd::View* pView,
46 SdDrawDocument* pDoc,
47 SfxRequest& rReq)
48 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
52 rtl::Reference<FuPoor> FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
54 rtl::Reference<FuPoor> xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
55 xFunc->DoExecute(rReq);
56 return xFunc;
59 void FuParagraph::DoExecute( SfxRequest& rReq )
61 const SfxItemSet* pArgs = rReq.GetArgs();
63 OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
64 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
66 if( !pArgs )
68 SfxItemSet aEditAttr( mpDoc->GetPool() );
69 mpView->GetAttributes( aEditAttr );
70 SfxItemPool *pPool = aEditAttr.GetPool();
71 SfxItemSet aNewAttr( *pPool,
72 svl::Items<EE_ITEMS_START, EE_ITEMS_END,
73 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
74 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END>{} );
76 aNewAttr.Put( aEditAttr );
78 // left border is offset
79 const long nOff = aNewAttr.Get( EE_PARA_LRSPACE ).GetTextLeft();
80 // conversion since TabulatorTabPage always uses Twips!
81 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
82 aNewAttr.Put( aOff );
84 if( pOutlView && pOutliner )
86 ESelection eSelection = pOutlView->GetSelection();
87 aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
88 aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
91 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
92 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdParagraphTabDlg(mpViewShell->GetActiveWindow(), &aNewAttr) : nullptr);
93 if (!pDlg)
94 return;
96 sal_uInt16 nResult = pDlg->Execute();
98 switch( nResult )
100 case RET_OK:
102 rReq.Done( *( pDlg->GetOutputItemSet() ) );
104 pArgs = rReq.GetArgs();
106 break;
108 default:
109 return; // Cancel
112 mpView->SetAttributes( *pArgs );
114 if( pOutlView && pOutliner )
116 ESelection eSelection = pOutlView->GetSelection();
118 const SfxPoolItem *pItem = nullptr;
119 if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, false, &pItem ) )
121 const bool bNewStart = static_cast<const SfxBoolItem*>(pItem)->GetValue();
122 pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
125 if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, false, &pItem ) )
127 const sal_Int16 nStartAt = static_cast<const SfxInt16Item*>(pItem)->GetValue();
128 pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
132 // invalidate slots
133 static const sal_uInt16 SidArray[] = {
134 SID_ATTR_TABSTOP,
135 SID_ATTR_PARA_ADJUST_LEFT,
136 SID_ATTR_PARA_ADJUST_RIGHT,
137 SID_ATTR_PARA_ADJUST_CENTER,
138 SID_ATTR_PARA_ADJUST_BLOCK,
139 SID_ATTR_PARA_LINESPACE,
140 SID_ATTR_PARA_LINESPACE_10,
141 SID_ATTR_PARA_LINESPACE_15,
142 SID_ATTR_PARA_LINESPACE_20,
143 SID_ATTR_PARA_ULSPACE,
144 SID_ATTR_PARA_LRSPACE,
145 SID_ATTR_PARA_LEFT_TO_RIGHT,
146 SID_ATTR_PARA_RIGHT_TO_LEFT,
147 SID_RULER_TEXT_RIGHT_TO_LEFT,
148 SID_PARASPACE_INCREASE,
149 SID_PARASPACE_DECREASE,
150 0 };
152 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
155 void FuParagraph::Activate()
159 void FuParagraph::Deactivate()
163 } // end of namespace sd
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */