LCOV - code coverage report
Current view: top level - sfx2/source/doc - guisaveas.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 754 0.0 %
Date: 2012-08-25 Functions: 0 44 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2330 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      21                 :            : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      22                 :            : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      23                 :            : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
      24                 :            : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      25                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      26                 :            : #include <com/sun/star/view/XSelectionSupplier.hpp>
      27                 :            : #include <com/sun/star/beans/XPropertyAccess.hpp>
      28                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      29                 :            : #include <com/sun/star/beans/XPropertyContainer.hpp>
      30                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31                 :            : #include <com/sun/star/document/XExporter.hpp>
      32                 :            : #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
      33                 :            : #include <com/sun/star/document/XDocumentInfo.hpp>
      34                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      35                 :            : #include <com/sun/star/util/DateTime.hpp>
      36                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      37                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      38                 :            : #include <com/sun/star/frame/XStorable.hpp>
      39                 :            : #include <com/sun/star/frame/XStorable2.hpp>
      40                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      41                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      42                 :            : #include <com/sun/star/frame/XTitle.hpp>
      43                 :            : #include <com/sun/star/util/XModifyListener.hpp>
      44                 :            : #include <com/sun/star/util/XModifiable.hpp>
      45                 :            : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      46                 :            : 
      47                 :            : #include <com/sun/star/util/XCloneable.hpp>
      48                 :            : #include <com/sun/star/frame/XModuleManager.hpp>
      49                 :            : #include <com/sun/star/io/IOException.hpp>
      50                 :            : 
      51                 :            : #include "guisaveas.hxx"
      52                 :            : 
      53                 :            : #include <unotools/pathoptions.hxx>
      54                 :            : #include <svl/itemset.hxx>
      55                 :            : #include <svl/eitem.hxx>
      56                 :            : #include <svl/stritem.hxx>
      57                 :            : #include <svl/intitem.hxx>
      58                 :            : #include <unotools/useroptions.hxx>
      59                 :            : #include <unotools/saveopt.hxx>
      60                 :            : #include <svtools/miscopt.hxx>
      61                 :            : #include <tools/debug.hxx>
      62                 :            : #include <tools/urlobj.hxx>
      63                 :            : #include <comphelper/componentcontext.hxx>
      64                 :            : #include <comphelper/processfactory.hxx>
      65                 :            : #include <comphelper/configurationhelper.hxx>
      66                 :            : #include <comphelper/mimeconfighelper.hxx>
      67                 :            : #include <vcl/msgbox.hxx>
      68                 :            : #include <vcl/window.hxx>
      69                 :            : #include <toolkit/awt/vclxwindow.hxx>
      70                 :            : 
      71                 :            : #include <sfx2/sfxsids.hrc>
      72                 :            : #include <doc.hrc>
      73                 :            : #include <sfx2/sfxresid.hxx>
      74                 :            : #include <sfx2/docfilt.hxx>
      75                 :            : #include <sfx2/filedlghelper.hxx>
      76                 :            : #include <sfx2/app.hxx>
      77                 :            : #include <sfx2/objsh.hxx>
      78                 :            : #include <sfx2/dinfdlg.hxx>
      79                 :            : #include <sfx2/request.hxx>
      80                 :            : #include <sfxtypes.hxx>
      81                 :            : #include "alienwarn.hxx"
      82                 :            : 
      83                 :            : #include "../appl/app.hrc"
      84                 :            : 
      85                 :            : // flags that specify requested operation
      86                 :            : #define EXPORT_REQUESTED            1
      87                 :            : #define PDFEXPORT_REQUESTED         2
      88                 :            : #define PDFDIRECTEXPORT_REQUESTED   4
      89                 :            : #define WIDEEXPORT_REQUESTED        8
      90                 :            : #define SAVE_REQUESTED              16
      91                 :            : #define SAVEAS_REQUESTED            32
      92                 :            : 
      93                 :            : // possible statuses of save operation
      94                 :            : #define STATUS_NO_ACTION            0
      95                 :            : #define STATUS_SAVE                 1
      96                 :            : #define STATUS_SAVEAS               2
      97                 :            : #define STATUS_SAVEAS_STANDARDNAME  3
      98                 :            : 
      99                 :            : const char aFilterNameString[] = "FilterName";
     100                 :            : const char aFilterOptionsString[] = "FilterOptions";
     101                 :            : const char aFilterDataString[] = "FilterData";
     102                 :            : const char aFilterFlagsString[] = "FilterFlags";
     103                 :            : 
     104                 :            : using namespace ::com::sun::star;
     105                 :            : 
     106                 :            : namespace {
     107                 :            : //-------------------------------------------------------------------------
     108                 :          0 : static sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode )
     109                 :            : {
     110                 :            :     // This is a temporary hardcoded solution must be removed when
     111                 :            :     // dialogs do not need parameters in SidSet representation any more
     112                 :            : 
     113                 :          0 :     sal_uInt16 nResult = 0;
     114         [ #  # ]:          0 :     if ( nStoreMode == EXPORT_REQUESTED )
     115                 :          0 :         nResult = SID_EXPORTDOC;
     116         [ #  # ]:          0 :     else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED ) )
     117                 :          0 :         nResult = SID_EXPORTDOCASPDF;
     118         [ #  # ]:          0 :     else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED | PDFDIRECTEXPORT_REQUESTED ) )
     119                 :          0 :         nResult = SID_DIRECTEXPORTDOCASPDF;
     120 [ #  # ][ #  # ]:          0 :     else if ( nStoreMode == SAVEAS_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | WIDEEXPORT_REQUESTED ) )
     121                 :          0 :         nResult = SID_SAVEASDOC;
     122                 :            :     else {
     123                 :            :         DBG_ASSERT( sal_False, "Unacceptable slot name is provided!\n" );
     124                 :            :     }
     125                 :            : 
     126                 :          0 :     return nResult;
     127                 :            : }
     128                 :            : 
     129                 :            : //-------------------------------------------------------------------------
     130                 :          0 : static sal_uInt8 getStoreModeFromSlotName( const ::rtl::OUString& aSlotName )
     131                 :            : {
     132                 :          0 :     sal_uInt8 nResult = 0;
     133         [ #  # ]:          0 :     if ( aSlotName == "ExportTo" )
     134                 :          0 :         nResult = EXPORT_REQUESTED;
     135         [ #  # ]:          0 :     else if ( aSlotName == "ExportToPDF" )
     136                 :          0 :         nResult = EXPORT_REQUESTED | PDFEXPORT_REQUESTED;
     137         [ #  # ]:          0 :     else if ( aSlotName == "ExportDirectToPDF" )
     138                 :          0 :         nResult = EXPORT_REQUESTED | PDFEXPORT_REQUESTED | PDFDIRECTEXPORT_REQUESTED;
     139         [ #  # ]:          0 :     else if ( aSlotName == "Save" )
     140                 :          0 :         nResult = SAVE_REQUESTED;
     141         [ #  # ]:          0 :     else if ( aSlotName == "SaveAs" )
     142                 :          0 :         nResult = SAVEAS_REQUESTED;
     143                 :            :     else
     144                 :            :         throw task::ErrorCodeIOException( ::rtl::OUString(),
     145                 :            :                                             uno::Reference< uno::XInterface >(),
     146         [ #  # ]:          0 :                                             ERRCODE_IO_INVALIDPARAMETER );
     147                 :            : 
     148                 :          0 :     return nResult;
     149                 :            : }
     150                 :            : 
     151                 :            : //-------------------------------------------------------------------------
     152                 :          0 : static sal_Int32 getMustFlags( sal_Int8 nStoreMode )
     153                 :            : {
     154                 :            :     return ( SFX_FILTER_EXPORT
     155 [ #  # ][ #  # ]:          0 :             | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? 0 : SFX_FILTER_IMPORT ) );
     156                 :            : }
     157                 :            : 
     158                 :            : //-------------------------------------------------------------------------
     159                 :          0 : static sal_Int32 getDontFlags( sal_Int8 nStoreMode )
     160                 :            : {
     161                 :            :     return ( SFX_FILTER_INTERNAL
     162                 :            :             | SFX_FILTER_NOTINFILEDLG
     163 [ #  # ][ #  # ]:          0 :             | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SFX_FILTER_IMPORT : 0 ) );
     164                 :            : }
     165                 :            : 
     166                 :            : //=========================================================================
     167                 :            : // class DocumentSettingsGuard
     168                 :            : //=========================================================================
     169                 :            : 
     170                 :            : class DocumentSettingsGuard
     171                 :            : {
     172                 :            :     uno::Reference< beans::XPropertySet > m_xDocumentSettings;
     173                 :            :     sal_Bool m_bPreserveReadOnly;
     174                 :            :     sal_Bool m_bReadOnlySupported;
     175                 :            : 
     176                 :            :     sal_Bool m_bRestoreSettings;
     177                 :            : public:
     178                 :          0 :     DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_Bool bRestore )
     179                 :            :     : m_bPreserveReadOnly( sal_False )
     180                 :            :     , m_bReadOnlySupported( sal_False )
     181                 :          0 :     , m_bRestoreSettings( bRestore )
     182                 :            :     {
     183                 :            :         try
     184                 :            :         {
     185         [ #  # ]:          0 :             uno::Reference< lang::XMultiServiceFactory > xDocSettingsSupplier( xModel, uno::UNO_QUERY_THROW );
     186                 :            :             m_xDocumentSettings.set(
     187         [ #  # ]:          0 :                 xDocSettingsSupplier->createInstance(
     188                 :          0 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ),
     189 [ #  # ][ #  # ]:          0 :                 uno::UNO_QUERY_THROW );
                 [ #  # ]
     190                 :            : 
     191         [ #  # ]:          0 :             ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) );
     192                 :            : 
     193                 :            :             try
     194                 :            :             {
     195 [ #  # ][ #  # ]:          0 :                 m_xDocumentSettings->getPropertyValue( aLoadReadonlyString ) >>= m_bPreserveReadOnly;
     196 [ #  # ][ #  # ]:          0 :                 m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( bReadOnly ) );
         [ #  # ][ #  # ]
     197                 :          0 :                 m_bReadOnlySupported = sal_True;
     198                 :            :             }
     199         [ #  # ]:          0 :             catch( const uno::Exception& )
     200         [ #  # ]:          0 :             {}
     201                 :            :         }
     202         [ #  # ]:          0 :         catch( const uno::Exception& )
     203                 :            :         {}
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 :         if ( ( bReadOnly && !m_bReadOnlySupported ) )
     206         [ #  # ]:          0 :             throw uno::RuntimeException(); // the user could provide the data, so it must be stored
     207                 :          0 :     }
     208                 :            : 
     209                 :          0 :     ~DocumentSettingsGuard()
     210                 :          0 :     {
     211         [ #  # ]:          0 :         if ( m_bRestoreSettings )
     212                 :            :         {
     213         [ #  # ]:          0 :             ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) );
     214                 :            : 
     215                 :            :             try
     216                 :            :             {
     217         [ #  # ]:          0 :                 if ( m_bReadOnlySupported )
     218 [ #  # ][ #  # ]:          0 :                     m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( m_bPreserveReadOnly ) );
         [ #  # ][ #  # ]
     219                 :            :             }
     220         [ #  # ]:          0 :             catch( const uno::Exception& )
     221                 :            :             {
     222                 :            :                 OSL_FAIL( "Unexpected exception!" );
     223                 :          0 :             }
     224                 :            :         }
     225                 :          0 :     }
     226                 :            : };
     227                 :            : } // anonymous namespace
     228                 :            : 
     229                 :            : //=========================================================================
     230                 :            : // class ModelData_Impl
     231                 :            : //=========================================================================
     232                 :            : class ModelData_Impl
     233                 :            : {
     234                 :            :     SfxStoringHelper* m_pOwner;
     235                 :            :     uno::Reference< frame::XModel > m_xModel;
     236                 :            :     uno::Reference< frame::XStorable > m_xStorable;
     237                 :            :     uno::Reference< frame::XStorable2 > m_xStorable2;
     238                 :            :     uno::Reference< util::XModifiable > m_xModifiable;
     239                 :            : 
     240                 :            :     ::rtl::OUString m_aModuleName;
     241                 :            :     ::comphelper::SequenceAsHashMap* m_pDocumentPropsHM;
     242                 :            :     ::comphelper::SequenceAsHashMap* m_pModulePropsHM;
     243                 :            : 
     244                 :            :     ::comphelper::SequenceAsHashMap m_aMediaDescrHM;
     245                 :            : 
     246                 :            :     sal_Bool m_bRecommendReadOnly;
     247                 :            : 
     248                 :            : public:
     249                 :            :     ModelData_Impl( SfxStoringHelper& aOwner,
     250                 :            :                     const uno::Reference< frame::XModel >& xModel,
     251                 :            :                     const uno::Sequence< beans::PropertyValue >& aMediaDescr );
     252                 :            : 
     253                 :            :     ~ModelData_Impl();
     254                 :            : 
     255                 :            :     void FreeDocumentProps();
     256                 :            : 
     257                 :            :     uno::Reference< frame::XModel > GetModel();
     258                 :            :     uno::Reference< frame::XStorable > GetStorable();
     259                 :            :     uno::Reference< frame::XStorable2 > GetStorable2();
     260                 :            :     uno::Reference< util::XModifiable > GetModifiable();
     261                 :            : 
     262                 :          0 :     ::comphelper::SequenceAsHashMap& GetMediaDescr() { return m_aMediaDescrHM; }
     263                 :            : 
     264                 :          0 :     sal_Bool IsRecommendReadOnly() const { return m_bRecommendReadOnly; }
     265                 :            : 
     266                 :            :     const ::comphelper::SequenceAsHashMap& GetDocProps();
     267                 :            : 
     268                 :            :     ::rtl::OUString GetModuleName();
     269                 :            :     const ::comphelper::SequenceAsHashMap& GetModuleProps();
     270                 :            : 
     271                 :            :     void CheckInteractionHandler();
     272                 :            : 
     273                 :            : 
     274                 :            :     ::rtl::OUString GetDocServiceName();
     275                 :            :     uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilterCheckFlags( sal_Int32 nMust, sal_Int32 nDont );
     276                 :            :     uno::Sequence< beans::PropertyValue > GetDocServiceAnyFilter( sal_Int32 nMust, sal_Int32 nDont );
     277                 :            :     uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl( sal_Int8 nStoreMode );
     278                 :            :     uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilter();
     279                 :            : 
     280                 :            :     sal_Bool ExecuteFilterDialog_Impl( const ::rtl::OUString& aFilterName );
     281                 :            : 
     282                 :            :     sal_Int8 CheckSaveAcceptable( sal_Int8 nCurStatus );
     283                 :            :     sal_Int8 CheckStateForSave();
     284                 :            : 
     285                 :            :     sal_Int8 CheckFilter( const ::rtl::OUString& );
     286                 :            : 
     287                 :            :     sal_Bool CheckFilterOptionsDialogExistence();
     288                 :            : 
     289                 :            :     sal_Bool OutputFileDialog( sal_Int8 nStoreMode,
     290                 :            :                                 const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
     291                 :            :                                 sal_Bool bSetStandardName,
     292                 :            :                                 ::rtl::OUString& aSuggestedName,
     293                 :            :                                 sal_Bool bPreselectPassword,
     294                 :            :                                 ::rtl::OUString& aSuggestedDir,
     295                 :            :                                 sal_Int16 nDialog,
     296                 :            :                                 const ::rtl::OUString& rStandardDir,
     297                 :            :                                 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList
     298                 :            :                                 );
     299                 :            : 
     300                 :            :     sal_Bool ShowDocumentInfoDialog();
     301                 :            : 
     302                 :            :     ::rtl::OUString GetReccomendedDir( const ::rtl::OUString& aSuggestedDir );
     303                 :            :     ::rtl::OUString GetReccomendedName( const ::rtl::OUString& aSuggestedName,
     304                 :            :                                         const ::rtl::OUString& aTypeName );
     305                 :            : 
     306                 :            : };
     307                 :            : 
     308                 :            : //-------------------------------------------------------------------------
     309                 :          0 : ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner,
     310                 :            :                                 const uno::Reference< frame::XModel >& xModel,
     311                 :            :                                 const uno::Sequence< beans::PropertyValue >& aMediaDescr )
     312                 :            : : m_pOwner( &aOwner )
     313                 :            : , m_xModel( xModel )
     314                 :            : , m_pDocumentPropsHM( NULL )
     315                 :            : , m_pModulePropsHM( NULL )
     316                 :            : , m_aMediaDescrHM( aMediaDescr )
     317         [ #  # ]:          0 : , m_bRecommendReadOnly( sal_False )
     318                 :            : {
     319         [ #  # ]:          0 :     CheckInteractionHandler();
     320                 :          0 : }
     321                 :            : 
     322                 :            : //-------------------------------------------------------------------------
     323         [ #  # ]:          0 : ModelData_Impl::~ModelData_Impl()
     324                 :            : {
     325         [ #  # ]:          0 :     FreeDocumentProps();
     326         [ #  # ]:          0 :     if ( m_pDocumentPropsHM )
     327 [ #  # ][ #  # ]:          0 :         delete m_pDocumentPropsHM;
     328                 :            : 
     329         [ #  # ]:          0 :     if ( m_pModulePropsHM )
     330 [ #  # ][ #  # ]:          0 :         delete m_pModulePropsHM;
     331                 :          0 : }
     332                 :            : 
     333                 :            : //-------------------------------------------------------------------------
     334                 :          0 : void ModelData_Impl::FreeDocumentProps()
     335                 :            : {
     336         [ #  # ]:          0 :     if ( m_pDocumentPropsHM )
     337                 :            :     {
     338         [ #  # ]:          0 :         delete m_pDocumentPropsHM;
     339                 :          0 :         m_pDocumentPropsHM = NULL;
     340                 :            :     }
     341                 :          0 : }
     342                 :            : 
     343                 :            : //-------------------------------------------------------------------------
     344                 :          0 : uno::Reference< frame::XModel > ModelData_Impl::GetModel()
     345                 :            : {
     346         [ #  # ]:          0 :     if ( !m_xModel.is() )
     347         [ #  # ]:          0 :         throw uno::RuntimeException();
     348                 :            : 
     349                 :          0 :     return m_xModel;
     350                 :            : }
     351                 :            : 
     352                 :            : //-------------------------------------------------------------------------
     353                 :          0 : uno::Reference< frame::XStorable > ModelData_Impl::GetStorable()
     354                 :            : {
     355         [ #  # ]:          0 :     if ( !m_xStorable.is() )
     356                 :            :     {
     357         [ #  # ]:          0 :         m_xStorable = uno::Reference< frame::XStorable >( m_xModel, uno::UNO_QUERY );
     358         [ #  # ]:          0 :         if ( !m_xStorable.is() )
     359         [ #  # ]:          0 :             throw uno::RuntimeException();
     360                 :            :     }
     361                 :            : 
     362                 :          0 :     return m_xStorable;
     363                 :            : }
     364                 :            : 
     365                 :            : //-------------------------------------------------------------------------
     366                 :          0 : uno::Reference< frame::XStorable2 > ModelData_Impl::GetStorable2()
     367                 :            : {
     368         [ #  # ]:          0 :     if ( !m_xStorable2.is() )
     369                 :            :     {
     370         [ #  # ]:          0 :         m_xStorable2 = uno::Reference< frame::XStorable2 >( m_xModel, uno::UNO_QUERY );
     371         [ #  # ]:          0 :         if ( !m_xStorable2.is() )
     372         [ #  # ]:          0 :             throw uno::RuntimeException();
     373                 :            :     }
     374                 :            : 
     375                 :          0 :     return m_xStorable2;
     376                 :            : }
     377                 :            : 
     378                 :            : //-------------------------------------------------------------------------
     379                 :          0 : uno::Reference< util::XModifiable > ModelData_Impl::GetModifiable()
     380                 :            : {
     381         [ #  # ]:          0 :     if ( !m_xModifiable.is() )
     382                 :            :     {
     383         [ #  # ]:          0 :         m_xModifiable = uno::Reference< util::XModifiable >( m_xModel, uno::UNO_QUERY );
     384         [ #  # ]:          0 :         if ( !m_xModifiable.is() )
     385         [ #  # ]:          0 :             throw uno::RuntimeException();
     386                 :            :     }
     387                 :            : 
     388                 :          0 :     return m_xModifiable;
     389                 :            : }
     390                 :            : 
     391                 :            : //-------------------------------------------------------------------------
     392                 :          0 : const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetDocProps()
     393                 :            : {
     394         [ #  # ]:          0 :     if ( !m_pDocumentPropsHM )
     395 [ #  # ][ #  # ]:          0 :         m_pDocumentPropsHM = new ::comphelper::SequenceAsHashMap( GetModel()->getArgs() );
         [ #  # ][ #  # ]
                 [ #  # ]
     396                 :            : 
     397                 :          0 :     return *m_pDocumentPropsHM;
     398                 :            : }
     399                 :            : 
     400                 :            : //-------------------------------------------------------------------------
     401                 :          0 : ::rtl::OUString ModelData_Impl::GetModuleName()
     402                 :            : {
     403         [ #  # ]:          0 :     if ( m_aModuleName.isEmpty() )
     404                 :            :     {
     405         [ #  # ]:          0 :         m_aModuleName = m_pOwner->GetModuleManager()->identify(
     406 [ #  # ][ #  # ]:          0 :                                                 uno::Reference< uno::XInterface >( m_xModel, uno::UNO_QUERY ) );
     407         [ #  # ]:          0 :         if ( m_aModuleName.isEmpty() )
     408         [ #  # ]:          0 :             throw uno::RuntimeException(); // TODO:
     409                 :            :     }
     410                 :          0 :     return m_aModuleName;
     411                 :            : }
     412                 :            : 
     413                 :            : //-------------------------------------------------------------------------
     414                 :          0 : const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetModuleProps()
     415                 :            : {
     416         [ #  # ]:          0 :     if ( !m_pModulePropsHM )
     417                 :            :     {
     418         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > aModuleProps;
     419 [ #  # ][ #  # ]:          0 :         m_pOwner->GetNamedModuleManager()->getByName( GetModuleName() ) >>= aModuleProps;
         [ #  # ][ #  # ]
                 [ #  # ]
     420         [ #  # ]:          0 :         if ( !aModuleProps.getLength() )
     421         [ #  # ]:          0 :             throw uno::RuntimeException(); // TODO;
     422 [ #  # ][ #  # ]:          0 :         m_pModulePropsHM = new ::comphelper::SequenceAsHashMap( aModuleProps );
                 [ #  # ]
     423                 :            :     }
     424                 :            : 
     425                 :          0 :     return *m_pModulePropsHM;
     426                 :            : }
     427                 :            : 
     428                 :            : //-------------------------------------------------------------------------
     429                 :          0 : ::rtl::OUString ModelData_Impl::GetDocServiceName()
     430                 :            : {
     431 [ #  # ][ #  # ]:          0 :     return GetModuleProps().getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryDocumentService")), ::rtl::OUString());
                 [ #  # ]
     432                 :            : }
     433                 :            : 
     434                 :            : //-------------------------------------------------------------------------
     435                 :          0 : void ModelData_Impl::CheckInteractionHandler()
     436                 :            : {
     437                 :            :     ::comphelper::SequenceAsHashMap::const_iterator aInteractIter =
     438 [ #  # ][ #  # ]:          0 :             m_aMediaDescrHM.find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) );
     439                 :            : 
     440 [ #  # ][ #  # ]:          0 :     if ( aInteractIter == m_aMediaDescrHM.end() )
     441                 :            :     {
     442                 :            :         try {
     443 [ #  # ][ #  # ]:          0 :             m_aMediaDescrHM[ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) ]
     444                 :            :                 <<= uno::Reference< task::XInteractionHandler >(
     445 [ #  # ][ #  # ]:          0 :                             m_pOwner->GetServiceFactory()->createInstance(
                 [ #  # ]
     446                 :          0 :                                             DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
     447 [ #  # ][ #  # ]:          0 :                             uno::UNO_QUERY );
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     448                 :            :         }
     449         [ #  # ]:          0 :         catch( const uno::Exception& )
     450                 :            :         {
     451                 :            :         }
     452                 :            :     }
     453                 :            :     else
     454                 :            :     {
     455                 :          0 :         uno::Reference< task::XInteractionHandler > xInteract;
     456                 :          0 :         DBG_ASSERT( ( aInteractIter->second >>= xInteract ) && xInteract.is(), "Broken interaction handler is provided!\n" );
     457                 :            :     }
     458                 :          0 : }
     459                 :            : 
     460                 :            : //-------------------------------------------------------------------------
     461                 :          0 : uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceDefaultFilter()
     462                 :            : {
     463         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aProps;
     464                 :            : 
     465         [ #  # ]:          0 :     ::rtl::OUString aFilterName = GetModuleProps().getUnpackedValueOrDefault(
     466                 :            :                                                                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryDefaultFilter")),
     467 [ #  # ][ #  # ]:          0 :                                                                 ::rtl::OUString() );
     468                 :            : 
     469 [ #  # ][ #  # ]:          0 :     m_pOwner->GetFilterConfiguration()->getByName( aFilterName ) >>= aProps;
         [ #  # ][ #  # ]
     470                 :            : 
     471                 :          0 :     return aProps;
     472                 :            : }
     473                 :            : 
     474                 :            : //-------------------------------------------------------------------------
     475                 :          0 : uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceDefaultFilterCheckFlags( sal_Int32 nMust,
     476                 :            :                                                                                                 sal_Int32 nDont )
     477                 :            : {
     478         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aFilterProps;
     479         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aProps = GetDocServiceDefaultFilter();
     480         [ #  # ]:          0 :     if ( aProps.getLength() )
     481                 :            :     {
     482         [ #  # ]:          0 :         ::comphelper::SequenceAsHashMap aFiltHM( aProps );
     483                 :            :         sal_Int32 nFlags = aFiltHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")),
     484 [ #  # ][ #  # ]:          0 :                                                         (sal_Int32)0 );
     485 [ #  # ][ #  # ]:          0 :         if ( ( ( nFlags & nMust ) == nMust ) && !( nFlags & nDont ) )
     486 [ #  # ][ #  # ]:          0 :             aFilterProps = aProps;
     487                 :            :     }
     488                 :            : 
     489         [ #  # ]:          0 :     return aFilterProps;
     490                 :            : }
     491                 :            : 
     492                 :            : 
     493                 :            : //-------------------------------------------------------------------------
     494                 :          0 : uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceAnyFilter( sal_Int32 nMust, sal_Int32 nDont )
     495                 :            : {
     496         [ #  # ]:          0 :     uno::Sequence< beans::NamedValue > aSearchRequest( 1 );
     497 [ #  # ][ #  # ]:          0 :     aSearchRequest[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService"));
     498 [ #  # ][ #  # ]:          0 :     aSearchRequest[0].Value <<= GetDocServiceName();
                 [ #  # ]
     499                 :            : 
     500 [ #  # ][ #  # ]:          0 :     return ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
                 [ #  # ]
     501                 :            : }
     502                 :            : 
     503                 :            : //-------------------------------------------------------------------------
     504                 :          0 : uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl( sal_Int8 nStoreMode )
     505                 :            : {
     506                 :          0 :     uno::Sequence< beans::PropertyValue > aFilterProps;
     507                 :            : 
     508                 :          0 :     sal_Int32 nMust = getMustFlags( nStoreMode );
     509                 :          0 :     sal_Int32 nDont = getDontFlags( nStoreMode );
     510                 :            : 
     511         [ #  # ]:          0 :     if ( nStoreMode & PDFEXPORT_REQUESTED )
     512                 :            :     {
     513                 :            :         // Preselect PDF-Filter for EXPORT
     514         [ #  # ]:          0 :         uno::Sequence< beans::NamedValue > aSearchRequest( 2 );
     515 [ #  # ][ #  # ]:          0 :         aSearchRequest[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type"));
     516 [ #  # ][ #  # ]:          0 :         aSearchRequest[0].Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pdf_Portable_Document_Format"));
                 [ #  # ]
     517 [ #  # ][ #  # ]:          0 :         aSearchRequest[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService"));
     518 [ #  # ][ #  # ]:          0 :         aSearchRequest[1].Value <<= GetDocServiceName();
                 [ #  # ]
     519                 :            : 
     520 [ #  # ][ #  # ]:          0 :         aFilterProps = ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
         [ #  # ][ #  # ]
                 [ #  # ]
     521                 :            :     }
     522                 :            :     else
     523                 :            :     {
     524 [ #  # ][ #  # ]:          0 :         aFilterProps = GetDocServiceDefaultFilterCheckFlags( nMust, nDont );
                 [ #  # ]
     525                 :            : 
     526         [ #  # ]:          0 :         if ( !aFilterProps.getLength() )
     527                 :            :         {
     528                 :            :             // the default filter was not faund, use just the first acceptable one
     529 [ #  # ][ #  # ]:          0 :             aFilterProps = GetDocServiceAnyFilter( nMust, nDont );
                 [ #  # ]
     530                 :            :         }
     531                 :            :     }
     532                 :            : 
     533                 :          0 :     return aFilterProps;
     534                 :            : }
     535                 :            : 
     536                 :            : //-------------------------------------------------------------------------
     537                 :          0 : sal_Bool ModelData_Impl::ExecuteFilterDialog_Impl( const ::rtl::OUString& aFilterName )
     538                 :            : {
     539                 :          0 :     sal_Bool bDialogUsed = sal_False;
     540                 :            : 
     541                 :            :     try {
     542         [ #  # ]:          0 :         uno::Sequence < beans::PropertyValue > aProps;
     543 [ #  # ][ #  # ]:          0 :           uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( aFilterName );
                 [ #  # ]
     544 [ #  # ][ #  # ]:          0 :            if ( aAny >>= aProps )
     545                 :            :            {
     546                 :          0 :                sal_Int32 nPropertyCount = aProps.getLength();
     547         [ #  # ]:          0 :                for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
     548 [ #  # ][ #  # ]:          0 :                    if( aProps[nProperty].Name == "UIComponent" )
     549                 :            :                    {
     550                 :          0 :                     ::rtl::OUString aServiceName;
     551         [ #  # ]:          0 :                        aProps[nProperty].Value >>= aServiceName;
     552         [ #  # ]:          0 :                     if( !aServiceName.isEmpty() )
     553                 :            :                     {
     554                 :            :                         uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog(
     555 [ #  # ][ #  # ]:          0 :                                                     m_pOwner->GetServiceFactory()->createInstance( aServiceName ), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     556         [ #  # ]:          0 :                         uno::Reference< beans::XPropertyAccess > xFilterProperties( xFilterDialog, uno::UNO_QUERY );
     557                 :            : 
     558 [ #  # ][ #  # ]:          0 :                         if( xFilterDialog.is() && xFilterProperties.is() )
                 [ #  # ]
     559                 :            :                         {
     560                 :          0 :                             bDialogUsed = sal_True;
     561                 :            : 
     562         [ #  # ]:          0 :                             uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY );
     563         [ #  # ]:          0 :                             if( xExporter.is() )
     564         [ #  # ]:          0 :                                 xExporter->setSourceDocument(
     565 [ #  # ][ #  # ]:          0 :                                     uno::Reference< lang::XComponent >( GetModel(), uno::UNO_QUERY ) );
                 [ #  # ]
     566                 :            : 
     567         [ #  # ]:          0 :                             uno::Sequence< beans::PropertyValue > aPropsForDialog;
     568         [ #  # ]:          0 :                             GetMediaDescr() >> aPropsForDialog;
     569 [ #  # ][ #  # ]:          0 :                             xFilterProperties->setPropertyValues( aPropsForDialog );
     570                 :            : 
     571 [ #  # ][ #  # ]:          0 :                             if( xFilterDialog->execute() )
                 [ #  # ]
     572                 :            :                             {
     573                 :            :                                 uno::Sequence< beans::PropertyValue > aPropsFromDialog =
     574 [ #  # ][ #  # ]:          0 :                                                                             xFilterProperties->getPropertyValues();
     575         [ #  # ]:          0 :                                 for ( sal_Int32 nInd = 0; nInd < aPropsFromDialog.getLength(); nInd++ )
     576 [ #  # ][ #  # ]:          0 :                                     GetMediaDescr()[aPropsFromDialog[nInd].Name] = aPropsFromDialog[nInd].Value;
         [ #  # ][ #  # ]
     577                 :            :                             }
     578                 :            :                             else
     579                 :            :                             {
     580                 :            :                                 throw task::ErrorCodeIOException( ::rtl::OUString(),
     581                 :            :                                                                     uno::Reference< uno::XInterface >(),
     582         [ #  # ]:          0 :                                                                     ERRCODE_IO_ABORT );
     583         [ #  # ]:          0 :                             }
     584                 :          0 :                         }
     585                 :            :                     }
     586                 :            : 
     587                 :          0 :                     break;
     588                 :            :                 }
     589         [ #  # ]:          0 :         }
     590                 :            :     }
     591                 :          0 :     catch( const container::NoSuchElementException& )
     592                 :            :     {
     593                 :            :         // the filter name is unknown
     594                 :            :         throw task::ErrorCodeIOException( ::rtl::OUString(),
     595                 :            :                                             uno::Reference< uno::XInterface >(),
     596         [ #  # ]:          0 :                                             ERRCODE_IO_INVALIDPARAMETER );
     597                 :            :     }
     598   [ #  #  #  # ]:          0 :     catch( const task::ErrorCodeIOException& )
     599                 :            :     {
     600                 :          0 :         throw;
     601                 :            :     }
     602                 :          0 :     catch( const uno::Exception& )
     603                 :            :     {
     604                 :            :     }
     605                 :            : 
     606                 :          0 :     return bDialogUsed;
     607                 :            : }
     608                 :            : 
     609                 :            : //-------------------------------------------------------------------------
     610                 :          0 : sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus )
     611                 :            : {
     612                 :          0 :     sal_Int8 nResult = nCurStatus;
     613                 :            : 
     614 [ #  # ][ #  # ]:          0 :     if ( nResult != STATUS_NO_ACTION && GetStorable()->hasLocation() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     615                 :            :     {
     616                 :            :         // check whether save is acceptable by the configuration
     617                 :            :         // it is done only for documents that have persistence already
     618                 :            :         uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
     619                 :            :                             m_pOwner->GetServiceFactory(),
     620                 :            :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
     621 [ #  # ][ #  # ]:          0 :                             ::comphelper::ConfigurationHelper::E_STANDARD );
                 [ #  # ]
     622         [ #  # ]:          0 :         if ( !xCommonConfig.is() )
     623         [ #  # ]:          0 :             throw uno::RuntimeException(); // should the saving proceed as usual instead?
     624                 :            : 
     625                 :            :         try
     626                 :            :         {
     627                 :          0 :             sal_Bool bAlwaysSaveAs = sal_False;
     628                 :            : 
     629                 :            :             // the saving is acceptable
     630                 :            :             // in case the configuration entry is not set or set to false
     631                 :            :             // or in case of version creation
     632         [ #  # ]:          0 :             ::rtl::OUString aVersionCommentString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VersionComment"));
     633   [ #  #  #  # ]:          0 :             if ( ( ::comphelper::ConfigurationHelper::readRelativeKey(
         [ #  # ][ #  # ]
     634                 :            :                     xCommonConfig,
     635                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Save/Document/" ) ),
     636 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AlwaysSaveAs" ) ) ) >>= bAlwaysSaveAs )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     637                 :            :               && bAlwaysSaveAs
     638 [ #  # ][ #  # ]:          0 :             && GetMediaDescr().find( aVersionCommentString ) == GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     639                 :            :             {
     640                 :            :                 // notify the user that SaveAs is going to be done
     641         [ #  # ]:          0 :                 Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel );
     642 [ #  # ][ #  # ]:          0 :                 QueryBox aMessageBox( pWin, WB_OK_CANCEL | WB_DEF_OK, SfxResId(STR_NEW_FILENAME_SAVE).toString() );
         [ #  # ][ #  # ]
                 [ #  # ]
     643 [ #  # ][ #  # ]:          0 :                 if ( aMessageBox.Execute() == RET_OK )
     644                 :          0 :                     nResult = STATUS_SAVEAS;
     645                 :            :                 else
     646         [ #  # ]:          0 :                     nResult = STATUS_NO_ACTION;
     647         [ #  # ]:          0 :             }
     648                 :            :         }
     649         [ #  # ]:          0 :         catch( const uno::Exception& )
     650                 :            :         {
     651                 :            :             // impossibility to get the configuration access means normal saving flow for now
     652                 :          0 :         }
     653                 :            :     }
     654                 :            : 
     655                 :          0 :     return nResult;
     656                 :            : }
     657                 :            : 
     658                 :            : //-------------------------------------------------------------------------
     659                 :          0 : sal_Int8 ModelData_Impl::CheckStateForSave()
     660                 :            : {
     661                 :            :     // if the document is readonly or a new one a SaveAs operation must be used
     662 [ #  # ][ #  # ]:          0 :     if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
     663                 :          0 :         return STATUS_SAVEAS;
     664                 :            : 
     665                 :            :     // check acceptable entries for media descriptor
     666                 :          0 :     sal_Bool bVersInfoNeedsStore = sal_False;
     667         [ #  # ]:          0 :     ::comphelper::SequenceAsHashMap aAcceptedArgs;
     668                 :            : 
     669                 :          0 :     ::rtl::OUString aVersionCommentString("VersionComment");
     670                 :          0 :     ::rtl::OUString aAuthorString("Author");
     671                 :          0 :     ::rtl::OUString aInteractionHandlerString("InteractionHandler");
     672                 :          0 :     ::rtl::OUString aStatusIndicatorString("StatusIndicator");
     673                 :          0 :         ::rtl::OUString aFailOnWarningString("FailOnWarning");
     674                 :            : 
     675 [ #  # ][ #  # ]:          0 :     if ( GetMediaDescr().find( aVersionCommentString ) != GetMediaDescr().end() )
                 [ #  # ]
     676                 :            :     {
     677                 :          0 :         bVersInfoNeedsStore = sal_True;
     678 [ #  # ][ #  # ]:          0 :         aAcceptedArgs[ aVersionCommentString ] = GetMediaDescr()[ aVersionCommentString ];
     679                 :            :     }
     680 [ #  # ][ #  # ]:          0 :     if ( GetMediaDescr().find( aAuthorString ) != GetMediaDescr().end() )
                 [ #  # ]
     681 [ #  # ][ #  # ]:          0 :         aAcceptedArgs[ aAuthorString ] = GetMediaDescr()[ aAuthorString ];
     682 [ #  # ][ #  # ]:          0 :     if ( GetMediaDescr().find( aInteractionHandlerString ) != GetMediaDescr().end() )
                 [ #  # ]
     683 [ #  # ][ #  # ]:          0 :         aAcceptedArgs[ aInteractionHandlerString ] = GetMediaDescr()[ aInteractionHandlerString ];
     684 [ #  # ][ #  # ]:          0 :     if ( GetMediaDescr().find( aStatusIndicatorString ) != GetMediaDescr().end() )
                 [ #  # ]
     685 [ #  # ][ #  # ]:          0 :         aAcceptedArgs[ aStatusIndicatorString ] = GetMediaDescr()[ aStatusIndicatorString ];
     686 [ #  # ][ #  # ]:          0 :         if ( GetMediaDescr().find( aFailOnWarningString ) != GetMediaDescr().end() )
                 [ #  # ]
     687 [ #  # ][ #  # ]:          0 :                 aAcceptedArgs[ aFailOnWarningString ] = GetMediaDescr()[ aFailOnWarningString ];
     688                 :            : 
     689                 :            :     // remove unacceptable entry if there is any
     690                 :            :     DBG_ASSERT( GetMediaDescr().size() == aAcceptedArgs.size(),
     691                 :            :                 "Unacceptable parameters are provided in Save request!\n" );
     692         [ #  # ]:          0 :     if ( GetMediaDescr().size() != aAcceptedArgs.size() )
     693         [ #  # ]:          0 :         GetMediaDescr() = aAcceptedArgs;
     694                 :            : 
     695                 :            :     // the document must be modified unless the always-save flag is set.
     696         [ #  # ]:          0 :     SvtMiscOptions aMiscOptions;
     697         [ #  # ]:          0 :     sal_Bool bAlwaysAllowSave = aMiscOptions.IsSaveAlwaysAllowed();
     698         [ #  # ]:          0 :     if (!bAlwaysAllowSave)
     699                 :            :     {
     700 [ #  # ][ #  # ]:          0 :         if ( !GetModifiable()->isModified() && !bVersInfoNeedsStore )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     701                 :          0 :             return STATUS_NO_ACTION;
     702                 :            :     }
     703                 :            : 
     704                 :            :     // check that the old filter is acceptable
     705         [ #  # ]:          0 :     ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
     706                 :            :                                                     rtl::OUString(aFilterNameString),
     707         [ #  # ]:          0 :                                                     ::rtl::OUString() );
     708         [ #  # ]:          0 :     sal_Int8 nResult = CheckFilter( aOldFilterName );
     709                 :            : 
     710 [ #  # ][ #  # ]:          0 :     return nResult;
     711                 :            : }
     712                 :            : 
     713                 :          0 : sal_Int8 ModelData_Impl::CheckFilter( const ::rtl::OUString& aFilterName )
     714                 :            : {
     715         [ #  # ]:          0 :     ::comphelper::SequenceAsHashMap aFiltPropsHM;
     716                 :          0 :     sal_Int32 nFiltFlags = 0;
     717         [ #  # ]:          0 :     if ( !aFilterName.isEmpty() )
     718                 :            :     {
     719                 :            :         // get properties of filter
     720         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > aFilterProps;
     721         [ #  # ]:          0 :         if ( !aFilterName.isEmpty() )
     722 [ #  # ][ #  # ]:          0 :             m_pOwner->GetFilterConfiguration()->getByName( aFilterName ) >>= aFilterProps;
         [ #  # ][ #  # ]
     723                 :            : 
     724 [ #  # ][ #  # ]:          0 :         aFiltPropsHM = ::comphelper::SequenceAsHashMap( aFilterProps );
                 [ #  # ]
     725 [ #  # ][ #  # ]:          0 :         nFiltFlags = aFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 );
                 [ #  # ]
     726                 :            :     }
     727                 :            : 
     728                 :            :     // only a temporary solution until default filter retrieving feature is implemented
     729                 :            :     // then GetDocServiceDefaultFilter() must be used
     730 [ #  # ][ #  # ]:          0 :     ::comphelper::SequenceAsHashMap aDefFiltPropsHM = GetDocServiceDefaultFilterCheckFlags( 3, 0 );
                 [ #  # ]
     731 [ #  # ][ #  # ]:          0 :     sal_Int32 nDefFiltFlags = aDefFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 );
     732                 :            : 
     733                 :            :     // if the old filter is not acceptable
     734                 :            :     // and there is no default filter or it is not acceptable for requested parameters then proceed with saveAs
     735   [ #  #  #  # ]:          0 :     if ( ( !aFiltPropsHM.size() || !( nFiltFlags & SFX_FILTER_EXPORT ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     736                 :          0 :       && ( !aDefFiltPropsHM.size() || !( nDefFiltFlags & SFX_FILTER_EXPORT ) || nDefFiltFlags & SFX_FILTER_INTERNAL ) )
     737                 :          0 :         return STATUS_SAVEAS;
     738                 :            : 
     739                 :            :     // so at this point there is either an acceptable old filter or default one
     740 [ #  # ][ #  # ]:          0 :     if ( !aFiltPropsHM.size() || !( nFiltFlags & SFX_FILTER_EXPORT ) )
                 [ #  # ]
     741                 :            :     {
     742                 :            :         // so the default filter must be acceptable
     743                 :          0 :         return STATUS_SAVEAS_STANDARDNAME;
     744                 :            :     }
     745         [ #  # ]:          0 :     else if ( ( !( nFiltFlags & SFX_FILTER_OWN ) || ( nFiltFlags & SFX_FILTER_ALIEN ) )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     746                 :          0 :            && aDefFiltPropsHM.size()
     747                 :          0 :            && ( nDefFiltFlags & SFX_FILTER_EXPORT ) && !( nDefFiltFlags & SFX_FILTER_INTERNAL ))
     748                 :            :     {
     749                 :            :         // the default filter is acceptable and the old filter is alian one
     750                 :            :         // so ask to make a saveAs operation
     751                 :            :         ::rtl::OUString aUIName = aFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     752 [ #  # ][ #  # ]:          0 :                                                                                 ::rtl::OUString() );
     753                 :            :         ::rtl::OUString aDefUIName = aDefFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     754 [ #  # ][ #  # ]:          0 :                                                                                 ::rtl::OUString() );
     755         [ #  # ]:          0 :         ::rtl::OUString aPreusedFilterName = GetDocProps().getUnpackedValueOrDefault(
     756                 :            :                                                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PreusedFilterName")),
     757 [ #  # ][ #  # ]:          0 :                                                     ::rtl::OUString() );
     758 [ #  # ][ #  # ]:          0 :         if ( !aPreusedFilterName.equals( aFilterName ) && !aUIName.equals( aDefUIName ) )
                 [ #  # ]
     759                 :            :         {
     760 [ #  # ][ #  # ]:          0 :             if ( !SfxStoringHelper::WarnUnacceptableFormat( GetModel(), aUIName, aDefUIName, sal_True ) )
                 [ #  # ]
     761                 :          0 :                 return STATUS_SAVEAS_STANDARDNAME;
     762 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     763                 :            :     }
     764                 :            : 
     765 [ #  # ][ #  # ]:          0 :     return STATUS_SAVE;
     766                 :            : }
     767                 :            : 
     768                 :            : //-------------------------------------------------------------------------
     769                 :          0 : sal_Bool ModelData_Impl::CheckFilterOptionsDialogExistence()
     770                 :            : {
     771         [ #  # ]:          0 :     uno::Sequence< beans::NamedValue > aSearchRequest( 1 );
     772 [ #  # ][ #  # ]:          0 :     aSearchRequest[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService"));
     773 [ #  # ][ #  # ]:          0 :     aSearchRequest[0].Value <<= GetDocServiceName();
                 [ #  # ]
     774                 :            : 
     775                 :            :     uno::Reference< container::XEnumeration > xFilterEnum =
     776 [ #  # ][ #  # ]:          0 :                                     m_pOwner->GetFilterQuery()->createSubSetEnumerationByProperties( aSearchRequest );
                 [ #  # ]
     777                 :            : 
     778 [ #  # ][ #  # ]:          0 :     while ( xFilterEnum->hasMoreElements() )
                 [ #  # ]
     779                 :            :     {
     780         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > pProps;
     781 [ #  # ][ #  # ]:          0 :         if ( xFilterEnum->nextElement() >>= pProps )
         [ #  # ][ #  # ]
     782                 :            :         {
     783         [ #  # ]:          0 :             ::comphelper::SequenceAsHashMap aPropsHM( pProps );
     784                 :            :             ::rtl::OUString aUIServName = aPropsHM.getUnpackedValueOrDefault(
     785                 :            :                                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIComponent")),
     786 [ #  # ][ #  # ]:          0 :                                             ::rtl::OUString() );
     787         [ #  # ]:          0 :             if ( !aUIServName.isEmpty() )
     788 [ #  # ][ #  # ]:          0 :                 return sal_True;
                 [ #  # ]
     789                 :            :         }
     790 [ #  # ][ #  # ]:          0 :     }
     791                 :            : 
     792         [ #  # ]:          0 :     return sal_False;
     793                 :            : }
     794                 :            : 
     795                 :            : //-------------------------------------------------------------------------
     796                 :          0 : sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
     797                 :            :                                             const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
     798                 :            :                                             sal_Bool bSetStandardName,
     799                 :            :                                             ::rtl::OUString& aSuggestedName,
     800                 :            :                                             sal_Bool bPreselectPassword,
     801                 :            :                                             ::rtl::OUString& aSuggestedDir,
     802                 :            :                                             sal_Int16 nDialog,
     803                 :            :                                             const ::rtl::OUString& rStandardDir,
     804                 :            :                                             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList)
     805                 :            : {
     806                 :          0 :     sal_Bool bUseFilterOptions = sal_False;
     807                 :            : 
     808                 :            :     ::comphelper::SequenceAsHashMap::const_iterator aOverwriteIter =
     809 [ #  # ][ #  # ]:          0 :                 GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Overwrite")) );
     810                 :            : 
     811                 :            :     // the file name must be specified if overwrite option is set
     812 [ #  # ][ #  # ]:          0 :     if ( aOverwriteIter != GetMediaDescr().end() )
     813                 :            :            throw task::ErrorCodeIOException( ::rtl::OUString(),
     814                 :            :                                             uno::Reference< uno::XInterface >(),
     815         [ #  # ]:          0 :                                             ERRCODE_IO_INVALIDPARAMETER );
     816                 :            : 
     817                 :            :     // no target file name is specified
     818                 :            :     // we need to show the file dialog
     819                 :            : 
     820                 :            :     // check if we have a filter which allows for filter options, so we need a corresponding checkbox in the dialog
     821                 :          0 :     sal_Bool bAllowOptions = sal_False;
     822                 :            : 
     823                 :            :     // in case of Export, filter options dialog is used if available
     824 [ #  # ][ #  # ]:          0 :     if( !( nStoreMode & EXPORT_REQUESTED ) || ( nStoreMode & WIDEEXPORT_REQUESTED ) )
     825         [ #  # ]:          0 :         bAllowOptions = CheckFilterOptionsDialogExistence();
     826                 :            : 
     827                 :            :     // get the filename by dialog ...
     828                 :            :     // create the file dialog
     829                 :            :     sal_Int16  aDialogMode = bAllowOptions
     830                 :            :         ? (com::sun::star::ui::dialogs::TemplateDescription::
     831                 :            :            FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS)
     832                 :            :         : (com::sun::star::ui::dialogs::TemplateDescription::
     833         [ #  # ]:          0 :            FILESAVE_AUTOEXTENSION_PASSWORD);
     834                 :          0 :     sal_Int64 aDialogFlags = 0;
     835                 :            : 
     836 [ #  # ][ #  # ]:          0 :     if( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
     837                 :            :     {
     838         [ #  # ]:          0 :         if ( nStoreMode & PDFEXPORT_REQUESTED )
     839                 :            :             aDialogMode = com::sun::star::ui::dialogs::TemplateDescription::
     840                 :          0 :                 FILESAVE_AUTOEXTENSION;
     841                 :            :         else
     842                 :            :             aDialogMode = com::sun::star::ui::dialogs::TemplateDescription::
     843                 :          0 :                 FILESAVE_AUTOEXTENSION_SELECTION;
     844                 :          0 :         aDialogFlags = SFXWB_EXPORT;
     845                 :            :     }
     846                 :            : 
     847                 :          0 :     sfx2::FileDialogHelper* pFileDlg = NULL;
     848                 :            : 
     849         [ #  # ]:          0 :     ::rtl::OUString aDocServiceName = GetDocServiceName();
     850                 :            :     DBG_ASSERT( !aDocServiceName.isEmpty(), "No document service for this module set!" );
     851                 :            : 
     852                 :          0 :     sal_Int32 nMust = getMustFlags( nStoreMode );
     853                 :          0 :     sal_Int32 nDont = getDontFlags( nStoreMode );
     854                 :          0 :     sfx2::FileDialogHelper::Context eCtxt = sfx2::FileDialogHelper::UNKNOWN_CONTEXT;
     855                 :            : 
     856 [ #  # ][ #  # ]:          0 :     if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
     857                 :            :     {
     858 [ #  # ][ #  # ]:          0 :         if ( ( nStoreMode & PDFEXPORT_REQUESTED ) && aPreselectedFilterPropsHM.size() )
                 [ #  # ]
     859                 :            :         {
     860                 :            :             // this is a PDF export
     861                 :            :             // the filter options has been shown already
     862                 :            :             ::rtl::OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
     863                 :            :                                                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     864 [ #  # ][ #  # ]:          0 :                                                         ::rtl::OUString() );
     865                 :            : 
     866 [ #  # ][ #  # ]:          0 :             pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf" ) ), rStandardDir, rBlackList );
                 [ #  # ]
     867 [ #  # ][ #  # ]:          0 :             pFileDlg->SetCurrentFilter( aFilterUIName );
                 [ #  # ]
     868                 :            :         }
     869                 :            :         else
     870                 :            :         {
     871                 :            :             // This is the normal dialog
     872 [ #  # ][ #  # ]:          0 :             pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rBlackList );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     873                 :            :         }
     874                 :            : 
     875         [ #  # ]:          0 :         if ( aDocServiceName == "com.sun.star.drawing.DrawingDocument" )
     876                 :          0 :             eCtxt = sfx2::FileDialogHelper::SD_EXPORT;
     877         [ #  # ]:          0 :         else if ( aDocServiceName == "com.sun.star.presentation.PresentationDocument" )
     878                 :          0 :             eCtxt = sfx2::FileDialogHelper::SI_EXPORT;
     879         [ #  # ]:          0 :         else if ( aDocServiceName == "com.sun.star.text.TextDocument" )
     880                 :          0 :             eCtxt = sfx2::FileDialogHelper::SW_EXPORT;
     881                 :            : 
     882         [ #  # ]:          0 :         if ( eCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT )
     883         [ #  # ]:          0 :                pFileDlg->SetContext( eCtxt );
     884                 :            : 
     885 [ #  # ][ #  # ]:          0 :         pFileDlg->CreateMatcher( aDocServiceName );
                 [ #  # ]
     886                 :            : 
     887         [ #  # ]:          0 :         uno::Reference< ui::dialogs::XFilePicker > xFilePicker = pFileDlg->GetFilePicker();
     888                 :            :         uno::Reference< ui::dialogs::XFilePickerControlAccess > xControlAccess =
     889         [ #  # ]:          0 :         uno::Reference< ui::dialogs::XFilePickerControlAccess >( xFilePicker, uno::UNO_QUERY );
     890                 :            : 
     891         [ #  # ]:          0 :         if ( xControlAccess.is() )
     892                 :            :         {
     893 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aCtrlText = SfxResId(STR_EXPORTBUTTON).toString();
     894 [ #  # ][ #  # ]:          0 :             xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, aCtrlText );
     895                 :            : 
     896 [ #  # ][ #  # ]:          0 :             aCtrlText = SfxResId(STR_LABEL_FILEFORMAT).toString();
     897 [ #  # ][ #  # ]:          0 :             xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, aCtrlText );
     898                 :          0 :         }
     899                 :            :     }
     900                 :            :     else
     901                 :            :     {
     902                 :            :         // This is the normal dialog
     903 [ #  # ][ #  # ]:          0 :         pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rBlackList );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     904 [ #  # ][ #  # ]:          0 :         pFileDlg->CreateMatcher( aDocServiceName );
                 [ #  # ]
     905                 :            :     }
     906                 :            : 
     907                 :          0 :     ::rtl::OUString aAdjustToType;
     908                 :            : 
     909                 :          0 :     const ::rtl::OUString sFilterNameString(aFilterNameString);
     910                 :            : 
     911 [ #  # ][ #  # ]:          0 :     if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
     912                 :            :     {
     913                 :            :         // it is export, set the preselected filter
     914                 :            :         ::rtl::OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
     915                 :            :                                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     916 [ #  # ][ #  # ]:          0 :                                         ::rtl::OUString() );
     917 [ #  # ][ #  # ]:          0 :         pFileDlg->SetCurrentFilter( aFilterUIName );
                 [ #  # ]
     918                 :            :     }
     919                 :            :     // it is no export, bSetStandardName == true means that user agreed to store document in the default (default default ;-)) format
     920 [ #  # ][ #  # ]:          0 :     else if ( bSetStandardName || GetStorable()->hasLocation() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     921                 :            :     {
     922         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > aOldFilterProps;
     923         [ #  # ]:          0 :         ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
     924                 :            :                                                         sFilterNameString,
     925         [ #  # ]:          0 :                                                         ::rtl::OUString() );
     926                 :            : 
     927         [ #  # ]:          0 :         if ( !aOldFilterName.isEmpty() )
     928 [ #  # ][ #  # ]:          0 :             m_pOwner->GetFilterConfiguration()->getByName( aOldFilterName ) >>= aOldFilterProps;
         [ #  # ][ #  # ]
     929                 :            : 
     930         [ #  # ]:          0 :         ::comphelper::SequenceAsHashMap aOldFiltPropsHM( aOldFilterProps );
     931 [ #  # ][ #  # ]:          0 :         sal_Int32 nOldFiltFlags = aOldFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 );
     932                 :            : 
     933 [ #  # ][ #  # ]:          0 :         if ( bSetStandardName || ( nOldFiltFlags & nMust ) != nMust || nOldFiltFlags & nDont )
                 [ #  # ]
     934                 :            :         {
     935                 :            :             // the suggested type will be changed, the extension should be adjusted
     936                 :            :             aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
     937                 :            :                                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")),
     938 [ #  # ][ #  # ]:          0 :                                             ::rtl::OUString() );
     939                 :            : 
     940                 :            :             ::rtl::OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault(
     941                 :            :                                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     942 [ #  # ][ #  # ]:          0 :                                             ::rtl::OUString() );
     943 [ #  # ][ #  # ]:          0 :             pFileDlg->SetCurrentFilter( aFilterUIName );
                 [ #  # ]
     944                 :            :         }
     945                 :            :         else
     946                 :            :         {
     947                 :            :             pFileDlg->SetCurrentFilter( aOldFiltPropsHM.getUnpackedValueOrDefault(
     948                 :            :                                                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")),
     949 [ #  # ][ #  # ]:          0 :                                                         ::rtl::OUString() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     950 [ #  # ][ #  # ]:          0 :         }
     951                 :            :     }
     952                 :            : 
     953         [ #  # ]:          0 :     ::rtl::OUString aReccomendedDir = GetReccomendedDir( aSuggestedDir );
     954         [ #  # ]:          0 :     if ( !aReccomendedDir.isEmpty() )
     955 [ #  # ][ #  # ]:          0 :         pFileDlg->SetDisplayFolder( aReccomendedDir );
                 [ #  # ]
     956         [ #  # ]:          0 :     ::rtl::OUString aReccomendedName = GetReccomendedName( aSuggestedName, aAdjustToType );
     957         [ #  # ]:          0 :     if ( !aReccomendedName.isEmpty() )
     958 [ #  # ][ #  # ]:          0 :         pFileDlg->SetFileName( aReccomendedName );
                 [ #  # ]
     959                 :            : 
     960 [ #  # ][ #  # ]:          0 :     uno::Reference < view::XSelectionSupplier > xSel( GetModel()->getCurrentController(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     961 [ #  # ][ #  # ]:          0 :     if ( xSel.is() && xSel->getSelection().hasValue() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     962 [ #  # ][ #  # ]:          0 :         GetMediaDescr()[::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SelectionOnly"))] <<= sal_True;
                 [ #  # ]
     963                 :            : 
     964                 :            :     // This is a temporary hardcoded solution must be removed when
     965                 :            :     // dialogs do not need parameters in SidSet representation any more
     966                 :          0 :     sal_uInt16 nSlotID = getSlotIDFromMode( nStoreMode );
     967         [ #  # ]:          0 :     if ( !nSlotID )
     968         [ #  # ]:          0 :         throw lang::IllegalArgumentException(); // TODO:
     969                 :            : 
     970                 :            :     // generate SidSet from MediaDescriptor and provide it into FileDialog
     971                 :            :     // than merge changed SidSet back
     972 [ #  # ][ #  # ]:          0 :     SfxAllItemSet aDialogParams( SFX_APP()->GetPool() );
     973                 :          0 :     SfxItemSet* pDialogParams = &aDialogParams;
     974                 :            :     TransformParameters( nSlotID,
     975                 :          0 :                          GetMediaDescr().getAsConstPropertyValueList(),
     976                 :            :                          aDialogParams,
     977 [ #  # ][ #  # ]:          0 :                          NULL );
                 [ #  # ]
     978                 :            : 
     979                 :          0 :     const SfxPoolItem* pItem = NULL;
     980 [ #  # ][ #  # ]:          0 :     if ( bPreselectPassword && aDialogParams.GetItemState( SID_ENCRYPTIONDATA, sal_True, &pItem ) != SFX_ITEM_SET )
         [ #  # ][ #  # ]
     981                 :            :     {
     982                 :            :         // the file dialog preselects the password checkbox if the provided mediadescriptor has encryption data entry
     983                 :            :         // after dialog execution the password interaction flag will be either removed or not
     984 [ #  # ][ #  # ]:          0 :         aDialogParams.Put( SfxBoolItem( SID_PASSWORDINTERACTION, sal_True ) );
                 [ #  # ]
     985                 :            :     }
     986                 :            : 
     987                 :            :     // aStringTypeFN is a pure output parameter, pDialogParams is an in/out parameter
     988         [ #  # ]:          0 :     String aStringTypeFN;
     989 [ #  # ][ #  # ]:          0 :     if ( pFileDlg->Execute( pDialogParams, aStringTypeFN ) != ERRCODE_NONE )
     990                 :            :     {
     991 [ #  # ][ #  # ]:          0 :         delete pFileDlg;
     992         [ #  # ]:          0 :         throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
     993                 :            :     }
     994                 :            : 
     995         [ #  # ]:          0 :     ::rtl::OUString aFilterName = aStringTypeFN;
     996                 :            : 
     997                 :            :     // the following two arguments can not be converted in MediaDescriptor,
     998                 :            :     // so they should be removed from the ItemSet after retrieving
     999 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pDialogParams, pRecommendReadOnly, SfxBoolItem, SID_RECOMMENDREADONLY, sal_False );
    1000 [ #  # ][ #  # ]:          0 :     m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() );
    1001         [ #  # ]:          0 :     pDialogParams->ClearItem( SID_RECOMMENDREADONLY );
    1002                 :            : 
    1003         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aPropsFromDialog;
    1004         [ #  # ]:          0 :     TransformItems( nSlotID, *pDialogParams, aPropsFromDialog, NULL );
    1005         [ #  # ]:          0 :     GetMediaDescr() << aPropsFromDialog;
    1006                 :            : 
    1007                 :            :     // get the path from the dialog
    1008 [ #  # ][ #  # ]:          0 :     INetURLObject aURL( pFileDlg->GetPath() );
         [ #  # ][ #  # ]
    1009                 :            :     // the path should be provided outside since it might be used for further calls to the dialog
    1010         [ #  # ]:          0 :     aSuggestedName = aURL.GetName( INetURLObject::DECODE_WITH_CHARSET );
    1011 [ #  # ][ #  # ]:          0 :        aSuggestedDir = pFileDlg->GetDisplayDirectory();
                 [ #  # ]
    1012                 :            : 
    1013                 :            :     // old filter options should be cleared in case different filter is used
    1014                 :            : 
    1015                 :          0 :     ::rtl::OUString aFilterFromMediaDescr = GetMediaDescr().getUnpackedValueOrDefault(
    1016                 :            :                                                     sFilterNameString,
    1017         [ #  # ]:          0 :                                                     ::rtl::OUString() );
    1018         [ #  # ]:          0 :     ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault(
    1019                 :            :                                                     sFilterNameString,
    1020         [ #  # ]:          0 :                                                     ::rtl::OUString() );
    1021                 :            : 
    1022                 :          0 :     const ::rtl::OUString sFilterOptionsString(aFilterOptionsString);
    1023                 :          0 :     const ::rtl::OUString sFilterDataString(aFilterDataString);
    1024                 :            : 
    1025         [ #  # ]:          0 :     if ( aFilterName.equals( aFilterFromMediaDescr ) )
    1026                 :            :     {
    1027                 :            :         // preserv current settings if any
    1028                 :            :         // if there no current settings and the name is the same
    1029                 :            :         // as old filter name use old filter settings
    1030                 :            : 
    1031         [ #  # ]:          0 :         if ( aFilterFromMediaDescr.equals( aOldFilterName ) )
    1032                 :            :         {
    1033                 :            :             ::comphelper::SequenceAsHashMap::const_iterator aIter =
    1034 [ #  # ][ #  # ]:          0 :                                         GetDocProps().find( sFilterOptionsString );
    1035 [ #  # ][ #  # ]:          0 :             if ( aIter != GetDocProps().end()
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1036 [ #  # ][ #  # ]:          0 :               && GetMediaDescr().find( sFilterOptionsString ) == GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1037 [ #  # ][ #  # ]:          0 :                 GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1038                 :            : 
    1039 [ #  # ][ #  # ]:          0 :             aIter = GetDocProps().find( sFilterDataString );
    1040 [ #  # ][ #  # ]:          0 :             if ( aIter != GetDocProps().end()
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1041 [ #  # ][ #  # ]:          0 :               && GetMediaDescr().find( sFilterDataString ) == GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1042 [ #  # ][ #  # ]:          0 :                 GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1043                 :            :         }
    1044                 :            :     }
    1045                 :            :     else
    1046                 :            :     {
    1047         [ #  # ]:          0 :         GetMediaDescr().erase( sFilterDataString );
    1048         [ #  # ]:          0 :         GetMediaDescr().erase( sFilterOptionsString );
    1049                 :            : 
    1050         [ #  # ]:          0 :         if ( aFilterName.equals( aOldFilterName ) )
    1051                 :            :         {
    1052                 :            :             // merge filter option of the document filter
    1053                 :            : 
    1054                 :            :             ::comphelper::SequenceAsHashMap::const_iterator aIter =
    1055 [ #  # ][ #  # ]:          0 :                                 GetDocProps().find( sFilterOptionsString );
    1056 [ #  # ][ #  # ]:          0 :             if ( aIter != GetDocProps().end() )
                 [ #  # ]
    1057 [ #  # ][ #  # ]:          0 :                 GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1058                 :            : 
    1059 [ #  # ][ #  # ]:          0 :             aIter = GetDocProps().find( sFilterDataString );
    1060 [ #  # ][ #  # ]:          0 :             if ( aIter != GetDocProps().end() )
                 [ #  # ]
    1061 [ #  # ][ #  # ]:          0 :                 GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1062                 :            :         }
    1063                 :            :     }
    1064                 :            : 
    1065 [ #  # ][ #  # ]:          0 :     uno::Reference< ui::dialogs::XFilePickerControlAccess > xExtFileDlg( pFileDlg->GetFilePicker(), uno::UNO_QUERY );
    1066         [ #  # ]:          0 :     if ( xExtFileDlg.is() )
    1067                 :            :     {
    1068 [ #  # ][ #  # ]:          0 :         if ( SfxStoringHelper::CheckFilterOptionsAppearence( m_pOwner->GetFilterConfiguration(), aFilterName ) )
                 [ #  # ]
    1069                 :          0 :             bUseFilterOptions = sal_True;
    1070                 :            : 
    1071 [ #  # ][ #  # ]:          0 :         if ( ( !( nStoreMode & EXPORT_REQUESTED ) || ( nStoreMode & WIDEEXPORT_REQUESTED ) ) && bUseFilterOptions )
                 [ #  # ]
    1072                 :            :         {
    1073                 :            :             try
    1074                 :            :             {
    1075                 :            :                 // for exporters: always show dialog if format uses options
    1076                 :            :                 // for save: show dialog if format uses options and no options given or if forced by user
    1077                 :            :                 uno::Any aVal =
    1078 [ #  # ][ #  # ]:          0 :                         xExtFileDlg->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 0 );
    1079                 :            : 
    1080                 :          0 :                 aVal >>= bUseFilterOptions;
    1081         [ #  # ]:          0 :                 if ( !bUseFilterOptions )
    1082                 :            :                     bUseFilterOptions =
    1083 [ #  # ][ #  # ]:          0 :                       ( GetMediaDescr().find( sFilterDataString ) == GetMediaDescr().end()
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1084 [ #  # ][ #  # ]:          0 :                       && GetMediaDescr().find( sFilterOptionsString ) == GetMediaDescr().end() );
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
    1085                 :            :             }
    1086         [ #  # ]:          0 :             catch( const lang::IllegalArgumentException& )
    1087                 :            :             {}
    1088                 :            :         }
    1089                 :            :     }
    1090                 :            : 
    1091 [ #  # ][ #  # ]:          0 :     delete pFileDlg;
    1092                 :            : 
    1093                 :            :     // merge in results of the dialog execution
    1094 [ #  # ][ #  # ]:          0 :     GetMediaDescr()[::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))] <<=
    1095 [ #  # ][ #  # ]:          0 :                                                 ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ));
    1096 [ #  # ][ #  # ]:          0 :     GetMediaDescr()[sFilterNameString] <<= aFilterName;
    1097                 :            : 
    1098 [ #  # ][ #  # ]:          0 :     return bUseFilterOptions;
         [ #  # ][ #  # ]
    1099                 :            : }
    1100                 :            : 
    1101                 :            : //-------------------------------------------------------------------------
    1102                 :          0 : sal_Bool ModelData_Impl::ShowDocumentInfoDialog()
    1103                 :            : {
    1104                 :          0 :     sal_Bool bDialogUsed = sal_False;
    1105                 :            : 
    1106                 :            :     try {
    1107 [ #  # ][ #  # ]:          0 :         uno::Reference< frame::XController > xController = GetModel()->getCurrentController();
                 [ #  # ]
    1108         [ #  # ]:          0 :         if ( xController.is() )
    1109                 :            :         {
    1110 [ #  # ][ #  # ]:          0 :             uno::Reference< frame::XDispatchProvider > xFrameDispatch( xController->getFrame(), uno::UNO_QUERY );
                 [ #  # ]
    1111         [ #  # ]:          0 :             if ( xFrameDispatch.is() )
    1112                 :            :             {
    1113                 :          0 :                 util::URL aURL;
    1114         [ #  # ]:          0 :                 aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SetDocumentProperties"));
    1115                 :            : 
    1116 [ #  # ][ #  # ]:          0 :                 uno::Reference < util::XURLTransformer > xTransformer( util::URLTransformer::create( ::comphelper::ComponentContext(m_pOwner->GetServiceFactory()).getUNOContext() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1117 [ #  # ][ #  # ]:          0 :                 if ( xTransformer->parseStrict( aURL ) )
                 [ #  # ]
    1118                 :            :                 {
    1119         [ #  # ]:          0 :                     uno::Reference< frame::XDispatch > xDispatch = xFrameDispatch->queryDispatch(
    1120                 :            :                                                                                 aURL,
    1121                 :            :                                                                                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")),
    1122 [ #  # ][ #  # ]:          0 :                                                                                 0 );
    1123         [ #  # ]:          0 :                     if ( xDispatch.is() )
    1124                 :            :                     {
    1125 [ #  # ][ #  # ]:          0 :                         xDispatch->dispatch( aURL, uno::Sequence< beans::PropertyValue >() );
         [ #  # ][ #  # ]
    1126                 :          0 :                         bDialogUsed = sal_True;
    1127                 :          0 :                     }
    1128                 :          0 :                 }
    1129                 :          0 :             }
    1130         [ #  # ]:          0 :         }
    1131                 :            :     }
    1132                 :          0 :     catch ( const uno::Exception& )
    1133                 :            :     {
    1134                 :            :     }
    1135                 :            : 
    1136                 :          0 :     return bDialogUsed;
    1137                 :            : }
    1138                 :            : 
    1139                 :            : //-------------------------------------------------------------------------
    1140                 :          0 : ::rtl::OUString ModelData_Impl::GetReccomendedDir( const ::rtl::OUString& aSuggestedDir )
    1141                 :            : {
    1142                 :          0 :     ::rtl::OUString aReccomendedDir;
    1143                 :            : 
    1144 [ #  # ][ #  # ]:          0 :     if ( ( !aSuggestedDir.isEmpty() || GetStorable()->hasLocation() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1145                 :          0 :       && !GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage")),
    1146   [ #  #  #  # ]:          0 :                                                                       sal_False ) )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1147                 :            :     {
    1148         [ #  # ]:          0 :         INetURLObject aLocation;
    1149         [ #  # ]:          0 :         if ( !aSuggestedDir.isEmpty() )
    1150 [ #  # ][ #  # ]:          0 :             aLocation = INetURLObject( aSuggestedDir );
                 [ #  # ]
    1151                 :            :         else
    1152                 :            :         {
    1153 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aOldURL = GetStorable()->getLocation();
                 [ #  # ]
    1154         [ #  # ]:          0 :             if ( !aOldURL.isEmpty() )
    1155                 :            :             {
    1156         [ #  # ]:          0 :                 INetURLObject aTmp( aOldURL );
    1157 [ #  # ][ #  # ]:          0 :                 if ( aTmp.removeSegment() )
    1158 [ #  # ][ #  # ]:          0 :                     aLocation = aTmp;
    1159                 :            :             }
    1160                 :            : 
    1161         [ #  # ]:          0 :             if ( aLocation.HasError() )
    1162 [ #  # ][ #  # ]:          0 :                 aLocation = INetURLObject( SvtPathOptions().GetWorkPath() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1163                 :            :         }
    1164                 :            : 
    1165         [ #  # ]:          0 :         aLocation.setFinalSlash();
    1166         [ #  # ]:          0 :         if ( !aLocation.HasError() )
    1167 [ #  # ][ #  # ]:          0 :             aReccomendedDir = aLocation.GetMainURL( INetURLObject::NO_DECODE );
    1168                 :            :     }
    1169                 :            :     else
    1170                 :            :     {
    1171 [ #  # ][ #  # ]:          0 :         aReccomendedDir = INetURLObject( SvtPathOptions().GetWorkPath() ).GetMainURL( INetURLObject::NO_DECODE );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1172                 :            :     }
    1173                 :            : 
    1174                 :          0 :     return aReccomendedDir;
    1175                 :            : }
    1176                 :            : 
    1177                 :            : //-------------------------------------------------------------------------
    1178                 :          0 : ::rtl::OUString ModelData_Impl::GetReccomendedName( const ::rtl::OUString& aSuggestedName, const ::rtl::OUString& aTypeName )
    1179                 :            : {
    1180                 :            :     // the last used name might be provided by aSuggestedName from the old selection, or from the MediaDescriptor
    1181                 :          0 :     ::rtl::OUString aReccomendedName;
    1182                 :            : 
    1183         [ #  # ]:          0 :     if ( !aSuggestedName.isEmpty() )
    1184                 :          0 :         aReccomendedName = aSuggestedName;
    1185                 :            :     else
    1186                 :            :     {
    1187 [ #  # ][ #  # ]:          0 :         aReccomendedName = INetURLObject( GetStorable()->getLocation() ).GetName( INetURLObject::DECODE_WITH_CHARSET );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1188         [ #  # ]:          0 :         if ( aReccomendedName.isEmpty() )
    1189                 :            :         {
    1190                 :            :             try {
    1191 [ #  # ][ #  # ]:          0 :                 uno::Reference< frame::XTitle > xTitle( GetModel(), uno::UNO_QUERY_THROW );
    1192 [ #  # ][ #  # ]:          0 :                 aReccomendedName = xTitle->getTitle();
                 [ #  # ]
    1193         [ #  # ]:          0 :             } catch( const uno::Exception& ) {}
    1194                 :            :         }
    1195                 :            : 
    1196 [ #  # ][ #  # ]:          0 :         if ( !aReccomendedName.isEmpty() && !aTypeName.isEmpty() )
                 [ #  # ]
    1197                 :            :         {
    1198                 :            :             // adjust the extension to the type
    1199                 :            :             uno::Reference< container::XNameAccess > xTypeDetection = uno::Reference< container::XNameAccess >(
    1200 [ #  # ][ #  # ]:          0 :                 m_pOwner->GetServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection")) ),
    1201 [ #  # ][ #  # ]:          0 :                 uno::UNO_QUERY );
                 [ #  # ]
    1202         [ #  # ]:          0 :             if ( xTypeDetection.is() )
    1203                 :            :             {
    1204 [ #  # ][ #  # ]:          0 :                 INetURLObject aObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "file:///c:/" ) ) + aReccomendedName );
    1205                 :            : 
    1206         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aTypeNameProps;
    1207 [ #  # ][ #  # ]:          0 :                 if ( ( xTypeDetection->getByName( aTypeName ) >>= aTypeNameProps ) && aTypeNameProps.getLength() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1208                 :            :                 {
    1209         [ #  # ]:          0 :                     ::comphelper::SequenceAsHashMap aTypeNamePropsHM( aTypeNameProps );
    1210                 :            :                     uno::Sequence< ::rtl::OUString > aExtensions = aTypeNamePropsHM.getUnpackedValueOrDefault(
    1211                 :            :                                                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extensions")),
    1212 [ #  # ][ #  # ]:          0 :                                                     ::uno::Sequence< ::rtl::OUString >() );
         [ #  # ][ #  # ]
    1213         [ #  # ]:          0 :                     if ( aExtensions.getLength() )
    1214 [ #  # ][ #  # ]:          0 :                         aObj.SetExtension( aExtensions[0] );
         [ #  # ][ #  # ]
    1215                 :            :                 }
    1216                 :            : 
    1217 [ #  # ][ #  # ]:          0 :                 aReccomendedName = aObj.GetName( INetURLObject::DECODE_WITH_CHARSET );
                 [ #  # ]
    1218                 :          0 :             }
    1219                 :            :         }
    1220                 :            :     }
    1221                 :            : 
    1222                 :          0 :     return aReccomendedName;
    1223                 :            : }
    1224                 :            : 
    1225                 :            : 
    1226                 :            : //=========================================================================
    1227                 :            : // class SfxStoringHelper
    1228                 :            : //=========================================================================
    1229                 :            : //-------------------------------------------------------------------------
    1230                 :          0 : SfxStoringHelper::SfxStoringHelper( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
    1231                 :          0 : : m_xFactory( xFactory )
    1232                 :            : {
    1233                 :          0 : }
    1234                 :            : 
    1235                 :            : //-------------------------------------------------------------------------
    1236                 :          0 : uno::Reference< lang::XMultiServiceFactory > SfxStoringHelper::GetServiceFactory()
    1237                 :            : {
    1238         [ #  # ]:          0 :     if ( !m_xFactory.is() )
    1239                 :            :     {
    1240         [ #  # ]:          0 :         m_xFactory = ::comphelper::getProcessServiceFactory();
    1241         [ #  # ]:          0 :         if( !m_xFactory.is() )
    1242         [ #  # ]:          0 :             throw uno::RuntimeException(); // TODO:
    1243                 :            :     }
    1244                 :            : 
    1245                 :          0 :     return m_xFactory;
    1246                 :            : }
    1247                 :            : 
    1248                 :            : //-------------------------------------------------------------------------
    1249                 :          0 : uno::Reference< container::XNameAccess > SfxStoringHelper::GetFilterConfiguration()
    1250                 :            : {
    1251         [ #  # ]:          0 :     if ( !m_xFilterCFG.is() )
    1252                 :            :     {
    1253                 :            :         m_xFilterCFG = uno::Reference< container::XNameAccess >(
    1254         [ #  # ]:          0 :             GetServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.FilterFactory")) ),
    1255 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY );
         [ #  # ][ #  # ]
    1256                 :            : 
    1257         [ #  # ]:          0 :         if ( !m_xFilterCFG.is() )
    1258         [ #  # ]:          0 :             throw uno::RuntimeException();
    1259                 :            :     }
    1260                 :            : 
    1261                 :          0 :     return m_xFilterCFG;
    1262                 :            : }
    1263                 :            : 
    1264                 :            : //-------------------------------------------------------------------------
    1265                 :          0 : uno::Reference< container::XContainerQuery > SfxStoringHelper::GetFilterQuery()
    1266                 :            : {
    1267         [ #  # ]:          0 :     if ( !m_xFilterQuery.is() )
    1268                 :            :     {
    1269 [ #  # ][ #  # ]:          0 :         m_xFilterQuery = uno::Reference< container::XContainerQuery >( GetFilterConfiguration(), uno::UNO_QUERY );
    1270         [ #  # ]:          0 :         if ( !m_xFilterQuery.is() )
    1271         [ #  # ]:          0 :             throw uno::RuntimeException();
    1272                 :            :     }
    1273                 :            : 
    1274                 :          0 :     return m_xFilterQuery;
    1275                 :            : }
    1276                 :            : 
    1277                 :            : //-------------------------------------------------------------------------
    1278                 :          0 : uno::Reference< ::com::sun::star::frame::XModuleManager > SfxStoringHelper::GetModuleManager()
    1279                 :            : {
    1280         [ #  # ]:          0 :     if ( !m_xModuleManager.is() )
    1281                 :            :     {
    1282                 :            :         m_xModuleManager = uno::Reference< ::com::sun::star::frame::XModuleManager >(
    1283         [ #  # ]:          0 :             GetServiceFactory()->createInstance(
    1284                 :          0 :                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager")) ),
    1285 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY );
         [ #  # ][ #  # ]
    1286                 :            : 
    1287         [ #  # ]:          0 :         if ( !m_xModuleManager.is() )
    1288         [ #  # ]:          0 :             throw uno::RuntimeException();
    1289                 :            :     }
    1290                 :            : 
    1291                 :          0 :     return m_xModuleManager;
    1292                 :            : }
    1293                 :            : 
    1294                 :            : //-------------------------------------------------------------------------
    1295                 :          0 : uno::Reference< container::XNameAccess > SfxStoringHelper::GetNamedModuleManager()
    1296                 :            : {
    1297         [ #  # ]:          0 :     if ( !m_xNamedModManager.is() )
    1298                 :            :     {
    1299 [ #  # ][ #  # ]:          0 :         m_xNamedModManager = uno::Reference< container::XNameAccess >( GetModuleManager(), uno::UNO_QUERY );
    1300         [ #  # ]:          0 :         if ( !m_xNamedModManager.is() )
    1301         [ #  # ]:          0 :             throw uno::RuntimeException();
    1302                 :            :     }
    1303                 :            : 
    1304                 :          0 :     return m_xNamedModManager;
    1305                 :            : }
    1306                 :            : 
    1307                 :            : //-------------------------------------------------------------------------
    1308                 :          0 : sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xModel,
    1309                 :            :                                             const ::rtl::OUString& aSlotName,
    1310                 :            :                                             uno::Sequence< beans::PropertyValue >& aArgsSequence,
    1311                 :            :                                             sal_Bool bPreselectPassword,
    1312                 :            :                                             ::rtl::OUString aSuggestedName,
    1313                 :            :                                             sal_uInt16 nDocumentSignatureState )
    1314                 :            : {
    1315         [ #  # ]:          0 :     ModelData_Impl aModelData( *this, xModel, aArgsSequence );
    1316                 :            : 
    1317                 :          0 :     sal_Bool bDialogUsed = sal_False;
    1318                 :            : 
    1319         [ #  # ]:          0 :     INetURLObject aURL;
    1320                 :            : 
    1321                 :          0 :     sal_Bool bSetStandardName = sal_False; // can be set only for SaveAs
    1322                 :            : 
    1323                 :            :     // parse the slot name
    1324         [ #  # ]:          0 :     sal_Int8 nStoreMode = getStoreModeFromSlotName( aSlotName );
    1325                 :          0 :     sal_Int8 nStatusSave = STATUS_NO_ACTION;
    1326                 :            : 
    1327                 :            :     // handle the special cases
    1328         [ #  # ]:          0 :     if ( nStoreMode & SAVEAS_REQUESTED )
    1329                 :            :     {
    1330                 :            :         ::comphelper::SequenceAsHashMap::const_iterator aSaveToIter =
    1331 [ #  # ][ #  # ]:          0 :                         aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SaveTo")) );
    1332 [ #  # ][ #  # ]:          0 :         if ( aSaveToIter != aModelData.GetMediaDescr().end() )
    1333                 :            :         {
    1334                 :          0 :             sal_Bool bWideExport = sal_False;
    1335         [ #  # ]:          0 :             aSaveToIter->second >>= bWideExport;
    1336         [ #  # ]:          0 :             if ( bWideExport )
    1337                 :          0 :                 nStoreMode = EXPORT_REQUESTED | WIDEEXPORT_REQUESTED;
    1338                 :            :         }
    1339                 :            : 
    1340                 :            :         // if saving is not acceptable the warning must be shown even in case of SaveAs operation
    1341 [ #  # ][ #  # ]:          0 :         if ( ( nStoreMode & SAVEAS_REQUESTED ) && aModelData.CheckSaveAcceptable( STATUS_SAVEAS ) == STATUS_NO_ACTION )
         [ #  # ][ #  # ]
    1342         [ #  # ]:          0 :             throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
    1343                 :            :     }
    1344         [ #  # ]:          0 :     else if ( nStoreMode & SAVE_REQUESTED )
    1345                 :            :     {
    1346                 :            :         // if saving is not acceptable by the configuration the warning must be shown
    1347         [ #  # ]:          0 :         nStatusSave = aModelData.CheckSaveAcceptable( STATUS_SAVE );
    1348                 :            : 
    1349         [ #  # ]:          0 :         if ( nStatusSave == STATUS_NO_ACTION )
    1350         [ #  # ]:          0 :             throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
    1351         [ #  # ]:          0 :         else if ( nStatusSave == STATUS_SAVE )
    1352                 :            :         {
    1353                 :            :             // check whether it is possible to use save operation
    1354         [ #  # ]:          0 :             nStatusSave = aModelData.CheckStateForSave();
    1355                 :            :         }
    1356                 :            : 
    1357         [ #  # ]:          0 :         if ( nStatusSave == STATUS_NO_ACTION )
    1358                 :            :         {
    1359         [ #  # ]:          0 :             throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
    1360                 :            :         }
    1361         [ #  # ]:          0 :         else if ( nStatusSave != STATUS_SAVE )
    1362                 :            :         {
    1363                 :            :             // this should be a usual SaveAs operation
    1364                 :          0 :             nStoreMode = SAVEAS_REQUESTED;
    1365         [ #  # ]:          0 :             if ( nStatusSave == STATUS_SAVEAS_STANDARDNAME )
    1366                 :          0 :                 bSetStandardName = sal_True;
    1367                 :            :         }
    1368                 :            :     }
    1369                 :            : 
    1370         [ #  # ]:          0 :     if ( !( nStoreMode & EXPORT_REQUESTED ) )
    1371                 :            :     {
    1372                 :            :         // if it is no export, warn user that the signature will be removed
    1373 [ #  # ][ #  # ]:          0 :         if (  SIGNATURESTATE_SIGNATURES_OK == nDocumentSignatureState
         [ #  # ][ #  # ]
    1374                 :            :            || SIGNATURESTATE_SIGNATURES_INVALID == nDocumentSignatureState
    1375                 :            :            || SIGNATURESTATE_SIGNATURES_NOTVALIDATED == nDocumentSignatureState
    1376                 :            :            || SIGNATURESTATE_SIGNATURES_PARTIAL_OK == nDocumentSignatureState)
    1377                 :            :         {
    1378 [ #  # ][ #  # ]:          0 :             if ( QueryBox( NULL, SfxResId( RID_XMLSEC_QUERY_LOSINGSIGNATURE ) ).Execute() != RET_YES )
         [ #  # ][ #  # ]
                 [ #  # ]
    1379                 :            :             {
    1380                 :            :                 // the user has decided not to store the document
    1381                 :            :                 throw task::ErrorCodeIOException( ::rtl::OUString(),
    1382                 :            :                                                   uno::Reference< uno::XInterface >(),
    1383         [ #  # ]:          0 :                                                   ERRCODE_IO_ABORT );
    1384                 :            :             }
    1385                 :            :         }
    1386                 :            :     }
    1387                 :            : 
    1388 [ #  # ][ #  # ]:          0 :     if ( nStoreMode & SAVE_REQUESTED && nStatusSave == STATUS_SAVE )
    1389                 :            :     {
    1390                 :            :         // Document properties can contain streams that should be freed before storing
    1391         [ #  # ]:          0 :         aModelData.FreeDocumentProps();
    1392                 :            : 
    1393 [ #  # ][ #  # ]:          0 :         if ( aModelData.GetStorable2().is() )
    1394                 :            :         {
    1395                 :            :             try
    1396                 :            :             {
    1397 [ #  # ][ #  # ]:          0 :                 aModelData.GetStorable2()->storeSelf( aModelData.GetMediaDescr().getAsConstPropertyValueList() );
         [ #  # ][ #  # ]
                 [ #  # ]
    1398                 :            :             }
    1399   [ #  #  #  # ]:          0 :             catch( const lang::IllegalArgumentException& )
    1400                 :            :             {
    1401                 :            :                 OSL_FAIL( "ModelData didn't handle illegal parameters, all the parameters are ignored!\n" );
    1402   [ #  #  #  #  :          0 :                 aModelData.GetStorable()->store();
                   #  # ]
    1403                 :            :             }
    1404                 :            :         }
    1405                 :            :         else
    1406                 :            :         {
    1407                 :            :             OSL_FAIL( "XStorable2 is not supported by the model!\n" );
    1408 [ #  # ][ #  # ]:          0 :             aModelData.GetStorable()->store();
                 [ #  # ]
    1409                 :            :         }
    1410                 :            : 
    1411                 :          0 :         return sal_False;
    1412                 :            :     }
    1413                 :            : 
    1414                 :            :     // preselect a filter for the storing process
    1415         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aFilterProps = aModelData.GetPreselectedFilter_Impl( nStoreMode );
    1416                 :            : 
    1417                 :            :     DBG_ASSERT( aFilterProps.getLength(), "No filter for storing!\n" );
    1418         [ #  # ]:          0 :     if ( !aFilterProps.getLength() )
    1419                 :            :         throw task::ErrorCodeIOException( ::rtl::OUString(),
    1420                 :            :                                             uno::Reference< uno::XInterface >(),
    1421         [ #  # ]:          0 :                                             ERRCODE_IO_INVALIDPARAMETER );
    1422                 :            : 
    1423         [ #  # ]:          0 :     ::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
    1424                 :            :     ::rtl::OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
    1425                 :            :                                                                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")),
    1426 [ #  # ][ #  # ]:          0 :                                                                     ::rtl::OUString() );
    1427                 :            : 
    1428                 :          0 :     const ::rtl::OUString sFilterNameString(aFilterNameString);
    1429                 :            : 
    1430                 :          0 :     ::rtl::OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault(
    1431                 :            :                                                     sFilterNameString,
    1432         [ #  # ]:          0 :                                                     ::rtl::OUString() );
    1433         [ #  # ]:          0 :     ::rtl::OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault(
    1434                 :            :                                                     sFilterNameString,
    1435         [ #  # ]:          0 :                                                     ::rtl::OUString() );
    1436                 :            : 
    1437                 :          0 :     sal_Bool bUseFilterOptions = sal_False;
    1438 [ #  # ][ #  # ]:          0 :     ::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) );
    1439                 :            : 
    1440                 :          0 :     const ::rtl::OUString sFilterOptionsString(aFilterOptionsString);
    1441                 :          0 :     const ::rtl::OUString sFilterDataString(aFilterDataString);
    1442                 :          0 :     const ::rtl::OUString sFilterFlagsString(aFilterFlagsString);
    1443                 :            : 
    1444 [ #  # ][ #  # ]:          0 :     if ( ( nStoreMode & EXPORT_REQUESTED ) && ( nStoreMode & PDFEXPORT_REQUESTED ) && !( nStoreMode & PDFDIRECTEXPORT_REQUESTED ) )
                 [ #  # ]
    1445                 :            :     {
    1446                 :            :         // this is PDF export, the filter options dialog should be shown before the export
    1447 [ #  # ][ #  # ]:          0 :         aModelData.GetMediaDescr()[sFilterNameString] <<= aFilterName;
    1448 [ #  # ][ #  # ]:          0 :         if ( aModelData.GetMediaDescr().find( sFilterFlagsString ) == aModelData.GetMediaDescr().end()
           [ #  #  #  #  
           #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1449 [ #  # ][ #  # ]:          0 :           && aModelData.GetMediaDescr().find( sFilterOptionsString ) == aModelData.GetMediaDescr().end()
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1450 [ #  # ][ #  # ]:          0 :           && aModelData.GetMediaDescr().find( sFilterDataString ) == aModelData.GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1451                 :            :         {
    1452                 :            :             // execute filter options dialog since no options are set in the media descriptor
    1453 [ #  # ][ #  # ]:          0 :             if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) )
    1454                 :          0 :                 bDialogUsed = sal_True;
    1455                 :            :         }
    1456                 :            :     }
    1457                 :            : 
    1458 [ #  # ][ #  # ]:          0 :     if ( aFileNameIter == aModelData.GetMediaDescr().end() )
    1459                 :            :     {
    1460                 :          0 :         sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG;
    1461                 :            :         ::comphelper::SequenceAsHashMap::const_iterator aDlgIter =
    1462 [ #  # ][ #  # ]:          0 :             aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSystemDialog")) );
    1463 [ #  # ][ #  # ]:          0 :         if ( aDlgIter != aModelData.GetMediaDescr().end() )
    1464                 :            :         {
    1465                 :          0 :             sal_Bool bUseSystemDialog = sal_True;
    1466 [ #  # ][ #  # ]:          0 :             if ( aDlgIter->second >>= bUseSystemDialog )
    1467                 :            :             {
    1468         [ #  # ]:          0 :                 if ( bUseSystemDialog )
    1469                 :          0 :                     nDialog = SFX2_IMPL_DIALOG_SYSTEM;
    1470                 :            :                 else
    1471                 :          0 :                     nDialog = SFX2_IMPL_DIALOG_OOO;
    1472                 :            :             }
    1473                 :            :         }
    1474                 :            : 
    1475                 :            :         // The Dispatch supports parameter FolderName that overwrites SuggestedSaveAsDir
    1476 [ #  # ][ #  # ]:          0 :         ::rtl::OUString aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FolderName" ) ), ::rtl::OUString() );
    1477         [ #  # ]:          0 :         if ( aSuggestedDir.isEmpty() )
    1478                 :            :         {
    1479 [ #  # ][ #  # ]:          0 :             aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsDir" ) ), ::rtl::OUString() );
    1480         [ #  # ]:          0 :             if ( aSuggestedDir.isEmpty() )
    1481 [ #  # ][ #  # ]:          0 :                 aSuggestedDir = aModelData.GetDocProps().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsDir" ) ), ::rtl::OUString() );
                 [ #  # ]
    1482                 :            :         }
    1483                 :            : 
    1484 [ #  # ][ #  # ]:          0 :     aSuggestedName = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsName" ) ), ::rtl::OUString() );
    1485         [ #  # ]:          0 :         if ( aSuggestedName.isEmpty() )
    1486 [ #  # ][ #  # ]:          0 :             aSuggestedName = aModelData.GetDocProps().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsName" ) ), ::rtl::OUString() );
                 [ #  # ]
    1487                 :            : 
    1488                 :          0 :         ::rtl::OUString sStandardDir;
    1489                 :            :         ::comphelper::SequenceAsHashMap::const_iterator aStdDirIter =
    1490 [ #  # ][ #  # ]:          0 :             aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StandardDir")) );
    1491 [ #  # ][ #  # ]:          0 :         if ( aStdDirIter != aModelData.GetMediaDescr().end() )
    1492         [ #  # ]:          0 :             aStdDirIter->second >>= sStandardDir;
    1493                 :            : 
    1494         [ #  # ]:          0 :         ::com::sun::star::uno::Sequence< ::rtl::OUString >  aBlackList;
    1495                 :            : 
    1496                 :            :         ::comphelper::SequenceAsHashMap::const_iterator aBlackListIter =
    1497 [ #  # ][ #  # ]:          0 :             aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BlackList")) );
    1498 [ #  # ][ #  # ]:          0 :         if ( aBlackListIter != aModelData.GetMediaDescr().end() )
    1499 [ #  # ][ #  # ]:          0 :             aBlackListIter->second >>= aBlackList;
    1500                 :            : 
    1501                 :          0 :         sal_Bool bExit = sal_False;
    1502         [ #  # ]:          0 :         while ( !bExit )
    1503                 :            :         {
    1504                 :            :             // in case the dialog is opened a second time the folder should be the same as previously navigated to by the user, not what was handed over by initial parameters
    1505 [ #  # ][ #  # ]:          0 :             bUseFilterOptions = aModelData.OutputFileDialog( nStoreMode, aFilterProps, bSetStandardName, aSuggestedName, bPreselectPassword, aSuggestedDir, nDialog, sStandardDir, aBlackList );
                 [ #  # ]
    1506         [ #  # ]:          0 :             if ( nStoreMode == SAVEAS_REQUESTED )
    1507                 :            :             {
    1508                 :            :                 // in case of saving check filter for possible alien warning
    1509                 :          0 :                 ::rtl::OUString aSelFilterName = aModelData.GetMediaDescr().getUnpackedValueOrDefault(
    1510                 :            :                                                                                 sFilterNameString,
    1511         [ #  # ]:          0 :                                                                                 ::rtl::OUString() );
    1512         [ #  # ]:          0 :                 sal_Int8 nStatusFilterSave = aModelData.CheckFilter( aSelFilterName );
    1513         [ #  # ]:          0 :                 if ( nStatusFilterSave == STATUS_SAVEAS_STANDARDNAME )
    1514                 :            :                 {
    1515                 :            :                     // switch to best filter
    1516                 :          0 :                     bSetStandardName = sal_True;
    1517                 :            :                 }
    1518         [ #  # ]:          0 :                 else if ( nStatusFilterSave == STATUS_SAVE )
    1519                 :            :                 {
    1520                 :            :                     // user confirmed alien filter or "good" filter is used
    1521                 :          0 :                     bExit = sal_True;
    1522                 :          0 :                 }
    1523                 :            :             }
    1524                 :            :             else
    1525                 :          0 :                 bExit = sal_True;
    1526                 :            :         }
    1527                 :            : 
    1528                 :          0 :         bDialogUsed = sal_True;
    1529 [ #  # ][ #  # ]:          0 :         aFileNameIter = aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) );
                 [ #  # ]
    1530                 :            :     }
    1531                 :            :     else
    1532                 :            :     {
    1533                 :            :         // the target file name is provided so check if new filter options
    1534                 :            :         // are provided or old options can be used
    1535         [ #  # ]:          0 :         if ( aFilterFromMediaDescr.equals( aOldFilterName ) )
    1536                 :            :         {
    1537                 :            :             ::comphelper::SequenceAsHashMap::const_iterator aIter =
    1538 [ #  # ][ #  # ]:          0 :                                             aModelData.GetDocProps().find( sFilterOptionsString );
    1539 [ #  # ][ #  # ]:          0 :             if ( aIter != aModelData.GetDocProps().end()
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1540 [ #  # ][ #  # ]:          0 :               && aModelData.GetMediaDescr().find( sFilterOptionsString ) == aModelData.GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1541 [ #  # ][ #  # ]:          0 :                 aModelData.GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1542                 :            : 
    1543 [ #  # ][ #  # ]:          0 :             aIter = aModelData.GetDocProps().find( sFilterDataString );
    1544 [ #  # ][ #  # ]:          0 :             if ( aIter != aModelData.GetDocProps().end()
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1545 [ #  # ][ #  # ]:          0 :               && aModelData.GetMediaDescr().find( sFilterDataString ) == aModelData.GetMediaDescr().end() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1546 [ #  # ][ #  # ]:          0 :                 aModelData.GetMediaDescr()[aIter->first] = aIter->second;
                 [ #  # ]
    1547                 :            :         }
    1548                 :            :     }
    1549                 :            : 
    1550 [ #  # ][ #  # ]:          0 :     if ( aFileNameIter != aModelData.GetMediaDescr().end() )
    1551                 :            :     {
    1552                 :          0 :         ::rtl::OUString aFileName;
    1553         [ #  # ]:          0 :         aFileNameIter->second >>= aFileName;
    1554         [ #  # ]:          0 :         aURL.SetURL( aFileName );
    1555                 :            :         DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL!" );
    1556                 :            : 
    1557                 :            :         ::comphelper::SequenceAsHashMap::const_iterator aIter =
    1558         [ #  # ]:          0 :                                 aModelData.GetMediaDescr().find( sFilterNameString );
    1559                 :            : 
    1560 [ #  # ][ #  # ]:          0 :         if ( aIter != aModelData.GetMediaDescr().end() )
    1561         [ #  # ]:          0 :             aIter->second >>= aFilterName;
    1562                 :            :         else
    1563 [ #  # ][ #  # ]:          0 :             aModelData.GetMediaDescr()[sFilterNameString] <<= aFilterName;
    1564                 :            : 
    1565                 :          0 :         DBG_ASSERT( !aFilterName.isEmpty(), "Illegal filter!" );
    1566                 :            :     }
    1567                 :            :     else
    1568                 :            :     {
    1569                 :            :         DBG_ASSERT( sal_False, "This code must be unreachable!\n" );
    1570                 :            :         throw task::ErrorCodeIOException( ::rtl::OUString(),
    1571                 :            :                                             uno::Reference< uno::XInterface >(),
    1572         [ #  # ]:          0 :                                             ERRCODE_IO_INVALIDPARAMETER );
    1573                 :            :     }
    1574                 :            : 
    1575                 :            :     ::comphelper::SequenceAsHashMap::const_iterator aIter =
    1576 [ #  # ][ #  # ]:          0 :                             aModelData.GetMediaDescr().find( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterFlags")) );
    1577         [ #  # ]:          0 :     sal_Bool bFilterFlagsSet = ( aIter != aModelData.GetMediaDescr().end() );
    1578                 :            : 
    1579 [ #  # ][ #  # ]:          0 :     if( !( nStoreMode & PDFEXPORT_REQUESTED ) && !bFilterFlagsSet
         [ #  # ][ #  # ]
    1580                 :            :         && ( ( nStoreMode & EXPORT_REQUESTED ) || bUseFilterOptions ) )
    1581                 :            :     {
    1582                 :            :         // execute filter options dialog
    1583 [ #  # ][ #  # ]:          0 :         if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) )
    1584                 :          0 :             bDialogUsed = sal_True;
    1585                 :            :     }
    1586                 :            : 
    1587                 :            :     // so the arguments will not change any more and can be stored to the main location
    1588 [ #  # ][ #  # ]:          0 :     aArgsSequence = aModelData.GetMediaDescr().getAsConstPropertyValueList();
                 [ #  # ]
    1589                 :            : 
    1590                 :            :     // store the document and handle it's docinfo
    1591         [ #  # ]:          0 :     SvtSaveOptions aOptions;
    1592                 :            : 
    1593 [ #  # ][ #  # ]:          0 :     DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), nStoreMode & EXPORT_REQUESTED );
    1594                 :            : 
    1595                 :            :     OSL_ENSURE( aModelData.GetMediaDescr().find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Password" ) ) ) == aModelData.GetMediaDescr().end(), "The Password property of MediaDescriptor should not be used here!" );
    1596 [ #  # ][ #  # ]:          0 :     if ( aOptions.IsDocInfoSave()
         [ #  # ][ #  # ]
                 [ #  # ]
    1597 [ #  # ][ #  # ]:          0 :       && ( !aModelData.GetStorable()->hasLocation()
         [ #  # ][ #  # ]
                 [ #  # ]
    1598 [ #  # ][ #  # ]:          0 :           || INetURLObject( aModelData.GetStorable()->getLocation() ) != aURL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1599                 :            :     {
    1600                 :            :         // this is defenitly not a Save operation
    1601                 :            :         // so the document info can be updated
    1602                 :            : 
    1603                 :            :         // on export document info must be preserved
    1604                 :            :         uno::Reference<document::XDocumentInfoSupplier> xDIS(
    1605 [ #  # ][ #  # ]:          0 :             aModelData.GetModel(), uno::UNO_QUERY_THROW);
    1606                 :            :         uno::Reference<util::XCloneable> xCloneable(
    1607 [ #  # ][ #  # ]:          0 :             xDIS->getDocumentInfo(), uno::UNO_QUERY_THROW);
                 [ #  # ]
    1608                 :            :         uno::Reference<document::XDocumentInfo> xOldDocInfo(
    1609 [ #  # ][ #  # ]:          0 :             xCloneable->createClone(), uno::UNO_QUERY_THROW);
                 [ #  # ]
    1610                 :            : 
    1611                 :            :         // use dispatch API to show document info dialog
    1612 [ #  # ][ #  # ]:          0 :         if ( aModelData.ShowDocumentInfoDialog() )
    1613                 :          0 :             bDialogUsed = sal_True;
    1614                 :            :         else
    1615                 :            :         {
    1616                 :            :             OSL_FAIL( "Can't execute document info dialog!\n" );
    1617                 :            :         }
    1618                 :            : 
    1619                 :            :         try {
    1620                 :            :             // Document properties can contain streams that should be freed before storing
    1621         [ #  # ]:          0 :             aModelData.FreeDocumentProps();
    1622         [ #  # ]:          0 :             if ( ( nStoreMode & EXPORT_REQUESTED ) )
    1623 [ #  # ][ #  # ]:          0 :                 aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence );
         [ #  # ][ #  # ]
    1624                 :            :             else
    1625 [ #  # ][ #  # ]:          0 :                 aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence );
         [ #  # ][ #  # ]
    1626                 :            :         }
    1627         [ #  # ]:          0 :         catch( const uno::Exception& )
    1628                 :            :         {
    1629         [ #  # ]:          0 :             if ( ( nStoreMode & EXPORT_REQUESTED ) )
    1630   [ #  #  #  # ]:          0 :                 SetDocInfoState( aModelData.GetModel(), xOldDocInfo, sal_True );
    1631                 :            : 
    1632                 :          0 :             throw;
    1633                 :            :         }
    1634                 :            : 
    1635         [ #  # ]:          0 :         if ( ( nStoreMode & EXPORT_REQUESTED ) )
    1636 [ #  # ][ #  # ]:          0 :             SetDocInfoState( aModelData.GetModel(), xOldDocInfo, sal_True );
    1637                 :            :     }
    1638                 :            :     else
    1639                 :            :     {
    1640                 :            :         // Document properties can contain streams that should be freed before storing
    1641         [ #  # ]:          0 :         aModelData.FreeDocumentProps();
    1642                 :            : 
    1643                 :            :         // this is actually a save operation with different parameters
    1644                 :            :         // so storeTo or storeAs without DocInfo operations are used
    1645         [ #  # ]:          0 :         if ( ( nStoreMode & EXPORT_REQUESTED ) )
    1646 [ #  # ][ #  # ]:          0 :             aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence );
         [ #  # ][ #  # ]
    1647                 :            :         else
    1648 [ #  # ][ #  # ]:          0 :             aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence );
         [ #  # ][ #  # ]
    1649                 :            :     }
    1650                 :            : 
    1651 [ #  # ][ #  # ]:          0 :     return bDialogUsed;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1652                 :            : }
    1653                 :            : 
    1654                 :            : //-------------------------------------------------------------------------
    1655                 :            : // static
    1656                 :          0 : sal_Bool SfxStoringHelper::CheckFilterOptionsAppearence(
    1657                 :            :                                                     const uno::Reference< container::XNameAccess >& xFilterCFG,
    1658                 :            :                                                     const ::rtl::OUString& aFilterName )
    1659                 :            : {
    1660                 :          0 :     sal_Bool bUseFilterOptions = sal_False;
    1661                 :            : 
    1662                 :            :     DBG_ASSERT( xFilterCFG.is(), "No filter configuration!\n" );
    1663         [ #  # ]:          0 :     if( xFilterCFG.is() )
    1664                 :            :     {
    1665                 :            :         try {
    1666         [ #  # ]:          0 :                uno::Sequence < beans::PropertyValue > aProps;
    1667 [ #  # ][ #  # ]:          0 :             uno::Any aAny = xFilterCFG->getByName( aFilterName );
    1668 [ #  # ][ #  # ]:          0 :                if ( aAny >>= aProps )
    1669                 :            :                {
    1670         [ #  # ]:          0 :                 ::comphelper::SequenceAsHashMap aPropsHM( aProps );
    1671                 :            :                    ::rtl::OUString aServiceName = aPropsHM.getUnpackedValueOrDefault(
    1672                 :            :                                                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIComponent")),
    1673 [ #  # ][ #  # ]:          0 :                                                     ::rtl::OUString() );
    1674         [ #  # ]:          0 :                 if( !aServiceName.isEmpty() )
    1675         [ #  # ]:          0 :                        bUseFilterOptions = sal_True;
    1676 [ #  # ][ #  # ]:          0 :             }
    1677                 :            :         }
    1678                 :          0 :         catch( const uno::Exception& )
    1679                 :            :         {
    1680                 :            :         }
    1681                 :            :     }
    1682                 :            : 
    1683                 :          0 :     return bUseFilterOptions;
    1684                 :            : }
    1685                 :            : 
    1686                 :            : //-------------------------------------------------------------------------
    1687                 :            : // static
    1688                 :          0 : void SfxStoringHelper::SetDocInfoState(
    1689                 :            :         const uno::Reference< frame::XModel >& xModel,
    1690                 :            :         const uno::Reference< document::XDocumentInfo >& i_xOldDocInfo,
    1691                 :            :         sal_Bool bNoModify )
    1692                 :            : {
    1693         [ #  # ]:          0 :     uno::Reference< document::XDocumentInfoSupplier > xModelDocInfoSupplier( xModel, uno::UNO_QUERY );
    1694         [ #  # ]:          0 :     if ( !xModelDocInfoSupplier.is() )
    1695         [ #  # ]:          0 :         throw uno::RuntimeException(); // TODO:
    1696                 :            : 
    1697 [ #  # ][ #  # ]:          0 :     uno::Reference< document::XDocumentInfo > xDocInfoToFill = xModelDocInfoSupplier->getDocumentInfo();
    1698                 :            :     uno::Reference< beans::XPropertySet > xPropSet( i_xOldDocInfo,
    1699         [ #  # ]:          0 :         uno::UNO_QUERY_THROW );
    1700                 :            : 
    1701         [ #  # ]:          0 :     uno::Reference< util::XModifiable > xModifiable( xModel, uno::UNO_QUERY );
    1702 [ #  # ][ #  # ]:          0 :     if ( bNoModify && !xModifiable.is() )
                 [ #  # ]
    1703 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException();
    1704                 :            : 
    1705 [ #  # ][ #  # ]:          0 :     sal_Bool bIsModified = bNoModify && xModifiable->isModified();
         [ #  # ][ #  # ]
    1706                 :            : 
    1707                 :            :     try
    1708                 :            :     {
    1709         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xSet( xDocInfoToFill, uno::UNO_QUERY );
    1710         [ #  # ]:          0 :         uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY );
    1711 [ #  # ][ #  # ]:          0 :         uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
    1712 [ #  # ][ #  # ]:          0 :         uno::Sequence< beans::Property > lProps = xSetInfo->getProperties();
    1713                 :          0 :         const beans::Property* pProps = lProps.getConstArray();
    1714                 :          0 :         sal_Int32 c = lProps.getLength();
    1715                 :          0 :         sal_Int32 i = 0;
    1716         [ #  # ]:          0 :         for (i=0; i<c; ++i)
    1717                 :            :         {
    1718 [ #  # ][ #  # ]:          0 :             uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name );
    1719         [ #  # ]:          0 :             if ( pProps[i].Attributes & ::com::sun::star::beans::PropertyAttribute::REMOVABLE )
    1720                 :            :                 // QUESTION: DefaultValue?!
    1721 [ #  # ][ #  # ]:          0 :                 xContainer->addProperty( pProps[i].Name, pProps[i].Attributes, aValue );
    1722                 :            :             try
    1723                 :            :             {
    1724                 :            :                 // it is possible that the propertysets from XML and binary files differ; we shouldn't break then
    1725 [ #  # ][ #  # ]:          0 :                 xSet->setPropertyValue( pProps[i].Name, aValue );
    1726                 :            :             }
    1727         [ #  # ]:          0 :             catch ( const uno::Exception& ) {}
    1728                 :          0 :         }
    1729                 :            : 
    1730 [ #  # ][ #  # ]:          0 :         sal_Int16 nCount = i_xOldDocInfo->getUserFieldCount();
    1731 [ #  # ][ #  # ]:          0 :         sal_Int16 nSupportedCount = xDocInfoToFill->getUserFieldCount();
    1732 [ #  # ][ #  # ]:          0 :         for ( sal_Int16 nInd = 0; nInd < nCount && nInd < nSupportedCount; nInd++ )
                 [ #  # ]
    1733                 :            :         {
    1734 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aPropName = i_xOldDocInfo->getUserFieldName( nInd );
    1735 [ #  # ][ #  # ]:          0 :             xDocInfoToFill->setUserFieldName( nInd, aPropName );
    1736 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aPropVal = i_xOldDocInfo->getUserFieldValue( nInd );
    1737 [ #  # ][ #  # ]:          0 :             xDocInfoToFill->setUserFieldValue( nInd, aPropVal );
    1738 [ #  # ][ #  # ]:          0 :         }
    1739                 :            :     }
    1740         [ #  # ]:          0 :     catch ( const uno::Exception& ) {}
    1741                 :            : 
    1742                 :            :     // set the modified flag back if required
    1743 [ #  # ][ #  # ]:          0 :     if ( bNoModify && bIsModified != xModifiable->isModified() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1744 [ #  # ][ #  # ]:          0 :         xModifiable->setModified( bIsModified );
    1745                 :          0 : }
    1746                 :            : 
    1747                 :            : //-------------------------------------------------------------------------
    1748                 :            : // static
    1749                 :          0 : sal_Bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XModel >& xModel,
    1750                 :            :                                                     ::rtl::OUString aOldUIName,
    1751                 :            :                                                     ::rtl::OUString /*aDefUIName*/,
    1752                 :            :                                                     sal_Bool /*bCanProceedFurther*/ )
    1753                 :            : {
    1754 [ #  # ][ #  # ]:          0 :     if ( !SvtSaveOptions().IsWarnAlienFormat() )
         [ #  # ][ #  # ]
    1755                 :          0 :         return sal_True;
    1756                 :            : 
    1757         [ #  # ]:          0 :     Window* pWin = SfxStoringHelper::GetModelWindow( xModel );
    1758 [ #  # ][ #  # ]:          0 :     SfxAlienWarningDialog aDlg( pWin, aOldUIName );
                 [ #  # ]
    1759                 :            : 
    1760 [ #  # ][ #  # ]:          0 :     return aDlg.Execute() == RET_OK;
    1761                 :            : }
    1762                 :            : 
    1763                 :          0 : Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel )
    1764                 :            : {
    1765                 :          0 :     Window* pWin = 0;
    1766                 :            :     try {
    1767         [ #  # ]:          0 :         if ( xModel.is() )
    1768                 :            :         {
    1769 [ #  # ][ #  # ]:          0 :             uno::Reference< frame::XController > xController = xModel->getCurrentController();
    1770         [ #  # ]:          0 :             if ( xController.is() )
    1771                 :            :             {
    1772 [ #  # ][ #  # ]:          0 :                 uno::Reference< frame::XFrame > xFrame = xController->getFrame();
    1773         [ #  # ]:          0 :                 if ( xFrame.is() )
    1774                 :            :                 {
    1775 [ #  # ][ #  # ]:          0 :                     uno::Reference< awt::XWindow > xWindow = xFrame->getContainerWindow();
    1776         [ #  # ]:          0 :                     if ( xWindow.is() )
    1777                 :            :                     {
    1778                 :          0 :                         VCLXWindow* pVCLWindow = VCLXWindow::GetImplementation( xWindow );
    1779         [ #  # ]:          0 :                         if ( pVCLWindow )
    1780                 :          0 :                             pWin = pVCLWindow->GetWindow();
    1781                 :          0 :                     }
    1782                 :          0 :                 }
    1783         [ #  # ]:          0 :             }
    1784                 :            :         }
    1785                 :            :     }
    1786                 :          0 :     catch ( const uno::Exception& )
    1787                 :            :     {
    1788                 :            :     }
    1789                 :            : 
    1790                 :          0 :     return pWin;
    1791                 :            : }
    1792                 :            : 
    1793                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10