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

Generated by: LCOV version 1.10