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 :
21 : #include "scitems.hxx"
22 : #include <editeng/adjustitem.hxx>
23 : #include <svx/drawitem.hxx>
24 : #include <svx/fontwork.hxx>
25 : #include <editeng/frmdiritem.hxx>
26 : #include <editeng/outlobj.hxx>
27 : #include <svx/svdocapt.hxx>
28 : #include <svx/xtextit.hxx>
29 : #include <editeng/writingmodeitem.hxx>
30 : #include <sfx2/bindings.hxx>
31 : #include <sfx2/viewfrm.hxx>
32 : #include <sfx2/objsh.hxx>
33 : #include <sfx2/request.hxx>
34 : #include <sot/formats.hxx>
35 : #include <svl/whiter.hxx>
36 : #include <svx/svdoashp.hxx>
37 : #include "sc.hrc"
38 : #include "drtxtob.hxx"
39 : #include "viewdata.hxx"
40 : #include "drawview.hxx"
41 : #include "tabvwsh.hxx"
42 : #include "impex.hxx"
43 : #include "docsh.hxx"
44 : #include "transobj.hxx"
45 : #include "drwtrans.hxx"
46 : #include "drwlayer.hxx"
47 :
48 0 : sal_uInt16 ScGetFontWorkId()
49 : {
50 0 : return SvxFontWorkChildWindow::GetChildWindowId();
51 : }
52 :
53 0 : bool ScDrawTextObjectBar::IsNoteEdit()
54 : {
55 0 : return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() );
56 : }
57 :
58 : // wenn kein Text editiert wird, Funktionen wie in drawsh
59 :
60 0 : void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
61 : {
62 0 : ScTabView* pTabView = pViewData->GetView();
63 0 : ScDrawView* pView = pTabView->GetScDrawView();
64 :
65 0 : sal_uInt16 nSlot = rReq.GetSlot();
66 0 : switch ( nSlot )
67 : {
68 : case SID_COPY:
69 0 : pView->DoCopy();
70 0 : break;
71 :
72 : case SID_CUT:
73 0 : pView->DoCut();
74 0 : pViewData->GetViewShell()->UpdateDrawShell();
75 0 : break;
76 :
77 : case SID_PASTE:
78 : case SID_PASTE_SPECIAL:
79 : case SID_CLIPBOARD_FORMAT_ITEMS:
80 : case SID_HYPERLINK_SETLINK:
81 : {
82 : // cell methods are at cell shell, which is not available if
83 : // ScDrawTextObjectBar is active
84 : //! move paste etc. to view shell?
85 : }
86 0 : break;
87 :
88 : case SID_SELECTALL:
89 0 : pView->MarkAll();
90 0 : break;
91 :
92 : case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
93 : case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
94 : {
95 0 : SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 );
96 : aAttr.Put( SvxWritingModeItem(
97 : nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
98 : com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
99 0 : SDRATTR_TEXTDIRECTION ) );
100 0 : pView->SetAttributes( aAttr );
101 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
102 0 : rReq.Done( aAttr );
103 : }
104 0 : break;
105 :
106 : case SID_ENABLE_HYPHENATION:
107 : {
108 0 : SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
109 0 : if( pItem )
110 : {
111 0 : SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
112 0 : sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
113 0 : aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
114 0 : pView->SetAttributes( aSet );
115 : }
116 0 : rReq.Done();
117 : }
118 0 : break;
119 : }
120 0 : }
121 :
122 0 : void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
123 : {
124 : // cell methods are at cell shell, which is not available if
125 : // ScDrawTextObjectBar is active -> disable everything
126 : //! move paste etc. to view shell?
127 :
128 0 : SfxWhichIter aIter(rSet);
129 0 : sal_uInt16 nWhich = aIter.FirstWhich();
130 0 : while (nWhich)
131 : {
132 0 : rSet.DisableItem( nWhich );
133 0 : nWhich = aIter.NextWhich();
134 0 : }
135 0 : }
136 :
137 0 : void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
138 : {
139 0 : ScTabView* pTabView = pViewData->GetView();
140 0 : ScDrawView* pView = pTabView->GetScDrawView();
141 :
142 0 : sal_uInt16 nSlot = rReq.GetSlot();
143 0 : switch ( nSlot )
144 : {
145 : case SID_FONTWORK:
146 : {
147 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
148 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
149 :
150 0 : if ( rReq.GetArgs() )
151 : pViewFrm->SetChildWindow( nId,
152 : ((const SfxBoolItem&)
153 0 : (rReq.GetArgs()->Get(SID_FONTWORK))).
154 0 : GetValue() );
155 : else
156 0 : pViewFrm->ToggleChildWindow( nId );
157 :
158 0 : pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
159 0 : rReq.Done();
160 : }
161 0 : break;
162 :
163 : case SID_ATTR_PARA_LEFT_TO_RIGHT:
164 : case SID_ATTR_PARA_RIGHT_TO_LEFT:
165 : {
166 0 : SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
167 : EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
168 : EE_PARA_JUST, EE_PARA_JUST,
169 0 : 0 );
170 0 : sal_Bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
171 : aAttr.Put( SvxFrameDirectionItem(
172 : bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP,
173 0 : EE_PARA_WRITINGDIR ) );
174 : aAttr.Put( SvxAdjustItem(
175 : bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT,
176 0 : EE_PARA_JUST ) );
177 0 : pView->SetAttributes( aAttr );
178 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
179 0 : rReq.Done(); //! Done(aAttr) ?
180 :
181 : }
182 0 : break;
183 : }
184 0 : }
185 :
186 0 : void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq)
187 : {
188 0 : ScTabView* pTabView = pViewData->GetView();
189 0 : ScDrawView* pDrView = pTabView->GetScDrawView();
190 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
191 :
192 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
193 : {
194 0 : const SfxItemSet& rSet = *rReq.GetArgs();
195 :
196 0 : if ( pDrView->IsTextEdit() )
197 0 : pDrView->ScEndTextEdit();
198 :
199 0 : pDrView->SetAttributes(rSet);
200 : }
201 0 : }
202 :
203 0 : void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
204 : {
205 0 : const SdrObject* pObj = NULL;
206 0 : SvxFontWorkDialog* pDlg = NULL;
207 0 : ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
208 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
209 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
210 :
211 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
212 0 : if ( pViewFrm->HasChildWindow(nId) )
213 0 : pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
214 :
215 0 : if ( rMarkList.GetMarkCount() == 1 )
216 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
217 :
218 0 : const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
219 : const bool bDeactivate(
220 0 : !pObj ||
221 0 : !pTextObj ||
222 0 : !pTextObj->HasText() ||
223 0 : dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
224 :
225 0 : if(bDeactivate)
226 : {
227 0 : if ( pDlg )
228 0 : pDlg->SetActive(false);
229 :
230 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
231 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
232 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
233 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
234 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
235 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
236 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
237 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
238 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
239 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
240 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
241 : }
242 : else
243 : {
244 0 : if ( pDlg )
245 : {
246 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
247 :
248 0 : if ( pDocSh )
249 : {
250 0 : const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
251 0 : XColorListRef pColorList;
252 :
253 0 : if ( pItem )
254 0 : pColorList = ((SvxColorListItem*)pItem)->GetColorList();
255 :
256 0 : pDlg->SetActive();
257 :
258 0 : if ( pColorList.is() )
259 0 : pDlg->SetColorList( pColorList );
260 : }
261 : }
262 0 : SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
263 0 : pDrView->GetAttributes(aViewAttr);
264 0 : rSet.Set(aViewAttr);
265 : }
266 0 : }
267 :
268 :
269 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|