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 "sdattr.hrc"
37 :
38 : namespace sd {
39 :
40 0 : TYPEINIT1( FuParagraph, FuPoor );
41 :
42 0 : FuParagraph::FuParagraph (
43 : ViewShell* pViewSh,
44 : ::sd::Window* pWin,
45 : ::sd::View* pView,
46 : SdDrawDocument* pDoc,
47 : SfxRequest& rReq)
48 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
49 : {
50 0 : }
51 :
52 0 : rtl::Reference<FuPoor> FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
53 : {
54 0 : rtl::Reference<FuPoor> xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
55 0 : xFunc->DoExecute(rReq);
56 0 : return xFunc;
57 : }
58 :
59 0 : void FuParagraph::DoExecute( SfxRequest& rReq )
60 : {
61 0 : const SfxItemSet* pArgs = rReq.GetArgs();
62 :
63 0 : OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
64 0 : ::Outliner* pOutliner = mpView->GetTextEditOutliner();
65 :
66 0 : if( !pArgs )
67 : {
68 0 : SfxItemSet aEditAttr( mpDoc->GetPool() );
69 0 : mpView->GetAttributes( aEditAttr );
70 0 : SfxItemPool *pPool = aEditAttr.GetPool();
71 : SfxItemSet aNewAttr( *pPool,
72 : EE_ITEMS_START, EE_ITEMS_END,
73 : SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
74 : ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
75 0 : 0 );
76 :
77 0 : aNewAttr.Put( aEditAttr );
78 :
79 : // left border is offset
80 0 : const long nOff = ( (SvxLRSpaceItem&)aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTxtLeft();
81 : // conversion since TabulatorTabPage always uses Twips!
82 0 : SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
83 0 : aNewAttr.Put( aOff );
84 :
85 0 : if( pOutlView && pOutliner )
86 : {
87 0 : ESelection eSelection = pOutlView->GetSelection();
88 0 : aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
89 0 : aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
90 : }
91 :
92 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
93 0 : SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
94 0 : if (!pDlg)
95 0 : return;
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 : }
117 0 : mpView->SetAttributes( *pArgs );
118 :
119 0 : if( pOutlView && pOutliner )
120 : {
121 0 : ESelection eSelection = pOutlView->GetSelection();
122 :
123 0 : const SfxPoolItem *pItem = 0;
124 0 : if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, false, &pItem ) )
125 : {
126 0 : const sal_Bool bNewStart = ((SfxBoolItem*)pItem)->GetValue() ? sal_True : sal_False;
127 0 : pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
128 : }
129 :
130 0 : if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, false, &pItem ) )
131 : {
132 0 : const sal_Int16 nStartAt = ((SfxInt16Item*)pItem)->GetValue();
133 0 : pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
134 : }
135 : }
136 :
137 : // invalidate slots
138 : static sal_uInt16 SidArray[] = {
139 : SID_ATTR_TABSTOP,
140 : SID_ATTR_PARA_LINESPACE,
141 : SID_ATTR_PARA_ULSPACE,
142 : SID_ATTR_PARA_ADJUST_LEFT,
143 : SID_ATTR_PARA_ADJUST_RIGHT,
144 : SID_ATTR_PARA_ADJUST_CENTER,
145 : SID_ATTR_PARA_ADJUST_BLOCK,
146 : SID_ATTR_PARA_LINESPACE_10,
147 : SID_ATTR_PARA_LINESPACE_15,
148 : SID_ATTR_PARA_LINESPACE_20,
149 : SID_ATTR_PARA_LRSPACE,
150 : SID_ATTR_PARA_LEFT_TO_RIGHT,
151 : SID_ATTR_PARA_RIGHT_TO_LEFT,
152 : SID_RULER_TEXT_RIGHT_TO_LEFT,
153 : SID_PARASPACE_INCREASE,
154 : SID_PARASPACE_DECREASE,
155 : 0 };
156 :
157 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
158 : }
159 :
160 0 : void FuParagraph::Activate()
161 : {
162 0 : }
163 :
164 0 : void FuParagraph::Deactivate()
165 : {
166 0 : }
167 :
168 0 : } // end of namespace sd
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|