Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / sfx2 / new.hxx
blob8cb2bd9b4ea4ddab35efb6fe36ec82e576005b65
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_NEW_HXX
20 #define INCLUDED_SFX2_NEW_HXX
22 #include <memory>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sfx2/basedlgs.hxx>
26 #include <sfx2/objsh.hxx>
28 #include <vcl/idle.hxx>
29 #include <sfx2/doctempl.hxx>
30 #include <o3tl/typed_flags_set.hxx>
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; }
40 class SfxPreviewWin_Impl;
42 enum class SfxNewFileDialogMode {
43 NONE, Preview, LoadTemplate
46 enum class SfxTemplateFlags
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,
55 namespace o3tl
57 template<> struct typed_flags<SfxTemplateFlags> : is_typed_flags<SfxTemplateFlags, 0x1f> {};
60 #define RET_TEMPLATE_LOAD 100
62 class SFX2_DLLPUBLIC SfxNewFileDialog final : public SfxDialogController
64 private:
65 Idle m_aPrevIdle;
66 SfxNewFileDialogMode m_nFlags;
67 SfxDocumentTemplates m_aTemplates;
68 SfxObjectShellLock m_xDocShell;
70 std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewController;
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;
84 DECL_DLLPRIVATE_LINK( Update, Timer *, void );
86 DECL_DLLPRIVATE_LINK(RegionSelect, weld::TreeView&, void);
87 DECL_DLLPRIVATE_LINK(TemplateSelect, weld::TreeView&, void);
88 DECL_DLLPRIVATE_LINK(DoubleClick, weld::TreeView&, bool);
89 DECL_DLLPRIVATE_LINK(Expand, weld::Expander&, void);
90 sal_uInt16 GetSelectedTemplatePos() const;
92 public:
93 SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags);
94 virtual ~SfxNewFileDialog() override;
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;
101 // load template methods
102 SfxTemplateFlags GetTemplateFlags() const;
103 void SetTemplateFlags(SfxTemplateFlags nSet);
106 #endif
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */