LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - chardlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 149 0.0 %
Date: 2014-11-03 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(vcl::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 + ")");
      71             :     }
      72           0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
      73             :     OSL_ENSURE(pFact, "Dialog creation failed!");
      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             : // set FontList
     101           0 : void SwCharDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     102             : {
     103           0 :     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
     104           0 :     if (nId == m_nCharStdId)
     105             :     {
     106             :         SvxFontListItem aFontListItem( *( (SvxFontListItem*)
     107           0 :            ( m_rView.GetDocShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ) ) );
     108           0 :         aSet.Put (SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
     109           0 :         if(m_nDialogMode != DLG_CHAR_DRAW && m_nDialogMode != DLG_CHAR_ANN)
     110           0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     111           0 :         rPage.PageCreated(aSet);
     112             :     }
     113           0 :     else if (nId == m_nCharExtId)
     114             :     {
     115           0 :         if(m_nDialogMode == DLG_CHAR_DRAW || m_nDialogMode == DLG_CHAR_ANN)
     116           0 :             aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
     117             : 
     118             :         else
     119             :         {
     120           0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER|SVX_ENABLE_FLASH));
     121             :         }
     122           0 :         rPage.PageCreated(aSet);
     123             :     }
     124           0 :     else if (nId == m_nCharPosId)
     125             :     {
     126           0 :         aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     127           0 :         rPage.PageCreated(aSet);
     128             :     }
     129           0 :     else if (nId == m_nCharTwoId)
     130             :     {
     131           0 :         aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     132           0 :         rPage.PageCreated(aSet);
     133           0 :     }
     134           0 : }
     135             : 
     136           0 : SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
     137             :     : SfxTabPage(pParent, "CharURLPage", "modules/swriter/ui/charurlpage.ui", &rCoreSet)
     138             :     , pINetItem(0)
     139           0 :     , bModified(false)
     140             : 
     141             : {
     142           0 :     get(m_pURLED, "urled");
     143           0 :     get(m_pTextFT, "textft");
     144           0 :     get(m_pTextED, "texted");
     145           0 :     get(m_pNameED, "nameed");
     146           0 :     get(m_pTargetFrmLB, "targetfrmlb");
     147           0 :     get(m_pURLPB, "urlpb");
     148           0 :     get(m_pEventPB, "eventpb");
     149           0 :     get(m_pVisitedLB, "visitedlb");
     150           0 :     get(m_pNotVisitedLB, "unvisitedlb");
     151           0 :     get(m_pCharStyleContainer, "charstyle");
     152             : 
     153             :     const SfxPoolItem* pItem;
     154             :     SfxObjectShell* pShell;
     155           0 :     if(SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
     156           0 :         ( 0 != ( pShell = SfxObjectShell::Current()) &&
     157           0 :                     0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
     158             :     {
     159           0 :         sal_uInt16 nHtmlMode = ((const SfxUInt16Item*)pItem)->GetValue();
     160           0 :         if(HTMLMODE_ON & nHtmlMode)
     161           0 :             m_pCharStyleContainer->Hide();
     162             :     }
     163             : 
     164           0 :     m_pURLPB->SetClickHdl  (LINK( this, SwCharURLPage, InsertFileHdl));
     165           0 :     m_pEventPB->SetClickHdl(LINK( this, SwCharURLPage, EventHdl ));
     166             : 
     167           0 :     SwView *pView = ::GetActiveView();
     168           0 :     ::FillCharStyleListBox(*m_pVisitedLB, pView->GetDocShell());
     169           0 :     ::FillCharStyleListBox(*m_pNotVisitedLB, pView->GetDocShell());
     170             : 
     171           0 :     TargetList* pList = new TargetList;
     172           0 :     const SfxFrame& rFrame = pView->GetViewFrame()->GetTopFrame();
     173           0 :     rFrame.GetTargetList(*pList);
     174           0 :     if ( !pList->empty() )
     175             :     {
     176           0 :         size_t nCount = pList->size();
     177             : 
     178           0 :         for ( size_t i = 0; i < nCount; i++ )
     179             :         {
     180           0 :             m_pTargetFrmLB->InsertEntry( pList->at( i ) );
     181             :         }
     182             :     }
     183           0 :     delete pList;
     184           0 : }
     185             : 
     186           0 : SwCharURLPage::~SwCharURLPage()
     187             : {
     188           0 :     delete pINetItem;
     189           0 : }
     190             : 
     191           0 : void SwCharURLPage::Reset(const SfxItemSet* rSet)
     192             : {
     193             :     const SfxPoolItem* pItem;
     194           0 :     if ( SfxItemState::SET == rSet->GetItemState( RES_TXTATR_INETFMT, false, &pItem ) )
     195             :     {
     196           0 :         const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*) pItem;
     197           0 :         m_pURLED->SetText(INetURLObject::decode(pINetFmt->GetValue(),
     198             :             '%', INetURLObject::DECODE_UNAMBIGUOUS,
     199           0 :             RTL_TEXTENCODING_UTF8));
     200           0 :         m_pURLED->SaveValue();
     201           0 :         m_pURLED->SetText(pINetFmt->GetName());
     202             : 
     203           0 :         OUString sEntry = pINetFmt->GetVisitedFmt();
     204           0 :         if (sEntry.isEmpty())
     205             :         {
     206             :             OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing visited character format at hyperlink attribute" );
     207           0 :             SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_VISIT, sEntry);
     208             :         }
     209           0 :         m_pVisitedLB->SelectEntry( sEntry );
     210             : 
     211           0 :         sEntry = pINetFmt->GetINetFmt();
     212           0 :         if (sEntry.isEmpty())
     213             :         {
     214             :             OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing unvisited character format at hyperlink attribute" );
     215           0 :             SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_NORMAL, sEntry);
     216             :         }
     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(SfxItemState::SET == rSet->GetItemState(FN_PARAM_SELECTION, false, &pItem))
     229             :     {
     230           0 :         m_pTextED->SetText(((const SfxStringItem*)pItem)->GetValue());
     231           0 :         m_pTextFT->Enable( false );
     232           0 :         m_pTextED->Enable( false );
     233             :     }
     234           0 : }
     235             : 
     236           0 : 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           0 :         if ( sURL.startsWith("file:") )
     244           0 :             sURL = URIHelper::simpleNormalizedMakeRelative(OUString(), sURL);
     245             :     }
     246             : 
     247           0 :     SwFmtINetFmt aINetFmt(sURL, m_pTargetFrmLB->GetText());
     248           0 :     aINetFmt.SetName(m_pNameED->GetText());
     249           0 :     bool bURLModified = m_pURLED->IsValueChangedFromSaved();
     250           0 :     bool bNameModified = m_pNameED->IsModified();
     251           0 :     bool bTargetModified = m_pTargetFrmLB->IsValueChangedFromSaved();
     252           0 :     bModified = bURLModified || bNameModified || bTargetModified;
     253             : 
     254             :     // set valid settings first
     255           0 :     OUString sEntry = m_pVisitedLB->GetSelectEntry();
     256           0 :     sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     257           0 :     aINetFmt.SetVisitedFmtAndId( sEntry, nId );
     258             : 
     259           0 :     sEntry = m_pNotVisitedLB->GetSelectEntry();
     260           0 :     nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     261           0 :     aINetFmt.SetINetFmtAndId( sEntry, nId );
     262             : 
     263           0 :     if( pINetItem && !pINetItem->GetMacroTable().empty() )
     264           0 :         aINetFmt.SetMacroTbl( &pINetItem->GetMacroTable() );
     265             : 
     266           0 :     if(m_pVisitedLB->IsValueChangedFromSaved())
     267           0 :         bModified = true;
     268             : 
     269           0 :     if(m_pNotVisitedLB->IsValueChangedFromSaved())
     270           0 :         bModified = true;
     271             : 
     272           0 :     if(m_pTextED->IsModified())
     273             :     {
     274           0 :         bModified = true;
     275           0 :         rSet->Put(SfxStringItem(FN_PARAM_SELECTION, m_pTextED->GetText()));
     276             :     }
     277           0 :     if(bModified)
     278           0 :         rSet->Put(aINetFmt);
     279           0 :     return bModified;
     280             : }
     281             : 
     282           0 : SfxTabPage* SwCharURLPage::Create(  vcl::Window* pParent,
     283             :                         const SfxItemSet* rAttrSet )
     284             : {
     285           0 :     return ( new SwCharURLPage( pParent, *rAttrSet ) );
     286             : }
     287             : 
     288           0 : IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl)
     289             : {
     290           0 :     FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     291           0 :     if( aDlgHelper.Execute() == ERRCODE_NONE )
     292             :     {
     293           0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     294           0 :         m_pURLED->SetText(xFP->getFiles().getConstArray()[0]);
     295             :     }
     296           0 :     return 0;
     297             : }
     298             : 
     299           0 : IMPL_LINK_NOARG(SwCharURLPage, EventHdl)
     300             : {
     301             :     bModified |= SwMacroAssignDlg::INetFmtDlg( this,
     302           0 :                     ::GetActiveView()->GetWrtShell(), pINetItem );
     303           0 :     return 0;
     304           0 : }
     305             : 
     306             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10