LibreOffice Module sc (master) 1
drtxtob2.cxx
Go to the documentation of this file.
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
21#include <svx/fontwork.hxx>
22#include <editeng/eeitem.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
37sal_uInt16 ScGetFontWorkId()
38{
39 return SvxFontWorkChildWindow::GetChildWindowId();
40}
41
43{
45}
46
47// if no text edited, functions like in drawsh
48
50{
51 ScTabView* pTabView = mrViewData.GetView();
52 ScDrawView* pView = pTabView->GetScDrawView();
53
54 sal_uInt16 nSlot = rReq.GetSlot();
55 switch ( nSlot )
56 {
57 case SID_COPY:
58 pView->DoCopy();
59 break;
60
61 case SID_CUT:
62 pView->DoCut();
64 break;
65
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:
71 {
72 // cell methods are at cell shell, which is not available if
73 // ScDrawTextObjectBar is active
75 }
76 break;
77
78 case SID_SELECTALL:
79 pView->MarkAll();
80 break;
81
82 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
83 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
84 {
87 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
88 css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL,
90 pView->SetAttributes( aAttr );
91 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
92 rReq.Done( aAttr );
93 }
94 break;
95
96 case SID_ENABLE_HYPHENATION:
97 {
98 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION);
99 if( pItem )
100 {
102 bool bValue = pItem->GetValue();
103 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
104 pView->SetAttributes( aSet );
105 }
106 rReq.Done();
107 }
108 break;
109 }
110}
111
113{
114 // cell methods are at cell shell, which is not available if
115 // ScDrawTextObjectBar is active -> disable everything
117
118 SfxWhichIter aIter(rSet);
119 sal_uInt16 nWhich = aIter.FirstWhich();
120 while (nWhich)
121 {
122 rSet.DisableItem( nWhich );
123 nWhich = aIter.NextWhich();
124 }
125}
126
128{
129 ScTabView* pTabView = mrViewData.GetView();
130 ScDrawView* pView = pTabView->GetScDrawView();
131
132 sal_uInt16 nSlot = rReq.GetSlot();
133 switch ( nSlot )
134 {
135 case SID_FONTWORK:
136 {
137 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
139
140 if ( rReq.GetArgs() )
141 pViewFrm->SetChildWindow( nId,
142 static_cast<const SfxBoolItem&>(
143 (rReq.GetArgs()->Get(SID_FONTWORK))).
144 GetValue() );
145 else
146 pViewFrm->ToggleChildWindow( nId );
147
148 pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
149 rReq.Done();
150 }
151 break;
152
153 case SID_ATTR_PARA_LEFT_TO_RIGHT:
154 case SID_ATTR_PARA_RIGHT_TO_LEFT:
155 {
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,
162 aAttr.Put( SvxAdjustItem(
163 bLeft ? SvxAdjust::Left : SvxAdjust::Right,
164 EE_PARA_JUST ) );
165 pView->SetAttributes( aAttr );
167 rReq.Done();
168
169 }
170 break;
171 }
172}
173
175{
176 ScTabView* pTabView = mrViewData.GetView();
177 ScDrawView* pDrView = pTabView->GetScDrawView();
178 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
179
180 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
181 {
182 const SfxItemSet& rSet = *rReq.GetArgs();
183
184 if ( pDrView->IsTextEdit() )
185 pDrView->ScEndTextEdit();
186
187 pDrView->SetAttributes(rSet);
188 }
189}
190
192{
193 const SdrObject* pObj = nullptr;
195 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
196
197 if ( rMarkList.GetMarkCount() == 1 )
198 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
199
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
206
207 if(bDeactivate)
208 {
220 }
221 else
222 {
223 SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
224 pDrView->GetAttributes(aViewAttr);
225 rSet.Set(aViewAttr);
226 }
227}
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsNoteCaption(SdrObject *pObj)
Returns true, if the passed object is the caption of a cell note.
Definition: drwlayer.cxx:2630
void ExecFormText(const SfxRequest &rReq)
Definition: drtxtob2.cxx:174
static void GetGlobalClipState(SfxItemSet &rSet)
Definition: drtxtob2.cxx:112
void ExecuteGlobal(SfxRequest &rReq)
Definition: drtxtob2.cxx:49
bool IsNoteEdit() const
Definition: drtxtob2.cxx:42
void ExecuteExtra(SfxRequest &rReq)
Definition: drtxtob2.cxx:127
ScViewData & mrViewData
Definition: drtxtob.hxx:37
void GetFormTextState(SfxItemSet &rSet)
Definition: drtxtob2.cxx:191
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:896
void InvalidateDrawTextAttrs()
Definition: drawview.cxx:162
void DoCopy()
Definition: drawvie4.cxx:332
void DoCut()
Definition: drawview.cxx:284
void UpdateDrawShell()
Definition: tabvwsh4.cxx:571
ScDrawView * GetScDrawView()
Definition: tabview.hxx:343
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3169
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
SdrTextObj * GetTextEditObject() const
virtual bool IsTextEdit() const final override
SdrModel * GetModel() const
virtual bool HasText() const override
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
void MarkAll()
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
void Invalidate(sal_uInt16 nId)
bool GetValue() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool Set(const SfxItemSet &, bool bDeep=true)
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void Done(bool bRemove=false)
SfxItemPool & GetPool() const
void ToggleChildWindow(sal_uInt16)
SfxBindings & GetBindings()
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
SfxViewFrame * GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
sal_uInt16 ScGetFontWorkId()
Definition: drtxtob2.cxx:37
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
sal_Int16 nId
const char GetValue[]
static SfxItemSet & rSet
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
constexpr TypedWhichId< XFormTextMirrorItem > XATTR_FORMTXTMIRROR(XATTR_TEXT_FIRST+4)
constexpr TypedWhichId< XFormTextStyleItem > XATTR_FORMTXTSTYLE(XATTR_TEXT_FIRST)
constexpr TypedWhichId< XFormTextStartItem > XATTR_FORMTXTSTART(XATTR_TEXT_FIRST+3)
constexpr TypedWhichId< XFormTextShadowYValItem > XATTR_FORMTXTSHDWYVAL(XATTR_TEXT_FIRST+9)
constexpr TypedWhichId< XFormTextHideFormItem > XATTR_FORMTXTHIDEFORM(XATTR_TEXT_FIRST+10)
constexpr TypedWhichId< XFormTextDistanceItem > XATTR_FORMTXTDISTANCE(XATTR_TEXT_FIRST+2)
constexpr TypedWhichId< XFormTextShadowItem > XATTR_FORMTXTSHADOW(XATTR_TEXT_FIRST+6)
constexpr TypedWhichId< XFormTextOutlineItem > XATTR_FORMTXTOUTLINE(XATTR_TEXT_FIRST+5)
constexpr TypedWhichId< XFormTextShadowXValItem > XATTR_FORMTXTSHDWXVAL(XATTR_TEXT_FIRST+8)
constexpr TypedWhichId< XFormTextShadowColorItem > XATTR_FORMTXTSHDWCOLOR(XATTR_TEXT_FIRST+7)
constexpr TypedWhichId< XFormTextAdjustItem > XATTR_FORMTXTADJUST(XATTR_TEXT_FIRST+1)