LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - chardlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 150 0.0 %
Date: 2012-08-25 Functions: 0 14 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 <hintids.hxx>
      30                 :            : 
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : #include <svl/urihelper.hxx>
      33                 :            : #include <svl/stritem.hxx>
      34                 :            : #include <editeng/flstitem.hxx>
      35                 :            : #include <svx/htmlmode.hxx>
      36                 :            : #include <svl/cjkoptions.hxx>
      37                 :            : 
      38                 :            : #include <cmdid.h>
      39                 :            : #include <helpid.h>
      40                 :            : #include <swtypes.hxx>
      41                 :            : #include <view.hxx>
      42                 :            : #include <wrtsh.hxx>
      43                 :            : #include <docsh.hxx>
      44                 :            : #include <uitool.hxx>
      45                 :            : #include <fmtinfmt.hxx>
      46                 :            : #include <macassgn.hxx>
      47                 :            : #include <chrdlg.hxx>       // the dialog
      48                 :            : #include <swmodule.hxx>
      49                 :            : #include <poolfmt.hxx>
      50                 :            : 
      51                 :            : #include <globals.hrc>
      52                 :            : #include <chrdlg.hrc>
      53                 :            : #include <chardlg.hrc>
      54                 :            : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      55                 :            : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      56                 :            : #include <SwStyleNameMapper.hxx>
      57                 :            : #include <sfx2/filedlghelper.hxx>
      58                 :            : #include <sfx2/viewfrm.hxx>
      59                 :            : 
      60                 :            : #include <svx/svxdlg.hxx>
      61                 :            : #include <svx/svxids.hrc>
      62                 :            : #include <svx/flagsdef.hxx>
      63                 :            : #include <svx/dialogs.hrc>
      64                 :            : 
      65                 :            : using namespace ::com::sun::star::ui::dialogs;
      66                 :            : using namespace ::com::sun::star::lang;
      67                 :            : using namespace ::com::sun::star::uno;
      68                 :            : using namespace ::sfx2;
      69                 :            : 
      70                 :          0 : SwCharDlg::SwCharDlg(Window* pParent, SwView& rVw, const SfxItemSet& rCoreSet,
      71                 :            :                      const String* pStr, sal_Bool bIsDrwTxtDlg) :
      72                 :            :     SfxTabDialog(pParent, SW_RES(DLG_CHAR), &rCoreSet, pStr != 0),
      73                 :            :     rView(rVw),
      74                 :          0 :     bIsDrwTxtMode(bIsDrwTxtDlg)
      75                 :            : {
      76                 :          0 :     FreeResource();
      77                 :            : 
      78                 :          0 :     if(pStr)
      79                 :            :     {
      80                 :          0 :         String aTmp( GetText() );
      81                 :          0 :         aTmp += SW_RESSTR(STR_TEXTCOLL_HEADER);
      82                 :          0 :         aTmp += *pStr;
      83                 :          0 :         aTmp += ')';
      84                 :          0 :         SetText(aTmp);
      85                 :            :     }
      86                 :          0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
      87                 :            :     OSL_ENSURE(pFact, "Dialogdiet fail!");
      88                 :          0 :     AddTabPage(TP_CHAR_STD, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), 0 );
      89                 :          0 :     AddTabPage(TP_CHAR_EXT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), 0 );
      90                 :          0 :     AddTabPage(TP_CHAR_POS, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_POSITION ), 0 );
      91                 :          0 :     AddTabPage(TP_CHAR_TWOLN, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_TWOLINES ), 0 );
      92                 :          0 :     AddTabPage(TP_CHAR_URL, SwCharURLPage::Create, 0);
      93                 :          0 :     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
      94                 :            : 
      95                 :          0 :     SvtCJKOptions aCJKOptions;
      96                 :          0 :     if(bIsDrwTxtMode)
      97                 :            :     {
      98                 :          0 :         RemoveTabPage( TP_CHAR_URL );
      99                 :          0 :         RemoveTabPage( TP_BACKGROUND );
     100                 :          0 :         RemoveTabPage( TP_CHAR_TWOLN );
     101                 :            :     }
     102                 :          0 :     else if(!aCJKOptions.IsDoubleLinesEnabled())
     103                 :          0 :         RemoveTabPage( TP_CHAR_TWOLN );
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : SwCharDlg::~SwCharDlg()
     107                 :            : {
     108                 :          0 : }
     109                 :            : 
     110                 :            : /*--------------------------------------------------------------------
     111                 :            :     Description:    set FontList
     112                 :            :  --------------------------------------------------------------------*/
     113                 :            : 
     114                 :          0 : void SwCharDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     115                 :            : {
     116                 :          0 :     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
     117                 :          0 :     switch( nId )
     118                 :            :     {
     119                 :            :         case TP_CHAR_STD:
     120                 :            :             {
     121                 :            :             SvxFontListItem aFontListItem( *( (SvxFontListItem*)
     122                 :          0 :                ( rView.GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ) ) );
     123                 :          0 :             aSet.Put (SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
     124                 :          0 :                 if(!bIsDrwTxtMode)
     125                 :          0 :                     aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     126                 :          0 :             rPage.PageCreated(aSet);
     127                 :            :             }
     128                 :          0 :             break;
     129                 :            :         case TP_CHAR_EXT:
     130                 :          0 :             if(bIsDrwTxtMode)
     131                 :          0 :                 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
     132                 :            : 
     133                 :            :             else
     134                 :            :             {
     135                 :          0 :                 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER|SVX_ENABLE_FLASH));
     136                 :            :             }
     137                 :          0 :             rPage.PageCreated(aSet);
     138                 :          0 :             break;
     139                 :            :         case TP_CHAR_POS:
     140                 :          0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     141                 :          0 :             rPage.PageCreated(aSet);
     142                 :          0 :         break;
     143                 :            :         case TP_CHAR_TWOLN:
     144                 :          0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     145                 :          0 :             rPage.PageCreated(aSet);
     146                 :          0 :         break;
     147                 :          0 :     }
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : SwCharURLPage::SwCharURLPage(   Window* pParent,
     151                 :            :                                 const SfxItemSet& rCoreSet ) :
     152                 :            :     SfxTabPage( pParent, SW_RES( TP_CHAR_URL ), rCoreSet ),
     153                 :            :     aURLFL (        this, SW_RES(FL_URL)),
     154                 :            : 
     155                 :            :     aURLFT(         this, SW_RES(FT_URL        )),
     156                 :            :     aURLED(         this, SW_RES(ED_URL        )),
     157                 :            :     aTextFT(        this, SW_RES(FT_TEXT          )),
     158                 :            :     aTextED(        this, SW_RES(ED_TEXT          )),
     159                 :            :     aNameFT(        this, SW_RES(FT_NAME    )),
     160                 :            :     aNameED(        this, SW_RES(ED_NAME)),
     161                 :            :     aTargetFrmFT(   this, SW_RES(FT_TARGET     )),
     162                 :            :     aTargetFrmLB(   this, SW_RES(LB_TARGET    )),
     163                 :            :     aURLPB(         this, SW_RES(PB_URL        )),
     164                 :            :     aEventPB(       this, SW_RES(PB_EVENT      )),
     165                 :            :     aStyleFL(       this, SW_RES(FL_STYLE      )),
     166                 :            :     aVisitedFT(     this, SW_RES(FT_VISITED    )),
     167                 :            :     aVisitedLB(     this, SW_RES(LB_VISITED    )),
     168                 :            :     aNotVisitedFT(  this, SW_RES(FT_NOT_VISITED)),
     169                 :            :     aNotVisitedLB(  this, SW_RES(LB_NOT_VISITED)),
     170                 :            :     pINetItem(0),
     171                 :          0 :     bModified(sal_False)
     172                 :            : 
     173                 :            : {
     174                 :          0 :     FreeResource();
     175                 :            : 
     176                 :          0 :     aEventPB.SetAccessibleRelationMemberOf(&aURLFL);
     177                 :            : 
     178                 :            :     const SfxPoolItem* pItem;
     179                 :            :     SfxObjectShell* pShell;
     180                 :          0 :     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
     181                 :            :         ( 0 != ( pShell = SfxObjectShell::Current()) &&
     182                 :          0 :                     0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
     183                 :            :     {
     184                 :          0 :         sal_uInt16 nHtmlMode = ((const SfxUInt16Item*)pItem)->GetValue();
     185                 :          0 :         if(HTMLMODE_ON & nHtmlMode)
     186                 :            :         {
     187                 :          0 :             aStyleFL.Hide();
     188                 :          0 :             aVisitedFT.Hide();
     189                 :          0 :             aVisitedLB.Hide();
     190                 :          0 :             aNotVisitedFT.Hide();
     191                 :          0 :             aNotVisitedLB.Hide();
     192                 :            :         }
     193                 :            :     }
     194                 :            : 
     195                 :          0 :     aURLPB.SetClickHdl  (LINK( this, SwCharURLPage, InsertFileHdl));
     196                 :          0 :     aEventPB.SetClickHdl(LINK( this, SwCharURLPage, EventHdl ));
     197                 :            : 
     198                 :          0 :     SwView *pView = ::GetActiveView();
     199                 :          0 :     ::FillCharStyleListBox(aVisitedLB, pView->GetDocShell());
     200                 :          0 :     ::FillCharStyleListBox(aNotVisitedLB, pView->GetDocShell());
     201                 :            : 
     202                 :          0 :     TargetList* pList = new TargetList;
     203                 :          0 :     const SfxFrame& rFrame = pView->GetViewFrame()->GetTopFrame();
     204                 :          0 :     rFrame.GetTargetList(*pList);
     205                 :          0 :     if ( !pList->empty() )
     206                 :            :     {
     207                 :          0 :         size_t nCount = pList->size();
     208                 :            :         size_t i;
     209                 :            : 
     210                 :          0 :         for ( i = 0; i < nCount; i++ )
     211                 :            :         {
     212                 :          0 :             aTargetFrmLB.InsertEntry( *pList->at( i ) );
     213                 :            :         }
     214                 :          0 :         for ( i = nCount; i; )
     215                 :            :         {
     216                 :          0 :             delete pList->at( --i );
     217                 :            :         }
     218                 :            :     }
     219                 :          0 :     delete pList;
     220                 :          0 : }
     221                 :            : 
     222                 :          0 : SwCharURLPage::~SwCharURLPage()
     223                 :            : {
     224                 :          0 :     delete pINetItem;
     225                 :          0 : }
     226                 :            : 
     227                 :          0 : void SwCharURLPage::Reset(const SfxItemSet& rSet)
     228                 :            : {
     229                 :            :     const SfxPoolItem* pItem;
     230                 :          0 :     if(SFX_ITEM_SET == rSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem))
     231                 :            :     {
     232                 :          0 :         const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem;
     233                 :          0 :         aURLED.SetText( INetURLObject::decode( pINetFmt->GetValue(),
     234                 :            :                                         INET_HEX_ESCAPE,
     235                 :            :                                            INetURLObject::DECODE_UNAMBIGUOUS,
     236                 :          0 :                                         RTL_TEXTENCODING_UTF8 ));
     237                 :          0 :         aURLED.SaveValue();
     238                 :          0 :         aNameED.SetText(pINetFmt->GetName());
     239                 :          0 :         String sEntry = pINetFmt->GetVisitedFmt();
     240                 :          0 :         if( !sEntry.Len() )
     241                 :          0 :             SwStyleNameMapper::FillUIName( RES_POOLCHR_INET_VISIT, sEntry );
     242                 :          0 :         aVisitedLB.SelectEntry(sEntry);
     243                 :          0 :         sEntry = pINetFmt->GetINetFmt();
     244                 :          0 :         if(!sEntry.Len())
     245                 :          0 :             SwStyleNameMapper::FillUIName( RES_POOLCHR_INET_NORMAL, sEntry );
     246                 :          0 :         aNotVisitedLB.SelectEntry(sEntry);
     247                 :            : 
     248                 :          0 :         aTargetFrmLB.SetText(pINetFmt->GetTargetFrame());
     249                 :          0 :         aVisitedLB.   SaveValue();
     250                 :          0 :         aNotVisitedLB.SaveValue();
     251                 :          0 :         aTargetFrmLB. SaveValue();
     252                 :          0 :         pINetItem = new SvxMacroItem(FN_INET_FIELD_MACRO);
     253                 :            : 
     254                 :          0 :         if( pINetFmt->GetMacroTbl() )
     255                 :          0 :             pINetItem->SetMacroTable( *pINetFmt->GetMacroTbl() );
     256                 :            :     }
     257                 :          0 :     if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_SELECTION, sal_False, &pItem))
     258                 :            :     {
     259                 :          0 :         aTextED.SetText(((const SfxStringItem*)pItem)->GetValue());
     260                 :          0 :         aTextFT.Enable( sal_False );
     261                 :          0 :         aTextED.Enable( sal_False );
     262                 :            :     }
     263                 :          0 : }
     264                 :            : 
     265                 :          0 : sal_Bool SwCharURLPage::FillItemSet(SfxItemSet& rSet)
     266                 :            : {
     267                 :          0 :    ::rtl::OUString sURL = aURLED.GetText();
     268                 :          0 :    if(!sURL.isEmpty())
     269                 :            :     {
     270                 :          0 :         sURL = URIHelper::SmartRel2Abs(INetURLObject(), sURL, Link(), false );
     271                 :            :         // #i100683# file URLs should be normalized in the UI
     272                 :            :         static const sal_Char* pFile = "file:";
     273                 :          0 :        sal_Int32 nLength = ((sal_Int32)sizeof(pFile)-1);
     274                 :          0 :        if( sURL.copy(0, nLength ).equalsAsciiL( pFile, nLength ))
     275                 :          0 :             sURL = URIHelper::simpleNormalizedMakeRelative(::rtl::OUString(), sURL);
     276                 :            :     }
     277                 :            : 
     278                 :          0 :     SwFmtINetFmt aINetFmt(sURL, aTargetFrmLB.GetText());
     279                 :          0 :     aINetFmt.SetName(aNameED.GetText());
     280                 :          0 :     bModified |= aURLED.GetText() != aURLED.GetSavedValue();
     281                 :          0 :     bModified |= aNameED.IsModified();
     282                 :          0 :     bModified |= aTargetFrmLB.GetSavedValue() != aTargetFrmLB.GetText();
     283                 :            : 
     284                 :            :     // set valid settings first
     285                 :          0 :     String sEntry = aVisitedLB.GetSelectEntry();
     286                 :          0 :     sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     287                 :          0 :     aINetFmt.SetVisitedFmtId(nId);
     288                 :          0 :     aINetFmt.SetVisitedFmt(nId == RES_POOLCHR_INET_VISIT ? aEmptyStr : sEntry);
     289                 :            : 
     290                 :          0 :     sEntry = aNotVisitedLB.GetSelectEntry();
     291                 :          0 :     nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     292                 :          0 :     aINetFmt.SetINetFmtId( nId );
     293                 :          0 :     aINetFmt.SetINetFmt(nId == RES_POOLCHR_INET_NORMAL ? aEmptyStr : sEntry);
     294                 :            : 
     295                 :          0 :     if( pINetItem && !pINetItem->GetMacroTable().empty() )
     296                 :          0 :         aINetFmt.SetMacroTbl( &pINetItem->GetMacroTable() );
     297                 :            : 
     298                 :          0 :     if(aVisitedLB.GetSavedValue() != aVisitedLB.GetSelectEntryPos())
     299                 :          0 :         bModified = sal_True;
     300                 :            : 
     301                 :          0 :     if(aNotVisitedLB.GetSavedValue() != aNotVisitedLB.GetSelectEntryPos())
     302                 :          0 :         bModified = sal_True;
     303                 :            : 
     304                 :          0 :     if(aTextED.IsModified())
     305                 :            :     {
     306                 :          0 :         bModified = sal_True;
     307                 :          0 :         rSet.Put(SfxStringItem(FN_PARAM_SELECTION, aTextED.GetText()));
     308                 :            :     }
     309                 :          0 :     if(bModified)
     310                 :          0 :         rSet.Put(aINetFmt);
     311                 :          0 :     return bModified;
     312                 :            : }
     313                 :            : 
     314                 :          0 : SfxTabPage* SwCharURLPage::Create(  Window* pParent,
     315                 :            :                         const SfxItemSet& rAttrSet )
     316                 :            : {
     317                 :          0 :     return ( new SwCharURLPage( pParent, rAttrSet ) );
     318                 :            : }
     319                 :            : 
     320                 :          0 : IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl)
     321                 :            : {
     322                 :          0 :     FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     323                 :          0 :     if( aDlgHelper.Execute() == ERRCODE_NONE )
     324                 :            :     {
     325                 :          0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     326                 :          0 :         aURLED.SetText(xFP->getFiles().getConstArray()[0]);
     327                 :            :     }
     328                 :          0 :     return 0;
     329                 :            : }
     330                 :            : 
     331                 :          0 : IMPL_LINK_NOARG(SwCharURLPage, EventHdl)
     332                 :            : {
     333                 :            :     bModified |= SwMacroAssignDlg::INetFmtDlg( this,
     334                 :          0 :                     ::GetActiveView()->GetWrtShell(), pINetItem );
     335                 :          0 :     return 0;
     336                 :            : }
     337                 :            : 
     338                 :            : 
     339                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10