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