LCOV - code coverage report
Current view: top level - cui/source/dialogs - srchxtra.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 136 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "srchxtra.hxx"
      21             : #include <tools/rcid.h>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <svl/cjkoptions.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <sfx2/objsh.hxx>
      26             : #include <cuires.hrc>
      27             : #include <svx/svxitems.hrc>
      28             : #include <svx/dialmgr.hxx>
      29             : #include <editeng/flstitem.hxx>
      30             : #include "chardlg.hxx"
      31             : #include "paragrph.hxx"
      32             : #include <dialmgr.hxx>
      33             : #include "backgrnd.hxx"
      34             : #include <svx/dialogs.hrc>
      35             : #include <tools/resary.hxx>
      36             : #include <rtl/strbuf.hxx>
      37             : #include "svtools/treelistentry.hxx"
      38             : 
      39           0 : SvxSearchFormatDialog::SvxSearchFormatDialog(vcl::Window* pParent, const SfxItemSet& rSet)
      40             :     : SfxTabDialog(pParent, "SearchFormatDialog", "cui/ui/searchformatdialog.ui", &rSet)
      41             :     , m_pFontList(NULL)
      42             :     , m_nNamePageId(0)
      43             :     , m_nParaStdPageId(0)
      44             :     , m_nParaAlignPageId(0)
      45           0 :     , m_nBackPageId(0)
      46             : {
      47           0 :     m_nNamePageId = AddTabPage("font", SvxCharNamePage::Create, 0);
      48           0 :     AddTabPage("fonteffects", SvxCharEffectsPage::Create, 0);
      49           0 :     AddTabPage("position", SvxCharPositionPage::Create, 0);
      50           0 :     AddTabPage("asianlayout", SvxCharTwoLinesPage::Create, 0);
      51           0 :     m_nParaStdPageId = AddTabPage("labelTP_PARA_STD", SvxStdParagraphTabPage::Create, 0);
      52           0 :     m_nParaAlignPageId = AddTabPage("labelTP_PARA_ALIGN", SvxParaAlignTabPage::Create, 0);
      53           0 :     AddTabPage("labelTP_PARA_EXT", SvxExtParagraphTabPage::Create, 0);
      54           0 :     AddTabPage("labelTP_PARA_ASIAN", SvxAsianTabPage::Create, 0 );
      55           0 :     m_nBackPageId = AddTabPage("background", SvxBackgroundTabPage::Create, 0);
      56             : 
      57             :     // remove asian tabpages if necessary
      58           0 :     SvtCJKOptions aCJKOptions;
      59           0 :     if ( !aCJKOptions.IsDoubleLinesEnabled() )
      60           0 :         RemoveTabPage("asianlayout");
      61           0 :     if ( !aCJKOptions.IsAsianTypographyEnabled() )
      62           0 :         RemoveTabPage("labelTP_PARA_ASIAN");
      63           0 : }
      64             : 
      65           0 : SvxSearchFormatDialog::~SvxSearchFormatDialog()
      66             : {
      67           0 :     disposeOnce();
      68           0 : }
      69             : 
      70           0 : void SvxSearchFormatDialog::dispose()
      71             : {
      72           0 :     delete m_pFontList;
      73           0 :     m_pFontList = NULL;
      74           0 :     SfxTabDialog::dispose();
      75           0 : }
      76             : 
      77           0 : void SvxSearchFormatDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage )
      78             : {
      79           0 :     if (nId == m_nNamePageId)
      80             :     {
      81           0 :         const FontList* pApm_pFontList = 0;
      82           0 :         SfxObjectShell* pSh = SfxObjectShell::Current();
      83             : 
      84           0 :         if ( pSh )
      85             :         {
      86             :             const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>(
      87           0 :                 pSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
      88           0 :             if ( pFLItem )
      89           0 :                 pApm_pFontList = pFLItem->GetFontList();
      90             :         }
      91             : 
      92           0 :         const FontList* pList = pApm_pFontList;
      93             : 
      94           0 :         if ( !pList )
      95             :         {
      96           0 :             if ( !m_pFontList )
      97           0 :                 m_pFontList = new FontList( this );
      98           0 :             pList = m_pFontList;
      99             :         }
     100             : 
     101           0 :         if ( pList )
     102             :             static_cast<SvxCharNamePage&>(rPage).
     103           0 :                 SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
     104           0 :         static_cast<SvxCharNamePage&>(rPage).EnableSearchMode();
     105             :     }
     106           0 :     else if (nId == m_nParaStdPageId)
     107             :     {
     108           0 :         static_cast<SvxStdParagraphTabPage&>(rPage).EnableAutoFirstLine();
     109             :     }
     110           0 :     else if (nId == m_nParaAlignPageId)
     111             :     {
     112           0 :         static_cast<SvxParaAlignTabPage&>(rPage).EnableJustifyExt();
     113             :     }
     114           0 :     else if (nId == m_nBackPageId)
     115             :     {
     116           0 :         static_cast<SvxBackgroundTabPage&>(rPage).ShowParaControl(true);
     117             :     }
     118           0 : }
     119             : 
     120           0 : SvxSearchAttributeDialog::SvxSearchAttributeDialog(vcl::Window* pParent,
     121             :     SearchAttrItemList& rLst, const sal_uInt16* pWhRanges)
     122             :     : ModalDialog(pParent, "SearchAttrDialog", "cui/ui/searchattrdialog.ui")
     123           0 :     , rList(rLst)
     124             : {
     125           0 :     get(m_pOKBtn, "ok");
     126           0 :     get(m_pAttrLB, "treeview");
     127           0 :     m_pAttrLB->set_height_request(m_pAttrLB->GetTextHeight() * 12);
     128           0 :     m_pAttrLB->set_width_request(m_pAttrLB->approximate_char_width() * 56);
     129             : 
     130           0 :     m_pAttrLB->SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
     131           0 :     m_pAttrLB->GetModel()->SetSortMode( SortAscending );
     132             : 
     133           0 :     m_pOKBtn->SetClickHdl( LINK( this, SvxSearchAttributeDialog, OKHdl ) );
     134             : 
     135           0 :     SfxObjectShell* pSh = SfxObjectShell::Current();
     136             :     DBG_ASSERT( pSh, "No DocShell" );
     137             : 
     138           0 :     ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
     139           0 :     SfxItemPool& rPool = pSh->GetPool();
     140           0 :     SfxItemSet aSet( rPool, pWhRanges );
     141           0 :     SfxWhichIter aIter( aSet );
     142           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     143             : 
     144           0 :     while ( nWhich )
     145             :     {
     146           0 :         sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
     147           0 :         if ( nSlot >= SID_SVX_START )
     148             :         {
     149           0 :             bool bChecked = false, bFound = false;
     150           0 :             for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
     151             :             {
     152           0 :                 if ( nSlot == rList[i].nSlot )
     153             :                 {
     154           0 :                     bFound = true;
     155           0 :                     if ( IsInvalidItem( rList[i].pItem ) )
     156           0 :                         bChecked = true;
     157             :                 }
     158             :             }
     159             : 
     160             :             // item resources are in svx
     161           0 :             sal_uInt32 nId  = aAttrNames.FindIndex( nSlot );
     162           0 :             SvTreeListEntry* pEntry = NULL;
     163           0 :             if ( RESARRAY_INDEX_NOTFOUND != nId )
     164           0 :                 pEntry = m_pAttrLB->SvTreeListBox::InsertEntry( aAttrNames.GetString(nId) );
     165             :             else
     166             :                 SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) );
     167             : 
     168           0 :             if ( pEntry )
     169             :             {
     170           0 :                 m_pAttrLB->SetCheckButtonState( pEntry, bChecked ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
     171           0 :                 pEntry->SetUserData( reinterpret_cast<void*>(nSlot) );
     172             :             }
     173             :         }
     174           0 :         nWhich = aIter.NextWhich();
     175             :     }
     176             : 
     177           0 :     m_pAttrLB->SetHighlightRange();
     178           0 :     m_pAttrLB->SelectEntryPos( 0 );
     179           0 : }
     180             : 
     181           0 : SvxSearchAttributeDialog::~SvxSearchAttributeDialog()
     182             : {
     183           0 :     disposeOnce();
     184           0 : }
     185             : 
     186           0 : void SvxSearchAttributeDialog::dispose()
     187             : {
     188           0 :     m_pAttrLB.clear();
     189           0 :     m_pOKBtn.clear();
     190           0 :     ModalDialog::dispose();
     191           0 : }
     192             : 
     193             : 
     194           0 : IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl)
     195             : {
     196             :     SearchAttrItem aInvalidItem;
     197           0 :     aInvalidItem.pItem = reinterpret_cast<SfxPoolItem*>(-1);
     198             : 
     199           0 :     for ( sal_uLong i = 0; i < m_pAttrLB->GetEntryCount(); ++i )
     200             :     {
     201           0 :         sal_uInt16 nSlot = (sal_uInt16)reinterpret_cast<sal_uLong>(m_pAttrLB->GetEntryData(i));
     202           0 :         bool bChecked = m_pAttrLB->IsChecked(i);
     203             : 
     204             :         sal_uInt16 j;
     205           0 :         for ( j = rList.Count(); j; )
     206             :         {
     207           0 :             SearchAttrItem& rItem = rList[ --j ];
     208           0 :             if( rItem.nSlot == nSlot )
     209             :             {
     210           0 :                 if( bChecked )
     211             :                 {
     212           0 :                     if( !IsInvalidItem( rItem.pItem ) )
     213           0 :                         delete rItem.pItem;
     214           0 :                     rItem.pItem = reinterpret_cast<SfxPoolItem*>(-1);
     215             :                 }
     216           0 :                 else if( IsInvalidItem( rItem.pItem ) )
     217           0 :                     rItem.pItem = 0;
     218           0 :                 j = 1;
     219           0 :                 break;
     220             :             }
     221             :         }
     222             : 
     223           0 :         if ( !j && bChecked )
     224             :         {
     225           0 :             aInvalidItem.nSlot = nSlot;
     226           0 :             rList.Insert( aInvalidItem );
     227             :         }
     228             :     }
     229             : 
     230             :     // remove invalid items (pItem == NULL)
     231           0 :     for ( sal_uInt16 n = rList.Count(); n; )
     232           0 :         if ( !rList[ --n ].pItem )
     233           0 :             rList.Remove( n );
     234             : 
     235           0 :     EndDialog( RET_OK );
     236           0 :     return 0;
     237             : }
     238             : 
     239             : // class SvxSearchSimilarityDialog ---------------------------------------
     240             : 
     241           0 : SvxSearchSimilarityDialog::SvxSearchSimilarityDialog
     242             : (
     243             :     vcl::Window* pParent,
     244             :     bool bRelax,
     245             :     sal_uInt16 nOther,
     246             :     sal_uInt16 nShorter,
     247             :     sal_uInt16 nLonger
     248             : ) :
     249           0 :     ModalDialog( pParent, "SimilaritySearchDialog", "cui/ui/similaritysearchdialog.ui" )
     250             : {
     251           0 :     get( m_pOtherFld, "otherfld");
     252           0 :     get( m_pLongerFld, "longerfld");
     253           0 :     get( m_pShorterFld, "shorterfld");
     254           0 :     get( m_pRelaxBox, "relaxbox");
     255             : 
     256           0 :     m_pOtherFld->SetValue( nOther );
     257           0 :     m_pShorterFld->SetValue( nShorter );
     258           0 :     m_pLongerFld->SetValue( nLonger );
     259           0 :     m_pRelaxBox->Check( bRelax );
     260           0 : }
     261             : 
     262           0 : SvxSearchSimilarityDialog::~SvxSearchSimilarityDialog()
     263             : {
     264           0 :     disposeOnce();
     265           0 : }
     266             : 
     267           0 : void SvxSearchSimilarityDialog::dispose()
     268             : {
     269           0 :     m_pOtherFld.clear();
     270           0 :     m_pLongerFld.clear();
     271           0 :     m_pShorterFld.clear();
     272           0 :     m_pRelaxBox.clear();
     273           0 :     ModalDialog::dispose();
     274           0 : }
     275             : 
     276             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11