1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <unotools/moduleoptions.hxx>
33 #include <unotools/fltrcfg.hxx>
34 #include "optfltr.hxx"
35 #include "optfltr.hrc"
38 #include <dialmgr.hxx>
40 enum MSFltrPg2_CheckBoxEntries
{
49 #define CBCOL_SECOND 1
51 // -----------------------------------------------------------------------
53 OfaMSFilterTabPage::OfaMSFilterTabPage(Window
* pParent
, const SfxItemSet
& rSet
)
54 : SfxTabPage( pParent
, CUI_RES( RID_OFAPAGE_MSFILTEROPT
), rSet
),
55 aMSWordGB ( this, CUI_RES( GB_WORD
) ),
56 aWBasicCodeCB ( this, CUI_RES( CB_WBAS_CODE
) ),
57 aWBasicStgCB ( this, CUI_RES( CB_WBAS_STG
) ),
58 aMSExcelGB ( this, CUI_RES( GB_EXCEL
) ),
59 aEBasicCodeCB ( this, CUI_RES( CB_EBAS_CODE
) ),
60 aEBasicExectblCB( this, CUI_RES( CB_EBAS_EXECTBL
) ),
61 aEBasicStgCB ( this, CUI_RES( CB_EBAS_STG
) ),
62 aMSPPointGB ( this, CUI_RES( GB_PPOINT
) ),
63 aPBasicCodeCB ( this, CUI_RES( CB_PBAS_CODE
) ),
64 aPBasicStgCB ( this, CUI_RES( CB_PBAS_STG
) )
68 aEBasicCodeCB
.SetClickHdl( LINK( this, OfaMSFilterTabPage
, LoadExcelBasicCheckHdl_Impl
) );
71 OfaMSFilterTabPage::~OfaMSFilterTabPage()
75 IMPL_LINK( OfaMSFilterTabPage
, LoadExcelBasicCheckHdl_Impl
, CheckBox
*, EMPTYARG
)
77 aEBasicExectblCB
.Enable( aEBasicCodeCB
.IsChecked() );
81 SfxTabPage
* OfaMSFilterTabPage::Create( Window
* pParent
,
82 const SfxItemSet
& rAttrSet
)
84 return new OfaMSFilterTabPage( pParent
, rAttrSet
);
87 sal_Bool
OfaMSFilterTabPage::FillItemSet( SfxItemSet
& )
89 SvtFilterOptions
* pOpt
= SvtFilterOptions::Get();
92 if( aWBasicCodeCB
.GetSavedValue() != (bFlag
= aWBasicCodeCB
.IsChecked()))
93 pOpt
->SetLoadWordBasicCode( bFlag
);
94 if( aWBasicStgCB
.GetSavedValue() != (bFlag
= aWBasicStgCB
.IsChecked()))
95 pOpt
->SetLoadWordBasicStorage( bFlag
);
97 if( aEBasicCodeCB
.GetSavedValue() != (bFlag
= aEBasicCodeCB
.IsChecked()))
98 pOpt
->SetLoadExcelBasicCode( bFlag
);
99 if( aEBasicExectblCB
.GetSavedValue() != (bFlag
= aEBasicExectblCB
.IsChecked()))
100 pOpt
->SetLoadExcelBasicExecutable( bFlag
);
101 if( aEBasicStgCB
.GetSavedValue() != (bFlag
= aEBasicStgCB
.IsChecked()))
102 pOpt
->SetLoadExcelBasicStorage( bFlag
);
104 if( aPBasicCodeCB
.GetSavedValue() != (bFlag
= aPBasicCodeCB
.IsChecked()))
105 pOpt
->SetLoadPPointBasicCode( bFlag
);
106 if( aPBasicStgCB
.GetSavedValue() != (bFlag
= aPBasicStgCB
.IsChecked()))
107 pOpt
->SetLoadPPointBasicStorage( bFlag
);
112 /*-----------------02.09.96 13.47-------------------
114 --------------------------------------------------*/
116 void OfaMSFilterTabPage::Reset( const SfxItemSet
& )
118 SvtFilterOptions
* pOpt
= SvtFilterOptions::Get();
120 aWBasicCodeCB
.Check( pOpt
->IsLoadWordBasicCode() );
121 aWBasicCodeCB
.SaveValue();
122 aWBasicStgCB
.Check( pOpt
->IsLoadWordBasicStorage() );
123 aWBasicStgCB
.SaveValue();
125 aEBasicCodeCB
.Check( pOpt
->IsLoadExcelBasicCode() );
126 aEBasicCodeCB
.SaveValue();
127 aEBasicExectblCB
.Check( pOpt
->IsLoadExcelBasicExecutable() );
128 aEBasicExectblCB
.SaveValue();
129 aEBasicStgCB
.Check( pOpt
->IsLoadExcelBasicStorage() );
130 aEBasicStgCB
.SaveValue();
131 LoadExcelBasicCheckHdl_Impl( &aEBasicCodeCB
);
133 aPBasicCodeCB
.Check( pOpt
->IsLoadPPointBasicCode() );
134 aPBasicCodeCB
.SaveValue();
135 aPBasicStgCB
.Check( pOpt
->IsLoadPPointBasicStorage() );
136 aPBasicStgCB
.SaveValue();
140 /*-----------------29.06.00 13:22-------------------
142 * --------------------------------------------------*/
143 OfaMSFilterTabPage2::OfaMSFilterTabPage2( Window
* pParent
,
144 const SfxItemSet
& rSet
)
145 : SfxTabPage( pParent
, CUI_RES( RID_OFAPAGE_MSFILTEROPT2
), rSet
),
146 aCheckLB ( this, CUI_RES( CLB_SETTINGS
)),
147 aHeader1FT ( this, CUI_RES( FT_HEADER1_EXPLANATION
)),
148 aHeader2FT ( this, CUI_RES( FT_HEADER2_EXPLANATION
)),
149 sHeader1 ( CUI_RES( ST_HEADER1
)),
150 sHeader2 ( CUI_RES( ST_HEADER2
)),
151 sChgToFromMath ( CUI_RES( ST_CHG_MATH
)),
152 sChgToFromWriter ( CUI_RES( ST_CHG_WRITER
)),
153 sChgToFromCalc ( CUI_RES( ST_CHG_CALC
)),
154 sChgToFromImpress ( CUI_RES( ST_CHG_IMPRESS
)),
159 static long aStaticTabs
[] = { 3, 0, 20, 40 };
160 aCheckLB
.SvxSimpleTable::SetTabs( aStaticTabs
);
162 String
sHeader( sHeader1
);
163 (( sHeader
+= '\t' ) += sHeader2
) += '\t';
164 aCheckLB
.InsertHeaderEntry( sHeader
, HEADERBAR_APPEND
,
165 HIB_CENTER
| HIB_VCENTER
| HIB_FIXEDPOS
| HIB_FIXED
);
167 aCheckLB
.SetHelpId( HID_OFAPAGE_MSFLTR2_CLB
);
168 aCheckLB
.SetStyle( aCheckLB
.GetStyle()|WB_HSCROLL
| WB_VSCROLL
);
171 OfaMSFilterTabPage2::~OfaMSFilterTabPage2()
173 delete pCheckButtonData
;
176 SfxTabPage
* OfaMSFilterTabPage2::Create( Window
* pParent
,
177 const SfxItemSet
& rAttrSet
)
179 return new OfaMSFilterTabPage2( pParent
, rAttrSet
);
182 sal_Bool
OfaMSFilterTabPage2::FillItemSet( SfxItemSet
& )
184 sal_Bool bModified
= sal_False
;
185 SvtFilterOptions
* pOpt
= SvtFilterOptions::Get();
187 static struct ChkCBoxEntries
{
188 MSFltrPg2_CheckBoxEntries eType
;
189 sal_Bool (SvtFilterOptions:: *FnIs
)() const;
190 void (SvtFilterOptions:: *FnSet
)( sal_Bool bFlag
);
192 { Math
, &SvtFilterOptions::IsMathType2Math
,
193 &SvtFilterOptions::SetMathType2Math
},
194 { Math
, &SvtFilterOptions::IsMath2MathType
,
195 &SvtFilterOptions::SetMath2MathType
},
196 { Writer
, &SvtFilterOptions::IsWinWord2Writer
,
197 &SvtFilterOptions::SetWinWord2Writer
},
198 { Writer
, &SvtFilterOptions::IsWriter2WinWord
,
199 &SvtFilterOptions::SetWriter2WinWord
},
200 { Calc
, &SvtFilterOptions::IsExcel2Calc
,
201 &SvtFilterOptions::SetExcel2Calc
},
202 { Calc
, &SvtFilterOptions::IsCalc2Excel
,
203 &SvtFilterOptions::SetCalc2Excel
},
204 { Impress
, &SvtFilterOptions::IsPowerPoint2Impress
,
205 &SvtFilterOptions::SetPowerPoint2Impress
},
206 { Impress
, &SvtFilterOptions::IsImpress2PowerPoint
,
207 &SvtFilterOptions::SetImpress2PowerPoint
},
208 { InvalidCBEntry
, 0, 0 }
211 sal_Bool bCheck
, bFirst
= sal_True
;
212 for( const ChkCBoxEntries
* pArr
= aChkArr
;
213 InvalidCBEntry
!= pArr
->eType
; ++pArr
, bFirst
= !bFirst
)
215 sal_uInt16 nCol
= bFirst
? 1 : 2;
216 SvLBoxEntry
* pEntry
= GetEntry4Type( pArr
->eType
);
219 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem( nCol
));
220 if( pItem
&& ((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
222 sal_uInt16 nButtonFlags
= pItem
->GetButtonFlags();
223 bCheck
= SV_BUTTON_CHECKED
==
224 pCheckButtonData
->ConvertToButtonState( nButtonFlags
);
226 if( bCheck
!= (pOpt
->*pArr
->FnIs
)() )
228 bModified
= sal_True
;
229 (pOpt
->*pArr
->FnSet
)( bCheck
);
238 void OfaMSFilterTabPage2::Reset( const SfxItemSet
& )
240 SvtFilterOptions
* pOpt
= SvtFilterOptions::Get();
242 aCheckLB
.SetUpdateMode(sal_False
);
245 SvtModuleOptions aModuleOpt
;
247 // int the same sequence as the enums of MSFltrPg2_CheckBoxEntries
248 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SMATH
) )
249 InsertEntry( sChgToFromMath
, static_cast< sal_IntPtr
>( Math
) );
250 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
) )
251 InsertEntry( sChgToFromWriter
, static_cast< sal_IntPtr
>( Writer
) );
252 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
) )
253 InsertEntry( sChgToFromCalc
, static_cast< sal_IntPtr
>( Calc
) );
254 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS
) )
255 InsertEntry( sChgToFromImpress
, static_cast< sal_IntPtr
>( Impress
) );
257 static struct ChkCBoxEntries
{
258 MSFltrPg2_CheckBoxEntries eType
;
259 sal_Bool (SvtFilterOptions:: *FnIs
)() const;
261 { Math
, &SvtFilterOptions::IsMathType2Math
},
262 { Math
, &SvtFilterOptions::IsMath2MathType
},
263 { Writer
, &SvtFilterOptions::IsWinWord2Writer
},
264 { Writer
, &SvtFilterOptions::IsWriter2WinWord
},
265 { Calc
, &SvtFilterOptions::IsExcel2Calc
},
266 { Calc
, &SvtFilterOptions::IsCalc2Excel
},
267 { Impress
, &SvtFilterOptions::IsPowerPoint2Impress
},
268 { Impress
, &SvtFilterOptions::IsImpress2PowerPoint
},
269 { InvalidCBEntry
, NULL
}
272 sal_Bool bFirst
= sal_True
;
273 for( const ChkCBoxEntries
* pArr
= aChkArr
;
274 InvalidCBEntry
!= pArr
->eType
; ++pArr
, bFirst
= !bFirst
)
276 sal_uInt16 nCol
= bFirst
? 1 : 2;
277 SvLBoxEntry
* pEntry
= GetEntry4Type( static_cast< sal_IntPtr
>( pArr
->eType
) );
280 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem( nCol
));
281 if( pItem
&& ((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
283 if( (pOpt
->*pArr
->FnIs
)() )
284 pItem
->SetStateChecked();
286 pItem
->SetStateUnchecked();
287 aCheckLB
.InvalidateEntry( pEntry
);
291 aCheckLB
.SetUpdateMode( sal_True
);
294 void OfaMSFilterTabPage2::InsertEntry( const String
& _rTxt
, sal_IntPtr _nType
)
296 SvLBoxEntry
* pEntry
= new SvLBoxEntry
;
298 if( !pCheckButtonData
)
299 pCheckButtonData
= new SvLBoxButtonData( &aCheckLB
);
301 pEntry
->AddItem( new SvLBoxContextBmp( pEntry
, 0, Image(), Image(), 0));
302 pEntry
->AddItem( new SvLBoxButton( pEntry
, SvLBoxButtonKind_enabledCheckbox
,
303 0, pCheckButtonData
) );
304 pEntry
->AddItem( new SvLBoxButton( pEntry
, SvLBoxButtonKind_enabledCheckbox
,
305 0, pCheckButtonData
) );
306 pEntry
->AddItem( new SvLBoxString( pEntry
, 0, _rTxt
) );
308 pEntry
->SetUserData( (void*)_nType
);
309 aCheckLB
.Insert( pEntry
);
312 SvLBoxEntry
* OfaMSFilterTabPage2::GetEntry4Type( sal_IntPtr _nType
) const
314 SvLBoxEntry
* pEntry
= aCheckLB
.First();
317 if ( _nType
== sal_IntPtr( pEntry
->GetUserData() ) )
319 pEntry
= aCheckLB
.Next( pEntry
);
324 void OfaMSFilterTabPage2::MSFltrSimpleTable::SetTabs()
326 SvxSimpleTable::SetTabs();
327 sal_uInt16 nAdjust
= SV_LBOXTAB_ADJUST_RIGHT
|SV_LBOXTAB_ADJUST_LEFT
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_ADJUST_NUMERIC
|SV_LBOXTAB_FORCE
;
329 if( aTabs
.Count() > 1 )
331 SvLBoxTab
* pTab
= (SvLBoxTab
*)aTabs
.GetObject(1);
332 pTab
->nFlags
&= ~nAdjust
;
333 pTab
->nFlags
|= SV_LBOXTAB_PUSHABLE
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_FORCE
;
335 if( aTabs
.Count() > 2 )
337 SvLBoxTab
* pTab
= (SvLBoxTab
*)aTabs
.GetObject(2);
338 pTab
->nFlags
&= ~nAdjust
;
339 pTab
->nFlags
|= SV_LBOXTAB_PUSHABLE
|SV_LBOXTAB_ADJUST_CENTER
|SV_LBOXTAB_FORCE
;
343 void OfaMSFilterTabPage2::MSFltrSimpleTable::HBarClick()
345 // Sortierung durch diese Ueberladung abgeklemmt
347 /* -----------------------------2002/06/20 11:51------------------------------
349 ---------------------------------------------------------------------------*/
350 void OfaMSFilterTabPage2::MSFltrSimpleTable::SetCheckButtonState(
351 SvLBoxEntry
* pEntry
, sal_uInt16 nCol
, SvButtonState eState
)
353 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem(nCol
+ 1));
355 DBG_ASSERT(pItem
,"SetCheckButton:Item not found");
356 if (((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
360 case SV_BUTTON_CHECKED
:
361 pItem
->SetStateChecked();
364 case SV_BUTTON_UNCHECKED
:
365 pItem
->SetStateUnchecked();
368 case SV_BUTTON_TRISTATE
:
369 pItem
->SetStateTristate();
372 InvalidateEntry( pEntry
);
375 /* -----------------------------2002/06/20 11:56------------------------------
377 ---------------------------------------------------------------------------*/
378 SvButtonState
OfaMSFilterTabPage2::MSFltrSimpleTable::GetCheckButtonState(
379 SvLBoxEntry
* pEntry
, sal_uInt16 nCol
) const
381 SvButtonState eState
= SV_BUTTON_UNCHECKED
;
382 SvLBoxButton
* pItem
= (SvLBoxButton
*)(pEntry
->GetItem(nCol
+ 1));
383 DBG_ASSERT(pItem
,"GetChButnState:Item not found");
385 if (((SvLBoxItem
*)pItem
)->IsA() == SV_ITEM_ID_LBOXBUTTON
)
387 sal_uInt16 nButtonFlags
= pItem
->GetButtonFlags();
388 eState
= pCheckButtonData
->ConvertToButtonState( nButtonFlags
);
393 /* -----------------------------2002/06/20 11:57------------------------------
395 ---------------------------------------------------------------------------*/
396 void OfaMSFilterTabPage2::MSFltrSimpleTable::CheckEntryPos(sal_uLong nPos
, sal_uInt16 nCol
, sal_Bool bChecked
)
398 if ( nPos
< GetEntryCount() )
402 bChecked
? SvButtonState( SV_BUTTON_CHECKED
) :
403 SvButtonState( SV_BUTTON_UNCHECKED
) );
405 /* -----------------------------2002/06/20 11:51------------------------------
407 ---------------------------------------------------------------------------*/
408 void OfaMSFilterTabPage2::MSFltrSimpleTable::KeyInput( const KeyEvent
& rKEvt
)
410 if(!rKEvt
.GetKeyCode().GetModifier() &&
411 KEY_SPACE
== rKEvt
.GetKeyCode().GetCode())
413 sal_uLong nSelPos
= GetModel()->GetAbsPos(GetCurEntry());
414 sal_uInt16 nCol
= GetCurrentTabPos() - 1;
417 SvLBoxEntry
* pEntry
= GetEntry( nSelPos
);
418 sal_Bool bIsChecked
= ( GetCheckButtonState( pEntry
, nCol
) == SV_BUTTON_CHECKED
);
419 CheckEntryPos( nSelPos
, nCol
, !bIsChecked
);
420 CallImplEventListeners( VCLEVENT_CHECKBOX_TOGGLE
, (void*)pEntry
);
424 sal_uInt16 nCheck
= GetCheckButtonState( GetEntry(nSelPos
), 1 ) == SV_BUTTON_CHECKED
? 1 : 0;
425 if(GetCheckButtonState( GetEntry(nSelPos
), 0 ))
429 CheckEntryPos(nSelPos
, 1, 0 != (nCheck
& 1));
430 CheckEntryPos(nSelPos
, 0, 0 != (nCheck
& 2));
434 SvxSimpleTable::KeyInput(rKEvt
);