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 <sfx2/sfxdlg.hxx>
26 #include <svx/svxids.hrc>
27 #include <editeng/editdata.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <svx/svdoutl.hxx>
30 #include <svl/intitem.hxx>
33 #include <ViewShell.hxx>
34 #include <drawdoc.hxx>
35 #include <sdabstdlg.hxx>
41 FuParagraph::FuParagraph (
47 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
51 rtl::Reference
<FuPoor
> FuParagraph::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
53 rtl::Reference
<FuPoor
> xFunc( new FuParagraph( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
54 xFunc
->DoExecute(rReq
);
58 void FuParagraph::DoExecute( SfxRequest
& rReq
)
60 const SfxItemSet
* pArgs
= rReq
.GetArgs();
62 OutlinerView
* pOutlView
= mpView
->GetTextEditOutlinerView();
63 ::Outliner
* pOutliner
= mpView
->GetTextEditOutliner();
67 SfxItemSet
aEditAttr( mpDoc
->GetPool() );
68 mpView
->GetAttributes( aEditAttr
);
69 SfxItemPool
*pPool
= aEditAttr
.GetPool();
70 SfxItemSet
aNewAttr( *pPool
,
71 svl::Items
<EE_ITEMS_START
, EE_ITEMS_END
,
72 SID_ATTR_TABSTOP_OFFSET
, SID_ATTR_TABSTOP_OFFSET
,
73 ATTR_PARANUMBERING_START
, ATTR_PARANUMBERING_END
>{} );
75 aNewAttr
.Put( aEditAttr
);
77 // left border is offset
78 const long nOff
= aNewAttr
.Get( EE_PARA_LRSPACE
).GetTextLeft();
79 // conversion since TabulatorTabPage always uses Twips!
80 SfxInt32Item
aOff( SID_ATTR_TABSTOP_OFFSET
, nOff
);
83 if( pOutlView
&& pOutliner
)
85 ESelection eSelection
= pOutlView
->GetSelection();
86 aNewAttr
.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT
, pOutliner
->GetNumberingStartValue( eSelection
.nStartPara
) ) );
87 aNewAttr
.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART
, pOutliner
->IsParaIsNumberingRestart( eSelection
.nStartPara
) ) );
90 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
91 ScopedVclPtr
<SfxAbstractTabDialog
> pDlg(pFact
->CreateSdParagraphTabDlg(mpViewShell
->GetFrameWeld(), &aNewAttr
));
93 sal_uInt16 nResult
= pDlg
->Execute();
99 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
101 pArgs
= rReq
.GetArgs();
109 mpView
->SetAttributes( *pArgs
);
111 if( pOutlView
&& pOutliner
)
113 ESelection eSelection
= pOutlView
->GetSelection();
115 const SfxPoolItem
*pItem
= nullptr;
116 if( SfxItemState::SET
== pArgs
->GetItemState( ATTR_NUMBER_NEWSTART
, false, &pItem
) )
118 const bool bNewStart
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
119 pOutliner
->SetParaIsNumberingRestart( eSelection
.nStartPara
, bNewStart
);
122 if( SfxItemState::SET
== pArgs
->GetItemState( ATTR_NUMBER_NEWSTART_AT
, false, &pItem
) )
124 const sal_Int16 nStartAt
= static_cast<const SfxInt16Item
*>(pItem
)->GetValue();
125 pOutliner
->SetNumberingStartValue( eSelection
.nStartPara
, nStartAt
);
130 static const sal_uInt16 SidArray
[] = {
132 SID_ATTR_PARA_ADJUST_LEFT
,
133 SID_ATTR_PARA_ADJUST_RIGHT
,
134 SID_ATTR_PARA_ADJUST_CENTER
,
135 SID_ATTR_PARA_ADJUST_BLOCK
,
136 SID_ATTR_PARA_LINESPACE
,
137 SID_ATTR_PARA_LINESPACE_10
,
138 SID_ATTR_PARA_LINESPACE_15
,
139 SID_ATTR_PARA_LINESPACE_20
,
140 SID_ATTR_PARA_ULSPACE
,
141 SID_ATTR_PARA_LRSPACE
,
144 SID_ATTR_PARA_LEFT_TO_RIGHT
,
145 SID_ATTR_PARA_RIGHT_TO_LEFT
,
146 SID_RULER_TEXT_RIGHT_TO_LEFT
,
147 SID_PARASPACE_INCREASE
,
148 SID_PARASPACE_DECREASE
,
151 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
154 void FuParagraph::Activate()
158 void FuParagraph::Deactivate()
162 } // end of namespace sd
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */