1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SW_XMLTEXTBLOCKS_HXX
24 #define _SW_XMLTEXTBLOCKS_HXX
25 #include <sfx2/objsh.hxx>
26 #include <sfx2/docfile.hxx>
27 #include <swblocks.hxx>
28 
29 class SfxMedium;
30 class SwPaM;
31 class SwDoc;
32 class SvxMacroTableDtor;
33 class SwImpBlocks;
34 
35 #define SWXML_CONVBLOCK 	0x0001
36 #define SWXML_NOROOTCOMMIT 	0x0002
37 
38 class SwXMLTextBlocks : public SwImpBlocks
39 {
40 protected:
41 	sal_Bool 		 bAutocorrBlock;
42 	sal_Bool 		 bBlock;
43     SfxObjectShellRef xDocShellRef;
44 	sal_uInt16		 nFlags;
45 	String		 aPackageName;
46     SfxMediumRef xMedium;
47 
48 	void ReadInfo();
49 	void WriteInfo();
50     void InitBlockMode ( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStorage );
51 	void ResetBlockMode();
52 
53 public:
54     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xBlkRoot;
55     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xRoot;
56 	short				nCurBlk;
57     SwXMLTextBlocks( const String& rFile );
58     SwXMLTextBlocks( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFile );
59 	void   AddName( const String&, const String&, const String&, sal_Bool bOnlyTxt = sal_False );
60 	virtual void   AddName( const String&, const String&, sal_Bool bOnlyTxt = sal_False );
61 	void GeneratePackageName ( const String& rShort, String& rPackageName );
62 	virtual ~SwXMLTextBlocks();
63 	//virtual sal_Bool   IsOld() const;
64 	virtual sal_uLong Delete( sal_uInt16 );
65 	virtual sal_uLong Rename( sal_uInt16, const String&, const String& );
66 	virtual sal_uLong CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
67 	virtual void  ClearDoc();
68 	virtual sal_uLong GetDoc( sal_uInt16 );
69 	virtual sal_uLong BeginPutDoc( const String&, const String& );
70     virtual sal_uLong PutDoc();
71 	virtual sal_uLong GetText( sal_uInt16, String& );
72 	virtual sal_uLong PutText( const String&, const String&, const String& );
73 	virtual sal_uLong MakeBlockList();
74 
75 	virtual short GetFileType ( void ) const;
76 	virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True );
77 	virtual void  CloseFile();
78 
79 	static sal_Bool IsFileUCBStorage( const String & rFileName);
80 
81 	// Methods for the new Autocorrecter
82 	sal_uLong GetText( const String& rShort, String& );
83 
84 	virtual sal_Bool IsOnlyTextBlock( const String& rShort ) const;
85 	virtual sal_Bool IsOnlyTextBlock( sal_uInt16 nIdx ) const;
86 	virtual void SetIsTextOnly( const String& rShort, sal_Bool bNewValue );
87 	virtual void SetIsTextOnly( sal_uInt16 nIdx, sal_Bool bNewValue );
88 
89 	virtual sal_uLong GetMacroTable( sal_uInt16, SvxMacroTableDtor& rMacroTbl,
90 								 sal_Bool bFileAlreadyOpen = sal_False );
91 	virtual sal_uLong SetMacroTable( sal_uInt16 nIdx,
92 								 const SvxMacroTableDtor& rMacroTable,
93 								 sal_Bool bFileAlreadyOpen = sal_False );
94 	virtual sal_Bool PutMuchEntries( sal_Bool bOn );
95 
96 public:
GetDoc() const97 	SwDoc* GetDoc() const { return pDoc; }
98 	//void  SetDoc( SwDoc * pNewDoc);
99 	sal_uLong StartPutBlock( const String& rShort, const String& rPackageName );
100     sal_uLong PutBlock( SwPaM& rPaM, const String& rLong );
101 	sal_uLong GetBlockText( const String& rShort, String& rText );
102 	sal_uLong PutBlockText( const String& rShort, const String& rName, const String& rText,  const String& rPackageName );
103 	void MakeBlockText( const String& rText );
104 
105 };
106 
107 #endif
108