1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drtxtob2.cxx,v $
10 * $Revision: 1.19.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "scitems.hxx"
35 #include <svx/adjitem.hxx>
36 #include <svx/drawitem.hxx>
37 #include <svx/fontwork.hxx>
38 #include <svx/frmdiritem.hxx>
39 #include <svx/outlobj.hxx>
40 #include <svx/svdocapt.hxx>
41 #include <svx/xtextit.hxx>
42 #include <svx/writingmodeitem.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <sfx2/objsh.hxx>
46 #include <sfx2/request.hxx>
47 #include <sot/formats.hxx>
48 #include <svtools/whiter.hxx>
51 #include "drtxtob.hxx"
52 #include "viewdata.hxx"
53 #include "drawview.hxx"
54 #include "tabvwsh.hxx"
57 #include "transobj.hxx"
58 #include "drwtrans.hxx"
59 #include "drwlayer.hxx"
61 //------------------------------------------------------------------------
63 USHORT
ScGetFontWorkId()
65 return SvxFontWorkChildWindow::GetChildWindowId();
68 BOOL
ScDrawTextObjectBar::IsNoteEdit()
70 return ScDrawLayer::IsNoteCaption( pViewData
->GetView()->GetSdrView()->GetTextEditObject() );
73 // wenn kein Text editiert wird, Funktionen wie in drawsh
75 void __EXPORT
ScDrawTextObjectBar::ExecuteGlobal( SfxRequest
&rReq
)
77 ScTabView
* pTabView
= pViewData
->GetView();
78 ScDrawView
* pView
= pTabView
->GetScDrawView();
80 USHORT nSlot
= rReq
.GetSlot();
89 if (!pTabView
->IsDrawSelMode())
90 pViewData
->GetViewShell()->SetDrawShell( FALSE
);
94 case SID_PASTE_SPECIAL
:
95 case SID_CLIPBOARD_FORMAT_ITEMS
:
96 case SID_HYPERLINK_SETLINK
:
98 // cell methods are at cell shell, which is not available if
99 // ScDrawTextObjectBar is active
100 //! move paste etc. to view shell?
108 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
109 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
111 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
, 0 );
112 aAttr
.Put( SvxWritingModeItem(
113 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
114 com::sun::star::text::WritingMode_LR_TB
: com::sun::star::text::WritingMode_TB_RL
,
115 SDRATTR_TEXTDIRECTION
) );
116 pView
->SetAttributes( aAttr
);
117 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
122 case SID_ENABLE_HYPHENATION
:
124 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, SID_ENABLE_HYPHENATION
, FALSE
);
127 SfxItemSet
aSet( GetPool(), EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
);
128 BOOL bValue
= ( (const SfxBoolItem
*) pItem
)->GetValue();
129 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, bValue
) );
130 pView
->SetAttributes( aSet
);
138 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet
& rSet
)
140 // cell methods are at cell shell, which is not available if
141 // ScDrawTextObjectBar is active -> disable everything
142 //! move paste etc. to view shell?
144 SfxWhichIter
aIter(rSet
);
145 USHORT nWhich
= aIter
.FirstWhich();
148 rSet
.DisableItem( nWhich
);
149 nWhich
= aIter
.NextWhich();
153 void __EXPORT
ScDrawTextObjectBar::ExecuteExtra( SfxRequest
&rReq
)
155 ScTabView
* pTabView
= pViewData
->GetView();
156 ScDrawView
* pView
= pTabView
->GetScDrawView();
158 USHORT nSlot
= rReq
.GetSlot();
163 USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
164 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
166 if ( rReq
.GetArgs() )
167 pViewFrm
->SetChildWindow( nId
,
168 ((const SfxBoolItem
&)
169 (rReq
.GetArgs()->Get(SID_FONTWORK
))).
172 pViewFrm
->ToggleChildWindow( nId
);
174 pViewFrm
->GetBindings().Invalidate( SID_FONTWORK
);
179 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
180 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
182 SfxItemSet
aAttr( pView
->GetModel()->GetItemPool(),
183 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
184 EE_PARA_JUST
, EE_PARA_JUST
,
186 BOOL bLeft
= ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
);
187 aAttr
.Put( SvxFrameDirectionItem(
188 bLeft
? FRMDIR_HORI_LEFT_TOP
: FRMDIR_HORI_RIGHT_TOP
,
189 EE_PARA_WRITINGDIR
) );
190 aAttr
.Put( SvxAdjustItem(
191 bLeft
? SVX_ADJUST_LEFT
: SVX_ADJUST_RIGHT
,
193 pView
->SetAttributes( aAttr
);
194 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
195 rReq
.Done(); //! Done(aAttr) ?
202 void ScDrawTextObjectBar::ExecFormText(SfxRequest
& rReq
)
204 ScTabView
* pTabView
= pViewData
->GetView();
205 ScDrawView
* pDrView
= pTabView
->GetScDrawView();
206 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
208 if ( rMarkList
.GetMarkCount() == 1 && rReq
.GetArgs() )
210 const SfxItemSet
& rSet
= *rReq
.GetArgs();
211 const SfxPoolItem
* pItem
;
213 if ( pDrView
->IsTextEdit() )
214 pDrView
->ScEndTextEdit();
217 rSet
.GetItemState(XATTR_FORMTXTSTDFORM
, TRUE
, &pItem
)
219 ((const XFormTextStdFormItem
*) pItem
)->GetValue() )
222 USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
223 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
224 SvxFontWorkDialog
* pDlg
= (SvxFontWorkDialog
*)
226 GetChildWindow(nId
)->GetWindow());
228 pDlg
->CreateStdFormObj(*pDrView
, *pDrView
->GetSdrPageView(),
229 rSet
, *rMarkList
.GetMark(0)->GetMarkedSdrObj(),
230 ((const XFormTextStdFormItem
*) pItem
)->
234 pDrView
->SetAttributes(rSet
);
238 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet
& rSet
)
240 const SdrObject
* pObj
= NULL
;
241 SvxFontWorkDialog
* pDlg
= NULL
;
242 ScDrawView
* pDrView
= pViewData
->GetView()->GetScDrawView();
243 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
244 USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
246 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
247 if ( pViewFrm
->HasChildWindow(nId
) )
248 pDlg
= (SvxFontWorkDialog
*)(pViewFrm
->GetChildWindow(nId
)->GetWindow());
250 if ( rMarkList
.GetMarkCount() == 1 )
251 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
253 if ( pObj
== NULL
|| !pObj
->ISA(SdrTextObj
) ||
254 !((SdrTextObj
*) pObj
)->HasText() )
257 pDlg
->SetActive(FALSE
);
259 rSet
.DisableItem(XATTR_FORMTXTSTYLE
);
260 rSet
.DisableItem(XATTR_FORMTXTADJUST
);
261 rSet
.DisableItem(XATTR_FORMTXTDISTANCE
);
262 rSet
.DisableItem(XATTR_FORMTXTSTART
);
263 rSet
.DisableItem(XATTR_FORMTXTMIRROR
);
264 rSet
.DisableItem(XATTR_FORMTXTSTDFORM
);
265 rSet
.DisableItem(XATTR_FORMTXTHIDEFORM
);
266 rSet
.DisableItem(XATTR_FORMTXTOUTLINE
);
267 rSet
.DisableItem(XATTR_FORMTXTSHADOW
);
268 rSet
.DisableItem(XATTR_FORMTXTSHDWCOLOR
);
269 rSet
.DisableItem(XATTR_FORMTXTSHDWXVAL
);
270 rSet
.DisableItem(XATTR_FORMTXTSHDWYVAL
);
276 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
280 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
281 XColorTable
* pColorTable
= NULL
;
284 pColorTable
= ((SvxColorTableItem
*)pItem
)->GetColorTable();
289 pDlg
->SetColorTable( pColorTable
);
291 { DBG_ERROR( "ColorList not found :-/" ); }
294 SfxItemSet
aViewAttr(pDrView
->GetModel()->GetItemPool());
295 pDrView
->GetAttributes(aViewAttr
);