LCOV - code coverage report
Current view: top level - cui/source/dialogs - insdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 460 0.0 %
Date: 2012-08-25 Functions: 0 26 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1329 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 <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      30                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      31                 :            : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      32                 :            : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      33                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      34                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      35                 :            : #include <comphelper/processfactory.hxx>
      36                 :            : #include <com/sun/star/embed/EmbedStates.hpp>
      37                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      38                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      39                 :            : #include <com/sun/star/embed/XInsertObjectDialog.hpp>
      40                 :            : #include <com/sun/star/ucb/CommandAbortedException.hpp>
      41                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      42                 :            : 
      43                 :            : #include "insdlg.hxx"
      44                 :            : #include <dialmgr.hxx>
      45                 :            : #include <svtools/sores.hxx>
      46                 :            : 
      47                 :            : #include <stdio.h>
      48                 :            : #include <tools/urlobj.hxx>
      49                 :            : #include <tools/debug.hxx>
      50                 :            : #include <svl/urihelper.hxx>
      51                 :            : #include <svtools/svmedit.hxx>
      52                 :            : #include <vcl/button.hxx>
      53                 :            : #include <vcl/fixed.hxx>
      54                 :            : #include <vcl/group.hxx>
      55                 :            : #include <vcl/lstbox.hxx>
      56                 :            : #include <vcl/msgbox.hxx>
      57                 :            : #include <vcl/svapp.hxx>
      58                 :            : #include <sot/clsids.hxx>
      59                 :            : #include <sfx2/frmdescr.hxx>
      60                 :            : #include <sfx2/viewsh.hxx>
      61                 :            : #include <sfx2/filedlghelper.hxx>
      62                 :            : #include <svl/ownlist.hxx>
      63                 :            : #include <comphelper/seqstream.hxx>
      64                 :            : 
      65                 :            : #include "svuidlg.hrc"
      66                 :            : 
      67                 :            : #include <osl/file.hxx>
      68                 :            : 
      69                 :            : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      70                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      71                 :            : 
      72                 :            : using namespace ::com::sun::star;
      73                 :            : using namespace ::com::sun::star::lang;
      74                 :            : using namespace ::com::sun::star::uno;
      75                 :            : using namespace ::com::sun::star::container;
      76                 :            : using namespace ::com::sun::star::ui::dialogs;
      77                 :            : using ::rtl::OUString;
      78                 :            : 
      79                 :            : 
      80                 :          0 : static String impl_getSvtResString( sal_uInt32 nId )
      81                 :            : {
      82         [ #  # ]:          0 :     String aRet;
      83 [ #  # ][ #  # ]:          0 :     com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
      84         [ #  # ]:          0 :     ResMgr* pMgr = ResMgr::CreateResMgr( "svt", aLocale );
      85         [ #  # ]:          0 :     if( pMgr )
      86                 :            :     {
      87 [ #  # ][ #  # ]:          0 :         aRet = String( ResId( nId, *pMgr ) );
                 [ #  # ]
      88 [ #  # ][ #  # ]:          0 :         delete pMgr;
      89                 :            :     }
      90                 :          0 :     return aRet;
      91                 :            : }
      92                 :            : 
      93                 :          0 : sal_Bool InsertObjectDialog_Impl::IsCreateNew() const
      94                 :            : {
      95                 :          0 :     return sal_False;
      96                 :            : }
      97                 :            : 
      98                 :          0 : uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( ::rtl::OUString* /*pGraphicMediaType*/ )
      99                 :            : {
     100                 :          0 :     return uno::Reference< io::XInputStream >();
     101                 :            : }
     102                 :            : 
     103                 :          0 : InsertObjectDialog_Impl::InsertObjectDialog_Impl( Window * pParent, const ResId & rResId, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
     104                 :            :  : ModalDialog( pParent, rResId )
     105                 :            :  , m_xStorage( xStorage )
     106         [ #  # ]:          0 :  , aCnt( m_xStorage )
     107                 :            : {
     108                 :          0 : }
     109                 :            : 
     110                 :            : // -----------------------------------------------------------------------
     111                 :            : 
     112                 :          0 : IMPL_LINK_NOARG_INLINE_START(SvInsertOleDlg, DoubleClickHdl)
     113                 :            : {
     114                 :          0 :     EndDialog( RET_OK );
     115                 :          0 :     return 0;
     116                 :            : }
     117                 :          0 : IMPL_LINK_INLINE_END( SvInsertOleDlg, DoubleClickHdl, ListBox *, pListBox )
     118                 :            : 
     119                 :            : // -----------------------------------------------------------------------
     120                 :            : 
     121                 :          0 : IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl)
     122                 :            : {
     123         [ #  # ]:          0 :     Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     124         [ #  # ]:          0 :     if( xFactory.is() )
     125                 :            :     {
     126 [ #  # ][ #  # ]:          0 :         Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     127                 :            :         DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
     128                 :            : 
     129         [ #  # ]:          0 :         Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
     130         [ #  # ]:          0 :         Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
     131 [ #  # ][ #  # ]:          0 :         if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
         [ #  # ][ #  # ]
     132                 :            :         {
     133         [ #  # ]:          0 :             Sequence< Any > aServiceType( 1 );
     134 [ #  # ][ #  # ]:          0 :             aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
     135 [ #  # ][ #  # ]:          0 :             xInit->initialize( aServiceType );
     136                 :            : 
     137                 :            :             // add filter
     138                 :            :             try
     139                 :            :             {
     140         [ #  # ]:          0 :                 xFilterMgr->appendFilter(
     141                 :            :                      OUString(),
     142                 :            :                      OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) )
     143 [ #  # ][ #  # ]:          0 :                      );
                 [ #  # ]
     144                 :            :             }
     145         [ #  # ]:          0 :             catch( IllegalArgumentException& )
     146                 :            :             {
     147                 :            :                 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
     148                 :            :             }
     149                 :            : 
     150 [ #  # ][ #  # ]:          0 :             if( xFilePicker->execute() == ExecutableDialogResults::OK )
                 [ #  # ]
     151                 :            :             {
     152 [ #  # ][ #  # ]:          0 :                 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
     153 [ #  # ][ #  # ]:          0 :                 INetURLObject aObj( aPathSeq[0] );
     154 [ #  # ][ #  # ]:          0 :                 aEdFilepath.SetText( aObj.PathToFileName() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     155         [ #  # ]:          0 :             }
     156                 :          0 :         }
     157                 :            :     }
     158                 :            : 
     159                 :          0 :     return 0;
     160                 :            : }
     161                 :            : 
     162                 :            : // -----------------------------------------------------------------------
     163                 :            : 
     164                 :          0 : IMPL_LINK_NOARG(SvInsertOleDlg, RadioHdl)
     165                 :            : {
     166         [ #  # ]:          0 :     if ( aRbNewObject.IsChecked() )
     167                 :            :     {
     168                 :          0 :         aLbObjecttype.Show();
     169                 :          0 :         aEdFilepath.Hide();
     170                 :          0 :         aBtnFilepath.Hide();
     171                 :          0 :         aCbFilelink.Hide();
     172                 :          0 :         aGbObject.SetText( _aOldStr );
     173                 :            :     }
     174                 :            :     else
     175                 :            :     {
     176                 :          0 :         aCbFilelink.Show();
     177                 :          0 :         aLbObjecttype.Hide();
     178                 :          0 :         aEdFilepath.Show();
     179                 :          0 :         aBtnFilepath.Show();
     180                 :          0 :         aCbFilelink.Show();
     181                 :          0 :         aGbObject.SetText( aStrFile );
     182                 :            :     }
     183                 :          0 :     return 0;
     184                 :            : }
     185                 :            : 
     186                 :            : // -----------------------------------------------------------------------
     187                 :            : 
     188                 :          0 : void SvInsertOleDlg::SelectDefault()
     189                 :            : {
     190                 :          0 :     aLbObjecttype.SelectEntryPos( 0 );
     191                 :          0 : }
     192                 :            : 
     193                 :            : // -----------------------------------------------------------------------
     194                 :          0 : SvInsertOleDlg::SvInsertOleDlg
     195                 :            : (
     196                 :            :     Window* pParent,
     197                 :            :     const Reference < embed::XStorage >& xStorage,
     198                 :            :     const SvObjectServerList* pServers
     199                 :            : )
     200                 :          0 :     : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OLEOBJECT ), xStorage ),
     201         [ #  # ]:          0 :     aRbNewObject( this, CUI_RES( RB_NEW_OBJECT ) ),
     202         [ #  # ]:          0 :     aRbObjectFromfile( this, CUI_RES( RB_OBJECT_FROMFILE ) ),
     203         [ #  # ]:          0 :     aGbObject( this, CUI_RES( GB_OBJECT ) ),
     204         [ #  # ]:          0 :     aLbObjecttype( this, CUI_RES( LB_OBJECTTYPE ) ),
     205         [ #  # ]:          0 :     aEdFilepath( this, CUI_RES( ED_FILEPATH ) ),
     206         [ #  # ]:          0 :     aBtnFilepath( this, CUI_RES( BTN_FILEPATH ) ),
     207         [ #  # ]:          0 :     aCbFilelink( this, CUI_RES( CB_FILELINK ) ),
     208         [ #  # ]:          0 :     aOKButton1( this, CUI_RES( 1 ) ),
     209         [ #  # ]:          0 :     aCancelButton1( this, CUI_RES( 1 ) ),
     210         [ #  # ]:          0 :     aHelpButton1( this, CUI_RES( 1 ) ),
     211         [ #  # ]:          0 :     aStrFile( CUI_RES( STR_FILE ) ),
     212 [ #  # ][ #  # ]:          0 :     m_pServers( pServers )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     213                 :            : {
     214         [ #  # ]:          0 :     FreeResource();
     215 [ #  # ][ #  # ]:          0 :     _aOldStr = aGbObject.GetText();
                 [ #  # ]
     216         [ #  # ]:          0 :     aLbObjecttype.SetDoubleClickHdl( LINK( this, SvInsertOleDlg, DoubleClickHdl ) );
     217         [ #  # ]:          0 :     aBtnFilepath.SetClickHdl( LINK( this, SvInsertOleDlg, BrowseHdl ) );
     218         [ #  # ]:          0 :     Link aLink( LINK( this, SvInsertOleDlg, RadioHdl ) );
     219                 :          0 :     aRbNewObject.SetClickHdl( aLink );
     220                 :          0 :     aRbObjectFromfile.SetClickHdl( aLink );
     221         [ #  # ]:          0 :     aRbNewObject.Check( sal_True );
     222         [ #  # ]:          0 :     RadioHdl( NULL );
     223         [ #  # ]:          0 :     aBtnFilepath.SetAccessibleRelationMemberOf(&aGbObject);
     224                 :          0 : }
     225                 :            : 
     226                 :          0 : short SvInsertOleDlg::Execute()
     227                 :            : {
     228                 :          0 :     short nRet = RET_OK;
     229         [ #  # ]:          0 :     SvObjectServerList  aObjS;
     230         [ #  # ]:          0 :     if ( !m_pServers )
     231                 :            :     {
     232                 :            :         // if no list was provided, take the complete one
     233         [ #  # ]:          0 :         aObjS.FillInsertObjects();
     234                 :          0 :         m_pServers = &aObjS;
     235                 :            :     }
     236                 :            : 
     237                 :            :     // fill listbox and select default
     238                 :          0 :     ListBox& rBox = GetObjectTypes();
     239         [ #  # ]:          0 :     rBox.SetUpdateMode( sal_False );
     240         [ #  # ]:          0 :     for ( sal_uLong i = 0; i < m_pServers->Count(); i++ )
     241 [ #  # ][ #  # ]:          0 :         rBox.InsertEntry( (*m_pServers)[i].GetHumanName() );
                 [ #  # ]
     242         [ #  # ]:          0 :     rBox.SetUpdateMode( sal_True );
     243         [ #  # ]:          0 :     SelectDefault();
     244                 :          0 :     ::rtl::OUString aName;
     245                 :            : 
     246                 :            :     DBG_ASSERT( m_xStorage.is(), "No storage!");
     247 [ #  # ][ #  # ]:          0 :     if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
         [ #  # ][ #  # ]
     248                 :            :     {
     249         [ #  # ]:          0 :         String aFileName;
     250                 :          0 :         sal_Bool bLink = sal_False;
     251         [ #  # ]:          0 :         sal_Bool bCreateNew = IsCreateNew();
     252         [ #  # ]:          0 :         if ( bCreateNew )
     253                 :            :         {
     254                 :            :             // create and insert new embedded object
     255         [ #  # ]:          0 :             String aServerName = rBox.GetSelectEntry();
     256         [ #  # ]:          0 :             const SvObjectServer* pS = m_pServers->Get( aServerName );
     257         [ #  # ]:          0 :             if ( pS )
     258                 :            :             {
     259 [ #  # ][ #  # ]:          0 :                 if( pS->GetClassName() == SvGlobalName( SO3_OUT_CLASSID ) )
         [ #  # ][ #  # ]
     260                 :            :                 {
     261                 :            :                     try
     262                 :            :                     {
     263                 :            :                         uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
     264 [ #  # ][ #  # ]:          0 :                             ::comphelper::getProcessServiceFactory()->createInstance(
     265                 :          0 :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
     266 [ #  # ][ #  # ]:          0 :                             uno::UNO_QUERY );
                 [ #  # ]
     267                 :            : 
     268         [ #  # ]:          0 :                         if ( xDialogCreator.is() )
     269                 :            :                         {
     270         [ #  # ]:          0 :                             aName = aCnt.CreateUniqueObjectName();
     271         [ #  # ]:          0 :                             embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
     272                 :            :                                                                     m_xStorage,
     273                 :            :                                                                     aName,
     274 [ #  # ][ #  # ]:          0 :                                                                     uno::Sequence < beans::PropertyValue >() );
                 [ #  # ]
     275                 :            : 
     276                 :            :                             OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
     277         [ #  # ]:          0 :                             m_xObj = aNewInf.Object;
     278         [ #  # ]:          0 :                             for ( sal_Int32 nInd = 0; nInd < aNewInf.Options.getLength(); nInd++ )
     279 [ #  # ][ #  # ]:          0 :                                 if ( aNewInf.Options[nInd].Name == "Icon" )
     280                 :            :                                 {
     281 [ #  # ][ #  # ]:          0 :                                     aNewInf.Options[nInd].Value >>= m_aIconMetaFile;
     282                 :            :                                 }
     283 [ #  # ][ #  # ]:          0 :                                 else if ( aNewInf.Options[nInd].Name == "IconFormat" )
     284                 :            :                                 {
     285                 :          0 :                                     datatransfer::DataFlavor aFlavor;
     286 [ #  # ][ #  # ]:          0 :                                     if ( aNewInf.Options[nInd].Value >>= aFlavor )
                 [ #  # ]
     287                 :          0 :                                         m_aIconMediaType = aFlavor.MimeType;
     288         [ #  # ]:          0 :                                 }
     289                 :            : 
     290      [ #  #  # ]:          0 :                         }
     291                 :            :                     }
     292         [ #  # ]:          0 :                     catch( ucb::CommandAbortedException& )
     293                 :            :                     {
     294                 :            :                         // the user has pressed cancel
     295                 :            :                     }
     296         [ #  # ]:          0 :                     catch( uno::Exception& )
     297                 :            :                     {
     298                 :            :                         // TODO: Error handling
     299                 :            :                     }
     300                 :            :                 }
     301                 :            :                 else
     302                 :            :                 {
     303                 :            :                     // create object with desired ClassId
     304 [ #  # ][ #  # ]:          0 :                     m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
         [ #  # ][ #  # ]
     305                 :            :                 }
     306                 :            : 
     307         [ #  # ]:          0 :                 if ( !m_xObj.is() )
     308                 :            :                 {
     309         [ #  # ]:          0 :                     if( aFileName.Len() )  // from OLE Dialog
     310                 :            :                     {
     311                 :            :                         // object couldn't be created from file
     312                 :            :                         // global Resource from svtools (former so3 resource)
     313         [ #  # ]:          0 :                         String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
     314 [ #  # ][ #  # ]:          0 :                         aErr.SearchAndReplace( rtl::OUString( '%' ), aFileName );
                 [ #  # ]
     315 [ #  # ][ #  # ]:          0 :                         ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
         [ #  # ][ #  # ]
     316                 :            :                     }
     317                 :            :                     else
     318                 :            :                     {
     319                 :            :                         // object couldn't be created
     320                 :            :                         // global Resource from svtools (former so3 resource)
     321         [ #  # ]:          0 :                         String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE ) );
     322 [ #  # ][ #  # ]:          0 :                         aErr.SearchAndReplace( rtl::OUString( '%' ), aServerName );
                 [ #  # ]
     323 [ #  # ][ #  # ]:          0 :                         ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
         [ #  # ][ #  # ]
     324                 :            :                     }
     325                 :            :                 }
     326         [ #  # ]:          0 :             }
     327                 :            :         }
     328                 :            :         else
     329                 :            :         {
     330 [ #  # ][ #  # ]:          0 :             aFileName = GetFilePath();
                 [ #  # ]
     331         [ #  # ]:          0 :             INetURLObject aURL;
     332                 :          0 :             aURL.SetSmartProtocol( INET_PROT_FILE );
     333 [ #  # ][ #  # ]:          0 :             aURL.SetSmartURL( aFileName );
     334 [ #  # ][ #  # ]:          0 :             aFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
     335         [ #  # ]:          0 :             bLink = IsLinked();
     336                 :            : 
     337         [ #  # ]:          0 :             if ( aFileName.Len() )
     338                 :            :             {
     339                 :            :                 // create MediaDescriptor for file to create object from
     340         [ #  # ]:          0 :                 uno::Sequence < beans::PropertyValue > aMedium( 2 );
     341 [ #  # ][ #  # ]:          0 :                 aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
     342 [ #  # ][ #  # ]:          0 :                 aMedium[0].Value <<= ::rtl::OUString( aFileName );
                 [ #  # ]
     343                 :            : 
     344                 :          0 :                 uno::Reference< task::XInteractionHandler > xInteraction;
     345         [ #  # ]:          0 :                 uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
     346         [ #  # ]:          0 :                 if ( xFactory.is() )
     347                 :            :                     xInteraction = uno::Reference< task::XInteractionHandler >(
     348         [ #  # ]:          0 :                         xFactory->createInstance(
     349                 :          0 :                             DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
     350 [ #  # ][ #  # ]:          0 :                         uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     351                 :            : 
     352         [ #  # ]:          0 :                 if ( xInteraction.is() )
     353                 :            :                 {
     354 [ #  # ][ #  # ]:          0 :                        aMedium[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) );
     355 [ #  # ][ #  # ]:          0 :                        aMedium[1].Value <<= xInteraction;
     356                 :            :                 }
     357                 :            :                 else
     358                 :            :                 {
     359                 :            :                     OSL_FAIL( "Can not get InteractionHandler!\n" );
     360         [ #  # ]:          0 :                     aMedium.realloc( 1 );
     361                 :            :                 }
     362                 :            : 
     363                 :            :                 // create object from media descriptor
     364         [ #  # ]:          0 :                 if ( bLink )
     365 [ #  # ][ #  # ]:          0 :                     m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
     366                 :            :                 else
     367 [ #  # ][ #  # ]:          0 :                     m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
                 [ #  # ]
     368                 :            :             }
     369                 :            : 
     370         [ #  # ]:          0 :             if ( !m_xObj.is() )
     371                 :            :             {
     372                 :            :                 // object couldn't be created from file
     373                 :            :                 // global Resource from svtools (former so3 resource)
     374         [ #  # ]:          0 :                 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
     375 [ #  # ][ #  # ]:          0 :                 aErr.SearchAndReplace( rtl::OUString( '%' ), aFileName );
                 [ #  # ]
     376 [ #  # ][ #  # ]:          0 :                 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
         [ #  # ][ #  # ]
     377         [ #  # ]:          0 :             }
     378         [ #  # ]:          0 :         }
     379                 :            :     }
     380                 :            : 
     381                 :          0 :     m_pServers = 0;
     382                 :          0 :     return nRet;
     383                 :            : }
     384                 :            : 
     385                 :          0 : uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( ::rtl::OUString* pGraphicMediaType )
     386                 :            : {
     387         [ #  # ]:          0 :     if ( m_aIconMetaFile.getLength() )
     388                 :            :     {
     389         [ #  # ]:          0 :         if ( pGraphicMediaType )
     390                 :          0 :             *pGraphicMediaType = m_aIconMediaType;
     391                 :            : 
     392 [ #  # ][ #  # ]:          0 :         return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
     393                 :            :     }
     394                 :            : 
     395                 :          0 :     return uno::Reference< io::XInputStream >();
     396                 :            : }
     397                 :            : 
     398                 :          0 : IMPL_LINK_NOARG(SvInsertPlugInDialog, BrowseHdl)
     399                 :            : {
     400 [ #  # ][ #  # ]:          0 :     Sequence< OUString > aFilterNames, aFilterTypes;
     401                 :            :     void fillNetscapePluginFilters( Sequence< OUString >& rNames, Sequence< OUString >& rTypes );
     402         [ #  # ]:          0 :     fillNetscapePluginFilters( aFilterNames, aFilterTypes );
     403                 :            : 
     404         [ #  # ]:          0 :     Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     405         [ #  # ]:          0 :     if( xFactory.is() )
     406                 :            :     {
     407 [ #  # ][ #  # ]:          0 :         Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     408                 :            :         DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
     409                 :            : 
     410         [ #  # ]:          0 :         Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
     411         [ #  # ]:          0 :         Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
     412 [ #  # ][ #  # ]:          0 :         if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
         [ #  # ][ #  # ]
     413                 :            :         {
     414         [ #  # ]:          0 :             Sequence< Any > aServiceType( 1 );
     415 [ #  # ][ #  # ]:          0 :             aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
     416 [ #  # ][ #  # ]:          0 :             xInit->initialize( aServiceType );
     417                 :            : 
     418                 :            :             // add the filters
     419                 :            :             try
     420                 :            :             {
     421                 :          0 :                 const OUString* pNames = aFilterNames.getConstArray();
     422                 :          0 :                 const OUString* pTypes = aFilterTypes.getConstArray();
     423         [ #  # ]:          0 :                 for( int i = 0; i < aFilterNames.getLength(); i++ )
     424 [ #  # ][ #  # ]:          0 :                     xFilterMgr->appendFilter( pNames[i], pTypes[i] );
     425                 :            :             }
     426         [ #  # ]:          0 :             catch( IllegalArgumentException& )
     427                 :            :             {
     428                 :            :                 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
     429                 :            :             }
     430                 :            : 
     431 [ #  # ][ #  # ]:          0 :             if( xFilePicker->execute() == ExecutableDialogResults::OK )
                 [ #  # ]
     432                 :            :             {
     433 [ #  # ][ #  # ]:          0 :                 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
     434 [ #  # ][ #  # ]:          0 :                 INetURLObject aObj( aPathSeq[0] );
     435 [ #  # ][ #  # ]:          0 :                 aEdFileurl.SetText( aObj.PathToFileName() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     436         [ #  # ]:          0 :             }
     437                 :          0 :         }
     438                 :            :     }
     439                 :            : 
     440 [ #  # ][ #  # ]:          0 :     return 0;
     441                 :            : }
     442                 :            : 
     443                 :            : // -----------------------------------------------------------------------
     444                 :            : 
     445                 :          0 : SvInsertPlugInDialog::SvInsertPlugInDialog( Window* pParent, const uno::Reference < embed::XStorage >& xStorage )
     446                 :          0 :     : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_PLUGIN ), xStorage ),
     447         [ #  # ]:          0 :     aGbFileurl( this, CUI_RES( GB_FILEURL ) ),
     448         [ #  # ]:          0 :     aEdFileurl( this, CUI_RES( ED_FILEURL ) ),
     449         [ #  # ]:          0 :     aBtnFileurl( this, CUI_RES( BTN_FILEURL ) ),
     450         [ #  # ]:          0 :     aGbPluginsOptions( this, CUI_RES( GB_PLUGINS_OPTIONS ) ),
     451         [ #  # ]:          0 :     aEdPluginsOptions( this, CUI_RES( ED_PLUGINS_OPTIONS ) ),
     452         [ #  # ]:          0 :     aOKButton1( this, CUI_RES( 1 ) ),
     453         [ #  # ]:          0 :     aCancelButton1( this, CUI_RES( 1 ) ),
     454         [ #  # ]:          0 :     aHelpButton1( this, CUI_RES( 1 ) ),
     455 [ #  # ][ #  # ]:          0 :     m_pURL(0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     456                 :            : {
     457         [ #  # ]:          0 :     FreeResource();
     458         [ #  # ]:          0 :     aBtnFileurl.SetClickHdl( LINK( this, SvInsertPlugInDialog, BrowseHdl ) );
     459                 :          0 : }
     460                 :            : 
     461 [ #  # ][ #  # ]:          0 : SvInsertPlugInDialog::~SvInsertPlugInDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     462                 :            : {
     463 [ #  # ][ #  # ]:          0 :     delete m_pURL;
     464         [ #  # ]:          0 : }
     465                 :            : 
     466                 :            : // -----------------------------------------------------------------------
     467                 :            : 
     468                 :          0 : static void Plugin_ImplFillCommandSequence( const String& aCommands, uno::Sequence< beans::PropertyValue >& aCommandSequence )
     469                 :            : {
     470                 :            :     sal_Int32 nEaten;
     471         [ #  # ]:          0 :     SvCommandList aLst;
     472 [ #  # ][ #  # ]:          0 :     aLst.AppendCommands( aCommands, &nEaten );
     473                 :            : 
     474                 :          0 :     const size_t nCount = aLst.size();
     475         [ #  # ]:          0 :     aCommandSequence.realloc( nCount );
     476         [ #  # ]:          0 :     for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
     477                 :            :     {
     478 [ #  # ][ #  # ]:          0 :         aCommandSequence[nIndex].Name = aLst[ nIndex ].GetCommand();
     479         [ #  # ]:          0 :         aCommandSequence[nIndex].Handle = -1;
     480 [ #  # ][ #  # ]:          0 :         aCommandSequence[nIndex].Value = makeAny( aLst[ nIndex ].GetArgument() );
                 [ #  # ]
     481         [ #  # ]:          0 :         aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
     482                 :          0 :     }
     483                 :          0 : }
     484                 :            : 
     485                 :          0 : short SvInsertPlugInDialog::Execute()
     486                 :            : {
     487                 :          0 :     short nRet = RET_OK;
     488                 :          0 :     m_aCommands.Erase();
     489                 :            :     DBG_ASSERT( m_xStorage.is(), "No storage!");
     490 [ #  # ][ #  # ]:          0 :     if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
                 [ #  # ]
     491                 :            :     {
     492         [ #  # ]:          0 :         if ( !m_pURL )
     493 [ #  # ][ #  # ]:          0 :             m_pURL = new INetURLObject();
     494                 :            :         else
     495 [ #  # ][ #  # ]:          0 :             *m_pURL = INetURLObject();
                 [ #  # ]
     496                 :            : 
     497 [ #  # ][ #  # ]:          0 :         m_aCommands = GetPlugInOptions();
                 [ #  # ]
     498         [ #  # ]:          0 :         String aURL = GetPlugInFile();
     499                 :            : 
     500                 :            :         // URL can be a valid and absolute URL or a system file name
     501                 :          0 :         m_pURL->SetSmartProtocol( INET_PROT_FILE );
     502 [ #  # ][ #  # ]:          0 :         if ( !aURL.Len() || m_pURL->SetSmartURL( aURL ) )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     503                 :            :         {
     504                 :            :             // create a plugin object
     505                 :          0 :             ::rtl::OUString aName;
     506         [ #  # ]:          0 :             SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
     507 [ #  # ][ #  # ]:          0 :             m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
         [ #  # ][ #  # ]
                 [ #  # ]
     508                 :            :         }
     509                 :            : 
     510         [ #  # ]:          0 :         if ( m_xObj.is() )
     511                 :            :         {
     512                 :            :             // set properties from dialog
     513 [ #  # ][ #  # ]:          0 :             if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
                 [ #  # ]
     514 [ #  # ][ #  # ]:          0 :                 m_xObj->changeState( embed::EmbedStates::RUNNING );
     515                 :            : 
     516 [ #  # ][ #  # ]:          0 :             uno::Reference < beans::XPropertySet > xSet( m_xObj->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
     517         [ #  # ]:          0 :             if ( xSet.is() )
     518                 :            :             {
     519         [ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PluginURL") ),
     520 [ #  # ][ #  # ]:          0 :                         makeAny( ::rtl::OUString( m_pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
         [ #  # ][ #  # ]
     521         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aCommandSequence;
     522         [ #  # ]:          0 :                 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
     523 [ #  # ][ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PluginCommands") ), makeAny( aCommandSequence ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     524                 :          0 :             }
     525                 :            :         }
     526                 :            :         else
     527                 :            :         {
     528                 :            :             // PlugIn couldn't be created
     529                 :            :             // global Resource from svtools (former so3 resource)
     530         [ #  # ]:          0 :             String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_PLUGIN ) );
     531 [ #  # ][ #  # ]:          0 :             aErr.SearchAndReplace( rtl::OUString('%'), aURL );
                 [ #  # ]
     532 [ #  # ][ #  # ]:          0 :             ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
         [ #  # ][ #  # ]
     533         [ #  # ]:          0 :         }
     534                 :            :     }
     535                 :            : 
     536                 :          0 :     return nRet;
     537                 :            : }
     538                 :            : 
     539                 :          0 : SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent,
     540                 :            :                             const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
     541                 :          0 :     : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), xStorage )
     542         [ #  # ]:          0 :     , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
     543         [ #  # ]:          0 :     , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
     544         [ #  # ]:          0 :     , aFTURL ( this, CUI_RES( FT_URL ) )
     545         [ #  # ]:          0 :     , aEDURL ( this, CUI_RES( ED_URL ) )
     546         [ #  # ]:          0 :     , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
     547                 :            : 
     548         [ #  # ]:          0 :     , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
     549         [ #  # ]:          0 :     , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
     550         [ #  # ]:          0 :     , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
     551         [ #  # ]:          0 :     , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
     552         [ #  # ]:          0 :     , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
     553         [ #  # ]:          0 :     , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
     554         [ #  # ]:          0 :     , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
     555         [ #  # ]:          0 :     , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
     556         [ #  # ]:          0 :     , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
     557         [ #  # ]:          0 :     , aFLMargin( this, CUI_RES( GB_MARGIN ) )
     558         [ #  # ]:          0 :     , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
     559         [ #  # ]:          0 :     , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
     560         [ #  # ]:          0 :     , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
     561         [ #  # ]:          0 :     , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
     562         [ #  # ]:          0 :     , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
     563         [ #  # ]:          0 :     , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
     564         [ #  # ]:          0 :     , aOKButton1( this, CUI_RES( 1 ) )
     565         [ #  # ]:          0 :     , aCancelButton1( this, CUI_RES( 1 ) )
     566 [ #  # ][ #  # ]:          0 :     , aHelpButton1( this, CUI_RES( 1 ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     567                 :            : {
     568         [ #  # ]:          0 :     FreeResource();
     569                 :            : 
     570 [ #  # ][ #  # ]:          0 :     aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
     571 [ #  # ][ #  # ]:          0 :     aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
     572                 :            : 
     573         [ #  # ]:          0 :     Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
     574                 :          0 :     aCBMarginWidthDefault.SetClickHdl( aLink );
     575                 :          0 :     aCBMarginHeightDefault.SetClickHdl( aLink );
     576                 :            : 
     577         [ #  # ]:          0 :     aCBMarginWidthDefault.Check();
     578         [ #  # ]:          0 :     aCBMarginHeightDefault.Check();
     579         [ #  # ]:          0 :     aRBScrollingAuto.Check();
     580         [ #  # ]:          0 :     aRBFrameBorderOn.Check();
     581                 :            : 
     582         [ #  # ]:          0 :     aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
     583                 :          0 : }
     584                 :            : 
     585                 :          0 : SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent, const uno::Reference < embed::XEmbeddedObject >& xObj )
     586         [ #  # ]:          0 :     : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), uno::Reference < embed::XStorage >() )
     587         [ #  # ]:          0 :     , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
     588         [ #  # ]:          0 :     , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
     589         [ #  # ]:          0 :     , aFTURL ( this, CUI_RES( FT_URL ) )
     590         [ #  # ]:          0 :     , aEDURL ( this, CUI_RES( ED_URL ) )
     591         [ #  # ]:          0 :     , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
     592                 :            : 
     593         [ #  # ]:          0 :     , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
     594         [ #  # ]:          0 :     , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
     595         [ #  # ]:          0 :     , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
     596         [ #  # ]:          0 :     , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
     597                 :            : 
     598         [ #  # ]:          0 :     , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
     599         [ #  # ]:          0 :     , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
     600         [ #  # ]:          0 :     , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
     601         [ #  # ]:          0 :     , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
     602                 :            : 
     603         [ #  # ]:          0 :     , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
     604         [ #  # ]:          0 :     , aFLMargin( this, CUI_RES( GB_MARGIN ) )
     605         [ #  # ]:          0 :     , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
     606         [ #  # ]:          0 :     , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
     607         [ #  # ]:          0 :     , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
     608         [ #  # ]:          0 :     , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
     609         [ #  # ]:          0 :     , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
     610         [ #  # ]:          0 :     , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
     611         [ #  # ]:          0 :     , aOKButton1( this, CUI_RES( 1 ) )
     612         [ #  # ]:          0 :     , aCancelButton1( this, CUI_RES( 1 ) )
     613 [ #  # ][ #  # ]:          0 :     , aHelpButton1( this, CUI_RES( 1 ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     614                 :            : {
     615         [ #  # ]:          0 :     FreeResource();
     616                 :            : 
     617         [ #  # ]:          0 :     m_xObj = xObj;
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :     aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
     620 [ #  # ][ #  # ]:          0 :     aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
     621                 :            : 
     622         [ #  # ]:          0 :     Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
     623                 :          0 :     aCBMarginWidthDefault.SetClickHdl( aLink );
     624                 :          0 :     aCBMarginHeightDefault.SetClickHdl( aLink );
     625                 :            : 
     626         [ #  # ]:          0 :     aCBMarginWidthDefault.Check();
     627         [ #  # ]:          0 :     aCBMarginHeightDefault.Check();
     628         [ #  # ]:          0 :     aRBScrollingAuto.Check();
     629         [ #  # ]:          0 :     aRBFrameBorderOn.Check();
     630                 :            : 
     631         [ #  # ]:          0 :     aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
     632                 :          0 : }
     633                 :            : 
     634                 :          0 : short SfxInsertFloatingFrameDialog::Execute()
     635                 :            : {
     636                 :          0 :     short nRet = RET_OK;
     637                 :          0 :     sal_Bool bOK = sal_False;
     638                 :          0 :     uno::Reference < beans::XPropertySet > xSet;
     639         [ #  # ]:          0 :     if ( m_xObj.is() )
     640                 :            :     {
     641                 :            :         try
     642                 :            :         {
     643 [ #  # ][ #  # ]:          0 :             if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
                 [ #  # ]
     644 [ #  # ][ #  # ]:          0 :                 m_xObj->changeState( embed::EmbedStates::RUNNING );
     645 [ #  # ][ #  # ]:          0 :             xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     646                 :          0 :             ::rtl::OUString aStr;
     647 [ #  # ][ #  # ]:          0 :             uno::Any aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameURL") ) );
                 [ #  # ]
     648         [ #  # ]:          0 :             if ( aAny >>= aStr )
     649 [ #  # ][ #  # ]:          0 :                 aEDURL.SetText( aStr );
                 [ #  # ]
     650 [ #  # ][ #  # ]:          0 :             aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameName") ) );
                 [ #  # ]
     651         [ #  # ]:          0 :             if ( aAny >>= aStr )
     652 [ #  # ][ #  # ]:          0 :                 aEDName.SetText( aStr );
                 [ #  # ]
     653                 :            : 
     654                 :          0 :             sal_Int32 nSize = SIZE_NOT_SET;
     655 [ #  # ][ #  # ]:          0 :             aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameMarginWidth") ) );
                 [ #  # ]
     656                 :          0 :             aAny >>= nSize;
     657                 :            : 
     658         [ #  # ]:          0 :             if ( nSize == SIZE_NOT_SET )
     659                 :            :             {
     660         [ #  # ]:          0 :                 aCBMarginWidthDefault.Check( sal_True );
     661 [ #  # ][ #  # ]:          0 :                 aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH )  );
                 [ #  # ]
     662         [ #  # ]:          0 :                 aFTMarginWidth.Enable( sal_False );
     663         [ #  # ]:          0 :                 aNMMarginWidth.Enable( sal_False );
     664                 :            :             }
     665                 :            :             else
     666 [ #  # ][ #  # ]:          0 :                 aNMMarginWidth.SetText( String::CreateFromInt32( nSize ) );
                 [ #  # ]
     667                 :            : 
     668 [ #  # ][ #  # ]:          0 :             aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameMarginHeight") ) );
                 [ #  # ]
     669                 :          0 :             aAny >>= nSize;
     670                 :            : 
     671         [ #  # ]:          0 :             if ( nSize == SIZE_NOT_SET )
     672                 :            :             {
     673         [ #  # ]:          0 :                 aCBMarginHeightDefault.Check( sal_True );
     674 [ #  # ][ #  # ]:          0 :                 aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT )  );
                 [ #  # ]
     675         [ #  # ]:          0 :                 aFTMarginHeight.Enable( sal_False );
     676         [ #  # ]:          0 :                 aNMMarginHeight.Enable( sal_False );
     677                 :            :             }
     678                 :            :             else
     679 [ #  # ][ #  # ]:          0 :                 aNMMarginHeight.SetText( String::CreateFromInt32( nSize ) );
                 [ #  # ]
     680                 :            : 
     681                 :          0 :             sal_Bool bScrollOn = sal_False;
     682                 :          0 :             sal_Bool bScrollOff = sal_False;
     683                 :          0 :             sal_Bool bScrollAuto = sal_False;
     684                 :            : 
     685                 :          0 :             sal_Bool bSet = sal_False;
     686 [ #  # ][ #  # ]:          0 :             aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsAutoScroll") ) );
                 [ #  # ]
     687                 :          0 :             aAny >>= bSet;
     688         [ #  # ]:          0 :             if ( !bSet )
     689                 :            :             {
     690 [ #  # ][ #  # ]:          0 :                 aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsScrollingMode") ) );
                 [ #  # ]
     691                 :          0 :                 aAny >>= bSet;
     692                 :          0 :                 bScrollOn = bSet;
     693                 :          0 :                 bScrollOff = !bSet;
     694                 :            :             }
     695                 :            :             else
     696                 :          0 :                 bScrollAuto = sal_True;
     697                 :            : 
     698         [ #  # ]:          0 :             aRBScrollingOn.Check( bScrollOn );
     699         [ #  # ]:          0 :             aRBScrollingOff.Check( bScrollOff );
     700         [ #  # ]:          0 :             aRBScrollingAuto.Check( bScrollAuto );
     701                 :            : 
     702                 :          0 :             bSet = sal_False;
     703 [ #  # ][ #  # ]:          0 :             aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsAutoBorder") ) );
                 [ #  # ]
     704                 :          0 :             aAny >>= bSet;
     705         [ #  # ]:          0 :             if ( !bSet )
     706                 :            :             {
     707 [ #  # ][ #  # ]:          0 :                 aAny = xSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsBorder") ) );
                 [ #  # ]
     708                 :          0 :                 aAny >>= bSet;
     709         [ #  # ]:          0 :                 aRBFrameBorderOn.Check( bSet );
     710         [ #  # ]:          0 :                 aRBFrameBorderOff.Check( !bSet );
     711                 :            :             }
     712                 :            : 
     713         [ #  # ]:          0 :             SetUpdateMode( sal_True );
     714         [ #  # ]:          0 :             bOK = sal_True;
     715                 :            :         }
     716         [ #  # ]:          0 :         catch ( uno::Exception& )
     717                 :            :         {
     718                 :            :             OSL_FAIL( "No IFrame!" );
     719                 :            :         }
     720                 :            :     }
     721                 :            :     else
     722                 :            :     {
     723                 :            :         DBG_ASSERT( m_xStorage.is(), "No storage!");
     724                 :          0 :         bOK = m_xStorage.is();
     725                 :            :     }
     726                 :            : 
     727 [ #  # ][ #  # ]:          0 :     if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
         [ #  # ][ #  # ]
     728                 :            :     {
     729                 :          0 :         ::rtl::OUString aURL;
     730 [ #  # ][ #  # ]:          0 :         if ( aEDURL.GetText().Len() )
                 [ #  # ]
     731                 :            :         {
     732                 :            :             // URL can be a valid and absolute URL or a system file name
     733         [ #  # ]:          0 :             INetURLObject aObj;
     734                 :          0 :             aObj.SetSmartProtocol( INET_PROT_FILE );
     735 [ #  # ][ #  # ]:          0 :             if ( aObj.SetSmartURL( aEDURL.GetText() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     736 [ #  # ][ #  # ]:          0 :                 aURL = aObj.GetMainURL( INetURLObject::NO_DECODE );
     737                 :            :         }
     738                 :            : 
     739 [ #  # ][ #  # ]:          0 :         if ( !m_xObj.is() && !aURL.isEmpty() )
                 [ #  # ]
     740                 :            :         {
     741                 :            :             // create the object
     742                 :          0 :             ::rtl::OUString aName;
     743         [ #  # ]:          0 :             SvGlobalName aClassId( SO3_IFRAME_CLASSID );
     744 [ #  # ][ #  # ]:          0 :             m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
         [ #  # ][ #  # ]
     745 [ #  # ][ #  # ]:          0 :             if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
                 [ #  # ]
     746 [ #  # ][ #  # ]:          0 :                 m_xObj->changeState( embed::EmbedStates::RUNNING );
     747 [ #  # ][ #  # ]:          0 :             xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     748                 :            :         }
     749                 :            : 
     750         [ #  # ]:          0 :         if ( m_xObj.is() )
     751                 :            :         {
     752                 :            :             try
     753                 :            :             {
     754 [ #  # ][ #  # ]:          0 :                 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
     755         [ #  # ]:          0 :                 if ( bIPActive )
     756 [ #  # ][ #  # ]:          0 :                     m_xObj->changeState( embed::EmbedStates::RUNNING );
     757                 :            : 
     758 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aName = aEDName.GetText();
                 [ #  # ]
     759                 :          0 :                 ScrollingMode eScroll = ScrollingNo;
     760         [ #  # ]:          0 :                 if ( aRBScrollingOn.IsChecked() )
     761                 :          0 :                     eScroll = ScrollingYes;
     762         [ #  # ]:          0 :                 if ( aRBScrollingOff.IsChecked() )
     763                 :          0 :                     eScroll = ScrollingNo;
     764         [ #  # ]:          0 :                 if ( aRBScrollingAuto.IsChecked() )
     765                 :          0 :                     eScroll = ScrollingAuto;
     766                 :            : 
     767                 :          0 :                 sal_Bool bHasBorder = aRBFrameBorderOn.IsChecked();
     768                 :            : 
     769                 :            :                 long lMarginWidth;
     770 [ #  # ][ #  # ]:          0 :                 if ( !aCBMarginWidthDefault.IsChecked() )
     771 [ #  # ][ #  # ]:          0 :                     lMarginWidth = (long) aNMMarginWidth.GetText().ToInt32();
                 [ #  # ]
     772                 :            :                 else
     773                 :          0 :                     lMarginWidth = SIZE_NOT_SET;
     774                 :            : 
     775                 :            :                 long lMarginHeight;
     776 [ #  # ][ #  # ]:          0 :                 if ( !aCBMarginHeightDefault.IsChecked() )
     777 [ #  # ][ #  # ]:          0 :                     lMarginHeight = (long) aNMMarginHeight.GetText().ToInt32();
                 [ #  # ]
     778                 :            :                 else
     779                 :          0 :                     lMarginHeight = SIZE_NOT_SET;
     780                 :            : 
     781 [ #  # ][ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameURL") ), makeAny( aURL ) );
         [ #  # ][ #  # ]
     782 [ #  # ][ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameName") ), makeAny( aName ) );
         [ #  # ][ #  # ]
     783                 :            : 
     784         [ #  # ]:          0 :                 if ( eScroll == ScrollingAuto )
     785         [ #  # ]:          0 :                     xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsAutoScroll") ),
     786 [ #  # ][ #  # ]:          0 :                         makeAny( sal_True ) );
                 [ #  # ]
     787                 :            :                 else
     788         [ #  # ]:          0 :                     xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsScrollingMode") ),
     789 [ #  # ][ #  # ]:          0 :                         makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
                 [ #  # ]
     790                 :            : 
     791         [ #  # ]:          0 :                     xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsBorder") ),
     792 [ #  # ][ #  # ]:          0 :                         makeAny( bHasBorder ) );
                 [ #  # ]
     793                 :            : 
     794         [ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameMarginWidth") ),
     795 [ #  # ][ #  # ]:          0 :                     makeAny( sal_Int32( lMarginWidth ) ) );
                 [ #  # ]
     796                 :            : 
     797         [ #  # ]:          0 :                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FrameMarginHeight") ),
     798 [ #  # ][ #  # ]:          0 :                     makeAny( sal_Int32( lMarginHeight ) ) );
                 [ #  # ]
     799                 :            : 
     800         [ #  # ]:          0 :                 if ( bIPActive )
     801 [ #  # ][ #  # ]:          0 :                     m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
                 [ #  # ]
     802                 :            :             }
     803         [ #  # ]:          0 :             catch ( uno::Exception& )
     804                 :            :             {
     805                 :            :                 OSL_FAIL( "No IFrame!" );
     806                 :            :             }
     807                 :          0 :         }
     808                 :            :     }
     809                 :            : 
     810                 :          0 :     return nRet;
     811                 :            : }
     812                 :            : 
     813                 :            : //------------------------------------------------------------------------------
     814                 :            : 
     815                 :          0 : IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, CheckHdl, CheckBox*, pCB )
     816                 :            : {
     817         [ #  # ]:          0 :     if ( pCB == &pThis->aCBMarginWidthDefault )
     818                 :            :     {
     819         [ #  # ]:          0 :         if ( pCB->IsChecked() )
     820         [ #  # ]:          0 :             pThis->aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH ) );
     821                 :          0 :         pThis->aFTMarginWidth.Enable( !pCB->IsChecked() );
     822                 :          0 :         pThis->aNMMarginWidth.Enable( !pCB->IsChecked() );
     823                 :            :     }
     824                 :            : 
     825         [ #  # ]:          0 :     if ( pCB == &pThis->aCBMarginHeightDefault )
     826                 :            :     {
     827         [ #  # ]:          0 :         if ( pCB->IsChecked() )
     828         [ #  # ]:          0 :             pThis->aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT ) );
     829                 :          0 :         pThis->aFTMarginHeight.Enable( !pCB->IsChecked() );
     830                 :          0 :         pThis->aNMMarginHeight.Enable( !pCB->IsChecked() );
     831                 :            :     }
     832                 :            : 
     833                 :          0 :     return 0L;
     834                 :            : }
     835                 :            : 
     836                 :            : //------------------------------------------------------------------------------
     837                 :            : 
     838                 :          0 : IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, OpenHdl, PushButton*, EMPTYARG )
     839                 :            : {
     840         [ #  # ]:          0 :     Window* pOldParent = Application::GetDefDialogParent();
     841         [ #  # ]:          0 :     Application::SetDefDialogParent( pThis );
     842                 :            : 
     843                 :            :     // create the file dialog
     844                 :            :     sfx2::FileDialogHelper aFileDlg(
     845 [ #  # ][ #  # ]:          0 :             ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0, String() );
                 [ #  # ]
     846                 :            : 
     847                 :            :     // set the title
     848 [ #  # ][ #  # ]:          0 :     aFileDlg.SetTitle( OUString( String( CUI_RES( MD_INSERT_OBJECT_IFRAME ) ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     849                 :            : 
     850                 :            :     // show the dialog
     851 [ #  # ][ #  # ]:          0 :     if ( aFileDlg.Execute() == ERRCODE_NONE )
     852                 :            :         pThis->aEDURL.SetText(
     853 [ #  # ][ #  # ]:          0 :             INetURLObject( aFileDlg.GetPath() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     854                 :            : 
     855         [ #  # ]:          0 :     Application::SetDefDialogParent( pOldParent );
     856         [ #  # ]:          0 :     return 0L;
     857                 :            : }
     858                 :            : 
     859                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10