LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgass.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 936 0.0 %
Date: 2014-11-03 Functions: 0 82 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/presentation/ClickAction.hpp>
      21             : #include <vcl/svapp.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <vcl/msgbox.hxx>
      24             : #include <vcl/lstbox.hxx>
      25             : #include <vcl/combobox.hxx>
      26             : #include <vcl/layout.hxx>
      27             : #include <sfx2/doctempl.hxx>
      28             : #include <svl/lstner.hxx>
      29             : #include <sfx2/objsh.hxx>
      30             : #include <svtools/ehdl.hxx>
      31             : #include <svtools/sfxecode.hxx>
      32             : #include <tools/urlobj.hxx>
      33             : #include <com/sun/star/presentation/FadeEffect.hpp>
      34             : #include <fadedef.h>
      35             : #include <sfx2/sfxsids.hrc>
      36             : #include <svl/undo.hxx>
      37             : #include "DrawDocShell.hxx"
      38             : #include <vcl/gdimtf.hxx>
      39             : #include <tools/wintypes.hxx>
      40             : #include "docprev.hxx"
      41             : #include <sfx2/app.hxx>
      42             : #include <sfx2/docfile.hxx>
      43             : #include <sfx2/dispatch.hxx>
      44             : #include <sfx2/request.hxx>
      45             : #include <com/sun/star/sdbc/XResultSet.hpp>
      46             : #include <com/sun/star/lang/XComponent.hpp>
      47             : #include <com/sun/star/util/XCloseable.hpp>
      48             : #include <com/sun/star/uno/RuntimeException.hpp>
      49             : #include <com/sun/star/frame/XModuleManager.hpp>
      50             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      51             : #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
      52             : #include <com/sun/star/ui/XImageManager.hpp>
      53             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      54             : #include <com/sun/star/frame/theUICommandDescription.hpp>
      55             : #include <unotools/historyoptions.hxx>
      56             : #include <osl/file.hxx>
      57             : #include <sfx2/filedlghelper.hxx>
      58             : 
      59             : #include "sdpage.hxx"
      60             : #include "helpids.h"
      61             : #include "assclass.hxx"
      62             : #include "dlgass.hxx"
      63             : #include "dlgctrls.hxx"
      64             : #include "strings.hrc"
      65             : #include "dlgassim.hxx"
      66             : #include "TemplateScanner.hxx"
      67             : #include "WindowUpdater.hxx"
      68             : 
      69             : #include <comphelper/processfactory.hxx>
      70             : #include <vector>
      71             : #include <boost/ptr_container/ptr_vector.hpp>
      72             : 
      73             : using namespace ::com::sun::star;
      74             : using namespace ::com::sun::star::uno;
      75             : using namespace ::sd;
      76             : 
      77             : using ::std::vector;
      78             : 
      79           0 : class PasswordEntry
      80             : {
      81             : public:
      82             :     uno::Sequence< beans::NamedValue > aEncryptionData;
      83             :     OUString maPath;
      84             : };
      85             : 
      86             : /** A simple wrapper that looks like a PushButton and is used to force the
      87             :     broadcasting of focus events primarily for accessibility tools.
      88             :     Forcing focus events is achieved by using two identical PushButtons
      89             :     which, when the focus event is requested, are exchanged and play focus
      90             :     ping-pong by moving the focus from one to the other.
      91             : */
      92             : class NextButton
      93             : {
      94             : public:
      95             :     NextButton (vcl::Window* pParent);
      96             : 
      97             :     void ForceFocusEventBroadcast (void);
      98             :     void SetClickHdl (const Link& rLink);
      99             :     bool IsEnabled (void);
     100             :     void Enable (bool bEnable);
     101             : 
     102             : private:
     103             :     PushButton* mpNextButton1;
     104             :     PushButton* mpNextButton2;
     105             :     bool mbIsFirstButtonActive;
     106             : };
     107             : 
     108             : class AssistentDlgImpl : public SfxListener
     109             : {
     110             : public:
     111             :     AssistentDlgImpl( vcl::Window* pWindow, const Link& rFinishLink, bool bAutoPilot  );
     112             :     virtual ~AssistentDlgImpl();
     113             : 
     114             :     /// Local mutex used to serialize concurrent method calls.
     115             :     ::osl::Mutex maMutex;
     116             : 
     117             :     SfxObjectShellLock GetDocument();
     118             : 
     119             :     /** closes the current preview docshell */
     120             :     void CloseDocShell();
     121             : 
     122             :     /** Extract form the history list of recently used files the impress
     123             :         files and insert them into a listbox.
     124             :     */
     125             :     void    ScanDocmenu         (void);
     126             :     /** Flag that is set to sal_True after the recently used files have been
     127             :         scanned.
     128             :     */
     129             :     bool mbRecentDocumentsReady;
     130             : 
     131             :     /** When the list of templates has not been scanned already this is done
     132             :         when this method is called.  That includes requesting the whole list
     133             :         of templates from UCB and extracting from that list the impress
     134             :         templates and layouts and storing them for later use in
     135             :         <member>maPresentList</member>.  Note that the first call to this
     136             :         method after installing a new Office may take some time.
     137             :     */
     138             :     void ProvideTemplates (void);
     139             : 
     140             :     /** This method transfers the template folders from the template scanner
     141             :         to the internal structures of this class.  On termination it sets
     142             :         the flag <member>mbTemplatesReady</member> to <TRUE/> to indicate
     143             :         that the templates are available.
     144             :         @param rTemplateFolders
     145             :             This is a list of template folders.  This method takes ownership
     146             :             of the supplied entries by removing them from the list and
     147             :             transferring them to an internal structure.
     148             :     */
     149             :     void TemplateScanDone (std::vector<TemplateDir*>& rTemplateFolders);
     150             : 
     151             :     /** Flag that is set to sal_True after the impress templates have been
     152             :         scanned.
     153             :     */
     154             :     bool mbTemplatesReady;
     155             : 
     156             :     /** Flag used to prevent nested or concurrent calls to the
     157             :         <member>UpdatePreview</memember> method.  A <TRUE/> value indicates
     158             :         that a preview update is currently active.
     159             :     */
     160             :     bool mbPreviewUpdating;
     161             : 
     162             :     vcl::Window* mpWindow;
     163             : 
     164             :     void SavePassword( SfxObjectShellLock xDoc, const OUString& rPath );
     165             :     void RestorePassword( SfxItemSet* pSet, const OUString& rPath );
     166             :     uno::Sequence < beans::NamedValue > GetPassword( const OUString& rPath );
     167             :     void DeletePasswords();
     168             : 
     169             :     boost::ptr_vector< PasswordEntry > maPasswordList;
     170             : 
     171             :     OUString maDocFile;
     172             :     OUString maLayoutFile;
     173             : 
     174             :     OUString GetDocFileName();
     175             :     OUString GetLayoutFileName();
     176             : 
     177             :     /// List of URLs of recently used impress files.
     178             :     std::vector<OUString> maOpenFilesList;
     179             : 
     180             :     /// List of folders containing data about impress templates.
     181             :     std::vector<TemplateDir*> maPresentList;
     182             : 
     183             :     /// Currently selected template folder.
     184             :     TemplateDir* mpTemplateRegion;
     185             : 
     186             :     /// Currently selected layout folder.
     187             :     TemplateDir* mpLayoutRegion;
     188             : 
     189             :     // preview
     190             :     bool mbUserDataDirty;
     191             :     Timer maPrevTimer;
     192             :     Timer maEffectPrevTimer;
     193             :     Timer maUpdatePageListTimer;
     194             :     Timer maStartScanTimer;
     195             : 
     196             :     SfxObjectShellLock xDocShell;
     197             : 
     198             :     ::std::unique_ptr<WindowUpdater> mpWindowUpdater;
     199             : 
     200             :     bool mbPreview;
     201             :     sal_uInt16 mnShowPage;
     202             :     bool mbDocPreview;
     203             : 
     204             :     OUString maPageListFile;
     205             : 
     206             :     void UpdatePreview( bool bDocPreview );
     207             :     void UpdatePageList();
     208             :     void UpdateUserData();
     209             : 
     210             :     bool IsOwnFormat( const OUString& rPath );
     211             : 
     212             :     // dlg status
     213             :     void EndDialog( long nResult = 0 );
     214             : 
     215             :     void SetStartType( StartType eType );
     216             :     StartType GetStartType();
     217             : 
     218             :     void SelectTemplateRegion( const OUString& rRegion );
     219             :     void SelectLayoutRegion( const OUString& rRegion );
     220             : 
     221             :     void UpdatePage();
     222             :     void ChangePage();
     223             :     void LeavePage();
     224             : 
     225             :     OUString GetUiTextForCommand (const OUString& aCommandURL);
     226             :     Image GetUiIconForCommand (const OUString& aCommandURL);
     227             : 
     228             :     DECL_LINK( SelectFileHdl, void * );
     229             :     DECL_LINK( SelectRegionHdl, ListBox * );
     230             :     DECL_LINK( UpdatePreviewHdl, void * );
     231             :     DECL_LINK( UpdatePageListHdl, void * );
     232             :     DECL_LINK( StartTypeHdl, RadioButton * );
     233             :     DECL_LINK( SelectTemplateHdl, void * );
     234             :     DECL_LINK( NextPageHdl, void * );
     235             :     DECL_LINK( LastPageHdl, void * );
     236             :     DECL_LINK( PreviewFlagHdl, void * );
     237             :     DECL_LINK( EffectPreviewHdl, void * );
     238             :     DECL_LINK( SelectLayoutHdl, void * );
     239             :     DECL_LINK( PageSelectHdl, void * );
     240             :     DECL_LINK( PresTypeHdl, void * );
     241             :     DECL_LINK( UpdateUserDataHdl, void * );
     242             :     DECL_LINK( SelectEffectHdl, void* );
     243             :     DECL_LINK( OpenButtonHdl, Button * );
     244             : 
     245             :     OUString            maCreateStr;
     246             :     OUString            maOpenStr;
     247             : 
     248             :     // Common
     249             :     Assistent           maAssistentFunc;
     250             :     CheckBox*           mpPreviewFlag;
     251             :     CheckBox*           mpStartWithFlag;
     252             :     PushButton*         mpLastPageButton;
     253             :     NextButton*         mpNextPageButton;
     254             :     PushButton*         mpFinishButton;
     255             :     SdDocPreviewWin*    mpPreview;
     256             :     VclContainer*       mpPage1235;
     257             : 
     258             :     // page 1
     259             :     VclContainer*       mpPage1;
     260             :     FixedImage*         mpPage1FB;
     261             :     FixedText*          mpPage1ArtFL;
     262             :     RadioButton*        mpPage1EmptyRB;
     263             :     RadioButton*        mpPage1TemplateRB;
     264             :     ListBox*            mpPage1RegionLB;
     265             :     ListBox*            mpPage1TemplateLB;
     266             :     RadioButton*        mpPage1OpenRB;
     267             :     ListBox*            mpPage1OpenLB;
     268             :     PushButton*         mpPage1OpenPB;
     269             : 
     270             :     // page 2
     271             :     VclContainer*       mpPage2;
     272             :     FixedImage*         mpPage2FB;
     273             :     FixedText*          mpPage2LayoutFL;
     274             :     ListBox*            mpPage2RegionLB;
     275             :     ListBox*            mpPage2LayoutLB;
     276             :     FixedText*          mpPage2OutTypesFL;
     277             :     RadioButton*        mpPage2Medium1RB;
     278             :     RadioButton*        mpPage2Medium2RB;
     279             :     RadioButton*        mpPage2Medium3RB;
     280             :     RadioButton*        mpPage2Medium4RB;
     281             :     RadioButton*        mpPage2Medium5RB;
     282             :     RadioButton*        mpPage2Medium6RB;
     283             : 
     284             :     // page 3
     285             :     VclContainer*       mpPage3;
     286             :     FixedImage*         mpPage3FB;
     287             :     FixedText*          mpPage3EffectFL;
     288             :     FixedText*          mpPage3EffectFT;
     289             :     FadeEffectLB*       mpPage3EffectLB;
     290             :     FixedText*          mpPage3SpeedFT;
     291             :     ListBox*            mpPage3SpeedLB;
     292             :     FixedText*          mpPage3PresTypeFL;
     293             :     RadioButton*        mpPage3PresTypeLiveRB;
     294             :     RadioButton*        mpPage3PresTypeKioskRB;
     295             :     FixedText*          mpPage3PresTimeFT;
     296             :     TimeField*          mpPage3PresTimeTMF;
     297             :     FixedText*          mpPage3BreakFT;
     298             :     TimeField*          mpPage3BreakTMF;
     299             :     CheckBox*           mpPage3LogoCB;
     300             : 
     301             :     // page 4
     302             :     VclContainer*       mpPage4;
     303             :     FixedImage*         mpPage4FB;
     304             :     FixedText*          mpPage4PersonalFL;
     305             :     FixedText*          mpPage4AskNameFT;
     306             :     Edit*               mpPage4AskNameEDT;
     307             :     FixedText*          mpPage4AskTopicFT;
     308             :     Edit*               mpPage4AskTopicEDT;
     309             :     FixedText*          mpPage4AskInfoFT;
     310             :     VclMultiLineEdit*      mpPage4AskInfoEDT;
     311             : 
     312             :     // page 5
     313             :     VclContainer*       mpPage5;
     314             :     FixedImage*         mpPage5FB;
     315             :     FixedText*          mpPage5PageListFT;
     316             :     SdPageListControl*  mpPage5PageListCT;
     317             :     CheckBox*           mpPage5SummaryCB;
     318             : 
     319             : };
     320             : 
     321           0 : AssistentDlgImpl::AssistentDlgImpl( vcl::Window* pWindow, const Link& rFinishLink, bool bAutoPilot ) :
     322             :     mpTemplateRegion(NULL),
     323             :     mpLayoutRegion(NULL),
     324             :     mbUserDataDirty(false),
     325             :     xDocShell (NULL),
     326           0 :     mpWindowUpdater (new WindowUpdater()),
     327             :     mbPreview(true),
     328             :     mnShowPage(0),
     329             :     mbDocPreview(false),
     330           0 :     maAssistentFunc(5)
     331             : {
     332           0 :     AssistentDlg* assDlg = static_cast<AssistentDlg*>(pWindow);
     333           0 :     assDlg->get(mpPreviewFlag, "previewCheckbutton");
     334           0 :     assDlg->get(mpStartWithFlag, "startWithCheckbutton");
     335           0 :     assDlg->get(mpLastPageButton, "lastPageButton");
     336           0 :     assDlg->get(mpFinishButton, "finishButton");
     337           0 :     maCreateStr = mpFinishButton->GetText();
     338           0 :     maOpenStr = assDlg->get<PushButton>("open")->GetText();
     339           0 :     assDlg->get(mpPreview, "previewControl");
     340           0 :     assDlg->get(mpPage1235, "page1235Box");
     341           0 :     mpNextPageButton = new NextButton( pWindow );
     342             : 
     343             :     //Lock down the preferred size based on the
     344             :     //initial max-size configuration
     345           0 :     assDlg->get(mpPage1TemplateLB, "templatesTreeview");
     346           0 :     assDlg->get(mpPage1OpenLB, "openTreeview");
     347           0 :     long nHeight = mpPage1TemplateLB->GetTextHeight() * 7;
     348           0 :     mpPage1TemplateLB->set_height_request(nHeight);
     349           0 :     mpPage1OpenLB->set_height_request(nHeight);
     350             : 
     351           0 :     assDlg->get(mpPage1, "page1Box");
     352           0 :     assDlg->get(mpPage2, "page2Box");
     353           0 :     assDlg->get(mpPage3, "page3Box");
     354           0 :     assDlg->get(mpPage4, "page4Frame");
     355           0 :     assDlg->get(mpPage5, "page5Box");
     356           0 :     Size aSize(mpPage1->get_preferred_size());
     357           0 :     mpPage1->set_height_request(aSize.Height());
     358           0 :     mpPage2->set_height_request(aSize.Height());
     359           0 :     mpPage3->set_height_request(aSize.Height());
     360           0 :     mpPage4->set_height_request(aSize.Height());
     361           0 :     mpPage5->set_height_request(aSize.Height());
     362           0 :     mpPage1->set_width_request(aSize.Width());
     363           0 :     mpPage2->set_width_request(aSize.Width());
     364           0 :     mpPage3->set_width_request(aSize.Width());
     365           0 :     mpPage4->set_width_request(aSize.Width());
     366           0 :     mpPage5->set_width_request(aSize.Width());
     367             : 
     368           0 :     aSize = assDlg->get_preferred_size();
     369           0 :     assDlg->set_width_request(aSize.Width());
     370           0 :     assDlg->set_height_request(aSize.Height());
     371             : 
     372           0 :     maPageListFile = "?";
     373           0 :     mbRecentDocumentsReady = false;
     374           0 :     mbTemplatesReady = false;
     375           0 :     mbPreviewUpdating = false;
     376             : 
     377           0 :     mpWindow = pWindow;
     378             : 
     379           0 :     if (bAutoPilot)
     380           0 :         mpStartWithFlag->Hide();
     381             :     else
     382           0 :         maAssistentFunc.InsertControl(1, mpStartWithFlag );
     383             : 
     384             :     // initialize page1 and give it to the assistant functionality
     385           0 :     assDlg->get(mpPage1FB, "header1Image");
     386           0 :     assDlg->get(mpPage1ArtFL, "typeLabel");
     387           0 :     assDlg->get(mpPage1EmptyRB, "emptyRadiobutton");
     388           0 :     assDlg->get(mpPage1TemplateRB, "templateRadiobutton");
     389           0 :     assDlg->get(mpPage1OpenRB, "openRadiobutton");
     390           0 :     assDlg->get(mpPage1RegionLB, "regionCombobox");
     391           0 :     assDlg->get(mpPage1OpenPB, "openButton");
     392           0 :     maAssistentFunc.InsertControl(1, mpPage1 );
     393           0 :     maAssistentFunc.InsertControl(1, mpPage1235 );
     394           0 :     maAssistentFunc.InsertControl(1, mpPreview );
     395           0 :     maAssistentFunc.InsertControl(1, mpPreviewFlag );
     396           0 :     maAssistentFunc.InsertControl(1, mpPage1FB );
     397           0 :     maAssistentFunc.InsertControl(1, mpPage1ArtFL );
     398           0 :     maAssistentFunc.InsertControl(1, mpPage1EmptyRB);
     399           0 :     maAssistentFunc.InsertControl(1, mpPage1TemplateRB );
     400           0 :     maAssistentFunc.InsertControl(1, mpPage1OpenRB );
     401           0 :     maAssistentFunc.InsertControl(1, mpPage1RegionLB );
     402           0 :     maAssistentFunc.InsertControl(1, mpPage1TemplateLB );
     403           0 :     maAssistentFunc.InsertControl(1, mpPage1OpenPB );
     404           0 :     maAssistentFunc.InsertControl(1, mpPage1OpenLB );
     405             : 
     406             :     // Set text and icon of the 'Open...' button.
     407             :     {
     408           0 :         OUString sText (GetUiTextForCommand(".uno:Open"));
     409             :         // Remove the mnemonic and add a leading space so that icon and text
     410             :         // are not too close together.
     411           0 :         sText = sText.replaceAll("~", "");
     412           0 :         sText = " " + sText;
     413           0 :         mpPage1OpenPB->SetText(sText);
     414             :         // Place icon left of text and both centered in the button.
     415             :         mpPage1OpenPB->SetModeImage(
     416             :             GetUiIconForCommand(".uno:Open")
     417           0 :         );
     418           0 :         mpPage1OpenPB->EnableImageDisplay(true);
     419           0 :         mpPage1OpenPB->EnableTextDisplay(true);
     420           0 :         mpPage1OpenPB->SetImageAlign(IMAGEALIGN_LEFT);
     421           0 :         mpPage1OpenPB->SetStyle(mpPage1OpenPB->GetStyle() | WB_CENTER);
     422             :     }
     423             : 
     424             :     // links&handler
     425           0 :     mpPage1RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
     426           0 :     mpPage1RegionLB->SetDropDownLineCount( 6 );
     427           0 :     mpPage1TemplateLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectTemplateHdl));
     428           0 :     mpPage1TemplateLB->SetStyle(mpPage1TemplateLB->GetStyle() | WB_SORT);
     429           0 :     mpPage1TemplateLB->InsertEntry(SD_RESSTR(STR_ISLOADING));
     430             : 
     431           0 :     mpPage1EmptyRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
     432           0 :     mpPage1TemplateRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
     433           0 :     mpPage1OpenRB->SetClickHdl(LINK(this,AssistentDlgImpl,StartTypeHdl));
     434           0 :     mpPage1OpenLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectFileHdl));
     435           0 :     mpPage1OpenLB->SetDoubleClickHdl(rFinishLink);
     436           0 :     mpPage1OpenPB->SetClickHdl(LINK(this,AssistentDlgImpl,OpenButtonHdl));
     437             : 
     438             :     // page 2
     439           0 :     assDlg->get(mpPage2FB, "header2Image");
     440           0 :     assDlg->get(mpPage2LayoutFL, "layout2Label");
     441           0 :     assDlg->get(mpPage2RegionLB, "page2RegionCombobox");
     442           0 :     assDlg->get(mpPage2LayoutLB, "layoutTreeview");
     443           0 :     maAssistentFunc.InsertControl(2, mpPage2 );
     444           0 :     maAssistentFunc.InsertControl(2, mpPage1235 );
     445           0 :     maAssistentFunc.InsertControl(2, mpPreview );
     446           0 :     maAssistentFunc.InsertControl(2, mpPreviewFlag );
     447           0 :     maAssistentFunc.InsertControl(2, mpPage2FB );
     448           0 :     maAssistentFunc.InsertControl(2, mpPage2LayoutFL );
     449           0 :     maAssistentFunc.InsertControl(2, mpPage2RegionLB );
     450           0 :     maAssistentFunc.InsertControl(2, mpPage2LayoutLB );
     451             : 
     452           0 :     assDlg->get(mpPage2OutTypesFL, "outTypesLabel");
     453           0 :     assDlg->get(mpPage2Medium5RB, "medium5Radiobutton");
     454           0 :     assDlg->get(mpPage2Medium3RB, "medium3Radiobutton");
     455           0 :     assDlg->get(mpPage2Medium4RB, "medium4Radiobutton");
     456           0 :     assDlg->get(mpPage2Medium1RB, "medium1Radiobutton");
     457           0 :     assDlg->get(mpPage2Medium2RB, "medium2Radiobutton");
     458           0 :     assDlg->get(mpPage2Medium6RB, "medium6Radiobutton");
     459           0 :     maAssistentFunc.InsertControl(2, mpPage2OutTypesFL );
     460           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium5RB );
     461           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium3RB );
     462           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium4RB );
     463           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium1RB );
     464           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium2RB );
     465           0 :     maAssistentFunc.InsertControl(2, mpPage2Medium6RB );
     466           0 :     mpPage2Medium5RB->Check();
     467             : 
     468           0 :     mpPage2RegionLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectRegionHdl));
     469           0 :     mpPage2RegionLB->SetDropDownLineCount( 6 );
     470           0 :     mpPage2LayoutLB->SetSelectHdl(LINK(this,AssistentDlgImpl,SelectLayoutHdl));
     471           0 :     mpPage2LayoutLB->SetStyle(mpPage2LayoutLB->GetStyle() | WB_SORT);
     472           0 :     mpPage2LayoutLB->InsertEntry(SD_RESSTR(STR_ISLOADING));
     473             : 
     474             :     // page 3
     475           0 :     assDlg->get(mpPage3FB, "header3Image");
     476           0 :     assDlg->get(mpPage3EffectFL, "page3EffectLabel");
     477           0 :     assDlg->get(mpPage3EffectFT, "effectLabel");
     478           0 :     assDlg->get(mpPage3EffectLB, "effectCombobox");
     479           0 :     assDlg->get(mpPage3SpeedFT, "speedLabel");
     480           0 :     assDlg->get(mpPage3SpeedLB, "speedCombobox");
     481           0 :     assDlg->get(mpPage3PresTypeFL, "presTypeLabel");
     482           0 :     assDlg->get(mpPage3PresTypeLiveRB, "liveRadiobutton");
     483           0 :     assDlg->get(mpPage3PresTypeKioskRB, "kioskRadiobutton");
     484           0 :     assDlg->get(mpPage3PresTimeFT, "presTimeLabel");
     485           0 :     assDlg->get(mpPage3PresTimeTMF, "timeSpinbutton");
     486           0 :     assDlg->get(mpPage3BreakFT, "breakLabel");
     487           0 :     assDlg->get(mpPage3BreakTMF, "breakSpinbutton");
     488           0 :     assDlg->get(mpPage3LogoCB, "logoCheckbutton");
     489             : 
     490           0 :     maAssistentFunc.InsertControl(3, mpPage3 );
     491           0 :     maAssistentFunc.InsertControl(3, mpPage1235 );
     492           0 :     maAssistentFunc.InsertControl(3, mpPreview );
     493           0 :     maAssistentFunc.InsertControl(3, mpPreviewFlag );
     494           0 :     maAssistentFunc.InsertControl(3, mpPage3FB );
     495           0 :     maAssistentFunc.InsertControl(3, mpPage3EffectFL );
     496           0 :     maAssistentFunc.InsertControl(3, mpPage3EffectFT );
     497           0 :     maAssistentFunc.InsertControl(3, mpPage3EffectLB );
     498           0 :     maAssistentFunc.InsertControl(3, mpPage3SpeedFT );
     499           0 :     maAssistentFunc.InsertControl(3, mpPage3SpeedLB );
     500           0 :     maAssistentFunc.InsertControl(3, mpPage3PresTypeFL );
     501           0 :     maAssistentFunc.InsertControl(3, mpPage3PresTypeLiveRB );
     502           0 :     maAssistentFunc.InsertControl(3, mpPage3PresTypeKioskRB );
     503           0 :     maAssistentFunc.InsertControl(3, mpPage3PresTimeFT );
     504           0 :     maAssistentFunc.InsertControl(3, mpPage3PresTimeTMF );
     505           0 :     maAssistentFunc.InsertControl(3, mpPage3BreakFT );
     506           0 :     maAssistentFunc.InsertControl(3, mpPage3BreakTMF );
     507           0 :     maAssistentFunc.InsertControl(3, mpPage3LogoCB );
     508             : 
     509           0 :     mpPage3EffectLB->Fill();
     510           0 :     mpPage3EffectLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
     511           0 :     mpPage3EffectLB->SetDropDownLineCount( 12 );
     512             : 
     513           0 :     mpPage3SpeedLB->InsertEntry( SD_RESSTR(STR_SLOW) );
     514           0 :     mpPage3SpeedLB->InsertEntry( SD_RESSTR(STR_MEDIUM) );
     515           0 :     mpPage3SpeedLB->InsertEntry( SD_RESSTR(STR_FAST) );
     516           0 :     mpPage3SpeedLB->SetDropDownLineCount( 3 );
     517           0 :     mpPage3SpeedLB->SetSelectHdl( LINK(this,AssistentDlgImpl,SelectEffectHdl ));
     518           0 :     mpPage3SpeedLB->SelectEntryPos( 1 );
     519             : 
     520           0 :     mpPage3PresTypeLiveRB->Check();
     521           0 :     mpPage3PresTypeLiveRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
     522           0 :     mpPage3PresTypeKioskRB->SetClickHdl( LINK(this,AssistentDlgImpl, PresTypeHdl ));
     523           0 :     mpPage3PresTimeTMF->SetFormat( TimeFieldFormat::F_SEC );
     524           0 :     mpPage3PresTimeTMF->SetTime( ::tools::Time( 0, 0, 10 ) );
     525           0 :     mpPage3BreakTMF->SetFormat( TimeFieldFormat::F_SEC );
     526           0 :     mpPage3BreakTMF->SetTime( ::tools::Time( 0, 0, 10 ) );
     527           0 :     mpPage3LogoCB->Check();
     528             : 
     529             :     // set cursor in timefield
     530           0 :     Edit *pEditPage3PresTimeTMF = mpPage3PresTimeTMF->GetField();
     531           0 :     Edit *pEditPage3BreakTMF = mpPage3BreakTMF->GetField();
     532           0 :     Selection aSel1( pEditPage3PresTimeTMF->GetMaxTextLen(), pEditPage3PresTimeTMF->GetMaxTextLen() );
     533           0 :     Selection aSel2( pEditPage3BreakTMF->GetMaxTextLen(), pEditPage3BreakTMF->GetMaxTextLen() );
     534           0 :     pEditPage3PresTimeTMF->SetSelection( aSel1 );
     535           0 :     pEditPage3BreakTMF->SetSelection( aSel2 );
     536             : 
     537             :     // page 4
     538           0 :     assDlg->get(mpPage4FB, "header4Image");
     539           0 :     assDlg->get(mpPage4PersonalFL, "personalLabel");
     540           0 :     assDlg->get(mpPage4AskNameFT, "askNameLabel");
     541           0 :     assDlg->get(mpPage4AskNameEDT, "askNameEntry");
     542           0 :     assDlg->get(mpPage4AskTopicFT, "askTopicLabel");
     543           0 :     assDlg->get(mpPage4AskTopicEDT, "askTopicEntry");
     544           0 :     assDlg->get(mpPage4AskInfoFT, "askInfoLabel");
     545           0 :     assDlg->get(mpPage4AskInfoEDT, "askInformationTextview");
     546           0 :     maAssistentFunc.InsertControl(4, mpPage4 );
     547           0 :     maAssistentFunc.InsertControl(4, mpPage4FB );
     548           0 :     maAssistentFunc.InsertControl(4, mpPage4PersonalFL );
     549           0 :     maAssistentFunc.InsertControl(4, mpPage4AskNameFT );
     550           0 :     maAssistentFunc.InsertControl(4, mpPage4AskNameEDT );
     551           0 :     maAssistentFunc.InsertControl(4, mpPage4AskTopicFT);
     552           0 :     maAssistentFunc.InsertControl(4, mpPage4AskTopicEDT );
     553           0 :     maAssistentFunc.InsertControl(4, mpPage4AskInfoFT );
     554           0 :     maAssistentFunc.InsertControl(4, mpPage4AskInfoEDT );
     555             : 
     556           0 :     mpPage4AskNameEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
     557           0 :     mpPage4AskTopicEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
     558           0 :     mpPage4AskInfoEDT->SetModifyHdl(LINK(this,AssistentDlgImpl,UpdateUserDataHdl));
     559             : 
     560             :     // page 5
     561           0 :     assDlg->get(mpPage5FB, "header5Image");
     562           0 :     assDlg->get(mpPage5PageListFT, "pageListLabel");
     563           0 :     assDlg->get(mpPage5PageListCT, "TreeListBox");
     564           0 :     assDlg->get(mpPage5SummaryCB, "summaryCheckbutton");
     565           0 :     maAssistentFunc.InsertControl(5, mpPage5 );
     566           0 :     maAssistentFunc.InsertControl(5, mpPage1235 );
     567           0 :     maAssistentFunc.InsertControl(5, mpPreview );
     568           0 :     maAssistentFunc.InsertControl(5, mpPreviewFlag );
     569           0 :     maAssistentFunc.InsertControl(5, mpPage5FB );
     570           0 :     maAssistentFunc.InsertControl(5, mpPage5PageListFT );
     571           0 :     maAssistentFunc.InsertControl(5, mpPage5PageListCT );
     572           0 :     maAssistentFunc.InsertControl(5, mpPage5SummaryCB );
     573             : 
     574           0 :     mpPage5PageListCT->SetSelectHdl(LINK(this,AssistentDlgImpl, PageSelectHdl));
     575             : 
     576             :     // general
     577           0 :     mpLastPageButton->SetClickHdl(LINK(this,AssistentDlgImpl, LastPageHdl ));
     578           0 :     mpNextPageButton->SetClickHdl(LINK(this,AssistentDlgImpl, NextPageHdl ));
     579             : 
     580           0 :     mpPreviewFlag->Check( mbPreview );
     581           0 :     mpPreviewFlag->SetClickHdl(LINK(this, AssistentDlgImpl, PreviewFlagHdl ));
     582           0 :     mpPreview->SetClickHdl(LINK(this,AssistentDlgImpl, EffectPreviewHdl ));
     583             : 
     584             :     // sets the exit page
     585           0 :     maAssistentFunc.GotoPage(1);
     586           0 :     mpLastPageButton->Disable();
     587             : 
     588           0 :     maPrevTimer.SetTimeout( 200 );
     589           0 :     maPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePreviewHdl));
     590             : 
     591           0 :     maEffectPrevTimer.SetTimeout( 50 );
     592           0 :     maEffectPrevTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, EffectPreviewHdl ));
     593             : 
     594           0 :     maUpdatePageListTimer.SetTimeout( 50 );
     595           0 :     maUpdatePageListTimer.SetTimeoutHdl( LINK( this, AssistentDlgImpl, UpdatePageListHdl));
     596             : 
     597           0 :     SetStartType( ST_EMPTY );
     598             : 
     599           0 :     ChangePage();
     600             : 
     601           0 :     mpWindowUpdater->RegisterWindow (mpPreview);
     602             : 
     603           0 :     UpdatePreview( true );
     604             : 
     605             :     //check whether we should start with a template document initialy and preselect it
     606           0 :     const OUString aServiceName( "com.sun.star.presentation.PresentationDocument" );
     607           0 :     OUString aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) );
     608           0 :     if( !aStandardTemplate.isEmpty() )
     609             :     {
     610           0 :         ProvideTemplates();
     611             : 
     612             :         //find aStandardTemplate in maPresentList
     613           0 :         TemplateDir*   pStandardTemplateDir = 0;
     614           0 :         TemplateEntry* pStandardTemplateEntry = 0;
     615             : 
     616           0 :         std::vector<TemplateDir*>::iterator I;
     617           0 :         for (I=maPresentList.begin(); I!=maPresentList.end(); ++I)
     618             :         {
     619           0 :             TemplateDir* pDir = *I;
     620           0 :             std::vector<TemplateEntry*>::iterator   J;
     621           0 :             for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); ++J)
     622             :             {
     623           0 :                 TemplateEntry* pEntry = *J;
     624           0 :                 if(pEntry->msPath == aStandardTemplate)
     625             :                 {
     626           0 :                     pStandardTemplateDir = pDir;
     627           0 :                     pStandardTemplateEntry = pEntry;
     628           0 :                     break;
     629             :                 }
     630             :             }
     631           0 :             if(pStandardTemplateDir)
     632           0 :                 break;
     633             :         }
     634             : 
     635             :         //preselect template
     636           0 :         if( pStandardTemplateDir && pStandardTemplateEntry )
     637             :         {
     638           0 :             mpPage1RegionLB->SelectEntry( pStandardTemplateDir->msRegion );
     639           0 :             SelectTemplateRegion( pStandardTemplateDir->msRegion );
     640           0 :             mpPage1TemplateLB->SelectEntry( pStandardTemplateEntry->msTitle );
     641           0 :             SelectTemplateHdl(mpPage1TemplateLB);
     642             :         }
     643           0 :     }
     644           0 : }
     645             : 
     646           0 : AssistentDlgImpl::~AssistentDlgImpl()
     647             : {
     648           0 :     CloseDocShell();
     649             : 
     650           0 :     DeletePasswords();
     651             : 
     652             :     //  Delete the template file infos.
     653           0 :     std::vector<TemplateDir*>::iterator I;
     654           0 :     std::vector<TemplateEntry*>::iterator   J;
     655           0 :     for (I=maPresentList.begin(); I!=maPresentList.end(); ++I)
     656             :     {
     657           0 :         for (J=(*I)->maEntries.begin(); J!=(*I)->maEntries.end(); ++J)
     658           0 :             delete (*J);
     659           0 :         delete (*I);
     660             :     }
     661           0 : }
     662             : 
     663           0 : void AssistentDlgImpl::CloseDocShell()
     664             : {
     665           0 :     if(xDocShell.Is())
     666             :     {
     667           0 :         uno::Reference< util::XCloseable > xCloseable( xDocShell->GetModel(), uno::UNO_QUERY );
     668           0 :         if( xCloseable.is() )
     669             :         {
     670           0 :             xCloseable->close( sal_True );
     671           0 :             xDocShell = NULL;
     672             :         }
     673             :         else
     674             :         {
     675           0 :             xDocShell->DoClose();
     676           0 :             xDocShell = NULL;
     677           0 :         }
     678             :     }
     679           0 : }
     680             : 
     681           0 : void AssistentDlgImpl::EndDialog( long )
     682             : {
     683           0 :     mpWindow = NULL;
     684           0 : }
     685             : 
     686           0 : void    AssistentDlgImpl::ScanDocmenu   (void)
     687             : {
     688           0 :     if( mbRecentDocumentsReady )
     689           0 :         return;
     690             : 
     691             :     uno::Sequence<uno::Sequence<beans::PropertyValue> > aHistory =
     692           0 :         SvtHistoryOptions().GetList (ePICKLIST);
     693             : 
     694           0 :     uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     695           0 :     uno::Reference< container::XNameAccess > xFilterFactory( xFactory->createInstance( "com.sun.star.document.FilterFactory" ), uno::UNO_QUERY );
     696             : 
     697           0 :     uno::Reference<ucb::XSimpleFileAccess3> xFileAccess(ucb::SimpleFileAccess::create(::comphelper::getProcessComponentContext()));
     698             : 
     699           0 :     sal_uInt32 nCount = aHistory.getLength();
     700           0 :     for (sal_uInt32 nItem=0; nItem<nCount; ++nItem)
     701             :     {
     702             :         //  Get the current history item's properties.
     703           0 :         uno::Sequence<beans::PropertyValue> aPropertySet = aHistory[nItem];
     704           0 :         OUString   sURL;
     705           0 :         OUString   sFilter;
     706           0 :         OUString   sTitle;
     707           0 :         OUString   sPassword;
     708           0 :         sal_uInt32 nPropertyCount = aPropertySet.getLength();
     709           0 :         for (sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty)
     710           0 :             if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL)
     711           0 :                 aPropertySet[nProperty].Value >>= sURL;
     712           0 :             else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_FILTER)
     713           0 :                 aPropertySet[nProperty].Value >>= sFilter;
     714           0 :             else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE)
     715           0 :                 aPropertySet[nProperty].Value >>= sTitle;
     716           0 :             else if (aPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_PASSWORD)
     717           0 :                 aPropertySet[nProperty].Value >>= sPassword;
     718             : 
     719             :         //  If the entry is an impress file then insert it into the
     720             :         //  history list and the list box.
     721           0 :         uno::Sequence< beans::PropertyValue > lProps;
     722           0 :         if (xFilterFactory->hasByName(sFilter))
     723             :         {
     724           0 :             uno::Any aFilterPropSet = xFilterFactory->getByName( sFilter );
     725           0 :             aFilterPropSet >>= lProps;
     726             :         }
     727             : 
     728           0 :         sal_Int32 nPropCount = lProps.getLength();
     729           0 :         OUString sFactoryName;
     730           0 :         for( sal_Int32 i=0; i<nPropCount; ++i )
     731             :         {
     732           0 :             if( lProps[i].Name.equalsAscii( "DocumentService" ) &&
     733           0 :                 (lProps[i].Value >>= sFactoryName) &&
     734           0 :                 sFactoryName.equalsAscii( "com.sun.star.presentation.PresentationDocument" ) )
     735             :             {
     736             :                 // yes, it's an impress document
     737           0 :                 INetURLObject aURL;
     738             : 
     739             :                 // Do not include the file if it does not exist.
     740           0 :                 if (xFileAccess.is() && ! xFileAccess->exists(sURL))
     741           0 :                     continue;
     742             : 
     743           0 :                 aURL.SetSmartURL (sURL);
     744             :                 // The password is set only when it is not empty.
     745           0 :                 if (!sPassword.isEmpty())
     746           0 :                     aURL.SetPass (sPassword);
     747           0 :                 maOpenFilesList.push_back (aURL.GetMainURL(INetURLObject::NO_DECODE));
     748           0 :                 mpPage1OpenLB->InsertEntry (sTitle);
     749           0 :                 break;
     750             :             }
     751             :         }
     752           0 :     }
     753           0 :     mbRecentDocumentsReady = true;
     754             :     try
     755             :     {
     756           0 :         UpdatePreview(true);
     757             :     }
     758           0 :     catch (uno::RuntimeException& )
     759             :     {
     760             :         // Ignore all exceptions.
     761           0 :     }
     762             : }
     763             : 
     764           0 : void AssistentDlgImpl::ProvideTemplates (void)
     765             : {
     766           0 :     if ( ! mbTemplatesReady)
     767             :     {
     768           0 :         TemplateScanner aScanner;
     769           0 :         aScanner.EnableEntrySorting();
     770           0 :         aScanner.Scan ();
     771           0 :         TemplateScanDone (aScanner.GetFolderList());
     772             : 
     773             :         try
     774             :         {
     775           0 :             UpdatePreview(true);
     776             :         }
     777           0 :         catch (uno::RuntimeException& )
     778             :         {
     779             :             // Ignore all exceptions.
     780           0 :         }
     781             :     }
     782           0 : }
     783             : 
     784           0 : void AssistentDlgImpl::TemplateScanDone (
     785             :     std::vector<TemplateDir*>& rTemplateFolder)
     786             : {
     787             :     //  This method is called from a thread.  Therefore we get the solar mutex.
     788           0 :     SolarMutexGuard aGuard;
     789             : 
     790             :     // Copy the contents of the given template folders to a local list.
     791           0 :     maPresentList.swap (rTemplateFolder);
     792             : 
     793             :     //  Fill in the list box on the first page.
     794           0 :     int nFirstEntry = 0;
     795           0 :     mpPage1RegionLB->Clear();
     796           0 :     std::vector<TemplateDir*>::iterator I;
     797             :     int i;
     798           0 :     for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); ++I,++i)
     799             :     {
     800           0 :         TemplateDir* pDir = *I;
     801           0 :         if (pDir == NULL)
     802           0 :             continue;
     803             : 
     804             :         // HACK! presnt directory is always initially selected.
     805             :         // We have to look at the first entry to get a URL.
     806           0 :         if (!pDir->maEntries.empty() )
     807             :         {
     808           0 :             TemplateEntry* pEntry = pDir->maEntries.front();
     809           0 :             if (pEntry != NULL)
     810           0 :                 if (pEntry->msPath.indexOf("presnt") != -1)
     811           0 :                     nFirstEntry = i;
     812             :         }
     813             : 
     814           0 :         mpPage1RegionLB->InsertEntry (pDir->msRegion);
     815             :     }
     816           0 :     mpPage1RegionLB->SelectEntryPos ((sal_uInt16)nFirstEntry);
     817           0 :     mpPage1RegionLB->Update();
     818           0 :     SelectTemplateRegion (mpPage1RegionLB->GetSelectEntry());
     819             : 
     820             :     //  Fill in the list box on the second page.
     821           0 :     nFirstEntry = 0;
     822           0 :     mpPage2RegionLB->Clear();
     823           0 :     for (i=0,I=maPresentList.begin(); I!=maPresentList.end(); ++I,++i)
     824             :     {
     825           0 :         TemplateDir* pDir = *I;
     826           0 :         if (pDir == NULL)
     827           0 :             continue;
     828             : 
     829             :         // HACK! layout directory is always initially selected.
     830             :         // We have to look at the first entry to get a URL.
     831           0 :         if (!pDir->maEntries.empty() )
     832             :         {
     833           0 :             TemplateEntry* pEntry = pDir->maEntries.front();
     834           0 :             if (pEntry != NULL)
     835           0 :                 if (pEntry->msPath.indexOf("layout") != -1)
     836           0 :                     nFirstEntry = i;
     837             :         }
     838             : 
     839           0 :         mpPage2RegionLB->InsertEntry (pDir->msRegion);
     840             :     }
     841           0 :     mpPage2RegionLB->SelectEntryPos ((sal_uInt16)nFirstEntry);
     842           0 :     mpPage2RegionLB->Update();
     843           0 :     SelectLayoutRegion (mpPage2RegionLB->GetSelectEntry());
     844             : 
     845             :     //  Make the changes visible.
     846           0 :     mbTemplatesReady = true;
     847           0 :     if (mpWindow)
     848           0 :         UpdatePage();
     849           0 : }
     850             : 
     851             : // ********************************************************************
     852             : // state methods
     853             : // ********************************************************************
     854             : 
     855           0 : void AssistentDlgImpl::SetStartType( StartType eType )
     856             : {
     857           0 :     mpPage1EmptyRB->SetState( eType == ST_EMPTY );
     858           0 :     mpPage1TemplateRB->SetState( eType == ST_TEMPLATE );
     859           0 :     mpPage1OpenRB->SetState( eType == ST_OPEN );
     860           0 :     mpNextPageButton->Enable( eType != ST_OPEN );
     861             : 
     862           0 :     mpPage1RegionLB->Show(eType == ST_TEMPLATE);
     863           0 :     mpPage1TemplateLB->Show(eType == ST_TEMPLATE);
     864           0 :     mpPage1OpenLB->Show(eType == ST_OPEN);
     865           0 :     mpPage1OpenPB->Show(eType == ST_OPEN);
     866             : 
     867           0 :     if (eType == ST_OPEN)
     868           0 :         mpFinishButton->SetText(maOpenStr);
     869             :     else
     870           0 :         mpFinishButton->SetText(maCreateStr);
     871           0 : }
     872             : 
     873           0 : StartType AssistentDlgImpl::GetStartType()
     874             : {
     875           0 :     if( mpPage1EmptyRB->IsChecked() )
     876           0 :         return ST_EMPTY;
     877           0 :     else if( mpPage1TemplateRB->IsChecked() )
     878           0 :         return ST_TEMPLATE;
     879             :     else
     880           0 :         return ST_OPEN;
     881             : }
     882             : 
     883           0 : OUString AssistentDlgImpl::GetDocFileName()
     884             : {
     885           0 :     OUString aTitle;
     886           0 :     if(mpWindow)
     887             :     {
     888           0 :         aTitle = mpWindow->GetText();
     889           0 :         sal_Int32 nPos = aTitle.indexOf('(');
     890           0 :         if (nPos != -1)
     891           0 :             aTitle = aTitle.copy( 0, nPos-1 );
     892             :     }
     893             : 
     894           0 :     OUString aDocFile;
     895           0 :     if( GetStartType() == ST_TEMPLATE )
     896             :     {
     897           0 :         const sal_uInt16 nEntry = mpPage1TemplateLB->GetSelectEntryPos();
     898           0 :         TemplateEntry* pEntry = NULL;
     899           0 :         if(nEntry != (sal_uInt16)-1)
     900           0 :             pEntry = mpTemplateRegion->maEntries[nEntry];
     901             : 
     902           0 :         if(pEntry)
     903             :         {
     904           0 :             aDocFile = pEntry->msPath;
     905             : 
     906           0 :             aTitle += " (";
     907           0 :             aTitle += pEntry->msTitle;
     908           0 :             aTitle += ")";
     909             :         }
     910             :     }
     911           0 :     else if( GetStartType() == ST_OPEN )
     912             :     {
     913           0 :         const sal_uInt16 nEntry = mpPage1OpenLB->GetSelectEntryPos();
     914           0 :         if(nEntry != (sal_uInt16)-1 )
     915           0 :             aDocFile = maOpenFilesList[nEntry];
     916             :     }
     917             : 
     918           0 :     if(mpWindow)
     919           0 :         mpWindow->SetText(aTitle);
     920             : 
     921           0 :     return aDocFile;
     922             : }
     923             : 
     924           0 : OUString AssistentDlgImpl::GetLayoutFileName()
     925             : {
     926           0 :     const sal_uInt16 nEntry = mpPage2LayoutLB->GetSelectEntryPos();
     927           0 :     TemplateEntry* pEntry = NULL;
     928           0 :     if(nEntry != (sal_uInt16)-1 && nEntry > 0)
     929           0 :         pEntry = mpLayoutRegion->maEntries[nEntry-1];
     930             : 
     931           0 :     if(pEntry)
     932           0 :         return pEntry->msPath;
     933             : 
     934           0 :     return OUString();
     935             : }
     936             : 
     937           0 : SfxObjectShellLock AssistentDlgImpl::GetDocument()
     938             : {
     939           0 :     UpdatePreview(false);   // but load completely
     940           0 :     UpdatePageList();
     941             : 
     942           0 :     SfxObjectShell* pShell = xDocShell;
     943           0 :     ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell,pShell);
     944           0 :     SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
     945             : 
     946           0 :     if(pDoc)
     947             :     {
     948           0 :         const sal_uInt16 nPageCount = pDoc->GetSdPageCount(PK_STANDARD);
     949           0 :         bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
     950           0 :         double fNewTime = (double)mpPage3PresTimeTMF->GetTime().GetMSFromTime() / 1000.0;
     951           0 :         if(bKiosk)
     952             :         {
     953           0 :             PresentationSettings& rSettings = pDoc->getPresentationSettings();
     954           0 :             rSettings.mbEndless = bKiosk;
     955           0 :             rSettings.mnPauseTimeout = (sal_Int32)mpPage3BreakTMF->GetTime().GetMSFromTime() / 1000;
     956           0 :             rSettings.mbShowPauseLogo = mpPage3LogoCB->IsChecked();
     957             :         }
     958             : 
     959           0 :         sal_uInt16 nPgAbsNum = 0;
     960           0 :         sal_uInt16 nPgRelNum = 0;
     961           0 :         while( nPgAbsNum < nPageCount )
     962             :         {
     963           0 :             SdPage* pPage = pDoc->GetSdPage( nPgRelNum, PK_STANDARD );
     964           0 :             if( mpPage5PageListCT->IsPageChecked(nPgAbsNum) )
     965             :             {
     966           0 :                 mpPage3EffectLB->applySelected(pPage);
     967           0 :                 const sal_uInt16 nPos = mpPage3SpeedLB->GetSelectEntryPos();
     968           0 :                 pPage->setTransitionDuration( (nPos == 0) ? 3.0 : (nPos == 1) ? 2.0 : 1.0 );
     969           0 :                 if(bKiosk)
     970             :                 {
     971           0 :                     pPage->SetPresChange( PRESCHANGE_AUTO );
     972           0 :                     pPage->SetTime(fNewTime);
     973             :                 }
     974           0 :                 nPgRelNum++;
     975             :             }
     976             :             else
     977             :             {
     978             :                 // delete this page
     979           0 :                 pDoc->DeletePage( (nPgRelNum << 1) + 2 ); // delete not page
     980           0 :                 pDoc->DeletePage( (nPgRelNum << 1) + 1 ); // delete page
     981             :             }
     982             : 
     983           0 :             nPgAbsNum++;
     984             :         }
     985             :     }
     986             :     else
     987             :     {
     988             :         OSL_FAIL("sd::AssistentDlgImpl::GetDocument(), no template?");
     989             :     }
     990             : 
     991           0 :     SfxObjectShellLock xRet = xDocShell;
     992           0 :     xDocShell = NULL;
     993             : 
     994           0 :     return xRet;
     995             : }
     996             : 
     997           0 : void AssistentDlgImpl::LeavePage()
     998             : {
     999           0 :     int nPage = maAssistentFunc.GetCurrentPage();
    1000             : 
    1001           0 :     if( nPage == 4 && mbUserDataDirty )
    1002           0 :         maPrevTimer.Start();
    1003           0 : }
    1004             : 
    1005           0 : void AssistentDlgImpl::ChangePage()
    1006             : {
    1007           0 :     mpNextPageButton->Enable(!maAssistentFunc.IsLastPage());
    1008           0 :     mpLastPageButton->Enable(!maAssistentFunc.IsFirstPage());
    1009             : 
    1010           0 :     UpdatePage();
    1011             : 
    1012           0 :     if( mpNextPageButton->IsEnabled() )
    1013             :     {
    1014           0 :       mpNextPageButton->ForceFocusEventBroadcast();
    1015             :     }
    1016             :     else
    1017           0 :         mpFinishButton->GrabFocus();
    1018           0 : }
    1019             : 
    1020           0 : void AssistentDlgImpl::UpdatePage()
    1021             : {
    1022           0 :     sal_uInt16 nPage = (sal_uInt16)maAssistentFunc.GetCurrentPage();
    1023             : 
    1024           0 :     switch(nPage)
    1025             :     {
    1026             :     case 1:
    1027             :         {
    1028             :             // Show elements on first page depending of start type
    1029           0 :             SetStartType( GetStartType() );
    1030           0 :             mpPage1TemplateRB->Enable(true /*mbTemplatesReady*/);
    1031           0 :             break;
    1032             :         }
    1033             : 
    1034             :     case 2:
    1035             :         {
    1036           0 :             mpPage2RegionLB->Enable(mbTemplatesReady);
    1037           0 :             mpPage2LayoutLB->Enable(mbTemplatesReady);
    1038             : 
    1039           0 :             if( GetStartType() != ST_EMPTY )
    1040             :             {
    1041           0 :                 mpPage2Medium5RB->Enable( true );
    1042             :             }
    1043             :             else
    1044             :             {
    1045           0 :                 mpPage2Medium5RB->Enable( false );
    1046           0 :                 if(mpPage2Medium5RB->IsChecked())
    1047           0 :                     mpPage2Medium1RB->Check();
    1048             :             }
    1049             : 
    1050           0 :             break;
    1051             :         }
    1052             :     case 5:
    1053             :         {
    1054           0 :             if(mbDocPreview || maPageListFile != maDocFile)
    1055           0 :                 mpPage5PageListCT->Clear();
    1056             : 
    1057           0 :             maUpdatePageListTimer.Start();
    1058           0 :             break;
    1059             :         }
    1060             : 
    1061             :     case 3:
    1062             :         {
    1063           0 :             if(GetStartType() != ST_TEMPLATE)
    1064           0 :                 mpNextPageButton->Enable(false);
    1065             : 
    1066           0 :             bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
    1067           0 :             mpPage3PresTimeFT->Enable(bKiosk);
    1068           0 :             mpPage3BreakFT->Enable(bKiosk);
    1069           0 :             mpPage3PresTimeTMF->Enable(bKiosk);
    1070           0 :             mpPage3BreakTMF->Enable(bKiosk);
    1071           0 :             mpPage3LogoCB->Enable(bKiosk);
    1072           0 :             break;
    1073             :         }
    1074             :     }
    1075           0 : }
    1076             : 
    1077             : // ********************************************************************
    1078             : // UI-Handler
    1079             : // ********************************************************************
    1080             : 
    1081           0 : IMPL_LINK( AssistentDlgImpl, SelectRegionHdl, ListBox *, pLB )
    1082             : {
    1083           0 :     if( pLB == mpPage1RegionLB )
    1084             :     {
    1085           0 :         SelectTemplateRegion( pLB->GetSelectEntry() );
    1086           0 :         SetStartType( ST_TEMPLATE );
    1087           0 :         mpPage2Medium5RB->Check();
    1088             :     }
    1089             :     else
    1090             :     {
    1091           0 :         SelectLayoutRegion( pLB->GetSelectEntry() );
    1092             :     }
    1093             : 
    1094           0 :     return 0;
    1095             : }
    1096             : 
    1097           0 : IMPL_LINK_NOARG(AssistentDlgImpl, SelectEffectHdl)
    1098             : {
    1099           0 :     maEffectPrevTimer.Start();
    1100           0 :     return 0;
    1101             : }
    1102             : 
    1103           0 : IMPL_LINK( AssistentDlgImpl, OpenButtonHdl, Button*, pButton )
    1104             : {
    1105             :     // Clear the selection and forward the call.
    1106           0 :     mpPage1OpenLB->SetNoSelection();
    1107           0 :     return mpPage1OpenLB->GetDoubleClickHdl().Call(pButton);
    1108             : }
    1109             : 
    1110           0 : IMPL_LINK_NOARG(AssistentDlgImpl, EffectPreviewHdl)
    1111             : {
    1112           0 :     if(mbPreview && xDocShell.Is() )
    1113             :     {
    1114           0 :         SfxObjectShell* pShell = xDocShell;
    1115           0 :         DrawDocShell* pDocShell = dynamic_cast< DrawDocShell * >(pShell);
    1116           0 :         if( pDocShell )
    1117             :         {
    1118           0 :             SdDrawDocument* pDoc = pDocShell->GetDoc();
    1119           0 :             if( pDoc )
    1120             :             {
    1121           0 :                 SdPage* pPage = pDoc->GetSdPage( mnShowPage, PK_STANDARD );
    1122           0 :                 if( pPage )
    1123           0 :                     mpPage3EffectLB->applySelected(pPage);
    1124             :             }
    1125             :         }
    1126           0 :         mpPreview->startPreview();
    1127             :     }
    1128           0 :     return 0;
    1129             : }
    1130             : 
    1131           0 : IMPL_LINK_NOARG(AssistentDlgImpl, PreviewFlagHdl)
    1132             : 
    1133             : {
    1134           0 :     if( mpPreviewFlag->IsChecked() != mbPreview )
    1135             :     {
    1136           0 :         mbPreview = mpPreviewFlag->IsChecked();
    1137           0 :         UpdatePreview(true);
    1138             :     }
    1139           0 :     return 0;
    1140             : }
    1141             : 
    1142           0 : IMPL_LINK_NOARG(AssistentDlgImpl, SelectTemplateHdl)
    1143             : {
    1144           0 :     SetStartType( ST_TEMPLATE );
    1145           0 :     mpPage2Medium5RB->Check();
    1146           0 :     mpPage2LayoutLB->SelectEntryPos(0);
    1147           0 :     maPrevTimer.Start();
    1148           0 :     return 0;
    1149             : }
    1150             : 
    1151           0 : IMPL_LINK_NOARG(AssistentDlgImpl, SelectLayoutHdl)
    1152             : {
    1153           0 :     maPrevTimer.Start();
    1154           0 :     return 0;
    1155             : }
    1156             : 
    1157           0 : IMPL_LINK_NOARG(AssistentDlgImpl, SelectFileHdl)
    1158             : {
    1159           0 :     SetStartType( ST_OPEN );
    1160           0 :     maPrevTimer.Start();
    1161           0 :     return 0;
    1162             : }
    1163             : 
    1164           0 : IMPL_LINK_NOARG(AssistentDlgImpl, PageSelectHdl)
    1165             : {
    1166           0 :     sal_uInt16 nPage = mpPage5PageListCT->GetSelectedPage();
    1167           0 :     if( mnShowPage != nPage )
    1168             :     {
    1169           0 :         mnShowPage = nPage;
    1170           0 :         UpdatePreview(false);
    1171             :     }
    1172             : 
    1173           0 :     return 0;
    1174             : }
    1175             : 
    1176           0 : IMPL_LINK_NOARG(AssistentDlgImpl, UpdatePageListHdl)
    1177             : {
    1178           0 :     UpdatePageList();
    1179           0 :     return 0;
    1180             : }
    1181             : 
    1182           0 : IMPL_LINK_NOARG(AssistentDlgImpl, UpdatePreviewHdl)
    1183             : {
    1184           0 :     UpdatePreview( true );
    1185           0 :     return 0;
    1186             : }
    1187             : 
    1188           0 : IMPL_LINK( AssistentDlgImpl, StartTypeHdl, RadioButton *, pButton )
    1189             : {
    1190           0 :     StartType eType = pButton == mpPage1EmptyRB?ST_EMPTY:pButton == mpPage1TemplateRB?ST_TEMPLATE:ST_OPEN;
    1191             : 
    1192           0 :     if(eType == ST_TEMPLATE)
    1193           0 :         ProvideTemplates();
    1194           0 :     else if(eType == ST_OPEN)
    1195           0 :         ScanDocmenu();
    1196             : 
    1197           0 :     SetStartType( eType );
    1198             : 
    1199           0 :     if(eType == ST_TEMPLATE)
    1200             :     {
    1201           0 :         mpPage1TemplateLB->SelectEntryPos(0);
    1202           0 :         mpPage2Medium5RB->Check();
    1203             :     }
    1204           0 :     else if(eType == ST_OPEN)
    1205           0 :         mpPage1OpenLB->SelectEntryPos(0);
    1206             : 
    1207           0 :     maPrevTimer.Start();
    1208           0 :     return 0;
    1209             : }
    1210             : 
    1211           0 : IMPL_LINK_NOARG(AssistentDlgImpl, NextPageHdl)
    1212             : {
    1213             :     // When changing from the first to the second page make sure that the
    1214             :     // templates are present.
    1215           0 :     if (maAssistentFunc.GetCurrentPage() == 1)
    1216           0 :         ProvideTemplates();
    1217             : 
    1218             :     // Change to the next page.
    1219           0 :     LeavePage();
    1220           0 :     maAssistentFunc.NextPage();
    1221           0 :     ChangePage();
    1222           0 :     return 0;
    1223             : }
    1224             : 
    1225           0 : IMPL_LINK_NOARG(AssistentDlgImpl, LastPageHdl)
    1226             : {
    1227           0 :     LeavePage();
    1228           0 :     maAssistentFunc.PreviousPage();
    1229           0 :     ChangePage();
    1230           0 :     return 0;
    1231             : }
    1232             : 
    1233           0 : IMPL_LINK_NOARG(AssistentDlgImpl, PresTypeHdl)
    1234             : {
    1235           0 :     if (maDocFile.isEmpty())
    1236             :     {
    1237           0 :         mpNextPageButton->Enable(false);
    1238             :     }
    1239             : 
    1240           0 :     bool bKiosk = mpPage3PresTypeKioskRB->IsChecked();
    1241           0 :     mpPage3PresTimeFT->Enable(bKiosk);
    1242           0 :     mpPage3BreakFT->Enable(bKiosk);
    1243           0 :     mpPage3PresTimeTMF->Enable(bKiosk);
    1244           0 :     mpPage3BreakTMF->Enable(bKiosk);
    1245           0 :     mpPage3LogoCB->Enable(bKiosk);
    1246           0 :     return 0;
    1247             : }
    1248             : 
    1249           0 : IMPL_LINK_NOARG(AssistentDlgImpl, UpdateUserDataHdl)
    1250             : {
    1251           0 :     mbUserDataDirty = true;
    1252           0 :     OUString aTopic = mpPage4AskTopicEDT->GetText();
    1253           0 :     OUString aName  = mpPage4AskNameEDT->GetText();
    1254           0 :     OUString aInfo  = mpPage4AskInfoEDT->GetText();
    1255             : 
    1256           0 :     if (aTopic.isEmpty() && aName.isEmpty() && aInfo.isEmpty())
    1257           0 :         maDocFile = "";
    1258             : 
    1259           0 :     return 0;
    1260             : }
    1261             : 
    1262             : // ********************************************************************
    1263             : // ********************************************************************
    1264             : 
    1265           0 : void AssistentDlgImpl::SelectTemplateRegion( const OUString& rRegion )
    1266             : {
    1267           0 :     mpPage1TemplateLB->Clear();
    1268           0 :     std::vector<TemplateDir*>::iterator I;
    1269           0 :     for (I=maPresentList.begin(); I!=maPresentList.end(); ++I)
    1270             :     {
    1271           0 :         TemplateDir * pDir = *I;
    1272           0 :         mpTemplateRegion = *I;
    1273           0 :         if (pDir->msRegion == rRegion)
    1274             :         {
    1275           0 :             std::vector<TemplateEntry*>::iterator   J;
    1276           0 :             for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); ++J)
    1277           0 :                 mpPage1TemplateLB->InsertEntry ((*J)->msTitle);
    1278           0 :             mpPage1TemplateLB->Update();
    1279           0 :             if(GetStartType() == ST_TEMPLATE)
    1280             :             {
    1281           0 :                 mpPage1TemplateLB->SelectEntryPos( 0 );
    1282           0 :                 SelectTemplateHdl(NULL);
    1283             :             }
    1284           0 :             break;
    1285             :         }
    1286             :     }
    1287           0 : }
    1288             : 
    1289           0 : void AssistentDlgImpl::SelectLayoutRegion( const OUString& rRegion )
    1290             : {
    1291           0 :     mpPage2LayoutLB->Clear();
    1292           0 :     mpPage2LayoutLB->InsertEntry(SD_RESSTR(STR_WIZARD_ORIGINAL));
    1293           0 :     std::vector<TemplateDir*>::iterator I;
    1294           0 :     for (I=maPresentList.begin(); I!=maPresentList.end(); ++I)
    1295             :     {
    1296           0 :         TemplateDir * pDir = *I;
    1297           0 :         mpLayoutRegion = *I;
    1298             : 
    1299           0 :         if (pDir->msRegion == rRegion)
    1300             :         {
    1301           0 :             std::vector<TemplateEntry*>::iterator   J;
    1302           0 :             for (J=pDir->maEntries.begin(); J!=pDir->maEntries.end(); ++J)
    1303           0 :                 mpPage2LayoutLB->InsertEntry ((*J)->msTitle);
    1304           0 :             mpPage2LayoutLB->Update();
    1305           0 :             break;
    1306             :         }
    1307             :     }
    1308           0 : }
    1309             : 
    1310           0 : void AssistentDlgImpl::UpdateUserData()
    1311             : {
    1312           0 :     OUString aTopic = mpPage4AskTopicEDT->GetText();
    1313           0 :     OUString aName  = mpPage4AskNameEDT->GetText();
    1314           0 :     OUString aInfo  = mpPage4AskInfoEDT->GetText();
    1315             : 
    1316           0 :     SfxObjectShell* pShell = xDocShell;
    1317           0 :     DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
    1318           0 :     SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
    1319           0 :     SdPage* pPage = pDoc?pDoc->GetSdPage(0, PK_STANDARD):NULL;
    1320             : 
    1321           0 :     if (pPage && (!aTopic.isEmpty() || !aName.isEmpty() || !aInfo.isEmpty()))
    1322             :     {
    1323           0 :         if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
    1324           0 :             pPage->SetAutoLayout(AUTOLAYOUT_TITLE, true);
    1325             : 
    1326             :         SdrTextObj* pObj;
    1327             : 
    1328           0 :         if (!aTopic.isEmpty())
    1329             :         {
    1330           0 :             pObj  = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TITLE ) );
    1331           0 :             if( pObj )
    1332             :             {
    1333           0 :                 pPage->SetObjText( pObj, NULL, PRESOBJ_TITLE, aTopic );
    1334           0 :                 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ), true );
    1335           0 :                 pObj->SetEmptyPresObj(false);
    1336             :             }
    1337             : 
    1338             :         }
    1339             : 
    1340           0 :         if (!aName.isEmpty() || !aInfo.isEmpty())
    1341             :         {
    1342           0 :             OUString aStrTmp( aName );
    1343           0 :             if (!aName.isEmpty())
    1344           0 :                 aStrTmp += "\n\n";
    1345           0 :             aStrTmp += aInfo;
    1346             : 
    1347           0 :             pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_OUTLINE ) );
    1348           0 :             if( pObj )
    1349             :             {
    1350           0 :                 pPage->SetObjText( pObj, NULL, PRESOBJ_OUTLINE, aStrTmp );
    1351           0 :                 pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ), true );
    1352           0 :                 pObj->SetEmptyPresObj(false);
    1353             :             }
    1354             :             else
    1355             :             {
    1356           0 :                 pObj = dynamic_cast<SdrTextObj*>( pPage->GetPresObj( PRESOBJ_TEXT ) );
    1357           0 :                 if( pObj )
    1358             :                 {
    1359           0 :                     pPage->SetObjText( pObj, NULL, PRESOBJ_TEXT, aStrTmp );
    1360           0 :                     pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT ), true );
    1361           0 :                     pObj->SetEmptyPresObj(false);
    1362             :                 }
    1363           0 :             }
    1364             :         }
    1365             :     }
    1366             : 
    1367           0 :     mbUserDataDirty = false;
    1368           0 : }
    1369             : 
    1370           0 : void AssistentDlgImpl::UpdatePageList()
    1371             : {
    1372           0 :     if(mbDocPreview || !mbPreview)
    1373           0 :         UpdatePreview(false);
    1374           0 :     else if(maPageListFile == maDocFile)
    1375           0 :         return;
    1376             : 
    1377           0 :     maPageListFile = maDocFile;
    1378             : 
    1379           0 :     SfxObjectShell* pShell = xDocShell;
    1380           0 :     DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
    1381           0 :     SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
    1382             : 
    1383           0 :     mpPage5PageListCT->Clear();
    1384             : 
    1385           0 :     if(pDoc)
    1386           0 :         mpPage5PageListCT->Fill(pDoc);
    1387             : }
    1388             : 
    1389           0 : void AssistentDlgImpl::UpdatePreview( bool bDocPreview )
    1390             : {
    1391             :     // Guard against multiple concurrent execution to this method caused either
    1392             :     // by calls from different threads or recursion.
    1393           0 :     ::osl::MutexGuard aGuard (maMutex);
    1394           0 :     if (mbPreviewUpdating)
    1395           0 :         return;
    1396           0 :     mbPreviewUpdating = true;
    1397             : 
    1398           0 :     if(!mbPreview && bDocPreview)
    1399             :     {
    1400           0 :         mpPreview->Invalidate();
    1401           0 :         mpPreview->SetObjectShell(0);
    1402           0 :         mbPreviewUpdating = false;
    1403           0 :         return;
    1404             :     }
    1405             : 
    1406           0 :     OUString aDocFile = GetDocFileName();
    1407           0 :     OUString aLayoutFile = GetLayoutFileName();
    1408             : 
    1409           0 :     SfxApplication *pSfxApp = SfxGetpApp();
    1410             :     sal_uLong lErr;
    1411           0 :     bool bChangeMaster = !aLayoutFile.isEmpty();
    1412             : 
    1413           0 :     if (aDocFile.isEmpty())
    1414             :     {
    1415           0 :         if (!xDocShell.Is() || !maDocFile.isEmpty() ||
    1416           0 :             (maDocFile.isEmpty() && !maLayoutFile.isEmpty() && aLayoutFile.isEmpty()))
    1417             :         {
    1418           0 :             CloseDocShell();
    1419             : 
    1420             :             DrawDocShell* pNewDocSh;
    1421           0 :             xDocShell = pNewDocSh = new DrawDocShell(SFX_CREATE_MODE_STANDARD, false);
    1422           0 :             pNewDocSh->DoInitNew(NULL);
    1423           0 :             SdDrawDocument* pDoc = pNewDocSh->GetDoc();
    1424           0 :             pDoc->CreateFirstPages();
    1425           0 :             pDoc->StopWorkStartupDelay();
    1426           0 :             mbDocPreview = false;
    1427             : 
    1428           0 :             maDocFile = aDocFile;
    1429           0 :             mbUserDataDirty = true;
    1430             :         }
    1431             :         else
    1432           0 :             bChangeMaster = !aLayoutFile.isEmpty() && (maLayoutFile != aLayoutFile);
    1433             :     }
    1434           0 :     else if( aDocFile == maDocFile && ( mbDocPreview == bDocPreview || bDocPreview ) )
    1435             :     {
    1436           0 :         if( aLayoutFile != maLayoutFile )
    1437             :         {
    1438           0 :             SfxObjectShell* pShell = xDocShell;
    1439           0 :             DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
    1440           0 :             ::svl::IUndoManager* pUndoMgr = pDocShell?pDocShell->GetUndoManager():NULL;
    1441           0 :             if(pUndoMgr)
    1442           0 :                 pUndoMgr->Undo();
    1443           0 :             mbUserDataDirty = true;
    1444             :         }
    1445             :         else
    1446           0 :             bChangeMaster = false;
    1447             :     }
    1448             :     else
    1449             :     {
    1450           0 :         CloseDocShell();
    1451             : 
    1452           0 :         vcl::Window *pParent = Application::GetDefDialogParent();
    1453           0 :         Application::SetDefDialogParent( mpWindow );
    1454             : 
    1455           0 :         SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
    1456             : 
    1457           0 :         if(IsOwnFormat(aDocFile))
    1458             :         {
    1459           0 :             SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
    1460           0 :             pSet->Put( SfxBoolItem( SID_TEMPLATE, true ) );
    1461           0 :             if(bDocPreview)
    1462           0 :                 pSet->Put( SfxBoolItem( SID_PREVIEW, true ) );
    1463           0 :             RestorePassword( pSet, aDocFile );
    1464           0 :             if( (lErr = pSfxApp->LoadTemplate( xDocShell, aDocFile, true, pSet )) != 0 )
    1465           0 :                 ErrorHandler::HandleError(lErr);
    1466             :             else
    1467           0 :                 SavePassword( xDocShell, aDocFile );
    1468             :         }
    1469             :         else
    1470             :         {
    1471           0 :             SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, SfxGetpApp()->GetPool() );
    1472           0 :             aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aDocFile ));
    1473           0 :             aReq.AppendItem( SfxStringItem( SID_REFERER, OUString() ) );
    1474           0 :             aReq.AppendItem( SfxStringItem( SID_TARGETNAME, OUString("_default") ) );
    1475           0 :             aReq.AppendItem( SfxBoolItem( SID_HIDDEN, true ) );
    1476           0 :             aReq.AppendItem( SfxBoolItem( SID_PREVIEW, bDocPreview ) );
    1477             : 
    1478           0 :             const SfxViewFrameItem* pRet = PTR_CAST( SfxViewFrameItem, SfxGetpApp()->ExecuteSlot( aReq ) );
    1479             : 
    1480           0 :             if ( pRet && pRet->GetFrame() && pRet->GetFrame()->GetObjectShell() )
    1481           0 :                 xDocShell = pRet->GetFrame()->GetObjectShell();
    1482             :         }
    1483             : 
    1484           0 :         Application::SetDefDialogParent( pParent );
    1485             : 
    1486           0 :         mnShowPage = 0;
    1487           0 :         mbDocPreview = bDocPreview;
    1488           0 :         maDocFile = aDocFile;
    1489           0 :         mbUserDataDirty = true;
    1490             :     }
    1491             : 
    1492           0 :     if(bChangeMaster && (aLayoutFile != maDocFile))
    1493             :     {
    1494             :         // load layout template
    1495           0 :         SfxObjectShellLock xLayoutDocShell;
    1496           0 :         SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,mpWindow);
    1497             : 
    1498           0 :         vcl::Window *pParent = Application::GetDefDialogParent();
    1499           0 :         Application::SetDefDialogParent( mpWindow );
    1500             : 
    1501           0 :         if(IsOwnFormat(aLayoutFile))
    1502             :         {
    1503           0 :             SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
    1504           0 :             pSet->Put( SfxBoolItem( SID_TEMPLATE, true ) );
    1505           0 :             pSet->Put( SfxBoolItem( SID_PREVIEW, true ) );
    1506             : 
    1507           0 :             RestorePassword( pSet, aLayoutFile );
    1508           0 :             if( (lErr = pSfxApp->LoadTemplate( xLayoutDocShell, aLayoutFile, true, pSet )) != 0 )
    1509           0 :                 ErrorHandler::HandleError(lErr);
    1510           0 :             SavePassword( xLayoutDocShell, aLayoutFile );
    1511             :         }
    1512             : 
    1513           0 :         Application::SetDefDialogParent( pParent );
    1514             : 
    1515             :         // determine the implementation
    1516           0 :         SfxObjectShell* pShell = xDocShell;
    1517           0 :         DrawDocShell* pDocShell = PTR_CAST(DrawDocShell,pShell);
    1518           0 :         SdDrawDocument* pDoc = pDocShell?pDocShell->GetDoc():NULL;
    1519             : 
    1520           0 :         pShell = xLayoutDocShell;
    1521           0 :         pDocShell = PTR_CAST(DrawDocShell,pShell);
    1522           0 :         SdDrawDocument* pLayoutDoc = pDocShell?pDocShell->GetDoc():NULL;
    1523             : 
    1524           0 :         if( pDoc && pLayoutDoc )
    1525             :         {
    1526           0 :             pDoc->SetMasterPage(0, OUString(), pLayoutDoc, true,  false );
    1527             :         }
    1528             :         else
    1529             :         {
    1530             :             OSL_FAIL("sd::AssistentDlgImpl::UpdatePreview(), no document for preview?");
    1531             :         }
    1532             : 
    1533           0 :         mbUserDataDirty = true;
    1534             :     }
    1535           0 :     maLayoutFile = aLayoutFile;
    1536             : 
    1537           0 :     if(mbUserDataDirty)
    1538           0 :         UpdateUserData();
    1539             : 
    1540           0 :     if ( !xDocShell.Is() || !mbPreview )
    1541           0 :         mpPreview->SetObjectShell( 0 );
    1542             :     else
    1543             :     {
    1544           0 :         mpPreview->SetObjectShell( xDocShell, mnShowPage );
    1545             :     }
    1546             : 
    1547           0 :     mbPreviewUpdating = false;
    1548             : }
    1549             : 
    1550           0 : void AssistentDlgImpl::SavePassword( SfxObjectShellLock xDoc, const OUString& rPath )
    1551             : {
    1552           0 :     if(xDoc.Is())
    1553             :     {
    1554           0 :         SfxMedium * pMedium = xDoc->GetMedium();
    1555           0 :         if(pMedium && pMedium->IsStorage())
    1556             :         {
    1557           0 :           SfxItemSet * pSet = pMedium->GetItemSet();
    1558           0 :           SFX_ITEMSET_ARG( pSet, pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, false);
    1559           0 :           uno::Sequence < beans::NamedValue > aEncryptionData;
    1560           0 :           if (pEncryptionDataItem)
    1561           0 :               pEncryptionDataItem->GetValue() >>= aEncryptionData;
    1562             :           else
    1563           0 :               return;
    1564           0 :           if( aEncryptionData.getLength() )
    1565             :           {
    1566             : 
    1567           0 :             PasswordEntry* pEntry = NULL;
    1568           0 :             for ( size_t i = 0, n = maPasswordList.size(); i < n; ++i )
    1569             :             {
    1570           0 :                 if ( maPasswordList[ i ].maPath == rPath )
    1571             :                 {
    1572           0 :                     pEntry = &maPasswordList[ i ];
    1573           0 :                     break;
    1574             :                 }
    1575             :             }
    1576             : 
    1577           0 :             if(pEntry == NULL)
    1578             :             {
    1579           0 :                 pEntry = new PasswordEntry();
    1580           0 :                 pEntry->maPath = rPath;
    1581           0 :                 maPasswordList.push_back( pEntry );
    1582             :             }
    1583             : 
    1584           0 :             pEntry->aEncryptionData = aEncryptionData;
    1585           0 :           }
    1586             :         }
    1587             :     }
    1588             : }
    1589             : 
    1590           0 : void AssistentDlgImpl::RestorePassword( SfxItemSet* pSet, const OUString& rPath )
    1591             : {
    1592           0 :     uno::Sequence < beans::NamedValue > aEncryptionData( GetPassword( rPath ) );
    1593             : 
    1594           0 :     if(aEncryptionData.getLength())
    1595           0 :         pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
    1596           0 : }
    1597             : 
    1598           0 : uno::Sequence < beans::NamedValue > AssistentDlgImpl::GetPassword( const OUString& rPath )
    1599             : {
    1600           0 :     for ( size_t i = 0, n = maPasswordList.size(); i < n; ++i )
    1601             :     {
    1602           0 :         PasswordEntry* pEntry = &maPasswordList[ i ];
    1603           0 :         if(pEntry->maPath == rPath)
    1604           0 :             return pEntry->aEncryptionData;
    1605             :     }
    1606           0 :     return uno::Sequence < beans::NamedValue > ();;
    1607             : }
    1608             : 
    1609           0 : void AssistentDlgImpl::DeletePasswords()
    1610             : {
    1611           0 :     maPasswordList.clear();
    1612           0 : }
    1613             : 
    1614           0 : bool AssistentDlgImpl::IsOwnFormat( const OUString& rPath )
    1615             : {
    1616           0 :     INetURLObject   aURL( rPath );
    1617           0 :     OUString        aExt( aURL.GetFileExtension() );
    1618             : 
    1619             :     DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
    1620             : 
    1621           0 :     return !aExt.equalsIgnoreAsciiCase( "ppt" );
    1622             : }
    1623             : 
    1624           0 : OUString AssistentDlgImpl::GetUiTextForCommand (const OUString& sCommandURL)
    1625             : {
    1626           0 :     OUString sLabel;
    1627           0 :     Reference<container::XNameAccess> xUICommandLabels;
    1628             : 
    1629             :     try
    1630             :     {
    1631             :         do
    1632             :         {
    1633           0 :             if (sCommandURL.isEmpty())
    1634           0 :                 break;
    1635             : 
    1636             :             // Retrieve popup menu labels
    1637           0 :             Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
    1638           0 :             if ( ! xContext.is())
    1639           0 :                 break;
    1640             : 
    1641             :             Reference<container::XNameAccess> const xNameAccess(
    1642           0 :                     frame::theUICommandDescription::get(xContext) );
    1643           0 :             Any a = xNameAccess->getByName(
    1644           0 :                 "com.sun.star.presentation.PresentationDocument");
    1645           0 :             a >>= xUICommandLabels;
    1646           0 :             if ( ! xUICommandLabels.is())
    1647           0 :                 break;
    1648             : 
    1649           0 :             OUString sString;
    1650           0 :             Sequence<beans::PropertyValue> aProperties;
    1651           0 :             Any aAny (xUICommandLabels->getByName(sCommandURL));
    1652           0 :             if (aAny >>= aProperties)
    1653             :             {
    1654           0 :                 sal_Int32 nCount (aProperties.getLength());
    1655           0 :                 for (sal_Int32 i=0; i<nCount; i++)
    1656             :                 {
    1657           0 :                     OUString sPropertyName (aProperties[i].Name);
    1658           0 :                     if ( sPropertyName == "Label" )
    1659             :                     {
    1660           0 :                         aProperties[i].Value >>= sString;
    1661           0 :                         break;
    1662             :                     }
    1663           0 :                 }
    1664             :             }
    1665           0 :             sLabel = sString;
    1666             :         }
    1667             :         while(false);
    1668             :     }
    1669           0 :     catch (com::sun::star::uno::Exception& )
    1670             :     {
    1671             :     }
    1672             : 
    1673           0 :     return sLabel;
    1674             : }
    1675             : 
    1676           0 : Image AssistentDlgImpl::GetUiIconForCommand (const OUString& sCommandURL)
    1677             : {
    1678           0 :     Image aIcon;
    1679           0 :     Reference<container::XNameAccess> xUICommandLabels;
    1680             : 
    1681             :     try
    1682             :     {
    1683             :         do
    1684             :         {
    1685           0 :             if (sCommandURL.isEmpty())
    1686           0 :                 break;
    1687             : 
    1688             :             // Retrieve popup menu labels
    1689           0 :             Reference<uno::XComponentContext> xContext ( ::comphelper::getProcessComponentContext() );
    1690           0 :             if ( ! xContext.is())
    1691           0 :                 break;
    1692             : 
    1693             :             Reference<ui::XModuleUIConfigurationManagerSupplier> xSupplier (
    1694           0 :                 ui::theModuleUIConfigurationManagerSupplier::get(xContext));
    1695             : 
    1696             :             Reference<com::sun::star::ui::XUIConfigurationManager> xManager (
    1697           0 :                 xSupplier->getUIConfigurationManager(
    1698           0 :                     "com.sun.star.presentation.PresentationDocument"));
    1699           0 :             if ( ! xManager.is())
    1700           0 :                 break;
    1701             : 
    1702             :             Reference<com::sun::star::ui::XImageManager> xImageManager (
    1703           0 :                 xManager->getImageManager(),
    1704           0 :                 UNO_QUERY_THROW);
    1705             : 
    1706           0 :             Sequence<OUString> aCommandList(1);
    1707           0 :             aCommandList[0] = sCommandURL;
    1708             :             Sequence<Reference<graphic::XGraphic> > xIconList (
    1709           0 :                 xImageManager->getImages(0,aCommandList));
    1710           0 :             if ( ! xIconList.hasElements())
    1711           0 :                 break;
    1712             : 
    1713           0 :             aIcon = Image(Graphic(xIconList[0]).GetBitmapEx());
    1714             :         }
    1715             :         while(false);
    1716             :     }
    1717           0 :     catch (com::sun::star::uno::Exception& )
    1718             :     {
    1719             :     }
    1720             : 
    1721           0 :     return aIcon;
    1722             : }
    1723             : 
    1724           0 : AssistentDlg::AssistentDlg(vcl::Window* pParent, bool bAutoPilot) :
    1725           0 :     ModalDialog(pParent, "Assistent", "modules/simpress/ui/assistentdialog.ui")
    1726             : {
    1727           0 :     Link aFinishLink = LINK(this,AssistentDlg, FinishHdl);
    1728           0 :     mpImpl = new AssistentDlgImpl( this, aFinishLink, bAutoPilot );
    1729             : 
    1730             :     // button assigmnent
    1731           0 :     mpImpl->mpFinishButton->SetClickHdl(LINK(this,AssistentDlg,FinishHdl));
    1732           0 : }
    1733             : 
    1734           0 : IMPL_LINK_NOARG(AssistentDlg, FinishHdl)
    1735             : {
    1736           0 :     if( GetStartType() == ST_OPEN )
    1737             :     {
    1738             :         //if we do not have a file here asked for one before ending the dialog
    1739           0 :         OUString aFileToOpen = GetDocPath();
    1740           0 :         if (aFileToOpen.isEmpty())
    1741             :         {
    1742             :             sfx2::FileDialogHelper aFileDlg(
    1743             :                 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, 0,
    1744           0 :                 OUString("simpress") );
    1745             : 
    1746           0 :             if ( aFileDlg.Execute() == ERRCODE_NONE )
    1747           0 :                 aFileToOpen = aFileDlg.GetPath();
    1748           0 :             if (aFileToOpen.isEmpty())
    1749           0 :                 return 1;
    1750             :             else
    1751             :             {
    1752             :                 //add the selected file to the recent-file-listbox and select the new entry
    1753             :                 //this is necessary for 'GetDocPath()' returning the selected file after end of dialog
    1754             : 
    1755           0 :                 INetURLObject aURL;
    1756           0 :                 aURL.SetSmartURL(aFileToOpen);
    1757           0 :                 mpImpl->maOpenFilesList.push_back (aURL.GetMainURL(INetURLObject::NO_DECODE));
    1758           0 :                 sal_uInt16 nNewPos = mpImpl->mpPage1OpenLB->InsertEntry(aURL.getName());
    1759           0 :                 mpImpl->mpPage1OpenLB->SelectEntryPos(nNewPos);
    1760           0 :             }
    1761           0 :         }
    1762             :     }
    1763             : 
    1764             :     // end
    1765           0 :     mpImpl->EndDialog(RET_OK);
    1766           0 :     EndDialog(RET_OK);
    1767           0 :     return 0;
    1768             : }
    1769             : 
    1770           0 : AssistentDlg::~AssistentDlg()
    1771             : {
    1772           0 :     delete mpImpl;
    1773           0 : }
    1774             : 
    1775           0 : SfxObjectShellLock AssistentDlg::GetDocument()
    1776             : {
    1777           0 :     return mpImpl->GetDocument();
    1778             : }
    1779             : 
    1780           0 : OutputType AssistentDlg::GetOutputMedium() const
    1781             : {
    1782           0 :     if(mpImpl->mpPage2Medium1RB->IsChecked())
    1783           0 :         return OUTPUT_PRESENTATION;
    1784           0 :     else if(mpImpl->mpPage2Medium2RB->IsChecked())
    1785           0 :         return OUTPUT_SLIDE;
    1786           0 :     else if(mpImpl->mpPage2Medium3RB->IsChecked())
    1787           0 :         return OUTPUT_OVERHEAD;
    1788           0 :     else if(mpImpl->mpPage2Medium4RB->IsChecked())
    1789           0 :         return OUTPUT_PAGE;
    1790           0 :     else if(mpImpl->mpPage2Medium6RB->IsChecked())
    1791           0 :         return OUTPUT_WIDESCREEN;
    1792             :     else
    1793           0 :         return OUTPUT_ORIGINAL;
    1794             : }
    1795             : 
    1796           0 : bool AssistentDlg::IsSummary() const
    1797             : {
    1798           0 :     return mpImpl->mpPage5SummaryCB->IsChecked();
    1799             : }
    1800             : 
    1801           0 : StartType AssistentDlg::GetStartType() const
    1802             : {
    1803           0 :     return mpImpl->GetStartType();
    1804             : }
    1805             : 
    1806           0 : OUString AssistentDlg::GetDocPath() const
    1807             : {
    1808           0 :     return mpImpl->GetDocFileName();
    1809             : }
    1810             : 
    1811           0 : bool AssistentDlg::GetStartWithFlag() const
    1812             : {
    1813           0 :     return !mpImpl->mpStartWithFlag->IsChecked();
    1814             : }
    1815             : 
    1816           0 : bool AssistentDlg::IsDocEmpty() const
    1817             : {
    1818           0 :     return mpImpl->GetDocFileName().isEmpty() &&
    1819           0 :            mpImpl->GetLayoutFileName().isEmpty();
    1820             : }
    1821             : 
    1822           0 : uno::Sequence< beans::NamedValue > AssistentDlg::GetPassword()
    1823             : {
    1824           0 :     return mpImpl->GetPassword( mpImpl->maDocFile );
    1825             : }
    1826             : 
    1827             : //===== NextButton ============================================================
    1828             : 
    1829           0 : NextButton::NextButton (vcl::Window* pParent) :
    1830           0 :       mbIsFirstButtonActive(true)
    1831             : {
    1832           0 :     AssistentDlg* assDlg = static_cast<AssistentDlg*>(pParent);
    1833           0 :     assDlg->get(mpNextButton1, "nextPage1Button");
    1834           0 :     assDlg->get(mpNextButton2, "nextPage2Button");
    1835             :     // Hide the unused button.
    1836           0 :     mpNextButton2->Hide();
    1837           0 : }
    1838             : 
    1839           0 : void NextButton::ForceFocusEventBroadcast (void)
    1840             : {
    1841             :     // Hide the currently visible button and show and focus the other one.
    1842           0 :     if (mbIsFirstButtonActive)
    1843             :     {
    1844           0 :         mbIsFirstButtonActive = false;
    1845           0 :         mpNextButton2->Show();
    1846           0 :         mpNextButton2->GrabFocus();
    1847           0 :         mpNextButton1->Hide();
    1848             :     }
    1849             :     else
    1850             :     {
    1851           0 :         mbIsFirstButtonActive = true;
    1852           0 :         mpNextButton1->Show();
    1853           0 :         mpNextButton1->GrabFocus();
    1854           0 :         mpNextButton2->Hide();
    1855             :     }
    1856           0 : }
    1857             : 
    1858           0 : void NextButton::SetClickHdl (const Link& rLink)
    1859             : {
    1860             :     // Forward the setting of the click handler to the two buttons
    1861             :     // regardless of which one is currently visible.
    1862           0 :     mpNextButton1->SetClickHdl(rLink);
    1863           0 :     mpNextButton2->SetClickHdl(rLink);
    1864           0 : }
    1865             : 
    1866           0 : bool NextButton::IsEnabled (void)
    1867             : {
    1868             :     // Because the buttons are both either enabled or disabled, it is
    1869             :     // sufficient to ask one to determine the state.
    1870           0 :     return mpNextButton1->IsEnabled();
    1871             : }
    1872             : 
    1873           0 : void NextButton::Enable (bool bEnable)
    1874             : {
    1875             :     // Enable or disable both buttons but do not change visibility or focus.
    1876           0 :     mpNextButton1->Enable(bEnable);
    1877           0 :     mpNextButton2->Enable(bEnable);
    1878           0 : }
    1879             : 
    1880             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10