Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Copyright 2012 LibreOffice contributors.
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 : :
10 : : #include "templatedlg.hxx"
11 : :
12 : : #include "inputdlg.hxx"
13 : : #include "templatesearchview.hxx"
14 : : #include "templatesearchviewitem.hxx"
15 : :
16 : : #include <comphelper/processfactory.hxx>
17 : : #include <comphelper/storagehelper.hxx>
18 : : #include <sfx2/app.hxx>
19 : : #include <sfx2/docfac.hxx>
20 : : #include <sfx2/fcontnr.hxx>
21 : : #include <sfx2/filedlghelper.hxx>
22 : : #include <sfx2/sfxresid.hxx>
23 : : #include <sfx2/templateinfodlg.hxx>
24 : : #include <sfx2/templatelocalview.hxx>
25 : : #include <sfx2/templatelocalviewitem.hxx>
26 : : #include <sfx2/templateremoteview.hxx>
27 : : #include <sfx2/templateremoteviewitem.hxx>
28 : : #include <sfx2/templateviewitem.hxx>
29 : : #include <sfx2/thumbnailviewitem.hxx>
30 : : #include <sot/storage.hxx>
31 : : #include <svtools/imagemgr.hxx>
32 : : #include <svtools/PlaceEditDialog.hxx>
33 : : #include <tools/urlobj.hxx>
34 : : #include <unotools/moduleoptions.hxx>
35 : : #include <unotools/pathoptions.hxx>
36 : : #include <vcl/edit.hxx>
37 : : #include <vcl/msgbox.hxx>
38 : : #include <vcl/toolbox.hxx>
39 : :
40 : : #include <com/sun/star/beans/PropertyValue.hpp>
41 : : #include <com/sun/star/embed/XStorage.hpp>
42 : : #include <com/sun/star/embed/ElementModes.hpp>
43 : : #include <com/sun/star/frame/XComponentLoader.hpp>
44 : : #include <com/sun/star/frame/XStorable.hpp>
45 : : #include <com/sun/star/lang/XComponent.hpp>
46 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 : : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
48 : : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
49 : : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
50 : :
51 : : #include "doc.hrc"
52 : : #include "templatedlg.hrc"
53 : :
54 : : #define INIT_FOLDER_COLS 3
55 : : #define INIT_FOLDER_LINES 2
56 : :
57 : : #define PADDING_TOOLBAR_VIEW 15
58 : : #define PADDING_DLG_BORDER 10
59 : :
60 : : using namespace ::com::sun::star;
61 : : using namespace ::com::sun::star::beans;
62 : : using namespace ::com::sun::star::embed;
63 : : using namespace ::com::sun::star::frame;
64 : : using namespace ::com::sun::star::lang;
65 : : using namespace ::com::sun::star::ui::dialogs;
66 : :
67 : : void lcl_createTemplate(uno::Reference<XComponentLoader> xDesktop, const FILTER_APPLICATION eApp);
68 : :
69 : : bool lcl_getServiceName (const OUString &rFileURL, OUString &rName );
70 : :
71 : : std::vector<OUString> lcl_getAllFactoryURLs ();
72 : :
73 : : // Sort by name in ascending order
74 : : class SortView_Name
75 : : {
76 : : public:
77 : :
78 : 0 : bool operator() (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2)
79 : : {
80 : 0 : return (pItem1->maTitle.compareTo(pItem2->maTitle) < 0);
81 : : }
82 : : };
83 : :
84 : 0 : class SearchView_Keyword
85 : : {
86 : : public:
87 : :
88 : 0 : SearchView_Keyword (const OUString &rKeyword)
89 : 0 : : maKeyword(rKeyword)
90 : 0 : {}
91 : :
92 : 0 : bool operator() (const TemplateItemProperties &rItem)
93 : : {
94 : 0 : return rItem.aName.matchIgnoreAsciiCase(maKeyword);
95 : : }
96 : :
97 : : private:
98 : :
99 : : OUString maKeyword;
100 : : };
101 : :
102 : 0 : SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
103 : : : ModelessDialog(parent, SfxResId(DLG_TEMPLATE_MANAGER)),
104 : : aButtonAll(this,SfxResId(BTN_SELECT_ALL)),
105 : : aButtonDocs(this,SfxResId(BTN_SELECT_DOCS)),
106 : : aButtonPresents(this,SfxResId(BTN_SELECT_PRESENTATIONS)),
107 : : aButtonSheets(this,SfxResId(BTN_SELECT_SHEETS)),
108 : : aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
109 : : maButtonSelMode(this,SfxResId(BTN_SELECTION_MODE)),
110 [ # # ]: 0 : mpSearchEdit(new Edit(this,WB_HIDE | WB_BORDER)),
111 [ # # ]: 0 : mpViewBar( new ToolBox(this, SfxResId(TBX_ACTION_VIEW))),
112 [ # # ]: 0 : mpActionBar( new ToolBox(this, SfxResId(TBX_ACTION_ACTION))),
113 [ # # ]: 0 : mpTemplateBar( new ToolBox(this, SfxResId(TBX_ACTION_TEMPLATES))),
114 [ # # ]: 0 : mpSearchView(new TemplateSearchView(this)),
115 [ # # ]: 0 : maView(new TemplateLocalView(this,SfxResId(TEMPLATE_VIEW))),
116 [ # # ]: 0 : mpOnlineView(new TemplateRemoteView(this, WB_VSCROLL,false)),
117 : : mbIsSaveMode(false),
118 [ # # ][ # # ]: 0 : mxDesktop(comphelper::getProcessServiceFactory()->createInstance( "com.sun.star.frame.Desktop" ),uno::UNO_QUERY )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
119 : : {
120 [ # # ][ # # ]: 0 : maButtonSelMode.SetStyle(maButtonSelMode.GetStyle() | WB_TOGGLE);
121 : :
122 : : // Create popup menus
123 [ # # ][ # # ]: 0 : mpActionMenu = new PopupMenu;
124 [ # # ][ # # ]: 0 : mpActionMenu->InsertItem(MNI_ACTION_SORT_NAME,SfxResId(STR_ACTION_SORT_NAME).toString(),SfxResId(IMG_ACTION_SORT));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
125 [ # # ][ # # ]: 0 : mpActionMenu->InsertItem(MNI_ACTION_REFRESH,SfxResId(STR_ACTION_REFRESH).toString(),SfxResId(IMG_ACTION_REFRESH));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
126 [ # # ][ # # ]: 0 : mpActionMenu->InsertItem(MNI_ACTION_DEFAULT,SfxResId(STR_ACTION_DEFAULT).toString());
[ # # ][ # # ]
[ # # ]
127 [ # # ]: 0 : mpActionMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MenuSelectHdl));
128 : :
129 [ # # ][ # # ]: 0 : mpRepositoryMenu = new PopupMenu;
130 [ # # ]: 0 : mpRepositoryMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,RepositoryMenuSelectHdl));
131 : :
132 [ # # ][ # # ]: 0 : mpTemplateDefaultMenu = new PopupMenu;
133 [ # # ]: 0 : mpTemplateDefaultMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,DefaultTemplateMenuSelectHdl));
134 [ # # ]: 0 : mpActionMenu->SetPopupMenu(MNI_ACTION_DEFAULT,mpTemplateDefaultMenu);
135 : :
136 [ # # ]: 0 : Size aWinSize = GetOutputSize();
137 : :
138 : : // Calculate thumbnail view minimum size
139 : : Size aThumbSize = maView->CalcWindowSizePixel(INIT_FOLDER_COLS,INIT_FOLDER_LINES,
140 [ # # ]: 0 : TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_MAX_HEIGHT,TEMPLATE_ITEM_SPACE);
141 : :
142 [ # # ]: 0 : if (aWinSize.getWidth() < aThumbSize.getWidth() + 2*PADDING_DLG_BORDER)
143 : 0 : aWinSize.setWidth(aThumbSize.getWidth() + 2*PADDING_DLG_BORDER);
144 : :
145 : : // Calculate toolboxs size and positions
146 [ # # ]: 0 : Size aViewSize = mpViewBar->CalcMinimumWindowSizePixel();
147 [ # # ]: 0 : Size aActionSize = mpActionBar->CalcMinimumWindowSizePixel();
148 [ # # ]: 0 : Size aTemplateSize = mpTemplateBar->CalcMinimumWindowSizePixel();
149 : :
150 : 0 : aActionSize.setWidth(3*aActionSize.getWidth());
151 [ # # ]: 0 : aViewSize.setWidth(aWinSize.getWidth()-aActionSize.getWidth()-mpViewBar->GetPosPixel().X());
152 : 0 : aTemplateSize.setWidth(aWinSize.getWidth());
153 : :
154 [ # # ]: 0 : Point aActionPos = mpActionBar->GetPosPixel();
155 : 0 : aActionPos.setX(aWinSize.getWidth() - aActionSize.getWidth());
156 : :
157 [ # # ]: 0 : mpViewBar->SetSizePixel(aViewSize);
158 [ # # ]: 0 : mpActionBar->SetPosSizePixel(aActionPos,aActionSize);
159 [ # # ]: 0 : mpTemplateBar->SetSizePixel(aTemplateSize);
160 : :
161 : : // Set toolbox styles
162 [ # # ]: 0 : mpViewBar->SetButtonType(BUTTON_SYMBOLTEXT);
163 [ # # ]: 0 : mpTemplateBar->SetButtonType(BUTTON_SYMBOLTEXT);
164 : :
165 : : // Set toolbox button bits
166 [ # # ]: 0 : mpViewBar->SetItemBits(TBI_TEMPLATE_REPOSITORY, TIB_DROPDOWNONLY);
167 [ # # ]: 0 : mpActionBar->SetItemBits(TBI_TEMPLATE_ACTION, TIB_DROPDOWNONLY);
168 [ # # ]: 0 : mpTemplateBar->SetItemBits(TBI_TEMPLATE_MOVE,TIB_DROPDOWNONLY);
169 : :
170 : : // Set toolbox handlers
171 [ # # ]: 0 : mpViewBar->SetClickHdl(LINK(this,SfxTemplateManagerDlg,TBXViewHdl));
172 [ # # ][ # # ]: 0 : mpViewBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
173 [ # # ]: 0 : mpActionBar->SetClickHdl(LINK(this,SfxTemplateManagerDlg,TBXActionHdl));
174 [ # # ][ # # ]: 0 : mpActionBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
175 [ # # ]: 0 : mpTemplateBar->SetClickHdl(LINK(this,SfxTemplateManagerDlg,TBXTemplateHdl));
176 [ # # ][ # # ]: 0 : mpTemplateBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
177 : :
178 : : // Set view position below toolbox
179 [ # # ]: 0 : Point aViewPos = maView->GetPosPixel();
180 : 0 : aViewPos.setY(aActionPos.Y() + aActionSize.getHeight() + PADDING_TOOLBAR_VIEW);
181 : 0 : aViewPos.setX((aWinSize.getWidth() - aThumbSize.getWidth())/2); // Center the view
182 [ # # ]: 0 : maView->SetPosPixel(aViewPos);
183 : :
184 [ # # ]: 0 : if (aWinSize.getHeight() < aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER)
185 : 0 : aWinSize.setHeight(aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER);
186 : :
187 : : // Set search box position and size
188 [ # # ]: 0 : Size aSearchSize = mpSearchEdit->CalcMinimumSize();
189 : 0 : aSearchSize.setWidth(aWinSize.getWidth() - 2*PADDING_DLG_BORDER);
190 : :
191 [ # # ]: 0 : mpSearchEdit->SetSizePixel(aSearchSize);
192 [ # # ]: 0 : mpSearchEdit->SetPosPixel(Point(PADDING_DLG_BORDER,aActionPos.Y()+aActionSize.getHeight()));
193 [ # # ][ # # ]: 0 : mpSearchEdit->SetUpdateDataHdl(LINK(this,SfxTemplateManagerDlg,SearchUpdateHdl));
194 [ # # ]: 0 : mpSearchEdit->EnableUpdateData();
195 : :
196 [ # # ]: 0 : maView->SetStyle(WB_VSCROLL);
197 [ # # ]: 0 : maView->SetSizePixel(aThumbSize);
198 [ # # ]: 0 : maView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
199 : :
200 : : maView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
201 : : TEMPLATE_ITEM_MAX_HEIGHT-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
202 [ # # ]: 0 : TEMPLATE_ITEM_PADDING);
203 : :
204 [ # # ]: 0 : maView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVFolderStateHdl));
205 [ # # ]: 0 : maView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
206 [ # # ][ # # ]: 0 : maView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
207 [ # # ][ # # ]: 0 : maView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl));
208 : :
209 : : // Set online view position and dimensions
210 [ # # ]: 0 : mpOnlineView->SetPosSizePixel(aViewPos,aThumbSize);
211 [ # # ]: 0 : mpOnlineView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
212 : :
213 : : mpOnlineView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
214 : : TEMPLATE_ITEM_MAX_HEIGHT-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
215 [ # # ]: 0 : TEMPLATE_ITEM_PADDING);
216 : :
217 [ # # ]: 0 : mpOnlineView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
218 [ # # ][ # # ]: 0 : mpOnlineView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
219 [ # # ][ # # ]: 0 : mpOnlineView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl));
220 [ # # ][ # # ]: 0 : mpOnlineView->setOverlayChangeNameHdl(LINK(this,SfxTemplateManagerDlg,RepositoryChangeNameHdl));
221 : :
222 [ # # ]: 0 : mpSearchView->SetSizePixel(aThumbSize);
223 [ # # ]: 0 : mpSearchView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
224 : :
225 : : mpSearchView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
226 : : TEMPLATE_ITEM_MAX_HEIGHT-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
227 [ # # ]: 0 : TEMPLATE_ITEM_PADDING);
228 : :
229 [ # # ]: 0 : mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
230 : :
231 [ # # ]: 0 : aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl));
232 [ # # ]: 0 : aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl));
233 [ # # ]: 0 : aButtonPresents.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewPresentsHdl));
234 [ # # ]: 0 : aButtonSheets.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewSheetsHdl));
235 [ # # ]: 0 : aButtonDraws.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDrawsHdl));
236 [ # # ]: 0 : maButtonSelMode.SetClickHdl(LINK(this,SfxTemplateManagerDlg,OnClickSelectionMode));
237 : :
238 : : // Set dialog to correct dimensions
239 [ # # ]: 0 : SetSizePixel(aWinSize);
240 : :
241 [ # # ]: 0 : centerTopButtons();
242 : :
243 [ # # ]: 0 : mpViewBar->Show();
244 [ # # ]: 0 : mpActionBar->Show();
245 : :
246 [ # # ]: 0 : switchMainView(true);
247 : :
248 [ # # ]: 0 : mpOnlineView->Populate();
249 : :
250 [ # # ]: 0 : createRepositoryMenu();
251 [ # # ]: 0 : createDefaultTemplateMenu();
252 : :
253 [ # # ]: 0 : maView->Populate();
254 [ # # ]: 0 : maView->Show();
255 : :
256 [ # # ]: 0 : FreeResource();
257 : 0 : }
258 : :
259 [ # # ][ # # ]: 0 : SfxTemplateManagerDlg::~SfxTemplateManagerDlg ()
[ # # ][ # # ]
[ # # ][ # # ]
260 : : {
261 [ # # ]: 0 : mpOnlineView->syncRepositories();
262 : :
263 [ # # ][ # # ]: 0 : delete mpSearchEdit;
264 [ # # ][ # # ]: 0 : delete mpViewBar;
265 [ # # ][ # # ]: 0 : delete mpActionBar;
266 [ # # ][ # # ]: 0 : delete mpTemplateBar;
267 [ # # ][ # # ]: 0 : delete mpSearchView;
268 [ # # ][ # # ]: 0 : delete maView;
269 [ # # ][ # # ]: 0 : delete mpOnlineView;
270 [ # # ][ # # ]: 0 : delete mpActionMenu;
271 [ # # ][ # # ]: 0 : delete mpRepositoryMenu;
272 [ # # ][ # # ]: 0 : delete mpTemplateDefaultMenu;
273 [ # # ]: 0 : }
274 : :
275 : 0 : void SfxTemplateManagerDlg::setSaveMode(bool bMode)
276 : : {
277 : 0 : mbIsSaveMode = bMode;
278 : :
279 [ # # ]: 0 : if (bMode)
280 : : {
281 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_SAVE);
282 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_IMPORT);
283 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_REPOSITORY);
284 : : }
285 : : else
286 : : {
287 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_SAVE);
288 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_IMPORT);
289 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_REPOSITORY);
290 : : }
291 : 0 : }
292 : :
293 : 0 : void SfxTemplateManagerDlg::setDocumentModel(const uno::Reference<frame::XModel> &rModel)
294 : : {
295 : 0 : m_xModel = rModel;
296 : 0 : }
297 : :
298 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
299 : : {
300 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_NONE);
301 : 0 : return 0;
302 : : }
303 : :
304 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDocsHdl)
305 : : {
306 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_WRITER);
307 : 0 : return 0;
308 : : }
309 : :
310 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewPresentsHdl)
311 : : {
312 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_IMPRESS);
313 : 0 : return 0;
314 : : }
315 : :
316 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewSheetsHdl)
317 : : {
318 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_CALC);
319 : 0 : return 0;
320 : : }
321 : :
322 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDrawsHdl)
323 : : {
324 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_DRAW);
325 : 0 : return 0;
326 : : }
327 : :
328 : 0 : void SfxTemplateManagerDlg::MouseButtonDown( const MouseEvent& rMEvt )
329 : : {
330 [ # # ][ # # ]: 0 : if (!maView->GetActiveClipRegion().IsInside(rMEvt.GetPosPixel()) && maView->isOverlayVisible())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
331 : : {
332 : 0 : maSelTemplates.clear();
333 : 0 : mpTemplateBar->Hide();
334 : 0 : mpViewBar->Show();
335 : :
336 : 0 : maView->showOverlay(false);
337 : : }
338 : 0 : }
339 : :
340 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg, CloseOverlayHdl)
341 : : {
342 : 0 : maSelTemplates.clear();
343 : 0 : mpTemplateBar->Hide();
344 : 0 : mpViewBar->Show();
345 : 0 : mpActionBar->Show();
346 : :
347 [ # # ]: 0 : if (mpCurView == maView)
348 : 0 : mpCurView->showOverlay(false);
349 : : else
350 : 0 : switchMainView(true);
351 : :
352 : 0 : return 0;
353 : : }
354 : :
355 : 0 : IMPL_LINK (SfxTemplateManagerDlg, OnClickSelectionMode, ImageButton*, pButton)
356 : : {
357 : 0 : maView->setSelectionMode(pButton->GetState() == STATE_CHECK);
358 : 0 : return 0;
359 : : }
360 : :
361 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,TBXViewHdl)
362 : : {
363 [ # # # # ]: 0 : switch(mpViewBar->GetCurItemId())
364 : : {
365 : : case TBI_TEMPLATE_IMPORT:
366 : 0 : OnTemplateImport();
367 : 0 : break;
368 : : case TBI_TEMPLATE_FOLDER_DEL:
369 [ # # ]: 0 : if (mpCurView == maView)
370 : 0 : OnFolderDelete();
371 : : else
372 : 0 : OnRepositoryDelete();
373 : 0 : break;
374 : : case TBI_TEMPLATE_SAVE:
375 : 0 : OnTemplateSaveAs();
376 : 0 : break;
377 : : default:
378 : 0 : break;
379 : : }
380 : :
381 : 0 : return 0;
382 : : }
383 : :
384 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,TBXActionHdl)
385 : : {
386 [ # # ]: 0 : switch(mpActionBar->GetCurItemId())
387 : : {
388 : : case TBI_TEMPLATE_SEARCH:
389 : 0 : OnTemplateSearch();
390 : 0 : break;
391 : : default:
392 : 0 : break;
393 : : }
394 : :
395 : 0 : return 0;
396 : : }
397 : :
398 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg,TBXTemplateHdl)
399 : : {
400 [ # # # # : 0 : switch(mpTemplateBar->GetCurItemId())
# # ]
401 : : {
402 : : case TBI_TEMPLATE_EDIT:
403 : 0 : OnTemplateEdit();
404 : 0 : break;
405 : : case TBI_TEMPLATE_PROPERTIES:
406 : 0 : OnTemplateProperties();
407 : 0 : break;
408 : : case TBI_TEMPLATE_DELETE:
409 : 0 : OnTemplateDelete();
410 : 0 : break;
411 : : case TBI_TEMPLATE_DEFAULT:
412 : 0 : OnTemplateAsDefault();
413 : 0 : break;
414 : : case TBI_TEMPLATE_EXPORT:
415 : 0 : OnTemplateExport();
416 : 0 : break;
417 : : default:
418 : 0 : break;
419 : : }
420 : :
421 : 0 : return 0;
422 : : }
423 : :
424 : 0 : IMPL_LINK(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox)
425 : : {
426 : 0 : const sal_uInt16 nCurItemId = pBox->GetCurItemId();
427 : :
428 [ # # # # ]: 0 : switch(nCurItemId)
429 : : {
430 : : case TBI_TEMPLATE_ACTION:
431 : 0 : pBox->SetItemDown( nCurItemId, true );
432 : :
433 : : mpActionMenu->Execute(pBox,pBox->GetItemRect(TBI_TEMPLATE_ACTION),
434 [ # # ]: 0 : POPUPMENU_EXECUTE_DOWN);
435 : :
436 : 0 : pBox->SetItemDown( nCurItemId, false );
437 : 0 : pBox->EndSelection();
438 : 0 : pBox->Invalidate();
439 : 0 : break;
440 : : case TBI_TEMPLATE_MOVE:
441 : : {
442 [ # # ]: 0 : pBox->SetItemDown( nCurItemId, true );
443 : :
444 [ # # ]: 0 : std::vector<OUString> aNames = maView->getFolderNames();
445 : :
446 [ # # ][ # # ]: 0 : PopupMenu *pMoveMenu = new PopupMenu;
447 [ # # ]: 0 : pMoveMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MoveMenuSelectHdl));
448 : :
449 [ # # ]: 0 : if (!aNames.empty())
450 : : {
451 [ # # ]: 0 : for (size_t i = 0, n = aNames.size(); i < n; ++i)
452 [ # # ][ # # ]: 0 : pMoveMenu->InsertItem(MNI_MOVE_FOLDER_BASE+i,aNames[i]);
[ # # ]
453 : : }
454 : :
455 [ # # ]: 0 : pMoveMenu->InsertSeparator();
456 : :
457 [ # # ][ # # ]: 0 : pMoveMenu->InsertItem(MNI_MOVE_NEW,SfxResId(STR_MOVE_NEW).toString());
[ # # ][ # # ]
[ # # ]
458 : :
459 : : pMoveMenu->Execute(pBox,pBox->GetItemRect(TBI_TEMPLATE_MOVE),
460 [ # # ][ # # ]: 0 : POPUPMENU_EXECUTE_DOWN);
461 : :
462 [ # # ][ # # ]: 0 : delete pMoveMenu;
463 : :
464 [ # # ]: 0 : pBox->SetItemDown( nCurItemId, false );
465 [ # # ]: 0 : pBox->EndSelection();
466 [ # # ]: 0 : pBox->Invalidate();
467 : 0 : break;
468 : : }
469 : : case TBI_TEMPLATE_REPOSITORY:
470 : 0 : pBox->SetItemDown( nCurItemId, true );
471 : :
472 : : mpRepositoryMenu->Execute(pBox,pBox->GetItemRect(TBI_TEMPLATE_REPOSITORY),
473 [ # # ]: 0 : POPUPMENU_EXECUTE_DOWN);
474 : :
475 : 0 : pBox->SetItemDown( nCurItemId, false );
476 : 0 : pBox->EndSelection();
477 : 0 : pBox->Invalidate();
478 : 0 : break;
479 : : default:
480 : 0 : break;
481 : : }
482 : :
483 : 0 : return 0;
484 : : }
485 : :
486 : 0 : IMPL_LINK(SfxTemplateManagerDlg, TVFolderStateHdl, const ThumbnailViewItem*, pItem)
487 : : {
488 [ # # ]: 0 : if (pItem->isSelected())
489 : : {
490 [ # # ][ # # ]: 0 : if (maSelFolders.empty() && !mbIsSaveMode)
[ # # ]
491 : : {
492 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_IMPORT);
493 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_DEL);
494 : : }
495 : :
496 : 0 : maSelFolders.insert(pItem);
497 : : }
498 : : else
499 : : {
500 : 0 : maSelFolders.erase(pItem);
501 : :
502 [ # # ][ # # ]: 0 : if (maSelFolders.empty() && !mbIsSaveMode)
[ # # ]
503 : : {
504 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_IMPORT);
505 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL);
506 : : }
507 : : }
508 : :
509 : 0 : return 0;
510 : : }
511 : :
512 : 0 : IMPL_LINK(SfxTemplateManagerDlg, TVTemplateStateHdl, const ThumbnailViewItem*, pItem)
513 : : {
514 [ # # ]: 0 : if (pItem->isSelected())
515 : : {
516 [ # # ]: 0 : if (!mbIsSaveMode)
517 : : {
518 [ # # ]: 0 : if (maSelTemplates.empty())
519 : : {
520 : 0 : mpViewBar->Show(false);
521 : 0 : mpActionBar->Show(false);
522 : 0 : mpTemplateBar->Show();
523 : : }
524 : : else
525 : : {
526 : 0 : mpTemplateBar->HideItem(TBI_TEMPLATE_EDIT);
527 : 0 : mpTemplateBar->HideItem(TBI_TEMPLATE_PROPERTIES);
528 : 0 : mpTemplateBar->HideItem(TBI_TEMPLATE_DEFAULT);
529 : : }
530 : : }
531 : :
532 : 0 : maSelTemplates.insert(pItem);
533 : : }
534 : : else
535 : : {
536 [ # # ][ # # ]: 0 : if (maSelTemplates.find(pItem) != maSelTemplates.end())
[ # # ]
537 : : {
538 : 0 : maSelTemplates.erase(pItem);
539 : :
540 [ # # ]: 0 : if (!mbIsSaveMode)
541 : : {
542 [ # # ]: 0 : if (maSelTemplates.empty())
543 : : {
544 : 0 : mpTemplateBar->Show(false);
545 : 0 : mpViewBar->Show();
546 : 0 : mpActionBar->Show();
547 : : }
548 [ # # ]: 0 : else if (maSelTemplates.size() == 1)
549 : : {
550 : 0 : mpTemplateBar->ShowItem(TBI_TEMPLATE_EDIT);
551 : 0 : mpTemplateBar->ShowItem(TBI_TEMPLATE_PROPERTIES);
552 : 0 : mpTemplateBar->ShowItem(TBI_TEMPLATE_DEFAULT);
553 : : }
554 : : }
555 : : }
556 : : }
557 : :
558 : 0 : return 0;
559 : : }
560 : :
561 : 0 : IMPL_LINK(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu)
562 : : {
563 : 0 : sal_uInt16 nMenuId = pMenu->GetCurItemId();
564 : :
565 [ # # # ]: 0 : switch(nMenuId)
566 : : {
567 : : case MNI_ACTION_SORT_NAME:
568 [ # # ]: 0 : if (maView->isOverlayVisible())
569 [ # # ][ # # ]: 0 : maView->sortOverlayItems(SortView_Name());
[ # # ]
570 : : else
571 [ # # ][ # # ]: 0 : maView->sortItems(SortView_Name());
[ # # ]
572 : 0 : break;
573 : : case MNI_ACTION_REFRESH:
574 : 0 : mpCurView->reload();
575 : 0 : break;
576 : : default:
577 : 0 : break;
578 : : }
579 : :
580 : 0 : return 0;
581 : : }
582 : :
583 : 0 : IMPL_LINK(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu)
584 : : {
585 : 0 : sal_uInt16 nMenuId = pMenu->GetCurItemId();
586 : :
587 [ # # ]: 0 : if (mpSearchView->IsVisible())
588 : : {
589 : : // Check if we are searching the local or remote templates
590 [ # # ]: 0 : if (mpCurView == maView)
591 : 0 : localSearchMoveTo(nMenuId);
592 : : }
593 : : else
594 : : {
595 : : // Check if we are displaying the local or remote templates
596 [ # # ]: 0 : if (mpCurView == maView)
597 : 0 : localMoveTo(nMenuId);
598 : : else
599 : 0 : remoteMoveTo(nMenuId);
600 : : }
601 : :
602 : 0 : return 0;
603 : : }
604 : :
605 : 0 : IMPL_LINK(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu)
606 : : {
607 : 0 : sal_uInt16 nMenuId = pMenu->GetCurItemId();
608 : :
609 [ # # ]: 0 : if (nMenuId == MNI_REPOSITORY_LOCAL)
610 : : {
611 : 0 : switchMainView(true);
612 : : }
613 [ # # ]: 0 : else if (nMenuId == MNI_REPOSITORY_NEW)
614 : : {
615 [ # # ]: 0 : PlaceEditDialog dlg(this);
616 : :
617 [ # # ][ # # ]: 0 : if (dlg.Execute())
618 : : {
619 [ # # ]: 0 : boost::shared_ptr<Place> pPlace = dlg.GetPlace();
620 : :
621 [ # # ][ # # ]: 0 : if (mpOnlineView->insertRepository(pPlace->GetName(),pPlace->GetUrl()))
[ # # ]
622 : : {
623 : : // update repository list menu.
624 [ # # ]: 0 : createRepositoryMenu();
625 : : }
626 : : else
627 : : {
628 [ # # ][ # # ]: 0 : OUString aMsg(SfxResId(STR_MSG_ERROR_REPOSITORY_NAME).toString());
629 : 0 : aMsg = aMsg.replaceFirst("$1",pPlace->GetName());
630 [ # # ][ # # ]: 0 : ErrorBox(this,WB_OK,aMsg).Execute();
[ # # ][ # # ]
[ # # ]
631 [ # # ]: 0 : }
632 [ # # ]: 0 : }
633 : : }
634 : : else
635 : : {
636 : 0 : sal_uInt16 nRepoId = nMenuId - MNI_REPOSITORY_BASE;
637 : :
638 [ # # ]: 0 : if (mpOnlineView->loadRepository(nRepoId,false))
639 : : {
640 : 0 : switchMainView(false);
641 : 0 : mpOnlineView->showOverlay(true);
642 : : }
643 : : }
644 : :
645 : 0 : return 0;
646 : : }
647 : :
648 : 0 : IMPL_LINK(SfxTemplateManagerDlg, DefaultTemplateMenuSelectHdl, Menu*, pMenu)
649 : : {
650 [ # # ]: 0 : sal_uInt16 nId = pMenu->GetCurItemId();
651 : :
652 [ # # ][ # # ]: 0 : OUString aServiceName = SfxObjectShell::GetServiceNameFromFactory( mpTemplateDefaultMenu->GetItemCommand(nId));
[ # # ][ # # ]
653 [ # # ][ # # ]: 0 : SfxObjectFactory::SetStandardTemplate( aServiceName, OUString() );
[ # # ][ # # ]
[ # # ]
654 : :
655 [ # # ]: 0 : createDefaultTemplateMenu();
656 : :
657 : 0 : return 0;
658 : : }
659 : :
660 : 0 : IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem)
661 : : {
662 [ # # ]: 0 : if (!mbIsSaveMode)
663 : : {
664 [ # # ]: 0 : uno::Sequence< PropertyValue > aArgs(1);
665 [ # # ]: 0 : aArgs[0].Name = "AsTemplate";
666 [ # # ][ # # ]: 0 : aArgs[0].Value <<= sal_True;
667 : :
668 : 0 : TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
669 : :
670 : : try
671 : : {
672 [ # # ][ # # ]: 0 : mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs );
[ # # ]
673 : : }
674 [ # # ]: 0 : catch( const uno::Exception& )
675 : : {
676 : : }
677 : :
678 [ # # ][ # # ]: 0 : Close();
679 : : }
680 : :
681 : 0 : return 0;
682 : : }
683 : :
684 : 0 : IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl)
685 : : {
686 : : // if the search view is hidden, hide the folder view and display search one
687 [ # # ][ # # ]: 0 : if (!mpCurView->isOverlayVisible() && !mpSearchView->IsVisible())
[ # # ][ # # ]
[ # # ]
688 : : {
689 [ # # ]: 0 : mpSearchView->Clear();
690 [ # # ]: 0 : mpSearchView->Show();
691 [ # # ]: 0 : mpCurView->Hide();
692 : : }
693 : :
694 [ # # ][ # # ]: 0 : OUString aKeyword = mpSearchEdit->GetText();
[ # # ]
695 : :
696 [ # # ]: 0 : if (!aKeyword.isEmpty())
697 : : {
698 [ # # ][ # # ]: 0 : if (mpCurView->isOverlayVisible())
699 : : {
700 [ # # ]: 0 : mpCurView->filterTemplatesByKeyword(aKeyword);
701 : : }
702 : : else
703 : : {
704 [ # # ]: 0 : mpSearchView->Clear();
705 : :
706 : : std::vector<TemplateItemProperties> aItems =
707 [ # # ][ # # ]: 0 : maView->getFilteredItems(SearchView_Keyword(aKeyword));
[ # # ]
708 : :
709 : 0 : size_t nCounter = 0;
710 [ # # ]: 0 : for (size_t i = 0; i < aItems.size(); ++i)
711 : : {
712 : 0 : TemplateItemProperties *pItem = &aItems[i];
713 : :
714 : : mpSearchView->AppendItem(++nCounter,pItem->nRegionId,
715 : : pItem->nId-1,
716 : : pItem->aName,
717 : : maView->GetItemText(pItem->nRegionId+1),
718 : : pItem->aPath,
719 [ # # ][ # # ]: 0 : pItem->aThumbnail);
720 : : }
721 : :
722 [ # # ]: 0 : mpSearchView->Invalidate();
723 : : }
724 : : }
725 : : else
726 : : {
727 [ # # ][ # # ]: 0 : if (mpCurView->isOverlayVisible())
728 : : {
729 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_NONE);
730 : : }
731 : : else
732 : : {
733 [ # # ]: 0 : mpSearchView->Hide();
734 [ # # ]: 0 : mpCurView->Show();
735 : : }
736 : : }
737 : :
738 : 0 : return 0;
739 : : }
740 : :
741 : 0 : IMPL_LINK_NOARG (SfxTemplateManagerDlg, RepositoryChangeNameHdl)
742 : : {
743 : 0 : createRepositoryMenu();
744 : 0 : return 0;
745 : : }
746 : :
747 : 0 : void SfxTemplateManagerDlg::OnTemplateImport ()
748 : : {
749 : : sal_Int16 nDialogType =
750 : 0 : com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
751 : :
752 [ # # ]: 0 : sfx2::FileDialogHelper aFileDlg(nDialogType, SFXWB_MULTISELECTION);
753 : :
754 : : // add "All" filter
755 : : aFileDlg.AddFilter( String(SfxResId( STR_SFX_FILTERNAME_ALL) ),
756 [ # # ][ # # ]: 0 : DEFINE_CONST_UNICODE(FILEDIALOG_FILTER_ALL) );
[ # # ][ # # ]
[ # # ][ # # ]
757 : :
758 : : // add template filter
759 : 0 : OUString sFilterExt;
760 [ # # ][ # # ]: 0 : OUString sFilterName( SfxResId( STR_TEMPLATE_FILTER ).toString() );
761 : :
762 : : // add filters of modules which are installed
763 [ # # ]: 0 : SvtModuleOptions aModuleOpt;
764 [ # # ][ # # ]: 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
765 : 0 : sFilterExt += "*.ott;*.stw;*.oth";
766 : :
767 [ # # ][ # # ]: 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
768 : : {
769 [ # # ]: 0 : if ( !sFilterExt.isEmpty() )
770 : 0 : sFilterExt += ";";
771 : :
772 : 0 : sFilterExt += "*.ots;*.stc";
773 : : }
774 : :
775 [ # # ][ # # ]: 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
776 : : {
777 [ # # ]: 0 : if ( !sFilterExt.isEmpty() )
778 : 0 : sFilterExt += ";";
779 : :
780 : 0 : sFilterExt += "*.otp;*.sti";
781 : : }
782 : :
783 [ # # ][ # # ]: 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
784 : : {
785 [ # # ]: 0 : if ( !sFilterExt.isEmpty() )
786 : 0 : sFilterExt += ";";
787 : :
788 : 0 : sFilterExt += "*.otg;*.std";
789 : : }
790 : :
791 [ # # ]: 0 : if ( !sFilterExt.isEmpty() )
792 : 0 : sFilterExt += ";";
793 : :
794 : 0 : sFilterExt += "*.vor";
795 : :
796 : 0 : sFilterName += " (";
797 : 0 : sFilterName += sFilterExt;
798 : 0 : sFilterName += ")";
799 : :
800 [ # # ][ # # ]: 0 : aFileDlg.AddFilter( sFilterName, sFilterExt );
[ # # ][ # # ]
[ # # ]
801 [ # # ][ # # ]: 0 : aFileDlg.SetCurrentFilter( sFilterName );
[ # # ]
802 : :
803 [ # # ]: 0 : ErrCode nCode = aFileDlg.Execute();
804 : :
805 [ # # ]: 0 : if ( nCode == ERRCODE_NONE )
806 : : {
807 [ # # ]: 0 : com::sun::star::uno::Sequence<OUString> aFiles = aFileDlg.GetSelectedFiles();
808 : :
809 [ # # ]: 0 : if (aFiles.hasElements())
810 : : {
811 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
812 [ # # ][ # # ]: 0 : for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
[ # # ]
813 : : {
814 : 0 : OUString aTemplateList;
815 [ # # ]: 0 : TemplateLocalViewItem *pFolder = (TemplateLocalViewItem*)(*pIter);
816 : :
817 [ # # ]: 0 : for (size_t i = 0, n = aFiles.getLength(); i < n; ++i)
818 : : {
819 [ # # ][ # # ]: 0 : if(!maView->copyFrom(pFolder,aFiles[i]))
[ # # ]
820 : : {
821 [ # # ]: 0 : if (aTemplateList.isEmpty())
822 [ # # ]: 0 : aTemplateList = aFiles[i];
823 : : else
824 [ # # ]: 0 : aTemplateList = aTemplateList + "\n" + aFiles[i];
825 : : }
826 : : }
827 : :
828 [ # # ]: 0 : if (!aTemplateList.isEmpty())
829 : : {
830 [ # # ][ # # ]: 0 : OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString());
831 : 0 : aMsg = aMsg.replaceFirst("$1",pFolder->maTitle);
832 [ # # ][ # # ]: 0 : ErrorBox(this,WB_OK,aMsg.replaceFirst("$2",aTemplateList));
[ # # ][ # # ]
833 : : }
834 : 0 : }
835 : :
836 [ # # ]: 0 : maView->Invalidate(INVALIDATE_NOERASE);
837 [ # # ]: 0 : }
838 [ # # ][ # # ]: 0 : }
839 : 0 : }
840 : :
841 : 0 : void SfxTemplateManagerDlg::OnTemplateExport()
842 : : {
843 [ # # ]: 0 : uno::Reference<XMultiServiceFactory> xFactory(comphelper::getProcessServiceFactory());
844 [ # # ][ # # ]: 0 : uno::Reference<XFolderPicker> xFolderPicker(xFactory->createInstance(FOLDER_PICKER_SERVICE_NAME),uno::UNO_QUERY);
[ # # ]
845 : :
846 [ # # ][ # # ]: 0 : xFolderPicker->setDisplayDirectory(SvtPathOptions().GetWorkPath());
[ # # ][ # # ]
[ # # ][ # # ]
847 : :
848 [ # # ][ # # ]: 0 : sal_Int16 nResult = xFolderPicker->execute();
849 : :
850 [ # # ]: 0 : if( nResult == ExecutableDialogResults::OK )
851 : : {
852 : 0 : OUString aTemplateList;
853 [ # # ][ # # ]: 0 : INetURLObject aPathObj(xFolderPicker->getDirectory());
[ # # ]
854 [ # # ]: 0 : aPathObj.setFinalSlash();
855 : :
856 [ # # ][ # # ]: 0 : if (mpSearchView->IsVisible())
857 : : {
858 : 0 : sal_uInt16 i = 1;
859 : :
860 : 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter = maSelTemplates.begin();
861 [ # # ][ # # ]: 0 : for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter, ++i)
[ # # ]
862 : : {
863 [ # # ]: 0 : const TemplateSearchViewItem *pItem = static_cast<const TemplateSearchViewItem*>(*pIter);
864 : :
865 [ # # ]: 0 : INetURLObject aItemPath(pItem->getPath());
866 : :
867 [ # # ]: 0 : if ( 1 == i )
868 [ # # ][ # # ]: 0 : aPathObj.Append(aItemPath.getName());
869 : : else
870 [ # # ][ # # ]: 0 : aPathObj.setName(aItemPath.getName());
871 : :
872 [ # # ]: 0 : OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
873 : :
874 [ # # ][ # # ]: 0 : if (!maView->exportTo(pItem->mnIdx+1,pItem->mnRegionId+1,aPath))
875 : : {
876 [ # # ]: 0 : if (aTemplateList.isEmpty())
877 : 0 : aTemplateList = pItem->maTitle;
878 : : else
879 : 0 : aTemplateList = aTemplateList + "\n" + pItem->maTitle;
880 : : }
881 [ # # ]: 0 : }
882 : :
883 [ # # ]: 0 : mpSearchView->deselectItems();
884 : : }
885 : : else
886 : : {
887 : : // export templates from the current open overlay
888 : :
889 : 0 : sal_uInt16 i = 1;
890 [ # # ]: 0 : sal_uInt16 nRegionItemId = maView->getOverlayRegionId() + 1;
891 : :
892 : 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter = maSelTemplates.begin();
893 [ # # ][ # # ]: 0 : for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter, ++i)
[ # # ]
894 : : {
895 [ # # ]: 0 : const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*pIter);
896 : :
897 [ # # ]: 0 : INetURLObject aItemPath(pItem->getPath());
898 : :
899 [ # # ]: 0 : if ( 1 == i )
900 [ # # ][ # # ]: 0 : aPathObj.Append(aItemPath.getName());
901 : : else
902 [ # # ][ # # ]: 0 : aPathObj.setName(aItemPath.getName());
903 : :
904 [ # # ]: 0 : OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
905 : :
906 [ # # ][ # # ]: 0 : if (!maView->exportTo(pItem->mnId,nRegionItemId,aPath))
907 : : {
908 [ # # ]: 0 : if (aTemplateList.isEmpty())
909 : 0 : aTemplateList = pItem->maTitle;
910 : : else
911 : 0 : aTemplateList = aTemplateList + "\n" + pItem->maTitle;
912 : : }
913 [ # # ]: 0 : }
914 : :
915 [ # # ]: 0 : maView->deselectOverlayItems();
916 : : }
917 : :
918 [ # # ]: 0 : if (!aTemplateList.isEmpty())
919 : : {
920 [ # # ][ # # ]: 0 : OUString aText( SfxResId(STR_MSG_ERROR_EXPORT).toString() );
921 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,aText.replaceFirst("$1",aTemplateList)).Execute();
[ # # ][ # # ]
[ # # ]
922 [ # # ]: 0 : }
923 : 0 : }
924 : 0 : }
925 : :
926 : 0 : void SfxTemplateManagerDlg::OnTemplateSearch ()
927 : : {
928 [ # # ]: 0 : Point aPos = maView->GetPosPixel();
929 [ # # ]: 0 : bool bVisible = mpSearchEdit->IsVisible();
930 [ # # ]: 0 : Size aWinSize = GetSizePixel();
931 [ # # ]: 0 : long nEditHeight = mpSearchEdit->GetSizePixel().getHeight();
932 : :
933 [ # # ]: 0 : if (bVisible)
934 : : {
935 : 0 : aWinSize.setHeight(aWinSize.getHeight() - nEditHeight );
936 : 0 : aPos.setY(aPos.getY() - nEditHeight );
937 [ # # ]: 0 : mpActionBar->SetItemState(TBI_TEMPLATE_SEARCH,STATE_NOCHECK);
938 : : }
939 : : else
940 : : {
941 : 0 : aWinSize.setHeight(aWinSize.getHeight() + nEditHeight );
942 : 0 : aPos.setY(aPos.getY() + nEditHeight );
943 [ # # ]: 0 : mpActionBar->SetItemState(TBI_TEMPLATE_SEARCH,STATE_CHECK);
944 : : }
945 : :
946 [ # # ]: 0 : SetSizePixel(aWinSize);
947 [ # # ]: 0 : maView->SetPosPixel(aPos);
948 [ # # ]: 0 : mpOnlineView->SetPosPixel(aPos);
949 [ # # ]: 0 : mpSearchView->SetPosPixel(aPos);
950 : :
951 : : // Hide search view
952 [ # # ]: 0 : if (bVisible)
953 : : {
954 [ # # ]: 0 : mpSearchView->Hide();
955 [ # # ]: 0 : mpCurView->Show();
956 : : }
957 : :
958 [ # # ]: 0 : mpSearchEdit->Show(!bVisible);
959 [ # # ][ # # ]: 0 : mpSearchEdit->SetText(OUString());
[ # # ]
960 : :
961 : : // display all templates if we hide the search bar
962 [ # # ][ # # ]: 0 : if (bVisible && mpCurView->isOverlayVisible())
[ # # ][ # # ]
963 [ # # ]: 0 : mpCurView->filterTemplatesByApp(FILTER_APP_NONE);
964 : 0 : }
965 : :
966 : 0 : void SfxTemplateManagerDlg::OnTemplateEdit ()
967 : : {
968 [ # # ]: 0 : uno::Sequence< PropertyValue > aArgs(1);
969 [ # # ]: 0 : aArgs[0].Name = "AsTemplate";
970 [ # # ][ # # ]: 0 : aArgs[0].Value <<= sal_False;
971 : :
972 : 0 : uno::Reference< XStorable > xStorable;
973 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
974 [ # # ][ # # ]: 0 : for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter)
[ # # ]
975 : : {
976 [ # # ]: 0 : const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*pIter);
977 : :
978 : : try
979 : : {
980 : : xStorable = uno::Reference< XStorable >(
981 [ # # ]: 0 : mxDesktop->loadComponentFromURL(pItem->getPath(),"_blank", 0, aArgs ),
982 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
[ # # ][ # # ]
983 : : }
984 [ # # ]: 0 : catch( const uno::Exception& )
985 : : {
986 : : }
987 : : }
988 : :
989 [ # # ][ # # ]: 0 : Close();
990 : 0 : }
991 : :
992 : 0 : void SfxTemplateManagerDlg::OnTemplateProperties ()
993 : : {
994 [ # # ]: 0 : const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*maSelTemplates.begin());
995 : :
996 [ # # ]: 0 : SfxTemplateInfoDlg aDlg;
997 [ # # ]: 0 : aDlg.loadDocument(pItem->getPath());
998 [ # # ][ # # ]: 0 : aDlg.Execute();
999 : 0 : }
1000 : :
1001 : 0 : void SfxTemplateManagerDlg::OnTemplateDelete ()
1002 : : {
1003 : 0 : OUString aTemplateList;
1004 : :
1005 [ # # ][ # # ]: 0 : if (mpSearchView->IsVisible())
1006 : : {
1007 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
1008 [ # # ][ # # ]: 0 : for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();)
1009 : : {
1010 : : const TemplateSearchViewItem *pItem =
1011 [ # # ]: 0 : static_cast<const TemplateSearchViewItem*>(*pIter);
1012 : :
1013 : 0 : sal_uInt16 nItemId = pItem->mnIdx + 1;
1014 : 0 : sal_uInt16 nItemRegionId = pItem->mnRegionId + 1;
1015 : :
1016 [ # # ][ # # ]: 0 : if (maView->removeTemplate(nItemId,nItemRegionId))
1017 [ # # ][ # # ]: 0 : maSelTemplates.erase(pIter++);
1018 : : else
1019 : : {
1020 [ # # ]: 0 : if (aTemplateList.isEmpty())
1021 : 0 : aTemplateList = pItem->maTitle;
1022 : : else
1023 : 0 : aTemplateList = aTemplateList + "\n" + pItem->maTitle;
1024 : :
1025 [ # # ]: 0 : ++pIter;
1026 : : }
1027 : : }
1028 : :
1029 : : // Update search results
1030 [ # # ]: 0 : if (maSelTemplates.empty())
1031 : : {
1032 [ # # ]: 0 : mpTemplateBar->Show(false);
1033 [ # # ]: 0 : mpViewBar->Show();
1034 [ # # ]: 0 : mpActionBar->Show();
1035 : : }
1036 : :
1037 [ # # ]: 0 : SearchUpdateHdl(mpSearchEdit);
1038 : : }
1039 : : else
1040 : : {
1041 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
1042 [ # # ][ # # ]: 0 : for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end();)
1043 : : {
1044 [ # # ][ # # ]: 0 : if (maView->removeTemplate((*pIter)->mnId,maView->getOverlayRegionId()+1))
[ # # ][ # # ]
1045 [ # # ][ # # ]: 0 : maSelTemplates.erase(pIter++);
1046 : : else
1047 : : {
1048 [ # # ]: 0 : if (aTemplateList.isEmpty())
1049 [ # # ]: 0 : aTemplateList = (*pIter)->maTitle;
1050 : : else
1051 [ # # ]: 0 : aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
1052 : :
1053 [ # # ]: 0 : ++pIter;
1054 : : }
1055 : : }
1056 : :
1057 [ # # ]: 0 : if (maSelTemplates.empty())
1058 : : {
1059 [ # # ]: 0 : mpTemplateBar->SetItemDown(TBI_TEMPLATE_DELETE,false);
1060 [ # # ]: 0 : mpTemplateBar->Show(false);
1061 [ # # ]: 0 : mpViewBar->Show();
1062 [ # # ]: 0 : mpActionBar->Show();
1063 : : }
1064 : : }
1065 : :
1066 [ # # ]: 0 : if (!aTemplateList.isEmpty())
1067 : : {
1068 [ # # ][ # # ]: 0 : OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_TEMPLATE).toString() );
1069 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,aMsg.replaceFirst("$1",aTemplateList)).Execute();
[ # # ][ # # ]
[ # # ]
1070 : 0 : }
1071 : 0 : }
1072 : :
1073 : 0 : void SfxTemplateManagerDlg::OnTemplateAsDefault ()
1074 : : {
1075 : : assert(!maSelTemplates.empty());
1076 : :
1077 [ # # ]: 0 : const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*(maSelTemplates.begin()));
1078 : :
1079 : 0 : OUString aServiceName;
1080 [ # # ][ # # ]: 0 : if (lcl_getServiceName(pItem->getPath(),aServiceName))
1081 : : {
1082 [ # # ][ # # ]: 0 : SfxObjectFactory::SetStandardTemplate(aServiceName,pItem->getPath());
[ # # ][ # # ]
[ # # ]
1083 : :
1084 [ # # ]: 0 : createDefaultTemplateMenu();
1085 : :
1086 : : // clear selection and display view/action toolbars
1087 [ # # ]: 0 : maView->deselectOverlayItem(pItem->mnId);
1088 : 0 : }
1089 : 0 : }
1090 : :
1091 : 0 : void SfxTemplateManagerDlg::OnFolderDelete()
1092 : : {
1093 [ # # ][ # # ]: 0 : QueryBox aQueryDlg(this, WB_YES_NO | WB_DEF_YES, SfxResId(STR_QMSG_SEL_FOLDER_DELETE).toString());
[ # # ][ # # ]
[ # # ]
1094 : :
1095 [ # # ][ # # ]: 0 : if ( aQueryDlg.Execute() == RET_NO )
1096 : 0 : return;
1097 : :
1098 : 0 : OUString aFolderList;
1099 : :
1100 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
1101 [ # # ][ # # ]: 0 : for (pIter = maSelFolders.begin(); pIter != maSelFolders.end();)
1102 : : {
1103 [ # # ][ # # ]: 0 : if (maView->removeRegion((*pIter)->mnId))
[ # # ]
1104 [ # # ][ # # ]: 0 : maSelFolders.erase(pIter++);
1105 : : else
1106 : : {
1107 [ # # ]: 0 : if (aFolderList.isEmpty())
1108 [ # # ]: 0 : aFolderList = (*pIter)->maTitle;
1109 : : else
1110 [ # # ]: 0 : aFolderList = aFolderList + "\n" + (*pIter)->maTitle;
1111 : :
1112 [ # # ]: 0 : ++pIter;
1113 : : }
1114 : : }
1115 : :
1116 [ # # ]: 0 : if (maSelFolders.empty())
1117 : : {
1118 [ # # ]: 0 : mpViewBar->HideItem(TBI_TEMPLATE_IMPORT);
1119 [ # # ]: 0 : mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL);
1120 : : }
1121 : :
1122 [ # # ]: 0 : if (!aFolderList.isEmpty())
1123 : : {
1124 [ # # ][ # # ]: 0 : OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER).toString() );
1125 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,aMsg.replaceFirst("$1",aFolderList)).Execute();
[ # # ][ # # ]
[ # # ]
1126 [ # # ][ # # ]: 0 : }
1127 : : }
1128 : :
1129 : 0 : void SfxTemplateManagerDlg::OnRepositoryDelete()
1130 : : {
1131 [ # # ]: 0 : if(mpOnlineView->deleteRepository(mpOnlineView->getOverlayRegionId()))
1132 : : {
1133 : : // close overlay and switch to local view
1134 : 0 : switchMainView(true);
1135 : :
1136 : 0 : createRepositoryMenu();
1137 : : }
1138 : 0 : }
1139 : :
1140 : 0 : void SfxTemplateManagerDlg::OnTemplateSaveAs()
1141 : : {
1142 : : assert(m_xModel.is());
1143 : :
1144 [ # # ][ # # ]: 0 : if (!maView->isOverlayVisible() && maSelFolders.empty())
[ # # ][ # # ]
1145 : : {
1146 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,SfxResId(STR_MSG_ERROR_SELECT_FOLDER).toString()).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1147 : : return;
1148 : : }
1149 : :
1150 [ # # ][ # # ]: 0 : InputDialog aDlg(SfxResId(STR_INPUT_TEMPLATE_NEW).toString(),this);
[ # # ]
1151 : :
1152 [ # # ][ # # ]: 0 : if (aDlg.Execute())
1153 : : {
1154 [ # # ]: 0 : OUString aName = aDlg.getEntryText();
1155 : :
1156 [ # # ]: 0 : if (!aName.isEmpty())
1157 : : {
1158 : 0 : OUString aFolderList;
1159 [ # # ][ # # ]: 0 : OUString aQMsg(SfxResId(STR_QMSG_TEMPLATE_OVERWRITE).toString());
1160 [ # # ][ # # ]: 0 : QueryBox aQueryDlg(this,WB_YES_NO | WB_DEF_YES, OUString());
[ # # ]
1161 : :
1162 [ # # ][ # # ]: 0 : if (maView->isOverlayVisible())
1163 : : {
1164 [ # # ]: 0 : sal_uInt16 nRegionItemId = maView->getOverlayRegionId()+1;
1165 : :
1166 [ # # ][ # # ]: 0 : if (!maView->isTemplateNameUnique(nRegionItemId,aName))
1167 : : {
1168 : 0 : aQMsg = aQMsg.replaceFirst("$1",aName);
1169 [ # # ][ # # ]: 0 : aQueryDlg.SetMessText(aQMsg.replaceFirst("$2",maView->getOverlayName()));
[ # # ][ # # ]
1170 : :
1171 [ # # ][ # # ]: 0 : if (aQueryDlg.Execute() == RET_NO)
1172 : : return;
1173 : : }
1174 : :
1175 [ # # ][ # # ]: 0 : if (!maView->saveTemplateAs(nRegionItemId,m_xModel,aName))
1176 [ # # ]: 0 : aFolderList = maView->getOverlayName();
1177 : : }
1178 : : else
1179 : : {
1180 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
1181 [ # # ][ # # ]: 0 : for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
[ # # ]
1182 : : {
1183 [ # # ]: 0 : TemplateLocalViewItem *pItem = (TemplateLocalViewItem*)(*pIter);
1184 : :
1185 [ # # ][ # # ]: 0 : if (!maView->isTemplateNameUnique(pItem->mnId,aName))
1186 : : {
1187 : 0 : OUString aDQMsg = aQMsg.replaceFirst("$1",aName);
1188 [ # # ][ # # ]: 0 : aQueryDlg.SetMessText(aDQMsg.replaceFirst("$2",pItem->maTitle));
[ # # ]
1189 : :
1190 [ # # ][ # # ]: 0 : if (aQueryDlg.Execute() == RET_NO)
1191 [ # # ]: 0 : continue;
1192 : : }
1193 : :
1194 [ # # ][ # # ]: 0 : if (!maView->saveTemplateAs(pItem,m_xModel,aName))
1195 : : {
1196 [ # # ]: 0 : if (aFolderList.isEmpty())
1197 [ # # ]: 0 : aFolderList = (*pIter)->maTitle;
1198 : : else
1199 [ # # ]: 0 : aFolderList = aFolderList + "\n" + (*pIter)->maTitle;
1200 : : }
1201 : : }
1202 : : }
1203 : :
1204 [ # # ]: 0 : maView->reload();
1205 : :
1206 : 0 : if (!aFolderList.isEmpty())
1207 : : {
1208 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1209 [ # # ]: 0 : }
1210 [ # # ][ # # ]: 0 : }
1211 : : }
1212 : :
1213 : 0 : void SfxTemplateManagerDlg::centerTopButtons()
1214 : : {
1215 [ # # ]: 0 : Point aFirstBtnPos = aButtonAll.GetPosPixel();
1216 : :
1217 [ # # ]: 0 : Size aSelBtnSize = maButtonSelMode.GetOutputSize(); // Last button in the list
1218 [ # # ]: 0 : Size aBtnSize = aButtonAll.GetOutputSize();
1219 [ # # ]: 0 : Size aWinSize = GetOutputSize();
1220 : :
1221 : 0 : long nTotalWidth = aSelBtnSize.getWidth() + aBtnSize.getWidth()*5;
1222 : 0 : long nSpace = (aWinSize.getWidth() - nTotalWidth)/2;
1223 : :
1224 : 0 : Point aBtnPos(nSpace,aFirstBtnPos.getY());
1225 [ # # ]: 0 : aButtonAll.SetPosPixel(aBtnPos);
1226 : :
1227 : 0 : aBtnPos.setX(aBtnPos.getX() + aBtnSize.getWidth());
1228 [ # # ]: 0 : aButtonDocs.SetPosPixel(aBtnPos);
1229 : :
1230 : 0 : aBtnPos.setX(aBtnPos.getX() + aBtnSize.getWidth());
1231 [ # # ]: 0 : aButtonPresents.SetPosPixel(aBtnPos);
1232 : :
1233 : 0 : aBtnPos.setX(aBtnPos.getX() + aBtnSize.getWidth());
1234 [ # # ]: 0 : aButtonSheets.SetPosPixel(aBtnPos);
1235 : :
1236 : 0 : aBtnPos.setX(aBtnPos.getX() + aBtnSize.getWidth());
1237 [ # # ]: 0 : aButtonDraws.SetPosPixel(aBtnPos);
1238 : :
1239 : 0 : aBtnPos.setX(aBtnPos.getX() + aBtnSize.getWidth());
1240 [ # # ]: 0 : maButtonSelMode.SetPosPixel(aBtnPos);
1241 : 0 : }
1242 : :
1243 : 0 : void SfxTemplateManagerDlg::createRepositoryMenu()
1244 : : {
1245 : 0 : mpRepositoryMenu->Clear();
1246 : :
1247 [ # # ][ # # ]: 0 : mpRepositoryMenu->InsertItem(MNI_REPOSITORY_LOCAL,SfxResId(STR_REPOSITORY_LOCAL).toString());
[ # # ][ # # ]
1248 : :
1249 : 0 : const std::vector<TemplateRemoteViewItem*> &rRepos = mpOnlineView->getRepositories();
1250 : :
1251 [ # # ]: 0 : for (size_t i = 0, n = rRepos.size(); i < n; ++i)
1252 [ # # ]: 0 : mpRepositoryMenu->InsertItem(MNI_REPOSITORY_BASE+rRepos[i]->mnId,rRepos[i]->maTitle);
1253 : :
1254 : 0 : mpRepositoryMenu->InsertSeparator();
1255 [ # # ][ # # ]: 0 : mpRepositoryMenu->InsertItem(MNI_REPOSITORY_NEW,SfxResId(STR_REPOSITORY_NEW).toString());
[ # # ][ # # ]
1256 : 0 : }
1257 : :
1258 : 0 : void SfxTemplateManagerDlg::createDefaultTemplateMenu ()
1259 : : {
1260 [ # # ]: 0 : std::vector<OUString> aList = lcl_getAllFactoryURLs();
1261 : :
1262 [ # # ]: 0 : if (!aList.empty())
1263 : : {
1264 [ # # ]: 0 : mpTemplateDefaultMenu->Clear();
1265 : :
1266 : 0 : sal_uInt16 nItemId = MNI_ACTION_DEFAULT + 1;
1267 [ # # ][ # # ]: 0 : for( std::vector<OUString>::const_iterator i = aList.begin(); i != aList.end(); ++i )
[ # # ]
1268 : : {
1269 [ # # ]: 0 : INetURLObject aObj(*i);
1270 [ # # ][ # # ]: 0 : OUString aTitle = SvFileInformationManager::GetDescription(aObj);
[ # # ]
1271 [ # # ][ # # ]: 0 : mpTemplateDefaultMenu->InsertItem(nItemId, aTitle, SvFileInformationManager::GetImage(aObj, false));
[ # # ][ # # ]
[ # # ]
1272 [ # # ][ # # ]: 0 : mpTemplateDefaultMenu->SetItemCommand(nItemId++, *i);
[ # # ]
1273 [ # # ]: 0 : }
1274 : :
1275 [ # # ]: 0 : mpActionMenu->ShowItem(MNI_ACTION_DEFAULT);
1276 : : }
1277 : : else
1278 [ # # ]: 0 : mpActionMenu->HideItem(MNI_ACTION_DEFAULT);
1279 : 0 : }
1280 : :
1281 : 0 : void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
1282 : : {
1283 [ # # ]: 0 : if (bDisplayLocal)
1284 : : {
1285 : 0 : mpCurView = maView;
1286 : :
1287 : 0 : mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL);
1288 : :
1289 : : // Enable deleting and exporting items from the filesystem
1290 : 0 : mpTemplateBar->ShowItem(TBI_TEMPLATE_EXPORT);
1291 : 0 : mpTemplateBar->ShowItem(TBI_TEMPLATE_DELETE);
1292 : :
1293 : 0 : mpOnlineView->Hide();
1294 : 0 : maView->Show();
1295 : : }
1296 : : else
1297 : : {
1298 : 0 : mpCurView = mpOnlineView;
1299 : :
1300 : 0 : mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_DEL);
1301 : :
1302 : : // Disable deleting and exporting items from remote repositories
1303 : 0 : mpTemplateBar->HideItem(TBI_TEMPLATE_EXPORT);
1304 : 0 : mpTemplateBar->HideItem(TBI_TEMPLATE_DELETE);
1305 : :
1306 : 0 : maView->Hide();
1307 : 0 : mpOnlineView->Show();
1308 : : }
1309 : 0 : }
1310 : :
1311 : 0 : void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId)
1312 : : {
1313 : 0 : sal_uInt16 nItemId = 0;
1314 : :
1315 [ # # ]: 0 : if (nMenuId == MNI_MOVE_NEW)
1316 : : {
1317 [ # # ][ # # ]: 0 : InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this);
[ # # ]
1318 : :
1319 [ # # ]: 0 : int ret = dlg.Execute();
1320 : :
1321 [ # # ]: 0 : if (ret)
1322 : : {
1323 [ # # ]: 0 : OUString aName = dlg.getEntryText();
1324 : :
1325 [ # # ]: 0 : if (!aName.isEmpty())
1326 [ # # ]: 0 : nItemId = maView->createRegion(aName);
1327 [ # # ]: 0 : }
1328 : : }
1329 : : else
1330 : : {
1331 : 0 : nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE);
1332 : : }
1333 : :
1334 [ # # ]: 0 : if (nItemId)
1335 : : {
1336 : : // Move templates to desired folder if for some reason move fails
1337 : : // try copying them.
1338 [ # # # # ]: 0 : if (!maView->moveTemplates(maSelTemplates,nItemId,false) &&
[ # # ]
1339 : 0 : !maView->moveTemplates(maSelTemplates,nItemId,true))
1340 : : {
1341 : 0 : OUString aTemplateList;
1342 : :
1343 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator pIter;
1344 [ # # ][ # # ]: 0 : for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
[ # # ]
1345 : : {
1346 [ # # ]: 0 : if (aTemplateList.isEmpty())
1347 [ # # ]: 0 : aTemplateList = (*pIter)->maTitle;
1348 : : else
1349 [ # # ]: 0 : aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
1350 : : }
1351 : :
1352 [ # # ]: 0 : OUString aDst = maView->GetItemText(nItemId);
1353 [ # # ][ # # ]: 0 : OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
1354 : 0 : aMsg = aMsg.replaceFirst("$1",aDst);
1355 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,aMsg.replaceFirst( "$2",aTemplateList)).Execute();
[ # # ][ # # ]
[ # # ]
1356 : : }
1357 : : }
1358 : 0 : }
1359 : :
1360 : 0 : void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId)
1361 : : {
1362 : 0 : sal_uInt16 nItemId = 0;
1363 : :
1364 [ # # ]: 0 : if (nMenuId == MNI_MOVE_NEW)
1365 : : {
1366 [ # # ][ # # ]: 0 : InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this);
[ # # ]
1367 : :
1368 [ # # ]: 0 : int ret = dlg.Execute();
1369 : :
1370 [ # # ]: 0 : if (ret)
1371 : : {
1372 [ # # ]: 0 : OUString aName = dlg.getEntryText();
1373 : :
1374 [ # # ]: 0 : if (!aName.isEmpty())
1375 [ # # ]: 0 : nItemId = maView->createRegion(aName);
1376 [ # # ]: 0 : }
1377 : : }
1378 : : else
1379 : : {
1380 : 0 : nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE);
1381 : : }
1382 : :
1383 [ # # ]: 0 : if (nItemId)
1384 : : {
1385 : 0 : OUString aTemplateList;
1386 : :
1387 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator aIter;
1388 [ # # ][ # # ]: 0 : for (aIter = maSelTemplates.begin(); aIter != maSelTemplates.end(); ++aIter)
[ # # ]
1389 : : {
1390 : : const TemplateSearchViewItem *pItem =
1391 [ # # ]: 0 : static_cast<const TemplateSearchViewItem*>(*aIter);
1392 : :
1393 [ # # ][ # # ]: 0 : if(!maView->copyFrom(nItemId,pItem->maPreview1,pItem->getPath()))
1394 : : {
1395 [ # # ]: 0 : if (aTemplateList.isEmpty())
1396 : 0 : aTemplateList = pItem->maTitle;
1397 : : else
1398 : 0 : aTemplateList = aTemplateList + "\n" + pItem->maTitle;
1399 : : }
1400 : : }
1401 : :
1402 [ # # ]: 0 : maView->Invalidate(INVALIDATE_NOERASE);
1403 : :
1404 [ # # ]: 0 : if (!aTemplateList.isEmpty())
1405 : : {
1406 [ # # ][ # # ]: 0 : OUString aMsg(SfxResId(STR_MSG_ERROR_REMOTE_MOVE).toString());
1407 [ # # ]: 0 : aMsg = aMsg.replaceFirst("$1",mpOnlineView->getOverlayName());
1408 [ # # ]: 0 : aMsg = aMsg.replaceFirst("$2",maView->GetItemText(nItemId));
1409 [ # # ][ # # ]: 0 : ErrorBox(this,WB_OK,aMsg.replaceFirst("$1",aTemplateList)).Execute();
[ # # ][ # # ]
[ # # ]
1410 : 0 : }
1411 : : }
1412 : 0 : }
1413 : :
1414 : 0 : void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId)
1415 : : {
1416 : 0 : sal_uInt16 nItemId = 0;
1417 : :
1418 [ # # ]: 0 : if (nMenuId == MNI_MOVE_NEW)
1419 : : {
1420 [ # # ][ # # ]: 0 : InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this);
[ # # ]
1421 : :
1422 [ # # ]: 0 : int ret = dlg.Execute();
1423 : :
1424 [ # # ]: 0 : if (ret)
1425 : : {
1426 [ # # ]: 0 : OUString aName = dlg.getEntryText();
1427 : :
1428 [ # # ]: 0 : if (!aName.isEmpty())
1429 [ # # ]: 0 : nItemId = maView->createRegion(aName);
1430 [ # # ]: 0 : }
1431 : : }
1432 : : else
1433 : : {
1434 : 0 : nItemId = maView->GetItemId(nMenuId-MNI_MOVE_FOLDER_BASE);
1435 : : }
1436 : :
1437 [ # # ]: 0 : if (nItemId)
1438 : : {
1439 : 0 : OUString aTemplateList;
1440 : :
1441 : : // Move templates to desired folder if for some reason move fails
1442 : : // try copying them.
1443 [ # # ]: 0 : std::set<const ThumbnailViewItem*>::const_iterator aIter;
1444 [ # # ][ # # ]: 0 : for (aIter = maSelTemplates.begin(); aIter != maSelTemplates.end(); ++aIter)
[ # # ]
1445 : : {
1446 : : const TemplateSearchViewItem *pItem =
1447 [ # # ]: 0 : static_cast<const TemplateSearchViewItem*>(*aIter);
1448 : :
1449 [ # # ][ # # ]: 0 : if(!maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,false)
[ # # ][ # # ]
1450 [ # # ]: 0 : && !maView->moveTemplate(pItem,pItem->mnRegionId+1,nItemId,true))
1451 : : {
1452 [ # # ]: 0 : if (aTemplateList.isEmpty())
1453 [ # # ]: 0 : aTemplateList = (*aIter)->maTitle;
1454 : : else
1455 [ # # ]: 0 : aTemplateList = aTemplateList + "\n" + (*aIter)->maTitle;
1456 : : }
1457 : : }
1458 : :
1459 [ # # ]: 0 : if (!aTemplateList.isEmpty())
1460 : : {
1461 [ # # ]: 0 : OUString aDst = maView->GetItemText(nItemId);
1462 [ # # ][ # # ]: 0 : OUString aMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE).toString());
1463 : 0 : aMsg = aMsg.replaceFirst("$1",aDst);
1464 [ # # ][ # # ]: 0 : ErrorBox(this, WB_OK,aMsg.replaceFirst( "$2",aTemplateList)).Execute();
[ # # ][ # # ]
[ # # ]
1465 : 0 : }
1466 : : }
1467 : :
1468 : : // Deselect all items and update search results
1469 : 0 : mpSearchView->deselectItems();
1470 : :
1471 : 0 : SearchUpdateHdl(mpSearchEdit);
1472 : 0 : }
1473 : :
1474 : 0 : bool lcl_getServiceName ( const OUString &rFileURL, OUString &rName )
1475 : : {
1476 : 0 : bool bRet = false;
1477 : :
1478 [ # # ]: 0 : if ( !rFileURL.isEmpty() )
1479 : : {
1480 : : try
1481 : : {
1482 : : uno::Reference< embed::XStorage > xStorage =
1483 [ # # ]: 0 : comphelper::OStorageHelper::GetStorageFromURL( rFileURL, embed::ElementModes::READ );
1484 : :
1485 [ # # ]: 0 : sal_uIntPtr nFormat = SotStorage::GetFormatID( xStorage );
1486 : :
1487 [ # # ][ # # ]: 0 : const SfxFilter* pFilter = SFX_APP()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat );
[ # # ]
1488 : :
1489 [ # # ]: 0 : if ( pFilter )
1490 : : {
1491 : 0 : rName = pFilter->GetServiceName();
1492 : 0 : bRet = true;
1493 [ # # ]: 0 : }
1494 : : }
1495 : 0 : catch( uno::Exception& )
1496 : : {}
1497 : : }
1498 : :
1499 : 0 : return bRet;
1500 : : }
1501 : :
1502 : 0 : std::vector<OUString> lcl_getAllFactoryURLs ()
1503 : : {
1504 [ # # ]: 0 : SvtModuleOptions aModOpt;
1505 [ # # ]: 0 : std::vector<OUString> aList;
1506 [ # # ]: 0 : const ::com::sun::star::uno::Sequence<OUString> &aServiceNames = aModOpt.GetAllServiceNames();
1507 : :
1508 [ # # ]: 0 : for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i )
1509 : : {
1510 [ # # ][ # # ]: 0 : if ( SfxObjectFactory::GetStandardTemplate( aServiceNames[i] ).Len() > 0 )
[ # # ][ # # ]
[ # # ]
1511 : : {
1512 : 0 : SvtModuleOptions::EFactory eFac = SvtModuleOptions::E_WRITER;
1513 [ # # ]: 0 : SvtModuleOptions::ClassifyFactoryByName( aServiceNames[i], eFac );
1514 [ # # ][ # # ]: 0 : aList.push_back(aModOpt.GetFactoryEmptyDocumentURL(eFac));
1515 : : }
1516 : : }
1517 : :
1518 [ # # ][ # # ]: 0 : return aList;
1519 : : }
1520 : :
1521 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|