Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "fuparagr.hxx"
21 : #include <editeng/eeitem.hxx>
22 : #include <vcl/msgbox.hxx>
23 : #include <sfx2/bindings.hxx>
24 : #include <sfx2/request.hxx>
25 : #include <sfx2/viewfrm.hxx>
26 : #include <svx/svxids.hrc>
27 : #include <editeng/editdata.hxx>
28 : #include <editeng/lrspitem.hxx>
29 : #include <svx/svdoutl.hxx>
30 :
31 : #include "app.hrc"
32 : #include "View.hxx"
33 : #include "ViewShell.hxx"
34 : #include "drawdoc.hxx"
35 : #include "sdabstdlg.hxx"
36 : #include "paragr.hrc"
37 : #include "sdattr.hrc"
38 :
39 : namespace sd {
40 :
41 0 : TYPEINIT1( FuParagraph, FuPoor );
42 :
43 0 : FuParagraph::FuParagraph (
44 : ViewShell* pViewSh,
45 : ::sd::Window* pWin,
46 : ::sd::View* pView,
47 : SdDrawDocument* pDoc,
48 : SfxRequest& rReq)
49 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
50 : {
51 0 : }
52 :
53 0 : FunctionReference FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
54 : {
55 0 : FunctionReference xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
56 0 : xFunc->DoExecute(rReq);
57 0 : return xFunc;
58 : }
59 :
60 0 : void FuParagraph::DoExecute( SfxRequest& rReq )
61 : {
62 0 : const SfxItemSet* pArgs = rReq.GetArgs();
63 :
64 0 : OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
65 0 : ::Outliner* pOutliner = mpView->GetTextEditOutliner();
66 :
67 0 : if( !pArgs )
68 : {
69 0 : SfxItemSet aEditAttr( mpDoc->GetPool() );
70 0 : mpView->GetAttributes( aEditAttr );
71 0 : SfxItemPool *pPool = aEditAttr.GetPool();
72 : SfxItemSet aNewAttr( *pPool,
73 : EE_ITEMS_START, EE_ITEMS_END,
74 : SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
75 : ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
76 0 : 0 );
77 :
78 0 : aNewAttr.Put( aEditAttr );
79 :
80 : // left border is offset
81 0 : const long nOff = ( (SvxLRSpaceItem&)aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTxtLeft();
82 : // conversion since TabulatorTabPage always uses Twips!
83 0 : SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
84 0 : aNewAttr.Put( aOff );
85 :
86 0 : if( pOutlView && pOutliner )
87 : {
88 0 : ESelection eSelection = pOutlView->GetSelection();
89 0 : aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
90 0 : aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
91 : }
92 :
93 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
94 0 : SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
95 0 : if( pDlg )
96 : {
97 0 : sal_uInt16 nResult = pDlg->Execute();
98 :
99 0 : switch( nResult )
100 : {
101 : case RET_OK:
102 : {
103 0 : rReq.Done( *( pDlg->GetOutputItemSet() ) );
104 :
105 0 : pArgs = rReq.GetArgs();
106 : }
107 0 : break;
108 :
109 : default:
110 : {
111 0 : delete pDlg;
112 : }
113 0 : return; // Cancel
114 : }
115 0 : delete( pDlg );
116 0 : }
117 : }
118 0 : mpView->SetAttributes( *pArgs );
119 :
120 0 : if( pOutlView && pOutliner )
121 : {
122 0 : ESelection eSelection = pOutlView->GetSelection();
123 :
124 0 : const SfxPoolItem *pItem = 0;
125 0 : if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, sal_False, &pItem ) )
126 : {
127 0 : const sal_Bool bNewStart = ((SfxBoolItem*)pItem)->GetValue() ? sal_True : sal_False;
128 0 : pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
129 : }
130 :
131 0 : if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, sal_False, &pItem ) )
132 : {
133 0 : const sal_Int16 nStartAt = ((SfxInt16Item*)pItem)->GetValue();
134 0 : pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
135 : }
136 : }
137 :
138 : // invalidate slots
139 : static sal_uInt16 SidArray[] = {
140 : SID_ATTR_TABSTOP,
141 : SID_ATTR_PARA_LINESPACE,
142 : SID_ATTR_PARA_ULSPACE,
143 : SID_ATTR_PARA_ADJUST_LEFT,
144 : SID_ATTR_PARA_ADJUST_RIGHT,
145 : SID_ATTR_PARA_ADJUST_CENTER,
146 : SID_ATTR_PARA_ADJUST_BLOCK,
147 : SID_ATTR_PARA_LINESPACE_10,
148 : SID_ATTR_PARA_LINESPACE_15,
149 : SID_ATTR_PARA_LINESPACE_20,
150 : SID_ATTR_PARA_LRSPACE,
151 : SID_ATTR_PARA_LEFT_TO_RIGHT,
152 : SID_ATTR_PARA_RIGHT_TO_LEFT,
153 : SID_RULER_TEXT_RIGHT_TO_LEFT,
154 : SID_PARASPACE_INCREASE,
155 : SID_PARASPACE_DECREASE,
156 : 0 };
157 :
158 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
159 : }
160 :
161 0 : void FuParagraph::Activate()
162 : {
163 0 : }
164 :
165 0 : void FuParagraph::Deactivate()
166 : {
167 0 : }
168 :
169 33 : } // end of namespace sd
170 :
171 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|