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 "scitems.hxx"
21 #include <editeng/adjustitem.hxx>
22 #include <svx/drawitem.hxx>
23 #include <svx/fontwork.hxx>
24 #include <editeng/frmdiritem.hxx>
25 #include <editeng/outlobj.hxx>
26 #include <svx/svdocapt.hxx>
27 #include <svx/xtextit.hxx>
28 #include <editeng/writingmodeitem.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <sfx2/objsh.hxx>
32 #include <sfx2/request.hxx>
33 #include <sot/formats.hxx>
34 #include <svl/whiter.hxx>
35 #include <svx/svdoashp.hxx>
37 #include "drtxtob.hxx"
38 #include "viewdata.hxx"
39 #include "drawview.hxx"
40 #include "tabvwsh.hxx"
43 #include "transobj.hxx"
44 #include "drwtrans.hxx"
45 #include "drwlayer.hxx"
47 sal_uInt16
ScGetFontWorkId()
49 return SvxFontWorkChildWindow::GetChildWindowId();
52 bool ScDrawTextObjectBar::IsNoteEdit()
54 return ScDrawLayer::IsNoteCaption( pViewData
->GetView()->GetSdrView()->GetTextEditObject() );
57 // wenn kein Text editiert wird, Funktionen wie in drawsh
59 void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest
&rReq
)
61 ScTabView
* pTabView
= pViewData
->GetView();
62 ScDrawView
* pView
= pTabView
->GetScDrawView();
64 sal_uInt16 nSlot
= rReq
.GetSlot();
73 pViewData
->GetViewShell()->UpdateDrawShell();
77 case SID_PASTE_SPECIAL
:
78 case SID_CLIPBOARD_FORMAT_ITEMS
:
79 case SID_HYPERLINK_SETLINK
:
81 // cell methods are at cell shell, which is not available if
82 // ScDrawTextObjectBar is active
83 //! move paste etc. to view shell?
91 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
92 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
94 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
, 0 );
95 aAttr
.Put( SvxWritingModeItem(
96 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
97 com::sun::star::text::WritingMode_LR_TB
: com::sun::star::text::WritingMode_TB_RL
,
98 SDRATTR_TEXTDIRECTION
) );
99 pView
->SetAttributes( aAttr
);
100 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
105 case SID_ENABLE_HYPHENATION
:
107 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, SID_ENABLE_HYPHENATION
, false);
110 SfxItemSet
aSet( GetPool(), EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
111 bool bValue
= pItem
->GetValue();
112 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, bValue
) );
113 pView
->SetAttributes( aSet
);
121 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet
& rSet
)
123 // cell methods are at cell shell, which is not available if
124 // ScDrawTextObjectBar is active -> disable everything
125 //! move paste etc. to view shell?
127 SfxWhichIter
aIter(rSet
);
128 sal_uInt16 nWhich
= aIter
.FirstWhich();
131 rSet
.DisableItem( nWhich
);
132 nWhich
= aIter
.NextWhich();
136 void ScDrawTextObjectBar::ExecuteExtra( SfxRequest
&rReq
)
138 ScTabView
* pTabView
= pViewData
->GetView();
139 ScDrawView
* pView
= pTabView
->GetScDrawView();
141 sal_uInt16 nSlot
= rReq
.GetSlot();
146 sal_uInt16 nId
= SvxFontWorkChildWindow::GetChildWindowId();
147 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
149 if ( rReq
.GetArgs() )
150 pViewFrm
->SetChildWindow( nId
,
151 static_cast<const SfxBoolItem
&>(
152 (rReq
.GetArgs()->Get(SID_FONTWORK
))).
155 pViewFrm
->ToggleChildWindow( nId
);
157 pViewFrm
->GetBindings().Invalidate( SID_FONTWORK
);
162 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
163 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
165 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(),
166 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
167 EE_PARA_JUST
, EE_PARA_JUST
,
169 bool bLeft
= ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
);
170 aAttr
.Put( SvxFrameDirectionItem(
171 bLeft
? FRMDIR_HORI_LEFT_TOP
: FRMDIR_HORI_RIGHT_TOP
,
172 EE_PARA_WRITINGDIR
) );
173 aAttr
.Put( SvxAdjustItem(
174 bLeft
? SVX_ADJUST_LEFT
: SVX_ADJUST_RIGHT
,
176 pView
->SetAttributes( aAttr
);
177 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
178 rReq
.Done(); //! Done(aAttr) ?
185 void ScDrawTextObjectBar::ExecFormText(SfxRequest
& rReq
)
187 ScTabView
* pTabView
= pViewData
->GetView();
188 ScDrawView
* pDrView
= pTabView
->GetScDrawView();
189 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
191 if ( rMarkList
.GetMarkCount() == 1 && rReq
.GetArgs() )
193 const SfxItemSet
& rSet
= *rReq
.GetArgs();
195 if ( pDrView
->IsTextEdit() )
196 pDrView
->ScEndTextEdit();
198 pDrView
->SetAttributes(rSet
);
202 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet
& rSet
)
204 const SdrObject
* pObj
= NULL
;
205 SvxFontWorkDialog
* pDlg
= NULL
;
206 ScDrawView
* pDrView
= pViewData
->GetView()->GetScDrawView();
207 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
208 sal_uInt16 nId
= SvxFontWorkChildWindow::GetChildWindowId();
210 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
211 if (pViewFrm
->HasChildWindow(nId
))
213 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow(nId
);
214 pDlg
= pWnd
? static_cast<SvxFontWorkDialog
*>(pWnd
->GetWindow()) : NULL
;
217 if ( rMarkList
.GetMarkCount() == 1 )
218 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
220 const SdrTextObj
* pTextObj
= dynamic_cast< const SdrTextObj
* >(pObj
);
221 const bool bDeactivate(
224 !pTextObj
->HasText() ||
225 dynamic_cast< const SdrObjCustomShape
* >(pObj
)); // #121538# no FontWork for CustomShapes
229 rSet
.DisableItem(XATTR_FORMTXTSTYLE
);
230 rSet
.DisableItem(XATTR_FORMTXTADJUST
);
231 rSet
.DisableItem(XATTR_FORMTXTDISTANCE
);
232 rSet
.DisableItem(XATTR_FORMTXTSTART
);
233 rSet
.DisableItem(XATTR_FORMTXTMIRROR
);
234 rSet
.DisableItem(XATTR_FORMTXTHIDEFORM
);
235 rSet
.DisableItem(XATTR_FORMTXTOUTLINE
);
236 rSet
.DisableItem(XATTR_FORMTXTSHADOW
);
237 rSet
.DisableItem(XATTR_FORMTXTSHDWCOLOR
);
238 rSet
.DisableItem(XATTR_FORMTXTSHDWXVAL
);
239 rSet
.DisableItem(XATTR_FORMTXTSHDWYVAL
);
245 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
249 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
250 XColorListRef pColorList
;
253 pColorList
= static_cast<const SvxColorListItem
*>(pItem
)->GetColorList();
255 if ( pColorList
.is() )
256 pDlg
->SetColorList( pColorList
);
259 SfxItemSet
aViewAttr(pDrView
->GetModel()->GetItemPool());
260 pDrView
->GetAttributes(aViewAttr
);
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */