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