1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 #include "scitems.hxx" 28 #include <editeng/adjitem.hxx> 29 #include <svx/drawitem.hxx> 30 #include <svx/fontwork.hxx> 31 #include <editeng/frmdiritem.hxx> 32 #include <editeng/outlobj.hxx> 33 #include <svx/svdocapt.hxx> 34 #include <svx/xtextit.hxx> 35 #include <editeng/writingmodeitem.hxx> 36 #include <sfx2/bindings.hxx> 37 #include <sfx2/viewfrm.hxx> 38 #include <sfx2/objsh.hxx> 39 #include <sfx2/request.hxx> 40 #include <sot/formats.hxx> 41 #include <svl/whiter.hxx> 42 #include <svx/svdoashp.hxx> 43 #include "sc.hrc" 44 #include "drtxtob.hxx" 45 #include "viewdata.hxx" 46 #include "drawview.hxx" 47 #include "tabvwsh.hxx" 48 #include "impex.hxx" 49 #include "docsh.hxx" 50 #include "transobj.hxx" 51 #include "drwtrans.hxx" 52 #include "drwlayer.hxx" 53 54 //------------------------------------------------------------------------ 55 56 sal_uInt16 ScGetFontWorkId() 57 { 58 return SvxFontWorkChildWindow::GetChildWindowId(); 59 } 60 61 sal_Bool ScDrawTextObjectBar::IsNoteEdit() 62 { 63 return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() ); 64 } 65 66 // wenn kein Text editiert wird, Funktionen wie in drawsh 67 68 void __EXPORT ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq ) 69 { 70 ScTabView* pTabView = pViewData->GetView(); 71 ScDrawView* pView = pTabView->GetScDrawView(); 72 73 sal_uInt16 nSlot = rReq.GetSlot(); 74 switch ( nSlot ) 75 { 76 case SID_COPY: 77 pView->DoCopy(); 78 break; 79 80 case SID_CUT: 81 pView->DoCut(); 82 pViewData->GetViewShell()->UpdateDrawShell(); 83 break; 84 85 case SID_PASTE: 86 case SID_PASTE_SPECIAL: 87 case SID_CLIPBOARD_FORMAT_ITEMS: 88 case SID_HYPERLINK_SETLINK: 89 { 90 // cell methods are at cell shell, which is not available if 91 // ScDrawTextObjectBar is active 92 //! move paste etc. to view shell? 93 } 94 break; 95 96 case SID_SELECTALL: 97 pView->MarkAll(); 98 break; 99 100 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 101 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 102 { 103 SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 ); 104 aAttr.Put( SvxWritingModeItem( 105 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? 106 com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL, 107 SDRATTR_TEXTDIRECTION ) ); 108 pView->SetAttributes( aAttr ); 109 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled 110 rReq.Done( aAttr ); 111 } 112 break; 113 114 case SID_ENABLE_HYPHENATION: 115 { 116 SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, sal_False); 117 if( pItem ) 118 { 119 SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE ); 120 sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue(); 121 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); 122 pView->SetAttributes( aSet ); 123 } 124 rReq.Done(); 125 } 126 break; 127 } 128 } 129 130 void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet ) 131 { 132 // cell methods are at cell shell, which is not available if 133 // ScDrawTextObjectBar is active -> disable everything 134 //! move paste etc. to view shell? 135 136 SfxWhichIter aIter(rSet); 137 sal_uInt16 nWhich = aIter.FirstWhich(); 138 while (nWhich) 139 { 140 rSet.DisableItem( nWhich ); 141 nWhich = aIter.NextWhich(); 142 } 143 } 144 145 void __EXPORT ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq ) 146 { 147 ScTabView* pTabView = pViewData->GetView(); 148 ScDrawView* pView = pTabView->GetScDrawView(); 149 150 sal_uInt16 nSlot = rReq.GetSlot(); 151 switch ( nSlot ) 152 { 153 case SID_FONTWORK: 154 { 155 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 156 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); 157 158 if ( rReq.GetArgs() ) 159 pViewFrm->SetChildWindow( nId, 160 ((const SfxBoolItem&) 161 (rReq.GetArgs()->Get(SID_FONTWORK))). 162 GetValue() ); 163 else 164 pViewFrm->ToggleChildWindow( nId ); 165 166 pViewFrm->GetBindings().Invalidate( SID_FONTWORK ); 167 rReq.Done(); 168 } 169 break; 170 171 case SID_ATTR_PARA_LEFT_TO_RIGHT: 172 case SID_ATTR_PARA_RIGHT_TO_LEFT: 173 { 174 SfxItemSet aAttr( pView->GetModel()->GetItemPool(), 175 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, 176 EE_PARA_JUST, EE_PARA_JUST, 177 0 ); 178 sal_Bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ); 179 aAttr.Put( SvxFrameDirectionItem( 180 bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP, 181 EE_PARA_WRITINGDIR ) ); 182 aAttr.Put( SvxAdjustItem( 183 bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT, 184 EE_PARA_JUST ) ); 185 pView->SetAttributes( aAttr ); 186 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); 187 rReq.Done(); //! Done(aAttr) ? 188 189 } 190 break; 191 } 192 } 193 194 void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq) 195 { 196 ScTabView* pTabView = pViewData->GetView(); 197 ScDrawView* pDrView = pTabView->GetScDrawView(); 198 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 199 200 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) 201 { 202 const SfxItemSet& rSet = *rReq.GetArgs(); 203 const SfxPoolItem* pItem; 204 205 if ( pDrView->IsTextEdit() ) 206 pDrView->ScEndTextEdit(); 207 208 pDrView->SetAttributes(rSet); 209 } 210 } 211 212 void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet) 213 { 214 const SdrObject* pObj = NULL; 215 SvxFontWorkDialog* pDlg = NULL; 216 ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); 217 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 218 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 219 220 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); 221 if ( pViewFrm->HasChildWindow(nId) ) 222 pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow()); 223 224 if ( rMarkList.GetMarkCount() == 1 ) 225 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 226 227 const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj); 228 const bool bDeactivate( 229 !pObj || 230 !pTextObj || 231 !pTextObj->HasText() || 232 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes 233 234 if(bDeactivate) 235 { 236 if ( pDlg ) 237 pDlg->SetActive(sal_False); 238 239 rSet.DisableItem(XATTR_FORMTXTSTYLE); 240 rSet.DisableItem(XATTR_FORMTXTADJUST); 241 rSet.DisableItem(XATTR_FORMTXTDISTANCE); 242 rSet.DisableItem(XATTR_FORMTXTSTART); 243 rSet.DisableItem(XATTR_FORMTXTMIRROR); 244 rSet.DisableItem(XATTR_FORMTXTHIDEFORM); 245 rSet.DisableItem(XATTR_FORMTXTOUTLINE); 246 rSet.DisableItem(XATTR_FORMTXTSHADOW); 247 rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); 248 rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); 249 rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); 250 } 251 else 252 { 253 if ( pDlg ) 254 { 255 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 256 257 if ( pDocSh ) 258 { 259 const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); 260 XColorTable* pColorTable = NULL; 261 262 if ( pItem ) 263 pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); 264 265 pDlg->SetActive(); 266 267 if ( pColorTable ) 268 pDlg->SetColorTable( pColorTable ); 269 else 270 { DBG_ERROR( "ColorList not found :-/" ); } 271 } 272 } 273 SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool()); 274 pDrView->GetAttributes(aViewAttr); 275 rSet.Set(aViewAttr); 276 } 277 } 278 279 280 281 282