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