Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "scitems.hxx"
31 : : #include <editeng/adjitem.hxx>
32 : : #include <svx/drawitem.hxx>
33 : : #include <svx/fontwork.hxx>
34 : : #include <editeng/frmdiritem.hxx>
35 : : #include <editeng/outlobj.hxx>
36 : : #include <svx/svdocapt.hxx>
37 : : #include <svx/xtextit.hxx>
38 : : #include <editeng/writingmodeitem.hxx>
39 : : #include <sfx2/bindings.hxx>
40 : : #include <sfx2/viewfrm.hxx>
41 : : #include <sfx2/objsh.hxx>
42 : : #include <sfx2/request.hxx>
43 : : #include <sot/formats.hxx>
44 : : #include <svl/whiter.hxx>
45 : :
46 : : #include "sc.hrc"
47 : : #include "drtxtob.hxx"
48 : : #include "viewdata.hxx"
49 : : #include "drawview.hxx"
50 : : #include "tabvwsh.hxx"
51 : : #include "impex.hxx"
52 : : #include "docsh.hxx"
53 : : #include "transobj.hxx"
54 : : #include "drwtrans.hxx"
55 : : #include "drwlayer.hxx"
56 : :
57 : : //------------------------------------------------------------------------
58 : :
59 : 51 : sal_uInt16 ScGetFontWorkId()
60 : : {
61 : 51 : return SvxFontWorkChildWindow::GetChildWindowId();
62 : : }
63 : :
64 : 0 : sal_Bool ScDrawTextObjectBar::IsNoteEdit()
65 : : {
66 : 0 : return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() );
67 : : }
68 : :
69 : : // wenn kein Text editiert wird, Funktionen wie in drawsh
70 : :
71 : 0 : void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
72 : : {
73 [ # # ]: 0 : ScTabView* pTabView = pViewData->GetView();
74 : 0 : ScDrawView* pView = pTabView->GetScDrawView();
75 : :
76 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
77 [ # # # # : 0 : switch ( nSlot )
# # # ]
78 : : {
79 : : case SID_COPY:
80 : 0 : pView->DoCopy();
81 : 0 : break;
82 : :
83 : : case SID_CUT:
84 : 0 : pView->DoCut();
85 : 0 : pViewData->GetViewShell()->UpdateDrawShell();
86 : 0 : break;
87 : :
88 : : case SID_PASTE:
89 : : case SID_PASTE_SPECIAL:
90 : : case SID_CLIPBOARD_FORMAT_ITEMS:
91 : : case SID_HYPERLINK_SETLINK:
92 : : {
93 : : // cell methods are at cell shell, which is not available if
94 : : // ScDrawTextObjectBar is active
95 : : //! move paste etc. to view shell?
96 : : }
97 : 0 : break;
98 : :
99 : : case SID_SELECTALL:
100 : 0 : pView->MarkAll();
101 : 0 : break;
102 : :
103 : : case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
104 : : case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
105 : : {
106 [ # # ]: 0 : SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 );
107 : : aAttr.Put( SvxWritingModeItem(
108 : : nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
109 : : com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
110 [ # # ][ # # ]: 0 : SDRATTR_TEXTDIRECTION ) );
[ # # ][ # # ]
111 [ # # ]: 0 : pView->SetAttributes( aAttr );
112 [ # # ][ # # ]: 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
113 [ # # ][ # # ]: 0 : rReq.Done( aAttr );
114 : : }
115 : 0 : break;
116 : :
117 : : case SID_ENABLE_HYPHENATION:
118 : : {
119 : 0 : SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
120 [ # # ]: 0 : if( pItem )
121 : : {
122 [ # # ]: 0 : SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
123 : 0 : sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
124 [ # # ][ # # ]: 0 : aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
[ # # ]
125 [ # # ][ # # ]: 0 : pView->SetAttributes( aSet );
126 : : }
127 : 0 : rReq.Done();
128 : : }
129 : 0 : break;
130 : : }
131 : 0 : }
132 : :
133 : 0 : void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
134 : : {
135 : : // cell methods are at cell shell, which is not available if
136 : : // ScDrawTextObjectBar is active -> disable everything
137 : : //! move paste etc. to view shell?
138 : :
139 [ # # ]: 0 : SfxWhichIter aIter(rSet);
140 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
141 [ # # ]: 0 : while (nWhich)
142 : : {
143 [ # # ]: 0 : rSet.DisableItem( nWhich );
144 [ # # ]: 0 : nWhich = aIter.NextWhich();
145 [ # # ]: 0 : }
146 : 0 : }
147 : :
148 : 0 : void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
149 : : {
150 [ # # ]: 0 : ScTabView* pTabView = pViewData->GetView();
151 : 0 : ScDrawView* pView = pTabView->GetScDrawView();
152 : :
153 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
154 [ # # # ]: 0 : switch ( nSlot )
155 : : {
156 : : case SID_FONTWORK:
157 : : {
158 : 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
159 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
160 : :
161 [ # # ]: 0 : if ( rReq.GetArgs() )
162 : : pViewFrm->SetChildWindow( nId,
163 : : ((const SfxBoolItem&)
164 : 0 : (rReq.GetArgs()->Get(SID_FONTWORK))).
165 : 0 : GetValue() );
166 : : else
167 : 0 : pViewFrm->ToggleChildWindow( nId );
168 : :
169 : 0 : pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
170 : 0 : rReq.Done();
171 : : }
172 : 0 : break;
173 : :
174 : : case SID_ATTR_PARA_LEFT_TO_RIGHT:
175 : : case SID_ATTR_PARA_RIGHT_TO_LEFT:
176 : : {
177 : 0 : SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
178 : : EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
179 : : EE_PARA_JUST, EE_PARA_JUST,
180 [ # # ]: 0 : 0 );
181 : 0 : sal_Bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
182 : : aAttr.Put( SvxFrameDirectionItem(
183 : : bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP,
184 [ # # ][ # # ]: 0 : EE_PARA_WRITINGDIR ) );
[ # # ]
185 : : aAttr.Put( SvxAdjustItem(
186 : : bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT,
187 [ # # ][ # # ]: 0 : EE_PARA_JUST ) );
[ # # ]
188 [ # # ]: 0 : pView->SetAttributes( aAttr );
189 [ # # ][ # # ]: 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
190 [ # # ][ # # ]: 0 : rReq.Done(); //! Done(aAttr) ?
191 : :
192 : : }
193 : 0 : break;
194 : : }
195 : 0 : }
196 : :
197 : 0 : void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq)
198 : : {
199 [ # # ]: 0 : ScTabView* pTabView = pViewData->GetView();
200 : 0 : ScDrawView* pDrView = pTabView->GetScDrawView();
201 : 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
202 : :
203 [ # # ][ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
[ # # ]
204 : : {
205 : 0 : const SfxItemSet& rSet = *rReq.GetArgs();
206 : : const SfxPoolItem* pItem;
207 : :
208 [ # # ][ # # ]: 0 : if ( pDrView->IsTextEdit() )
209 [ # # ]: 0 : pDrView->ScEndTextEdit();
210 : :
211 [ # # # # ]: 0 : if ( SFX_ITEM_SET ==
[ # # ]
212 [ # # ]: 0 : rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem)
213 : : && XFTFORM_NONE !=
214 : 0 : ((const XFormTextStdFormItem*) pItem)->GetValue() )
215 : : {
216 : :
217 [ # # ]: 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
218 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
219 : : SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
220 : : (pViewFrm->
221 [ # # ]: 0 : GetChildWindow(nId)->GetWindow());
222 : :
223 : 0 : pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
224 [ # # ][ # # ]: 0 : rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
225 : : ((const XFormTextStdFormItem*) pItem)->
226 [ # # ]: 0 : GetValue());
227 : : }
228 : : else
229 [ # # ]: 0 : pDrView->SetAttributes(rSet);
230 : : }
231 : 0 : }
232 : :
233 : 0 : void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
234 : : {
235 : 0 : const SdrObject* pObj = NULL;
236 : 0 : SvxFontWorkDialog* pDlg = NULL;
237 : 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
238 : 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
239 : 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
240 : :
241 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
242 [ # # ]: 0 : if ( pViewFrm->HasChildWindow(nId) )
243 : 0 : pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
244 : :
245 [ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 )
246 : 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
247 : :
248 [ # # ]: 0 : if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
[ # # # # ]
[ # # ]
249 : 0 : !((SdrTextObj*) pObj)->HasText() )
250 : : {
251 [ # # ]: 0 : if ( pDlg )
252 : 0 : pDlg->SetActive(false);
253 : :
254 : 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
255 : 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
256 : 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
257 : 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
258 : 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
259 : 0 : rSet.DisableItem(XATTR_FORMTXTSTDFORM);
260 : 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
261 : 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
262 : 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
263 : 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
264 : 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
265 : 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
266 : : }
267 : : else
268 : : {
269 [ # # ]: 0 : if ( pDlg )
270 : : {
271 [ # # ]: 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
272 : :
273 [ # # ]: 0 : if ( pDocSh )
274 : : {
275 [ # # ]: 0 : const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
276 : 0 : XColorListRef pColorList;
277 : :
278 [ # # ]: 0 : if ( pItem )
279 [ # # ][ # # ]: 0 : pColorList = ((SvxColorListItem*)pItem)->GetColorList();
280 : :
281 [ # # ]: 0 : pDlg->SetActive();
282 : :
283 [ # # ]: 0 : if ( pColorList.is() )
284 [ # # ]: 0 : pDlg->SetColorList( pColorList );
285 : : }
286 : : }
287 [ # # ]: 0 : SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
288 [ # # ]: 0 : pDrView->GetAttributes(aViewAttr);
289 [ # # ][ # # ]: 0 : rSet.Set(aViewAttr);
290 : : }
291 : 0 : }
292 : :
293 : :
294 : :
295 : :
296 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|