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

Generated by: LCOV version 1.10