xref: /aoo42x/main/sw/inc/hhcwrp.hxx (revision 1d2dbeb0)
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 _HHCWRP_HXX
24 #define _HHCWRP_HXX
25 
26 #include <editeng/hangulhanja.hxx>
27 #include <pam.hxx>
28 
29 class SwView;
30 class Window;
31 class SwWrtShell;
32 struct SwConversionArgs;
33 
34 //////////////////////////////////////////////////////////////////////
35 
36 class SwHHCWrapper : public editeng::HangulHanjaConversion
37 {
38     SwView *    pView;
39     Window*     pWin;
40     SwWrtShell &rWrtShell;
41 
42     SwConversionArgs *pConvArgs;    // object for arguments (and results) needed
43                                     // to find of next convertible text portion
44 
45     xub_StrLen      nLastPos;   // starting position of the last found text part
46                                 // (needs to be sth that gets not moved like
47                                 // SwPaM or SwPosition by replace operations!)
48     sal_Int32       nUnitOffset;
49 
50     sal_uInt16      nPageCount;     // page count for progress bar
51     sal_uInt16      nPageStart;     // first checked page
52 
53     sal_Bool    bIsDrawObj;
54     sal_Bool    bIsStart;
55     sal_Bool    bIsOtherCntnt;
56     sal_Bool    bStartChk;
57     sal_Bool    bIsSelection;   // true if only the selected text should be converted
58     sal_Bool    bInfoBox;       // true if message should be displayed at the end
59     sal_Bool    bIsConvSpecial; // true if special regions: header, footer, ... should be converted
60     sal_Bool    bStartDone;
61     sal_Bool    bEndDone;
62 //    sal_Bool    bLastRet;
63 
64     // from SvxSpellWrapper copied and modified
65     sal_Bool    ConvNext_impl();        // former SpellNext
66     sal_Bool    FindConvText_impl();    // former FindSpellError
67 
68     // from SwSpellWrapper copied and modified
69     sal_Bool    HasOtherCnt_impl();
70     void        ConvStart_impl( SwConversionArgs *pConvArgs, SvxSpellArea eSpell );   // former SpellStart
71     void        ConvEnd_impl( SwConversionArgs *pConvArgs );                          // former SpellEnd
72     sal_Bool    ConvContinue_impl( SwConversionArgs *pConvArgs );                     // former SpellContinue
73 
74     void        SelectNewUnit_impl( const sal_Int32 nUnitStart,
75                                     const sal_Int32 nUnitEnd );
76     void        ChangeText( const String &rNewText,
77                             const ::rtl::OUString& rOrigText,
78                             const ::com::sun::star::uno::Sequence< sal_Int32 > *pOffsets,
79                             SwPaM *pCrsr );
80     void        ChangeText_impl( const String &rNewText, sal_Bool bKeepAttributes );
81 
IsDrawObj()82     inline sal_Bool IsDrawObj()             { return bIsDrawObj; }
SetDrawObj(sal_Bool bNew)83     inline void SetDrawObj( sal_Bool bNew ) { bIsDrawObj = bNew; }
84 
85 protected:
86     virtual void    GetNextPortion( ::rtl::OUString& rNextPortion,
87                             LanguageType& rLangOfPortion,
88                             sal_Bool bAllowImplicitChangesForNotConvertibleText );
89     virtual void    HandleNewUnit( const sal_Int32 nUnitStart,
90                                    const sal_Int32 nUnitEnd );
91     virtual void    ReplaceUnit(
92                         const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
93                         const ::rtl::OUString& rOrigText,
94                         const ::rtl::OUString& rReplaceWith,
95                         const ::com::sun::star::uno::Sequence< sal_Int32 > &rOffsets,
96                         ReplacementAction eAction,
97                         LanguageType *pNewUnitLanguage );
98 
99     virtual sal_Bool    HasRubySupport() const;
100 
101 public:
102     SwHHCWrapper(
103         SwView* pView,
104         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF,
105         LanguageType nSourceLanguage, LanguageType nTargetLanguage,
106         const Font *pTargetFont,
107         sal_Int32 nConvOptions, sal_Bool bIsInteractive,
108         sal_Bool bStart, sal_Bool bOther, sal_Bool bSelection );
109 
110     virtual ~SwHHCWrapper();
111 
112     void    Convert();
113 };
114 
115 
116 #endif
117 
118