fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob2.cxx
blob2b547066f91b5a9da8de52ce6e273bb0f852c1e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
36 #include "sc.hrc"
37 #include "drtxtob.hxx"
38 #include "viewdata.hxx"
39 #include "drawview.hxx"
40 #include "tabvwsh.hxx"
41 #include "impex.hxx"
42 #include "docsh.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();
65 switch ( nSlot )
67 case SID_COPY:
68 pView->DoCopy();
69 break;
71 case SID_CUT:
72 pView->DoCut();
73 pViewData->GetViewShell()->UpdateDrawShell();
74 break;
76 case SID_PASTE:
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?
85 break;
87 case SID_SELECTALL:
88 pView->MarkAll();
89 break;
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
101 rReq.Done( aAttr );
103 break;
105 case SID_ENABLE_HYPHENATION:
107 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, false);
108 if( pItem )
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 );
115 rReq.Done();
117 break;
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();
129 while (nWhich)
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();
142 switch ( nSlot )
144 case SID_FONTWORK:
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))).
153 GetValue() );
154 else
155 pViewFrm->ToggleChildWindow( nId );
157 pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
158 rReq.Done();
160 break;
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,
168 0 );
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,
175 EE_PARA_JUST ) );
176 pView->SetAttributes( aAttr );
177 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
178 rReq.Done(); //! Done(aAttr) ?
181 break;
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(
222 !pObj ||
223 !pTextObj ||
224 !pTextObj->HasText() ||
225 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
227 if(bDeactivate)
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);
241 else
243 if ( pDlg )
245 SfxObjectShell* pDocSh = SfxObjectShell::Current();
247 if ( pDocSh )
249 const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
250 XColorListRef pColorList;
252 if ( pItem )
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);
261 rSet.Set(aViewAttr);
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */