LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - chardlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 161 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 17 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( *static_cast<const 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 :         aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER|SVX_ENABLE_FLASH));
     116           0 :         rPage.PageCreated(aSet);
     117             :     }
     118           0 :     else if (nId == m_nCharPosId)
     119             :     {
     120           0 :         aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     121           0 :         rPage.PageCreated(aSet);
     122             :     }
     123           0 :     else if (nId == m_nCharTwoId)
     124             :     {
     125           0 :         aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_PREVIEW_CHARACTER));
     126           0 :         rPage.PageCreated(aSet);
     127           0 :     }
     128           0 : }
     129             : 
     130           0 : SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
     131             :     : SfxTabPage(pParent, "CharURLPage", "modules/swriter/ui/charurlpage.ui", &rCoreSet)
     132             :     , pINetItem(0)
     133           0 :     , bModified(false)
     134             : 
     135             : {
     136           0 :     get(m_pURLED, "urled");
     137           0 :     get(m_pTextFT, "textft");
     138           0 :     get(m_pTextED, "texted");
     139           0 :     get(m_pNameED, "nameed");
     140           0 :     get(m_pTargetFrmLB, "targetfrmlb");
     141           0 :     get(m_pURLPB, "urlpb");
     142           0 :     get(m_pEventPB, "eventpb");
     143           0 :     get(m_pVisitedLB, "visitedlb");
     144           0 :     get(m_pNotVisitedLB, "unvisitedlb");
     145           0 :     get(m_pCharStyleContainer, "charstyle");
     146             : 
     147             :     const SfxPoolItem* pItem;
     148             :     SfxObjectShell* pShell;
     149           0 :     if(SfxItemState::SET == rCoreSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
     150           0 :         ( 0 != ( pShell = SfxObjectShell::Current()) &&
     151           0 :                     0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
     152             :     {
     153           0 :         sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
     154           0 :         if(HTMLMODE_ON & nHtmlMode)
     155           0 :             m_pCharStyleContainer->Hide();
     156             :     }
     157             : 
     158           0 :     m_pURLPB->SetClickHdl  (LINK( this, SwCharURLPage, InsertFileHdl));
     159           0 :     m_pEventPB->SetClickHdl(LINK( this, SwCharURLPage, EventHdl ));
     160             : 
     161           0 :     SwView *pView = ::GetActiveView();
     162           0 :     ::FillCharStyleListBox(*m_pVisitedLB, pView->GetDocShell());
     163           0 :     ::FillCharStyleListBox(*m_pNotVisitedLB, pView->GetDocShell());
     164             : 
     165           0 :     TargetList* pList = new TargetList;
     166           0 :     const SfxFrame& rFrame = pView->GetViewFrame()->GetTopFrame();
     167           0 :     rFrame.GetTargetList(*pList);
     168           0 :     if ( !pList->empty() )
     169             :     {
     170           0 :         size_t nCount = pList->size();
     171             : 
     172           0 :         for ( size_t i = 0; i < nCount; i++ )
     173             :         {
     174           0 :             m_pTargetFrmLB->InsertEntry( pList->at( i ) );
     175             :         }
     176             :     }
     177           0 :     delete pList;
     178           0 : }
     179             : 
     180           0 : SwCharURLPage::~SwCharURLPage()
     181             : {
     182           0 :     disposeOnce();
     183           0 : }
     184             : 
     185           0 : void SwCharURLPage::dispose()
     186             : {
     187           0 :     delete pINetItem;
     188           0 :     m_pURLED.clear();
     189           0 :     m_pTextFT.clear();
     190           0 :     m_pTextED.clear();
     191           0 :     m_pNameED.clear();
     192           0 :     m_pTargetFrmLB.clear();
     193           0 :     m_pURLPB.clear();
     194           0 :     m_pEventPB.clear();
     195           0 :     m_pVisitedLB.clear();
     196           0 :     m_pNotVisitedLB.clear();
     197           0 :     m_pCharStyleContainer.clear();
     198           0 :     SfxTabPage::dispose();
     199           0 : }
     200             : 
     201           0 : void SwCharURLPage::Reset(const SfxItemSet* rSet)
     202             : {
     203             :     const SfxPoolItem* pItem;
     204           0 :     if ( SfxItemState::SET == rSet->GetItemState( RES_TXTATR_INETFMT, false, &pItem ) )
     205             :     {
     206           0 :         const SwFormatINetFormat* pINetFormat = static_cast<const SwFormatINetFormat*>( pItem);
     207           0 :         m_pURLED->SetText(INetURLObject::decode(pINetFormat->GetValue(),
     208             :             INetURLObject::DECODE_UNAMBIGUOUS,
     209           0 :             RTL_TEXTENCODING_UTF8));
     210           0 :         m_pURLED->SaveValue();
     211           0 :         m_pURLED->SetText(pINetFormat->GetName());
     212             : 
     213           0 :         OUString sEntry = pINetFormat->GetVisitedFormat();
     214           0 :         if (sEntry.isEmpty())
     215             :         {
     216             :             OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing visited character format at hyperlink attribute" );
     217           0 :             SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_VISIT, sEntry);
     218             :         }
     219           0 :         m_pVisitedLB->SelectEntry( sEntry );
     220             : 
     221           0 :         sEntry = pINetFormat->GetINetFormat();
     222           0 :         if (sEntry.isEmpty())
     223             :         {
     224             :             OSL_ENSURE( false, "<SwCharURLPage::Reset(..)> - missing unvisited character format at hyperlink attribute" );
     225           0 :             SwStyleNameMapper::FillUIName(RES_POOLCHR_INET_NORMAL, sEntry);
     226             :         }
     227           0 :         m_pNotVisitedLB->SelectEntry(sEntry);
     228             : 
     229           0 :         m_pTargetFrmLB->SetText(pINetFormat->GetTargetFrame());
     230           0 :         m_pVisitedLB->   SaveValue();
     231           0 :         m_pNotVisitedLB->SaveValue();
     232           0 :         m_pTargetFrmLB-> SaveValue();
     233           0 :         pINetItem = new SvxMacroItem(FN_INET_FIELD_MACRO);
     234             : 
     235           0 :         if( pINetFormat->GetMacroTable() )
     236           0 :             pINetItem->SetMacroTable( *pINetFormat->GetMacroTable() );
     237             :     }
     238           0 :     if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_SELECTION, false, &pItem))
     239             :     {
     240           0 :         m_pTextED->SetText(static_cast<const SfxStringItem*>(pItem)->GetValue());
     241           0 :         m_pTextFT->Enable( false );
     242           0 :         m_pTextED->Enable( false );
     243             :     }
     244           0 : }
     245             : 
     246           0 : bool SwCharURLPage::FillItemSet(SfxItemSet* rSet)
     247             : {
     248           0 :     OUString sURL = m_pURLED->GetText();
     249           0 :     if(!sURL.isEmpty())
     250             :     {
     251           0 :         sURL = URIHelper::SmartRel2Abs(INetURLObject(), sURL, Link<OUString *, bool>(), false );
     252             :         // #i100683# file URLs should be normalized in the UI
     253           0 :         if ( sURL.startsWith("file:") )
     254           0 :             sURL = URIHelper::simpleNormalizedMakeRelative(OUString(), sURL);
     255             :     }
     256             : 
     257           0 :     SwFormatINetFormat aINetFormat(sURL, m_pTargetFrmLB->GetText());
     258           0 :     aINetFormat.SetName(m_pNameED->GetText());
     259           0 :     bool bURLModified = m_pURLED->IsValueChangedFromSaved();
     260           0 :     bool bNameModified = m_pNameED->IsModified();
     261           0 :     bool bTargetModified = m_pTargetFrmLB->IsValueChangedFromSaved();
     262           0 :     bModified = bURLModified || bNameModified || bTargetModified;
     263             : 
     264             :     // set valid settings first
     265           0 :     OUString sEntry = m_pVisitedLB->GetSelectEntry();
     266           0 :     sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     267           0 :     aINetFormat.SetVisitedFormatAndId( sEntry, nId );
     268             : 
     269           0 :     sEntry = m_pNotVisitedLB->GetSelectEntry();
     270           0 :     nId = SwStyleNameMapper::GetPoolIdFromUIName( sEntry, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     271           0 :     aINetFormat.SetINetFormatAndId( sEntry, nId );
     272             : 
     273           0 :     if( pINetItem && !pINetItem->GetMacroTable().empty() )
     274           0 :         aINetFormat.SetMacroTable( &pINetItem->GetMacroTable() );
     275             : 
     276           0 :     if(m_pVisitedLB->IsValueChangedFromSaved())
     277           0 :         bModified = true;
     278             : 
     279           0 :     if(m_pNotVisitedLB->IsValueChangedFromSaved())
     280           0 :         bModified = true;
     281             : 
     282           0 :     if(m_pTextED->IsModified())
     283             :     {
     284           0 :         bModified = true;
     285           0 :         rSet->Put(SfxStringItem(FN_PARAM_SELECTION, m_pTextED->GetText()));
     286             :     }
     287           0 :     if(bModified)
     288           0 :         rSet->Put(aINetFormat);
     289           0 :     return bModified;
     290             : }
     291             : 
     292           0 : VclPtr<SfxTabPage> SwCharURLPage::Create(  vcl::Window* pParent,
     293             :                                            const SfxItemSet* rAttrSet )
     294             : {
     295           0 :     return VclPtr<SwCharURLPage>::Create( pParent, *rAttrSet );
     296             : }
     297             : 
     298           0 : IMPL_LINK_NOARG(SwCharURLPage, InsertFileHdl)
     299             : {
     300           0 :     FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     301           0 :     if( aDlgHelper.Execute() == ERRCODE_NONE )
     302             :     {
     303           0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     304           0 :         m_pURLED->SetText(xFP->getFiles().getConstArray()[0]);
     305             :     }
     306           0 :     return 0;
     307             : }
     308             : 
     309           0 : IMPL_LINK_NOARG(SwCharURLPage, EventHdl)
     310             : {
     311             :     bModified |= SwMacroAssignDlg::INetFormatDlg( this,
     312           0 :                     ::GetActiveView()->GetWrtShell(), pINetItem );
     313           0 :     return 0;
     314           0 : }
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11