LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - swuiccoll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 147 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "cmdid.h"
      30                 :            : #include "swmodule.hxx"
      31                 :            : #include "view.hxx"
      32                 :            : #include "wrtsh.hxx"
      33                 :            : #include "globals.hrc"
      34                 :            : #include "helpid.h"
      35                 :            : 
      36                 :            : #include <sfx2/styfitem.hxx>
      37                 :            : 
      38                 :            : #include "uitool.hxx"
      39                 :            : #include "ccoll.hxx"
      40                 :            : #include "fmtcol.hxx"
      41                 :            : #include "hintids.hxx"
      42                 :            : #include "docsh.hxx"
      43                 :            : #include "docstyle.hxx"
      44                 :            : #include "hints.hxx"
      45                 :            : 
      46                 :            : #include "chrdlg.hrc"
      47                 :            : #include "ccoll.hrc"
      48                 :            : #include <vcl/svapp.hxx>
      49                 :            : 
      50                 :            : #include "swuiccoll.hxx"
      51                 :            : 
      52                 :            : static sal_uInt16 aPageRg[] = {
      53                 :            :     FN_COND_COLL, FN_COND_COLL,
      54                 :            :     0
      55                 :            : };
      56                 :            : 
      57                 :            : // Warning! This table is indicated directly in code (0, 1, ...)
      58                 :            : static long nTabs[] =
      59                 :            :     {   2, // Number of Tabs
      60                 :            :         0, 100
      61                 :            :     };
      62                 :            : 
      63                 :          0 : SwCondCollPage::SwCondCollPage(Window *pParent, const SfxItemSet &rSet)
      64                 :            : 
      65                 :            :     : SfxTabPage(pParent, SW_RES(TP_CONDCOLL), rSet),
      66                 :            :     aConditionFL( this, SW_RES( FL_CONDITION )),
      67                 :            :     aConditionCB( this, SW_RES( CB_CONDITION ) ),
      68                 :            :     aContextFT  ( this, SW_RES( FT_CONTEXT  ) ),
      69                 :            :     aUsedFT     ( this, SW_RES( FT_USED         ) ),
      70                 :            :     aTbLinks(     this, SW_RES( TB_CONDCOLLS ) ),
      71                 :            :     aStyleFT    ( this, SW_RES( FT_STYLE    ) ),
      72                 :            :     aStyleLB    ( this, SW_RES( LB_STYLE    ) ),
      73                 :            :     aFilterLB   ( this, SW_RES( LB_FILTER   ) ),
      74                 :            :     aRemovePB   ( this, SW_RES( PB_REMOVE   ) ),
      75                 :            :     aAssignPB   ( this, SW_RES( PB_ASSIGN   ) ),
      76                 :            :     sNoTmpl     (       SW_RES( STR_NOTEMPL  ) ),
      77                 :            :     aStrArr     (       SW_RES( STR_REGIONS  ) ),
      78                 :          0 :     rSh(::GetActiveView()->GetWrtShell()),
      79                 :          0 :     pCmds( SwCondCollItem::GetCmds() ),
      80                 :            :     pFmt(0),
      81                 :            : 
      82                 :          0 :     bNewTemplate(sal_False)
      83                 :            : {
      84                 :          0 :     FreeResource();
      85                 :          0 :     SetExchangeSupport();
      86                 :            : 
      87                 :          0 :     aRemovePB.SetAccessibleRelationMemberOf(&aConditionFL);
      88                 :          0 :     aAssignPB.SetAccessibleRelationMemberOf(&aConditionFL);
      89                 :          0 :     aTbLinks.SetAccessibleRelationLabeledBy(&aConditionCB);
      90                 :            : 
      91                 :            :     // Install handlers
      92                 :          0 :     aConditionCB.SetClickHdl(   LINK(this, SwCondCollPage, OnOffHdl));
      93                 :          0 :     aTbLinks.SetDoubleClickHdl( LINK(this, SwCondCollPage, AssignRemoveHdl ));
      94                 :          0 :     aStyleLB.SetDoubleClickHdl( LINK(this, SwCondCollPage, AssignRemoveHdl ));
      95                 :          0 :     aRemovePB.SetClickHdl(      LINK(this, SwCondCollPage, AssignRemoveHdl ));
      96                 :          0 :     aAssignPB.SetClickHdl(      LINK(this, SwCondCollPage, AssignRemoveHdl ));
      97                 :          0 :     aTbLinks.SetSelectHdl(      LINK(this, SwCondCollPage, SelectHdl));
      98                 :          0 :     aStyleLB.SetSelectHdl(      LINK(this, SwCondCollPage, SelectHdl));
      99                 :          0 :     aFilterLB.SetSelectHdl(     LINK(this, SwCondCollPage, SelectHdl));
     100                 :            : 
     101                 :          0 :     aTbLinks.SetStyle(aTbLinks.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN);
     102                 :          0 :     aTbLinks.SetSelectionMode( SINGLE_SELECTION );
     103                 :          0 :     aTbLinks.SetTabs( &nTabs[0], MAP_APPFONT );
     104                 :          0 :     aTbLinks.Resize();  // OS: Hack for the right selection
     105                 :          0 :     aTbLinks.SetSpaceBetweenEntries( 0 );
     106                 :          0 :     aTbLinks.SetHelpId(HID_COND_COLL_TABLIST);
     107                 :            : 
     108                 :          0 :     SfxStyleFamilies aFamilies(SW_RES(DLG_STYLE_DESIGNER));
     109                 :          0 :     const SfxStyleFamilyItem* pFamilyItem = 0;
     110                 :            : 
     111                 :          0 :     size_t nCount = aFamilies.size();
     112                 :          0 :     for( size_t i = 0; i < nCount; ++i )
     113                 :            :     {
     114                 :          0 :         if(SFX_STYLE_FAMILY_PARA == (sal_uInt16)(pFamilyItem = aFamilies.at( i ))->GetFamily())
     115                 :          0 :             break;
     116                 :            :     }
     117                 :            : 
     118                 :          0 :     const SfxStyleFilter& rFilterList = pFamilyItem->GetFilterList();
     119                 :          0 :     for( size_t i = 0; i < rFilterList.size(); ++i )
     120                 :            :     {
     121                 :          0 :         aFilterLB.InsertEntry( rFilterList[ i ]->aName);
     122                 :          0 :         sal_uInt16* pFilter = new sal_uInt16(rFilterList[i]->nFlags);
     123                 :          0 :         aFilterLB.SetEntryData(i, pFilter);
     124                 :            :     }
     125                 :          0 :     aFilterLB.SelectEntryPos(1);
     126                 :            : 
     127                 :          0 :     aTbLinks.Show();
     128                 :            : 
     129                 :          0 : }
     130                 :            : 
     131                 :            : /****************************************************************************
     132                 :            : Page: Dtor
     133                 :            : ****************************************************************************/
     134                 :            : 
     135                 :            : 
     136                 :          0 : SwCondCollPage::~SwCondCollPage()
     137                 :            : {
     138                 :          0 :     for(sal_uInt16 i = 0; i < aFilterLB.GetEntryCount(); ++i)
     139                 :          0 :         delete (sal_uInt16*)aFilterLB.GetEntryData(i);
     140                 :            : 
     141                 :          0 : }
     142                 :            : 
     143                 :            : 
     144                 :          0 : int SwCondCollPage::DeactivatePage(SfxItemSet * _pSet)
     145                 :            : {
     146                 :          0 :     if( _pSet )
     147                 :          0 :         FillItemSet(*_pSet);
     148                 :            : 
     149                 :          0 :     return LEAVE_PAGE;
     150                 :            : }
     151                 :            : 
     152                 :            : /****************************************************************************
     153                 :            : Page: Factory
     154                 :            : ****************************************************************************/
     155                 :            : 
     156                 :            : 
     157                 :          0 : SfxTabPage* SwCondCollPage::Create(Window *pParent, const SfxItemSet &rSet)
     158                 :            : {
     159                 :          0 :     return new SwCondCollPage(pParent, rSet);
     160                 :            : }
     161                 :            : 
     162                 :            : /****************************************************************************
     163                 :            : Page: FillItemSet-Overload
     164                 :            : ****************************************************************************/
     165                 :            : 
     166                 :            : 
     167                 :          0 : sal_Bool SwCondCollPage::FillItemSet(SfxItemSet &rSet)
     168                 :            : {
     169                 :          0 :     sal_Bool bModified = sal_True;
     170                 :          0 :     SwCondCollItem aCondItem;
     171                 :          0 :     for(sal_uInt16 i = 0; i < aStrArr.Count(); i++)
     172                 :            :     {
     173                 :          0 :         String sEntry = aTbLinks.GetEntryText(i, 1);
     174                 :          0 :         aCondItem.SetStyle( &sEntry, i);
     175                 :          0 :     }
     176                 :          0 :     rSet.Put(aCondItem);
     177                 :          0 :     return bModified;
     178                 :            : }
     179                 :            : 
     180                 :            : /****************************************************************************
     181                 :            : Page: Reset-Overload
     182                 :            : ****************************************************************************/
     183                 :            : 
     184                 :            : 
     185                 :          0 : void SwCondCollPage::Reset(const SfxItemSet &/*rSet*/)
     186                 :            : {
     187                 :          0 :     if(bNewTemplate)
     188                 :          0 :         aConditionCB.Enable();
     189                 :          0 :     if(RES_CONDTXTFMTCOLL == pFmt->Which())
     190                 :          0 :         aConditionCB.Check();
     191                 :          0 :     OnOffHdl(&aConditionCB);
     192                 :            : 
     193                 :          0 :     aTbLinks.Clear();
     194                 :            : 
     195                 :          0 :     SfxStyleSheetBasePool* pPool = rSh.GetView().GetDocShell()->GetStyleSheetPool();
     196                 :          0 :     pPool->SetSearchMask(SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL);
     197                 :          0 :     aStyleLB.Clear();
     198                 :          0 :     const SfxStyleSheetBase* pBase = pPool->First();
     199                 :          0 :     while( pBase )
     200                 :            :     {
     201                 :          0 :         if(!pFmt || pBase->GetName() != pFmt->GetName())
     202                 :          0 :             aStyleLB.InsertEntry(pBase->GetName());
     203                 :          0 :         pBase = pPool->Next();
     204                 :            :     }
     205                 :          0 :     aStyleLB.SelectEntryPos(0);
     206                 :            : 
     207                 :          0 :     for( sal_uInt16 n = 0; n < aStrArr.Count(); n++)
     208                 :            :     {
     209                 :          0 :         String aEntry( aStrArr.GetString(n) );
     210                 :          0 :         aEntry += '\t';
     211                 :            : 
     212                 :          0 :         const SwCollCondition* pCond = 0;
     213                 :          0 :         if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
     214                 :            :             0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
     215                 :          0 :             HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
     216                 :          0 :             && pCond->GetTxtFmtColl() )
     217                 :            :         {
     218                 :          0 :             aEntry += pCond->GetTxtFmtColl()->GetName();
     219                 :            :         }
     220                 :            : 
     221                 :          0 :         SvLBoxEntry* pE = aTbLinks.InsertEntryToColumn( aEntry, n );
     222                 :          0 :         if(0 == n)
     223                 :          0 :             aTbLinks.Select(pE);
     224                 :          0 :     }
     225                 :            : 
     226                 :          0 : }
     227                 :            : 
     228                 :          0 : sal_uInt16* SwCondCollPage::GetRanges()
     229                 :            : {
     230                 :          0 :     return aPageRg;
     231                 :            : }
     232                 :            : 
     233                 :          0 : IMPL_LINK( SwCondCollPage, OnOffHdl, CheckBox*, pBox )
     234                 :            : {
     235                 :          0 :     const sal_Bool bEnable = pBox->IsChecked();
     236                 :          0 :     aContextFT.Enable( bEnable );
     237                 :          0 :     aUsedFT   .Enable( bEnable );
     238                 :          0 :     aTbLinks  .EnableList( bEnable != sal_False );
     239                 :          0 :     aStyleFT  .Enable( bEnable );
     240                 :          0 :     aStyleLB  .Enable( bEnable );
     241                 :          0 :     aFilterLB .Enable( bEnable );
     242                 :          0 :     aRemovePB .Enable( bEnable );
     243                 :          0 :     aAssignPB .Enable( bEnable );
     244                 :          0 :     if( bEnable )
     245                 :          0 :         SelectHdl(0);
     246                 :          0 :     return 0;
     247                 :            : }
     248                 :            : 
     249                 :          0 : IMPL_LINK( SwCondCollPage, AssignRemoveHdl, PushButton*, pBtn)
     250                 :            : {
     251                 :          0 :     SvLBoxEntry* pE = aTbLinks.FirstSelected();
     252                 :            :     sal_uLong nPos;
     253                 :          0 :     if( !pE || LISTBOX_ENTRY_NOTFOUND ==
     254                 :          0 :         ( nPos = aTbLinks.GetModel()->GetAbsPos( pE ) ) )
     255                 :            :     {
     256                 :            :         OSL_ENSURE( pE, "where's the empty entry from?" );
     257                 :          0 :         return 0;
     258                 :            :     }
     259                 :            : 
     260                 :          0 :     String sSel = aStrArr.GetString( sal_uInt16(nPos) );
     261                 :          0 :     sSel += '\t';
     262                 :            : 
     263                 :          0 :     const sal_Bool bAssEnabled = pBtn != &aRemovePB && aAssignPB.IsEnabled();
     264                 :          0 :     aAssignPB.Enable( !bAssEnabled );
     265                 :          0 :     aRemovePB.Enable(  bAssEnabled );
     266                 :          0 :     if ( bAssEnabled )
     267                 :          0 :         sSel += aStyleLB.GetSelectEntry();
     268                 :            : 
     269                 :          0 :     aTbLinks.SetUpdateMode(sal_False);
     270                 :          0 :     aTbLinks.GetModel()->Remove(pE);
     271                 :          0 :     pE = aTbLinks.InsertEntryToColumn(sSel, nPos);
     272                 :          0 :     aTbLinks.Select(pE);
     273                 :          0 :     aTbLinks.MakeVisible(pE);
     274                 :          0 :     aTbLinks.SetUpdateMode(sal_True);
     275                 :          0 :     return 0;
     276                 :            : }
     277                 :            : 
     278                 :          0 : IMPL_LINK( SwCondCollPage, SelectHdl, ListBox*, pBox)
     279                 :            : {
     280                 :          0 :     if(pBox == &aFilterLB)
     281                 :            :     {
     282                 :          0 :         aStyleLB.Clear();
     283                 :          0 :         sal_uInt16 nSearchFlags = pBox->GetSelectEntryPos();
     284                 :          0 :         nSearchFlags = *(sal_uInt16*)aFilterLB.GetEntryData(nSearchFlags);
     285                 :          0 :         SfxStyleSheetBasePool* pPool = rSh.GetView().GetDocShell()->GetStyleSheetPool();
     286                 :          0 :         pPool->SetSearchMask(SFX_STYLE_FAMILY_PARA, nSearchFlags);
     287                 :          0 :         const SfxStyleSheetBase* pBase = pPool->First();
     288                 :            : 
     289                 :          0 :         while( pBase )
     290                 :            :         {
     291                 :          0 :             if(!pFmt || pBase->GetName() != pFmt->GetName())
     292                 :          0 :                 aStyleLB.InsertEntry(pBase->GetName());
     293                 :          0 :             pBase = pPool->Next();
     294                 :            :         }
     295                 :          0 :         aStyleLB.SelectEntryPos(0);
     296                 :          0 :         SelectHdl(&aStyleLB);
     297                 :            : 
     298                 :            :     }
     299                 :            :     else
     300                 :            :     {
     301                 :          0 :         String sTbEntry;
     302                 :          0 :         SvLBoxEntry* pE = aTbLinks.FirstSelected();
     303                 :          0 :         if(pE)
     304                 :          0 :             sTbEntry = aTbLinks.GetEntryText(pE);
     305                 :          0 :         sTbEntry = sTbEntry.GetToken(1, '\t');
     306                 :          0 :         String sStyle = aStyleLB.GetSelectEntry();
     307                 :            : 
     308                 :          0 :         aAssignPB.Enable( sStyle != sTbEntry && aConditionCB.IsChecked() );
     309                 :            : 
     310                 :          0 :         if(pBox != &aStyleLB)
     311                 :          0 :             aRemovePB.Enable( aConditionCB.IsChecked() && sTbEntry.Len() );
     312                 :            :     }
     313                 :          0 :     return 0;
     314                 :            : }
     315                 :            : 
     316                 :          0 : void SwCondCollPage::SetCollection( SwFmt* pFormat, sal_Bool bNew )
     317                 :            : {
     318                 :          0 :     pFmt = pFormat;
     319                 :          0 :     bNewTemplate = bNew;
     320                 :          0 : }
     321                 :            : 
     322                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10