1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 33 34 35 #ifndef _SVX_SVXIDS_HRC //autogen 36 #include <svx/svxids.hrc> 37 #endif 38 #ifndef _MSGBOX_HXX //autogen 39 #include <vcl/msgbox.hxx> 40 #endif 41 #include <sfx2/request.hxx> 42 #include <sfx2/dispatch.hxx> 43 #include <svx/svdview.hxx> 44 #include <svx/tabarea.hxx> 45 #include <svx/tabline.hxx> 46 #include <svx/drawitem.hxx> 47 48 #include <svx/xtable.hxx> 49 #include "view.hxx" 50 #include "wrtsh.hxx" 51 #include "docsh.hxx" 52 #include "cmdid.h" 53 54 #include "drawsh.hxx" 55 #include <svx/svxdlg.hxx> 56 #include <svx/dialogs.hrc> 57 58 /*-------------------------------------------------------------------- 59 Beschreibung: 60 --------------------------------------------------------------------*/ 61 62 63 void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) 64 { 65 SwWrtShell* pSh = &GetShell(); 66 SdrView* pView = pSh->GetDrawView(); 67 SdrModel* pDoc = pView->GetModel(); 68 sal_Bool bChanged = pDoc->IsChanged(); 69 pDoc->SetChanged(sal_False); 70 71 SfxItemSet aNewAttr( pDoc->GetItemPool() ); 72 pView->GetAttributes( aNewAttr ); 73 74 GetView().NoRotate(); 75 76 switch (rReq.GetSlot()) 77 { 78 case FN_DRAWTEXT_ATTR_DLG: 79 { 80 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 81 if ( pFact ) 82 { 83 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView ); 84 sal_uInt16 nResult = pDlg->Execute(); 85 86 if (nResult == RET_OK) 87 { 88 if (pView->AreObjectsMarked()) 89 { 90 pSh->StartAction(); 91 pView->SetAttributes(*pDlg->GetOutputItemSet()); 92 rReq.Done(*(pDlg->GetOutputItemSet())); 93 pSh->EndAction(); 94 } 95 } 96 97 delete( pDlg ); 98 } 99 } 100 break; 101 102 case SID_ATTRIBUTES_AREA: 103 { 104 sal_Bool bHasMarked = pView->AreObjectsMarked(); 105 106 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 107 DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); 108 AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL, 109 &aNewAttr, 110 pDoc, 111 pView); 112 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 113 const SvxColorTableItem* pColorItem = (const SvxColorTableItem*) 114 GetView().GetDocShell()->GetItem(SID_COLOR_TABLE); 115 if(pColorItem->GetColorTable() == XColorTable::GetStdColorTable()) 116 pDlg->DontDeleteColorTable(); 117 if (pDlg->Execute() == RET_OK) 118 { 119 pSh->StartAction(); 120 if (bHasMarked) 121 pView->SetAttributes(*pDlg->GetOutputItemSet()); 122 else 123 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False); 124 pSh->EndAction(); 125 126 static sal_uInt16 __READONLY_DATA aInval[] = 127 { 128 SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0 129 }; 130 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); 131 rBnd.Invalidate(aInval); 132 rBnd.Update(SID_ATTR_FILL_STYLE); 133 rBnd.Update(SID_ATTR_FILL_COLOR); 134 } 135 delete pDlg; 136 } 137 break; 138 139 case SID_ATTRIBUTES_LINE: 140 { 141 sal_Bool bHasMarked = pView->AreObjectsMarked(); 142 143 const SdrObject* pObj = NULL; 144 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 145 if( rMarkList.GetMarkCount() == 1 ) 146 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 147 148 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 149 DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); 150 SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL, 151 &aNewAttr, 152 pDoc, 153 pObj, 154 bHasMarked); 155 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 156 if (pDlg->Execute() == RET_OK) 157 { 158 pSh->StartAction(); 159 if(bHasMarked) 160 pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False); 161 else 162 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False); 163 pSh->EndAction(); 164 165 static sal_uInt16 __READONLY_DATA aInval[] = 166 { 167 SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH, 168 SID_ATTR_LINE_COLOR, 0 169 }; 170 171 GetView().GetViewFrame()->GetBindings().Invalidate(aInval); 172 } 173 delete pDlg; 174 } 175 break; 176 177 default: 178 break; 179 } 180 181 182 if (pDoc->IsChanged()) 183 GetShell().SetModified(); 184 else 185 if (bChanged) 186 pDoc->SetChanged(sal_True); 187 } 188 189 /*-------------------------------------------------------------------- 190 Beschreibung: 191 --------------------------------------------------------------------*/ 192 193 194 void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq) 195 { 196 SwWrtShell* pSh = &GetShell(); 197 SdrView* pView = pSh->GetDrawView(); 198 const SfxItemSet* pArgs = rReq.GetArgs(); 199 sal_Bool bChanged = pView->GetModel()->IsChanged(); 200 pView->GetModel()->SetChanged(sal_False); 201 202 GetView().NoRotate(); 203 204 if (pArgs) 205 { 206 if(pView->AreObjectsMarked()) 207 pView->SetAttrToMarked(*rReq.GetArgs(), sal_False); 208 else 209 pView->SetDefaultAttr(*rReq.GetArgs(), sal_False); 210 } 211 else 212 { 213 SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher(); 214 switch (rReq.GetSlot()) 215 { 216 case SID_ATTR_FILL_STYLE: 217 case SID_ATTR_FILL_COLOR: 218 case SID_ATTR_FILL_GRADIENT: 219 case SID_ATTR_FILL_HATCH: 220 case SID_ATTR_FILL_BITMAP: 221 pDis->Execute(SID_ATTRIBUTES_AREA, sal_False); 222 break; 223 case SID_ATTR_LINE_STYLE: 224 case SID_ATTR_LINE_DASH: 225 case SID_ATTR_LINE_WIDTH: 226 case SID_ATTR_LINE_COLOR: 227 pDis->Execute(SID_ATTRIBUTES_LINE, sal_False); 228 break; 229 } 230 } 231 if (pView->GetModel()->IsChanged()) 232 GetShell().SetModified(); 233 else 234 if (bChanged) 235 pView->GetModel()->SetChanged(sal_True); 236 } 237 238 /*-------------------------------------------------------------------- 239 Beschreibung: 240 --------------------------------------------------------------------*/ 241 242 243 void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet) 244 { 245 SdrView* pSdrView = GetShell().GetDrawView(); 246 247 if (pSdrView->AreObjectsMarked()) 248 { 249 sal_Bool bDisable = Disable( rSet ); 250 251 if( !bDisable ) 252 pSdrView->GetAttributes( rSet ); 253 } 254 else 255 rSet.Put(pSdrView->GetDefaultAttr()); 256 } 257 258 259 260