LCOV - code coverage report
Current view: top level - cui/source/dialogs - hldocntp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 194 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 618 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 "hldocntp.hxx"
      30                 :            : #include <sfx2/viewfrm.hxx>
      31                 :            : #include <sfx2/docfac.hxx>
      32                 :            : #include <com/sun/star/uno/Reference.h>
      33                 :            : #include <com/sun/star/uno/Sequence.h>
      34                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      35                 :            : #include <com/sun/star/uno/Exception.hpp>
      36                 :            : #include <unotools/localfilehelper.hxx>
      37                 :            : #include <vcl/image.hxx>
      38                 :            : #include <tools/urlobj.hxx>
      39                 :            : #include <unotools/pathoptions.hxx>
      40                 :            : #include <unotools/dynamicmenuoptions.hxx>
      41                 :            : #include <sfx2/filedlghelper.hxx>
      42                 :            : #include <unotools/ucbstreamhelper.hxx>
      43                 :            : #include <unotools/ucbhelper.hxx>
      44                 :            : 
      45                 :            : #include "hyperdlg.hrc"
      46                 :            : #include <comphelper/processfactory.hxx>
      47                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      48                 :            : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
      49                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      50                 :            : 
      51                 :            : using namespace ::com::sun::star::lang;
      52                 :            : using namespace ::com::sun::star::ui::dialogs;
      53                 :            : using namespace ::com::sun::star::uno;
      54                 :            : 
      55                 :            : using namespace ::rtl;
      56                 :            : using namespace ::com::sun::star;
      57                 :            : 
      58                 :            : /*************************************************************************
      59                 :            : |*
      60                 :            : |* Data-struct for documenttypes in listbox
      61                 :            : |*
      62                 :            : |************************************************************************/
      63                 :            : 
      64         [ #  # ]:          0 : struct DocumentTypeData
      65                 :            : {
      66                 :            :     String aStrURL;
      67                 :            :     String aStrExt;
      68         [ #  # ]:          0 :     DocumentTypeData (String aURL, String aExt) : aStrURL(aURL), aStrExt(aExt)
      69                 :          0 :     {}
      70                 :            : };
      71                 :            : 
      72                 :          0 : sal_Bool SvxHyperlinkNewDocTp::ImplGetURLObject( const String& rPath, const String& rBase, INetURLObject& aURLObject ) const
      73                 :            : {
      74                 :          0 :     sal_Bool bIsValidURL = rPath.Len() != 0;
      75         [ #  # ]:          0 :     if ( bIsValidURL )
      76                 :            :     {
      77         [ #  # ]:          0 :         aURLObject.SetURL( rPath );
      78         [ #  # ]:          0 :         if ( aURLObject.GetProtocol() == INET_PROT_NOT_VALID )      // test if the source is already a valid url
      79                 :            :         {                                                           // if not we have to create a url from a physical file name
      80                 :            :             bool wasAbs;
      81 [ #  # ][ #  # ]:          0 :             INetURLObject base(rBase);
      82         [ #  # ]:          0 :             base.setFinalSlash();
      83                 :            :             aURLObject = base.smartRel2Abs(
      84                 :            :                 rPath, wasAbs, true, INetURLObject::ENCODE_ALL,
      85 [ #  # ][ #  # ]:          0 :                 RTL_TEXTENCODING_UTF8, true);
         [ #  # ][ #  # ]
                 [ #  # ]
      86                 :            :         }
      87                 :          0 :         bIsValidURL = aURLObject.GetProtocol() != INET_PROT_NOT_VALID;
      88         [ #  # ]:          0 :         if ( bIsValidURL )
      89                 :            :         {
      90 [ #  # ][ #  # ]:          0 :             String aBase( aURLObject.getName( INetURLObject::LAST_SEGMENT, sal_False ) );
      91 [ #  # ][ #  # ]:          0 :             if ( ( aBase.Len() == 0 ) || ( aBase.GetChar( 0 ) == '.' ) )
                 [ #  # ]
      92         [ #  # ]:          0 :                 bIsValidURL = sal_False;
      93                 :            :         }
      94         [ #  # ]:          0 :         if ( bIsValidURL )
      95                 :            :         {
      96                 :          0 :             sal_uInt16 nPos = maLbDocTypes.GetSelectEntryPos();
      97         [ #  # ]:          0 :             if ( nPos != LISTBOX_ENTRY_NOTFOUND )
      98         [ #  # ]:          0 :                 aURLObject.SetExtension( ((DocumentTypeData*)maLbDocTypes.GetEntryData( nPos ))->aStrExt );
      99                 :            :         }
     100                 :            : 
     101                 :            :     }
     102                 :          0 :     return bIsValidURL;
     103                 :            : }
     104                 :            : 
     105                 :            : /*************************************************************************
     106                 :            : |*
     107                 :            : |* Contructor / Destructor
     108                 :            : |*
     109                 :            : |************************************************************************/
     110                 :            : 
     111                 :          0 : SvxHyperlinkNewDocTp::SvxHyperlinkNewDocTp ( Window *pParent, const SfxItemSet& rItemSet)
     112                 :          0 : :   SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_NEWDOCUMENT ), rItemSet ),
     113         [ #  # ]:          0 :     maGrpNewDoc     ( this, CUI_RES (GRP_NEWDOCUMENT) ),
     114         [ #  # ]:          0 :     maRbtEditNow    ( this, CUI_RES (RB_EDITNOW) ),
     115         [ #  # ]:          0 :     maRbtEditLater  ( this, CUI_RES (RB_EDITLATER) ),
     116         [ #  # ]:          0 :     maFtPath        ( this, CUI_RES (FT_PATH_NEWDOC) ),
     117                 :            :     maCbbPath       ( this, INET_PROT_FILE ),
     118         [ #  # ]:          0 :     maBtCreate      ( this, CUI_RES (BTN_CREATE) ),
     119         [ #  # ]:          0 :     maFtDocTypes    ( this, CUI_RES (FT_DOCUMENT_TYPES) ),
     120 [ #  # ][ #  # ]:          0 :     maLbDocTypes    ( this, CUI_RES (LB_DOCUMENT_TYPES) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     121                 :            : {
     122                 :            :     // Set HC bitmaps and disable display of bitmap names.
     123         [ #  # ]:          0 :     maBtCreate.EnableTextDisplay (sal_False);
     124                 :            : 
     125         [ #  # ]:          0 :     InitStdControls();
     126         [ #  # ]:          0 :     FreeResource();
     127                 :            : 
     128                 :          0 :     SetExchangeSupport ();
     129                 :            : 
     130 [ #  # ][ #  # ]:          0 :     maCbbPath.SetPosSizePixel ( LogicToPixel( Point( COL_2 , 25 ), MAP_APPFONT ),
     131   [ #  #  #  # ]:          0 :                                 LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     132         [ #  # ]:          0 :     maCbbPath.Show();
     133 [ #  # ][ #  # ]:          0 :     maCbbPath.SetBaseURL(SvtPathOptions().GetWorkPath());
         [ #  # ][ #  # ]
     134                 :            : 
     135                 :            :     // set defaults
     136         [ #  # ]:          0 :     maRbtEditNow.Check();
     137                 :            : 
     138         [ #  # ]:          0 :     maBtCreate.SetClickHdl        ( LINK ( this, SvxHyperlinkNewDocTp, ClickNewHdl_Impl ) );
     139                 :            : 
     140         [ #  # ]:          0 :     maBtCreate.SetAccessibleRelationMemberOf( &maGrpNewDoc );
     141         [ #  # ]:          0 :     maBtCreate.SetAccessibleRelationLabeledBy( &maFtPath );
     142                 :            : 
     143         [ #  # ]:          0 :     FillDocumentList ();
     144                 :          0 : }
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 : SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp ()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     147                 :            : {
     148 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 n=0; n<maLbDocTypes.GetEntryCount(); n++ )
     149                 :            :     {
     150                 :            :         DocumentTypeData* pTypeData = (DocumentTypeData*)
     151         [ #  # ]:          0 :                                       maLbDocTypes.GetEntryData ( n );
     152 [ #  # ][ #  # ]:          0 :         delete pTypeData;
     153                 :            :     }
     154         [ #  # ]:          0 : }
     155                 :            : 
     156                 :            : /*************************************************************************
     157                 :            : |*
     158                 :            : |* Fill the all dialog-controls except controls in groupbox "more..."
     159                 :            : |*
     160                 :            : |************************************************************************/
     161                 :            : 
     162                 :            : 
     163                 :          0 : void SvxHyperlinkNewDocTp::FillDlgFields ( String& /*aStrURL*/ )
     164                 :            : {
     165                 :          0 : }
     166                 :            : 
     167                 :          0 : void SvxHyperlinkNewDocTp::FillDocumentList ()
     168                 :            : {
     169         [ #  # ]:          0 :     EnterWait();
     170                 :            : 
     171                 :            :     uno::Sequence< uno::Sequence< beans::PropertyValue > >
     172 [ #  # ][ #  # ]:          0 :         aDynamicMenuEntries( SvtDynamicMenuOptions().GetMenu( E_NEWMENU ) );
                 [ #  # ]
     173                 :            : 
     174                 :          0 :     sal_uInt32 i, nCount = aDynamicMenuEntries.getLength();
     175         [ #  # ]:          0 :     for ( i = 0; i < nCount; i++ )
     176                 :            :     {
     177         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue >& rDynamicMenuEntry = aDynamicMenuEntries[ i ];
     178                 :            : 
     179                 :          0 :         rtl::OUString aDocumentUrl, aTitle, aImageId, aTargetName;
     180                 :            : 
     181         [ #  # ]:          0 :            for ( int e = 0; e < rDynamicMenuEntry.getLength(); e++ )
     182                 :            :         {
     183 [ #  # ][ #  # ]:          0 :             if ( rDynamicMenuEntry[ e ].Name == DYNAMICMENU_PROPERTYNAME_URL )
                 [ #  # ]
     184         [ #  # ]:          0 :                 rDynamicMenuEntry[ e ].Value >>= aDocumentUrl;
     185 [ #  # ][ #  # ]:          0 :             else if ( rDynamicMenuEntry[e].Name == DYNAMICMENU_PROPERTYNAME_TITLE )
                 [ #  # ]
     186         [ #  # ]:          0 :                 rDynamicMenuEntry[e].Value >>= aTitle;
     187 [ #  # ][ #  # ]:          0 :             else if ( rDynamicMenuEntry[e].Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER )
                 [ #  # ]
     188         [ #  # ]:          0 :                 rDynamicMenuEntry[e].Value >>= aImageId;
     189 [ #  # ][ #  # ]:          0 :             else if ( rDynamicMenuEntry[e].Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME )
                 [ #  # ]
     190         [ #  # ]:          0 :                 rDynamicMenuEntry[e].Value >>= aTargetName;
     191                 :            :         }
     192                 :            :         //#i96822# business cards, labels and database should not be inserted here
     193   [ #  #  #  #  :          0 :         if( aDocumentUrl == "private:factory/swriter?slot=21051" ||
           #  # ][ #  # ]
     194                 :          0 :             aDocumentUrl == "private:factory/swriter?slot=21052" ||
     195                 :          0 :             aDocumentUrl == "private:factory/sdatabase?Interactive" )
     196                 :          0 :             continue;
     197                 :            : 
     198                 :            :         // Insert into listbox
     199         [ #  # ]:          0 :         if ( !aDocumentUrl.isEmpty() )
     200                 :            :         {
     201         [ #  # ]:          0 :             if ( aDocumentUrl == "private:factory/simpress?slot=6686" )              // SJ: #106216# do not start
     202 [ #  # ][ #  # ]:          0 :                 aDocumentUrl = String( RTL_CONSTASCII_USTRINGPARAM( "private:factory/simpress" ) ); // the AutoPilot for impress
                 [ #  # ]
     203                 :            : 
     204                 :            :             // insert private-url and default-extension as user-data
     205 [ #  # ][ #  # ]:          0 :             const SfxFilter* pFilter = SfxFilter::GetDefaultFilterFromFactory( aDocumentUrl );
                 [ #  # ]
     206         [ #  # ]:          0 :             if ( pFilter )
     207                 :            :             {
     208                 :            :                 // insert doc-name and image
     209         [ #  # ]:          0 :                 String aTitleName( aTitle );
     210 [ #  # ][ #  # ]:          0 :                 aTitleName.Erase( aTitleName.Search( (sal_Unicode)'~' ), 1 );
     211                 :            : 
     212         [ #  # ]:          0 :                 sal_Int16 nPos = maLbDocTypes.InsertEntry ( aTitleName );
     213         [ #  # ]:          0 :                 String aStrDefExt( pFilter->GetDefaultExtension () );
     214 [ #  # ][ #  # ]:          0 :                 DocumentTypeData *pTypeData = new DocumentTypeData ( aDocumentUrl, aStrDefExt.Copy( 2, aStrDefExt.Len() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     215 [ #  # ][ #  # ]:          0 :                 maLbDocTypes.SetEntryData ( nPos, pTypeData );
                 [ #  # ]
     216                 :            :             }
     217                 :            :         }
     218 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
     219         [ #  # ]:          0 :     maLbDocTypes.SelectEntryPos ( 0 );
     220                 :            : 
     221 [ #  # ][ #  # ]:          0 :     LeaveWait();
     222                 :          0 : }
     223                 :            : 
     224                 :            : /*************************************************************************
     225                 :            : |*
     226                 :            : |* retrieve and prepare data from dialog-fields
     227                 :            : |*
     228                 :            : |************************************************************************/
     229                 :            : 
     230                 :          0 : void SvxHyperlinkNewDocTp::GetCurentItemData ( String& aStrURL, String& aStrName,
     231                 :            :                                                String& aStrIntName, String& aStrFrame,
     232                 :            :                                                SvxLinkInsertMode& eMode )
     233                 :            : {
     234                 :            :     // get data from dialog-controls
     235 [ #  # ][ #  # ]:          0 :     aStrURL = maCbbPath.GetText();
                 [ #  # ]
     236         [ #  # ]:          0 :     INetURLObject aURL;
     237 [ #  # ][ #  # ]:          0 :     if ( ImplGetURLObject( aStrURL, maCbbPath.GetBaseURL(), aURL ) )
     238                 :            :     {
     239 [ #  # ][ #  # ]:          0 :         aStrURL     = aURL.GetMainURL( INetURLObject::NO_DECODE );
     240                 :            :     }
     241                 :            : 
     242 [ #  # ][ #  # ]:          0 :     GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
     243                 :          0 : }
     244                 :            : 
     245                 :            : /*************************************************************************
     246                 :            : |*
     247                 :            : |* static method to create Tabpage
     248                 :            : |*
     249                 :            : |************************************************************************/
     250                 :            : 
     251                 :          0 : IconChoicePage* SvxHyperlinkNewDocTp::Create( Window* pWindow, const SfxItemSet& rItemSet )
     252                 :            : {
     253         [ #  # ]:          0 :     return( new SvxHyperlinkNewDocTp( pWindow, rItemSet ) );
     254                 :            : }
     255                 :            : 
     256                 :            : /*************************************************************************
     257                 :            : |*
     258                 :            : |* Set initial focus
     259                 :            : |*
     260                 :            : |************************************************************************/
     261                 :            : 
     262                 :          0 : void SvxHyperlinkNewDocTp::SetInitFocus()
     263                 :            : {
     264                 :          0 :     maCbbPath.GrabFocus();
     265                 :          0 : }
     266                 :            : 
     267                 :            : /*************************************************************************
     268                 :            : |*
     269                 :            : |* Ask page whether an insert is possible
     270                 :            : |*
     271                 :            : \************************************************************************/
     272                 :            : 
     273                 :          0 : sal_Bool SvxHyperlinkNewDocTp::AskApply()
     274                 :            : {
     275         [ #  # ]:          0 :     INetURLObject aINetURLObject;
     276 [ #  # ][ #  # ]:          0 :     sal_Bool bRet = ImplGetURLObject( maCbbPath.GetText(), maCbbPath.GetBaseURL(), aINetURLObject );
                 [ #  # ]
     277         [ #  # ]:          0 :     if ( !bRet )
     278                 :            :     {
     279 [ #  # ][ #  # ]:          0 :         WarningBox aWarning( this, WB_OK, CUI_RESSTR(RID_SVXSTR_HYPDLG_NOVALIDFILENAME) );
         [ #  # ][ #  # ]
                 [ #  # ]
     280 [ #  # ][ #  # ]:          0 :         aWarning.Execute();
     281                 :            :     }
     282         [ #  # ]:          0 :     return bRet;
     283                 :            : }
     284                 :            : 
     285                 :            : /*************************************************************************
     286                 :            : |*
     287                 :            : |* Any action to do after apply-button is pressed
     288                 :            : |*
     289                 :            : \************************************************************************/
     290                 :            : 
     291                 :          0 : void SvxHyperlinkNewDocTp::DoApply ()
     292                 :            : {
     293         [ #  # ]:          0 :     EnterWait();
     294                 :            : 
     295                 :            :     // get data from dialog-controls
     296         [ #  # ]:          0 :     String aStrNewName = maCbbPath.GetText();
     297                 :            : 
     298 [ #  # ][ #  # ]:          0 :     if ( aStrNewName == aEmptyStr )
     299         [ #  # ]:          0 :         aStrNewName = maStrInitURL;
     300                 :            : 
     301                 :            :     ///////////////////////////////////////////////////////
     302                 :            :     // create a real URL-String
     303                 :            : 
     304         [ #  # ]:          0 :     INetURLObject aURL;
     305 [ #  # ][ #  # ]:          0 :     if ( ImplGetURLObject( aStrNewName, maCbbPath.GetBaseURL(), aURL ) )
     306                 :            :     {
     307                 :            : 
     308                 :            :         ///////////////////////////////////////////////////////
     309                 :            :         // create Document
     310                 :            : 
     311 [ #  # ][ #  # ]:          0 :         aStrNewName = aURL.GetURLPath( INetURLObject::NO_DECODE );
     312                 :          0 :         SfxViewFrame *pViewFrame = NULL;
     313                 :            :         try
     314                 :            :         {
     315                 :          0 :             bool bCreate = true;
     316                 :            : 
     317                 :            :             // check if file exists, warn before we overwrite it
     318                 :            :             {
     319                 :          0 :                 com::sun::star::uno::Reference < com::sun::star::task::XInteractionHandler > xHandler;
     320 [ #  # ][ #  # ]:          0 :                 SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ, xHandler );
         [ #  # ][ #  # ]
     321                 :            : 
     322 [ #  # ][ #  # ]:          0 :                 sal_Bool bOk = pIStm && ( pIStm->GetError() == 0);
     323                 :            : 
     324         [ #  # ]:          0 :                 if( pIStm )
     325 [ #  # ][ #  # ]:          0 :                     delete pIStm;
     326                 :            : 
     327         [ #  # ]:          0 :                 if( bOk )
     328                 :            :                 {
     329 [ #  # ][ #  # ]:          0 :                     WarningBox aWarning( this, WB_YES_NO, CUI_RESSTR(RID_SVXSTR_HYPERDLG_QUERYOVERWRITE) );
         [ #  # ][ #  # ]
                 [ #  # ]
     330 [ #  # ][ #  # ]:          0 :                     bCreate = aWarning.Execute() == BUTTON_YES;
     331                 :          0 :                 }
     332                 :            :             }
     333                 :            : 
     334         [ #  # ]:          0 :             if( bCreate )
     335                 :            :             {
     336                 :            :                 // current document
     337         [ #  # ]:          0 :                 SfxViewFrame* pCurrentDocFrame = SfxViewFrame::Current();
     338                 :            : 
     339 [ #  # ][ #  # ]:          0 :                 if ( aStrNewName != aEmptyStr )
     340                 :            :                 {
     341                 :            :                     // get private-url
     342         [ #  # ]:          0 :                     sal_uInt16 nPos = maLbDocTypes.GetSelectEntryPos();
     343         [ #  # ]:          0 :                     if( nPos == LISTBOX_ENTRY_NOTFOUND )
     344                 :          0 :                         nPos=0;
     345                 :            :                     String aStrDocName ( ( ( DocumentTypeData* )
     346 [ #  # ][ #  # ]:          0 :                                          maLbDocTypes.GetEntryData( nPos ) )->aStrURL );
     347                 :            : 
     348                 :            :                     // create items
     349         [ #  # ]:          0 :                     SfxStringItem aName( SID_FILE_NAME, aStrDocName );
     350 [ #  # ][ #  # ]:          0 :                     SfxStringItem aReferer( SID_REFERER, rtl::OUString("private:user") );
                 [ #  # ]
     351 [ #  # ][ #  # ]:          0 :                     SfxStringItem aFrame( SID_TARGETNAME, rtl::OUString("_blank") );
                 [ #  # ]
     352                 :            : 
     353                 :          0 :                     rtl::OUString aStrFlags('S');
     354         [ #  # ]:          0 :                     if ( maRbtEditLater.IsChecked() )
     355                 :            :                     {
     356                 :          0 :                         aStrFlags += rtl::OUString('H');
     357                 :            :                     }
     358 [ #  # ][ #  # ]:          0 :                     SfxStringItem aFlags (SID_OPTIONS, aStrFlags);
                 [ #  # ]
     359                 :            : 
     360                 :            :                     // open url
     361                 :            :                     const SfxPoolItem* pReturn = GetDispatcher()->Execute( SID_OPENDOC,
     362                 :            :                                                                            SFX_CALLMODE_SYNCHRON,
     363                 :            :                                                                            &aName, &aFlags,
     364 [ #  # ][ #  # ]:          0 :                                                                            &aFrame, &aReferer, 0L );
     365                 :            : 
     366                 :            :                     // save new doc
     367 [ #  # ][ #  # ]:          0 :                     const SfxViewFrameItem *pItem = PTR_CAST( SfxViewFrameItem, pReturn );  // SJ: pReturn is NULL if the Hyperlink
         [ #  # ][ #  # ]
     368         [ #  # ]:          0 :                     if ( pItem )                                                            // creation is cancelled #106216#
     369                 :            :                     {
     370                 :          0 :                         pViewFrame = pItem->GetFrame();
     371         [ #  # ]:          0 :                         if (pViewFrame)
     372                 :            :                         {
     373 [ #  # ][ #  # ]:          0 :                             SfxStringItem aNewName( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     374                 :            : 
     375                 :            :                             pViewFrame->GetDispatcher()->Execute( SID_SAVEASDOC,
     376                 :            :                                                                   SFX_CALLMODE_SYNCHRON,
     377 [ #  # ][ #  # ]:          0 :                                                                   &aNewName, 0L );
     378                 :            : 
     379                 :            :                         }
     380 [ #  # ][ #  # ]:          0 :                     }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     381                 :            :                 }
     382                 :            : 
     383 [ #  # ][ #  # ]:          0 :                 if ( maRbtEditNow.IsChecked() && pCurrentDocFrame )
                 [ #  # ]
     384                 :            :                 {
     385         [ #  # ]:          0 :                     pCurrentDocFrame->ToTop();
     386                 :            :                 }
     387                 :            :             }
     388                 :            :         }
     389         [ #  # ]:          0 :         catch (const uno::Exception&)
     390                 :            :         {
     391                 :            :         }
     392                 :            : 
     393 [ #  # ][ #  # ]:          0 :         if ( pViewFrame && maRbtEditLater.IsChecked() )
                 [ #  # ]
     394                 :            :         {
     395         [ #  # ]:          0 :             SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
     396         [ #  # ]:          0 :             pObjShell->DoClose();
     397                 :            :         }
     398                 :            :     }
     399                 :            : 
     400 [ #  # ][ #  # ]:          0 :     LeaveWait();
                 [ #  # ]
     401                 :          0 : }
     402                 :            : 
     403                 :            : /*************************************************************************
     404                 :            : |*
     405                 :            : |* Click on imagebutton : new
     406                 :            : |*
     407                 :            : |************************************************************************/
     408                 :            : 
     409                 :          0 : IMPL_LINK_NOARG(SvxHyperlinkNewDocTp, ClickNewHdl_Impl)
     410                 :            : {
     411         [ #  # ]:          0 :     rtl::OUString                       aService( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) );
     412         [ #  # ]:          0 :     uno::Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     413 [ #  # ][ #  # ]:          0 :     uno::Reference < XFolderPicker >            xFolderPicker( xFactory->createInstance( aService ), UNO_QUERY );
                 [ #  # ]
     414                 :            : 
     415         [ #  # ]:          0 :     String              aStrURL;
     416         [ #  # ]:          0 :     String              aTempStrURL( maCbbPath.GetText() );
     417         [ #  # ]:          0 :     utl::LocalFileHelper::ConvertSystemPathToURL( aTempStrURL, maCbbPath.GetBaseURL(), aStrURL );
     418                 :            : 
     419         [ #  # ]:          0 :     String              aStrPath = aStrURL;
     420                 :          0 :     sal_Bool                bZeroPath = ( aStrPath.Len() == 0 );
     421                 :          0 :     sal_Bool                bHandleFileName = bZeroPath;    // when path has length of 0, then the rest should always be handled
     422                 :            :                                                         //  as file name, otherwise we do not yet know
     423                 :            : 
     424         [ #  # ]:          0 :     if( bZeroPath )
     425 [ #  # ][ #  # ]:          0 :         aStrPath = SvtPathOptions().GetWorkPath();
         [ #  # ][ #  # ]
     426 [ #  # ][ #  # ]:          0 :     else if( !::utl::UCBContentHelper::IsFolder( aStrURL ) )
                 [ #  # ]
     427                 :          0 :         bHandleFileName = sal_True;
     428                 :            : 
     429 [ #  # ][ #  # ]:          0 :     xFolderPicker->setDisplayDirectory( aStrPath );
                 [ #  # ]
     430                 :          0 :     DisableClose( sal_True );
     431 [ #  # ][ #  # ]:          0 :     sal_Int16 nResult = xFolderPicker->execute();
     432                 :          0 :     DisableClose( sal_False );
     433         [ #  # ]:          0 :     if( ExecutableDialogResults::OK == nResult )
     434                 :            :     {
     435                 :          0 :         sal_Char const  sSlash[] = "/";
     436                 :            : 
     437 [ #  # ][ #  # ]:          0 :         INetURLObject   aURL( aStrURL, INET_PROT_FILE );
     438         [ #  # ]:          0 :         String          aStrName;
     439         [ #  # ]:          0 :         if( bHandleFileName )
     440 [ #  # ][ #  # ]:          0 :             aStrName = bZeroPath? aTempStrURL : String(aURL.getName());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     441                 :            : 
     442 [ #  # ][ #  # ]:          0 :         maCbbPath.SetBaseURL( xFolderPicker->getDirectory() );
         [ #  # ][ #  # ]
                 [ #  # ]
     443 [ #  # ][ #  # ]:          0 :         String          aStrTmp( xFolderPicker->getDirectory() );
                 [ #  # ]
     444                 :            : 
     445         [ #  # ]:          0 :         if( aStrTmp.GetChar( aStrTmp.Len() - 1 ) != sSlash[0] )
     446         [ #  # ]:          0 :             aStrTmp.AppendAscii( sSlash );
     447                 :            : 
     448                 :            :         // append old file name
     449         [ #  # ]:          0 :         if( bHandleFileName )
     450         [ #  # ]:          0 :             aStrTmp += aStrName;
     451                 :            : 
     452 [ #  # ][ #  # ]:          0 :         INetURLObject   aNewURL( aStrTmp );
     453                 :            : 
     454 [ #  # ][ #  # ]:          0 :         if( aStrName.Len() > 0 && !aNewURL.getExtension().isEmpty() &&
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     455         [ #  # ]:          0 :             maLbDocTypes.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     456                 :            :         {
     457                 :            :             // get private-url
     458         [ #  # ]:          0 :             sal_uInt16 nPos = maLbDocTypes.GetSelectEntryPos();
     459 [ #  # ][ #  # ]:          0 :             aNewURL.setExtension( ( ( DocumentTypeData* ) maLbDocTypes.GetEntryData( nPos ) )->aStrExt );
                 [ #  # ]
     460                 :            :         }
     461                 :            : 
     462         [ #  # ]:          0 :         if( aNewURL.GetProtocol() == INET_PROT_FILE )
     463                 :            :         {
     464 [ #  # ][ #  # ]:          0 :             utl::LocalFileHelper::ConvertURLToSystemPath( aNewURL.GetMainURL( INetURLObject::NO_DECODE ), aStrTmp );
         [ #  # ][ #  # ]
     465                 :            :         }
     466                 :            :         else
     467                 :            :         {
     468 [ #  # ][ #  # ]:          0 :             aStrTmp = aNewURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
     469                 :            :         }
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :         maCbbPath.SetText ( aStrTmp );
         [ #  # ][ #  # ]
                 [ #  # ]
     472                 :            :     }
     473 [ #  # ][ #  # ]:          0 :     return( 0L );
                 [ #  # ]
     474                 :            : }
     475                 :            : 
     476                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10