xref: /trunk/main/sw/inc/unoflatpara.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
24 #ifndef _UNOFLATPARA_HXX
25 #define _UNOFLATPARA_HXX
26 
27 #include <cppuhelper/implbase1.hxx>
28 #include <com/sun/star/lang/XUnoTunnel.hpp>
29 #include <com/sun/star/text/XFlatParagraph.hpp>
30 #include <com/sun/star/text/XFlatParagraphIterator.hpp>
31 #include <calbck.hxx>
32 #include <modeltoviewhelper.hxx>
33 #include <unotextmarkup.hxx>
34 
35 #include <set>
36 
37 namespace css = com::sun::star;
38 
39 namespace com { namespace sun { namespace star { namespace container {
40     class XStringKeyMap;
41 } } } }
42 
43 namespace com { namespace sun { namespace star { namespace text {
44     class XTextRange;
45 } } } }
46 
47 class SwTxtNode;
48 class SwDoc;
49 
50 /******************************************************************************
51  * SwXFlatParagraph
52  ******************************************************************************/
53 
54 class SwXFlatParagraph:
55     public ::cppu::WeakImplHelper2
56     <
57         css::text::XFlatParagraph,
58         css::lang::XUnoTunnel
59     >,
60     public SwXTextMarkup
61 {
62 public:
63     SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper::ConversionMap* pConversionMap );
64     virtual ~SwXFlatParagraph();
65 
66     virtual     ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType );
67     virtual void SAL_CALL acquire(  ) throw();
68     virtual void SAL_CALL release(  ) throw();
69 
70     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  );
71     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  );
72 
73     // text::XTextMarkup:
74     virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer();
75 
76     virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const ::rtl::OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength,
77                                    const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer);
78 
79     virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const ::rtl::OUString & aIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & xRange,
80                                                 const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer);
81 
82 
83 
84     // text::XFlatParagraph:
85     virtual ::rtl::OUString SAL_CALL getText();
86     virtual ::sal_Bool SAL_CALL isModified();
87     virtual void SAL_CALL setChecked(::sal_Int32 nType, ::sal_Bool bVal);
88     virtual ::sal_Bool SAL_CALL isChecked(::sal_Int32 nType);
89     virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen);
90     virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen);
91     virtual void SAL_CALL changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const ::rtl::OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes);
92     virtual void SAL_CALL changeAttributes(::sal_Int32 nPos, ::sal_Int32 nLen, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes);
93     virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions();
94 
95     const SwTxtNode* getTxtNode() const;
96 
97     static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
98 
99     // XUnoTunnel
100     virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId);
101 
102 private:
103     SwXFlatParagraph( const SwXFlatParagraph & ); // not defined
104     SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined
105 
106     rtl::OUString maExpandText;
107 };
108 
109 /******************************************************************************
110  * SwXFlatParagraphIterator
111  ******************************************************************************/
112 
113 class SwXFlatParagraphIterator:
114     public ::cppu::WeakImplHelper1
115     <
116         css::text::XFlatParagraphIterator
117     >,
118     public SwClient     // to get notified when doc is closed...
119 {
120 public:
121     SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, sal_Bool bAutomatic );
122     virtual ~SwXFlatParagraphIterator();
123 
124     // text::XFlatParagraphIterator:
125     virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara();
126     virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara();
127     virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara();
128     virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaBefore(const css::uno::Reference< css::text::XFlatParagraph > & xPara);
129     virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getParaAfter(const css::uno::Reference< css::text::XFlatParagraph > & xPara);
130 
131 protected:
132     // SwClient
133     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
134 
135 private:
136     SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ); // not defined
137     SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ); // not defined
138 
139     // container to hold the 'hard' references as long as necessary and valid
140     std::set< css::uno::Reference< css::text::XFlatParagraph > >    m_aFlatParaList;
141 
142     SwDoc* mpDoc;
143     const sal_Int32 mnType;
144     const sal_Bool mbAutomatic;
145 
146     sal_uLong mnCurrentNode;    // used for non-automatic mode
147     sal_uLong mnStartNode;      // used for non-automatic mode
148     sal_uLong mnEndNode;        // used for non-automatic mode
149     sal_Bool mbWrapped;     // used for non-automatic mode
150 };
151 
152 #endif
153