1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
32 #include <ViewShell.hxx>
34 #include <drawdoc.hxx>
35 #include <sdabstdlg.hxx>
42 FuParagraph::FuParagraph (
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
);
59 void FuParagraph::DoExecute( SfxRequest
& rReq
)
61 const SfxItemSet
* pArgs
= rReq
.GetArgs();
63 OutlinerView
* pOutlView
= mpView
->GetTextEditOutlinerView();
64 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
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
);
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);
96 sal_uInt16 nResult
= pDlg
->Execute();
102 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
104 pArgs
= rReq
.GetArgs();
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
);
133 static const sal_uInt16 SidArray
[] = {
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
,
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: */