LibreOffice Module sw (master)  1
SwXMLTextBlocks.hxx
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 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <string_view>
25 
26 #include <sfx2/objsh.hxx>
27 #include "swblocks.hxx"
28 #include <o3tl/typed_flags_set.hxx>
29 
30 class SwDoc;
31 class SvxMacroTableDtor;
32 
33 enum class SwXmlFlags {
34  NONE = 0x0000,
35  NoRootCommit = 0x0002,
36 };
37 namespace o3tl {
38  template<> struct typed_flags<SwXmlFlags> : is_typed_flags<SwXmlFlags, 0x0002> {};
39 }
40 
41 class SwXMLTextBlocks final : public SwImpBlocks
42 {
45  OUString m_aPackageName;
47 
48  void ReadInfo();
49  void WriteInfo();
50  void InitBlockMode ( const css::uno::Reference < css::embed::XStorage >& rStorage );
51  void ResetBlockMode();
52 
53 public:
54  css::uno::Reference < css::embed::XStorage > m_xBlkRoot;
55  css::uno::Reference < css::embed::XStorage > m_xRoot;
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 void ClearDoc() override;
65  virtual ErrCode GetDoc( sal_uInt16 ) override;
66  virtual ErrCode BeginPutDoc( const OUString&, const OUString& ) override;
67  virtual ErrCode PutDoc() override;
68  virtual ErrCode PutText( const OUString&, const OUString&, const OUString& ) override;
69  virtual ErrCode MakeBlockList() override;
70 
71  virtual ErrCode OpenFile( bool bReadOnly = true ) override;
72  virtual void CloseFile() override;
73 
74  static bool IsFileUCBStorage( const OUString & rFileName);
75 
76  // Methods for the new Autocorrecter
77  ErrCode GetText( std::u16string_view rShort, OUString& );
78 
79  virtual bool IsOnlyTextBlock( const OUString& rShort ) const override;
80  bool IsOnlyTextBlock( sal_uInt16 nIdx ) const;
81  void SetIsTextOnly( const OUString& rShort, bool bNewValue );
82 
83  virtual ErrCode GetMacroTable( sal_uInt16, SvxMacroTableDtor& rMacroTable ) override;
84  virtual ErrCode SetMacroTable( sal_uInt16 nIdx,
85  const SvxMacroTableDtor& rMacroTable ) override;
86  virtual bool PutMuchEntries( bool bOn ) override;
87 
88  SwDoc* GetDoc() const { return m_xDoc.get(); }
89  //void SetDoc( SwDoc * pNewDoc);
90  ErrCode StartPutBlock( const OUString& rShort, const OUString& rPackageName );
91  ErrCode PutBlock();
92  ErrCode GetBlockText( std::u16string_view rShort, OUString& rText );
93  ErrCode PutBlockText( const OUString& rShort, const OUString& rText, const OUString& rPackageName );
94  void MakeBlockText( const OUString& rText );
95 };
96 
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InitBlockMode(const css::uno::Reference< css::embed::XStorage > &rStorage)
tools::SvRef< SfxMedium > m_xMedium
static OUString GeneratePackageName(std::u16string_view rShort)
rtl::Reference< SwDoc > m_xDoc
Definition: swblocks.hxx:66
virtual ErrCode SetMacroTable(sal_uInt16 nIdx, const SvxMacroTableDtor &rMacroTable) override
virtual ~SwXMLTextBlocks() override
Definition: doc.hxx:187
ErrCode PutBlockText(const OUString &rShort, const OUString &rText, const OUString &rPackageName)
SfxObjectShellRef m_xDocShellRef
virtual bool IsOnlyTextBlock(const OUString &rShort) const override
css::uno::Reference< css::embed::XStorage > m_xRoot
css::uno::Reference< css::embed::XStorage > m_xBlkRoot
virtual ErrCode Delete(sal_uInt16) override
virtual ErrCode OpenFile(bool bReadOnly=true) override
virtual void CloseFile() override
virtual void ClearDoc() override
Delete the document's content.
ErrCode GetText(std::u16string_view rShort, OUString &)
virtual ErrCode PutText(const OUString &, const OUString &, const OUString &) override
SwXmlFlags
void SetIsTextOnly(const OUString &rShort, bool bNewValue)
virtual ErrCode MakeBlockList() override
virtual bool PutMuchEntries(bool bOn) override
virtual ErrCode PutDoc() override
SwDoc * GetDoc() const
SwXMLTextBlocks(const OUString &rFile)
virtual ErrCode GetMacroTable(sal_uInt16, SvxMacroTableDtor &rMacroTable) override
void AddName(const OUString &, const OUString &, const OUString &, bool bOnlyText)
virtual ErrCode Rename(sal_uInt16, const OUString &) override
ErrCode StartPutBlock(const OUString &rShort, const OUString &rPackageName)
void MakeBlockText(const OUString &rText)
virtual ErrCode BeginPutDoc(const OUString &, const OUString &) override
ErrCode GetBlockText(std::u16string_view rShort, OUString &rText)
static bool IsFileUCBStorage(const OUString &rFileName)