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

Generated by: LCOV version 1.11