tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob2.cxx
blob37629721cff4d5300dacba61ff086292c5a04b8b
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 .
20 #include <editeng/adjustitem.hxx>
21 #include <svx/fontwork.hxx>
22 #include <editeng/eeitem.hxx>
23 #include <editeng/frmdiritem.hxx>
24 #include <editeng/writingmodeitem.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <sfx2/request.hxx>
28 #include <svl/whiter.hxx>
29 #include <svx/svdoashp.hxx>
30 #include <sc.hrc>
31 #include <drtxtob.hxx>
32 #include <viewdata.hxx>
33 #include <drawview.hxx>
34 #include <tabvwsh.hxx>
35 #include <drwlayer.hxx>
37 sal_uInt16 ScGetFontWorkId()
39 return SvxFontWorkChildWindow::GetChildWindowId();
42 bool ScDrawTextObjectBar::IsNoteEdit() const
44 return ScDrawLayer::IsNoteCaption( mrViewData.GetView()->GetScDrawView()->GetTextEditObject() );
47 // if no text edited, functions like in drawsh
49 void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
51 ScTabView* pTabView = mrViewData.GetView();
52 ScDrawView* pView = pTabView->GetScDrawView();
54 sal_uInt16 nSlot = rReq.GetSlot();
55 switch ( nSlot )
57 case SID_COPY:
58 pView->DoCopy();
59 break;
61 case SID_CUT:
62 pView->DoCut();
63 mrViewData.GetViewShell()->UpdateDrawShell();
64 break;
66 case SID_PASTE:
67 case SID_PASTE_SPECIAL:
68 case SID_PASTE_UNFORMATTED:
69 case SID_CLIPBOARD_FORMAT_ITEMS:
70 case SID_HYPERLINK_SETLINK:
72 // cell methods are at cell shell, which is not available if
73 // ScDrawTextObjectBar is active
74 //! move paste etc. to view shell?
76 break;
78 case SID_SELECTALL:
79 pView->MarkAll();
80 break;
82 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
83 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
85 SfxItemSetFixed<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION> aAttr(pView->GetModel().GetItemPool());
86 aAttr.Put( SvxWritingModeItem(
87 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
88 css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL,
89 SDRATTR_TEXTDIRECTION ) );
90 pView->SetAttributes( aAttr );
91 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
92 rReq.Done( aAttr );
94 break;
96 case SID_ENABLE_HYPHENATION:
98 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION);
99 if( pItem )
101 SfxItemSetFixed<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE> aSet( GetPool() );
102 bool bValue = pItem->GetValue();
103 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
104 pView->SetAttributes( aSet );
106 rReq.Done();
108 break;
112 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
114 // cell methods are at cell shell, which is not available if
115 // ScDrawTextObjectBar is active -> disable everything
116 //! move paste etc. to view shell?
118 SfxWhichIter aIter(rSet);
119 sal_uInt16 nWhich = aIter.FirstWhich();
120 while (nWhich)
122 rSet.DisableItem( nWhich );
123 nWhich = aIter.NextWhich();
127 void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
129 ScTabView* pTabView = mrViewData.GetView();
130 ScDrawView* pView = pTabView->GetScDrawView();
132 sal_uInt16 nSlot = rReq.GetSlot();
133 switch ( nSlot )
135 case SID_FONTWORK:
137 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
138 SfxViewFrame& rViewFrm = mrViewData.GetViewShell()->GetViewFrame();
140 if ( rReq.GetArgs() )
141 rViewFrm.SetChildWindow( nId,
142 static_cast<const SfxBoolItem&>(
143 (rReq.GetArgs()->Get(SID_FONTWORK))).
144 GetValue() );
145 else
146 rViewFrm.ToggleChildWindow( nId );
148 rViewFrm.GetBindings().Invalidate( SID_FONTWORK );
149 rReq.Done();
151 break;
153 case SID_ATTR_PARA_LEFT_TO_RIGHT:
154 case SID_ATTR_PARA_RIGHT_TO_LEFT:
156 SfxItemSetFixed<EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
157 EE_PARA_JUST, EE_PARA_JUST> aAttr(pView->GetModel().GetItemPool());
158 bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
159 aAttr.Put( SvxFrameDirectionItem(
160 bLeft ? SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB,
161 EE_PARA_WRITINGDIR ) );
162 aAttr.Put( SvxAdjustItem(
163 bLeft ? SvxAdjust::Left : SvxAdjust::Right,
164 EE_PARA_JUST ) );
165 pView->SetAttributes( aAttr );
166 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
167 rReq.Done(); //! Done(aAttr) ?
170 break;
174 void ScDrawTextObjectBar::ExecFormText(const SfxRequest& rReq)
176 ScTabView* pTabView = mrViewData.GetView();
177 ScDrawView* pDrView = pTabView->GetScDrawView();
178 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
180 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
182 const SfxItemSet& rSet = *rReq.GetArgs();
184 if ( pDrView->IsTextEdit() )
185 pDrView->ScEndTextEdit();
187 pDrView->SetAttributes(rSet);
191 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
193 const SdrObject* pObj = nullptr;
194 ScDrawView* pDrView = mrViewData.GetView()->GetScDrawView();
195 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
197 if ( rMarkList.GetMarkCount() == 1 )
198 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
200 const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj);
201 const bool bDeactivate(
202 !pObj ||
203 !pTextObj ||
204 !pTextObj->HasText() ||
205 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
207 if(bDeactivate)
209 rSet.DisableItem(XATTR_FORMTXTSTYLE);
210 rSet.DisableItem(XATTR_FORMTXTADJUST);
211 rSet.DisableItem(XATTR_FORMTXTDISTANCE);
212 rSet.DisableItem(XATTR_FORMTXTSTART);
213 rSet.DisableItem(XATTR_FORMTXTMIRROR);
214 rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
215 rSet.DisableItem(XATTR_FORMTXTOUTLINE);
216 rSet.DisableItem(XATTR_FORMTXTSHADOW);
217 rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
218 rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
219 rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
221 else
223 SfxItemSet aViewAttr(pDrView->GetModel().GetItemPool());
224 pDrView->GetAttributes(aViewAttr);
225 rSet.Set(aViewAttr);
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */