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 
20 #include <editeng/adjustitem.hxx>
21 #include <svx/fontwork.hxx>
22 #include <editeng/eeitem.hxx>
23 #include <editeng/frmdiritem.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 {
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  {
86  aAttr.Put( SvxWritingModeItem(
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  {
156  SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
157  svl::Items<EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
158  EE_PARA_JUST, EE_PARA_JUST>{} );
159  bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
160  aAttr.Put( SvxFrameDirectionItem(
161  bLeft ? SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB,
162  EE_PARA_WRITINGDIR ) );
163  aAttr.Put( SvxAdjustItem(
164  bLeft ? SvxAdjust::Left : SvxAdjust::Right,
165  EE_PARA_JUST ) );
166  pView->SetAttributes( aAttr );
168  rReq.Done();
169 
170  }
171  break;
172  }
173 }
174 
176 {
177  ScTabView* pTabView = mrViewData.GetView();
178  ScDrawView* pDrView = pTabView->GetScDrawView();
179  const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
180 
181  if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
182  {
183  const SfxItemSet& rSet = *rReq.GetArgs();
184 
185  if ( pDrView->IsTextEdit() )
186  pDrView->ScEndTextEdit();
187 
188  pDrView->SetAttributes(rSet);
189  }
190 }
191 
193 {
194  const SdrObject* pObj = nullptr;
195  ScDrawView* pDrView = mrViewData.GetView()->GetScDrawView();
196  const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
197 
198  if ( rMarkList.GetMarkCount() == 1 )
199  pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
200 
201  const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
202  const bool bDeactivate(
203  !pObj ||
204  !pTextObj ||
205  !pTextObj->HasText() ||
206  dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
207 
208  if(bDeactivate)
209  {
221  }
222  else
223  {
224  SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
225  pDrView->GetAttributes(aViewAttr);
226  rSet.Set(aViewAttr);
227  }
228 }
229 
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool GetValue() const
constexpr TypedWhichId< XFormTextHideFormItem > XATTR_FORMTXTHIDEFORM(XATTR_TEXT_FIRST+10)
void UpdateDrawShell()
Definition: tabvwsh4.cxx:554
bool IsNoteEdit() const
Definition: drtxtob2.cxx:42
size_t GetMarkCount() const
bool Set(const SfxItemSet &, bool bDeep=true)
std::string GetValue
void ExecuteExtra(SfxRequest &rReq)
Definition: drtxtob2.cxx:127
constexpr TypedWhichId< XFormTextOutlineItem > XATTR_FORMTXTOUTLINE(XATTR_TEXT_FIRST+5)
void MarkAll()
SdrTextObj * GetTextEditObject() const
sal_Int16 nId
sal_uInt16 FirstWhich()
void ExecFormText(const SfxRequest &rReq)
Definition: drtxtob2.cxx:175
void Done(bool bRemove=false)
SdrMark * GetMark(size_t nNum) const
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+15)
void GetFormTextState(SfxItemSet &rSet)
Definition: drtxtob2.cxx:192
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual bool HasText() const override
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
constexpr TypedWhichId< XFormTextDistanceItem > XATTR_FORMTXTDISTANCE(XATTR_TEXT_FIRST+2)
sal_uInt16 NextWhich()
void ToggleChildWindow(sal_uInt16)
ScViewData & mrViewData
Definition: drtxtob.hxx:38
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3074
constexpr TypedWhichId< XFormTextStyleItem > XATTR_FORMTXTSTYLE(XATTR_TEXT_FIRST)
SfxItemPool & GetPool() const
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
SdrObject * GetMarkedSdrObj() const
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
static void GetGlobalClipState(SfxItemSet &rSet)
Definition: drtxtob2.cxx:112
void InvalidateDrawTextAttrs()
Definition: drawview.cxx:160
SfxBindings & GetBindings()
const SdrMarkList & GetMarkedObjectList() const
const T * GetArg(sal_uInt16 nSlotId) const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
constexpr TypedWhichId< XFormTextShadowXValItem > XATTR_FORMTXTSHDWXVAL(XATTR_TEXT_FIRST+8)
constexpr TypedWhichId< XFormTextShadowItem > XATTR_FORMTXTSHADOW(XATTR_TEXT_FIRST+6)
constexpr TypedWhichId< XFormTextAdjustItem > XATTR_FORMTXTADJUST(XATTR_TEXT_FIRST+1)
void ExecuteGlobal(SfxRequest &rReq)
Definition: drtxtob2.cxx:49
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
void DoCut()
Definition: drawview.cxx:282
sal_uInt16 GetSlot() const
constexpr TypedWhichId< XFormTextStartItem > XATTR_FORMTXTSTART(XATTR_TEXT_FIRST+3)
virtual bool IsTextEdit() const final override
void DisableItem(sal_uInt16 nWhich)
ScDrawView * GetScDrawView()
Definition: tabview.hxx:340
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< XFormTextShadowYValItem > XATTR_FORMTXTSHDWYVAL(XATTR_TEXT_FIRST+9)
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:892
static bool IsNoteCaption(SdrObject *pObj)
Returns true, if the passed object is the caption of a cell note.
Definition: drwlayer.cxx:2309
const SfxItemPool & GetItemPool() const
constexpr TypedWhichId< XFormTextMirrorItem > XATTR_FORMTXTMIRROR(XATTR_TEXT_FIRST+4)
void DoCopy()
Definition: drawvie4.cxx:332
sal_uInt16 ScGetFontWorkId()
Definition: drtxtob2.cxx:37
SdrModel * GetModel() const
constexpr TypedWhichId< XFormTextShadowColorItem > XATTR_FORMTXTSHDWCOLOR(XATTR_TEXT_FIRST+7)