LibreOffice Module cui (master) 1
optsave.cxx
Go to the documentation of this file.
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 <sal/config.h>
21
22#include <string_view>
23
24#include <o3tl/string_view.hxx>
25#include <svl/eitem.hxx>
26#include <svl/intitem.hxx>
27#include <dialmgr.hxx>
28#include "optsave.hxx"
29#include <strings.hrc>
30#include <treeopt.hxx>
31#include <officecfg/Office/Common.hxx>
34#include <unotools/saveopt.hxx>
36#include <com/sun/star/lang/XMultiServiceFactory.hpp>
37#include <com/sun/star/container/XNameContainer.hpp>
38#include <com/sun/star/container/XContainerQuery.hpp>
39#include <com/sun/star/container/XEnumeration.hpp>
40#include <com/sun/star/beans/PropertyValue.hpp>
41#include <sfx2/sfxsids.hrc>
42#include <sfx2/docfilt.hxx>
44#include <osl/diagnose.h>
46#include <officecfg/Office/Recovery.hxx>
48
49#include <sfx2/fcontnr.hxx>
50
51using namespace com::sun::star::uno;
52using namespace com::sun::star::util;
53using namespace com::sun::star::lang;
54using namespace com::sun::star::beans;
55using namespace com::sun::star::container;
56using namespace comphelper;
57
58#define CFG_PAGE_AND_GROUP u"General", u"LoadSave"
59
60
62{
64 std::vector< OUString > aFilterArr[APP_COUNT];
65 std::vector< bool > aODFArr[APP_COUNT];
66 std::vector< OUString > aUIFilterArr[APP_COUNT];
70
72};
73
75{
76}
77
78// class SvxSaveTabPage --------------------------------------------------
79
81 : SfxTabPage( pPage, pController, "cui/ui/optsavepage.ui", "OptSavePage", &rCoreSet )
82 , pImpl(new SvxSaveTabPage_Impl)
83 , m_xLoadViewPosAnyUserCB(m_xBuilder->weld_check_button("load_anyuser"))
84 , m_xLoadUserSettingsCB(m_xBuilder->weld_check_button("load_settings"))
85 , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button("load_docprinter"))
86 , m_xDocInfoCB(m_xBuilder->weld_check_button("docinfo"))
87 , m_xBackupCB(m_xBuilder->weld_check_button("backup"))
88 , m_xBackupIntoDocumentFolderCB(m_xBuilder->weld_check_button("backupintodocumentfolder"))
89 , m_xAutoSaveCB(m_xBuilder->weld_check_button("autosave"))
90 , m_xAutoSaveEdit(m_xBuilder->weld_spin_button("autosave_spin"))
91 , m_xMinuteFT(m_xBuilder->weld_label("autosave_mins"))
92 , m_xUserAutoSaveCB(m_xBuilder->weld_check_button("userautosave"))
93 , m_xRelativeFsysCB(m_xBuilder->weld_check_button("relative_fsys"))
94 , m_xRelativeInetCB(m_xBuilder->weld_check_button("relative_inet"))
95 , m_xODFVersionLB(m_xBuilder->weld_combo_box("odfversion"))
96 , m_xWarnAlienFormatCB(m_xBuilder->weld_check_button("warnalienformat"))
97 , m_xDocTypeLB(m_xBuilder->weld_combo_box("doctype"))
98 , m_xSaveAsFT(m_xBuilder->weld_label("saveas_label"))
99 , m_xSaveAsLB(m_xBuilder->weld_combo_box("saveas"))
100 , m_xODFWarningFI(m_xBuilder->weld_widget("odfwarning_image"))
101 , m_xODFWarningFT(m_xBuilder->weld_label("odfwarning_label"))
102{
103 m_xAutoSaveEdit->set_max_length(2);
104 m_xBackupIntoDocumentFolderCB->set_accessible_description(CuiResId(RID_CUISTR_A11Y_DESC_BACKUP));
105
106 m_xODFVersionLB->set_id(0, OUString::number(SvtSaveOptions::ODFVER_011)); // 1.0/1.1
107 m_xODFVersionLB->set_id(1, OUString::number(SvtSaveOptions::ODFVER_012)); // 1.2
108 m_xODFVersionLB->set_id(2, OUString::number(SvtSaveOptions::ODFVER_012_EXT_COMPAT)); // 1.2 Extended (compatibility mode)
109 m_xODFVersionLB->set_id(3, OUString::number(SvtSaveOptions::ODFVER_012_EXTENDED)); // 1.2 Extended
110 m_xODFVersionLB->set_id(4, OUString::number(SvtSaveOptions::ODFVER_013)); // 1.3
111 m_xODFVersionLB->set_id(5, OUString::number(SvtSaveOptions::ODFVER_LATEST)); // 1.3 Extended (recommended)
112
115 "org.openoffice.Office.UI/FilterClassification/GlobalFilters/Classes",
116 -1,
118 );
119
120 m_xDocTypeLB->append(OUString::number(APP_WRITER), aFilterClassesNode.getNodeValue("com.sun.star.text.TextDocument/DisplayName").get<OUString>());
121 m_xDocTypeLB->append(OUString::number(APP_WRITER_WEB), aFilterClassesNode.getNodeValue("com.sun.star.text.WebDocument/DisplayName").get<OUString>());
122 m_xDocTypeLB->append(OUString::number(APP_WRITER_GLOBAL), aFilterClassesNode.getNodeValue("com.sun.star.text.GlobalDocument/DisplayName").get<OUString>());
123 m_xDocTypeLB->append(OUString::number(APP_CALC), aFilterClassesNode.getNodeValue("com.sun.star.sheet.SpreadsheetDocument/DisplayName").get<OUString>());
124 m_xDocTypeLB->append(OUString::number(APP_IMPRESS), aFilterClassesNode.getNodeValue("com.sun.star.presentation.PresentationDocument/DisplayName").get<OUString>());
125 m_xDocTypeLB->append(OUString::number(APP_DRAW), aFilterClassesNode.getNodeValue("com.sun.star.drawing.DrawingDocument/DisplayName").get<OUString>());
126 m_xDocTypeLB->append(OUString::number(APP_MATH), aFilterClassesNode.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>());
127
128 m_xAutoSaveCB->connect_toggled( LINK( this, SvxSaveTabPage, AutoClickHdl_Impl ) );
129 m_xBackupCB->connect_toggled(LINK(this, SvxSaveTabPage, BackupClickHdl_Impl));
130
131 SvtModuleOptions aModuleOpt;
133 {
134 m_xSaveAsLB->remove_id(OUString::number(APP_MATH));
135 m_xDocTypeLB->remove_id(OUString::number(APP_MATH));
136 }
137 else
138 {
141 }
142
144 {
145 m_xSaveAsLB->remove_id(OUString::number(APP_DRAW));
146 m_xDocTypeLB->remove_id(OUString::number(APP_DRAW));
147 }
148 else
149 {
152 }
153
155 {
156 m_xSaveAsLB->remove_id(OUString::number(APP_IMPRESS));
157 m_xDocTypeLB->remove_id(OUString::number(APP_IMPRESS));
158 }
159 else
160 {
163 }
164
166 {
167 m_xSaveAsLB->remove_id(OUString::number(APP_CALC));
168 m_xDocTypeLB->remove_id(OUString::number(APP_CALC));
169 }
170 else
171 {
174 }
175
177 {
178 m_xSaveAsLB->remove_id(OUString::number(APP_WRITER));
179 m_xSaveAsLB->remove_id(OUString::number(APP_WRITER_WEB));
180 m_xSaveAsLB->remove_id(OUString::number(APP_WRITER_GLOBAL));
181 m_xDocTypeLB->remove_id(OUString::number(APP_WRITER));
182 m_xDocTypeLB->remove_id(OUString::number(APP_WRITER_WEB));
183 m_xDocTypeLB->remove_id(OUString::number(APP_WRITER_GLOBAL));
184 }
185 else
186 {
193 }
194
195 Link<weld::ComboBox&,void> aLink = LINK( this, SvxSaveTabPage, ODFVersionHdl_Impl );
196 m_xODFVersionLB->connect_changed( aLink );
197 aLink = LINK( this, SvxSaveTabPage, FilterHdl_Impl );
198 m_xDocTypeLB->connect_changed( aLink );
199 m_xSaveAsLB->connect_changed( aLink );
200
202}
203
205{
206}
207
208std::unique_ptr<SfxTabPage> SvxSaveTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
209 const SfxItemSet* rAttrSet)
210{
211 return std::make_unique<SvxSaveTabPage>(pPage, pController, *rAttrSet);
212}
213
215{
216 SvtOptionsDialogOptions aOptionsDlgOpt;
217
218 if ( aOptionsDlgOpt.IsOptionHidden( u"Backup", CFG_PAGE_AND_GROUP ) )
219 {
220 // hide controls of "Backup"
221 m_xBackupCB->hide();
223 }
224
225 if ( aOptionsDlgOpt.IsOptionHidden( u"AutoSave", CFG_PAGE_AND_GROUP ) )
226 {
227 // hide controls of "AutoSave"
228 m_xAutoSaveCB->hide();
229 m_xAutoSaveEdit->hide();
230 m_xMinuteFT->hide();
231 }
232
233 if ( aOptionsDlgOpt.IsOptionHidden( u"UserAutoSave", CFG_PAGE_AND_GROUP ) )
234 {
235 // hide controls of "UserAutoSave"
236 m_xUserAutoSaveCB->hide();
237 }
238
239}
240
242{
244 bool bModified = false;
245 if (m_xLoadViewPosAnyUserCB->get_state_changed_from_saved())
246 {
247 officecfg::Office::Common::Load::ViewPositionForAnyUser::set(m_xLoadViewPosAnyUserCB->get_active(), xChanges);
248 }
249 if(m_xLoadUserSettingsCB->get_state_changed_from_saved())
250 officecfg::Office::Common::Load::UserDefinedSettings::set(m_xLoadUserSettingsCB->get_active(), xChanges);
251
252 if ( m_xLoadDocPrinterCB->get_state_changed_from_saved() )
253 officecfg::Office::Common::Save::Document::LoadPrinter::set(m_xLoadDocPrinterCB->get_active(), xChanges);
254
255 if ( m_xODFVersionLB->get_value_changed_from_saved() )
256 {
257 sal_Int32 nVersion = m_xODFVersionLB->get_active_id().toInt32();
259 }
260
261 if ( m_xDocInfoCB->get_state_changed_from_saved() )
262 {
263 rSet->Put( SfxBoolItem( SID_ATTR_DOCINFO,
264 m_xDocInfoCB->get_active() ) );
265 bModified = true;
266 }
267
268 if ( m_xBackupCB->get_sensitive() && m_xBackupCB->get_state_changed_from_saved() )
269 {
270 rSet->Put( SfxBoolItem( SID_ATTR_BACKUP, m_xBackupCB->get_active() ) );
271 bModified = true;
272 }
273
274 if (m_xBackupIntoDocumentFolderCB->get_sensitive()
275 && m_xBackupIntoDocumentFolderCB->get_state_changed_from_saved())
276 {
277 rSet->Put(
278 SfxBoolItem(SID_ATTR_BACKUP_BESIDE_ORIGINAL, m_xBackupIntoDocumentFolderCB->get_active()));
279 bModified = true;
280 }
281
282 if ( m_xAutoSaveCB->get_state_changed_from_saved() )
283 {
284 rSet->Put( SfxBoolItem( SID_ATTR_AUTOSAVE,
285 m_xAutoSaveCB->get_active() ) );
286 bModified = true;
287 }
288 if ( m_xWarnAlienFormatCB->get_state_changed_from_saved() )
289 {
290 rSet->Put( SfxBoolItem( SID_ATTR_WARNALIENFORMAT,
291 m_xWarnAlienFormatCB->get_active() ) );
292 bModified = true;
293 }
294
295 if ( m_xAutoSaveEdit->get_value_changed_from_saved() )
296 {
297 rSet->Put( SfxUInt16Item( SID_ATTR_AUTOSAVEMINUTE,
298 static_cast<sal_uInt16>(m_xAutoSaveEdit->get_value()) ) );
299 bModified = true;
300 }
301
302 if ( m_xUserAutoSaveCB->get_state_changed_from_saved() )
303 {
304 rSet->Put( SfxBoolItem( SID_ATTR_USERAUTOSAVE,
305 m_xUserAutoSaveCB->get_active() ) );
306 bModified = true;
307 }
308 // save relatively
309 if ( m_xRelativeFsysCB->get_state_changed_from_saved() )
310 {
311 rSet->Put( SfxBoolItem( SID_SAVEREL_FSYS,
312 m_xRelativeFsysCB->get_active() ) );
313 bModified = true;
314 }
315
316 if ( m_xRelativeInetCB->get_state_changed_from_saved() )
317 {
318 rSet->Put( SfxBoolItem( SID_SAVEREL_INET,
319 m_xRelativeInetCB->get_active() ) );
320 bModified = true;
321 }
322
323 SvtModuleOptions aModuleOpt;
324 if(!pImpl->aDefaultArr[APP_MATH].isEmpty() &&
327
328 if( !pImpl->aDefaultArr[APP_DRAW].isEmpty() &&
331
332 if(!pImpl->aDefaultArr[APP_IMPRESS].isEmpty() &&
335
336 if(!pImpl->aDefaultArr[APP_CALC].isEmpty() &&
339
340 if(!pImpl->aDefaultArr[APP_WRITER].isEmpty() &&
343
344 if(!pImpl->aDefaultArr[APP_WRITER_WEB].isEmpty() &&
347
348 if(!pImpl->aDefaultArr[APP_WRITER_GLOBAL].isEmpty() &&
351
352 xChanges->commit();
353 return bModified;
354}
355
356static bool isODFFormat( std::u16string_view sFilter )
357{
358 static const char* aODFFormats[] =
359 {
360 "writer8",
361 "writer8_template",
362 "writerglobal8",
363 "writerglobal8_writer",
364 "calc8",
365 "calc8_template",
366 "draw8",
367 "draw8_template",
368 "impress8",
369 "impress8_template",
370 "impress8_draw",
371 "chart8",
372 "math8",
373 nullptr
374 };
375
376 bool bRet = false;
377 int i = 0;
378 while ( aODFFormats[i] != nullptr )
379 {
380 if ( o3tl::equalsAscii( sFilter, aODFFormats[i++] ) )
381 {
382 bRet = true;
383 break;
384 }
385 }
386
387 return bRet;
388}
389
391{
392 m_xLoadViewPosAnyUserCB->set_active(officecfg::Office::Common::Load::ViewPositionForAnyUser::get());
393 m_xLoadViewPosAnyUserCB->save_state();
394 m_xLoadViewPosAnyUserCB->set_sensitive(!officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly());
395 m_xLoadUserSettingsCB->set_active(officecfg::Office::Common::Load::UserDefinedSettings::get());
396 m_xLoadUserSettingsCB->save_state();
397 m_xLoadUserSettingsCB->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly());
398 m_xLoadDocPrinterCB->set_active( officecfg::Office::Common::Save::Document::LoadPrinter::get() );
399 m_xLoadDocPrinterCB->save_state();
400 m_xLoadDocPrinterCB->set_sensitive(!officecfg::Office::Common::Save::Document::LoadPrinter::isReadOnly());
401
402 if ( !pImpl->bInitialized )
403 {
404 try
405 {
407 pImpl->xFact.set(xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY);
408
409 DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable");
410 Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY);
411 if(xQuery.is())
412 {
413 for (sal_Int32 n = 0, nEntryCount = m_xDocTypeLB->get_count(); n < nEntryCount; ++n)
414 {
415 unsigned int nData = m_xDocTypeLB->get_id(n).toUInt32();
416 OUString sCommand = "getSortedFilterList():module=%1:iflags=" +
417 OUString::number(static_cast<int>(SfxFilterFlags::IMPORT|SfxFilterFlags::EXPORT)) +
418 ":eflags=" +
419 OUString::number(static_cast<int>(SfxFilterFlags::NOTINFILEDLG));
420 OUString sReplace;
421 switch(nData)
422 {
423 case APP_WRITER : sReplace = "com.sun.star.text.TextDocument"; break;
424 case APP_WRITER_WEB : sReplace = "com.sun.star.text.WebDocument"; break;
425 case APP_WRITER_GLOBAL : sReplace = "com.sun.star.text.GlobalDocument"; break;
426 case APP_CALC : sReplace = "com.sun.star.sheet.SpreadsheetDocument";break;
427 case APP_IMPRESS : sReplace = "com.sun.star.presentation.PresentationDocument";break;
428 case APP_DRAW : sReplace = "com.sun.star.drawing.DrawingDocument";break;
429 case APP_MATH : sReplace = "com.sun.star.formula.FormulaProperties";break;
430 default: SAL_WARN("cui.options", "illegal user data");
431 }
432 sCommand = sCommand.replaceFirst("%1", sReplace);
433 Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
434 std::vector< OUString > lList;
435 std::vector<bool> lODFList;
436 while(xList->hasMoreElements())
437 {
438 SequenceAsHashMap aFilter(xList->nextElement());
439 OUString sFilter = aFilter.getUnpackedValueOrDefault("Name",OUString());
440 if (!sFilter.isEmpty())
441 {
442 lList.push_back(sFilter);
443 lODFList.push_back( isODFFormat( sFilter ) );
444 }
445 }
446 pImpl->aFilterArr[nData] = lList;
447 pImpl->aODFArr[nData] = lODFList;
448 }
449 }
451 sal_Int32 docId = 0;
452 if (sModule == "com.sun.star.text.TextDocument")
453 docId = APP_WRITER;
454 else if (sModule == "com.sun.star.text.WebDocument")
455 docId = APP_WRITER_WEB;
456 else if (sModule == "com.sun.star.text.GlobalDocument")
457 docId = APP_WRITER_GLOBAL;
458 else if (sModule == "com.sun.star.sheet.SpreadsheetDocument")
459 docId = APP_CALC;
460 else if (sModule == "com.sun.star.presentation.PresentationDocument")
461 docId = APP_IMPRESS;
462 else if (sModule == "com.sun.star.drawing.DrawingDocument")
463 docId = APP_DRAW;
464 else if (sModule == "com.sun.star.formula.FormulaProperties")
465 docId = APP_MATH;
466 m_xDocTypeLB->set_active_id(OUString::number(docId));
467 FilterHdl_Impl(*m_xDocTypeLB);
468 }
469 catch(Exception const &)
470 {
471 TOOLS_WARN_EXCEPTION( "cui.options", "exception in FilterFactory access" );
472 }
473
474 pImpl->bInitialized = true;
475 }
476
477 m_xDocInfoCB->set_active(officecfg::Office::Common::Save::Document::EditProperty::get());
478 m_xDocInfoCB->set_sensitive(!officecfg::Office::Common::Save::Document::EditProperty::isReadOnly());
479
480 m_xBackupCB->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get());
481 m_xBackupCB->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly());
482
484 officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get());
485 m_xBackupIntoDocumentFolderCB->set_sensitive(
486 !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly()
487 && m_xBackupCB->get_active());
488
489 m_xAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::Enabled::get());
490 m_xAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly());
491
492 m_xUserAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get());
493 m_xUserAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly());
494
495 m_xWarnAlienFormatCB->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get());
496 m_xWarnAlienFormatCB->set_sensitive(!officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly());
497
498 m_xAutoSaveEdit->set_value(officecfg::Office::Recovery::AutoSave::TimeIntervall::get());
499 m_xAutoSaveEdit->set_sensitive(!officecfg::Office::Recovery::AutoSave::TimeIntervall::isReadOnly());
500
501 // save relatively
502 m_xRelativeFsysCB->set_active(officecfg::Office::Common::Save::URL::FileSystem::get());
503 m_xRelativeFsysCB->set_sensitive(!officecfg::Office::Common::Save::URL::FileSystem::isReadOnly());
504
505 m_xRelativeInetCB->set_active(officecfg::Office::Common::Save::URL::Internet::get());
506 m_xRelativeInetCB->set_sensitive(!officecfg::Office::Common::Save::URL::Internet::isReadOnly());
507
508 sal_Int32 nDefaultVersion = GetODFDefaultVersion();
509 m_xODFVersionLB->set_active_id(OUString::number(nDefaultVersion));
510 m_xODFVersionLB->set_sensitive(!officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly());
511
512 AutoClickHdl_Impl(*m_xAutoSaveCB);
513 ODFVersionHdl_Impl(*m_xODFVersionLB);
514
515 m_xDocInfoCB->save_state();
516 m_xBackupCB->save_state();
517 m_xBackupIntoDocumentFolderCB->save_state();
518 m_xWarnAlienFormatCB->save_state();
519 m_xAutoSaveCB->save_state();
520 m_xAutoSaveEdit->save_value();
521
522 m_xUserAutoSaveCB->save_state();
523
524 m_xRelativeFsysCB->save_state();
525 m_xRelativeInetCB->save_state();
526 m_xODFVersionLB->save_value();
527}
528
529IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable&, rBox, void)
530{
531 if (&rBox != m_xAutoSaveCB.get())
532 return;
533
534 if (m_xAutoSaveCB->get_active())
535 {
536 m_xAutoSaveEdit->set_sensitive(true);
537 m_xMinuteFT->set_sensitive(true);
538 m_xUserAutoSaveCB->set_sensitive(true);
539 }
540 else
541 {
542 m_xAutoSaveEdit->set_sensitive(false);
543 m_xMinuteFT->set_sensitive(false);
544 m_xUserAutoSaveCB->set_sensitive(false);
545 }
546}
547
549{
550 m_xBackupIntoDocumentFolderCB->set_sensitive(m_xBackupCB->get_active());
551}
552
553static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, std::u16string_view rExtension)
554{
555 OUString sName;
556 const PropertyValue* pPropVal = rProperties.getConstArray();
557 const PropertyValue* const pEnd = pPropVal + rProperties.getLength();
558 for( ; pPropVal != pEnd; pPropVal++ )
559 {
560 const OUString &rName = pPropVal->Name;
561 if (rName == "UIName")
562 {
563 OUString sUIName;
564 if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
565 {
566 if (!rExtension.empty())
567 {
568 return sUIName + " (" + rExtension + ")";
569 }
570 else
571 {
572 return sUIName;
573 }
574 }
575 }
576 else if (rName == "Name")
577 {
578 pPropVal->Value >>= sName;
579 }
580 }
581
582 OSL_ENSURE( false, "Filter without UIName!" );
583
584 return sName;
585}
586
587IMPL_LINK( SvxSaveTabPage, FilterHdl_Impl, weld::ComboBox&, rBox, void )
588{
589 const int nCurPos = m_xDocTypeLB->get_active();
590
591 int nData = -1;
592 if (nCurPos < APP_COUNT)
593 nData = m_xDocTypeLB->get_id(nCurPos).toInt32();
594
595 if ( nData >= 0 && nData < APP_COUNT )
596 {
597 if(m_xDocTypeLB.get() == &rBox)
598 {
599 m_xSaveAsLB->clear();
600 auto & rFilters = pImpl->aFilterArr[nData];
601 if(pImpl->aUIFilterArr[nData].empty())
602 {
603 pImpl->aUIFilterArr[nData].resize(pImpl->aFilterArr[nData].size());
604 auto & rUIFilters = pImpl->aUIFilterArr[nData];
605 for(size_t nFilter = 0; nFilter < pImpl->aFilterArr[nData].size(); nFilter++)
606 {
607 Any aProps = pImpl->xFact->getByName(rFilters[nFilter]);
608 // get the extension of the filter
609 OUString extension;
610 SfxFilterMatcher matcher;
611 std::shared_ptr<const SfxFilter> pFilter = matcher.GetFilter4FilterName(rFilters[nFilter]);
612 if (pFilter)
613 {
614 extension = pFilter->GetWildcard().getGlob().getToken(0, ';');
615 }
617 aProps >>= aProperties;
618 rUIFilters[nFilter] = lcl_ExtracUIName(aProperties, extension);
619 }
620 }
621 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
622 OUString sSelect;
623 for(size_t i = 0; i < pImpl->aUIFilterArr[nData].size(); i++)
624 {
625 OUString sId;
626 if (pImpl->aODFArr[nData][i])
627 sId = weld::toId(pImpl.get());
628 m_xSaveAsLB->append(sId, rUIFilters[i]);
629 if (rFilters[i] == pImpl->aDefaultArr[nData])
630 sSelect = rUIFilters[i];
631 }
632 if (!sSelect.isEmpty())
633 {
634 m_xSaveAsLB->set_active_text(sSelect);
635 }
636
637 m_xSaveAsFT->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
638 m_xSaveAsLB->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
639 }
640 else
641 {
642 OUString sSelect = rBox.get_active_text();
643 auto const & rFilters = pImpl->aFilterArr[nData];
644 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
645 for(size_t i = 0; i < pImpl->aUIFilterArr[nData].size(); i++)
646 if(rUIFilters[i] == sSelect)
647 {
648 sSelect = rFilters[i];
649 break;
650 }
651
652 pImpl->aDefaultArr[nData] = sSelect;
653 }
654 }
655
656 ODFVersionHdl_Impl( *m_xSaveAsLB );
657}
658
660{
661 sal_Int32 nVersion = m_xODFVersionLB->get_active_id().toInt32();
663 if ( bShown )
664 {
665 bool bHasODFFormat = false;
666 const int nCount = m_xSaveAsLB->get_count();
667 for (int i = 0; i < nCount; ++i )
668 {
669 if ( m_xSaveAsLB->get_id(i).toInt64() != 0 )
670 {
671 bHasODFFormat = true;
672 break;
673 }
674 }
675
676 bShown = !bHasODFFormat
677 || ( m_xSaveAsLB->get_active_id().toInt64() != 0);
678 }
679
680 m_xODFWarningFI->set_visible(bShown);
681 m_xODFWarningFT->set_visible(bShown);
682}
683
684/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
static OUString getCurrentFactory_Impl(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1280
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::frame::XFrame > GetFrame() const
bool IsModuleInstalled(EModule eModule) const
bool IsDefaultFilterReadonly(EFactory eFactory) const
void SetFactoryDefaultFilter(EFactory eFactory, const OUString &sFilter)
OUString GetFactoryDefaultFilter(EFactory eFactory) const
bool IsOptionHidden(std::u16string_view _rOption, std::u16string_view _rPage, std::u16string_view _rGroup) const
void DetectHiddenControls()
Definition: optsave.cxx:214
std::unique_ptr< SvxSaveTabPage_Impl > pImpl
Definition: optsave.hxx:42
std::unique_ptr< weld::CheckButton > m_xLoadUserSettingsCB
Definition: optsave.hxx:45
std::unique_ptr< weld::CheckButton > m_xAutoSaveCB
Definition: optsave.hxx:50
std::unique_ptr< weld::CheckButton > m_xLoadDocPrinterCB
Definition: optsave.hxx:46
std::unique_ptr< weld::ComboBox > m_xSaveAsLB
Definition: optsave.hxx:60
std::unique_ptr< weld::CheckButton > m_xLoadViewPosAnyUserCB
Definition: optsave.hxx:44
std::unique_ptr< weld::SpinButton > m_xAutoSaveEdit
Definition: optsave.hxx:51
std::unique_ptr< weld::ComboBox > m_xDocTypeLB
Definition: optsave.hxx:58
std::unique_ptr< weld::CheckButton > m_xRelativeInetCB
Definition: optsave.hxx:55
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optsave.cxx:241
std::unique_ptr< weld::CheckButton > m_xBackupCB
Definition: optsave.hxx:48
std::unique_ptr< weld::Label > m_xMinuteFT
Definition: optsave.hxx:52
std::unique_ptr< weld::CheckButton > m_xDocInfoCB
Definition: optsave.hxx:47
std::unique_ptr< weld::CheckButton > m_xRelativeFsysCB
Definition: optsave.hxx:54
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optsave.cxx:208
virtual ~SvxSaveTabPage() override
Definition: optsave.cxx:204
SvxSaveTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optsave.cxx:80
std::unique_ptr< weld::CheckButton > m_xWarnAlienFormatCB
Definition: optsave.hxx:57
virtual void Reset(const SfxItemSet *rSet) override
Definition: optsave.cxx:390
std::unique_ptr< weld::CheckButton > m_xBackupIntoDocumentFolderCB
Definition: optsave.hxx:49
std::unique_ptr< weld::ComboBox > m_xODFVersionLB
Definition: optsave.hxx:56
std::unique_ptr< weld::CheckButton > m_xUserAutoSaveCB
Definition: optsave.hxx:53
static std::shared_ptr< ConfigurationChanges > create()
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
sal_Int16 nVersion
OUString sName
sal_Int64 n
#define SAL_WARN(area, stream)
@ Exception
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
int i
bool equalsAscii(std::u16string_view s1, std::string_view s2)
OUString toId(const void *pValue)
#define CFG_PAGE_AND_GROUP
Definition: optsave.cxx:58
static bool isODFFormat(std::u16string_view sFilter)
Definition: optsave.cxx:356
static OUString lcl_ExtracUIName(const Sequence< PropertyValue > &rProperties, std::u16string_view rExtension)
Definition: optsave.cxx:553
IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable &, rBox, void)
Definition: optsave.cxx:529
IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable &, void)
Definition: optsave.cxx:548
#define APP_WRITER
Definition: optsave.hxx:24
#define APP_DRAW
Definition: optsave.hxx:29
#define APP_COUNT
Definition: optsave.hxx:31
#define APP_IMPRESS
Definition: optsave.hxx:28
#define APP_WRITER_GLOBAL
Definition: optsave.hxx:26
#define APP_CALC
Definition: optsave.hxx:27
#define APP_WRITER_WEB
Definition: optsave.hxx:25
#define APP_MATH
Definition: optsave.hxx:30
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFDefaultVersion GetODFDefaultVersion()
UNOTOOLS_DLLPUBLIC void SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion eVersion)
static SfxItemSet & rSet
std::vector< OUString > aUIFilterArr[APP_COUNT]
Definition: optsave.cxx:66
std::vector< OUString > aFilterArr[APP_COUNT]
Definition: optsave.cxx:64
std::vector< bool > aODFArr[APP_COUNT]
Definition: optsave.cxx:65
bool aDefaultReadonlyArr[APP_COUNT]
Definition: optsave.cxx:68
OUString aDefaultArr[APP_COUNT]
Definition: optsave.cxx:67
Reference< XNameContainer > xFact
Definition: optsave.cxx:63
OUString sId