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_sc.hxx" 30 31 #undef SC_DLLIMPLEMENTATION 32 33 34 35 //------------------------------------------------------------------ 36 37 #include <svx/dlgutil.hxx> 38 #include <svx/drawitem.hxx> 39 #include <svx/xtable.hxx> 40 41 #include "appoptio.hxx" 42 #include "scmod.hxx" 43 #include "scitems.hxx" 44 #include "tpview.hxx" 45 #include "global.hxx" 46 #include "viewopti.hxx" 47 #include "tabvwsh.hxx" 48 #include "uiitems.hxx" 49 #include "scresid.hxx" 50 #include "docsh.hxx" 51 #include "sc.hrc" // -> Slot-IDs 52 #include "optdlg.hrc" 53 #include "globstr.hrc" 54 55 #include "opredlin.hxx" 56 #include "opredlin.hrc" 57 58 //------------------------------------------------------------------ 59 60 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent, 61 const SfxItemSet& rSet ) 62 : SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet), 63 aContentFT ( this, ScResId(FT_CONTENT )), 64 aContentColorLB ( this, ScResId(CLB_CONTENT )), 65 aRemoveFT ( this, ScResId(FT_REMOVE )), 66 aRemoveColorLB ( this, ScResId(CLB_REMOVE )), 67 aInsertFT ( this, ScResId(FT_INSERT )), 68 aInsertColorLB ( this, ScResId(CLB_INSERT )), 69 aMoveFT ( this, ScResId(FT_MOVE )), 70 aMoveColorLB ( this, ScResId(CLB_MOVE )), 71 aChangedGB ( this, ScResId(GB_COLORCHGS)), 72 aAuthorStr (ScResId(STR_AUTHOR)) 73 { 74 FreeResource(); 75 76 Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl); 77 aContentColorLB.SetSelectHdl( aLk ); 78 aMoveColorLB.SetSelectHdl( aLk ); 79 aInsertColorLB.SetSelectHdl( aLk ); 80 aRemoveColorLB.SetSelectHdl( aLk ); 81 } 82 83 /*----------------------------------------------------------------------- 84 Beschreibung: 85 -----------------------------------------------------------------------*/ 86 87 __EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage() 88 { 89 } 90 91 /*----------------------------------------------------------------------- 92 Beschreibung: 93 -----------------------------------------------------------------------*/ 94 95 SfxTabPage* __EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet ) 96 { 97 return new ScRedlineOptionsTabPage( pParent, rSet ); 98 } 99 100 /*----------------------------------------------------------------------- 101 Beschreibung: 102 -----------------------------------------------------------------------*/ 103 104 sal_Bool __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ ) 105 { 106 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); 107 108 sal_uLong nNew=0; 109 sal_uInt16 nPos=0; 110 111 nPos = aContentColorLB.GetSelectEntryPos(); 112 if (nPos != LISTBOX_ENTRY_NOTFOUND) 113 { 114 nPos = aContentColorLB.GetSelectEntryPos(); 115 if (nPos!=0) 116 nNew= aContentColorLB.GetEntryColor(nPos).GetColor(); 117 else 118 nNew= COL_TRANSPARENT; 119 120 aAppOptions.SetTrackContentColor(nNew); 121 122 } 123 nPos = aMoveColorLB.GetSelectEntryPos(); 124 if (nPos != LISTBOX_ENTRY_NOTFOUND) 125 { 126 nPos = aMoveColorLB.GetSelectEntryPos(); 127 if (nPos!=0) 128 nNew= aMoveColorLB.GetEntryColor(nPos).GetColor(); 129 else 130 nNew= COL_TRANSPARENT; 131 132 aAppOptions.SetTrackMoveColor(nNew); 133 134 } 135 nPos = aInsertColorLB.GetSelectEntryPos(); 136 if (nPos != LISTBOX_ENTRY_NOTFOUND) 137 { 138 nPos = aInsertColorLB.GetSelectEntryPos(); 139 if (nPos!=0) 140 nNew= aInsertColorLB.GetEntryColor(nPos).GetColor(); 141 else 142 nNew= COL_TRANSPARENT; 143 144 aAppOptions.SetTrackInsertColor(nNew); 145 146 } 147 nPos = aRemoveColorLB.GetSelectEntryPos(); 148 if (nPos != LISTBOX_ENTRY_NOTFOUND) 149 { 150 nPos = aRemoveColorLB.GetSelectEntryPos(); 151 if (nPos!=0) 152 nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor(); 153 else 154 nNew= COL_TRANSPARENT; 155 156 aAppOptions.SetTrackDeleteColor(nNew); 157 158 } 159 160 SC_MOD()->SetAppOptions(aAppOptions); 161 162 // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert, 163 // waere das nicht noetig...) 164 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 165 if (pDocSh) 166 pDocSh->PostPaintGridAll(); 167 168 return sal_False; 169 } 170 171 /*----------------------------------------------------------------------- 172 Beschreibung: 173 -----------------------------------------------------------------------*/ 174 175 void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ ) 176 { 177 178 XColorTable* pColorTbl = XColorTable::GetStdColorTable(); 179 aContentColorLB.InsertEntry(aAuthorStr); 180 aMoveColorLB.InsertEntry(aAuthorStr); 181 aInsertColorLB.InsertEntry(aAuthorStr); 182 aRemoveColorLB.InsertEntry(aAuthorStr); 183 184 aContentColorLB.SetUpdateMode( sal_False); 185 aMoveColorLB.SetUpdateMode( sal_False); 186 aInsertColorLB.SetUpdateMode( sal_False); 187 aRemoveColorLB.SetUpdateMode( sal_False); 188 189 for( sal_uInt16 i = 0; i < pColorTbl->Count(); ++i ) 190 { 191 XColorEntry* pEntry = pColorTbl->GetColor( i ); 192 Color aColor = pEntry->GetColor(); 193 String sName = pEntry->GetName(); 194 195 aContentColorLB.InsertEntry( aColor, sName ); 196 aMoveColorLB.InsertEntry( aColor, sName ); 197 aInsertColorLB.InsertEntry( aColor, sName ); 198 aRemoveColorLB.InsertEntry( aColor, sName ); 199 } 200 aContentColorLB.SetUpdateMode( sal_True ); 201 aMoveColorLB.SetUpdateMode( sal_True ); 202 aInsertColorLB.SetUpdateMode( sal_True ); 203 aRemoveColorLB.SetUpdateMode( sal_True ); 204 205 206 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); 207 208 sal_uLong nColor = aAppOptions.GetTrackContentColor(); 209 if (nColor == COL_TRANSPARENT) 210 aContentColorLB.SelectEntryPos(0); 211 else 212 aContentColorLB.SelectEntry(Color(nColor)); 213 214 nColor = aAppOptions.GetTrackMoveColor(); 215 if (nColor == COL_TRANSPARENT) 216 aMoveColorLB.SelectEntryPos(0); 217 else 218 aMoveColorLB.SelectEntry(Color(nColor)); 219 220 221 nColor = aAppOptions.GetTrackInsertColor(); 222 if (nColor == COL_TRANSPARENT) 223 aInsertColorLB.SelectEntryPos(0); 224 else 225 aInsertColorLB.SelectEntry(Color(nColor)); 226 227 228 nColor = aAppOptions.GetTrackDeleteColor(); 229 if (nColor == COL_TRANSPARENT) 230 aRemoveColorLB.SelectEntryPos(0); 231 else 232 aRemoveColorLB.SelectEntry(Color(nColor)); 233 234 } 235 236 237 IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG ) 238 { 239 /* 240 SvxFontPrevWindow *pPrev; 241 ListBox *pLB; 242 243 if (pColorLB == &aInsertColorLB) 244 { 245 pPrev = &aInsertPreviewWN; 246 pLB = &aInsertLB; 247 } 248 else 249 { 250 pPrev = &aDeletedPreviewWN; 251 pLB = &aDeletedLB; 252 } 253 254 SvxFont& rFont = pPrev->GetFont(); 255 sal_uInt16 nPos = pLB->GetSelectEntryPos(); 256 if (nPos == LISTBOX_ENTRY_NOTFOUND) 257 nPos = 0; 258 259 CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos); 260 261 if (pAttr->nItemId == SID_ATTR_BRUSH) 262 { 263 rFont.SetColor(Color(COL_BLACK)); 264 nPos = pColorLB->GetSelectEntryPos(); 265 if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND) 266 { 267 Brush aBrush(Color(pColorLB->GetSelectEntryColor())); 268 pPrev->SetBrush(aBrush); 269 } 270 else 271 { 272 Brush aBrush(Color(COL_LIGHTGRAY)); 273 pPrev->SetBrush(aBrush); 274 } 275 } 276 else 277 { 278 nPos = pColorLB->GetSelectEntryPos(); 279 if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND) 280 rFont.SetColor(pColorLB->GetEntryColor(nPos)); 281 else 282 rFont.SetColor(Color(COL_RED)); 283 } 284 285 pPrev->Invalidate(); 286 */ 287 return 0; 288 } 289 290