Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob2.cxx
blobdc9d1ba1179ee58cc14e0119989dfad64c5f1797
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 .
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"
48 sal_uInt16 ScGetFontWorkId()
50 return SvxFontWorkChildWindow::GetChildWindowId();
53 bool ScDrawTextObjectBar::IsNoteEdit()
55 return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() );
58 // wenn kein Text editiert wird, Funktionen wie in drawsh
60 void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
62 ScTabView* pTabView = pViewData->GetView();
63 ScDrawView* pView = pTabView->GetScDrawView();
65 sal_uInt16 nSlot = rReq.GetSlot();
66 switch ( nSlot )
68 case SID_COPY:
69 pView->DoCopy();
70 break;
72 case SID_CUT:
73 pView->DoCut();
74 pViewData->GetViewShell()->UpdateDrawShell();
75 break;
77 case SID_PASTE:
78 case SID_PASTE_SPECIAL:
79 case SID_CLIPBOARD_FORMAT_ITEMS:
80 case SID_HYPERLINK_SETLINK:
82 // cell methods are at cell shell, which is not available if
83 // ScDrawTextObjectBar is active
84 //! move paste etc. to view shell?
86 break;
88 case SID_SELECTALL:
89 pView->MarkAll();
90 break;
92 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
93 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
95 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 SDRATTR_TEXTDIRECTION ) );
100 pView->SetAttributes( aAttr );
101 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
102 rReq.Done( aAttr );
104 break;
106 case SID_ENABLE_HYPHENATION:
108 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
109 if( pItem )
111 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
112 bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
113 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
114 pView->SetAttributes( aSet );
116 rReq.Done();
118 break;
122 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
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?
128 SfxWhichIter aIter(rSet);
129 sal_uInt16 nWhich = aIter.FirstWhich();
130 while (nWhich)
132 rSet.DisableItem( nWhich );
133 nWhich = aIter.NextWhich();
137 void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
139 ScTabView* pTabView = pViewData->GetView();
140 ScDrawView* pView = pTabView->GetScDrawView();
142 sal_uInt16 nSlot = rReq.GetSlot();
143 switch ( nSlot )
145 case SID_FONTWORK:
147 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
148 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
150 if ( rReq.GetArgs() )
151 pViewFrm->SetChildWindow( nId,
152 ((const SfxBoolItem&)
153 (rReq.GetArgs()->Get(SID_FONTWORK))).
154 GetValue() );
155 else
156 pViewFrm->ToggleChildWindow( nId );
158 pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
159 rReq.Done();
161 break;
163 case SID_ATTR_PARA_LEFT_TO_RIGHT:
164 case SID_ATTR_PARA_RIGHT_TO_LEFT:
166 SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
167 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
168 EE_PARA_JUST, EE_PARA_JUST,
169 0 );
170 bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
171 aAttr.Put( SvxFrameDirectionItem(
172 bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP,
173 EE_PARA_WRITINGDIR ) );
174 aAttr.Put( SvxAdjustItem(
175 bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT,
176 EE_PARA_JUST ) );
177 pView->SetAttributes( aAttr );
178 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
179 rReq.Done(); //! Done(aAttr) ?
182 break;
186 void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq)
188 ScTabView* pTabView = pViewData->GetView();
189 ScDrawView* pDrView = pTabView->GetScDrawView();
190 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
192 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
194 const SfxItemSet& rSet = *rReq.GetArgs();
196 if ( pDrView->IsTextEdit() )
197 pDrView->ScEndTextEdit();
199 pDrView->SetAttributes(rSet);
203 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
205 const SdrObject* pObj = NULL;
206 SvxFontWorkDialog* pDlg = NULL;
207 ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
208 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
209 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
211 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
212 if ( pViewFrm->HasChildWindow(nId) )
213 pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
215 if ( rMarkList.GetMarkCount() == 1 )
216 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
218 const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
219 const bool bDeactivate(
220 !pObj ||
221 !pTextObj ||
222 !pTextObj->HasText() ||
223 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
225 if(bDeactivate)
227 if ( pDlg )
228 pDlg->SetActive(false);
230 rSet.DisableItem(XATTR_FORMTXTSTYLE);
231 rSet.DisableItem(XATTR_FORMTXTADJUST);
232 rSet.DisableItem(XATTR_FORMTXTDISTANCE);
233 rSet.DisableItem(XATTR_FORMTXTSTART);
234 rSet.DisableItem(XATTR_FORMTXTMIRROR);
235 rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
236 rSet.DisableItem(XATTR_FORMTXTOUTLINE);
237 rSet.DisableItem(XATTR_FORMTXTSHADOW);
238 rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
239 rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
240 rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
242 else
244 if ( pDlg )
246 SfxObjectShell* pDocSh = SfxObjectShell::Current();
248 if ( pDocSh )
250 const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
251 XColorListRef pColorList;
253 if ( pItem )
254 pColorList = ((SvxColorListItem*)pItem)->GetColorList();
256 pDlg->SetActive();
258 if ( pColorList.is() )
259 pDlg->SetColorList( pColorList );
262 SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
263 pDrView->GetAttributes(aViewAttr);
264 rSet.Set(aViewAttr);
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */