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 #ifndef INCLUDED_SFX2_NEW_HXX 20 #define INCLUDED_SFX2_NEW_HXX 21 22 #include <memory> 23 #include <sal/config.h> 24 #include <sfx2/dllapi.h> 25 #include <sfx2/basedlgs.hxx> 26 #include <sfx2/objsh.hxx> 27 28 #include <vcl/idle.hxx> 29 #include <sfx2/doctempl.hxx> 30 #include <o3tl/typed_flags_set.hxx> 31 32 namespace weld { class Button; } 33 namespace weld { class CheckButton; } 34 namespace weld { class CustomWeld; } 35 namespace weld { class Expander; } 36 namespace weld { class Label; } 37 namespace weld { class TreeView; } 38 namespace weld { class Window; } 39 40 class SfxPreviewWin_Impl; 41 42 enum class SfxNewFileDialogMode { 43 NONE, Preview, LoadTemplate 44 }; 45 46 enum class SfxTemplateFlags 47 { 48 NONE = 0x00, 49 LOAD_TEXT_STYLES = 0x01, 50 LOAD_FRAME_STYLES = 0x02, 51 LOAD_PAGE_STYLES = 0x04, 52 LOAD_NUM_STYLES = 0x08, 53 MERGE_STYLES = 0x10, 54 }; 55 namespace o3tl 56 { 57 template<> struct typed_flags<SfxTemplateFlags> : is_typed_flags<SfxTemplateFlags, 0x1f> {}; 58 } 59 60 #define RET_TEMPLATE_LOAD 100 61 62 class SFX2_DLLPUBLIC SfxNewFileDialog final : public SfxDialogController 63 { 64 private: 65 Idle m_aPrevIdle; 66 SfxNewFileDialogMode const m_nFlags; 67 SfxDocumentTemplates m_aTemplates; 68 SfxObjectShellLock m_xDocShell; 69 70 std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewController; 71 72 std::unique_ptr<weld::TreeView> m_xRegionLb; 73 std::unique_ptr<weld::TreeView> m_xTemplateLb; 74 std::unique_ptr<weld::CheckButton> m_xTextStyleCB; 75 std::unique_ptr<weld::CheckButton> m_xFrameStyleCB; 76 std::unique_ptr<weld::CheckButton> m_xPageStyleCB; 77 std::unique_ptr<weld::CheckButton> m_xNumStyleCB; 78 std::unique_ptr<weld::CheckButton> m_xMergeStyleCB; 79 std::unique_ptr<weld::Button> m_xLoadFilePB; 80 std::unique_ptr<weld::Expander> m_xMoreBt; 81 std::unique_ptr<weld::CustomWeld> m_xPreviewWin; 82 std::unique_ptr<weld::Label> m_xAltTitleFt; 83 84 DECL_LINK( Update, Timer *, void ); 85 86 DECL_LINK(RegionSelect, weld::TreeView&, void); 87 DECL_LINK(TemplateSelect, weld::TreeView&, void); 88 DECL_LINK(DoubleClick, weld::TreeView&, bool); 89 DECL_LINK(Expand, weld::Expander&, void); 90 sal_uInt16 GetSelectedTemplatePos() const; 91 92 public: 93 SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags); 94 virtual ~SfxNewFileDialog() override; 95 96 // Returns false, when '- No -' is set as Template 97 // Template names can only be obtained when IsTemplate() returns true. 98 bool IsTemplate() const; 99 OUString GetTemplateFileName() const; 100 101 // load template methods 102 SfxTemplateFlags GetTemplateFlags() const; 103 void SetTemplateFlags(SfxTemplateFlags nSet); 104 }; 105 106 #endif 107 108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 109