Author: arielch Date: Tue Dec 11 02:51:14 2012 New Revision: 1419979 URL: http://svn.apache.org/viewvc?rev=1419979&view=rev Log: i79901 - Store hierarchical style filter
Modified: openoffice/trunk/main/sfx2/source/dialog/templdlg.cxx Modified: openoffice/trunk/main/sfx2/source/dialog/templdlg.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/dialog/templdlg.cxx?rev=1419979&r1=1419978&r2=1419979&view=diff ============================================================================== --- openoffice/trunk/main/sfx2/source/dialog/templdlg.cxx (original) +++ openoffice/trunk/main/sfx2/source/dialog/templdlg.cxx Tue Dec 11 02:51:14 2012 @@ -98,6 +98,9 @@ static sal_uInt16 nLastItemId = USHRT_MA // filter box has maximum 12 entries visible #define MAX_FILTER_ENTRIES 12 +#define SFX_TEMPLDLG_FILTER_MAX 0xFFFF +#define SFX_TEMPLDLG_FILTER_HIERARCHICAL 0xFFFE + //========================================================================= TYPEINIT0(SfxCommonTemplateDialog_Impl); @@ -755,7 +758,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonT aFmtLb ( this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH ), aFilterLb ( pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP ), - nActFamily ( 0xffff ), + nActFamily ( SFX_TEMPLDLG_FILTER_MAX ), nActFilter ( 0 ), nAppFilter ( 0 ), @@ -800,7 +803,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonT aFmtLb ( this, SfxResId( BT_VLIST ) ), aFilterLb ( pW, SfxResId( BT_FLIST ) ), - nActFamily ( 0xffff ), + nActFamily ( SFX_TEMPLDLG_FILTER_MAX ), nActFilter ( 0 ), nAppFilter ( 0 ), @@ -874,8 +877,10 @@ void SfxCommonTemplateDialog_Impl::ReadR else pStyleFamilies = new SfxStyleFamilies( aFamId ); - nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0xFFFF; - if ( pCurObjShell && 0xFFFF == nActFilter ) + nActFilter = pCurObjShell ? + static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : + SFX_TEMPLDLG_FILTER_MAX; + if ( pCurObjShell && SFX_TEMPLDLG_FILTER_MAX == nActFilter ) nActFilter = pCurObjShell->GetAutoStyleFilterIndex(); // Einfuegen in die Toolbox @@ -1167,7 +1172,7 @@ void SfxCommonTemplateDialog_Impl::Enabl void SfxCommonTemplateDialog_Impl::FillTreeBox() { DBG_ASSERT( pTreeBox, "FillTreeBox() without treebox"); - if(pStyleSheetPool && nActFamily != 0xffff) + if(pStyleSheetPool && nActFamily != SFX_TEMPLDLG_FILTER_MAX) { const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL); @@ -1476,7 +1481,7 @@ void SfxCommonTemplateDialog_Impl::Updat SfxTemplateItem *pItem = 0; // aktueller Bereich nicht innerhalb der erlaubten Bereiche // oder Default - if(nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1] ) ) + if(nActFamily == SFX_TEMPLDLG_FILTER_MAX || 0 == (pItem = pFamilyState[nActFamily-1] ) ) { CheckItem(nActFamily, sal_False); SfxTemplateItem **ppItem = pFamilyState; @@ -1496,7 +1501,7 @@ void SfxCommonTemplateDialog_Impl::Updat // andere DocShell -> alles neu CheckItem( nActFamily, sal_True ); nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) ); - if ( 0xFFFF == nActFilter ) + if ( SFX_TEMPLDLG_FILTER_MAX == nActFilter ) nActFilter = pDocShell->GetAutoStyleFilterIndex(); nAppFilter = pItem->GetValue(); @@ -1512,10 +1517,6 @@ void SfxCommonTemplateDialog_Impl::Updat // anderer Filter fuer automatisch CheckItem( nActFamily, sal_True ); const SfxStyleFamilyItem *pStyleItem = GetFamilyItem_Impl(); -#if OSL_DEBUG_LEVEL > 1 - SfxFilterTupel *pT; - pT = pStyleItem->GetFilterList().GetObject(nActFilter); -#endif if(0 == pStyleItem->GetFilterList().GetObject(nActFilter)->nFlags && nAppFilter != pItem->GetValue()) { @@ -1791,6 +1792,17 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, SelectStyle(aSelectEntry); pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST)); pTreeBox->Show(); + + // Save the filter state + SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); + SfxObjectShell *pDocShell = pViewFrame->GetObjectShell(); + if (pDocShell) + { + // only in the configuration + // SetAutoStyleFilterIndex would update nActFilter + // which should only contain a valid listbox entry + SaveFactoryStyleFilter( pDocShell, SFX_TEMPLDLG_FILTER_HIERARCHICAL ); + } } } @@ -1861,13 +1873,13 @@ void SfxCommonTemplateDialog_Impl::Actio } case SID_STYLE_NEW_BY_EXAMPLE: { - if(pStyleSheetPool && nActFamily != 0xffff) + if(pStyleSheetPool && nActFamily != SFX_TEMPLDLG_FILTER_MAX) { const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily(); //pStyleSheetPool->GetSearchFamily(); const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); sal_uInt16 nFilter; - if(pItem&&nActFilter!=0xffff) + if(pItem&&nActFilter!=SFX_TEMPLDLG_FILTER_MAX) { nFilter = pItem->GetFilterList().GetObject( nActFilter)->nFlags; @@ -1958,7 +1970,7 @@ sal_Int32 SfxCommonTemplateDialog_Impl:: void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ) { - DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); + DBG_ASSERT( i_pObjSh, "SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter(): no ObjectShell" ); Reference< ::com::sun::star::container::XNameReplace > xContainer( xModuleManager, UNO_QUERY ); if ( xContainer.is() ) { @@ -1987,7 +1999,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, void SfxCommonTemplateDialog_Impl::NewHdl(void *) { String aEmpty; - if ( nActFamily != 0xffff ) + if ( nActFamily != SFX_TEMPLDLG_FILTER_MAX ) { Window* pTmp; pTmp = Application::GetDefDialogParent(); @@ -1999,7 +2011,7 @@ void SfxCommonTemplateDialog_Impl::NewHd const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); const SfxStyleFamily eFam=pItem->GetFamily(); sal_uInt16 nMask; - if(pItem&&nActFilter!=0xffff) + if(pItem&&nActFilter!=SFX_TEMPLDLG_FILTER_MAX) { nMask = pItem->GetFilterList().GetObject( nActFilter)->nFlags; @@ -2267,7 +2279,7 @@ void SfxCommonTemplateDialog_Impl::Execu SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const { const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl(); - if( !pFamilyItem || nActFamily == 0xffff ) + if( !pFamilyItem || nActFamily == SFX_TEMPLDLG_FILTER_MAX ) return SFX_STYLE_FAMILY_PARA; else return pFamilyItem->GetFamily(); @@ -2321,6 +2333,16 @@ SfxTemplateDialog_Impl::SfxTemplateDialo { pDlgWindow->FreeResource(); + + // Read the filter stored in the configuration + // This is already done in ReadResource(), invoked by Initialize() + // and stored in nActFilter, but we can't rely on nActFilter's value + // because it is changed in UpdateStyles_Impl + SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame(); + pCurObjShell = pViewFrame->GetObjectShell(); + const sal_uInt16 nConfigFilter = pCurObjShell ? + static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0; + Initialize(); m_aActionTbL.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect)); @@ -2332,6 +2354,13 @@ SfxTemplateDialog_Impl::SfxTemplateDialo aFont.SetWeight( WEIGHT_NORMAL ); aFilterLb.SetFont( aFont ); m_aActionTbL.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT ); + + if ( nConfigFilter == SFX_TEMPLDLG_FILTER_HIERARCHICAL ) + { + bHierarchical = sal_False; + aFilterLb.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL))); + FilterSelectHdl(&aFilterLb); + } } // ------------------------------------------------------------------------ @@ -2916,10 +2945,10 @@ void SfxCommonTemplateDialog_Impl::SetFa { if ( nId != nActFamily ) { - if ( nActFamily != 0xFFFF ) + if ( nActFamily != SFX_TEMPLDLG_FILTER_MAX ) CheckItem( nActFamily, sal_False ); nActFamily = nId; - if ( nId != 0xFFFF ) + if ( nId != SFX_TEMPLDLG_FILTER_MAX ) bUpdateFamily = sal_True; } }