/src/libreoffice/sc/source/ui/drawfunc/drtxtob2.cxx
Line | Count | Source |
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 <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> |
36 | | |
37 | | sal_uInt16 ScGetFontWorkId() |
38 | 11 | { |
39 | 11 | return SvxFontWorkChildWindow::GetChildWindowId(); |
40 | 11 | } |
41 | | |
42 | | bool ScDrawTextObjectBar::IsNoteEdit() const |
43 | 0 | { |
44 | 0 | return ScDrawLayer::IsNoteCaption( mrViewData.GetView()->GetScDrawView()->GetTextEditObject() ); |
45 | 0 | } |
46 | | |
47 | | // if no text edited, functions like in drawsh |
48 | | |
49 | | void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq ) |
50 | 0 | { |
51 | 0 | ScTabView* pTabView = mrViewData.GetView(); |
52 | 0 | ScDrawView* pView = pTabView->GetScDrawView(); |
53 | |
|
54 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
55 | 0 | switch ( nSlot ) |
56 | 0 | { |
57 | 0 | case SID_COPY: |
58 | 0 | pView->DoCopy(); |
59 | 0 | break; |
60 | | |
61 | 0 | case SID_CUT: |
62 | 0 | pView->DoCut(); |
63 | 0 | mrViewData.GetViewShell()->UpdateDrawShell(); |
64 | 0 | break; |
65 | | |
66 | 0 | case SID_PASTE: |
67 | 0 | case SID_PASTE_SPECIAL: |
68 | 0 | case SID_PASTE_UNFORMATTED: |
69 | 0 | case SID_CLIPBOARD_FORMAT_ITEMS: |
70 | 0 | case SID_HYPERLINK_SETLINK: |
71 | 0 | { |
72 | | // cell methods are at cell shell, which is not available if |
73 | | // ScDrawTextObjectBar is active |
74 | | //! move paste etc. to view shell? |
75 | 0 | } |
76 | 0 | break; |
77 | | |
78 | 0 | case SID_SELECTALL: |
79 | 0 | pView->MarkAll(); |
80 | 0 | break; |
81 | | |
82 | 0 | case SID_TEXTDIRECTION_LEFT_TO_RIGHT: |
83 | 0 | case SID_TEXTDIRECTION_TOP_TO_BOTTOM: |
84 | 0 | { |
85 | 0 | SfxItemSetFixed<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION> aAttr(pView->GetModel().GetItemPool()); |
86 | 0 | aAttr.Put( SvxWritingModeItem( |
87 | 0 | nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? |
88 | 0 | css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL, |
89 | 0 | SDRATTR_TEXTDIRECTION ) ); |
90 | 0 | pView->SetAttributes( aAttr ); |
91 | 0 | mrViewData.GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled |
92 | 0 | rReq.Done( aAttr ); |
93 | 0 | } |
94 | 0 | break; |
95 | | |
96 | 0 | case SID_ENABLE_HYPHENATION: |
97 | 0 | { |
98 | 0 | const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION); |
99 | 0 | if( pItem ) |
100 | 0 | { |
101 | 0 | SfxItemSetFixed<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE> aSet( GetPool() ); |
102 | 0 | bool bValue = pItem->GetValue(); |
103 | 0 | aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); |
104 | 0 | pView->SetAttributes( aSet ); |
105 | 0 | } |
106 | 0 | rReq.Done(); |
107 | 0 | } |
108 | 0 | break; |
109 | 0 | } |
110 | 0 | } |
111 | | |
112 | | void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet ) |
113 | 0 | { |
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? |
117 | |
|
118 | 0 | SfxWhichIter aIter(rSet); |
119 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
120 | 0 | while (nWhich) |
121 | 0 | { |
122 | 0 | rSet.DisableItem( nWhich ); |
123 | 0 | nWhich = aIter.NextWhich(); |
124 | 0 | } |
125 | 0 | } |
126 | | |
127 | | void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq ) |
128 | 0 | { |
129 | 0 | ScTabView* pTabView = mrViewData.GetView(); |
130 | 0 | ScDrawView* pView = pTabView->GetScDrawView(); |
131 | |
|
132 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
133 | 0 | switch ( nSlot ) |
134 | 0 | { |
135 | 0 | case SID_FONTWORK: |
136 | 0 | { |
137 | 0 | sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); |
138 | 0 | SfxViewFrame& rViewFrm = mrViewData.GetViewShell()->GetViewFrame(); |
139 | |
|
140 | 0 | if ( rReq.GetArgs() ) |
141 | 0 | rViewFrm.SetChildWindow( nId, |
142 | 0 | static_cast<const SfxBoolItem&>( |
143 | 0 | (rReq.GetArgs()->Get(SID_FONTWORK))). |
144 | 0 | GetValue() ); |
145 | 0 | else |
146 | 0 | rViewFrm.ToggleChildWindow( nId ); |
147 | |
|
148 | 0 | rViewFrm.GetBindings().Invalidate( SID_FONTWORK ); |
149 | 0 | rReq.Done(); |
150 | 0 | } |
151 | 0 | break; |
152 | | |
153 | 0 | case SID_ATTR_PARA_LEFT_TO_RIGHT: |
154 | 0 | case SID_ATTR_PARA_RIGHT_TO_LEFT: |
155 | 0 | { |
156 | 0 | SfxItemSetFixed<EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, |
157 | 0 | EE_PARA_JUST, EE_PARA_JUST> aAttr(pView->GetModel().GetItemPool()); |
158 | 0 | bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ); |
159 | 0 | aAttr.Put( SvxFrameDirectionItem( |
160 | 0 | bLeft ? SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB, |
161 | 0 | EE_PARA_WRITINGDIR ) ); |
162 | 0 | aAttr.Put( SvxAdjustItem( |
163 | 0 | bLeft ? SvxAdjust::Left : SvxAdjust::Right, |
164 | 0 | EE_PARA_JUST ) ); |
165 | 0 | pView->SetAttributes( aAttr ); |
166 | 0 | mrViewData.GetScDrawView()->InvalidateDrawTextAttrs(); |
167 | 0 | rReq.Done(); //! Done(aAttr) ? |
168 | |
|
169 | 0 | } |
170 | 0 | break; |
171 | 0 | } |
172 | 0 | } |
173 | | |
174 | | void ScDrawTextObjectBar::ExecFormText(const SfxRequest& rReq) |
175 | 0 | { |
176 | 0 | ScTabView* pTabView = mrViewData.GetView(); |
177 | 0 | ScDrawView* pDrView = pTabView->GetScDrawView(); |
178 | 0 | const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); |
179 | |
|
180 | 0 | if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) |
181 | 0 | { |
182 | 0 | const SfxItemSet& rSet = *rReq.GetArgs(); |
183 | |
|
184 | 0 | if ( pDrView->IsTextEdit() ) |
185 | 0 | pDrView->ScEndTextEdit(); |
186 | |
|
187 | 0 | pDrView->SetAttributes(rSet); |
188 | 0 | } |
189 | 0 | } |
190 | | |
191 | | void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet) |
192 | 0 | { |
193 | 0 | const SdrObject* pObj = nullptr; |
194 | 0 | ScDrawView* pDrView = mrViewData.GetView()->GetScDrawView(); |
195 | 0 | const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); |
196 | |
|
197 | 0 | if ( rMarkList.GetMarkCount() == 1 ) |
198 | 0 | pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); |
199 | |
|
200 | 0 | const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); |
201 | 0 | const bool bDeactivate( |
202 | 0 | !pObj || |
203 | 0 | !pTextObj || |
204 | 0 | !pTextObj->HasText() || |
205 | 0 | dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes |
206 | |
|
207 | 0 | if(bDeactivate) |
208 | 0 | { |
209 | 0 | rSet.DisableItem(XATTR_FORMTXTSTYLE); |
210 | 0 | rSet.DisableItem(XATTR_FORMTXTADJUST); |
211 | 0 | rSet.DisableItem(XATTR_FORMTXTDISTANCE); |
212 | 0 | rSet.DisableItem(XATTR_FORMTXTSTART); |
213 | 0 | rSet.DisableItem(XATTR_FORMTXTMIRROR); |
214 | 0 | rSet.DisableItem(XATTR_FORMTXTHIDEFORM); |
215 | 0 | rSet.DisableItem(XATTR_FORMTXTOUTLINE); |
216 | 0 | rSet.DisableItem(XATTR_FORMTXTSHADOW); |
217 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); |
218 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); |
219 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); |
220 | 0 | } |
221 | 0 | else |
222 | 0 | { |
223 | 0 | SfxItemSet aViewAttr(pDrView->GetModel().GetItemPool()); |
224 | 0 | pDrView->GetAttributes(aViewAttr); |
225 | 0 | rSet.Set(aViewAttr); |
226 | 0 | } |
227 | 0 | } |
228 | | |
229 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |