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 .
21 #include "scitems.hxx"
22 #include <editeng/adjustitem.hxx>
23 #include <svx/drawitem.hxx>
24 #include <svx/fontwork.hxx>
25 #include <editeng/frmdiritem.hxx>
26 #include <editeng/outlobj.hxx>
27 #include <svx/svdocapt.hxx>
28 #include <svx/xtextit.hxx>
29 #include <editeng/writingmodeitem.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <sfx2/request.hxx>
34 #include <sot/formats.hxx>
35 #include <svl/whiter.hxx>
36 #include <svx/svdoashp.hxx>
38 #include "drtxtob.hxx"
39 #include "viewdata.hxx"
40 #include "drawview.hxx"
41 #include "tabvwsh.hxx"
44 #include "transobj.hxx"
45 #include "drwtrans.hxx"
46 #include "drwlayer.hxx"
48 //------------------------------------------------------------------------
50 sal_uInt16
ScGetFontWorkId()
52 return SvxFontWorkChildWindow::GetChildWindowId();
55 sal_Bool
ScDrawTextObjectBar::IsNoteEdit()
57 return ScDrawLayer::IsNoteCaption( pViewData
->GetView()->GetSdrView()->GetTextEditObject() );
60 // wenn kein Text editiert wird, Funktionen wie in drawsh
62 void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest
&rReq
)
64 ScTabView
* pTabView
= pViewData
->GetView();
65 ScDrawView
* pView
= pTabView
->GetScDrawView();
67 sal_uInt16 nSlot
= rReq
.GetSlot();
76 pViewData
->GetViewShell()->UpdateDrawShell();
80 case SID_PASTE_SPECIAL
:
81 case SID_CLIPBOARD_FORMAT_ITEMS
:
82 case SID_HYPERLINK_SETLINK
:
84 // cell methods are at cell shell, which is not available if
85 // ScDrawTextObjectBar is active
86 //! move paste etc. to view shell?
94 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
95 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
97 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
, 0 );
98 aAttr
.Put( SvxWritingModeItem(
99 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
100 com::sun::star::text::WritingMode_LR_TB
: com::sun::star::text::WritingMode_TB_RL
,
101 SDRATTR_TEXTDIRECTION
) );
102 pView
->SetAttributes( aAttr
);
103 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
108 case SID_ENABLE_HYPHENATION
:
110 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, SID_ENABLE_HYPHENATION
, false);
113 SfxItemSet
aSet( GetPool(), EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
114 sal_Bool bValue
= ( (const SfxBoolItem
*) pItem
)->GetValue();
115 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, bValue
) );
116 pView
->SetAttributes( aSet
);
124 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet
& rSet
)
126 // cell methods are at cell shell, which is not available if
127 // ScDrawTextObjectBar is active -> disable everything
128 //! move paste etc. to view shell?
130 SfxWhichIter
aIter(rSet
);
131 sal_uInt16 nWhich
= aIter
.FirstWhich();
134 rSet
.DisableItem( nWhich
);
135 nWhich
= aIter
.NextWhich();
139 void ScDrawTextObjectBar::ExecuteExtra( SfxRequest
&rReq
)
141 ScTabView
* pTabView
= pViewData
->GetView();
142 ScDrawView
* pView
= pTabView
->GetScDrawView();
144 sal_uInt16 nSlot
= rReq
.GetSlot();
149 sal_uInt16 nId
= SvxFontWorkChildWindow::GetChildWindowId();
150 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
152 if ( rReq
.GetArgs() )
153 pViewFrm
->SetChildWindow( nId
,
154 ((const SfxBoolItem
&)
155 (rReq
.GetArgs()->Get(SID_FONTWORK
))).
158 pViewFrm
->ToggleChildWindow( nId
);
160 pViewFrm
->GetBindings().Invalidate( SID_FONTWORK
);
165 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
166 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
168 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(),
169 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
170 EE_PARA_JUST
, EE_PARA_JUST
,
172 sal_Bool bLeft
= ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
);
173 aAttr
.Put( SvxFrameDirectionItem(
174 bLeft
? FRMDIR_HORI_LEFT_TOP
: FRMDIR_HORI_RIGHT_TOP
,
175 EE_PARA_WRITINGDIR
) );
176 aAttr
.Put( SvxAdjustItem(
177 bLeft
? SVX_ADJUST_LEFT
: SVX_ADJUST_RIGHT
,
179 pView
->SetAttributes( aAttr
);
180 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
181 rReq
.Done(); //! Done(aAttr) ?
188 void ScDrawTextObjectBar::ExecFormText(SfxRequest
& rReq
)
190 ScTabView
* pTabView
= pViewData
->GetView();
191 ScDrawView
* pDrView
= pTabView
->GetScDrawView();
192 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
194 if ( rMarkList
.GetMarkCount() == 1 && rReq
.GetArgs() )
196 const SfxItemSet
& rSet
= *rReq
.GetArgs();
198 if ( pDrView
->IsTextEdit() )
199 pDrView
->ScEndTextEdit();
201 pDrView
->SetAttributes(rSet
);
205 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet
& rSet
)
207 const SdrObject
* pObj
= NULL
;
208 SvxFontWorkDialog
* pDlg
= NULL
;
209 ScDrawView
* pDrView
= pViewData
->GetView()->GetScDrawView();
210 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
211 sal_uInt16 nId
= SvxFontWorkChildWindow::GetChildWindowId();
213 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
214 if ( pViewFrm
->HasChildWindow(nId
) )
215 pDlg
= (SvxFontWorkDialog
*)(pViewFrm
->GetChildWindow(nId
)->GetWindow());
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
230 pDlg
->SetActive(false);
232 rSet
.DisableItem(XATTR_FORMTXTSTYLE
);
233 rSet
.DisableItem(XATTR_FORMTXTADJUST
);
234 rSet
.DisableItem(XATTR_FORMTXTDISTANCE
);
235 rSet
.DisableItem(XATTR_FORMTXTSTART
);
236 rSet
.DisableItem(XATTR_FORMTXTMIRROR
);
237 rSet
.DisableItem(XATTR_FORMTXTHIDEFORM
);
238 rSet
.DisableItem(XATTR_FORMTXTOUTLINE
);
239 rSet
.DisableItem(XATTR_FORMTXTSHADOW
);
240 rSet
.DisableItem(XATTR_FORMTXTSHDWCOLOR
);
241 rSet
.DisableItem(XATTR_FORMTXTSHDWXVAL
);
242 rSet
.DisableItem(XATTR_FORMTXTSHDWYVAL
);
248 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
252 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
253 XColorListRef pColorList
;
256 pColorList
= ((SvxColorListItem
*)pItem
)->GetColorList();
260 if ( pColorList
.is() )
261 pDlg
->SetColorList( pColorList
);
264 SfxItemSet
aViewAttr(pDrView
->GetModel()->GetItemPool());
265 pDrView
->GetAttributes(aViewAttr
);
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */