diff options
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/doctdlg.cxx | 206 | ||||
-rw-r--r-- | sfx2/source/doc/doctdlg.hrc | 32 | ||||
-rw-r--r-- | sfx2/source/doc/doctdlg.src | 108 | ||||
-rw-r--r-- | sfx2/source/doc/docvor.cxx | 2390 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 1 |
5 files changed, 0 insertions, 2737 deletions
diff --git a/sfx2/source/doc/doctdlg.cxx b/sfx2/source/doc/doctdlg.cxx deleted file mode 100644 index 0c151035c8a2..000000000000 --- a/sfx2/source/doc/doctdlg.cxx +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <vcl/msgbox.hxx> -#include <svl/stritem.hxx> - -#include <sfx2/doctdlg.hxx> -#include "docvor.hxx" -#include "sfx2/sfxresid.hxx" -#include "sfxtypes.hxx" -#include <sfx2/dispatch.hxx> -#include <sfx2/app.hxx> - -#include <sfx2/sfx.hrc> -#include "doc.hrc" -#include "doctdlg.hrc" -#include <sfx2/basedlgs.hxx> - -//========================================================================= - -SfxDocumentTemplateDlg::SfxDocumentTemplateDlg( Window * pParent, SfxDocumentTemplates* pTempl ) : - - ModalDialog( pParent, SfxResId( DLG_DOC_TEMPLATE ) ), - - aEditFL ( this, SfxResId( FL_EDIT ) ), - aNameEd ( this, SfxResId( ED_NAME ) ), - aTemplateFL ( this, SfxResId( FL_STYLESHEETS ) ), - aRegionFt ( this, SfxResId( FT_SECTION ) ), - aRegionLb ( this, SfxResId( LB_SECTION ) ), - aTemplateFt ( this, SfxResId( FT_STYLESHEETS ) ), - aTemplateLb ( this, SfxResId( LB_STYLESHEETS ) ), - - aOkBt ( this, SfxResId( BT_OK ) ), - aCancelBt ( this, SfxResId( BT_CANCEL ) ), - aHelpBt ( this, SfxResId( BT_HELP ) ), - aEditBt ( this, SfxResId( BT_EDIT ) ), - aOrganizeBt ( this, SfxResId( BT_ORGANIZE ) ), - - pTemplates ( pTempl ), - pHelper ( NULL ) - -{ - FreeResource(); - - pHelper = new SfxModalDefParentHelper( this ); - aOrganizeBt.SetClickHdl(LINK(this, SfxDocumentTemplateDlg, OrganizeHdl)); - aNameEd.SetModifyHdl(LINK(this, SfxDocumentTemplateDlg, NameModify)); - aOkBt.SetClickHdl(LINK(this, SfxDocumentTemplateDlg, OkHdl)); - aEditBt.SetClickHdl(LINK(this, SfxDocumentTemplateDlg, EditHdl)); - Init(); -} - -//------------------------------------------------------------------------- - -SfxDocumentTemplateDlg::~SfxDocumentTemplateDlg() -{ - delete pHelper; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxDocumentTemplateDlg, EditHdl, Button *, pBut ) -{ - (void)pBut; //unused - if ( !aRegionLb.GetSelectEntryCount() || - !aTemplateLb.GetSelectEntryCount()) - return 0; - - const SfxStringItem aRegion( SID_TEMPLATE_REGIONNAME, aRegionLb.GetSelectEntry() ); - const SfxStringItem aName( SID_TEMPLATE_NAME, aTemplateLb.GetSelectEntry() ); - SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_OPENTEMPLATE, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, &aRegion, &aName, 0L ); - EndDialog(RET_EDIT_STYLE); - - return 0; -} - -//------------------------------------------------------------------------- - -void SfxDocumentTemplateDlg::Init() -{ - if(!pTemplates->IsConstructed()) - pTemplates->Construct(); - - const sal_uInt16 nCount = pTemplates->GetRegionCount(); - for(sal_uInt16 i = 0; i < nCount; ++i) - aRegionLb.InsertEntry(pTemplates->GetFullRegionName(i)); - if(!nCount) - aRegionLb.InsertEntry(SfxResId(STR_STANDARD).toString()); - aRegionLb.SelectEntryPos(0); - if(nCount) - { - aRegionLb.SetSelectHdl(LINK(this, SfxDocumentTemplateDlg, RegionSelect)); - RegionSelect(&aRegionLb); - aTemplateLb.SetSelectHdl(LINK(this, SfxDocumentTemplateDlg, TemplateSelect)); - aTemplateLb.SetDoubleClickHdl(LINK(this, SfxDocumentTemplateDlg, EditHdl)); - } - else { - Link aLink; - aTemplateLb.SetSelectHdl(aLink); - aTemplateLb.SetDoubleClickHdl(aLink); - } -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxDocumentTemplateDlg, OrganizeHdl, Button *, pButton ) -{ - (void)pButton; //unused - SfxTemplateOrganizeDlg *pDlg = - new SfxTemplateOrganizeDlg(this, pTemplates); - const short nRet = pDlg->Execute(); - delete pDlg; - if(RET_OK == nRet) - { - // View aktualisieren - aRegionLb.SetUpdateMode( sal_False ); - aRegionLb.Clear(); - Init(); - aRegionLb.SetUpdateMode( sal_True ); - aRegionLb.Invalidate(); - aRegionLb.Update(); - aCancelBt.SetText(SfxResId(STR_CLOSE).toString()); - } - else if(RET_EDIT_STYLE == nRet) - EndDialog(RET_CANCEL); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxDocumentTemplateDlg, OkHdl, Control *, pControl ) -{ - (void)pControl; //unused - // Test whether a template with this name exists - if(LISTBOX_ENTRY_NOTFOUND != aTemplateLb.GetEntryPos( - GetTemplateName())) { - QueryBox aQuery(this, SfxResId(MSG_CONFIRM_OVERWRITE_TEMPLATE)); - if(RET_NO == aQuery.Execute()) - return 0; - } - EndDialog(RET_OK); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxDocumentTemplateDlg, RegionSelect, ListBox *, pBox ) -{ - const sal_uInt16 nRegion = pBox->GetSelectEntryPos(); - const sal_uInt16 nCount = pTemplates->GetCount(nRegion); - aTemplateLb.SetUpdateMode(sal_False); - aTemplateLb.Clear(); - for(sal_uInt16 i = 0; i < nCount; ++i) - aTemplateLb.InsertEntry(pTemplates->GetName(nRegion, i)); - aTemplateLb.SelectEntryPos(0); - aTemplateLb.SetUpdateMode(sal_True); - aTemplateLb.Invalidate(); - aTemplateLb.Update(); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_INLINE_START( SfxDocumentTemplateDlg, TemplateSelect, ListBox *, pBox ) -{ - aNameEd.SetText(pBox->GetSelectEntry()); - NameModify(&aNameEd); - return 0; -} -IMPL_LINK_INLINE_END( SfxDocumentTemplateDlg, TemplateSelect, ListBox *, pBox ) - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxDocumentTemplateDlg, NameModify, Edit *, pBox ) -{ - const String &rText=pBox->GetText(); - if(!rText.Len()) - aEditBt.Enable(); - else - { - aTemplateLb.SelectEntry(rText); - aEditBt.Enable( aTemplateLb.GetSelectEntry() == rText ); - } - - aOkBt.Enable( rText.Len() > 0 ); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/doctdlg.hrc b/sfx2/source/doc/doctdlg.hrc deleted file mode 100644 index 219db5b696ff..000000000000 --- a/sfx2/source/doc/doctdlg.hrc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#define FT_SECTION 1 -#define LB_SECTION 2 -#define FT_STYLESHEETS 3 -#define LB_STYLESHEETS 4 -#define BT_ORGANIZE 20 -#define BT_HELP 21 -#define FL_EDIT 5 -#define FT_NAME 6 -#define ED_NAME 7 -#define BT_OK 10 -#define BT_EDIT 12 -#define BT_NEW 13 -#define BT_DELETE 15 -#define BT_CANCEL 16 -#define FL_STYLESHEETS 17 diff --git a/sfx2/source/doc/doctdlg.src b/sfx2/source/doc/doctdlg.src deleted file mode 100644 index 3aaf703d1c9c..000000000000 --- a/sfx2/source/doc/doctdlg.src +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sfx2/sfx.hrc> -#include "doc.hrc" -#include "doctdlg.hrc" -#include <sfx2/sfxcommands.h> - -ModalDialog DLG_DOC_TEMPLATE -{ - HelpId = CMD_SID_DOCTEMPLATE ; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 280 , 128 ) ; - Text [ en-US ] = "Templates" ; - Moveable = TRUE ; - FixedLine FL_EDIT - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 212 , 8 ) ; - Text [ en-US ] = "New template" ; - }; - Edit ED_NAME - { - HelpID = "sfx2:Edit:DLG_DOC_TEMPLATE:ED_NAME"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 200 , 12 ) ; - }; - FixedLine FL_STYLESHEETS - { - Pos = MAP_APPFONT ( 6 , 32 ) ; - Size = MAP_APPFONT ( 212 , 8 ) ; - Text [ en-US ] = "Templates" ; - }; - FixedText FT_SECTION - { - Pos = MAP_APPFONT ( 12 , 43 ) ; - Size = MAP_APPFONT ( 97 , 10 ) ; - Text [ en-US ] = "~Categories" ; - }; - ListBox LB_SECTION - { - HelpID = "sfx2:ListBox:DLG_DOC_TEMPLATE:LB_SECTION"; - Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 56 ) ; - Size = MAP_APPFONT ( 97 , 66 ) ; - }; - FixedText FT_STYLESHEETS - { - Pos = MAP_APPFONT ( 115 , 43 ) ; - Size = MAP_APPFONT ( 97 , 10 ) ; - Text [ en-US ] = "~Templates" ; - }; - ListBox LB_STYLESHEETS - { - HelpID = "sfx2:ListBox:DLG_DOC_TEMPLATE:LB_STYLESHEETS"; - Border = TRUE ; - Pos = MAP_APPFONT ( 115 , 56 ) ; - Size = MAP_APPFONT ( 97 , 66 ) ; - }; - OKButton BT_OK - { - Pos = MAP_APPFONT ( 224 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - DefButton = TRUE ; - Disable = TRUE ; - }; - CancelButton BT_CANCEL - { - Pos = MAP_APPFONT ( 224 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - }; - HelpButton BT_HELP - { - Pos = MAP_APPFONT ( 224 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - }; - PushButton BT_EDIT - { - HelpID = "sfx2:PushButton:DLG_DOC_TEMPLATE:BT_EDIT"; - Pos = MAP_APPFONT ( 224 , 62 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - Text [ en-US ] = "~Edit" ; - }; - PushButton BT_ORGANIZE - { - HelpID = "sfx2:PushButton:DLG_DOC_TEMPLATE:BT_ORGANIZE"; - Pos = MAP_APPFONT ( 224 , 79 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - Text [ en-US ] = "~Organizer..." ; - }; -}; diff --git a/sfx2/source/doc/docvor.cxx b/sfx2/source/doc/docvor.cxx deleted file mode 100644 index 81bf89d3f16f..000000000000 --- a/sfx2/source/doc/docvor.cxx +++ /dev/null @@ -1,2390 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/embed/XStorage.hpp> -#include <com/sun/star/embed/ElementModes.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" - -#include <stdio.h> - -#include <svtools/prnsetup.hxx> -#include <vcl/cmdevt.hxx> -#include <vcl/menubtn.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/print.hxx> -#include <svl/style.hxx> -#include <svl/stritem.hxx> -#include <svl/eitem.hxx> -#include <svtools/sfxecode.hxx> -#include <svtools/ehdl.hxx> -#include <svtools/imagemgr.hxx> -#include <vcl/waitobj.hxx> -#include <tools/urlobj.hxx> -#include <tools/color.hxx> -#include <unotools/pathoptions.hxx> -#include <unotools/moduleoptions.hxx> -#include <sot/exchange.hxx> -#include <comphelper/storagehelper.hxx> - -#include "helpid.hrc" -#include "docvor.hxx" -#include <sfx2/docfac.hxx> -#include "orgmgr.hxx" -#include <sfx2/doctempl.hxx> -#include <sfx2/templdlg.hxx> -#include "sfxtypes.hxx" -#include <sfx2/app.hxx> -#include <sfx2/dispatch.hxx> -#include "sfx2/sfxresid.hxx" -#include "doc.hrc" -#include <sfx2/sfx.hrc> -#include <sfx2/docfilt.hxx> -#include <sfx2/filedlghelper.hxx> -#include <sfx2/fcontnr.hxx> -#include <svtools/localresaccess.hxx> -#include <svtools/addresstemplate.hxx> -#include "svtools/treelistentry.hxx" -#include <comphelper/processfactory.hxx> - -#define ID_NEW 1 -#define ID_DELETE 2 -#define ID_EDIT 3 -//seperator -#define ID_COPY_FROM 5 -#define ID_COPY_TO 6 -//seperator -#define ID_PRINT 8 -#define ID_PRINTER_SETUP 9 -//seperator -#define ID_RESCAN 11 -//seperator -#define ID_DEFAULT_TEMPLATE 13 -#define ID_RESET_DEFAULT_TEMPLATE 14 - -sal_Bool SfxOrganizeListBox_Impl::bDropMoveOk = sal_True; - -using namespace ::com::sun::star; - -//========================================================================= - -class SuspendAccel -{ -public: - Accelerator* pAccel; - - SuspendAccel( Accelerator* pA ) - { - pAccel=pA; - GetpApp()->RemoveAccel( pAccel ); - } - ~SuspendAccel() - { - GetpApp()->InsertAccel( pAccel ); - } -}; - -//========================================================================= - -extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSfxOrganizeListBox(Window *pParent, - VclBuilder::stringmap &) -{ - return new SfxOrganizeListBox_Impl(pParent, WB_BORDER | WB_TABSTOP | WB_HSCROLL); -} - -inline void SfxOrganizeListBox_Impl::SetBitmaps( - const Image &rOFolder, const Image &rCFolder, const Image &rODoc, const Image &rCDoc ) -{ - aOpenedFolderBmp = rOFolder; - aClosedFolderBmp = rCFolder; - aOpenedDocBmp = rODoc; - aClosedDocBmp = rCDoc; - -} - -//========================================================================= - -#define NO_DROP_ACTION ((sal_Int8)-1) - -class SfxOrganizeDlg_Impl -{ -friend class SfxTemplateOrganizeDlg; -friend class SfxOrganizeListBox_Impl; - - SuspendAccel* pSuspend; - SfxTemplateOrganizeDlg* pDialog; - - SfxOrganizeListBox_Impl* pFocusBox; - Printer* pPrt; - - // save pointer for asynchronous D&D - SvTreeListBox* pSourceView; - SvTreeListEntry* pTargetEntry; - SfxOrganizeListBox_Impl* pFinishedBox; - sal_Int8 nDropAction; - bool bExecDropFinished; - - // save some variables for the asynchronous file dialog - sal_uInt16 m_nRegion; - sal_uInt16 m_nIndex; - String m_sExtension4Save; - - SfxOrganizeListBox_Impl* m_pLeftLb; - ListBox* m_pLeftTypLb; - - SfxOrganizeListBox_Impl* m_pRightLb; - ListBox* m_pRightTypLb; - - MenuButton* m_pEditBtn; - PushButton* m_pAddressTemplateBtn; - PushButton* m_pFilesBtn; - - Accelerator aEditAcc; - - String aLastDir; - SfxOrganizeMgr aMgr; - sfx2::FileDialogHelper* pFileDlg; - - std::vector<rtl::OUString> GetAllFactoryURLs_Impl() const; - sal_Bool GetServiceName_Impl( String& rFactoryURL, String& rFileURL ) const; - long Dispatch_Impl( sal_uInt16 nId, Menu* _pMenu ); - String GetPath_Impl( sal_Bool bOpen, const String& rFileName ); - ::com::sun::star::uno::Sequence< ::rtl::OUString > - GetPaths_Impl( const String& rFileName ); - void InitBitmaps( void ); - - DECL_LINK( GetFocus_Impl, SfxOrganizeListBox_Impl * ); - DECL_LINK( LeftListBoxSelect_Impl, ListBox * ); - DECL_LINK( RightListBoxSelect_Impl, ListBox * ); - DECL_LINK( AccelSelect_Impl, Accelerator * ); - DECL_LINK( MenuSelect_Impl, Menu * ); - DECL_LINK( MenuActivate_Impl, Menu * ); - DECL_LINK( AddFiles_Impl, Button * ); - DECL_LINK( OnAddressTemplateClicked, void * ); - DECL_LINK( Close_Impl, void * ); - - DECL_LINK(ImportHdl, void *); - DECL_LINK(ExportHdl, void *); - DECL_LINK(AddFilesHdl, void *); - - sal_Bool DontDelete_Impl( SvTreeListEntry* pEntry ); - -public: - SfxOrganizeDlg_Impl( SfxTemplateOrganizeDlg* pParent, SfxDocumentTemplates* pTempl ); - ~SfxOrganizeDlg_Impl(); -}; - -//------------------------------------------------------------------------- - -SfxOrganizeDlg_Impl::SfxOrganizeDlg_Impl( SfxTemplateOrganizeDlg* pParent, - SfxDocumentTemplates* pTempl ) : - pSuspend ( NULL ), - pDialog ( pParent ), - pFocusBox ( NULL ), - pPrt ( NULL ), - pSourceView ( NULL ), - pTargetEntry ( NULL ), - pFinishedBox ( NULL ), - nDropAction ( NO_DROP_ACTION ), - bExecDropFinished ( true ), - - aMgr ( pTempl ), - pFileDlg ( NULL ) - -{ - aEditAcc.InsertItem(ID_NEW, KeyCode(KEY_INSERT)); - aEditAcc.InsertItem(ID_DELETE, KeyCode(KEY_DELETE)); - - pDialog->get(m_pLeftTypLb, "lefttype"); - pDialog->get(m_pLeftLb, "leftorganizer"); - m_pLeftLb->Init(this, SfxOrganizeListBox_Impl::VIEW_TEMPLATES); - - //20 lines - m_pLeftLb->set_height_request(m_pLeftLb->GetEntryHeight() * 20); - - pDialog->get(m_pRightTypLb, "righttype"); - pDialog->get(m_pRightLb, "rightorganizer"); - m_pRightLb->Init(this, SfxOrganizeListBox_Impl::VIEW_FILES); - - pDialog->get(m_pEditBtn, "commands"); - pDialog->get(m_pAddressTemplateBtn, "addressbook"); - pDialog->get(m_pFilesBtn, "file"); - - PushButton *pClose = pDialog->get<PushButton>("close"); - pClose->SetClickHdl(LINK(this,SfxOrganizeDlg_Impl, Close_Impl)); - - // update the SfxDocumentTemplates the manager works with - if ( aMgr.GetTemplates() ) // should never fail, but who knows .... - { - // for this, show a wait cursor (it may take a while) - Window* pWaitObjectRange = pDialog ? pDialog->GetParent() : NULL; - if ( !pWaitObjectRange ) - pWaitObjectRange = pDialog; - - WaitObject aWaitCursor( pWaitObjectRange ); - const_cast< SfxDocumentTemplates* >( aMgr.GetTemplates() )->Update( sal_True /* be smart */ ); - // this const_cast is a hack - but the alternative would be to - // * have a method which returns the templates non-const - // * use a new SfxDocumentTemplates instance for the update - // (knowing that they all share the same implementation class) - // * always work with an own instance, even if we get only NULL in this ctor - } - - String aWorkPath = SvtPathOptions().GetWorkPath(); - if ( aWorkPath.Len() ) - { - INetURLObject aObj( aWorkPath ); - DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL !" ); - aObj.setFinalSlash(); - aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - else - { - // fallback - String aProgURL = SvtPathOptions().SubstituteVariable( rtl::OUString("$(PROGURL)") ); - INetURLObject aObj( aProgURL ); - DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL !" ); - aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - - InitBitmaps(); - - m_pEditBtn->GetPopupMenu()->SetSelectHdl( LINK( this, SfxOrganizeDlg_Impl, MenuSelect_Impl ) ); - m_pEditBtn->GetPopupMenu()->SetActivateHdl( LINK( this, SfxOrganizeDlg_Impl, MenuActivate_Impl ) ); - aEditAcc.SetSelectHdl( LINK( this, SfxOrganizeDlg_Impl, AccelSelect_Impl ) ); - GetpApp()->InsertAccel( &aEditAcc ); - - m_pFilesBtn->SetClickHdl( - LINK(this,SfxOrganizeDlg_Impl, AddFiles_Impl)); - m_pAddressTemplateBtn->SetClickHdl( - LINK(this,SfxOrganizeDlg_Impl, OnAddressTemplateClicked)); - m_pLeftTypLb->SetSelectHdl( - LINK(this, SfxOrganizeDlg_Impl, LeftListBoxSelect_Impl)); - m_pRightTypLb->SetSelectHdl( - LINK(this, SfxOrganizeDlg_Impl, RightListBoxSelect_Impl)); - m_pLeftLb->SetGetFocusHdl( - LINK(this, SfxOrganizeDlg_Impl, GetFocus_Impl)); - m_pRightLb->SetGetFocusHdl( - LINK(this, SfxOrganizeDlg_Impl, GetFocus_Impl)); - m_pLeftLb->SetPosSizePixel(pParent->LogicToPixel(Point(3, 6), MAP_APPFONT), - pParent->LogicToPixel(Size(94, 132), MAP_APPFONT)); - m_pRightLb->SetPosSizePixel(pParent->LogicToPixel(Point(103, 6), MAP_APPFONT), - pParent->LogicToPixel(Size(94, 132), MAP_APPFONT)); - - if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) ) - m_pAddressTemplateBtn->Hide(); - Font aFont(m_pLeftLb->GetFont()); - aFont.SetWeight(WEIGHT_NORMAL); - m_pLeftLb->SetFont(aFont); - m_pRightLb->SetFont(aFont); - const long nIndent = m_pLeftLb->GetIndent() / 2; - m_pLeftLb->SetIndent( (short)nIndent ); - m_pRightLb->SetIndent( (short)nIndent ); - - m_pLeftLb->SetMgr(&aMgr); - m_pRightLb->SetMgr(&aMgr); - m_pLeftLb->Reset(); - m_pRightLb->Reset();//SetModel(m_pLeftLb->GetModel()); - - m_pLeftLb->Show(); - m_pRightLb->Show(); - - m_pLeftLb->SelectAll( sal_False ); - m_pRightLb->SelectAll( sal_False ); - m_pRightLb->GrabFocus(); -} - -//------------------------------------------------------------------------- - -SfxOrganizeDlg_Impl::~SfxOrganizeDlg_Impl() -{ - delete pFileDlg; -} - -//------------------------------------------------------------------------- - -void SfxOrganizeDlg_Impl::InitBitmaps( void ) -{ - const Image& rOpenedFolderBmp(pDialog->get<FixedImage>("folderop")->GetImage()); - const Image& rClosedFolderBmp(pDialog->get<FixedImage>("foldercl")->GetImage()); - const Image& rOpenedDocBmp(pDialog->get<FixedImage>("docop")->GetImage()); - const Image& rClosedDocBmp(pDialog->get<FixedImage>("doccl")->GetImage()); - - m_pLeftLb->SetBitmaps(rOpenedFolderBmp, rClosedFolderBmp, rOpenedDocBmp, rClosedDocBmp); - m_pRightLb->SetBitmaps(rOpenedFolderBmp, rClosedFolderBmp, rOpenedDocBmp, rClosedDocBmp); -} - -//========================================================================= - -sal_Bool QueryDelete_Impl(Window *pParent, // Parent to QueryBox - sal_uInt16 nId, // Resource Id - const String &rTemplateName) // Name of template to be deleted -/* [Description] - - Delete Query - -*/ -{ - SfxResId aResId( nId ); - String aEntryText( aResId.toString() ); - aEntryText.SearchAndReplaceAscii( "$1", rTemplateName ); - QueryBox aBox( pParent, WB_YES_NO | WB_DEF_NO, aEntryText ); - return RET_NO != aBox.Execute(); -} - -//------------------------------------------------------------------------- - -void ErrorDelete_Impl(Window *pParent, const String &rName, sal_Bool bFolder = sal_False ) - -/* [Description] - - User information that the template rName could not be deleted. -*/ -{ - if ( bFolder ) - { - rtl::OUString aText(SfxResId(STR_ERROR_DELETE_TEMPLATE_DIR).toString()); - ErrorBox( pParent, WB_OK, aText ).Execute(); - } - else - { - String aText( SfxResId(STR_ERROR_DELETE_TEMPLATE).toString() ); - aText.SearchAndReplaceAscii( "$1", rName ); - ErrorBox( pParent, WB_OK, aText ).Execute(); - } -} - - -//========================================================================= - -/* [Description] - - Implementation class, the benchmark for sal_uInt16-Array -*/ - -struct ImpPath_Impl -{ - std::vector<sal_uInt16> aUS; - sal_uInt16 nRef; - - ImpPath_Impl(); - ImpPath_Impl( const ImpPath_Impl& rCopy ); -}; - -//------------------------------------------------------------------------- - -ImpPath_Impl::ImpPath_Impl() : nRef(1) -{ -} - -//------------------------------------------------------------------------- - -ImpPath_Impl::ImpPath_Impl( const ImpPath_Impl& rCopy ) : - - aUS(rCopy.aUS), nRef( 1 ) - -{ -} - -//========================================================================== - -/* [Description] - - Implementation class, presentation of a position in the Outline- - Listbox ass sal_uInt16-Array, this describes the position of each as - Postions relative to the parent entry -*/ -class Path -{ - ImpPath_Impl *pData; -public: - Path(SvTreeListBox *pBox, SvTreeListEntry *pEntry); - Path(const Path &rPath): - pData(rPath.pData) - { - ++pData->nRef; - } - const Path &operator=(const Path &rPath) - { - if(&rPath != this) - { - if(!--pData->nRef) - delete pData; - pData = rPath.pData; - pData->nRef++; - } - return *this; - } - ~Path() - { - if(!--pData->nRef) - delete pData; - } - sal_uInt16 Count() const { return pData->aUS.size(); } - sal_uInt16 operator[]( sal_uInt16 i ) const - { - return i < Count()? pData->aUS[i]: INDEX_IGNORE; - } -}; - -//------------------------------------------------------------------------- - -Path::Path(SvTreeListBox *pBox, SvTreeListEntry *pEntry) : - pData(new ImpPath_Impl) -{ - DBG_ASSERT(pEntry != 0, "EntryPtr ist NULL"); - if(!pEntry) - return; - SvTreeListEntry *pParent = pBox->GetParent(pEntry); - do { - pData->aUS.insert(pData->aUS.begin(), - (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry)); - if(0 == pParent) - break; - pEntry = pParent; - pParent = pBox->GetParent(pEntry); - } while(1); -} - -//------------------------------------------------------------------------- - -SvTreeListEntry *GetIndices_Impl(SvTreeListBox *pBox, - SvTreeListEntry *pEntry, - sal_uInt16 &rRegion, - sal_uInt16 &rOffset) -/* [Description] - - Region and position within a range for a template is determined. - - [Parameter] - - SvTreeListBox *pBox Listbox where the event occurred - SvTreeListEntry *pEntry Entry whose position is to be determined - sal_uInt16 &rRegion the region within the region of the - document template (Out-Parameter) - sal_uInt16 &rOffset the position within the region of the - document template (Out-Parameter) - - - [Cross-references] - - <class Path> (in certain circumstances this function can also be - dispensed in favor of the Path) -*/ - -{ - if(!pEntry) - { - rRegion = rOffset = 0; - return pEntry; - } - if(0 == pBox->GetModel()->GetDepth(pEntry)) - { - rRegion = (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry); - rOffset = USHRT_MAX; - return pEntry; - } - SvTreeListEntry *pParent = pBox->GetParent(pEntry); - rRegion = (sal_uInt16)pBox->GetModel()->GetRelPos(pParent); - rOffset = (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry); - return pEntry; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::Select( SvTreeListEntry* pEntry, sal_Bool bSelect ) -{ - if(!bSelect) - return SvTreeListBox::Select(pEntry,bSelect); - sal_uInt16 nLevel = GetDocLevel(); - if(GetModel()->GetDepth(pEntry)+nLevel<3) - return SvTreeListBox::Select(pEntry,bSelect); - - Path aPath(this, pEntry); - - // it is ok to use the SfxObjectShellRef here since the object that - // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it - GetObjectShell(aPath)->TriggerHelpPI( - aPath[nLevel+1], aPath[nLevel+2]); - return SvTreeListBox::Select(pEntry,bSelect); -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy) -/* [Description] - - Move or copy a document templates - - [Parameter] - - SvTreeListBox *pSourceBox Source Listbox, at which the event occurred - SvTreeListEntry* pTarget Target entry, to where it will be moved - SvTreeListEntry *pSource Source entry, to be copied / moved - SvTreeListEntry *&pNewParent the parent of the target position generated - at entry (out parameter) - sal_uIntPtr &rIdx Index of the target entry - sal_Bool bCopy Flag for Copy / Move - - - [Return value] sal_Bool: Success or failure - - [Cross-references] - - <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> -*/ - -{ - sal_Bool bOk = sal_False; - - if(pSource) - { - sal_uInt16 nTargetRegion = 0, nTargetIndex = 0; - GetIndices_Impl(this, pTarget, nTargetRegion, nTargetIndex); - - sal_uInt16 nSourceRegion = 0, nSourceIndex = 0; - GetIndices_Impl(pSourceBox, pSource, nSourceRegion, nSourceIndex); - - bOk = bCopy ? - pMgr->Copy(nTargetRegion, nTargetIndex+1, - nSourceRegion, nSourceIndex): - pMgr->Move(nTargetRegion, nTargetIndex+1, - nSourceRegion, nSourceIndex); - - if(bOk) - { - if(pSourceBox->GetModel()->GetDepth(pSource) == GetModel()->GetDepth(pTarget)) - { - pNewParent = GetParent(pTarget); - rIdx = GetModel()->GetRelPos(pTarget)+1; - } - else - { - if(nTargetIndex == USHRT_MAX) - { - pNewParent = pTarget; - rIdx = 0; - } - else - SvTreeListBox::NotifyCopying( - pTarget, pSource, pNewParent, rIdx); - } - } - else if ( bCopy ) - { - // the template organizer always tries copy after the move, so no error is required for move case - String aText( SfxResId( bCopy ? STR_ERROR_COPY_TEMPLATE : STR_ERROR_MOVE_TEMPLATE ).toString() ); - aText.SearchAndReplaceAscii( "$1", - ( (SvTreeListBox *)pSourceBox )->GetEntryText( pSource ) ); - ErrorBox( this, WB_OK, aText ).Execute(); - } - } - return bOk; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::MoveOrCopyContents(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy) -/* [Description] - - Move or copy document contents - - [Parameter] - - SvTreeListBox *pSourceBox Source Listbox, at which the event occurred - SvTreeListEntry* pTarget Target entry, to where it will be moved - SvTreeListEntry *pSource Source entry, to be copied / moved - SvTreeListEntry *&pNewParent the parent of the target position generated - at entry (out parameter) - sal_uIntPtr &rIdx Index of the target entry - sal_Bool bCopy Flag for Copy / Move - - - [Return value] sal_Bool: Success or failure - - [Cross-references] - - <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> -*/ - -{ - SfxErrorContext aEc( ERRCTX_SFX_MOVEORCOPYCONTENTS, this); - sal_Bool bOk = sal_False, bKeepExpansion = sal_False; - sal_Bool bRemovedFromSource = sal_False; - Path aSource(pSourceBox, pSource); - Path aTarget(this, pTarget); - - // it is ok to use the SfxObjectShellRef here since the object that - // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it - SfxObjectShellRef aSourceDoc = ((SfxOrganizeListBox_Impl *)pSourceBox)->GetObjectShell(aSource); - SfxObjectShellRef aTargetDoc = GetObjectShell(aTarget); - - const sal_uInt16 nSLevel = - ((SfxOrganizeListBox_Impl *)pSourceBox)->GetDocLevel(); - const sal_uInt16 nTLevel = GetDocLevel(); - - if(aSourceDoc.Is() && aTargetDoc.Is()) - { - if (aSourceDoc->GetStyleSheetPool()) - aSourceDoc->GetStyleSheetPool()->SetSearchMask( - SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED); - - if (aTargetDoc->GetStyleSheetPool()) - aTargetDoc->GetStyleSheetPool()->SetSearchMask( - SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED); - sal_uInt16 p[3]; - sal_uInt16 nIdxDeleted = INDEX_IGNORE; - p[0]=aTarget[nTLevel+1]; - p[1]=aTarget[nTLevel+2]; - if(p[1]!=INDEX_IGNORE)p[1]++; - p[2]=aTarget[nTLevel+3]; - - bOk = aTargetDoc->Insert( - *aSourceDoc, aSource[nSLevel+1], - aSource[nSLevel+2], aSource[nSLevel+3], - p[0], p[1], p[2], nIdxDeleted); - // Evaluate Position correction - // a = Document content - // b = Position Sub-content 1 - // c = Position Sub-content 2 - // Delete duplicate entries - if(bOk) - { - SvTreeListEntry *pParentIter = pTarget; - // Up to the document level as - // the general reference point - while(GetModel()->GetDepth(pParentIter) != nTLevel) - pParentIter = GetParent(pParentIter); - if(pParentIter->HasChildrenOnDemand() && - !GetModel()->HasChildren(pParentIter)) - RequestingChildren(pParentIter); - SvTreeListEntry *pChildIter = 0; - - sal_uInt16 i = 0; - while(i < 2 && p[i+1] != INDEX_IGNORE) - { - pChildIter = FirstChild(pParentIter); - // To the index of the current level - for(sal_uInt16 j = 0; j < p[i]; ++j) - pChildIter = NextSibling(pChildIter); - // If possible, fill in Items onDemand - ++i; - if(i < 2 && p[i+1] != INDEX_IGNORE && - pChildIter->HasChildrenOnDemand() && - !GetModel()->HasChildren(pChildIter)) - RequestingChildren(pChildIter); - pParentIter = pChildIter; - } - rIdx = p[i]; - pNewParent = pParentIter; - if(!IsExpanded(pNewParent) && - pNewParent->HasChildrenOnDemand() && - !GetModel()->HasChildren(pNewParent)) - { - bOk = sal_False; - if(!bCopy) - pSourceBox->GetModel()->Remove(pSource); - } - // Remove deleted items - // (can be done by overwriting) - if(nIdxDeleted != INDEX_IGNORE) - { - pChildIter = FirstChild(pParentIter); - for(sal_uInt16 j = 0; j < nIdxDeleted; ++j) - pChildIter = NextSibling(pChildIter); - if( pChildIter && pChildIter != pSource ) - { - bKeepExpansion = IsExpanded(pParentIter); - GetModel()->Remove(pChildIter); - } - else - bOk = sal_False; - } - if(!bCopy && &aSourceDoc != &aTargetDoc) - { - //pool styles that are moved produce - //an rIdx == INDEX_IGNORE - //the method has to return true to keep the box content consistent - bRemovedFromSource = aSourceDoc->Remove(aSource[nSLevel+1], - aSource[nSLevel+2], - aSource[nSLevel+3]); - } - } - } - return (((rIdx != INDEX_IGNORE)|| bRemovedFromSource) && bOk ) - ? bKeepExpansion? (sal_Bool)2: sal_True: sal_False; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx) - -/* [Description] - - Notification that an item will be moved. - (SV-Handler) - - [Parameter] - - SvTreeListEntry* pTarget Target entry, to where it will be moved - SvTreeListEntry *pSource Source entry, to be moved - SvTreeListEntry *&pNewParent the parent of the target position generated - at entry (out parameter) - sal_uIntPtr &rIdx Index of the target entry - - - [Return value] sal_Bool: Sucess or failure - - [Cross-references] - - <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> -*/ - -{ - sal_Bool bOk = sal_False; - SvTreeListBox* pSourceBox = GetSourceView(); - if ( !pSourceBox ) - pSourceBox = pDlg->pSourceView; - DBG_ASSERT( pSourceBox, "no source view" ); - if ( !pTarget ) - pTarget = pDlg->pTargetEntry; - - if ( pSourceBox->GetModel()->GetDepth( pSource ) <= GetDocLevel() && - GetModel()->GetDepth( pTarget ) <= GetDocLevel() ) - bOk = MoveOrCopyTemplates( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_False ); - else - bOk = MoveOrCopyContents(pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_False ); - - return bOk; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx) -/* [Description] - - Notification that an item will be moved. - (SV-Handler) - - [Parameter] - - SvTreeListEntry* pTarget Target entry, to where it will be copied - SvTreeListEntry *pSource Source entry, to be copied - SvTreeListEntry *&pNewParent the parent of the target position generated - at entry (out parameter) - sal_uIntPtr &rIdx Index of the target entry - - [Return value] sal_Bool: Sucess or failure - - [Cross-references] - - <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvTreeListBox *pSourceBox, - SvTreeListEntry *pSource, - SvTreeListEntry* pTarget, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx, - sal_Bool bCopy)> - <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvTreeListEntry *pTarget, - SvTreeListEntry* pSource, - SvTreeListEntry *&pNewParent, - sal_uIntPtr &rIdx)> -*/ -{ - sal_Bool bOk = sal_False; - SvTreeListBox* pSourceBox = GetSourceView(); - if ( !pSourceBox ) - pSourceBox = pDlg->pSourceView; - DBG_ASSERT( pSourceBox, "no source view" ); - if ( !pTarget ) - pTarget = pDlg->pTargetEntry; - if ( pSourceBox->GetModel()->GetDepth( pSource ) <= GetDocLevel() && - GetModel()->GetDepth( pTarget ) <= GetDocLevel() ) - bOk = MoveOrCopyTemplates( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_True ); - else - bOk = MoveOrCopyContents( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_True ); - - return bOk; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::EditingEntry( SvTreeListEntry* pEntry, Selection& ) - -/* [Description] - - Check whether an item can be edited - (SV-Handler) - - [Cross-references] - <SfxOrganizeListBox_Impl::EditedEntry(SvTreeListEntry* pEntry, const rtl::OUString& rText)> -*/ - -{ - if( VIEW_TEMPLATES == eViewType && - GetModel()->GetDepth(pEntry) < 2 ) - { - pDlg->pSuspend = new SuspendAccel( &pDlg->aEditAcc ); - return sal_True; - } - return sal_False; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::EditedEntry(SvTreeListEntry* pEntry, const rtl::OUString& rText) - -/* [Description] - - The name of an entry has been processed, if the name you entered is a - valid name (length> 0) then the model is updated. - (SV-Handler) - - [Return value] - - sal_Bool sal_True: The name in the display should be changed - sal_False: The name should not be changed - - [Cross-references] - <SfxOrganizeListBox_Impl::EditingEntry(SvTreeListEntry* pEntry, const String& rText)> -*/ - -{ - DBG_ASSERT(pEntry, "No Entry selected"); - delete pDlg->pSuspend; - pDlg->pSuspend = NULL; - SvTreeListEntry* pParent = GetParent(pEntry); - if( rText.isEmpty() ) - { - ErrorBox aBox( this, SfxResId( MSG_ERROR_EMPTY_NAME ) ); - aBox.GrabFocus(); - aBox.Execute(); - return sal_False; - } - if ( !IsUniqName_Impl( rText, pParent, pEntry ) ) - { - ErrorBox aBox( this, SfxResId( MSG_ERROR_UNIQ_NAME ) ); - aBox.GrabFocus(); - aBox.Execute(); - return sal_False; - } - sal_uInt16 nRegion = 0, nIndex = 0; - GetIndices_Impl( this, pEntry, nRegion, nIndex ); - String aOldName; - if ( USHRT_MAX != nIndex ) - aOldName = pMgr->GetTemplates()->GetName( nRegion, nIndex ); - else - aOldName = pMgr->GetTemplates()->GetRegionName( nRegion ); - - if ( !pMgr->SetName( rText, nRegion, nIndex ) ) - { - SfxResId aResId( USHRT_MAX != nIndex ? MSG_ERROR_RENAME_TEMPLATE - : MSG_ERROR_RENAME_TEMPLATE_REGION ); - ErrorBox( this, aResId ).Execute(); - return sal_False; - } - - return sal_True; -} - -//------------------------------------------------------------------------- - -DragDropMode SfxOrganizeListBox_Impl::NotifyStartDrag( TransferDataContainer&, SvTreeListEntry* pEntry ) -{ - sal_uInt16 nSourceLevel = GetModel()->GetDepth( pEntry ); - if ( VIEW_FILES == GetViewType() ) - ++nSourceLevel; - if ( nSourceLevel >= 2 ) - bDropMoveOk = sal_False; - else - bDropMoveOk = sal_True; - - return GetDragDropMode(); -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::NotifyAcceptDrop( SvTreeListEntry* pEntry ) -{ - if(!pEntry) - return sal_False; - SvTreeListBox *pSource = GetSourceView(); - SvTreeListEntry *pSourceEntry = pSource->FirstSelected(); - if(pEntry == pSourceEntry) - return sal_False; - sal_uInt16 nSourceLevel = pSource->GetModel()->GetDepth(pSourceEntry); - if(VIEW_FILES == ((SfxOrganizeListBox_Impl *)pSource)->GetViewType()) - ++nSourceLevel; - sal_uInt16 nTargetLevel = GetModel()->GetDepth(pEntry); - if(VIEW_FILES == GetViewType()) - ++nTargetLevel; - Path aSource(pSource, pSourceEntry); - Path aTarget(this, pEntry); - const sal_uInt16 SL = ((SfxOrganizeListBox_Impl *)pSource)->GetDocLevel(); - const sal_uInt16 TL = GetDocLevel(); - - return( (nSourceLevel == 1 && nTargetLevel == 0 && - VIEW_TEMPLATES == - ((SfxOrganizeListBox_Impl *)pSource)->GetViewType()) || - (nSourceLevel == 1 && nTargetLevel == 1 && - VIEW_TEMPLATES == - ((SfxOrganizeListBox_Impl *)pSource)->GetViewType() && - VIEW_TEMPLATES == GetViewType()) || - (nSourceLevel == 3 && nTargetLevel == 1) || - (nSourceLevel == 3 && nTargetLevel == 2 && - aSource[1+SL] == aTarget[1+TL]) || - (nSourceLevel == 3 && nTargetLevel == 3 && - aSource[1+SL] == aTarget[1+TL]) || - (nSourceLevel == 4 && nTargetLevel == 3 && - aSource[1+SL] == aTarget[1+TL] && - aSource[2+SL] == aTarget[2+TL]) || - (nSourceLevel == 4 && nTargetLevel == 4 && - aSource[1+SL] == aTarget[1+TL] && - aSource[2+SL] == aTarget[2+TL])); -} - -//------------------------------------------------------------------------- - -sal_Int8 SfxOrganizeListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt ) -{ - sal_Bool bAccept = ( eViewType == VIEW_FILES && IsDropFormatSupported( SOT_FORMAT_FILE ) ); - if ( bAccept ) - return rEvt.mnAction; - else - return SvTreeListBox::AcceptDrop( rEvt ); -} - -//------------------------------------------------------------------------- - -sal_Int8 SfxOrganizeListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt ) -{ - TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable ); - sal_uInt32 nFormatCount = aHelper.GetFormatCount(); - sal_Bool bSuccess = sal_False; - for ( sal_uInt32 i = 0; i < nFormatCount; ++i ) - { - String aFileName; - SotFormatStringId nId = aHelper.GetFormat(i); - - if ( SOT_FORMAT_FILE == nId && aHelper.GetString( nId, aFileName ) ) - { - INetURLObject aObj( aFileName, INET_PROT_FILE ); - bSuccess |= pMgr->InsertFile( this, aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); - } - } - bDropMoveOk = sal_True; - sal_Int8 nRet = rEvt.mnAction; - if ( !bSuccess ) - { - // asynchronous, because of MessBoxes - pDlg->pSourceView = GetSourceView(); - pDlg->pTargetEntry = pTargetEntry; - pDlg->pFinishedBox = NULL; - pDlg->nDropAction = NO_DROP_ACTION; - PostUserEvent( LINK( this, SfxOrganizeListBox_Impl, OnAsyncExecuteDrop ), - new ExecuteDropEvent( rEvt ) ); - } - - return nRet; -} - -//------------------------------------------------------------------------- - -void SfxOrganizeListBox_Impl::DragFinished( sal_Int8 nDropAction ) -{ - if ( pDlg->bExecDropFinished ) - { - if ( pDlg->nDropAction != NO_DROP_ACTION ) - nDropAction = pDlg->nDropAction; - SvTreeListBox::DragFinished( nDropAction ); - pDlg->nDropAction = NO_DROP_ACTION; - } - else - pDlg->pFinishedBox = this; -} - -//------------------------------------------------------------------------- - -inline sal_uInt16 SfxOrganizeListBox_Impl::GetDocLevel() const - -/* [Description] - - Determines on which level there are documents (in the template view or - the document view) - - [Return value] - - sal_uInt16 Document level - -*/ - -{ - return eViewType == VIEW_FILES? 0: 1; -} - -//------------------------------------------------------------------------- - -SfxObjectShellRef SfxOrganizeListBox_Impl::GetObjectShell(const Path &rPath) - -/* [Description] - - Access to the ObjectShell to which the current entry is connected. - - [Parameter] - - const Path &rPath Description of the current entry - - [Return value] - - SfxObjectShellRef Reference to the ObjectShell - - [Cross-references] - - <class Path> - -*/ - -{ - SfxObjectShellRef aDoc; - if(eViewType == VIEW_FILES) - aDoc = pMgr->CreateObjectShell(rPath[0]); - else - aDoc = pMgr->CreateObjectShell(rPath[0], rPath[1]); - return aDoc; -} - -//------------------------------------------------------------------------- - -void SfxOrganizeListBox_Impl::RequestingChildren( SvTreeListEntry* pEntry ) - -/* [Description] - - Sent to the children of an entry that is going to be inserted. - (SV-Handler) - - [Parameter] - - SvTreeListEntry* pEntry the entry whose children is requested -*/ - -{ - if ( !GetModel()->HasChildren( pEntry ) ) - { - WaitObject aWaitCursor( this ); - - // Choose the correct mask color dependent from eColorMode. This - // must be adopted if we change the mask color for normal images, too! - Color aMaskColor( COL_LIGHTMAGENTA ); - - // Here are all the initial inserted - SfxErrorContext aEc(ERRCTX_SFX_CREATEOBJSH, pDlg->pDialog); - if(VIEW_TEMPLATES == GetViewType() && 0 == GetModel()->GetDepth(pEntry)) - { - sal_uInt16 i = (sal_uInt16)GetModel()->GetRelPos(pEntry); - const sal_uInt16 nEntryCount = pMgr->GetTemplates()->GetCount(i); - for(sal_uInt16 j = 0; j < nEntryCount; ++j) - InsertEntryByBmpType( pMgr->GetTemplates()->GetName( i, j ), BMPTYPE_DOC, pEntry, sal_True ); - } - else - { - const sal_uInt16 nDocLevel = GetDocLevel(); - Path aPath(this, pEntry); - - // it is ok to use the SfxObjectShellRef here since the object that - // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it - SfxObjectShellRef aRef = GetObjectShell(aPath); - if(aRef.Is()) - { - const sal_uInt16 nCount = aRef->GetContentCount(aPath[nDocLevel+1]); - String aText; - Bitmap aClosedBmp, aOpenedBmp; - const bool bCanHaveChildren = - aRef->CanHaveChildren(aPath[nDocLevel+1], - aPath[nDocLevel+2]); - for(sal_uInt16 i = 0; i < nCount; ++i) - { - sal_Bool bDeletable; - aRef->GetContent( - aText, aClosedBmp, aOpenedBmp, bDeletable, - i, aPath[nDocLevel+1]); - - // Create image with the correct mask color - Image aClosedImage( aClosedBmp, aMaskColor ); - Image aOpenedImage( aOpenedBmp, aMaskColor ); - - SvTreeListEntry *pNew = SvTreeListBox::InsertEntry( - aText, aOpenedImage, aClosedImage, - pEntry, bCanHaveChildren); - pNew->SetUserData(bDeletable ? &bDeletable : 0); - } - } - } - } -} - -//------------------------------------------------------------------------- - -long SfxOrganizeListBox_Impl::ExpandingHdl() - -/* [Description] - - SV-handler, before and after the unfolding of an entry is called. - Used if possibly to close the ObjectShell again, the entries with the - contents of this shell are also removed. -*/ - -{ - if ( !(nImpFlags & SVLBOX_IS_EXPANDING) ) - { - SvTreeListEntry* pEntry = GetHdlEntry(); - const sal_uInt16 nLevel = GetModel()->GetDepth(pEntry); - if((eViewType == VIEW_FILES && nLevel == 0) || - (eViewType == VIEW_TEMPLATES && nLevel == 1)) - { - Path aPath(this, pEntry); - // Release ObjectShell when closing the files - if(eViewType == VIEW_FILES && nLevel == 0) - pMgr->DeleteObjectShell(aPath[0]); - else - pMgr->DeleteObjectShell(aPath[0], aPath[1]); - // Delete all SubEntries - SvTreeListEntry *pToDel = SvTreeListBox::GetEntry(pEntry, 0); - while(pToDel) - { - GetModel()->Remove(pToDel); - pToDel = SvTreeListBox::GetEntry(pEntry, 0); - } - } - } - return sal_True; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeListBox_Impl::IsUniqName_Impl(const String &rText, - SvTreeListEntry* pParent, SvTreeListEntry *pEntry) const - -/* [Description] - - Checks whether a name is unique at its level. - - [Parameter] - - const String & Name of the search entry - SvTreeListEntry* pSibling Siblings (referred to the level) - - [Return value] - - sal_Bool sal_True, if the name is unique, otherwise sal_False -*/ - -{ - SvTreeListEntry* pChild = FirstChild(pParent); - while(pChild) { - const String aEntryText(GetEntryText(pChild)); - if(COMPARE_EQUAL == aEntryText.CompareIgnoreCaseToAscii(rText)&&(!pEntry || pEntry!=pChild)) - return sal_False; - pChild = NextSibling(pChild); - } - return sal_True; -} - -//------------------------------------------------------------------------- - -sal_uInt16 SfxOrganizeListBox_Impl::GetLevelCount_Impl(SvTreeListEntry* pParent) const -{ - SvTreeListEntry* pChild = FirstChild(pParent); - sal_uInt16 nCount = 0; - while(pChild) { - pChild = NextSibling(pChild); - ++nCount; - } - return nCount; -} - -//------------------------------------------------------------------------- - -SvTreeListEntry* SfxOrganizeListBox_Impl::InsertEntryByBmpType( - const OUString& rText, - BMPTYPE eBmpType, - SvTreeListEntry* pParent, - sal_Bool bChildrenOnDemand, - sal_uIntPtr nPos, - void* pUserData -) -{ - SvTreeListEntry* pEntry = NULL; - const Image* pExp = NULL; - const Image* pCol = NULL; - - switch( eBmpType ) - { - case BMPTYPE_FOLDER: - pExp = &aOpenedFolderBmp; - pCol = &aClosedFolderBmp; - break; - - case BMPTYPE_DOC: - pExp = &aOpenedDocBmp; - pCol = &aClosedDocBmp; - break; - - default: - OSL_FAIL( "SfxOrganizeListBox_Impl::InsertEntryByBmpType(): something forgotten?!" ); - } - - pEntry = SvTreeListBox::InsertEntry( rText, *pExp, *pCol, pParent, bChildrenOnDemand, nPos, pUserData ); - - return pEntry; -} - -SfxOrganizeListBox_Impl::SfxOrganizeListBox_Impl(Window* pParent, WinBits nBits) - : SvTreeListBox( pParent, nBits ) - , pMgr( NULL ) - , pDlg( NULL ) - , eViewType( SfxOrganizeListBox_Impl::VIEW_TEMPLATES ) -{ - SetDragDropMode( - SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY | - SV_DRAGDROP_APP_MOVE | SV_DRAGDROP_APP_COPY | SV_DRAGDROP_APP_DROP ); - SetEntryHeight( 16 ); - SetSelectionMode( SINGLE_SELECTION ); - GetModel()->SetSortMode( SortNone ); - - EnableContextMenuHandling(); -} - -void SfxOrganizeListBox_Impl::Init(SfxOrganizeDlg_Impl* pArgDlg, DataEnum eType) -{ - pDlg = pArgDlg; - eViewType = eType; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeListBox_Impl, OnAsyncExecuteDrop, ExecuteDropEvent*, pEvent ) -{ - DBG_ASSERT( pEvent, "invalid DropEvent" ); - if ( pEvent ) - { - SvTreeListBox* pSourceView = GetSourceView(); - if ( !pSourceView ) - pSourceView = pDlg->pSourceView; - pDlg->bExecDropFinished = false; - // if a template can not be moved it should be copied - if ( pEvent->mnAction == DND_ACTION_MOVE ) - pEvent->mnAction = DND_ACTION_COPYMOVE; - pDlg->nDropAction = SvTreeListBox::ExecuteDrop( *pEvent, pSourceView ); - delete pEvent; - pDlg->pSourceView = NULL; - pDlg->pTargetEntry = NULL; - pDlg->bExecDropFinished = true; - if ( pDlg->pFinishedBox ) - { - pDlg->pFinishedBox->DragFinished( pDlg->nDropAction ); - pDlg->pFinishedBox = NULL; - } - } - return 0; -} - -//------------------------------------------------------------------------- - -void SfxOrganizeListBox_Impl::Reset() - -/* [Description] - - Paste the items in the ListBox -*/ - -{ - DBG_ASSERT( pMgr != 0, "No Manager" ); - // Delete contents - SetUpdateMode(sal_False); - Clear(); - if ( VIEW_TEMPLATES == eViewType ) - { - const sal_uInt16 nCount = pMgr->GetTemplates()->GetRegionCount(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) - InsertEntryByBmpType( pMgr->GetTemplates()->GetFullRegionName(i), BMPTYPE_FOLDER, 0, sal_True ); - } - else - { - const SfxObjectList& rList = pMgr->GetObjectList(); - for ( SfxObjectList::const_iterator it = rList.begin(); it != rList.end(); ++it ) - InsertEntryByBmpType( rList.GetBaseName(*it), BMPTYPE_DOC, 0, sal_True ); - - } - SetUpdateMode(sal_True); - Invalidate(); - Update(); -} - -//------------------------------------------------------------------------- - -const Image &SfxOrganizeListBox_Impl::GetClosedBmp(sal_uInt16 nLevel) const - -/* [Description] - - Access to the bitmap for a closed entry at each level - - [Parameter] - - sal_uInt16 nLevel Indicator of the level, 2 levels are allowed - - [Return value] - - const Image & The Image on level nLevel -*/ - -{ - const Image* pRet = NULL; - - switch( nLevel ) - { - default: OSL_FAIL( "Bitmap index overflow" ); - - case 0: pRet = &aClosedFolderBmp; - break; - case 1: pRet = &aClosedDocBmp; - break; - } - - return *pRet; -} - -//------------------------------------------------------------------------- - -const Image &SfxOrganizeListBox_Impl::GetOpenedBmp(sal_uInt16 nLevel) const - -/* [Description] - - Access to the bitmap for an open entry at each level - - [Parameter] - - sal_uInt16 nLevel Indicator of the level, 2 levels are allowed - - [Return value] - - const Image & the image on the level nLevel - -*/ - -{ - const Image* pRet = NULL; - - switch( nLevel ) - { - case 0: - pRet = &aOpenedFolderBmp; break; - case 1: - pRet = &aOpenedDocBmp; break; - default: - pRet = &aClosedFolderBmp; break; - } - - return *pRet; -} - -//------------------------------------------------------------------------- - -PopupMenu* SfxOrganizeListBox_Impl::CreateContextMenu() -{ - return new PopupMenu( *( pDlg->m_pEditBtn->GetPopupMenu() ) ); -} - -//------------------------------------------------------------------------- - -String SfxOrganizeDlg_Impl::GetPath_Impl( sal_Bool bOpen, const String& rFileName ) - -/* [Description] - - Get path from FileDialog, for Import / Export of Templates - - [Parameter] - - sal_Bool bOpen Flag: Open / Save - const String& rFileName Current file name as default - - [Return value] File name with path or empty string if - users has pressed 'Cancel' -*/ - -{ - String aPath; - m_sExtension4Save = DEFINE_CONST_UNICODE( "vor" ); - sal_Int16 nDialogType = bOpen - ? com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE - : com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE; - if ( pFileDlg ) - delete pFileDlg; - pFileDlg = new sfx2::FileDialogHelper( nDialogType, 0L ); - - // add "All" filter - pFileDlg->AddFilter( SfxResId(STR_SFX_FILTERNAME_ALL).toString(), - DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) ); - // add template filter - String sFilterName( SfxResId(STR_TEMPLATE_FILTER).toString() ); - String sFilterExt; - // add filters of modules which are installed - SvtModuleOptions aModuleOpt; - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) - sFilterExt += DEFINE_CONST_UNICODE( "*.ott;*.stw;*.oth" ); - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.ots;*.stc" ); - } - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.otp;*.sti" ); - } - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.otg;*.std" ); - } - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.vor" ); - - sFilterName += DEFINE_CONST_UNICODE( " (" ); - sFilterName += sFilterExt; - sFilterName += ')'; - pFileDlg->AddFilter( sFilterName, sFilterExt ); - pFileDlg->SetCurrentFilter( sFilterName ); - - if ( aLastDir.Len() || rFileName.Len() ) - { - INetURLObject aObj; - if ( aLastDir.Len() ) - { - aObj.SetURL( aLastDir ); - if ( rFileName.Len() ) - aObj.insertName( rFileName ); - } - else - aObj.SetURL( rFileName ); - - if ( aObj.hasExtension() ) - { - m_sExtension4Save = aObj.getExtension( - INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); - aObj.removeExtension(); - } - - DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); - pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) ); - } - - pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, ExportHdl ) ); - - return aPath; -} - -//------------------------------------------------------------------------- - -::com::sun::star::uno::Sequence< ::rtl::OUString > - SfxOrganizeDlg_Impl::GetPaths_Impl( const String& rFileName ) - -/* [Description] - - Query plural paths by FileDialog, for Import / Export from document - templates - - [Parameter] - - const String& rFileName The default file name when dialog executes - - [Return value] Empty sequence when users have clicked - 'Cancel', a sequence just containing one - file name with path when they have - choosed one file or a sequence containing - path and file names without path -*/ - -{ - ::com::sun::star::uno::Sequence< ::rtl::OUString > aPaths; - m_sExtension4Save = DEFINE_CONST_UNICODE( "vor" ); - if ( pFileDlg ) - delete pFileDlg; - pFileDlg = new sfx2::FileDialogHelper( - com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, SFXWB_MULTISELECTION ); - - // add "All" filter - pFileDlg->AddFilter( SfxResId(STR_SFX_FILTERNAME_ALL).toString(), - DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) ); - - // add template filter - String sFilterName( SfxResId(STR_TEMPLATE_FILTER).toString() ); - String sFilterExt; - // add filters of modules which are installed - SvtModuleOptions aModuleOpt; - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) - sFilterExt += DEFINE_CONST_UNICODE( "*.ott;*.stw;*.oth;*.dot;*.dotm;*.dotx" ); - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.ots;*.stc;*.xlt;*.xltm;*.xltx" ); - } - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.otp;*.sti;*.pot;*.potm;*.potx" ); - } - if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) - { - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.otg;*.std" ); - } - if ( sFilterExt.Len() > 0 ) - sFilterExt += ';'; - sFilterExt += DEFINE_CONST_UNICODE( "*.vor" ); - - sFilterName += DEFINE_CONST_UNICODE( " (" ); - sFilterName += sFilterExt; - sFilterName += ')'; - pFileDlg->AddFilter( sFilterName, sFilterExt ); - pFileDlg->SetCurrentFilter( sFilterName ); - - if ( aLastDir.Len() || rFileName.Len() ) - { - INetURLObject aObj; - if ( aLastDir.Len() ) - { - aObj.SetURL( aLastDir ); - if ( rFileName.Len() ) - aObj.insertName( rFileName ); - } - else - aObj.SetURL( rFileName ); - - if ( aObj.hasExtension() ) - { - m_sExtension4Save = aObj.getExtension( - INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); - aObj.removeExtension(); - } - - DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); - pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) ); - } - - pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, ImportHdl ) ); - - return aPaths; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxOrganizeDlg_Impl::DontDelete_Impl( SvTreeListEntry* pEntry ) -{ - sal_uInt16 nDepth = pFocusBox->GetModel()->GetDepth(pEntry); - if(SfxOrganizeListBox_Impl::VIEW_FILES == - pFocusBox->GetViewType()) - nDepth++; - if( (nDepth > 2 && !pEntry->GetUserData()) || - //Delete using GetContent forbidden - nDepth==2 || // Template / Not deleting config header - (nDepth==1 && SfxOrganizeListBox_Impl::VIEW_FILES == - pFocusBox->GetViewType()) || //Not deleting Files - (0 == nDepth && pFocusBox->GetLevelCount_Impl(0) < 2)) - //At least keep one template - { - return sal_True; - } - - //If delete is pressed on e.g. a style entry go up the chain to find the - //owning template - while (nDepth > 1) - { - pEntry = pFocusBox->GetParent(pEntry); - --nDepth; - } - SvTreeListEntry *pTemplateEntry = pEntry; - - sal_uInt16 nRegion = 0, nIndex = 0; - GetIndices_Impl( pFocusBox, pTemplateEntry, nRegion, nIndex ); - const SfxDocumentTemplates* pTemplates = aMgr.GetTemplates(); - if ( !pTemplates || !pTemplates->HasUserContents( nRegion, nIndex ) ) - return sal_True; - - return sal_False; -} - -std::vector<rtl::OUString> SfxOrganizeDlg_Impl::GetAllFactoryURLs_Impl( ) const -{ - SvtModuleOptions aModOpt; - const ::com::sun::star::uno::Sequence < ::rtl::OUString >& aServiceNames = aModOpt.GetAllServiceNames() ; - std::vector<rtl::OUString> aList; - sal_Int32 nCount = aServiceNames.getLength(); - for( sal_Int32 i=0; i<nCount; ++i ) - { - if ( SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ).Len() > 0 ) - { - SvtModuleOptions::EFactory eFac = SvtModuleOptions::E_WRITER; - SvtModuleOptions::ClassifyFactoryByName( aServiceNames[i], eFac ); - aList.push_back(aModOpt.GetFactoryEmptyDocumentURL(eFac)); - } - } - - return aList; -} - -sal_Bool SfxOrganizeDlg_Impl::GetServiceName_Impl( String& rName, String& rFileURL ) const -{ - sal_Bool bRet = sal_False; - const SfxDocumentTemplates* pTemplates = aMgr.GetTemplates(); - SvTreeListEntry* pEntry = pFocusBox ? pFocusBox->FirstSelected() : NULL; - sal_uInt16 nRegion = 0, nIndex = 0; - GetIndices_Impl( pFocusBox, pEntry, nRegion, nIndex ); - rFileURL = pTemplates->GetPath( nRegion, nIndex ); - if ( rFileURL.Len() > 0 ) - { - try - { - uno::Reference< embed::XStorage > xStorage = ::comphelper::OStorageHelper::GetStorageFromURL( - rFileURL, - embed::ElementModes::READ ); - sal_uIntPtr nFormat = SotStorage::GetFormatID( xStorage ); - const SfxFilter* pFilter = - SFX_APP()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat ); - if ( pFilter ) - { - rName = pFilter->GetServiceName(); - bRet = sal_True; - } - } - catch( uno::Exception& ) - {} - } - - return bRet; -} - -long SfxOrganizeDlg_Impl::Dispatch_Impl( sal_uInt16 nId, Menu* _pMenu ) - -/* [Description] - - Processing the events from MenuButton or Accelerator - - [Parameter] - - sal_uInt16 nId Event ID - - [Return value] 1: Event has been processed, - 0: Event has not been processed (SV-Menu) -*/ - -{ - SuspendAccel aTmp(&aEditAcc); - SvTreeListEntry *pEntry = pFocusBox? pFocusBox->FirstSelected(): 0; - sal_Bool bHandled = sal_True; - switch(nId) - { - case ID_NEW: - { - if(!pEntry) - return 1; - if(pFocusBox->GetViewType() == SfxOrganizeListBox_Impl::VIEW_TEMPLATES) - { - if(0 == pFocusBox->GetModel()->GetDepth(pEntry)) - { - const rtl::OUString aNoName(SFX2_RESSTR(STR_NONAME)); - SvTreeListEntry* pParent = pFocusBox->GetParent(pEntry); - rtl::OUString aName(aNoName); - sal_Int32 n = 1; - while(!pFocusBox->IsUniqName_Impl(aName, pParent)) - { - aName = aNoName + rtl::OUString::valueOf(n++); - } - aMgr.InsertDir( pFocusBox, aName, - (sal_uInt16)pFocusBox->GetModel()->GetRelPos(pEntry)+1); - } - } - break; - } - - case ID_DELETE: - { - if(!pEntry || DontDelete_Impl(pEntry)) - return 1; - const sal_uInt16 nDepth = pFocusBox->GetModel()->GetDepth(pEntry); - if(nDepth < 2) - { - if(0 == nDepth && pFocusBox->GetLevelCount_Impl(0) < 2) return 1; - if(SfxOrganizeListBox_Impl::VIEW_TEMPLATES == pFocusBox->GetViewType()) - { - sal_uInt16 nResId = nDepth? STR_DELETE_TEMPLATE : - STR_DELETE_REGION; - if( !QueryDelete_Impl( - pDialog, nResId, pFocusBox->GetEntryText(pEntry))) - return 1; - if ( STR_DELETE_REGION == nResId && - pFocusBox->GetChildCount(pEntry)) - { - QueryBox aQBox(pDialog, SfxResId(MSG_REGION_NOTEMPTY)); - if(RET_NO == aQBox.Execute()) - return 1; - } - sal_uInt16 nRegion = 0, nIndex = 0; - GetIndices_Impl(pFocusBox, pEntry, nRegion, nIndex); - - sal_uInt16 nDeleteInd = ( STR_DELETE_REGION == nResId? USHRT_MAX: nIndex ); - if ( !aMgr.Delete( pFocusBox, nRegion, nDeleteInd ) ) - ErrorDelete_Impl( - pDialog, - pFocusBox->GetEntryText(pEntry), - ( nDeleteInd == USHRT_MAX && pFocusBox->GetChildCount(pEntry) ) ); - } - } - //Content Format - else if(nDepth + pFocusBox->GetDocLevel() >= 2) - { - if(!QueryDelete_Impl(pDialog, STR_DELETE_TEMPLATE, pFocusBox->GetEntryText(pEntry))) - return 1; - Path aPath(pFocusBox, pEntry); - - // it is ok to use the SfxObjectShellRef here since the object that - // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it - SfxObjectShellRef aRef = pFocusBox->GetObjectShell(aPath); - if(aRef.Is() && - aRef->Remove(aPath[1+pFocusBox->GetDocLevel()], - aPath[2+pFocusBox->GetDocLevel()], - aPath[3+pFocusBox->GetDocLevel()])) - pFocusBox->GetModel()->Remove(pEntry); - else - ErrorDelete_Impl(pDialog, pFocusBox->GetEntryText(pEntry), sal_False ); - } - break; - } - - case ID_EDIT: - { - if(!pEntry) - return 1; - sal_uInt16 nRegion = 0, nIndex = 0; - GetIndices_Impl( pFocusBox, pEntry, nRegion, nIndex ); - const SfxStringItem aName( SID_FILE_NAME, aMgr.GetTemplates()->GetPath( nRegion, nIndex ) ); - const SfxStringItem aLongName( SID_FILE_LONGNAME, pFocusBox->GetEntryText( pEntry ) ); - const SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private:user" ) ); - const SfxStringItem aTargetName( SID_TARGETNAME, DEFINE_CONST_UNICODE( "_default" ) ); - const SfxBoolItem aTemplateIndicator( SID_TEMPLATE, sal_False ); - - SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_OPENTEMPLATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, - &aName, &aLongName, &aReferer, &aTargetName, &aTemplateIndicator, 0L ); - pDialog->EndDialog( RET_EDIT_STYLE ); - break; - } - - case ID_COPY_FROM: - { - if ( !pEntry ) - return 1; - m_nRegion = 0; - m_nIndex = 0; - GetIndices_Impl( pFocusBox, pEntry, m_nRegion, m_nIndex ); - GetPaths_Impl( String() ); - break; - } - - case ID_COPY_TO: - { - if ( !pEntry ) - return 1; - m_nRegion = 0; - m_nIndex = 0; - GetIndices_Impl( pFocusBox, pEntry, m_nRegion, m_nIndex ); - GetPath_Impl( sal_False, aMgr.GetTemplates()->GetFileName( m_nRegion, m_nIndex ) ); - break; - } - - case ID_RESCAN: - if ( !aMgr.Rescan() ) - ErrorBox( pDialog, SfxResId( MSG_ERROR_RESCAN ) ).Execute(); - if ( SfxOrganizeListBox_Impl::VIEW_TEMPLATES == m_pLeftLb->GetViewType() ) - m_pLeftLb->Reset(); - if ( SfxOrganizeListBox_Impl::VIEW_TEMPLATES == m_pRightLb->GetViewType() ) - m_pRightLb->Reset(); - break; - - case ID_PRINT: - { - if ( !pEntry ) - return 1; - Path aPath( pFocusBox, pEntry ); - - // it is ok to use the SfxObjectShellRef here since the object that - // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it - SfxObjectShellRef aRef = pFocusBox->GetObjectShell( aPath ); - if ( aRef.Is() ) - { - const sal_uInt16 nDocLevel = pFocusBox->GetDocLevel(); - if ( !pPrt ) - pPrt = new Printer; - SvTreeListEntry *pDocEntry = pEntry; - while ( pFocusBox->GetModel()->GetDepth( pDocEntry ) > nDocLevel ) - pDocEntry = pFocusBox->GetParent( pDocEntry ); - const String aName(pFocusBox->GetEntryText(pDocEntry)); - if ( !aRef->Print( *pPrt, aPath[1+nDocLevel], - aPath[2+nDocLevel], aPath[3+nDocLevel], &aName ) ) - ErrorBox( pDialog, SfxResId( MSG_PRINT_ERROR ) ).Execute(); - } - break; - } - - case ID_PRINTER_SETUP: - { - PrinterSetupDialog* pDlg = new PrinterSetupDialog( pDialog ); - if ( !pPrt ) - pPrt = new Printer; - pDlg->SetPrinter( pPrt ); - pDlg->Execute(); - delete pDlg; - break; - } - - case ID_DEFAULT_TEMPLATE: - { - String aServiceName, aFileURL; - if ( GetServiceName_Impl( aServiceName, aFileURL ) ) - SfxObjectFactory::SetStandardTemplate( aServiceName, aFileURL ); - break; - } - - default: - bHandled = sal_False; - } - - if ( !bHandled && nId > ID_RESET_DEFAULT_TEMPLATE ) - { - Menu* pSubMenu = _pMenu ? _pMenu : m_pEditBtn->GetPopupMenu()->GetPopupMenu( ID_RESET_DEFAULT_TEMPLATE ); - if ( pSubMenu ) - { - String aServiceName = SfxObjectShell::GetServiceNameFromFactory( pSubMenu->GetItemCommand( nId ) ); - SfxObjectFactory::SetStandardTemplate( aServiceName, String() ); - bHandled = sal_True; - } - } - - return bHandled ? 1 : 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_INLINE_START( SfxOrganizeDlg_Impl, MenuSelect_Impl, Menu *, pMenu ) - -/* [Description] - - SelectHandler of Menu and Menubuttons (SV) - - [Parameter] - - MenuButton *pBtn Button triggering the event - - [Return value] 1: Event has been processed, - 0: Event has not been processed (SV-Menu) -*/ -{ - return Dispatch_Impl( pMenu->GetCurItemId(), pMenu ); -} -IMPL_LINK_INLINE_END( SfxOrganizeDlg_Impl, MenuSelect_Impl, Menu *, pMenu ) - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeDlg_Impl, AccelSelect_Impl, Accelerator *, pAccel ) - -/* [Description] - - SelectHandler of Accelerators (SV) - - [Parameter] - - Accelerator *pAccel Accelerator triggering the event - - [Return value] 1: Event has been processed, - 0: Event has not been processed (SV) -*/ - -{ - SvTreeListEntry* pEntry = pFocusBox && pFocusBox->GetSelectionCount() ? - pFocusBox->FirstSelected() : NULL ; - return pEntry && ( pAccel->GetCurItemId() == ID_NEW || !DontDelete_Impl( pEntry ) ) ? - Dispatch_Impl( pAccel->GetCurItemId(), NULL ) : 0; -} - -IMPL_LINK( SfxOrganizeDlg_Impl, MenuActivate_Impl, Menu *, pMenu ) - -/* [Description] - - ActivateHandler of Menu and Menubuttons (SV) - - [Parameter] - - Menu *pMenu Event triggering the Menu - - [Return value] 1: Event has been processed, - 0: Event has not been processed (SV-Menu) -*/ -{ - if ( pFocusBox && pFocusBox->IsEditingActive() ) - pFocusBox->EndEditing( sal_False ); - sal_Bool bEnable = ( pFocusBox && pFocusBox->GetSelectionCount() ); - SvTreeListEntry* pEntry = bEnable ? pFocusBox->FirstSelected() : NULL; - const sal_uInt16 nDepth = - ( bEnable && pFocusBox->GetSelectionCount() ) ? pFocusBox->GetModel()->GetDepth( pEntry ) : 0; - const sal_uInt16 nDocLevel = bEnable ? pFocusBox->GetDocLevel() : 0; - int eVT = pFocusBox ? pFocusBox->GetViewType() : 0; - // Create only Template - pMenu->EnableItem( ID_NEW, bEnable && 0 == nDepth && SfxOrganizeListBox_Impl::VIEW_TEMPLATES == eVT ); - // Template: Delete level 0,1,3ff - // At least one region must be retained - // Files: Delete level> 2 - - pMenu->EnableItem( ID_DELETE, bEnable && !DontDelete_Impl( pEntry ) ); - pMenu->EnableItem( ID_EDIT, - bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && nDepth == nDocLevel - && !DontDelete_Impl( pEntry ) ); - pMenu->EnableItem( ID_COPY_FROM, - bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && - ( nDepth == nDocLevel || nDepth == nDocLevel - 1 ) ); - pMenu->EnableItem( ID_COPY_TO, - bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && - nDepth == nDocLevel ); - pMenu->EnableItem( ID_RESCAN, - SfxOrganizeListBox_Impl::VIEW_TEMPLATES == m_pRightLb->GetViewType() || - SfxOrganizeListBox_Impl::VIEW_TEMPLATES == m_pLeftLb->GetViewType() ); - sal_Bool bPrint = bEnable && nDepth > pFocusBox->GetDocLevel(); - if ( bPrint && pPrt ) - bPrint = !pPrt->IsPrinting() && !pPrt->IsJobActive(); - if ( bPrint && bEnable ) - { - // only styles printable - Path aPath( pFocusBox, pFocusBox->FirstSelected() ); - sal_uInt16 nIndex = aPath[ nDocLevel + 1 ]; - bPrint = ( nIndex == CONTENT_STYLE ); - } - pMenu->EnableItem( ID_PRINT, bPrint ); - - if ( bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && nDepth == nDocLevel ) - { - String aFactoryURL, aFileURL; - bEnable = GetServiceName_Impl( aFactoryURL, aFileURL ); - } - else if ( bEnable ) - bEnable = sal_False; - pMenu->EnableItem( ID_DEFAULT_TEMPLATE, bEnable ); - - bEnable = sal_True; - std::vector<rtl::OUString> aList(GetAllFactoryURLs_Impl()); - if (!aList.empty()) - { - PopupMenu* pSubMenu = new PopupMenu; - sal_uInt16 nItemId = ID_RESET_DEFAULT_TEMPLATE + 1; - for(std::vector<rtl::OUString>::const_iterator i = aList.begin(); i != aList.end(); ++i) - { - INetURLObject aObj(*i); - String aTitle = SvFileInformationManager::GetDescription(aObj); - pSubMenu->InsertItem(nItemId, aTitle, SvFileInformationManager::GetImage(aObj, false)); - pSubMenu->SetItemCommand(nItemId++, *i); - } - pMenu->SetPopupMenu( ID_RESET_DEFAULT_TEMPLATE, pSubMenu ); - } - else - bEnable = sal_False; - - pMenu->EnableItem( ID_RESET_DEFAULT_TEMPLATE, bEnable ); - - return 1; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeDlg_Impl, GetFocus_Impl, SfxOrganizeListBox_Impl *, pBox ) - -/* [Description] - - GetFocus-Handler, is called from the Select-Handler of ListBox - Used in the listBox that has the focus and to determine its condition. - - [Parameter] - - SfxOrganizeListBox *pBox The calling Box -*/ - -{ - if(pFocusBox && pFocusBox != pBox) - pFocusBox->SelectAll(sal_False); - pFocusBox = pBox; - m_pFilesBtn->Enable( SfxOrganizeListBox_Impl::VIEW_FILES == - pFocusBox->GetViewType() ); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeDlg_Impl, LeftListBoxSelect_Impl, ListBox *, pBox ) - -/* [Description] - - Select-Handler, is called from the Select-Handler of ListBox. - If the mode of the Boxes are different (Document view or Template view) - then the models are separated, otherwise joined together. - - [Parameter] - - ListBox *pBox The calling Box -*/ -{ - const SfxOrganizeListBox_Impl::DataEnum - eViewType = pBox->GetSelectEntryPos() == 0 ? - SfxOrganizeListBox_Impl::VIEW_TEMPLATES : SfxOrganizeListBox_Impl::VIEW_FILES; - if(eViewType!= m_pLeftLb->GetViewType()) { - m_pLeftLb->SetViewType(eViewType); - if(m_pRightLb->GetViewType() == eViewType) - m_pLeftLb->SetModel(m_pRightLb->GetModel()); - else { - // Models trennen - m_pLeftLb->DisconnectFromModel(); - m_pLeftLb->Reset(); - } - } - GetFocus_Impl(m_pLeftLb); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeDlg_Impl, RightListBoxSelect_Impl, ListBox *, pBox ) - -/* [Description] - - Select-Handler, will be called by Select-Handler of the ListBox. - If the mode of the Boxes are different (Document view or Template view) - then the models are separated, otherwise joined together. - - [Parameter] - - ListBox *pBox The calling Box -*/ -{ - const SfxOrganizeListBox_Impl::DataEnum eViewType = - pBox->GetSelectEntryPos() == 0 ? - SfxOrganizeListBox_Impl::VIEW_TEMPLATES : SfxOrganizeListBox_Impl::VIEW_FILES; - if(eViewType!= m_pRightLb->GetViewType()) - { - m_pRightLb->SetViewType(eViewType); - if(m_pLeftLb->GetViewType() == eViewType) - m_pRightLb->SetModel(m_pLeftLb->GetModel()); - else - { - // Separate models - m_pRightLb->DisconnectFromModel(); - m_pRightLb->Reset(); - } - } - m_pRightLb->GrabFocus(); - GetFocus_Impl(m_pRightLb); - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_NOARG(SfxOrganizeDlg_Impl, OnAddressTemplateClicked) -{ - svt::AddressBookSourceDialog aDialog(pDialog, ::comphelper::getProcessServiceFactory()); - aDialog.Execute(); - return 0L; -} - -IMPL_LINK_NOARG(SfxOrganizeDlg_Impl, Close_Impl) -{ - pDialog->EndDialog( sal_True ); - return 0L; -} - -//------------------------------------------------------------------------- - -IMPL_LINK( SfxOrganizeDlg_Impl, AddFiles_Impl, Button *, pButton ) - -/* [Description] - - Handler of the button for adding files through Dialog. - - [Parameter] - - Button * Button, triggering this Event - -*/ -{ - (void)pButton; //unused - if ( pFileDlg ) - delete pFileDlg; - pFileDlg = new sfx2::FileDialogHelper( - ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, - 0, String() ); - - // add config and basic filter - static String sOpenBracket( DEFINE_CONST_UNICODE( " (" ) ); - static String sCloseBracket( DEFINE_CONST_UNICODE( ")" ) ); - static String sConfigExt( DEFINE_CONST_UNICODE( "*.cfg" ) ); - static String sBasicExt( DEFINE_CONST_UNICODE( "*.sbl" ) ); - - String sFilterName( SfxResId(RID_STR_FILTCONFIG).toString() ); - sFilterName += sOpenBracket; - sFilterName += sConfigExt; - sFilterName += sCloseBracket; - pFileDlg->AddFilter( sFilterName, sConfigExt ); - - sFilterName = SfxResId(RID_STR_FILTBASIC).toString(); - sFilterName += sOpenBracket; - sFilterName += sBasicExt; - sFilterName += sCloseBracket; - pFileDlg->AddFilter( sFilterName, sBasicExt ); - - // set "All" filter as current - pFileDlg->SetCurrentFilter( SfxResId(STR_SFX_FILTERNAME_ALL).toString() ); - - if ( aLastDir.Len() ) - pFileDlg->SetDisplayDirectory( aLastDir ); - - pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, AddFilesHdl ) ); - - return 0; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_NOARG(SfxOrganizeDlg_Impl, ExportHdl) -{ - DBG_ASSERT( pFileDlg, "SfxOrganizeDlg_Impl::ExportHdl(): no file dialog" ); - - if ( ERRCODE_NONE == pFileDlg->GetError() ) - { - String aPath = pFileDlg->GetPath(); - INetURLObject aObj( aPath ); - - // we want to keep the original extension when exporting, the file open dialog - // always sets the extension to *.vor - if ( pFileDlg->GetDialogType() == - com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE ) - { - if ( aObj.hasExtension() ) - aObj.removeExtension(); - - aObj.setExtension( m_sExtension4Save ); - aPath = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - - aObj.removeSegment(); - aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - - if ( aPath.Len() && !aMgr.CopyTo( m_nRegion, m_nIndex, aPath ) ) - { - String aText( SfxResId(STR_ERROR_COPY_TEMPLATE).toString() ); - aText.SearchAndReplaceAscii( "$1", aPath ); - ErrorBox( pDialog, WB_OK, aText ).Execute(); - } - } - - return 0L; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_NOARG(SfxOrganizeDlg_Impl, ImportHdl) -{ - DBG_ASSERT( pFileDlg, "SfxOrganizeDlg_Impl::ImportHdl(): no file dialog" ); - ::com::sun::star::uno::Sequence< ::rtl::OUString > aPaths; - - if ( ERRCODE_NONE == pFileDlg->GetError() ) - { - aPaths = pFileDlg->GetMPath(); - sal_Int32 lastCount = aPaths.getLength() - 1; - INetURLObject aObj( aPaths.getArray()[ lastCount ] ); - - aObj.removeSegment(); - aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - - sal_Int32 nCount = aPaths.getLength(); - if ( 1 == nCount ) - { - String aPath = String( aPaths.getArray()[0] ); - if ( aPath.Len() && !aMgr.CopyFrom( pFocusBox, m_nRegion, m_nIndex, aPath ) ) - { - String aText( SfxResId(STR_ERROR_COPY_TEMPLATE).toString() ); - aText.SearchAndReplaceAscii( "$1", aPath ); - ErrorBox( pDialog, WB_OK, aText ).Execute(); - } - } - else if ( nCount > 1 ) - { - INetURLObject aPathObj( aPaths[0] ); - aPathObj.setFinalSlash(); - for ( sal_uInt16 i = 1; i < nCount; ++i ) - { - if ( 1 == i ) - aPathObj.Append( aPaths[i] ); - else - aPathObj.setName( aPaths[i] ); - String aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE ); - if ( aPath.Len() && !aMgr.CopyFrom( pFocusBox, m_nRegion, m_nIndex, aPath ) ) - { - String aText( SfxResId(STR_ERROR_COPY_TEMPLATE).toString() ); - aText.SearchAndReplaceAscii( "$1", aPath ); - ErrorBox( pDialog, WB_OK, aText ).Execute(); - } - } - } - - return 0L; -} - -//------------------------------------------------------------------------- - -IMPL_LINK_NOARG(SfxOrganizeDlg_Impl, AddFilesHdl) -{ - if ( ERRCODE_NONE == pFileDlg->GetError() ) - { - String aPath = pFileDlg->GetPath(); - aMgr.InsertFile( pFocusBox, aPath ); - INetURLObject aObj( aPath ); - aObj.removeSegment(); - aObj.setFinalSlash(); - aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - - return 0L; -} - -//------------------------------------------------------------------------- - -short SfxTemplateOrganizeDlg::Execute() - -/* [Description] - - Overloaded Execute method; stores changes to the document templates - (SV-Methode) - -*/ - -{ - const short nRet = ModalDialog::Execute(); - if(RET_CANCEL != nRet) - { - pImp->aMgr.SaveAll(this); - SfxTemplateDialog* pTemplDlg = SFX_APP()->GetTemplateDialog(); - if(pTemplDlg) - pTemplDlg->Update(); - } - return nRet; -} - - -//------------------------------------------------------------------------- - -SfxTemplateOrganizeDlg::SfxTemplateOrganizeDlg(Window * pParent, - SfxDocumentTemplates *pTempl) - : ModalDialog(pParent, "TemplateManagementDialog", - "sfx/ui/templatemanagementdialog.ui") - , pImp( new SfxOrganizeDlg_Impl(this, pTempl) ) -{ -} - -//------------------------------------------------------------------------- - -SfxTemplateOrganizeDlg::~SfxTemplateOrganizeDlg() -{ - GetpApp()->RemoveAccel(&pImp->aEditAcc); - delete pImp->pPrt; - delete pImp; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 7d313e7867de..afb115bc3bc6 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -69,7 +69,6 @@ #include <sfx2/request.hxx> #include <sfx2/printer.hxx> #include <sfx2/viewsh.hxx> -#include <sfx2/doctdlg.hxx> #include <sfx2/docfilt.hxx> #include <sfx2/docfile.hxx> #include <sfx2/dispatch.hxx> |