1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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( pViewData
->GetView()->GetSdrView()->GetTextEditObject() );
47 // if no text edited, functions like in drawsh
49 void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest
&rReq
)
51 ScTabView
* pTabView
= pViewData
->GetView();
52 ScDrawView
* pView
= pTabView
->GetScDrawView();
54 sal_uInt16 nSlot
= rReq
.GetSlot();
63 pViewData
->GetViewShell()->UpdateDrawShell();
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?
82 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
83 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
85 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(), svl::Items
<SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
>{} );
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 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
96 case SID_ENABLE_HYPHENATION
:
98 const SfxBoolItem
* pItem
= rReq
.GetArg
<SfxBoolItem
>(SID_ENABLE_HYPHENATION
);
101 SfxItemSet
aSet( GetPool(), svl::Items
<EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
>{} );
102 bool bValue
= pItem
->GetValue();
103 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, bValue
) );
104 pView
->SetAttributes( aSet
);
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();
122 rSet
.DisableItem( nWhich
);
123 nWhich
= aIter
.NextWhich();
127 void ScDrawTextObjectBar::ExecuteExtra( SfxRequest
&rReq
)
129 ScTabView
* pTabView
= pViewData
->GetView();
130 ScDrawView
* pView
= pTabView
->GetScDrawView();
132 sal_uInt16 nSlot
= rReq
.GetSlot();
137 sal_uInt16 nId
= SvxFontWorkChildWindow::GetChildWindowId();
138 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
140 if ( rReq
.GetArgs() )
141 pViewFrm
->SetChildWindow( nId
,
142 static_cast<const SfxBoolItem
&>(
143 (rReq
.GetArgs()->Get(SID_FONTWORK
))).
146 pViewFrm
->ToggleChildWindow( nId
);
148 pViewFrm
->GetBindings().Invalidate( SID_FONTWORK
);
153 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
154 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
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
,
166 pView
->SetAttributes( aAttr
);
167 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
168 rReq
.Done(); //! Done(aAttr) ?
175 void ScDrawTextObjectBar::ExecFormText(const SfxRequest
& rReq
)
177 ScTabView
* pTabView
= pViewData
->GetView();
178 ScDrawView
* pDrView
= pTabView
->GetScDrawView();
179 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
181 if ( rMarkList
.GetMarkCount() == 1 && rReq
.GetArgs() )
183 const SfxItemSet
& rSet
= *rReq
.GetArgs();
185 if ( pDrView
->IsTextEdit() )
186 pDrView
->ScEndTextEdit();
188 pDrView
->SetAttributes(rSet
);
192 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet
& rSet
)
194 const SdrObject
* pObj
= nullptr;
195 ScDrawView
* pDrView
= pViewData
->GetView()->GetScDrawView();
196 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
198 if ( rMarkList
.GetMarkCount() == 1 )
199 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
201 const SdrTextObj
* pTextObj
= dynamic_cast< const SdrTextObj
* >(pObj
);
202 const bool bDeactivate(
205 !pTextObj
->HasText() ||
206 dynamic_cast< const SdrObjCustomShape
* >(pObj
)); // #121538# no FontWork for CustomShapes
210 rSet
.DisableItem(XATTR_FORMTXTSTYLE
);
211 rSet
.DisableItem(XATTR_FORMTXTADJUST
);
212 rSet
.DisableItem(XATTR_FORMTXTDISTANCE
);
213 rSet
.DisableItem(XATTR_FORMTXTSTART
);
214 rSet
.DisableItem(XATTR_FORMTXTMIRROR
);
215 rSet
.DisableItem(XATTR_FORMTXTHIDEFORM
);
216 rSet
.DisableItem(XATTR_FORMTXTOUTLINE
);
217 rSet
.DisableItem(XATTR_FORMTXTSHADOW
);
218 rSet
.DisableItem(XATTR_FORMTXTSHDWCOLOR
);
219 rSet
.DisableItem(XATTR_FORMTXTSHDWXVAL
);
220 rSet
.DisableItem(XATTR_FORMTXTSHDWYVAL
);
224 SfxItemSet
aViewAttr(pDrView
->GetModel()->GetItemPool());
225 pDrView
->GetAttributes(aViewAttr
);
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */