android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / func / fuparagr.cxx
blobac5d87636098188d86c264b4f79ad88bce8cc9e6
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 SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END,
71 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
72 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END> aNewAttr( *pPool );
74 aNewAttr.Put( aEditAttr );
76 // left border is offset
77 const ::tools::Long nOff = aNewAttr.Get( EE_PARA_LRSPACE ).GetTextLeft();
78 // conversion since TabulatorTabPage always uses Twips!
79 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
80 aNewAttr.Put( aOff );
82 if( pOutlView && pOutliner )
84 ESelection eSelection = pOutlView->GetSelection();
85 aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
86 aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
89 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
90 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSdParagraphTabDlg(mpViewShell->GetFrameWeld(), &aNewAttr));
92 sal_uInt16 nResult = pDlg->Execute();
94 switch( nResult )
96 case RET_OK:
98 rReq.Done( *( pDlg->GetOutputItemSet() ) );
100 pArgs = rReq.GetArgs();
102 break;
104 default:
105 return; // Cancel
108 mpView->SetAttributes( *pArgs );
110 if( pOutlView && pOutliner )
112 ESelection eSelection = pOutlView->GetSelection();
114 if( const SfxBoolItem* pItem = pArgs->GetItemIfSet( ATTR_NUMBER_NEWSTART, false ) )
116 const bool bNewStart = pItem->GetValue();
117 pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
120 if( const SfxInt16Item* pItem = pArgs->GetItemIfSet( ATTR_NUMBER_NEWSTART_AT, false ) )
122 const sal_Int16 nStartAt = pItem->GetValue();
123 pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
127 // invalidate slots
128 static const sal_uInt16 SidArray[] = {
129 SID_ATTR_TABSTOP,
130 SID_ATTR_PARA_ADJUST_LEFT,
131 SID_ATTR_PARA_ADJUST_RIGHT,
132 SID_ATTR_PARA_ADJUST_CENTER,
133 SID_ATTR_PARA_ADJUST_BLOCK,
134 SID_ATTR_PARA_LINESPACE,
135 SID_ATTR_PARA_LINESPACE_10,
136 SID_ATTR_PARA_LINESPACE_15,
137 SID_ATTR_PARA_LINESPACE_20,
138 SID_ATTR_PARA_ULSPACE,
139 SID_ATTR_PARA_LRSPACE,
140 SID_DEC_INDENT,
141 SID_INC_INDENT,
142 SID_ATTR_PARA_LEFT_TO_RIGHT,
143 SID_ATTR_PARA_RIGHT_TO_LEFT,
144 SID_RULER_TEXT_RIGHT_TO_LEFT,
145 SID_PARASPACE_INCREASE,
146 SID_PARASPACE_DECREASE,
147 0 };
149 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
152 void FuParagraph::Activate()
156 void FuParagraph::Deactivate()
160 } // end of namespace sd
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */