bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / fuparagr.cxx
blob6a455f5d1e87f70b60921a2781e8284dea884c4e
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 <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>
32 #include <View.hxx>
33 #include <ViewShell.hxx>
34 #include <drawdoc.hxx>
35 #include <sdabstdlg.hxx>
36 #include <sdattr.hrc>
38 namespace sd {
41 FuParagraph::FuParagraph (
42 ViewShell* pViewSh,
43 ::sd::Window* pWin,
44 ::sd::View* pView,
45 SdDrawDocument* pDoc,
46 SfxRequest& rReq)
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);
55 return xFunc;
58 void FuParagraph::DoExecute( SfxRequest& rReq )
60 const SfxItemSet* pArgs = rReq.GetArgs();
62 OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
63 ::Outliner* pOutliner = mpView->GetTextEditOutliner();
65 if( !pArgs )
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 );
81 aNewAttr.Put( aOff );
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();
95 switch( nResult )
97 case RET_OK:
99 rReq.Done( *( pDlg->GetOutputItemSet() ) );
101 pArgs = rReq.GetArgs();
103 break;
105 default:
106 return; // Cancel
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 );
129 // invalidate slots
130 static const sal_uInt16 SidArray[] = {
131 SID_ATTR_TABSTOP,
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,
142 SID_DEC_INDENT,
143 SID_INC_INDENT,
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,
149 0 };
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: */