Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / SwXMLTextBlocks.hxx
blob05a97ded59428212088e0e1833928ccbb977b062
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
26 #include <sfx2/objsh.hxx>
27 #include "swblocks.hxx"
28 #include <o3tl/typed_flags_set.hxx>
30 class SwDoc;
31 class SvxMacroTableDtor;
33 enum class SwXmlFlags {
34 NONE = 0x0000,
35 NoRootCommit = 0x0002,
37 namespace o3tl {
38 template<> struct typed_flags<SwXmlFlags> : is_typed_flags<SwXmlFlags, 0x0002> {};
41 class SwXMLTextBlocks final : public SwImpBlocks
43 SfxObjectShellRef m_xDocShellRef;
44 SwXmlFlags m_nFlags;
45 OUString m_aPackageName;
46 tools::SvRef<SfxMedium> m_xMedium;
47 css::uno::Reference < css::embed::XStorage > m_xBlkRoot;
48 css::uno::Reference < css::embed::XStorage > m_xRoot;
50 void ReadInfo();
51 void WriteInfo();
52 void InitBlockMode ( const css::uno::Reference < css::embed::XStorage >& rStorage );
53 void ResetBlockMode();
55 public:
56 SwXMLTextBlocks( const OUString& rFile );
57 SwXMLTextBlocks( const css::uno::Reference < css::embed::XStorage >&, const OUString& rFile );
58 void AddName( const OUString&, const OUString&, const OUString&, bool bOnlyText );
59 virtual void AddName( const OUString&, const OUString&, bool bOnlyText = false ) override;
60 static OUString GeneratePackageName ( std::u16string_view rShort );
61 virtual ~SwXMLTextBlocks() override;
62 virtual ErrCode Delete( sal_uInt16 ) override;
63 virtual ErrCode Rename( sal_uInt16, const OUString& ) override;
64 virtual ErrCode CopyBlock( SwImpBlocks& rImp, OUString& rShort, const OUString& rLong) override;
65 virtual void ClearDoc() override;
66 virtual ErrCode GetDoc( sal_uInt16 ) override;
67 virtual ErrCode BeginPutDoc( const OUString&, const OUString& ) override;
68 virtual ErrCode PutDoc() override;
69 virtual ErrCode PutText( const OUString&, const OUString&, const OUString& ) override;
70 virtual ErrCode MakeBlockList() override;
72 virtual ErrCode OpenFile( bool bReadOnly = true ) override;
73 virtual void CloseFile() override;
75 static bool IsFileUCBStorage( const OUString & rFileName);
77 // Methods for the new Autocorrecter
78 ErrCode GetText( std::u16string_view rShort, OUString& );
80 virtual bool IsOnlyTextBlock( const OUString& rShort ) const override;
81 bool IsOnlyTextBlock( sal_uInt16 nIdx ) const;
82 void SetIsTextOnly( const OUString& rShort, bool bNewValue );
84 virtual ErrCode GetMacroTable( sal_uInt16, SvxMacroTableDtor& rMacroTable ) override;
85 virtual ErrCode SetMacroTable( sal_uInt16 nIdx,
86 const SvxMacroTableDtor& rMacroTable ) override;
87 virtual bool PutMuchEntries( bool bOn ) override;
89 SwDoc* GetDoc() const { return m_xDoc.get(); }
90 //void SetDoc( SwDoc * pNewDoc);
91 ErrCode StartPutBlock( const OUString& rShort, const OUString& rPackageName );
92 ErrCode PutBlock();
93 ErrCode GetBlockText( std::u16string_view rShort, OUString& rText );
94 ErrCode PutBlockText( const OUString& rShort, std::u16string_view rText, const OUString& rPackageName );
95 void MakeBlockText( std::u16string_view rText );
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */