Line data Source code
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 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFLATPARA_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_UNOFLATPARA_HXX
22 :
23 : #include <cppuhelper/implbase1.hxx>
24 : #include <cppuhelper/implbase3.hxx>
25 :
26 : #include <com/sun/star/beans/XPropertySet.hpp>
27 : #include <com/sun/star/lang/XUnoTunnel.hpp>
28 : #include <com/sun/star/text/XFlatParagraph.hpp>
29 : #include <com/sun/star/text/XFlatParagraphIterator.hpp>
30 : #include <calbck.hxx>
31 : #include <modeltoviewhelper.hxx>
32 : #include <unotextmarkup.hxx>
33 :
34 : #include <set>
35 :
36 : namespace com { namespace sun { namespace star { namespace container {
37 : class XStringKeyMap;
38 : } } } }
39 :
40 : namespace com { namespace sun { namespace star { namespace text {
41 : class XTextRange;
42 : } } } }
43 :
44 : class SwTxtNode;
45 : class SwDoc;
46 :
47 : typedef ::cppu::ImplInheritanceHelper3
48 : < SwXTextMarkup
49 : , css::beans::XPropertySet
50 : , css::text::XFlatParagraph
51 : , css::lang::XUnoTunnel
52 : > SwXFlatParagraph_Base;
53 :
54 : class SwXFlatParagraph
55 : : public SwXFlatParagraph_Base
56 : {
57 : public:
58 : SwXFlatParagraph( SwTxtNode& rTxtNode, const OUString& aExpandText, const ModelToViewHelper& rConversionMap );
59 : virtual ~SwXFlatParagraph();
60 :
61 : // XPropertySet
62 : virtual ::com::sun::star::uno::Reference<
63 : ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
64 : getPropertySetInfo()
65 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : virtual void SAL_CALL setPropertyValue(
67 : const OUString& rPropertyName,
68 : const ::com::sun::star::uno::Any& rValue)
69 : throw (::com::sun::star::beans::UnknownPropertyException,
70 : ::com::sun::star::beans::PropertyVetoException,
71 : ::com::sun::star::lang::IllegalArgumentException,
72 : ::com::sun::star::lang::WrappedTargetException,
73 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
75 : const OUString& rPropertyName)
76 : throw (::com::sun::star::beans::UnknownPropertyException,
77 : ::com::sun::star::lang::WrappedTargetException,
78 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 : virtual void SAL_CALL addPropertyChangeListener(
80 : const OUString& rPropertyName,
81 : const ::com::sun::star::uno::Reference<
82 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
83 : throw (::com::sun::star::beans::UnknownPropertyException,
84 : ::com::sun::star::lang::WrappedTargetException,
85 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual void SAL_CALL removePropertyChangeListener(
87 : const OUString& rPropertyName,
88 : const ::com::sun::star::uno::Reference<
89 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
90 : throw (::com::sun::star::beans::UnknownPropertyException,
91 : ::com::sun::star::lang::WrappedTargetException,
92 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 : virtual void SAL_CALL addVetoableChangeListener(
94 : const OUString& rPropertyName,
95 : const ::com::sun::star::uno::Reference<
96 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
97 : throw (::com::sun::star::beans::UnknownPropertyException,
98 : ::com::sun::star::lang::WrappedTargetException,
99 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 : virtual void SAL_CALL removeVetoableChangeListener(
101 : const OUString& rPropertyName,
102 : const ::com::sun::star::uno::Reference<
103 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
104 : throw (::com::sun::star::beans::UnknownPropertyException,
105 : ::com::sun::star::lang::WrappedTargetException,
106 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : // text::XTextMarkup:
109 : virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength,
112 : const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 :
114 : virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & xRange,
115 : const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 :
117 : // text::XFlatParagraph:
118 : virtual OUString SAL_CALL getText() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual sal_Bool SAL_CALL isModified() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : virtual void SAL_CALL setChecked(::sal_Int32 nType, sal_Bool bVal) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual sal_Bool SAL_CALL isChecked(::sal_Int32 nType) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, std::exception) SAL_OVERRIDE;
123 : virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, std::exception) SAL_OVERRIDE;
124 : virtual void SAL_CALL changeText(::sal_Int32 nPos, ::sal_Int32 nLen, const OUString & aNewText, const css::uno::Sequence< css::beans::PropertyValue > & aAttributes) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, std::exception) SAL_OVERRIDE;
125 : 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, std::exception) SAL_OVERRIDE;
126 : virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 :
128 0 : const SwTxtNode* getTxtNode() const { return mpTxtNode;}
129 :
130 : static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
131 :
132 : // XUnoTunnel
133 : virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId)
134 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 :
136 : private:
137 : SwXFlatParagraph( const SwXFlatParagraph & ); // not defined
138 : SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined
139 :
140 : OUString maExpandText;
141 : };
142 :
143 : class SwXFlatParagraphIterator:
144 : public ::cppu::WeakImplHelper1
145 : <
146 : css::text::XFlatParagraphIterator
147 : >,
148 : public SwClient // to get notified when doc is closed...
149 : {
150 : public:
151 : SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, bool bAutomatic );
152 : virtual ~SwXFlatParagraphIterator();
153 :
154 : // text::XFlatParagraphIterator:
155 : virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 : virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 : virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 : 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, std::exception) SAL_OVERRIDE;
159 : 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, std::exception) SAL_OVERRIDE;
160 :
161 : protected:
162 : // SwClient
163 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) SAL_OVERRIDE;
164 :
165 : private:
166 : SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ); // not defined
167 : SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ); // not defined
168 :
169 : // container to hold the 'hard' references as long as necessary and valid
170 : std::set< css::uno::Reference< css::text::XFlatParagraph > > m_aFlatParaList;
171 :
172 : SwDoc* mpDoc;
173 : const sal_Int32 mnType;
174 : const bool mbAutomatic;
175 :
176 : sal_uLong mnCurrentNode; // used for non-automatic mode
177 : sal_uLong mnStartNode; // used for non-automatic mode
178 : sal_uLong mnEndNode; // used for non-automatic mode
179 : bool mbWrapped; // used for non-automatic mode
180 : };
181 :
182 : #endif
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|