xref: /trunk/main/sfx2/source/doc/docvor.cxx (revision 30acf5e801d38c3701bf451b42e514ce81855b4c)
1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d119d52dSAndrew Rist  * distributed with this work for additional information
6d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17d119d52dSAndrew Rist  * specific language governing permissions and limitations
18d119d52dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20d119d52dSAndrew Rist  *************************************************************/
21d119d52dSAndrew Rist 
22d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
27cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <stdio.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifndef _SV_PRNSETUP_HXX //autogen
34cdf0e10cSrcweir #include <svtools/prnsetup.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <vcl/cmdevt.hxx>
37cdf0e10cSrcweir #include <vcl/menubtn.hxx>
38cdf0e10cSrcweir #include <vcl/msgbox.hxx>
39cdf0e10cSrcweir #include <vcl/print.hxx>
40cdf0e10cSrcweir #include <svl/style.hxx>
41cdf0e10cSrcweir #include <svl/stritem.hxx>
42cdf0e10cSrcweir #include <svl/eitem.hxx>
43cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
44cdf0e10cSrcweir #include <svtools/ehdl.hxx>
45cdf0e10cSrcweir #include <svtools/imagemgr.hxx>
46cdf0e10cSrcweir #include <vcl/waitobj.hxx>
47cdf0e10cSrcweir #include <tools/urlobj.hxx>
48cdf0e10cSrcweir #include <tools/color.hxx>
49cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
50cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
51cdf0e10cSrcweir #include <sot/exchange.hxx>
52cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #include "helpid.hrc"
55cdf0e10cSrcweir #include "docvor.hxx"
56cdf0e10cSrcweir #include <sfx2/docfac.hxx>
57cdf0e10cSrcweir #include "orgmgr.hxx"
58cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
59cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
60cdf0e10cSrcweir #include "sfxtypes.hxx"
61cdf0e10cSrcweir #include <sfx2/app.hxx>
62cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
63cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
64cdf0e10cSrcweir #include "doc.hrc"
65cdf0e10cSrcweir #include <sfx2/sfx.hrc>
66cdf0e10cSrcweir #include "docvor.hrc"
67cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
68cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
69cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
70cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
71cdf0e10cSrcweir #include <svtools/localresaccess.hxx>
72cdf0e10cSrcweir #ifndef _SVT_DOC_ADDRESSTEMPLATE_HXX_
73cdf0e10cSrcweir #include <svtools/addresstemplate.hxx>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
76cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
77cdf0e10cSrcweir #include <svl/svstdarr.hxx>
78cdf0e10cSrcweir 
79cdf0e10cSrcweir static const char cDelim = ':';
80cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::bDropMoveOk = sal_True;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir using namespace ::com::sun::star;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir //=========================================================================
85cdf0e10cSrcweir 
86cdf0e10cSrcweir class SuspendAccel
87cdf0e10cSrcweir {
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir     Accelerator*    pAccel;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     SuspendAccel( Accelerator* pA )
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         pAccel=pA;
94cdf0e10cSrcweir         GetpApp()->RemoveAccel( pAccel );
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir     ~SuspendAccel()
97cdf0e10cSrcweir     {
98cdf0e10cSrcweir         GetpApp()->InsertAccel( pAccel );
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //=========================================================================
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir inline void SfxOrganizeListBox_Impl::SetBitmaps(
106cdf0e10cSrcweir     const Image &rOFolder, const Image &rCFolder, const Image &rODoc, const Image &rCDoc,
107cdf0e10cSrcweir     const Image &rOFolderHC, const Image &rCFolderHC, const Image &rODocHC, const Image &rCDocHC )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     aOpenedFolderBmp = rOFolder;
110cdf0e10cSrcweir     aClosedFolderBmp = rCFolder;
111cdf0e10cSrcweir     aOpenedDocBmp = rODoc;
112cdf0e10cSrcweir     aClosedDocBmp = rCDoc;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     aOpenedFolderBmpHC = rOFolderHC;
115cdf0e10cSrcweir     aClosedFolderBmpHC = rCFolderHC;
116cdf0e10cSrcweir     aOpenedDocBmpHC = rODocHC;
117cdf0e10cSrcweir     aClosedDocBmpHC = rCDocHC;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir //=========================================================================
122cdf0e10cSrcweir 
123cdf0e10cSrcweir #define NO_DROP_ACTION  ((sal_Int8)-1)
124cdf0e10cSrcweir 
125cdf0e10cSrcweir class SfxOrganizeDlg_Impl
126cdf0e10cSrcweir {
127cdf0e10cSrcweir friend class SfxTemplateOrganizeDlg;
128cdf0e10cSrcweir friend class SfxOrganizeListBox_Impl;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     SuspendAccel*           pSuspend;
131cdf0e10cSrcweir     SfxTemplateOrganizeDlg* pDialog;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     SfxOrganizeListBox_Impl* pFocusBox;
134cdf0e10cSrcweir     Printer*                 pPrt;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     // save pointer for asynchronous D&D
137cdf0e10cSrcweir     SvLBox*                 pSourceView;
138cdf0e10cSrcweir     SvLBoxEntry*            pTargetEntry;
139cdf0e10cSrcweir     SfxOrganizeListBox_Impl* pFinishedBox;
140cdf0e10cSrcweir     sal_Int8                nDropAction;
141cdf0e10cSrcweir     bool                    bExecDropFinished;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     // save some variables for the asynchronous file dialog
144cdf0e10cSrcweir     sal_uInt16                  m_nRegion;
145cdf0e10cSrcweir     sal_uInt16                  m_nIndex;
146cdf0e10cSrcweir     String                  m_sExtension4Save;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     SfxOrganizeListBox_Impl aLeftLb;
149cdf0e10cSrcweir     ListBox                 aLeftTypLb;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     SfxOrganizeListBox_Impl aRightLb;
152cdf0e10cSrcweir     ListBox                 aRightTypLb;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     OKButton                aOkBtn;
155cdf0e10cSrcweir     MenuButton              aEditBtn;
156cdf0e10cSrcweir     HelpButton              aHelpBtn;
157cdf0e10cSrcweir     PushButton              aAddressTemplateBtn;
158cdf0e10cSrcweir     PushButton              aFilesBtn;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     Accelerator             aEditAcc;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     String                  aLastDir;
163cdf0e10cSrcweir     SfxOrganizeMgr          aMgr;
164cdf0e10cSrcweir     sfx2::FileDialogHelper* pFileDlg;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     SvStringsDtor*          GetAllFactoryURLs_Impl() const;
167cdf0e10cSrcweir     sal_Bool                GetServiceName_Impl( String& rFactoryURL, String& rFileURL ) const;
168cdf0e10cSrcweir     long                    Dispatch_Impl( sal_uInt16 nId, Menu* _pMenu );
169cdf0e10cSrcweir     String                  GetPath_Impl( sal_Bool bOpen, const String& rFileName );
170cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString >
171cdf0e10cSrcweir                             GetPaths_Impl( const String& rFileName );
172cdf0e10cSrcweir     void                    InitBitmaps( void );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     DECL_LINK( GetFocus_Impl, SfxOrganizeListBox_Impl * );
175cdf0e10cSrcweir     DECL_LINK( LeftListBoxSelect_Impl, ListBox * );
176cdf0e10cSrcweir     DECL_LINK( RightListBoxSelect_Impl, ListBox * );
177cdf0e10cSrcweir     DECL_LINK( AccelSelect_Impl, Accelerator * );
178cdf0e10cSrcweir     DECL_LINK( MenuSelect_Impl, Menu * );
179cdf0e10cSrcweir     DECL_LINK( MenuActivate_Impl, Menu * );
180cdf0e10cSrcweir     DECL_LINK( AddFiles_Impl, Button * );
181cdf0e10cSrcweir     DECL_LINK( OnAddressTemplateClicked, Button * );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     DECL_LINK( ImportHdl, sfx2::FileDialogHelper* );
184cdf0e10cSrcweir     DECL_LINK( ExportHdl, sfx2::FileDialogHelper* );
185cdf0e10cSrcweir     DECL_LINK( AddFilesHdl, sfx2::FileDialogHelper* );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     sal_Bool        DontDelete_Impl( SvLBoxEntry* pEntry );
188cdf0e10cSrcweir     void        OkHdl( Button* );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir public:
191cdf0e10cSrcweir     SfxOrganizeDlg_Impl( SfxTemplateOrganizeDlg* pParent, SfxDocumentTemplates* pTempl );
192cdf0e10cSrcweir     ~SfxOrganizeDlg_Impl();
193cdf0e10cSrcweir };
194cdf0e10cSrcweir 
195cdf0e10cSrcweir //-------------------------------------------------------------------------
196cdf0e10cSrcweir 
197cdf0e10cSrcweir SfxOrganizeDlg_Impl::SfxOrganizeDlg_Impl( SfxTemplateOrganizeDlg* pParent,
198cdf0e10cSrcweir                                           SfxDocumentTemplates* pTempl ) :
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     pSuspend            ( NULL ),
201cdf0e10cSrcweir     pDialog             ( pParent ),
202cdf0e10cSrcweir     pFocusBox           ( NULL ),
203cdf0e10cSrcweir     pPrt                ( NULL ),
204cdf0e10cSrcweir     pSourceView         ( NULL ),
205cdf0e10cSrcweir     pTargetEntry        ( NULL ),
206cdf0e10cSrcweir     pFinishedBox        ( NULL ),
207cdf0e10cSrcweir     nDropAction         ( NO_DROP_ACTION ),
208cdf0e10cSrcweir     bExecDropFinished   ( true ),
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     aLeftLb     ( this, pParent, WB_BORDER | WB_TABSTOP | WB_HSCROLL, SfxOrganizeListBox_Impl::VIEW_TEMPLATES ),
211cdf0e10cSrcweir     aLeftTypLb  (  pParent, SfxResId( LB_LEFT_TYP ) ),
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     aRightLb    ( this, pParent, WB_BORDER | WB_TABSTOP | WB_HSCROLL, SfxOrganizeListBox_Impl::VIEW_FILES ),
214cdf0e10cSrcweir     aRightTypLb ( pParent, SfxResId( LB_RIGHT_TYP ) ),
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     aOkBtn              ( pParent, SfxResId( BTN_OK ) ),
217cdf0e10cSrcweir     aEditBtn            ( pParent, SfxResId( BTN_EDIT ) ),
218cdf0e10cSrcweir     aHelpBtn            ( pParent, SfxResId( BTN_HELP ) ),
219cdf0e10cSrcweir     aAddressTemplateBtn ( pParent, SfxResId( BTN_ADDRESSTEMPLATE ) ),
220cdf0e10cSrcweir     aFilesBtn           ( pParent, SfxResId( BTN_FILES ) ),
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     aEditAcc    ( SfxResId( ACC_EDIT ) ),
223cdf0e10cSrcweir     aMgr        ( &aLeftLb, &aRightLb, pTempl ),
224cdf0e10cSrcweir     pFileDlg    ( NULL )
225cdf0e10cSrcweir 
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     // update the SfxDocumentTemplates the manager works with
228cdf0e10cSrcweir     if ( aMgr.GetTemplates() )  // should never fail, but who knows ....
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         // for this, show a wait cursor (it may take a while)
231cdf0e10cSrcweir         Window* pWaitObjectRange = pDialog ? pDialog->GetParent() : NULL;
232cdf0e10cSrcweir         if ( !pWaitObjectRange )
233cdf0e10cSrcweir             pWaitObjectRange = pDialog;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         WaitObject aWaitCursor( pWaitObjectRange );
236cdf0e10cSrcweir         const_cast< SfxDocumentTemplates* >( aMgr.GetTemplates() )->Update( sal_True /* be smart */ );
237cdf0e10cSrcweir             // this const_cast is a hack - but the alternative would be to
238cdf0e10cSrcweir             // * have a method which returns the templates non-const
239cdf0e10cSrcweir             // * use a new SfxDocumentTemplates instance for the update (knowing that they all share the same
240cdf0e10cSrcweir             //   implementation class)
241cdf0e10cSrcweir             // * always work with an own instance, even if we get only NULL in this ctor
242cdf0e10cSrcweir     }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     aLeftLb.SetHelpId( HID_CTL_ORGANIZER_LEFT );
245cdf0e10cSrcweir     aRightLb.SetHelpId( HID_CTL_ORGANIZER_RIGHT );
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     String aWorkPath = SvtPathOptions().GetWorkPath();
248cdf0e10cSrcweir     if ( aWorkPath.Len() )
249cdf0e10cSrcweir     {
250cdf0e10cSrcweir         INetURLObject aObj( aWorkPath );
251cdf0e10cSrcweir         DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL !" );
252cdf0e10cSrcweir         aObj.setFinalSlash();
253cdf0e10cSrcweir         aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir     else
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         // fallback
258cdf0e10cSrcweir         String aProgURL = SvtPathOptions().SubstituteVariable( String::CreateFromAscii("$(PROGURL)") );
259cdf0e10cSrcweir         INetURLObject aObj( aProgURL );
260cdf0e10cSrcweir         DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL !" );
261cdf0e10cSrcweir         aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
262cdf0e10cSrcweir     }
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     InitBitmaps();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     aEditBtn.GetPopupMenu()->SetSelectHdl( LINK( this, SfxOrganizeDlg_Impl, MenuSelect_Impl ) );
267cdf0e10cSrcweir     aEditBtn.GetPopupMenu()->SetActivateHdl( LINK( this, SfxOrganizeDlg_Impl, MenuActivate_Impl ) );
268cdf0e10cSrcweir     aEditAcc.SetSelectHdl( LINK( this, SfxOrganizeDlg_Impl, AccelSelect_Impl ) );
269cdf0e10cSrcweir     GetpApp()->InsertAccel( &aEditAcc );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     aFilesBtn.SetClickHdl(
272cdf0e10cSrcweir         LINK(this,SfxOrganizeDlg_Impl, AddFiles_Impl));
273cdf0e10cSrcweir     aAddressTemplateBtn.SetClickHdl(
274cdf0e10cSrcweir         LINK(this,SfxOrganizeDlg_Impl, OnAddressTemplateClicked));
275cdf0e10cSrcweir     aLeftTypLb.SetSelectHdl(
276cdf0e10cSrcweir         LINK(this, SfxOrganizeDlg_Impl, LeftListBoxSelect_Impl));
277cdf0e10cSrcweir     aRightTypLb.SetSelectHdl(
278cdf0e10cSrcweir         LINK(this, SfxOrganizeDlg_Impl, RightListBoxSelect_Impl));
279cdf0e10cSrcweir     aLeftLb.SetGetFocusHdl(
280cdf0e10cSrcweir         LINK(this, SfxOrganizeDlg_Impl, GetFocus_Impl));
281cdf0e10cSrcweir     aRightLb.SetGetFocusHdl(
282cdf0e10cSrcweir         LINK(this, SfxOrganizeDlg_Impl, GetFocus_Impl));
283cdf0e10cSrcweir     aLeftLb.SetPosSizePixel(pParent->LogicToPixel(Point(3, 6), MAP_APPFONT),
284cdf0e10cSrcweir                             pParent->LogicToPixel(Size(94, 132), MAP_APPFONT));
285cdf0e10cSrcweir     aRightLb.SetPosSizePixel(pParent->LogicToPixel(Point(103, 6), MAP_APPFONT),
286cdf0e10cSrcweir                              pParent->LogicToPixel(Size(94, 132), MAP_APPFONT));
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
289cdf0e10cSrcweir         aAddressTemplateBtn.Hide();
290cdf0e10cSrcweir     Font aFont(aLeftLb.GetFont());
291cdf0e10cSrcweir     aFont.SetWeight(WEIGHT_NORMAL);
292cdf0e10cSrcweir     aLeftLb.SetFont(aFont);
293cdf0e10cSrcweir     aRightLb.SetFont(aFont);
294cdf0e10cSrcweir     const long nIndent = aLeftLb.GetIndent() / 2;
295cdf0e10cSrcweir     aLeftLb.SetIndent( (short)nIndent );
296cdf0e10cSrcweir     aRightLb.SetIndent( (short)nIndent );
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     aLeftLb.SetMgr(&aMgr);
299cdf0e10cSrcweir     aRightLb.SetMgr(&aMgr);
300cdf0e10cSrcweir     aLeftLb.Reset();
301cdf0e10cSrcweir     aRightLb.Reset();//SetModel(aLeftLb.GetModel());
302cdf0e10cSrcweir 
303cdf0e10cSrcweir     aLeftLb.Show();
304cdf0e10cSrcweir     aRightLb.Show();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     aLeftLb.SelectAll( sal_False );
307cdf0e10cSrcweir     aRightLb.SelectAll( sal_False );
308cdf0e10cSrcweir     aRightLb.GrabFocus();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir //-------------------------------------------------------------------------
312cdf0e10cSrcweir 
313cdf0e10cSrcweir SfxOrganizeDlg_Impl::~SfxOrganizeDlg_Impl()
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     delete pFileDlg;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir //-------------------------------------------------------------------------
319cdf0e10cSrcweir 
320cdf0e10cSrcweir void SfxOrganizeDlg_Impl::InitBitmaps( void )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     Image   aOpenedFolderBmp( SfxResId( IMG_OPENED_FOLDER ) );
323cdf0e10cSrcweir     Image   aClosedFolderBmp( SfxResId( IMG_CLOSED_FOLDER ) );
324cdf0e10cSrcweir     Image   aOpenedDocBmp( SfxResId( IMG_OPENED_DOC ) );
325cdf0e10cSrcweir     Image   aClosedDocBmp( SfxResId( IMG_CLOSED_DOC ) );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     Image   aOpenedFolderBmpHC( SfxResId( IMG_OPENED_FOLDER_HC ) );
328cdf0e10cSrcweir     Image   aClosedFolderBmpHC( SfxResId( IMG_CLOSED_FOLDER_HC ) );
329cdf0e10cSrcweir     Image   aOpenedDocBmpHC( SfxResId( IMG_OPENED_DOC_HC ) );
330cdf0e10cSrcweir     Image   aClosedDocBmpHC( SfxResId( IMG_CLOSED_DOC_HC ) );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     aLeftLb.SetBitmaps( aOpenedFolderBmp, aClosedFolderBmp, aOpenedDocBmp, aClosedDocBmp,
333cdf0e10cSrcweir                         aOpenedFolderBmpHC, aClosedFolderBmpHC, aOpenedDocBmpHC, aClosedDocBmpHC );
334cdf0e10cSrcweir     aRightLb.SetBitmaps( aOpenedFolderBmp, aClosedFolderBmp, aOpenedDocBmp, aClosedDocBmp,
335cdf0e10cSrcweir                         aOpenedFolderBmpHC, aClosedFolderBmpHC, aOpenedDocBmpHC, aClosedDocBmpHC );
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir //=========================================================================
339cdf0e10cSrcweir 
340cdf0e10cSrcweir sal_Bool QueryDelete_Impl(Window *pParent,      // Parent der QueryBox
341cdf0e10cSrcweir                              sal_uInt16 nId,            // Resource Id
342cdf0e10cSrcweir                              const String &rTemplateName)   // Name der zu l"oschenden Vorlage
343cdf0e10cSrcweir /*  [Beschreibung]
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     "oschabfrage
346cdf0e10cSrcweir 
347cdf0e10cSrcweir */
348cdf0e10cSrcweir {
349cdf0e10cSrcweir     SfxResId aResId( nId );
350cdf0e10cSrcweir     String aEntryText( aResId );
351cdf0e10cSrcweir     aEntryText.SearchAndReplaceAscii( "$1", rTemplateName );
352cdf0e10cSrcweir     QueryBox aBox( pParent, WB_YES_NO | WB_DEF_NO, aEntryText );
353cdf0e10cSrcweir     return RET_NO != aBox.Execute();
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir //-------------------------------------------------------------------------
357cdf0e10cSrcweir 
358cdf0e10cSrcweir void ErrorDelete_Impl(Window *pParent, const String &rName, sal_Bool bFolder = sal_False )
359cdf0e10cSrcweir 
360cdf0e10cSrcweir /*  [Beschreibung]
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     Benutzerinformation, da"s die Vorlage rName nicht gel"oscht werden konnte
363cdf0e10cSrcweir 
364cdf0e10cSrcweir */
365cdf0e10cSrcweir {
366cdf0e10cSrcweir     if ( bFolder )
367cdf0e10cSrcweir     {
368cdf0e10cSrcweir         String aText( SfxResId( STR_ERROR_DELETE_TEMPLATE_DIR ) );
369cdf0e10cSrcweir         ErrorBox( pParent, WB_OK, aText ).Execute();
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir     else
372cdf0e10cSrcweir     {
373cdf0e10cSrcweir         String aText( SfxResId( STR_ERROR_DELETE_TEMPLATE ) );
374cdf0e10cSrcweir         aText.SearchAndReplaceAscii( "$1", rName );
375cdf0e10cSrcweir         ErrorBox( pParent, WB_OK, aText ).Execute();
376cdf0e10cSrcweir     }
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 
380cdf0e10cSrcweir //=========================================================================
381cdf0e10cSrcweir 
382cdf0e10cSrcweir /*  [Beschreibung]
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     Implementierungsklasse; Referenzklasse f"ur USHORT-Array
385cdf0e10cSrcweir 
386cdf0e10cSrcweir */
387cdf0e10cSrcweir 
388cdf0e10cSrcweir struct ImpPath_Impl
389cdf0e10cSrcweir {
390cdf0e10cSrcweir     SvUShorts   aUS;
391cdf0e10cSrcweir     sal_uInt16      nRef;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     ImpPath_Impl();
394cdf0e10cSrcweir     ImpPath_Impl( const ImpPath_Impl& rCopy );
395cdf0e10cSrcweir };
396cdf0e10cSrcweir 
397cdf0e10cSrcweir //-------------------------------------------------------------------------
398cdf0e10cSrcweir 
399cdf0e10cSrcweir ImpPath_Impl::ImpPath_Impl() : aUS(5), nRef(1)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir //-------------------------------------------------------------------------
404cdf0e10cSrcweir 
405cdf0e10cSrcweir ImpPath_Impl::ImpPath_Impl( const ImpPath_Impl& rCopy ) :
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     aUS ( (sal_uInt8)rCopy.aUS.Count() ),
408cdf0e10cSrcweir     nRef( 1 )
409cdf0e10cSrcweir 
410cdf0e10cSrcweir {
411cdf0e10cSrcweir     const sal_uInt16 nCount = rCopy.aUS.Count();
412cdf0e10cSrcweir 
413cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nCount; ++i )
414cdf0e10cSrcweir         aUS.Insert( rCopy.aUS[i], i );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir //==========================================================================
418cdf0e10cSrcweir 
419cdf0e10cSrcweir /*  [Beschreibung]
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     Implementierungsklasse; Darstellung einer Position in der Outline-
422cdf0e10cSrcweir     Listbox als sal_uInt16-Array; dieses beschreibt die Position jeweil
42386e1cf34SPedro Giffuni     als relative Position zum "ubergeordneten Eintrag
424cdf0e10cSrcweir 
425cdf0e10cSrcweir */
426cdf0e10cSrcweir class Path
427cdf0e10cSrcweir {
428cdf0e10cSrcweir     ImpPath_Impl *pData;
429cdf0e10cSrcweir     void NewImp();
430cdf0e10cSrcweir public:
431cdf0e10cSrcweir     Path(SvLBox *pBox, SvLBoxEntry *pEntry);
432cdf0e10cSrcweir     Path(const Path &rPath):
433cdf0e10cSrcweir         pData(rPath.pData)
434cdf0e10cSrcweir     {
435cdf0e10cSrcweir         ++pData->nRef;
436cdf0e10cSrcweir     }
437cdf0e10cSrcweir     const Path &operator=(const Path &rPath)
438cdf0e10cSrcweir     {
439cdf0e10cSrcweir         if(&rPath != this)
440cdf0e10cSrcweir         {
441cdf0e10cSrcweir             if(!--pData->nRef)
442cdf0e10cSrcweir                 delete pData;
443cdf0e10cSrcweir             pData = rPath.pData;
444cdf0e10cSrcweir             pData->nRef++;
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir         return *this;
447cdf0e10cSrcweir     }
448cdf0e10cSrcweir     ~Path()
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         if(!--pData->nRef)
451cdf0e10cSrcweir             delete pData;
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir     sal_uInt16 Count() const { return pData->aUS.Count(); }
454cdf0e10cSrcweir     sal_uInt16 operator[]( sal_uInt16 i ) const
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         return i < Count()? pData->aUS[i]: INDEX_IGNORE;
457cdf0e10cSrcweir     }
458cdf0e10cSrcweir };
459cdf0e10cSrcweir 
460cdf0e10cSrcweir //-------------------------------------------------------------------------
461cdf0e10cSrcweir 
462cdf0e10cSrcweir Path::Path(SvLBox *pBox, SvLBoxEntry *pEntry) :
463cdf0e10cSrcweir     pData(new ImpPath_Impl)
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     DBG_ASSERT(pEntry != 0, "EntryPtr ist NULL");
466cdf0e10cSrcweir     if(!pEntry)
467cdf0e10cSrcweir         return;
468cdf0e10cSrcweir     SvLBoxEntry *pParent = pBox->GetParent(pEntry);
469cdf0e10cSrcweir     do {
470cdf0e10cSrcweir         pData->aUS.Insert((sal_uInt16)pBox->GetModel()->GetRelPos(pEntry), 0);
471cdf0e10cSrcweir         if(0 == pParent)
472cdf0e10cSrcweir             break;
473cdf0e10cSrcweir         pEntry = pParent;
474cdf0e10cSrcweir         pParent = pBox->GetParent(pEntry);
475cdf0e10cSrcweir     } while(1);
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir //-------------------------------------------------------------------------
479cdf0e10cSrcweir 
480cdf0e10cSrcweir void Path::NewImp()
481cdf0e10cSrcweir {
482cdf0e10cSrcweir     if(pData->nRef != 1)
483cdf0e10cSrcweir     {
484cdf0e10cSrcweir         pData->nRef--;
485cdf0e10cSrcweir         pData = new ImpPath_Impl(*pData);
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
489cdf0e10cSrcweir //-------------------------------------------------------------------------
490cdf0e10cSrcweir 
491cdf0e10cSrcweir SvLBoxEntry *GetIndices_Impl(SvLBox *pBox,
492cdf0e10cSrcweir                                SvLBoxEntry *pEntry,
493cdf0e10cSrcweir                                sal_uInt16 &rRegion,
494cdf0e10cSrcweir                                sal_uInt16 &rOffset)
495cdf0e10cSrcweir /*  [Beschreibung]
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     Bereich und Position innerhalb eines Bereiches f"ur eine
498cdf0e10cSrcweir     Dokumentvorlage wird ermittelt.
499cdf0e10cSrcweir 
500cdf0e10cSrcweir     [Parameter]
501cdf0e10cSrcweir 
502cdf0e10cSrcweir     SvLBox *pBox            Listbox, an der das Ereignis auftrat
503cdf0e10cSrcweir     SvLBoxEntry *pEntry     Eintrag, dessen Position ermittelt werden soll
504cdf0e10cSrcweir     sal_uInt16 &rRegion         der Bereich innerhalb der Bereiche der
505cdf0e10cSrcweir                             Dokumentvorlagen (Out-Parameter)
506cdf0e10cSrcweir     sal_uInt16 &rOffset         die Position innerhalb des Bereiches
507cdf0e10cSrcweir                             Dokumentvorlagen (Out-Parameter)
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     [Querverweise]
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     <class Path>    (unter Umst"anden kann auf diese Funktion zugunsten
512cdf0e10cSrcweir                      von Path verzichtet werden.)
513cdf0e10cSrcweir 
514cdf0e10cSrcweir */
515cdf0e10cSrcweir 
516cdf0e10cSrcweir {
517cdf0e10cSrcweir     if(!pEntry)
518cdf0e10cSrcweir     {
519cdf0e10cSrcweir         rRegion = rOffset = 0;
520cdf0e10cSrcweir         return pEntry;
521cdf0e10cSrcweir     }
522cdf0e10cSrcweir     if(0 == pBox->GetModel()->GetDepth(pEntry))
523cdf0e10cSrcweir     {
524cdf0e10cSrcweir         rRegion = (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry);
525cdf0e10cSrcweir         rOffset = USHRT_MAX;
526cdf0e10cSrcweir         return pEntry;
527cdf0e10cSrcweir     }
528cdf0e10cSrcweir     SvLBoxEntry *pParent = pBox->GetParent(pEntry);
529cdf0e10cSrcweir     rRegion = (sal_uInt16)pBox->GetModel()->GetRelPos(pParent);
530cdf0e10cSrcweir     rOffset = (sal_uInt16)pBox->GetModel()->GetRelPos(pEntry);
531cdf0e10cSrcweir     return pEntry;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir //-------------------------------------------------------------------------
535cdf0e10cSrcweir 
536cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir     if(!bSelect)
539cdf0e10cSrcweir         return SvTreeListBox::Select(pEntry,bSelect);
540cdf0e10cSrcweir     sal_uInt16 nLevel = GetDocLevel();
541cdf0e10cSrcweir     if(GetModel()->GetDepth(pEntry)+nLevel<3)
542cdf0e10cSrcweir         return SvTreeListBox::Select(pEntry,bSelect);
543cdf0e10cSrcweir 
544cdf0e10cSrcweir     Path aPath(this, pEntry);
545cdf0e10cSrcweir 
546cdf0e10cSrcweir     // it is ok to use the SfxObjectShellRef here since the object that
547cdf0e10cSrcweir     // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it
548cdf0e10cSrcweir     GetObjectShell(aPath)->TriggerHelpPI(
549cdf0e10cSrcweir         aPath[nLevel+1], aPath[nLevel+2], aPath[nLevel+3]);
550cdf0e10cSrcweir     return SvTreeListBox::Select(pEntry,bSelect);
551cdf0e10cSrcweir }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir //-------------------------------------------------------------------------
554cdf0e10cSrcweir 
555cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvLBox *pSourceBox,
556cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
557cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
558cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
559cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
560cdf0e10cSrcweir                                             sal_Bool bCopy)
561cdf0e10cSrcweir /*  [Beschreibung]
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     Verschieben oder Kopieren von Dokumentvorlagen
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     [Parameter]
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     SvLBox *pSourceBox          Quell-Listbox, an der das Ereignis auftrat
568cdf0e10cSrcweir     SvLBoxEntry *pSource        Quell-Eintrag, der kopiert / verschoben werden soll
569cdf0e10cSrcweir     SvLBoxEntry* pTarget        Ziel-Eintrag, auf den verschoben werden soll
570cdf0e10cSrcweir     SvLBoxEntry *&pNewParent    der Parent der an der Zielposition erzeugten
571cdf0e10cSrcweir                                 Eintrags (Out-Parameter)
572cdf0e10cSrcweir     sal_uIntPtr &rIdx                 Index des Zieleintrags
573cdf0e10cSrcweir     sal_Bool bCopy                  Flag f"ur Kopieren / Verschieben
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 
576cdf0e10cSrcweir     [Returnwert]                sal_Bool: Erfolg oder Mi"serfolg
577cdf0e10cSrcweir 
578cdf0e10cSrcweir     [Querverweise]
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvLBox *pSourceBox,
581cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
582cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
583cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
584cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
585cdf0e10cSrcweir                                             sal_Bool bCopy)>
586cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvLBoxEntry *pTarget,
587cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
588cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
589cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
590cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvLBoxEntry *pTarget,
591cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
592cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
593cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
594cdf0e10cSrcweir */
595cdf0e10cSrcweir 
596cdf0e10cSrcweir {
597cdf0e10cSrcweir     sal_Bool bOk = sal_False;
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     if(pSource)
600cdf0e10cSrcweir     {
601cdf0e10cSrcweir         sal_uInt16 nTargetRegion = 0, nTargetIndex = 0;
602cdf0e10cSrcweir         GetIndices_Impl(this, pTarget, nTargetRegion, nTargetIndex);
603cdf0e10cSrcweir 
604cdf0e10cSrcweir         sal_uInt16 nSourceRegion = 0, nSourceIndex = 0;
605cdf0e10cSrcweir         GetIndices_Impl(pSourceBox, pSource, nSourceRegion, nSourceIndex);
606cdf0e10cSrcweir 
607cdf0e10cSrcweir         bOk =  bCopy ?
608cdf0e10cSrcweir             pMgr->Copy(nTargetRegion, nTargetIndex+1,
609cdf0e10cSrcweir                        nSourceRegion, nSourceIndex):
610cdf0e10cSrcweir             pMgr->Move(nTargetRegion, nTargetIndex+1,
611cdf0e10cSrcweir                        nSourceRegion, nSourceIndex);
612cdf0e10cSrcweir 
613cdf0e10cSrcweir         if(bOk)
614cdf0e10cSrcweir         {
615cdf0e10cSrcweir             if(pSourceBox->GetModel()->GetDepth(pSource) == GetModel()->GetDepth(pTarget))
616cdf0e10cSrcweir             {
617cdf0e10cSrcweir                 pNewParent = GetParent(pTarget);
618cdf0e10cSrcweir                 rIdx = GetModel()->GetRelPos(pTarget)+1;
619cdf0e10cSrcweir             }
620cdf0e10cSrcweir             else
621cdf0e10cSrcweir             {
622cdf0e10cSrcweir                 if(nTargetIndex == USHRT_MAX)
623cdf0e10cSrcweir                 {
624cdf0e10cSrcweir                     pNewParent = pTarget;
625cdf0e10cSrcweir                     rIdx = 0;
626cdf0e10cSrcweir                 }
627cdf0e10cSrcweir                 else
628cdf0e10cSrcweir                     SvLBox::NotifyCopying(
629cdf0e10cSrcweir                         pTarget, pSource, pNewParent, rIdx);
630cdf0e10cSrcweir             }
631cdf0e10cSrcweir         }
632cdf0e10cSrcweir         else if ( bCopy )
633cdf0e10cSrcweir         {
634cdf0e10cSrcweir             // the template organizer always tries copy after the move, so no error is required for move case
635cdf0e10cSrcweir             String aText( SfxResId( bCopy ? STR_ERROR_COPY_TEMPLATE : STR_ERROR_MOVE_TEMPLATE ) );
636cdf0e10cSrcweir             aText.SearchAndReplaceAscii( "$1",
637cdf0e10cSrcweir                                          ( (SvTreeListBox *)pSourceBox )->GetEntryText( pSource ) );
638cdf0e10cSrcweir             ErrorBox( this, WB_OK, aText ).Execute();
639cdf0e10cSrcweir         }
640cdf0e10cSrcweir     }
641cdf0e10cSrcweir     return bOk;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir //-------------------------------------------------------------------------
645cdf0e10cSrcweir 
646cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::MoveOrCopyContents(SvLBox *pSourceBox,
647cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
648cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
649cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
650cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
651cdf0e10cSrcweir                                             sal_Bool bCopy)
652cdf0e10cSrcweir /*  [Beschreibung]
653cdf0e10cSrcweir 
654cdf0e10cSrcweir     Verschieben oder Kopieren von Dokumentinhalten
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     [Parameter]
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     SvLBox *pSourceBox          Quell-Listbox, an der das Ereignis auftrat
659cdf0e10cSrcweir     SvLBoxEntry *pSource        Quell-Eintrag, der kopiert / verschoben werden soll
660cdf0e10cSrcweir     SvLBoxEntry* pTarget        Ziel-Eintrag, auf den verschoben werden soll
661cdf0e10cSrcweir     SvLBoxEntry *&pNewParent    der Parent der an der Zielposition erzeugten
662cdf0e10cSrcweir                                 Eintrags (Out-Parameter)
663cdf0e10cSrcweir     sal_uIntPtr &rIdx                 Index des Zieleintrags
664cdf0e10cSrcweir     sal_Bool bCopy                  Flag f"ur Kopieren / Verschieben
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     [Returnwert]                sal_Bool: Erfolg oder Mi"serfolg
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     [Querverweise]
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvLBox *pSourceBox,
672cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
673cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
674cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
675cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
676cdf0e10cSrcweir                                             sal_Bool bCopy)>
677cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvLBoxEntry *pTarget,
678cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
679cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
680cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
681cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvLBoxEntry *pTarget,
682cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
683cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
684cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
685cdf0e10cSrcweir */
686cdf0e10cSrcweir 
687cdf0e10cSrcweir {
688cdf0e10cSrcweir     SfxErrorContext aEc( ERRCTX_SFX_MOVEORCOPYCONTENTS, this);
689cdf0e10cSrcweir     sal_Bool bOk = sal_False, bKeepExpansion = sal_False;
690cdf0e10cSrcweir     sal_Bool bRemovedFromSource = sal_False;
691cdf0e10cSrcweir     Path aSource(pSourceBox, pSource);
692cdf0e10cSrcweir     Path aTarget(this, pTarget);
693cdf0e10cSrcweir 
694cdf0e10cSrcweir     // it is ok to use the SfxObjectShellRef here since the object that
695cdf0e10cSrcweir     // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it
696cdf0e10cSrcweir     SfxObjectShellRef aSourceDoc = ((SfxOrganizeListBox_Impl *)pSourceBox)->GetObjectShell(aSource);
697cdf0e10cSrcweir     SfxObjectShellRef aTargetDoc = GetObjectShell(aTarget);
698cdf0e10cSrcweir 
699cdf0e10cSrcweir     const sal_uInt16 nSLevel =
700cdf0e10cSrcweir         ((SfxOrganizeListBox_Impl *)pSourceBox)->GetDocLevel();
701cdf0e10cSrcweir     const sal_uInt16 nTLevel = GetDocLevel();
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     if(aSourceDoc.Is() && aTargetDoc.Is())
704cdf0e10cSrcweir     {
705cdf0e10cSrcweir         if (aSourceDoc->GetStyleSheetPool())
706cdf0e10cSrcweir             aSourceDoc->GetStyleSheetPool()->SetSearchMask(
707cdf0e10cSrcweir                 SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED);
708cdf0e10cSrcweir 
709cdf0e10cSrcweir         if (aTargetDoc->GetStyleSheetPool())
710cdf0e10cSrcweir             aTargetDoc->GetStyleSheetPool()->SetSearchMask(
711cdf0e10cSrcweir                 SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED);
712cdf0e10cSrcweir         sal_uInt16 p[3];
713cdf0e10cSrcweir         sal_uInt16 nIdxDeleted = INDEX_IGNORE;
714cdf0e10cSrcweir         p[0]=aTarget[nTLevel+1];
715cdf0e10cSrcweir         p[1]=aTarget[nTLevel+2];
716cdf0e10cSrcweir         if(p[1]!=INDEX_IGNORE)p[1]++;
717cdf0e10cSrcweir         p[2]=aTarget[nTLevel+3];
718cdf0e10cSrcweir 
719cdf0e10cSrcweir         bOk = aTargetDoc->Insert(
720cdf0e10cSrcweir             *aSourceDoc, aSource[nSLevel+1],
721cdf0e10cSrcweir             aSource[nSLevel+2], aSource[nSLevel+3],
722cdf0e10cSrcweir             p[0], p[1], p[2],  nIdxDeleted);
723cdf0e10cSrcweir         // Positionskorrektur auswerten
724cdf0e10cSrcweir         // a = Dokumentinhalt
725cdf0e10cSrcweir         // b = Position Sub-Inhalt 1
726cdf0e10cSrcweir         // c = Position Sub-Inhalt 2
727cdf0e10cSrcweir         // doppelte Eintraege loeschen
728cdf0e10cSrcweir         if(bOk)
729cdf0e10cSrcweir         {
730cdf0e10cSrcweir             SvLBoxEntry *pParentIter = pTarget;
731cdf0e10cSrcweir             // bis auf die DokumentEbene nach oben als
732cdf0e10cSrcweir             // allgemeiner Bezugspunkt
733cdf0e10cSrcweir             while(GetModel()->GetDepth(pParentIter) != nTLevel)
734cdf0e10cSrcweir                 pParentIter = GetParent(pParentIter);
735cdf0e10cSrcweir             if(pParentIter->HasChildsOnDemand() &&
736cdf0e10cSrcweir                 !GetModel()->HasChilds(pParentIter))
737cdf0e10cSrcweir                 RequestingChilds(pParentIter);
738cdf0e10cSrcweir             SvLBoxEntry *pChildIter = 0;
739cdf0e10cSrcweir 
740cdf0e10cSrcweir             sal_uInt16 i = 0;
741cdf0e10cSrcweir             while(i < 2 && p[i+1] != INDEX_IGNORE)
742cdf0e10cSrcweir             {
743cdf0e10cSrcweir                 pChildIter = FirstChild(pParentIter);
744cdf0e10cSrcweir                 // bis zum Index der aktuellen Ebene
745cdf0e10cSrcweir                 for(sal_uInt16 j = 0; j < p[i]; ++j)
746cdf0e10cSrcweir                     pChildIter = NextSibling(pChildIter);
747cdf0e10cSrcweir                 // gfs Fuellen bei Items onDemand
748cdf0e10cSrcweir                 ++i;
7491776ad39SArmin Le Grand                 if((i < 2) && p[i+1] != INDEX_IGNORE &&
750cdf0e10cSrcweir                    pChildIter->HasChildsOnDemand() &&
751cdf0e10cSrcweir                    !GetModel()->HasChilds(pChildIter))
752cdf0e10cSrcweir                     RequestingChilds(pChildIter);
753cdf0e10cSrcweir                 pParentIter = pChildIter;
754cdf0e10cSrcweir             }
755cdf0e10cSrcweir             rIdx = p[i];
756cdf0e10cSrcweir             pNewParent = pParentIter;
757cdf0e10cSrcweir             if(!IsExpanded(pNewParent) &&
758cdf0e10cSrcweir                pNewParent->HasChildsOnDemand() &&
759cdf0e10cSrcweir                !GetModel()->HasChilds(pNewParent))
760cdf0e10cSrcweir             {
761cdf0e10cSrcweir                 bOk = sal_False;
762cdf0e10cSrcweir                 if(!bCopy)
763cdf0e10cSrcweir                     pSourceBox->GetModel()->Remove(pSource);
764cdf0e10cSrcweir             }
765cdf0e10cSrcweir             // Geloeschte Eintraege entfernen
766cdf0e10cSrcweir             // (kann durch Ueberschreiben geschehen)
767cdf0e10cSrcweir             if(nIdxDeleted != INDEX_IGNORE)
768cdf0e10cSrcweir             {
769cdf0e10cSrcweir                 pChildIter = FirstChild(pParentIter);
770cdf0e10cSrcweir                 for(sal_uInt16 j = 0; j < nIdxDeleted; ++j)
771cdf0e10cSrcweir                     pChildIter = NextSibling(pChildIter);
772cdf0e10cSrcweir                 if( pChildIter && pChildIter != pSource )
773cdf0e10cSrcweir                 {
774cdf0e10cSrcweir                     bKeepExpansion = IsExpanded(pParentIter);
775cdf0e10cSrcweir                     GetModel()->Remove(pChildIter);
776cdf0e10cSrcweir                 }
777cdf0e10cSrcweir                 else
778cdf0e10cSrcweir                     bOk = sal_False;
779cdf0e10cSrcweir             }
780cdf0e10cSrcweir             if(!bCopy && &aSourceDoc != &aTargetDoc)
781cdf0e10cSrcweir             {
782cdf0e10cSrcweir                 //#109566# pool styles that are moved produce
783cdf0e10cSrcweir                 //an rIdx == INDEX_IGNORE
784cdf0e10cSrcweir                 //the method has to return true to keep the box content consistent
785cdf0e10cSrcweir                 bRemovedFromSource = aSourceDoc->Remove(aSource[nSLevel+1],
786cdf0e10cSrcweir                                      aSource[nSLevel+2],
787cdf0e10cSrcweir                                      aSource[nSLevel+3]);
788cdf0e10cSrcweir             }
789cdf0e10cSrcweir         }
790cdf0e10cSrcweir     }
791cdf0e10cSrcweir //  rIdx++;
792cdf0e10cSrcweir     return (((rIdx != INDEX_IGNORE)|| bRemovedFromSource) && bOk )
793cdf0e10cSrcweir         ? bKeepExpansion? (sal_Bool)2: sal_True: sal_False;
794cdf0e10cSrcweir }
795cdf0e10cSrcweir 
796cdf0e10cSrcweir //-------------------------------------------------------------------------
797cdf0e10cSrcweir 
798cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvLBoxEntry *pTarget,
799cdf0e10cSrcweir                                         SvLBoxEntry* pSource,
800cdf0e10cSrcweir                                         SvLBoxEntry *&pNewParent,
801cdf0e10cSrcweir                                         sal_uIntPtr &rIdx)
802cdf0e10cSrcweir 
803cdf0e10cSrcweir /*  [Beschreibung]
804cdf0e10cSrcweir 
805cdf0e10cSrcweir     Benachrichtigung, da"s ein Eintrag verschoben werden soll
806cdf0e10cSrcweir     (SV-Handler)
807cdf0e10cSrcweir 
808cdf0e10cSrcweir     [Parameter]
809cdf0e10cSrcweir 
810cdf0e10cSrcweir     SvLBoxEntry* pTarget        Ziel-Eintrag, auf den verschoben werden soll
811cdf0e10cSrcweir     SvLBoxEntry *pSource        Quell-Eintrag, der verschoben werden soll
812cdf0e10cSrcweir     SvLBoxEntry *&pNewParent    der Parent der an der Zielposition erzeugten
813cdf0e10cSrcweir                                 Eintrags (Out-Parameter)
814cdf0e10cSrcweir     sal_uIntPtr &rIdx                 Index des Zieleintrags
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 
817cdf0e10cSrcweir     [Returnwert]                sal_Bool: Erfolg oder Mi"serfolg
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     [Querverweise]
820cdf0e10cSrcweir 
821cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvLBox *pSourceBox,
822cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
823cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
824cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
825cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
826cdf0e10cSrcweir                                             sal_Bool bCopy)>
827cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvLBox *pSourceBox,
828cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
829cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
830cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
831cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
832cdf0e10cSrcweir                                             sal_Bool bCopy)>
833cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvLBoxEntry *pTarget,
834cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
835cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
836cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
837cdf0e10cSrcweir */
838cdf0e10cSrcweir 
839cdf0e10cSrcweir {
840cdf0e10cSrcweir     sal_Bool bOk =  sal_False;
841cdf0e10cSrcweir     SvLBox* pSourceBox = GetSourceView();
842cdf0e10cSrcweir     if ( !pSourceBox )
843cdf0e10cSrcweir         pSourceBox = pDlg->pSourceView;
844cdf0e10cSrcweir     DBG_ASSERT( pSourceBox, "no source view" );
845cdf0e10cSrcweir     if ( !pTarget )
846cdf0e10cSrcweir         pTarget = pDlg->pTargetEntry;
847cdf0e10cSrcweir 
848cdf0e10cSrcweir     if ( pSourceBox->GetModel()->GetDepth( pSource ) <= GetDocLevel() &&
849cdf0e10cSrcweir                      GetModel()->GetDepth( pTarget ) <= GetDocLevel() )
850cdf0e10cSrcweir         bOk = MoveOrCopyTemplates( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_False );
851cdf0e10cSrcweir     else
852cdf0e10cSrcweir         bOk = MoveOrCopyContents(pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_False );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     return bOk;
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir //-------------------------------------------------------------------------
858cdf0e10cSrcweir 
859cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::NotifyCopying(SvLBoxEntry *pTarget,
860cdf0e10cSrcweir                                         SvLBoxEntry* pSource,
861cdf0e10cSrcweir                                         SvLBoxEntry *&pNewParent,
862cdf0e10cSrcweir                                         sal_uIntPtr &rIdx)
863cdf0e10cSrcweir /*  [Beschreibung]
864cdf0e10cSrcweir 
865cdf0e10cSrcweir     Benachrichtigung, da"s ein Eintrag kopiert werden soll
866cdf0e10cSrcweir     (SV-Handler)
867cdf0e10cSrcweir 
868cdf0e10cSrcweir     [Parameter]
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     SvLBoxEntry* pTarget        Ziel-Eintrag, auf den kopiert werden soll
871cdf0e10cSrcweir     SvLBoxEntry *pSource        Quell-Eintrag, der kopiert werden soll
872cdf0e10cSrcweir     SvLBoxEntry *&pNewParent    der Parent der an der Zielposition erzeugten
873cdf0e10cSrcweir                                 Eintrags (Out-Parameter)
874cdf0e10cSrcweir     sal_uIntPtr &rIdx                 Index des Zieleintrags
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 
877cdf0e10cSrcweir     [Returnwert]                sal_Bool: Erfolg oder Mi"serfolg
878cdf0e10cSrcweir 
879cdf0e10cSrcweir     [Querverweise]
880cdf0e10cSrcweir 
881cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyTemplates(SvLBox *pSourceBox,
882cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
883cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
884cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
885cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
886cdf0e10cSrcweir                                             sal_Bool bCopy)>
887cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::MoveOrCopyContents(SvLBox *pSourceBox,
888cdf0e10cSrcweir                                             SvLBoxEntry *pSource,
889cdf0e10cSrcweir                                             SvLBoxEntry* pTarget,
890cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
891cdf0e10cSrcweir                                             sal_uIntPtr &rIdx,
892cdf0e10cSrcweir                                             sal_Bool bCopy)>
893cdf0e10cSrcweir     <sal_Bool SfxOrganizeListBox_Impl::NotifyMoving(SvLBoxEntry *pTarget,
894cdf0e10cSrcweir                                             SvLBoxEntry* pSource,
895cdf0e10cSrcweir                                             SvLBoxEntry *&pNewParent,
896cdf0e10cSrcweir                                             sal_uIntPtr &rIdx)>
897cdf0e10cSrcweir */
898cdf0e10cSrcweir {
899cdf0e10cSrcweir     sal_Bool bOk =  sal_False;
900cdf0e10cSrcweir     SvLBox* pSourceBox = GetSourceView();
901cdf0e10cSrcweir     if ( !pSourceBox )
902cdf0e10cSrcweir         pSourceBox = pDlg->pSourceView;
903cdf0e10cSrcweir     DBG_ASSERT( pSourceBox, "no source view" );
904cdf0e10cSrcweir     if ( !pTarget )
905cdf0e10cSrcweir         pTarget = pDlg->pTargetEntry;
906cdf0e10cSrcweir     if ( pSourceBox->GetModel()->GetDepth( pSource ) <= GetDocLevel() &&
907cdf0e10cSrcweir                      GetModel()->GetDepth( pTarget ) <= GetDocLevel() )
908cdf0e10cSrcweir         bOk = MoveOrCopyTemplates( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_True );
909cdf0e10cSrcweir     else
910cdf0e10cSrcweir         bOk = MoveOrCopyContents( pSourceBox, pSource, pTarget, pNewParent, rIdx, sal_True );
911cdf0e10cSrcweir 
912cdf0e10cSrcweir     return bOk;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir //-------------------------------------------------------------------------
916cdf0e10cSrcweir 
917cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::EditingEntry( SvLBoxEntry* pEntry, Selection&  )
918cdf0e10cSrcweir 
919cdf0e10cSrcweir /*  [Beschreibung]
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     Nachfrage, ob ein Eintrag editierbar ist
922cdf0e10cSrcweir     (SV-Handler)
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     [Querverweise]
925cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::EditedEntry(SvLBoxEntry* pEntry, const String& rText)>
926cdf0e10cSrcweir */
927cdf0e10cSrcweir 
928cdf0e10cSrcweir {
929cdf0e10cSrcweir     if( VIEW_TEMPLATES == eViewType &&
930cdf0e10cSrcweir         GetModel()->GetDepth(pEntry) < 2 )
931cdf0e10cSrcweir     {
932cdf0e10cSrcweir         pDlg->pSuspend = new SuspendAccel( &pDlg->aEditAcc );
933cdf0e10cSrcweir         return sal_True;
934cdf0e10cSrcweir     }
935cdf0e10cSrcweir     return sal_False;
936cdf0e10cSrcweir }
937cdf0e10cSrcweir 
938cdf0e10cSrcweir //-------------------------------------------------------------------------
939cdf0e10cSrcweir 
940cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::EditedEntry(SvLBoxEntry* pEntry, const String& rText)
941cdf0e10cSrcweir 
942cdf0e10cSrcweir /*  [Beschreibung]
943cdf0e10cSrcweir 
944cdf0e10cSrcweir     Der Name eines Eintrags wurde bearbeitet; ist der eingegebene Name
945cdf0e10cSrcweir     ein g"ultiger Name ("ange > 0), wird das Model aktualisiert.
946cdf0e10cSrcweir     (SV-Handler)
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     [Returnwert]
949cdf0e10cSrcweir 
950cdf0e10cSrcweir     sal_Bool                sal_True: der Name soll in der Anzeige ge"andert werden
951cdf0e10cSrcweir                             sal_False:der Name soll nicht ge"andert werden
952cdf0e10cSrcweir 
953cdf0e10cSrcweir     [Querverweise]
954cdf0e10cSrcweir     <SfxOrganizeListBox_Impl::EditingEntry(SvLBoxEntry* pEntry, const String& rText)>
955cdf0e10cSrcweir */
956cdf0e10cSrcweir 
957cdf0e10cSrcweir {
958cdf0e10cSrcweir     DBG_ASSERT(pEntry, "kein Entry selektiert");
959cdf0e10cSrcweir     delete pDlg->pSuspend;
960cdf0e10cSrcweir     pDlg->pSuspend = NULL;
961cdf0e10cSrcweir     SvLBoxEntry* pParent = GetParent(pEntry);
962cdf0e10cSrcweir     if( !rText.Len() )
963cdf0e10cSrcweir     {
964cdf0e10cSrcweir         ErrorBox aBox( this, SfxResId( MSG_ERROR_EMPTY_NAME ) );
965cdf0e10cSrcweir         aBox.GrabFocus();
966cdf0e10cSrcweir         aBox.Execute();
967cdf0e10cSrcweir         return sal_False;
968cdf0e10cSrcweir     }
969cdf0e10cSrcweir     if ( !IsUniqName_Impl( rText, pParent, pEntry ) )
970cdf0e10cSrcweir     {
971cdf0e10cSrcweir         ErrorBox aBox( this, SfxResId( MSG_ERROR_UNIQ_NAME ) );
972cdf0e10cSrcweir         aBox.GrabFocus();
973cdf0e10cSrcweir         aBox.Execute();
974cdf0e10cSrcweir         return sal_False;
975cdf0e10cSrcweir     }
976cdf0e10cSrcweir     sal_uInt16 nRegion = 0, nIndex = 0;
977cdf0e10cSrcweir     GetIndices_Impl( this, pEntry, nRegion, nIndex );
978cdf0e10cSrcweir     String aOldName;
979cdf0e10cSrcweir     if ( USHRT_MAX != nIndex )
980cdf0e10cSrcweir         aOldName = pMgr->GetTemplates()->GetName( nRegion, nIndex );
981cdf0e10cSrcweir     else
982cdf0e10cSrcweir         aOldName = pMgr->GetTemplates()->GetRegionName( nRegion );
983cdf0e10cSrcweir 
984cdf0e10cSrcweir     if ( !pMgr->SetName( rText, nRegion, nIndex ) )
985cdf0e10cSrcweir     {
986cdf0e10cSrcweir         SfxResId aResId( USHRT_MAX != nIndex ? MSG_ERROR_RENAME_TEMPLATE
987cdf0e10cSrcweir                                              : MSG_ERROR_RENAME_TEMPLATE_REGION );
988cdf0e10cSrcweir         ErrorBox( this, aResId ).Execute();
989cdf0e10cSrcweir         return sal_False;
990cdf0e10cSrcweir     }
991cdf0e10cSrcweir /*
992cdf0e10cSrcweir     else
993cdf0e10cSrcweir     {
994cdf0e10cSrcweir         SfxTemplateOrganizeDlg* pDlg = (SfxTemplateOrganizeDlg*)Window::GetParent();
995cdf0e10cSrcweir     }
996cdf0e10cSrcweir */
997cdf0e10cSrcweir     return sal_True;
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir //-------------------------------------------------------------------------
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir DragDropMode SfxOrganizeListBox_Impl::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* pEntry )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir     sal_uInt16 nSourceLevel = GetModel()->GetDepth( pEntry );
1005cdf0e10cSrcweir     if ( VIEW_FILES == GetViewType() )
1006cdf0e10cSrcweir         ++nSourceLevel;
1007cdf0e10cSrcweir     if ( nSourceLevel >= 2 )
1008cdf0e10cSrcweir         bDropMoveOk = sal_False;
1009cdf0e10cSrcweir     else
1010cdf0e10cSrcweir         bDropMoveOk = sal_True;
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     return GetDragDropMode();
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir //-------------------------------------------------------------------------
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::NotifyAcceptDrop( SvLBoxEntry* pEntry )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir     if(!pEntry)
1020cdf0e10cSrcweir         return sal_False;
1021cdf0e10cSrcweir     SvLBox *pSource = GetSourceView();
1022cdf0e10cSrcweir     SvLBoxEntry *pSourceEntry = pSource->FirstSelected();
1023cdf0e10cSrcweir     if(pEntry == pSourceEntry)
1024cdf0e10cSrcweir         return sal_False;
1025cdf0e10cSrcweir     sal_uInt16 nSourceLevel = pSource->GetModel()->GetDepth(pSourceEntry);
1026cdf0e10cSrcweir     if(VIEW_FILES == ((SfxOrganizeListBox_Impl *)pSource)->GetViewType())
1027cdf0e10cSrcweir         ++nSourceLevel;
1028cdf0e10cSrcweir     sal_uInt16 nTargetLevel = GetModel()->GetDepth(pEntry);
1029cdf0e10cSrcweir     if(VIEW_FILES == GetViewType())
1030cdf0e10cSrcweir         ++nTargetLevel;
1031cdf0e10cSrcweir     Path aSource(pSource, pSourceEntry);
1032cdf0e10cSrcweir     Path aTarget(this, pEntry);
1033cdf0e10cSrcweir     const sal_uInt16 SL = ((SfxOrganizeListBox_Impl *)pSource)->GetDocLevel();
1034cdf0e10cSrcweir     const sal_uInt16 TL = GetDocLevel();
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir     return( (nSourceLevel == 1 && nTargetLevel == 0 &&
1037cdf0e10cSrcweir             VIEW_TEMPLATES ==
1038cdf0e10cSrcweir             ((SfxOrganizeListBox_Impl *)pSource)->GetViewType()) ||
1039cdf0e10cSrcweir            (nSourceLevel == 1 && nTargetLevel == 1 &&
1040cdf0e10cSrcweir             VIEW_TEMPLATES ==
1041cdf0e10cSrcweir             ((SfxOrganizeListBox_Impl *)pSource)->GetViewType() &&
1042cdf0e10cSrcweir             VIEW_TEMPLATES == GetViewType()) ||
1043cdf0e10cSrcweir            (nSourceLevel == 3 && nTargetLevel == 1) ||
1044cdf0e10cSrcweir            (nSourceLevel == 3 && nTargetLevel == 2 &&
1045cdf0e10cSrcweir             aSource[1+SL] == aTarget[1+TL]) ||
1046cdf0e10cSrcweir            (nSourceLevel == 3 && nTargetLevel == 3 &&
1047cdf0e10cSrcweir             aSource[1+SL] == aTarget[1+TL]) ||
1048cdf0e10cSrcweir            (nSourceLevel == 4 && nTargetLevel == 3 &&
1049cdf0e10cSrcweir             aSource[1+SL] == aTarget[1+TL] &&
1050cdf0e10cSrcweir             aSource[2+SL] == aTarget[2+TL]) ||
1051cdf0e10cSrcweir            (nSourceLevel == 4 && nTargetLevel == 4 &&
1052cdf0e10cSrcweir             aSource[1+SL] == aTarget[1+TL] &&
1053cdf0e10cSrcweir             aSource[2+SL] == aTarget[2+TL]));
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir //-------------------------------------------------------------------------
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir sal_Int8 SfxOrganizeListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir     sal_Bool bAccept = ( eViewType == VIEW_FILES && IsDropFormatSupported( SOT_FORMAT_FILE ) );
1061cdf0e10cSrcweir     if ( bAccept )
1062cdf0e10cSrcweir         return rEvt.mnAction;
1063cdf0e10cSrcweir     else
1064cdf0e10cSrcweir         return SvTreeListBox::AcceptDrop( rEvt );
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir //-------------------------------------------------------------------------
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir sal_Int8 SfxOrganizeListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir     TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable );
1072cdf0e10cSrcweir     sal_uInt32 nFormatCount = aHelper.GetFormatCount();
1073cdf0e10cSrcweir     sal_Bool bSuccess = sal_False;
1074cdf0e10cSrcweir     for ( sal_uInt32 i = 0; i < nFormatCount; ++i )
1075cdf0e10cSrcweir     {
1076cdf0e10cSrcweir         String aFileName;
1077cdf0e10cSrcweir         SotFormatStringId nId = aHelper.GetFormat(i);
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir         if ( SOT_FORMAT_FILE == nId && aHelper.GetString( nId, aFileName ) )
1080cdf0e10cSrcweir         {
1081cdf0e10cSrcweir             INetURLObject aObj( aFileName, INET_PROT_FILE );
1082cdf0e10cSrcweir             bSuccess |= pMgr->InsertFile( this, aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) );
1083cdf0e10cSrcweir         }
1084cdf0e10cSrcweir     }
1085cdf0e10cSrcweir     bDropMoveOk = sal_True;
1086cdf0e10cSrcweir     sal_Int8 nRet = rEvt.mnAction;
1087cdf0e10cSrcweir     if ( !bSuccess )
1088cdf0e10cSrcweir     {
1089cdf0e10cSrcweir         // asynchronous, because of MessBoxes
1090cdf0e10cSrcweir         pDlg->pSourceView = GetSourceView();
1091cdf0e10cSrcweir         pDlg->pTargetEntry = pTargetEntry;
1092cdf0e10cSrcweir         pDlg->pFinishedBox = NULL;
1093cdf0e10cSrcweir         pDlg->nDropAction = NO_DROP_ACTION;
1094cdf0e10cSrcweir         PostUserEvent( LINK( this, SfxOrganizeListBox_Impl, OnAsyncExecuteDrop ),
1095cdf0e10cSrcweir                        new ExecuteDropEvent( rEvt ) );
1096cdf0e10cSrcweir     }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir     return nRet;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir //-------------------------------------------------------------------------
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir void SfxOrganizeListBox_Impl::DragFinished( sal_Int8 nDropAction )
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir     if ( pDlg->bExecDropFinished )
1106cdf0e10cSrcweir     {
1107cdf0e10cSrcweir         if ( pDlg->nDropAction != NO_DROP_ACTION )
1108cdf0e10cSrcweir             nDropAction = pDlg->nDropAction;
1109cdf0e10cSrcweir         SvTreeListBox::DragFinished( nDropAction );
1110cdf0e10cSrcweir         pDlg->nDropAction = NO_DROP_ACTION;
1111cdf0e10cSrcweir     }
1112cdf0e10cSrcweir     else
1113cdf0e10cSrcweir         pDlg->pFinishedBox = this;
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir //-------------------------------------------------------------------------
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir inline sal_uInt16 SfxOrganizeListBox_Impl::GetDocLevel() const
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir /*  [Beschreibung]
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir     Ermittelt, auf welche Ebene sich Dokumente befinden (unterschiedlich
1123cdf0e10cSrcweir     in der Dokumentvorlagensicht und der Dokumentensicht)
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir     [Returnwert]
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir     sal_uInt16              Die Ebene der Dokumente
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir */
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir     return eViewType == VIEW_FILES? 0: 1;
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir //-------------------------------------------------------------------------
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir SfxObjectShellRef SfxOrganizeListBox_Impl::GetObjectShell(const Path &rPath)
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir /*  [Beschreibung]
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir     Zugriff auf die ObjectShell, die dem aktuellen Eintrag zugeordnet
1142cdf0e10cSrcweir     ist.
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir     [Parameter]
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir     const Path &rPath       Beschreibung des aktuellen Eintrags
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir     [Returnwert]
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir     SfxObjectShellRef     Referenz auf die ObjectShell
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir     [Querverweise]
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir     <class Path>
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir */
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir     SfxObjectShellRef aDoc;
1160cdf0e10cSrcweir     if(eViewType == VIEW_FILES)
1161cdf0e10cSrcweir         aDoc = pMgr->CreateObjectShell(rPath[0]);
1162cdf0e10cSrcweir     else
1163cdf0e10cSrcweir         aDoc = pMgr->CreateObjectShell(rPath[0], rPath[1]);
1164cdf0e10cSrcweir     return aDoc;
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir //-------------------------------------------------------------------------
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir void SfxOrganizeListBox_Impl::RequestingChilds( SvLBoxEntry* pEntry )
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir /*  [Beschreibung]
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir     Aufforderung, der Childs eines Eintrags einzuf"ugen
1174cdf0e10cSrcweir     ist.
1175cdf0e10cSrcweir     (SV-Handler)
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     [Parameter]
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir     SvLBoxEntry* pEntry     der Eintrag, dessen Childs erfragt werden
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir */
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir     // wenn keine Childs vorhanden sind, gfs. Childs
1186cdf0e10cSrcweir     // einfuegen
1187cdf0e10cSrcweir     BmpColorMode eColorMode = BMP_COLOR_NORMAL;
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     if ( GetSettings().GetStyleSettings().GetHighContrastMode() )
1190cdf0e10cSrcweir         eColorMode = BMP_COLOR_HIGHCONTRAST;
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir     if ( !GetModel()->HasChilds( pEntry ) )
1194cdf0e10cSrcweir     {
1195cdf0e10cSrcweir         WaitObject aWaitCursor( this );
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir         // Choose the correct mask color dependent from eColorMode. This must be adopted if
1198cdf0e10cSrcweir         // we change the mask color for normal images, too!
1199cdf0e10cSrcweir         Color aMaskColor( COL_LIGHTMAGENTA );
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir         // hier sind alle initial eingefuegt
1202cdf0e10cSrcweir         SfxErrorContext aEc(ERRCTX_SFX_CREATEOBJSH, pDlg->pDialog);
1203cdf0e10cSrcweir         if(VIEW_TEMPLATES == GetViewType() && 0 == GetModel()->GetDepth(pEntry))
1204cdf0e10cSrcweir         {
1205cdf0e10cSrcweir             sal_uInt16 i = (sal_uInt16)GetModel()->GetRelPos(pEntry);
1206cdf0e10cSrcweir             const sal_uInt16 nEntryCount = pMgr->GetTemplates()->GetCount(i);
1207cdf0e10cSrcweir             for(sal_uInt16 j = 0; j < nEntryCount; ++j)
1208cdf0e10cSrcweir                 InsertEntryByBmpType( pMgr->GetTemplates()->GetName( i, j ), BMPTYPE_DOC, pEntry, sal_True );
1209cdf0e10cSrcweir         }
1210cdf0e10cSrcweir         else
1211cdf0e10cSrcweir         {
1212cdf0e10cSrcweir             const sal_uInt16 nDocLevel = GetDocLevel();
1213cdf0e10cSrcweir             Path aPath(this, pEntry);
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir             // it is ok to use the SfxObjectShellRef here since the object that
1216cdf0e10cSrcweir             // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it
1217cdf0e10cSrcweir             SfxObjectShellRef aRef = GetObjectShell(aPath);
1218cdf0e10cSrcweir             if(aRef.Is())
1219cdf0e10cSrcweir             {
1220cdf0e10cSrcweir                 const sal_uInt16 nCount = aRef->GetContentCount(
1221cdf0e10cSrcweir                     aPath[nDocLevel+1], aPath[nDocLevel+2]);
1222cdf0e10cSrcweir                 String aText;
1223cdf0e10cSrcweir                 Bitmap aClosedBmp, aOpenedBmp;
1224cdf0e10cSrcweir                 const sal_Bool bCanHaveChilds =
1225cdf0e10cSrcweir                     aRef->CanHaveChilds(aPath[nDocLevel+1],
1226cdf0e10cSrcweir                                         aPath[nDocLevel+2]);
1227cdf0e10cSrcweir                 for(sal_uInt16 i = 0; i < nCount; ++i)
1228cdf0e10cSrcweir                 {
1229cdf0e10cSrcweir                     sal_Bool bDeletable;
1230cdf0e10cSrcweir                     aRef->GetContent(
1231cdf0e10cSrcweir                         aText, aClosedBmp, aOpenedBmp, eColorMode, bDeletable,
1232cdf0e10cSrcweir                         i, aPath[nDocLevel+1], aPath[nDocLevel+2]);
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir                     // Create image with the correct mask color
1235cdf0e10cSrcweir                     Image aClosedImage( aClosedBmp, aMaskColor );
1236cdf0e10cSrcweir                     Image aOpenedImage( aOpenedBmp, aMaskColor );
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir                     SvLBoxEntry *pNew = SvTreeListBox::InsertEntry(
1239cdf0e10cSrcweir                         aText, aOpenedImage, aClosedImage,
1240cdf0e10cSrcweir                         pEntry, bCanHaveChilds);
1241cdf0e10cSrcweir                     pNew->SetUserData(bDeletable ? &bDeletable : 0);
1242cdf0e10cSrcweir                 }
1243cdf0e10cSrcweir             }
1244cdf0e10cSrcweir         }
1245cdf0e10cSrcweir     }
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir //-------------------------------------------------------------------------
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir long SfxOrganizeListBox_Impl::ExpandingHdl()
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir /*  [Beschreibung]
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     SV-Handler, der nach dem und vor dem Aufklappen eines Eintrags
1255cdf0e10cSrcweir     gerufen wird.
1256cdf0e10cSrcweir     Wird verwendet, um gfs. die ObjectShell wieder zu schlie"sen;
1257cdf0e10cSrcweir     die Eintr"age mit den Inhalten dieser Shell werden ebenfalls
1258cdf0e10cSrcweir     entfernt.
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir */
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir     if ( !(nImpFlags & SVLBOX_IS_EXPANDING) )
1264cdf0e10cSrcweir     {
1265cdf0e10cSrcweir         SvLBoxEntry* pEntry  = GetHdlEntry();
1266cdf0e10cSrcweir         const sal_uInt16 nLevel = GetModel()->GetDepth(pEntry);
1267cdf0e10cSrcweir         if((eViewType == VIEW_FILES && nLevel == 0) ||
1268cdf0e10cSrcweir            (eViewType == VIEW_TEMPLATES && nLevel == 1))
1269cdf0e10cSrcweir         {
1270cdf0e10cSrcweir             Path aPath(this, pEntry);
1271cdf0e10cSrcweir             // Beim Schliessen des Files die ObjectShell freigeben
1272cdf0e10cSrcweir             if(eViewType == VIEW_FILES && nLevel == 0)
1273cdf0e10cSrcweir                 pMgr->DeleteObjectShell(aPath[0]);
1274cdf0e10cSrcweir             else
1275cdf0e10cSrcweir                 pMgr->DeleteObjectShell(aPath[0], aPath[1]);
1276cdf0e10cSrcweir             // alle SubEntries loeschen
1277cdf0e10cSrcweir             SvLBoxEntry *pToDel = SvLBox::GetEntry(pEntry, 0);
1278cdf0e10cSrcweir             while(pToDel)
1279cdf0e10cSrcweir             {
1280cdf0e10cSrcweir                 GetModel()->Remove(pToDel);
1281cdf0e10cSrcweir                 pToDel = SvLBox::GetEntry(pEntry, 0);
1282cdf0e10cSrcweir             }
1283cdf0e10cSrcweir         }
1284cdf0e10cSrcweir     }
1285cdf0e10cSrcweir     return sal_True;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir //-------------------------------------------------------------------------
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir sal_Bool SfxOrganizeListBox_Impl::IsUniqName_Impl(const String &rText,
1291cdf0e10cSrcweir                                          SvLBoxEntry* pParent, SvLBoxEntry *pEntry) const
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir /*  [Beschreibung]
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir     Pr"uft, ob eine Name auf seiner Ebene eindeutig ist.
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir     [Parameter]
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir     const String &         Name des zu suchenden Eintrags
1300cdf0e10cSrcweir     SvLBoxEntry* pSibling  Geschwister (bezeichnet die Ebene)
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir     [Returnwert]
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir     sal_Bool                     sal_True, wenn der Name eindeutig ist, sonst sal_False
1305cdf0e10cSrcweir */
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir     SvLBoxEntry* pChild = FirstChild(pParent);
1309cdf0e10cSrcweir     while(pChild)  {
1310cdf0e10cSrcweir         const String aEntryText(GetEntryText(pChild));
1311cdf0e10cSrcweir         if(COMPARE_EQUAL == aEntryText.CompareIgnoreCaseToAscii(rText)&&(!pEntry || pEntry!=pChild))
1312cdf0e10cSrcweir             return sal_False;
1313cdf0e10cSrcweir         pChild = NextSibling(pChild);
1314cdf0e10cSrcweir     }
1315cdf0e10cSrcweir     return sal_True;
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir //-------------------------------------------------------------------------
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir sal_uInt16 SfxOrganizeListBox_Impl::GetLevelCount_Impl(SvLBoxEntry* pParent) const
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     SvLBoxEntry* pChild = FirstChild(pParent);
1323cdf0e10cSrcweir     sal_uInt16 nCount = 0;
1324cdf0e10cSrcweir     while(pChild)  {
1325cdf0e10cSrcweir         pChild = NextSibling(pChild);
1326cdf0e10cSrcweir         ++nCount;
1327cdf0e10cSrcweir     }
1328cdf0e10cSrcweir     return nCount;
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir //-------------------------------------------------------------------------
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir SvLBoxEntry* SfxOrganizeListBox_Impl::InsertEntryByBmpType( const XubString& rText, BMPTYPE eBmpType,
1334cdf0e10cSrcweir     SvLBoxEntry* pParent, sal_Bool bChildsOnDemand, sal_uIntPtr nPos, void* pUserData )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir     SvLBoxEntry*    pEntry = NULL;
1337cdf0e10cSrcweir     const Image*    pExp = NULL;
1338cdf0e10cSrcweir     const Image*    pCol = NULL;
1339cdf0e10cSrcweir     const Image*    pExpHC = NULL;
1340cdf0e10cSrcweir     const Image*    pColHC = NULL;
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir     switch( eBmpType )
1343cdf0e10cSrcweir     {
1344cdf0e10cSrcweir         case BMPTYPE_FOLDER:
1345cdf0e10cSrcweir             pExp = &aOpenedFolderBmp;
1346cdf0e10cSrcweir             pCol = &aClosedFolderBmp;
1347cdf0e10cSrcweir             pExpHC = &aOpenedFolderBmpHC;
1348cdf0e10cSrcweir             pColHC = &aClosedFolderBmpHC;
1349cdf0e10cSrcweir             break;
1350cdf0e10cSrcweir         default:
1351cdf0e10cSrcweir             DBG_ERROR( "SfxOrganizeListBox_Impl::InsertEntryByBmpType(): something forgotten?!" );
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir         case BMPTYPE_DOC:
1354cdf0e10cSrcweir             pExp = &aOpenedDocBmp;
1355cdf0e10cSrcweir             pCol = &aClosedDocBmp;
1356cdf0e10cSrcweir             pExpHC = &aOpenedDocBmpHC;
1357cdf0e10cSrcweir             pColHC = &aClosedDocBmpHC;
1358cdf0e10cSrcweir             break;
1359cdf0e10cSrcweir     }
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir     pEntry = SvTreeListBox::InsertEntry( rText, *pExp, *pCol, pParent, bChildsOnDemand, nPos, pUserData );
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir     SetExpandedEntryBmp( pEntry, *pExpHC, BMP_COLOR_HIGHCONTRAST );
1364cdf0e10cSrcweir     SetCollapsedEntryBmp( pEntry, *pColHC, BMP_COLOR_HIGHCONTRAST );
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir     return pEntry;
1367cdf0e10cSrcweir }
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir //-------------------------------------------------------------------------
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir SfxOrganizeListBox_Impl::SfxOrganizeListBox_Impl
1372cdf0e10cSrcweir (
1373cdf0e10cSrcweir     SfxOrganizeDlg_Impl* pArgDlg,
1374cdf0e10cSrcweir     Window* pParent,
1375cdf0e10cSrcweir     WinBits nBits,
1376cdf0e10cSrcweir     DataEnum eType
1377cdf0e10cSrcweir ) :
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir     SvTreeListBox( pParent, nBits ),
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir     pMgr        ( NULL ),
1382cdf0e10cSrcweir     pDlg        ( pArgDlg ),
1383cdf0e10cSrcweir     eViewType   ( eType )
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir /*  [Beschreibung]
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir     Konstruktor SfxOrganizeListBox
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir */
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir     SetDragDropMode(
1393cdf0e10cSrcweir         SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
1394cdf0e10cSrcweir         SV_DRAGDROP_APP_MOVE  | SV_DRAGDROP_APP_COPY  | SV_DRAGDROP_APP_DROP );
1395cdf0e10cSrcweir     SetEntryHeight( 16 );
1396cdf0e10cSrcweir     SetSelectionMode( SINGLE_SELECTION );
1397cdf0e10cSrcweir     GetModel()->SetSortMode( SortNone );
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir     EnableContextMenuHandling();
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir //-------------------------------------------------------------------------
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir IMPL_LINK( SfxOrganizeListBox_Impl, OnAsyncExecuteDrop, ExecuteDropEvent*, pEvent )
1405cdf0e10cSrcweir {
1406cdf0e10cSrcweir     DBG_ASSERT( pEvent, "invalid DropEvent" );
1407cdf0e10cSrcweir     if ( pEvent )
1408cdf0e10cSrcweir     {
1409cdf0e10cSrcweir         SvLBox* pSourceView = GetSourceView();
1410cdf0e10cSrcweir         if ( !pSourceView )
1411cdf0e10cSrcweir             pSourceView = pDlg->pSourceView;
1412cdf0e10cSrcweir         pDlg->bExecDropFinished = false;
1413cdf0e10cSrcweir         // if a template can not be moved it should be copied
1414cdf0e10cSrcweir         if ( pEvent->mnAction == DND_ACTION_MOVE )
1415cdf0e10cSrcweir             pEvent->mnAction = DND_ACTION_COPYMOVE;
1416cdf0e10cSrcweir         pDlg->nDropAction = SvTreeListBox::ExecuteDrop( *pEvent, pSourceView );
1417cdf0e10cSrcweir         delete pEvent;
1418cdf0e10cSrcweir         pDlg->pSourceView = NULL;
1419cdf0e10cSrcweir         pDlg->pTargetEntry = NULL;
1420cdf0e10cSrcweir         pDlg->bExecDropFinished = true;
1421cdf0e10cSrcweir         if ( pDlg->pFinishedBox )
1422cdf0e10cSrcweir         {
1423cdf0e10cSrcweir             pDlg->pFinishedBox->DragFinished( pDlg->nDropAction );
1424cdf0e10cSrcweir             pDlg->pFinishedBox = NULL;
1425cdf0e10cSrcweir         }
1426cdf0e10cSrcweir     }
1427cdf0e10cSrcweir     return 0;
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir //-------------------------------------------------------------------------
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir void SfxOrganizeListBox_Impl::Reset()
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir /*  [Beschreibung]
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir     Einf"ugen der Elemente in die ListBox
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir */
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir     DBG_ASSERT( pMgr != 0, "kein Manager" );
1442cdf0e10cSrcweir     // Inhalte l"oschen
1443cdf0e10cSrcweir     SetUpdateMode(sal_False);
1444cdf0e10cSrcweir     Clear();
1445cdf0e10cSrcweir     if ( VIEW_TEMPLATES == eViewType )
1446cdf0e10cSrcweir     {
1447cdf0e10cSrcweir         const sal_uInt16 nCount = pMgr->GetTemplates()->GetRegionCount();
1448cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < nCount; ++i )
1449cdf0e10cSrcweir             InsertEntryByBmpType( pMgr->GetTemplates()->GetFullRegionName(i), BMPTYPE_FOLDER, 0, sal_True );
1450cdf0e10cSrcweir     }
1451cdf0e10cSrcweir     else
1452cdf0e10cSrcweir     {
1453cdf0e10cSrcweir         const SfxObjectList& rList = pMgr->GetObjectList();
1454cdf0e10cSrcweir         const sal_uInt16 nCount = rList.Count();
1455cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < nCount; ++i )
1456cdf0e10cSrcweir             InsertEntryByBmpType( rList.GetBaseName(i), BMPTYPE_DOC, 0, sal_True );
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir     }
1459cdf0e10cSrcweir     SetUpdateMode(sal_True);
1460cdf0e10cSrcweir     Invalidate();
1461cdf0e10cSrcweir     Update();
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir //-------------------------------------------------------------------------
1465cdf0e10cSrcweir 
1466cdf0e10cSrcweir const Image &SfxOrganizeListBox_Impl::GetClosedBmp(sal_uInt16 nLevel) const
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir /*  [Beschreibung]
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir     Zugriff auf die Bitmap f"ur einen geschlossenen Eintrag
1471cdf0e10cSrcweir     der jeweiligen Ebene
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir     [Parameter]
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir     sal_uInt16 nLevel       Angabe der Ebene, 2 Ebenen sind erlaubt
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir     [Returnwert]
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir     const Image &       das Image auf der Ebenen nLevel
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir */
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir {
1484cdf0e10cSrcweir     sal_Bool            bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
1485cdf0e10cSrcweir     const Image*    pRet = NULL;
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir     switch( nLevel )
1488cdf0e10cSrcweir     {
1489cdf0e10cSrcweir         default:    DBG_ERROR( "Bitmaps ueberindiziert" );
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir         case 0:     pRet = bHC? &aClosedFolderBmpHC : &aClosedFolderBmp;        break;
1492cdf0e10cSrcweir         case 1:     pRet = bHC? &aClosedDocBmpHC : &aClosedDocBmp;              break;
1493cdf0e10cSrcweir     }
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir     return *pRet;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir //-------------------------------------------------------------------------
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir const Image &SfxOrganizeListBox_Impl::GetOpenedBmp(sal_uInt16 nLevel) const
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir /*  [Beschreibung]
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir     Zugriff auf die Bitmap f"ur einen ge"offneten Eintrag
1505cdf0e10cSrcweir     der jeweiligen Ebene
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir     [Parameter]
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir     sal_uInt16 nLevel       Angabe der Ebene, 2 Ebenen sind erlaubt
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir     [Returnwert]
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir     const Image &       das Image auf der Ebenen nLevel
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir */
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir     sal_Bool         bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
1519cdf0e10cSrcweir     const Image* pRet = NULL;
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir     switch( nLevel )
1522cdf0e10cSrcweir     {
1523cdf0e10cSrcweir         case 0:
1524cdf0e10cSrcweir            pRet = bHC ? &aOpenedFolderBmpHC : &aOpenedFolderBmp; break;
1525cdf0e10cSrcweir         case 1:
1526cdf0e10cSrcweir            pRet = bHC ? &aOpenedDocBmpHC : &aOpenedDocBmp; break;
1527cdf0e10cSrcweir         default:
1528cdf0e10cSrcweir             pRet = bHC ? &aClosedFolderBmpHC : &aClosedFolderBmp; break;
1529cdf0e10cSrcweir     }
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir     return *pRet;
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir //-------------------------------------------------------------------------
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir PopupMenu* SfxOrganizeListBox_Impl::CreateContextMenu()
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir     return new PopupMenu( *( pDlg->aEditBtn.GetPopupMenu() ) );
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir //-------------------------------------------------------------------------
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir String SfxOrganizeDlg_Impl::GetPath_Impl( sal_Bool bOpen, const String& rFileName )
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir /*  [Beschreibung]
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir     Pfad per FileDialog erfragen, f"ur Import / Export von
1548cdf0e10cSrcweir     Dokumentvorlagen
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir     [Parameter]
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir     sal_Bool bOpen                      Flag: "Offnen / Speichern
1553cdf0e10cSrcweir     const String& rFileName         aktueller Dateiname als Vorschlag
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir     [R"uckgabewert]                 Dateiname mit Pfad oder Leerstring, wenn
1556cdf0e10cSrcweir                                     der Benutzer 'Abbrechen' gedr"uckt hat
1557cdf0e10cSrcweir */
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir {
1560cdf0e10cSrcweir     String aPath;
1561cdf0e10cSrcweir     m_sExtension4Save = DEFINE_CONST_UNICODE( "vor" );
1562cdf0e10cSrcweir     sal_Int16 nDialogType = bOpen
1563cdf0e10cSrcweir         ? com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
1564cdf0e10cSrcweir         : com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE;
1565cdf0e10cSrcweir     if ( pFileDlg )
1566cdf0e10cSrcweir         delete pFileDlg;
1567cdf0e10cSrcweir     pFileDlg = new sfx2::FileDialogHelper( nDialogType, 0L );
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir     // add "All" filter
1570cdf0e10cSrcweir     pFileDlg->AddFilter( String( SfxResId( STR_SFX_FILTERNAME_ALL ) ),
1571cdf0e10cSrcweir                          DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) );
1572cdf0e10cSrcweir     // add template filter
1573cdf0e10cSrcweir     String sFilterName( SfxResId( STR_TEMPLATE_FILTER ) );
1574cdf0e10cSrcweir     String sFilterExt;
1575cdf0e10cSrcweir     // add filters of modules which are installed
1576cdf0e10cSrcweir     SvtModuleOptions aModuleOpt;
1577cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
1578cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.ott;*.stw;*.oth" );
1579cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
1580cdf0e10cSrcweir     {
1581cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1582cdf0e10cSrcweir             sFilterExt += ';';
1583cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.ots;*.stc" );
1584cdf0e10cSrcweir     }
1585cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
1586cdf0e10cSrcweir     {
1587cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1588cdf0e10cSrcweir             sFilterExt += ';';
1589cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.otp;*.sti" );
1590cdf0e10cSrcweir     }
1591cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
1592cdf0e10cSrcweir     {
1593cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1594cdf0e10cSrcweir             sFilterExt += ';';
1595cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.otg;*.std" );
1596cdf0e10cSrcweir     }
1597cdf0e10cSrcweir     if ( sFilterExt.Len() > 0 )
1598cdf0e10cSrcweir         sFilterExt += ';';
1599cdf0e10cSrcweir     sFilterExt += DEFINE_CONST_UNICODE( "*.vor" );
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     sFilterName += DEFINE_CONST_UNICODE( " (" );
1602cdf0e10cSrcweir     sFilterName += sFilterExt;
1603cdf0e10cSrcweir     sFilterName += ')';
1604cdf0e10cSrcweir     pFileDlg->AddFilter( sFilterName, sFilterExt );
1605cdf0e10cSrcweir     pFileDlg->SetCurrentFilter( sFilterName );
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir     if ( aLastDir.Len() || rFileName.Len() )
1608cdf0e10cSrcweir     {
1609cdf0e10cSrcweir         INetURLObject aObj;
1610cdf0e10cSrcweir         if ( aLastDir.Len() )
1611cdf0e10cSrcweir         {
1612cdf0e10cSrcweir             aObj.SetURL( aLastDir );
1613cdf0e10cSrcweir             if ( rFileName.Len() )
1614cdf0e10cSrcweir                 aObj.insertName( rFileName );
1615cdf0e10cSrcweir         }
1616cdf0e10cSrcweir         else
1617cdf0e10cSrcweir             aObj.SetURL( rFileName );
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir         if ( aObj.hasExtension() )
1620cdf0e10cSrcweir         {
1621cdf0e10cSrcweir             m_sExtension4Save = aObj.getExtension(
1622cdf0e10cSrcweir                 INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
1623cdf0e10cSrcweir             aObj.removeExtension();
1624cdf0e10cSrcweir         }
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir         DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
1627cdf0e10cSrcweir         pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
1628cdf0e10cSrcweir     }
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir     pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, ImportHdl ) );
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir     return aPath;
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir //-------------------------------------------------------------------------
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString >
1638cdf0e10cSrcweir     SfxOrganizeDlg_Impl::GetPaths_Impl( const String& rFileName )
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir /*  [Description]
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir    Query plural paths by FileDialog, for Import / Export from document
1643cdf0e10cSrcweir    templates
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir    [Parameter]
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir    const String& rFileName         The default file name when dialog executes
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir    [Return value]                 Empty sequence when users have clicked
1650cdf0e10cSrcweir                                   'Cancel', a sequence just containing one
1651cdf0e10cSrcweir                                   file name with path when they have
1652*30acf5e8Spfg                                   chose one file or a sequence containing
1653cdf0e10cSrcweir                                   path and file names without path
1654cdf0e10cSrcweir */
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir {
1657cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > aPaths;
1658cdf0e10cSrcweir     m_sExtension4Save = DEFINE_CONST_UNICODE( "vor" );
1659cdf0e10cSrcweir     if ( pFileDlg )
1660cdf0e10cSrcweir             delete pFileDlg;
1661cdf0e10cSrcweir     pFileDlg = new sfx2::FileDialogHelper(
1662cdf0e10cSrcweir         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, SFXWB_MULTISELECTION );
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir     // add "All" filter
1665cdf0e10cSrcweir     pFileDlg->AddFilter( String( SfxResId( STR_SFX_FILTERNAME_ALL ) ),
1666cdf0e10cSrcweir                          DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) );
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir     // add template filter
1669cdf0e10cSrcweir     String sFilterName( SfxResId( STR_TEMPLATE_FILTER ) );
1670cdf0e10cSrcweir     String sFilterExt;
1671cdf0e10cSrcweir     // add filters of modules which are installed
1672cdf0e10cSrcweir     SvtModuleOptions aModuleOpt;
1673cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
1674cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.ott;*.stw;*.oth" );
1675cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
1676cdf0e10cSrcweir     {
1677cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1678cdf0e10cSrcweir             sFilterExt += ';';
1679cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.ots;*.stc" );
1680cdf0e10cSrcweir     }
1681cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
1682cdf0e10cSrcweir     {
1683cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1684cdf0e10cSrcweir             sFilterExt += ';';
1685cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.otp;*.sti" );
1686cdf0e10cSrcweir     }
1687cdf0e10cSrcweir     if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
1688cdf0e10cSrcweir     {
1689cdf0e10cSrcweir         if ( sFilterExt.Len() > 0 )
1690cdf0e10cSrcweir             sFilterExt += ';';
1691cdf0e10cSrcweir         sFilterExt += DEFINE_CONST_UNICODE( "*.otg;*.std" );
1692cdf0e10cSrcweir     }
1693cdf0e10cSrcweir     if ( sFilterExt.Len() > 0 )
1694cdf0e10cSrcweir         sFilterExt += ';';
1695cdf0e10cSrcweir     sFilterExt += DEFINE_CONST_UNICODE( "*.vor" );
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir     sFilterName += DEFINE_CONST_UNICODE( " (" );
1698cdf0e10cSrcweir     sFilterName += sFilterExt;
1699cdf0e10cSrcweir     sFilterName += ')';
1700cdf0e10cSrcweir     pFileDlg->AddFilter( sFilterName, sFilterExt );
1701cdf0e10cSrcweir     pFileDlg->SetCurrentFilter( sFilterName );
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir     if ( aLastDir.Len() || rFileName.Len() )
1704cdf0e10cSrcweir     {
1705cdf0e10cSrcweir         INetURLObject aObj;
1706cdf0e10cSrcweir         if ( aLastDir.Len() )
1707cdf0e10cSrcweir         {
1708cdf0e10cSrcweir             aObj.SetURL( aLastDir );
1709cdf0e10cSrcweir             if ( rFileName.Len() )
1710cdf0e10cSrcweir                 aObj.insertName( rFileName );
1711cdf0e10cSrcweir         }
1712cdf0e10cSrcweir         else
1713cdf0e10cSrcweir             aObj.SetURL( rFileName );
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir         if ( aObj.hasExtension() )
1716cdf0e10cSrcweir         {
1717cdf0e10cSrcweir             m_sExtension4Save = aObj.getExtension(
1718cdf0e10cSrcweir                  INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
1719cdf0e10cSrcweir             aObj.removeExtension();
1720cdf0e10cSrcweir         }
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir         DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
1723cdf0e10cSrcweir         pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
1724cdf0e10cSrcweir     }
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir     pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, ExportHdl ) );
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir     return aPaths;
1729cdf0e10cSrcweir }
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir //-------------------------------------------------------------------------
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir sal_Bool SfxOrganizeDlg_Impl::DontDelete_Impl( SvLBoxEntry* pEntry )
1734cdf0e10cSrcweir {
1735cdf0e10cSrcweir     sal_uInt16 nDepth = pFocusBox->GetModel()->GetDepth(pEntry);
1736cdf0e10cSrcweir     if(SfxOrganizeListBox_Impl::VIEW_FILES ==
1737cdf0e10cSrcweir        pFocusBox->GetViewType())
1738cdf0e10cSrcweir         nDepth++;
1739cdf0e10cSrcweir     if( (nDepth > 2 && !pEntry->GetUserData()) ||
1740cdf0e10cSrcweir        //Delete ueber GetContent verboten
1741cdf0e10cSrcweir        nDepth==2 || //Vorlage / Konfigurtionsrubrik nicht loeshcen
1742cdf0e10cSrcweir        (nDepth==1 && SfxOrganizeListBox_Impl::VIEW_FILES ==
1743cdf0e10cSrcweir         pFocusBox->GetViewType()) || //Files nicht loeschen
1744cdf0e10cSrcweir        (0 == nDepth && pFocusBox->GetLevelCount_Impl(0) < 2))
1745cdf0e10cSrcweir         //Mindestens eine Vorlage behalten
1746cdf0e10cSrcweir     {
1747cdf0e10cSrcweir         return sal_True;
1748cdf0e10cSrcweir     }
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir     sal_uInt16 nRegion = 0, nIndex = 0;
1751cdf0e10cSrcweir     GetIndices_Impl( pFocusBox, pEntry, nRegion, nIndex );
1752cdf0e10cSrcweir     const SfxDocumentTemplates* pTemplates = aMgr.GetTemplates();
1753cdf0e10cSrcweir     if ( !pTemplates || !pTemplates->HasUserContents( nRegion, nIndex ) )
1754cdf0e10cSrcweir         return sal_True;
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir     return sal_False;
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir SvStringsDtor* SfxOrganizeDlg_Impl::GetAllFactoryURLs_Impl( ) const
1760cdf0e10cSrcweir {
1761cdf0e10cSrcweir     SvtModuleOptions aModOpt;
1762cdf0e10cSrcweir     const ::com::sun::star::uno::Sequence < ::rtl::OUString >& aServiceNames = aModOpt.GetAllServiceNames() ;
1763cdf0e10cSrcweir     SvStringsDtor* pList = new SvStringsDtor;
1764cdf0e10cSrcweir     sal_Int32 nCount = aServiceNames.getLength();
1765cdf0e10cSrcweir     for( sal_Int32 i=0; i<nCount; ++i )
1766cdf0e10cSrcweir     {
1767cdf0e10cSrcweir         if ( SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ).Len() > 0 )
1768cdf0e10cSrcweir         {
1769cdf0e10cSrcweir             SvtModuleOptions::EFactory eFac = SvtModuleOptions::E_WRITER;
1770cdf0e10cSrcweir             SvtModuleOptions::ClassifyFactoryByName( aServiceNames[i], eFac );
1771cdf0e10cSrcweir             String* pURL = new String( aModOpt.GetFactoryEmptyDocumentURL( eFac ) );
1772cdf0e10cSrcweir             pList->Insert( pURL, pList->Count() );
1773cdf0e10cSrcweir         }
1774cdf0e10cSrcweir     }
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir     return pList;
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir sal_Bool SfxOrganizeDlg_Impl::GetServiceName_Impl( String& rName, String& rFileURL ) const
1780cdf0e10cSrcweir {
1781cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1782cdf0e10cSrcweir     const SfxDocumentTemplates* pTemplates = aMgr.GetTemplates();
1783cdf0e10cSrcweir     SvLBoxEntry* pEntry = pFocusBox ? pFocusBox->FirstSelected() : NULL;
1784cdf0e10cSrcweir     sal_uInt16 nRegion = 0, nIndex = 0;
1785cdf0e10cSrcweir     GetIndices_Impl( pFocusBox, pEntry, nRegion, nIndex );
1786cdf0e10cSrcweir     rFileURL = pTemplates->GetPath( nRegion, nIndex );
1787cdf0e10cSrcweir     if ( rFileURL.Len() > 0 )
1788cdf0e10cSrcweir     {
1789cdf0e10cSrcweir         try
1790cdf0e10cSrcweir         {
1791cdf0e10cSrcweir             uno::Reference< embed::XStorage > xStorage = ::comphelper::OStorageHelper::GetStorageFromURL(
1792cdf0e10cSrcweir                                                     rFileURL,
1793cdf0e10cSrcweir                                                     embed::ElementModes::READ );
1794cdf0e10cSrcweir             sal_uIntPtr nFormat = SotStorage::GetFormatID( xStorage );
1795cdf0e10cSrcweir             const SfxFilter* pFilter =
1796cdf0e10cSrcweir                 SFX_APP()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat );
1797cdf0e10cSrcweir             if ( pFilter )
1798cdf0e10cSrcweir             {
1799cdf0e10cSrcweir                 rName = pFilter->GetServiceName();
1800cdf0e10cSrcweir                 bRet = sal_True;
1801cdf0e10cSrcweir             }
1802cdf0e10cSrcweir         }
1803cdf0e10cSrcweir         catch( uno::Exception& )
1804cdf0e10cSrcweir         {}
1805cdf0e10cSrcweir     }
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir     return bRet;
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir long SfxOrganizeDlg_Impl::Dispatch_Impl( sal_uInt16 nId, Menu* _pMenu )
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir /*  [Beschreibung]
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir     Verarbeiten der Events aus MenuButton oder Accelerator
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir     [Parameter]
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir     sal_uInt16 nId                      ID des Events
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir     [R"uckgabewert]                 1: Event wurde verarbeitet,
1821cdf0e10cSrcweir                                     0: Event wurde nicht verarbeitet (SV-Menu)
1822cdf0e10cSrcweir 
1823cdf0e10cSrcweir */
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir {
1826cdf0e10cSrcweir     SuspendAccel aTmp(&aEditAcc);
1827cdf0e10cSrcweir     SvLBoxEntry *pEntry = pFocusBox? pFocusBox->FirstSelected(): 0;
1828cdf0e10cSrcweir     sal_Bool bHandled = sal_True;
1829cdf0e10cSrcweir     switch(nId)
1830cdf0e10cSrcweir     {
1831cdf0e10cSrcweir         case ID_NEW:
1832cdf0e10cSrcweir         {
1833cdf0e10cSrcweir             if(!pEntry)
1834cdf0e10cSrcweir                 return 1;
1835cdf0e10cSrcweir             if(pFocusBox->GetViewType() == SfxOrganizeListBox_Impl::VIEW_TEMPLATES)
1836cdf0e10cSrcweir             {
1837cdf0e10cSrcweir                 if(0 == pFocusBox->GetModel()->GetDepth(pEntry))
1838cdf0e10cSrcweir                 {
1839cdf0e10cSrcweir                     const String aNoName( SfxResId(STR_NONAME) );
1840cdf0e10cSrcweir                     SvLBoxEntry* pParent = pFocusBox->GetParent(pEntry);
1841cdf0e10cSrcweir                     String aName(aNoName);
1842cdf0e10cSrcweir                     sal_uInt16 n = 1;
1843cdf0e10cSrcweir                     while(!pFocusBox->IsUniqName_Impl(aName, pParent))
1844cdf0e10cSrcweir                     {
1845cdf0e10cSrcweir                         aName = aNoName;
1846cdf0e10cSrcweir                         aName += String::CreateFromInt32( n++ );
1847cdf0e10cSrcweir                     }
1848cdf0e10cSrcweir                     aMgr.InsertDir( pFocusBox, aName,
1849cdf0e10cSrcweir                             (sal_uInt16)pFocusBox->GetModel()->GetRelPos(pEntry)+1);
1850cdf0e10cSrcweir                 }
1851cdf0e10cSrcweir             }
1852cdf0e10cSrcweir             break;
1853cdf0e10cSrcweir         }
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir         case ID_DELETE:
1856cdf0e10cSrcweir         {
1857cdf0e10cSrcweir             if(!pEntry || DontDelete_Impl(pEntry))
1858cdf0e10cSrcweir                 return 1;
1859cdf0e10cSrcweir             const sal_uInt16 nDepth = pFocusBox->GetModel()->GetDepth(pEntry);
1860cdf0e10cSrcweir             if(nDepth < 2)
1861cdf0e10cSrcweir             {
1862cdf0e10cSrcweir                 if(0 == nDepth && pFocusBox->GetLevelCount_Impl(0) < 2) return 1;
1863cdf0e10cSrcweir                 if(SfxOrganizeListBox_Impl::VIEW_TEMPLATES == pFocusBox->GetViewType())
1864cdf0e10cSrcweir                 {
1865cdf0e10cSrcweir                     sal_uInt16 nResId = nDepth? STR_DELETE_TEMPLATE :
1866cdf0e10cSrcweir                                             STR_DELETE_REGION;
1867cdf0e10cSrcweir                     if( !QueryDelete_Impl(
1868cdf0e10cSrcweir                         pDialog, nResId, pFocusBox->GetEntryText(pEntry)))
1869cdf0e10cSrcweir                         return 1;
1870cdf0e10cSrcweir                     if ( STR_DELETE_REGION == nResId &&
1871cdf0e10cSrcweir                          pFocusBox->GetChildCount(pEntry))
1872cdf0e10cSrcweir                     {
1873cdf0e10cSrcweir                         QueryBox aQBox(pDialog, SfxResId(MSG_REGION_NOTEMPTY));
1874cdf0e10cSrcweir                         if(RET_NO == aQBox.Execute())
1875cdf0e10cSrcweir                             return 1;
1876cdf0e10cSrcweir                     }
1877cdf0e10cSrcweir                     sal_uInt16 nRegion = 0, nIndex = 0;
1878cdf0e10cSrcweir                     GetIndices_Impl(pFocusBox, pEntry, nRegion, nIndex);
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir                     sal_uInt16 nDeleteInd = ( STR_DELETE_REGION == nResId? USHRT_MAX: nIndex );
1881cdf0e10cSrcweir                     if ( !aMgr.Delete( pFocusBox, nRegion, nDeleteInd ) )
1882cdf0e10cSrcweir                         ErrorDelete_Impl(
1883cdf0e10cSrcweir                             pDialog,
1884cdf0e10cSrcweir                             pFocusBox->GetEntryText(pEntry),
1885cdf0e10cSrcweir                             ( nDeleteInd == USHRT_MAX && pFocusBox->GetChildCount(pEntry) ) );
1886cdf0e10cSrcweir                 }
1887cdf0e10cSrcweir             }
1888cdf0e10cSrcweir             // Inhaltsformen
1889cdf0e10cSrcweir             else if(nDepth + pFocusBox->GetDocLevel() >= 2)
1890cdf0e10cSrcweir             {
1891cdf0e10cSrcweir                 if(!QueryDelete_Impl(pDialog, STR_DELETE_TEMPLATE, pFocusBox->GetEntryText(pEntry)))
1892cdf0e10cSrcweir                     return 1;
1893cdf0e10cSrcweir                 Path aPath(pFocusBox, pEntry);
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir                 // it is ok to use the SfxObjectShellRef here since the object that
1896cdf0e10cSrcweir                 // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it
1897cdf0e10cSrcweir                 SfxObjectShellRef aRef = pFocusBox->GetObjectShell(aPath);
1898cdf0e10cSrcweir                 if(aRef.Is() &&
1899cdf0e10cSrcweir                     aRef->Remove(aPath[1+pFocusBox->GetDocLevel()],
1900cdf0e10cSrcweir                                  aPath[2+pFocusBox->GetDocLevel()],
1901cdf0e10cSrcweir                                  aPath[3+pFocusBox->GetDocLevel()]))
1902cdf0e10cSrcweir                     pFocusBox->GetModel()->Remove(pEntry);
1903cdf0e10cSrcweir                 else
1904cdf0e10cSrcweir                     ErrorDelete_Impl(pDialog, pFocusBox->GetEntryText(pEntry), sal_False );
1905cdf0e10cSrcweir             }
1906cdf0e10cSrcweir             break;
1907cdf0e10cSrcweir         }
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir         case ID_EDIT:
1910cdf0e10cSrcweir         {
1911cdf0e10cSrcweir             if(!pEntry)
1912cdf0e10cSrcweir                 return 1;
1913cdf0e10cSrcweir             sal_uInt16 nRegion = 0, nIndex = 0;
1914cdf0e10cSrcweir             GetIndices_Impl( pFocusBox, pEntry, nRegion, nIndex );
1915cdf0e10cSrcweir             const SfxStringItem aName( SID_FILE_NAME, aMgr.GetTemplates()->GetPath( nRegion, nIndex ) );
1916cdf0e10cSrcweir             const SfxStringItem aLongName( SID_FILE_LONGNAME, pFocusBox->GetEntryText( pEntry ) );
1917cdf0e10cSrcweir             const SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private:user" ) );
1918cdf0e10cSrcweir             const SfxStringItem aTargetName( SID_TARGETNAME, DEFINE_CONST_UNICODE( "_default" ) );
1919cdf0e10cSrcweir             const SfxBoolItem   aTemplateIndicator( SID_TEMPLATE, sal_False );
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir             SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_OPENTEMPLATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1922cdf0e10cSrcweir                                       &aName, &aLongName, &aReferer, &aTargetName, &aTemplateIndicator, 0L );
1923cdf0e10cSrcweir             pDialog->EndDialog( RET_EDIT_STYLE );
1924cdf0e10cSrcweir             break;
1925cdf0e10cSrcweir         }
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir         case ID_COPY_FROM:
1928cdf0e10cSrcweir         {
1929cdf0e10cSrcweir             if ( !pEntry )
1930cdf0e10cSrcweir                 return 1;
1931cdf0e10cSrcweir             m_nRegion = 0;
1932cdf0e10cSrcweir             m_nIndex = 0;
1933cdf0e10cSrcweir             GetIndices_Impl( pFocusBox, pEntry, m_nRegion, m_nIndex );
1934cdf0e10cSrcweir             GetPaths_Impl( String() );
1935cdf0e10cSrcweir             break;
1936cdf0e10cSrcweir         }
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir         case ID_COPY_TO:
1939cdf0e10cSrcweir         {
1940cdf0e10cSrcweir             if ( !pEntry )
1941cdf0e10cSrcweir                 return 1;
1942cdf0e10cSrcweir             m_nRegion = 0;
1943cdf0e10cSrcweir             m_nIndex = 0;
1944cdf0e10cSrcweir             GetIndices_Impl( pFocusBox, pEntry, m_nRegion, m_nIndex );
1945cdf0e10cSrcweir             GetPath_Impl( sal_False, aMgr.GetTemplates()->GetFileName( m_nRegion, m_nIndex ) );
1946cdf0e10cSrcweir             break;
1947cdf0e10cSrcweir         }
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir         case ID_RESCAN:
1950cdf0e10cSrcweir             if ( !aMgr.Rescan() )
1951cdf0e10cSrcweir                 ErrorBox( pDialog, SfxResId( MSG_ERROR_RESCAN ) ).Execute();
1952cdf0e10cSrcweir             if ( SfxOrganizeListBox_Impl::VIEW_TEMPLATES == aLeftLb.GetViewType() )
1953cdf0e10cSrcweir                 aLeftLb.Reset();
1954cdf0e10cSrcweir             if ( SfxOrganizeListBox_Impl::VIEW_TEMPLATES == aRightLb.GetViewType() )
1955cdf0e10cSrcweir                 aRightLb.Reset();
1956cdf0e10cSrcweir             break;
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir         case ID_PRINT:
1959cdf0e10cSrcweir         {
1960cdf0e10cSrcweir             if ( !pEntry )
1961cdf0e10cSrcweir                 return 1;
1962cdf0e10cSrcweir             Path aPath( pFocusBox, pEntry );
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir             // it is ok to use the SfxObjectShellRef here since the object that
1965cdf0e10cSrcweir             // provides it ( GetObjectShell() calls CreateObjectShell() ) has a lock on it
1966cdf0e10cSrcweir             SfxObjectShellRef aRef = pFocusBox->GetObjectShell( aPath );
1967cdf0e10cSrcweir             if ( aRef.Is() )
1968cdf0e10cSrcweir             {
1969cdf0e10cSrcweir                 const sal_uInt16 nDocLevel = pFocusBox->GetDocLevel();
1970cdf0e10cSrcweir                 if ( !pPrt )
1971cdf0e10cSrcweir                     pPrt = new Printer;
1972cdf0e10cSrcweir                 SvLBoxEntry *pDocEntry = pEntry;
1973cdf0e10cSrcweir                 while ( pFocusBox->GetModel()->GetDepth( pDocEntry ) > nDocLevel )
1974cdf0e10cSrcweir                     pDocEntry = pFocusBox->GetParent( pDocEntry );
1975cdf0e10cSrcweir                 const String aName(pFocusBox->GetEntryText(pDocEntry));
1976cdf0e10cSrcweir                 if ( !aRef->Print( *pPrt, aPath[1+nDocLevel],
1977cdf0e10cSrcweir                                    aPath[2+nDocLevel], aPath[3+nDocLevel], &aName ) )
1978cdf0e10cSrcweir                     ErrorBox( pDialog, SfxResId( MSG_PRINT_ERROR ) ).Execute();
1979cdf0e10cSrcweir             }
1980cdf0e10cSrcweir             break;
1981cdf0e10cSrcweir         }
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir         case ID_PRINTER_SETUP:
1984cdf0e10cSrcweir         {
1985cdf0e10cSrcweir             PrinterSetupDialog* pDlg = new PrinterSetupDialog( pDialog );
1986cdf0e10cSrcweir             if ( !pPrt )
1987cdf0e10cSrcweir                 pPrt = new Printer;
1988cdf0e10cSrcweir             pDlg->SetPrinter( pPrt );
1989cdf0e10cSrcweir             pDlg->Execute();
1990cdf0e10cSrcweir             delete pDlg;
1991cdf0e10cSrcweir             break;
1992cdf0e10cSrcweir         }
1993cdf0e10cSrcweir 
1994cdf0e10cSrcweir         case ID_DEFAULT_TEMPLATE:
1995cdf0e10cSrcweir         {
1996cdf0e10cSrcweir             String aServiceName, aFileURL;
1997cdf0e10cSrcweir             if ( GetServiceName_Impl( aServiceName, aFileURL ) )
1998cdf0e10cSrcweir                 SfxObjectFactory::SetStandardTemplate( aServiceName, aFileURL );
1999cdf0e10cSrcweir             break;
2000cdf0e10cSrcweir         }
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir         default:
2003cdf0e10cSrcweir             bHandled = sal_False;
2004cdf0e10cSrcweir     }
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir     if ( !bHandled && ( nId > ID_RESET_DEFAULT_TEMPLATE || nId <= ID_RESET_DEFAULT_TEMPLATE_END ) )
2007cdf0e10cSrcweir     {
2008cdf0e10cSrcweir         Menu* pSubMenu = _pMenu ? _pMenu : aEditBtn.GetPopupMenu()->GetPopupMenu( ID_RESET_DEFAULT_TEMPLATE );
2009cdf0e10cSrcweir         if ( pSubMenu )
2010cdf0e10cSrcweir         {
2011cdf0e10cSrcweir             String aServiceName = SfxObjectShell::GetServiceNameFromFactory( pSubMenu->GetItemCommand( nId ) );
2012cdf0e10cSrcweir             SfxObjectFactory::SetStandardTemplate( aServiceName, String() );
2013cdf0e10cSrcweir             bHandled = sal_True;
2014cdf0e10cSrcweir         }
2015cdf0e10cSrcweir     }
2016cdf0e10cSrcweir 
2017cdf0e10cSrcweir     return bHandled ? 1 : 0;
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir //-------------------------------------------------------------------------
2021cdf0e10cSrcweir 
2022cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxOrganizeDlg_Impl, MenuSelect_Impl, Menu *, pMenu )
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir /*  [Beschreibung]
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir     SelectHandler des Men"us des Men"ubuttons (SV)
2027cdf0e10cSrcweir 
2028cdf0e10cSrcweir     [Parameter]
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir     MenuButton *pBtn                der das Event ausl"osende Button
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir     [R"uckgabewert]                 1: Event wurde verarbeitet,
2033cdf0e10cSrcweir                                     0: Event wurde nicht verarbeitet (SV-Menu)
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir */
2036cdf0e10cSrcweir {
2037cdf0e10cSrcweir     return Dispatch_Impl( pMenu->GetCurItemId(), pMenu );
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxOrganizeDlg_Impl, MenuSelect_Impl, Menu *, pMenu )
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir //-------------------------------------------------------------------------
2042cdf0e10cSrcweir 
2043cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, AccelSelect_Impl, Accelerator *, pAccel )
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir /*  [Beschreibung]
2046cdf0e10cSrcweir 
2047cdf0e10cSrcweir     SelectHandler des Accelerators (SV)
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir     [Parameter]
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir     Accelerator *pAccel             der das Event ausl"osende Accelerator
2052cdf0e10cSrcweir 
2053cdf0e10cSrcweir     [R"uckgabewert]                 1: Event wurde verarbeitet,
2054cdf0e10cSrcweir                                     0: Event wurde nicht verarbeitet (SV)
2055cdf0e10cSrcweir 
2056cdf0e10cSrcweir */
2057cdf0e10cSrcweir 
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir     SvLBoxEntry* pEntry = pFocusBox && pFocusBox->GetSelectionCount() ?
2060cdf0e10cSrcweir         pFocusBox->FirstSelected() : NULL ;
2061cdf0e10cSrcweir     return pEntry && ( pAccel->GetCurItemId() == ID_NEW  || !DontDelete_Impl( pEntry ) ) ?
2062cdf0e10cSrcweir         Dispatch_Impl( pAccel->GetCurItemId(), NULL ) : 0;
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir //-------------------------------------------------------------------------
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir void SfxOrganizeDlg_Impl::OkHdl(Button *pButton)
2068cdf0e10cSrcweir {
2069cdf0e10cSrcweir     if(pFocusBox && pFocusBox->IsEditingActive())
2070cdf0e10cSrcweir         pFocusBox->EndEditing(sal_False);
2071cdf0e10cSrcweir     pButton->Click();
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir 
2076cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, MenuActivate_Impl, Menu *, pMenu )
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir /*  [Beschreibung]
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir     ActivateHandler des Men"us des Men"ubuttons (SV)
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir     [Parameter]
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir     Menu *pMenu                     das das Event ausl"osende Men"u
2085cdf0e10cSrcweir 
2086cdf0e10cSrcweir     [R"uckgabewert]                 1: Event wurde verarbeitet,
2087cdf0e10cSrcweir                                     0: Event wurde nicht verarbeitet (SV-Menu)
2088cdf0e10cSrcweir 
2089cdf0e10cSrcweir */
2090cdf0e10cSrcweir {
2091cdf0e10cSrcweir     if ( pFocusBox && pFocusBox->IsEditingActive() )
2092cdf0e10cSrcweir         pFocusBox->EndEditing( sal_False );
2093cdf0e10cSrcweir     sal_Bool bEnable = ( pFocusBox && pFocusBox->GetSelectionCount() );
2094cdf0e10cSrcweir     SvLBoxEntry* pEntry = bEnable ? pFocusBox->FirstSelected() : NULL;
2095cdf0e10cSrcweir     const sal_uInt16 nDepth =
2096cdf0e10cSrcweir         ( bEnable && pFocusBox->GetSelectionCount() ) ? pFocusBox->GetModel()->GetDepth( pEntry ) : 0;
2097cdf0e10cSrcweir     const sal_uInt16 nDocLevel = bEnable ? pFocusBox->GetDocLevel() : 0;
2098cdf0e10cSrcweir     int eVT = pFocusBox ? pFocusBox->GetViewType() : 0;
2099cdf0e10cSrcweir         // nur Vorlagen anlegen
2100cdf0e10cSrcweir     pMenu->EnableItem( ID_NEW, bEnable && 0 == nDepth && SfxOrganizeListBox_Impl::VIEW_TEMPLATES == eVT );
2101cdf0e10cSrcweir     // Vorlagen: Loeschen Ebene 0,1,3ff
2102cdf0e10cSrcweir     //           ein Bereich mu"s mindestens erhalten bleiben
2103cdf0e10cSrcweir     // Dateien : Loeschen Ebene > 2
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir     pMenu->EnableItem( ID_DELETE, bEnable && !DontDelete_Impl( pEntry ) );
2106cdf0e10cSrcweir     pMenu->EnableItem( ID_EDIT,
2107cdf0e10cSrcweir                        bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && nDepth == nDocLevel
2108cdf0e10cSrcweir                            && !DontDelete_Impl( pEntry ) );
2109cdf0e10cSrcweir     pMenu->EnableItem( ID_COPY_FROM,
2110cdf0e10cSrcweir                        bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES &&
2111cdf0e10cSrcweir                        ( nDepth == nDocLevel || nDepth == nDocLevel - 1 ) );
2112cdf0e10cSrcweir     pMenu->EnableItem( ID_COPY_TO,
2113cdf0e10cSrcweir                        bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES &&
2114cdf0e10cSrcweir                        nDepth == nDocLevel );
2115cdf0e10cSrcweir     pMenu->EnableItem( ID_RESCAN,
2116cdf0e10cSrcweir                        SfxOrganizeListBox_Impl::VIEW_TEMPLATES == aRightLb.GetViewType() ||
2117cdf0e10cSrcweir                        SfxOrganizeListBox_Impl::VIEW_TEMPLATES == aLeftLb.GetViewType() );
2118cdf0e10cSrcweir     sal_Bool bPrint = bEnable && nDepth > pFocusBox->GetDocLevel();
2119cdf0e10cSrcweir     if ( bPrint && pPrt )
2120cdf0e10cSrcweir         bPrint = !pPrt->IsPrinting() && !pPrt->IsJobActive();
2121cdf0e10cSrcweir     if ( bPrint && bEnable )
2122cdf0e10cSrcweir     {
2123cdf0e10cSrcweir         // only styles printable
2124cdf0e10cSrcweir         Path aPath( pFocusBox, pFocusBox->FirstSelected() );
2125cdf0e10cSrcweir         sal_uInt16 nIndex = aPath[ nDocLevel + 1 ];
2126cdf0e10cSrcweir         bPrint = ( nIndex == CONTENT_STYLE );
2127cdf0e10cSrcweir                 }
2128cdf0e10cSrcweir     pMenu->EnableItem( ID_PRINT, bPrint );
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir     if ( bEnable && eVT == SfxOrganizeListBox_Impl::VIEW_TEMPLATES && nDepth == nDocLevel )
2131cdf0e10cSrcweir     {
2132cdf0e10cSrcweir         String aFactoryURL, aFileURL;
2133cdf0e10cSrcweir         bEnable = GetServiceName_Impl( aFactoryURL, aFileURL );
2134cdf0e10cSrcweir     }
2135cdf0e10cSrcweir     else if ( bEnable )
2136cdf0e10cSrcweir         bEnable = sal_False;
2137cdf0e10cSrcweir     pMenu->EnableItem( ID_DEFAULT_TEMPLATE, bEnable );
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir     bEnable = sal_True;
2140cdf0e10cSrcweir     SvStringsDtor* pList = GetAllFactoryURLs_Impl();
2141cdf0e10cSrcweir     sal_uInt16 nCount = pList->Count();
2142cdf0e10cSrcweir     if ( nCount > 0 )
2143cdf0e10cSrcweir     {
2144cdf0e10cSrcweir         PopupMenu* pSubMenu = new PopupMenu;
2145cdf0e10cSrcweir         sal_uInt16 nItemId = ID_RESET_DEFAULT_TEMPLATE + 1;
2146cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < nCount; ++i )
2147cdf0e10cSrcweir         {
2148cdf0e10cSrcweir             String aObjFacURL( *pList->GetObject(i) );
2149cdf0e10cSrcweir             String aTitle = SvFileInformationManager::GetDescription(
2150cdf0e10cSrcweir                 INetURLObject(aObjFacURL) );
2151cdf0e10cSrcweir             pSubMenu->InsertItem( nItemId, aTitle,
2152cdf0e10cSrcweir                 SvFileInformationManager::GetImage(INetURLObject(aObjFacURL)) );
2153cdf0e10cSrcweir             pSubMenu->SetItemCommand( nItemId++, aObjFacURL );
2154cdf0e10cSrcweir             DBG_ASSERT( nItemId <= ID_RESET_DEFAULT_TEMPLATE_END, "menu item id overflow" );
2155cdf0e10cSrcweir         }
2156cdf0e10cSrcweir         pMenu->SetPopupMenu( ID_RESET_DEFAULT_TEMPLATE, pSubMenu );
2157cdf0e10cSrcweir     }
2158cdf0e10cSrcweir     else
2159cdf0e10cSrcweir         bEnable = sal_False;
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir     delete pList;
2162cdf0e10cSrcweir     pMenu->EnableItem( ID_RESET_DEFAULT_TEMPLATE, bEnable );
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir     return 1;
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir //-------------------------------------------------------------------------
2168cdf0e10cSrcweir 
2169cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, GetFocus_Impl, SfxOrganizeListBox_Impl *, pBox )
2170cdf0e10cSrcweir 
2171cdf0e10cSrcweir /*  [Beschreibung]
2172cdf0e10cSrcweir 
2173cdf0e10cSrcweir     GetFocus-Handler, wird aus den Select-Handler der Listboxen
2174cdf0e10cSrcweir     gerufen.
2175cdf0e10cSrcweir     Wird verwendet, im die Listbox, die den Focus besitzt sowie
2176cdf0e10cSrcweir     deren Zustand zu ermitteln.
2177cdf0e10cSrcweir 
2178cdf0e10cSrcweir     [Parameter]
2179cdf0e10cSrcweir 
2180cdf0e10cSrcweir     SfxOrganizeListBox *pBox        die rufende Box
2181cdf0e10cSrcweir 
2182cdf0e10cSrcweir */
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir {
2185cdf0e10cSrcweir     if(pFocusBox && pFocusBox != pBox)
2186cdf0e10cSrcweir         pFocusBox->SelectAll(sal_False);
2187cdf0e10cSrcweir     pFocusBox = pBox;
2188cdf0e10cSrcweir     aFilesBtn.Enable( SfxOrganizeListBox_Impl::VIEW_FILES ==
2189cdf0e10cSrcweir                       pFocusBox->GetViewType() );
2190cdf0e10cSrcweir     return 0;
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir 
2193cdf0e10cSrcweir //-------------------------------------------------------------------------
2194cdf0e10cSrcweir 
2195cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, LeftListBoxSelect_Impl, ListBox *, pBox )
2196cdf0e10cSrcweir 
2197cdf0e10cSrcweir /*  [Beschreibung]
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir     Select-Handler, wird aus den Select-Handler der Listboxen
2200cdf0e10cSrcweir     gerufen.
2201cdf0e10cSrcweir     Wenn sich der Modus der Boxen (Dokumentsicht, Dokumentvorlagensicht)
2202cdf0e10cSrcweir     unterscheiden, werden die Models getrennt; andernfalls zusammengefa"st.
2203cdf0e10cSrcweir 
2204cdf0e10cSrcweir     [Parameter]
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir     ListBox *pBox               die rufende Box
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir */
2209cdf0e10cSrcweir {
2210cdf0e10cSrcweir     const SfxOrganizeListBox_Impl::DataEnum
2211cdf0e10cSrcweir         eViewType = pBox->GetSelectEntryPos() == 0 ?
2212cdf0e10cSrcweir         SfxOrganizeListBox_Impl::VIEW_TEMPLATES : SfxOrganizeListBox_Impl::VIEW_FILES;
2213cdf0e10cSrcweir     if(eViewType!= aLeftLb.GetViewType()) {
2214cdf0e10cSrcweir         aLeftLb.SetViewType(eViewType);
2215cdf0e10cSrcweir         if(aRightLb.GetViewType() == eViewType)
2216cdf0e10cSrcweir             aLeftLb.SetModel(aRightLb.GetModel());
2217cdf0e10cSrcweir         else {
2218cdf0e10cSrcweir             // Models trennen
2219cdf0e10cSrcweir             aLeftLb.DisconnectFromModel();
2220cdf0e10cSrcweir             aLeftLb.Reset();
2221cdf0e10cSrcweir         }
2222cdf0e10cSrcweir     }
2223cdf0e10cSrcweir     GetFocus_Impl(&aLeftLb);
2224cdf0e10cSrcweir     return 0;
2225cdf0e10cSrcweir }
2226cdf0e10cSrcweir 
2227cdf0e10cSrcweir //-------------------------------------------------------------------------
2228cdf0e10cSrcweir 
2229cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, RightListBoxSelect_Impl, ListBox *, pBox )
2230cdf0e10cSrcweir 
2231cdf0e10cSrcweir /*  [Beschreibung]
2232cdf0e10cSrcweir 
2233cdf0e10cSrcweir     Select-Handler, wird aus den Select-Handler der Listboxen
2234cdf0e10cSrcweir     gerufen.
2235cdf0e10cSrcweir     Wenn sich der Modus der Boxen (Dokumentsicht, Dokumentvorlagensicht)
2236cdf0e10cSrcweir     unterscheiden, werden die Models getrennt; andernfalls zusammengefa"st.
2237cdf0e10cSrcweir 
2238cdf0e10cSrcweir     [Parameter]
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir     ListBox *pBox               die rufende Box
2241cdf0e10cSrcweir 
2242cdf0e10cSrcweir */
2243cdf0e10cSrcweir {
2244cdf0e10cSrcweir     const SfxOrganizeListBox_Impl::DataEnum eViewType =
2245cdf0e10cSrcweir         pBox->GetSelectEntryPos() == 0 ?
2246cdf0e10cSrcweir         SfxOrganizeListBox_Impl::VIEW_TEMPLATES : SfxOrganizeListBox_Impl::VIEW_FILES;
2247cdf0e10cSrcweir     if(eViewType!= aRightLb.GetViewType())
2248cdf0e10cSrcweir     {
2249cdf0e10cSrcweir         aRightLb.SetViewType(eViewType);
2250cdf0e10cSrcweir         if(aLeftLb.GetViewType() == eViewType)
2251cdf0e10cSrcweir             aRightLb.SetModel(aLeftLb.GetModel());
2252cdf0e10cSrcweir         else
2253cdf0e10cSrcweir         {
2254cdf0e10cSrcweir             // Models trennen
2255cdf0e10cSrcweir             aRightLb.DisconnectFromModel();
2256cdf0e10cSrcweir             aRightLb.Reset();
2257cdf0e10cSrcweir         }
2258cdf0e10cSrcweir     }
2259cdf0e10cSrcweir     aRightLb.GrabFocus();
2260cdf0e10cSrcweir     GetFocus_Impl(&aRightLb);
2261cdf0e10cSrcweir     return 0;
2262cdf0e10cSrcweir }
2263cdf0e10cSrcweir 
2264cdf0e10cSrcweir //-------------------------------------------------------------------------
2265cdf0e10cSrcweir 
2266cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, OnAddressTemplateClicked, Button *, pButton )
2267cdf0e10cSrcweir {
2268cdf0e10cSrcweir     (void)pButton; //unused
2269cdf0e10cSrcweir     svt::AddressBookSourceDialog aDialog(pDialog, ::comphelper::getProcessServiceFactory());
2270cdf0e10cSrcweir     aDialog.Execute();
2271cdf0e10cSrcweir     return 0L;
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir //-------------------------------------------------------------------------
2275cdf0e10cSrcweir 
2276cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, AddFiles_Impl, Button *, pButton )
2277cdf0e10cSrcweir 
2278cdf0e10cSrcweir /*  [Beschreibung]
2279cdf0e10cSrcweir 
2280cdf0e10cSrcweir     Handler des Buttons f"ur das Hinzuf"ugen von Dateien per Dialog.
2281cdf0e10cSrcweir 
2282cdf0e10cSrcweir     [Parameter]
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir     Button *                der Button, der dieses Events ausgel"ost hat.
2285cdf0e10cSrcweir 
2286cdf0e10cSrcweir */
2287cdf0e10cSrcweir {
2288cdf0e10cSrcweir     (void)pButton; //unused
2289cdf0e10cSrcweir     if ( pFileDlg )
2290cdf0e10cSrcweir         delete pFileDlg;
2291cdf0e10cSrcweir     pFileDlg = new sfx2::FileDialogHelper( WB_OPEN, String() );
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir     // add config and basic filter
2294cdf0e10cSrcweir     static String sOpenBracket( DEFINE_CONST_UNICODE( " (" ) );
2295cdf0e10cSrcweir     static String sCloseBracket( DEFINE_CONST_UNICODE( ")" ) );
2296cdf0e10cSrcweir     static String sConfigExt( DEFINE_CONST_UNICODE( "*.cfg" ) );
2297cdf0e10cSrcweir     static String sBasicExt( DEFINE_CONST_UNICODE( "*.sbl" ) );
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir     String sFilterName( SfxResId( RID_STR_FILTCONFIG ) );
2300cdf0e10cSrcweir     sFilterName += sOpenBracket;
2301cdf0e10cSrcweir     sFilterName += sConfigExt;
2302cdf0e10cSrcweir     sFilterName += sCloseBracket;
2303cdf0e10cSrcweir     pFileDlg->AddFilter( sFilterName, sConfigExt );
2304cdf0e10cSrcweir 
2305cdf0e10cSrcweir     sFilterName = String( SfxResId( RID_STR_FILTBASIC ) );
2306cdf0e10cSrcweir     sFilterName += sOpenBracket;
2307cdf0e10cSrcweir     sFilterName += sBasicExt;
2308cdf0e10cSrcweir     sFilterName += sCloseBracket;
2309cdf0e10cSrcweir     pFileDlg->AddFilter( sFilterName, sBasicExt );
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir     // set "All" filter as current
2312cdf0e10cSrcweir     pFileDlg->SetCurrentFilter( String( SfxResId( STR_SFX_FILTERNAME_ALL ) ) );
2313cdf0e10cSrcweir 
2314cdf0e10cSrcweir     if ( aLastDir.Len() )
2315cdf0e10cSrcweir         pFileDlg->SetDisplayDirectory( aLastDir );
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir     pFileDlg->StartExecuteModal( LINK( this, SfxOrganizeDlg_Impl, AddFilesHdl ) );
2318cdf0e10cSrcweir 
2319cdf0e10cSrcweir     return 0;
2320cdf0e10cSrcweir }
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir //-------------------------------------------------------------------------
2323cdf0e10cSrcweir 
2324cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, ImportHdl, sfx2::FileDialogHelper *, EMPTYARG )
2325cdf0e10cSrcweir {
2326cdf0e10cSrcweir     DBG_ASSERT( pFileDlg, "SfxOrganizeDlg_Impl::ImportHdl(): no file dialog" );
2327cdf0e10cSrcweir 
2328cdf0e10cSrcweir     if ( ERRCODE_NONE == pFileDlg->GetError() )
2329cdf0e10cSrcweir     {
2330cdf0e10cSrcweir         String aPath = pFileDlg->GetPath();
2331cdf0e10cSrcweir         INetURLObject aObj( aPath );
2332cdf0e10cSrcweir 
2333cdf0e10cSrcweir         // we want to keep the original extension when exporting, the file open dialog
2334cdf0e10cSrcweir         // always sets the extension to *.vor
2335cdf0e10cSrcweir         if ( pFileDlg->GetDialogType() ==
2336cdf0e10cSrcweir                 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE )
2337cdf0e10cSrcweir         {
2338cdf0e10cSrcweir             if ( aObj.hasExtension() )
2339cdf0e10cSrcweir                 aObj.removeExtension();
2340cdf0e10cSrcweir 
2341cdf0e10cSrcweir             aObj.setExtension( m_sExtension4Save );
2342cdf0e10cSrcweir             aPath = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
2343cdf0e10cSrcweir         }
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir         aObj.removeSegment();
2346cdf0e10cSrcweir         aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
2347cdf0e10cSrcweir 
2348cdf0e10cSrcweir         if ( aPath.Len() && !aMgr.CopyTo( m_nRegion, m_nIndex, aPath ) )
2349cdf0e10cSrcweir         {
2350cdf0e10cSrcweir             String aText( SfxResId( STR_ERROR_COPY_TEMPLATE ) );
2351cdf0e10cSrcweir             aText.SearchAndReplaceAscii( "$1", aPath );
2352cdf0e10cSrcweir             ErrorBox( pDialog, WB_OK, aText ).Execute();
2353cdf0e10cSrcweir         }
2354cdf0e10cSrcweir     }
2355cdf0e10cSrcweir 
2356cdf0e10cSrcweir     return 0L;
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir 
2359cdf0e10cSrcweir //-------------------------------------------------------------------------
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, ExportHdl, sfx2::FileDialogHelper *, EMPTYARG )
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir     DBG_ASSERT( pFileDlg, "SfxOrganizeDlg_Impl::ImportHdl(): no file dialog" );
2364cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > aPaths;
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir     if ( ERRCODE_NONE == pFileDlg->GetError() )
2367cdf0e10cSrcweir     {
2368cdf0e10cSrcweir         aPaths = pFileDlg->GetMPath();
2369cdf0e10cSrcweir         sal_Int32 lastCount = aPaths.getLength() - 1;
2370cdf0e10cSrcweir         INetURLObject aObj( aPaths.getArray()[ lastCount ] );
2371cdf0e10cSrcweir 
2372cdf0e10cSrcweir         aObj.removeSegment();
2373cdf0e10cSrcweir         aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
2374cdf0e10cSrcweir     }
2375cdf0e10cSrcweir 
2376cdf0e10cSrcweir     sal_Int32 nCount = aPaths.getLength();
2377cdf0e10cSrcweir     if ( 1 == nCount )
2378cdf0e10cSrcweir     {
2379cdf0e10cSrcweir        String aPath = String( aPaths.getArray()[0] );
2380cdf0e10cSrcweir        if ( aPath.Len() && !aMgr.CopyFrom( pFocusBox, m_nRegion, m_nIndex, aPath ) )
2381cdf0e10cSrcweir        {
2382cdf0e10cSrcweir            String aText( SfxResId( STR_ERROR_COPY_TEMPLATE ) );
2383cdf0e10cSrcweir            aText.SearchAndReplaceAscii( "$1", aPath );
2384cdf0e10cSrcweir            ErrorBox( pDialog, WB_OK, aText ).Execute();
2385cdf0e10cSrcweir        }
2386cdf0e10cSrcweir     }
2387cdf0e10cSrcweir     else if ( nCount > 1 )
2388cdf0e10cSrcweir     {
2389cdf0e10cSrcweir         INetURLObject aPathObj( aPaths[0] );
2390cdf0e10cSrcweir         aPathObj.setFinalSlash();
2391cdf0e10cSrcweir         for ( sal_uInt16 i = 1; i < nCount; ++i )
2392cdf0e10cSrcweir         {
2393cdf0e10cSrcweir             if ( 1 == i )
2394cdf0e10cSrcweir                 aPathObj.Append( aPaths[i] );
2395cdf0e10cSrcweir             else
2396cdf0e10cSrcweir                 aPathObj.setName( aPaths[i] );
2397cdf0e10cSrcweir             String aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
2398cdf0e10cSrcweir             if ( aPath.Len() && !aMgr.CopyFrom( pFocusBox, m_nRegion, m_nIndex, aPath ) )
2399cdf0e10cSrcweir             {
2400cdf0e10cSrcweir                 String aText( SfxResId( STR_ERROR_COPY_TEMPLATE ) );
2401cdf0e10cSrcweir                 aText.SearchAndReplaceAscii( "$1", aPath );
2402cdf0e10cSrcweir                 ErrorBox( pDialog, WB_OK, aText ).Execute();
2403cdf0e10cSrcweir             }
2404cdf0e10cSrcweir         }
2405cdf0e10cSrcweir     }
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir     return 0L;
2408cdf0e10cSrcweir }
2409cdf0e10cSrcweir 
2410cdf0e10cSrcweir //-------------------------------------------------------------------------
2411cdf0e10cSrcweir 
2412cdf0e10cSrcweir IMPL_LINK( SfxOrganizeDlg_Impl, AddFilesHdl, sfx2::FileDialogHelper *, EMPTYARG )
2413cdf0e10cSrcweir {
2414cdf0e10cSrcweir     if ( ERRCODE_NONE == pFileDlg->GetError() )
2415cdf0e10cSrcweir     {
2416cdf0e10cSrcweir         String aPath = pFileDlg->GetPath();
2417cdf0e10cSrcweir         aMgr.InsertFile( pFocusBox, aPath );
2418cdf0e10cSrcweir         INetURLObject aObj( aPath );
2419cdf0e10cSrcweir         aObj.removeSegment();
2420cdf0e10cSrcweir         aObj.setFinalSlash();
2421cdf0e10cSrcweir         aLastDir = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
2422cdf0e10cSrcweir     }
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir     return 0L;
2425cdf0e10cSrcweir }
2426cdf0e10cSrcweir 
2427cdf0e10cSrcweir //-------------------------------------------------------------------------
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir short SfxTemplateOrganizeDlg::Execute()
2430cdf0e10cSrcweir 
2431cdf0e10cSrcweir /*  [Beschreibung]
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir     "Uberladene Execute- Methode; speichert gfs. "Anderungen an den
2434cdf0e10cSrcweir     Dokumentvorlagen
2435cdf0e10cSrcweir     (SV-Methode)
2436cdf0e10cSrcweir 
2437cdf0e10cSrcweir */
2438cdf0e10cSrcweir 
2439cdf0e10cSrcweir {
2440cdf0e10cSrcweir     const short nRet = ModalDialog::Execute();
2441cdf0e10cSrcweir     if(RET_CANCEL != nRet)
2442cdf0e10cSrcweir     {
2443cdf0e10cSrcweir         pImp->aMgr.SaveAll(this);
2444cdf0e10cSrcweir         SfxTemplateDialog* pTemplDlg = SFX_APP()->GetTemplateDialog();
2445cdf0e10cSrcweir         if(pTemplDlg)
2446cdf0e10cSrcweir             pTemplDlg->Update();
2447cdf0e10cSrcweir     }
2448cdf0e10cSrcweir     return nRet;
2449cdf0e10cSrcweir }
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir 
2452cdf0e10cSrcweir //-------------------------------------------------------------------------
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir SfxTemplateOrganizeDlg::SfxTemplateOrganizeDlg(Window * pParent,
2455cdf0e10cSrcweir                                                 SfxDocumentTemplates *pTempl)
2456cdf0e10cSrcweir :   ModalDialog( pParent, SfxResId(DLG_ORGANIZE)),
2457cdf0e10cSrcweir     pImp( new SfxOrganizeDlg_Impl(this, pTempl) )
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir /*  [Beschreibung]
2460cdf0e10cSrcweir 
2461cdf0e10cSrcweir     Konstruktor
2462cdf0e10cSrcweir 
2463cdf0e10cSrcweir */
2464cdf0e10cSrcweir {
2465cdf0e10cSrcweir     FreeResource();
2466cdf0e10cSrcweir }
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir //-------------------------------------------------------------------------
2469cdf0e10cSrcweir 
2470cdf0e10cSrcweir SfxTemplateOrganizeDlg::~SfxTemplateOrganizeDlg()
2471cdf0e10cSrcweir {
2472cdf0e10cSrcweir     GetpApp()->RemoveAccel(&pImp->aEditAcc);
2473cdf0e10cSrcweir     delete pImp->pPrt;
2474cdf0e10cSrcweir     delete pImp;
2475cdf0e10cSrcweir }
2476cdf0e10cSrcweir 
2477