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 ) throw(::com::sun::star::uno::RuntimeException); 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( ) throw(::com::sun::star::uno::RuntimeException); 71 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 72 73 // text::XTextMarkup: 74 virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (css::uno::RuntimeException); 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) throw (css::uno::RuntimeException); 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) throw (css::uno::RuntimeException); 81 82 83 84 // text::XFlatParagraph: 85 virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); 86 virtual ::sal_Bool SAL_CALL isModified() throw (css::uno::RuntimeException); 87 virtual void SAL_CALL setChecked(::sal_Int32 nType, ::sal_Bool bVal) throw (css::uno::RuntimeException); 88 virtual ::sal_Bool SAL_CALL isChecked(::sal_Int32 nType) throw (css::uno::RuntimeException); 89 virtual css::lang::Locale SAL_CALL getLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 90 virtual css::lang::Locale SAL_CALL getPrimaryLanguageOfText(::sal_Int32 nPos, ::sal_Int32 nLen) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); 91 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); 92 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); 93 virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getLanguagePortions() throw (css::uno::RuntimeException); 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 throw (css::uno::RuntimeException); 102 103 private: 104 SwXFlatParagraph( const SwXFlatParagraph & ); // not defined 105 SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined 106 107 rtl::OUString maExpandText; 108 }; 109 110 /****************************************************************************** 111 * SwXFlatParagraphIterator 112 ******************************************************************************/ 113 114 class SwXFlatParagraphIterator: 115 public ::cppu::WeakImplHelper1 116 < 117 css::text::XFlatParagraphIterator 118 >, 119 public SwClient // to get notified when doc is closed... 120 { 121 public: 122 SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType, sal_Bool bAutomatic ); 123 virtual ~SwXFlatParagraphIterator(); 124 125 // text::XFlatParagraphIterator: 126 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getFirstPara() throw (css::uno::RuntimeException); 127 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getNextPara() throw (css::uno::RuntimeException); 128 virtual css::uno::Reference< css::text::XFlatParagraph > SAL_CALL getLastPara() throw (css::uno::RuntimeException); 129 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); 130 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); 131 132 protected: 133 // SwClient 134 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ); 135 136 private: 137 SwXFlatParagraphIterator( const SwXFlatParagraphIterator & ); // not defined 138 SwXFlatParagraphIterator & operator =(const SwXFlatParagraphIterator & ); // not defined 139 140 // container to hold the 'hard' references as long as necessary and valid 141 std::set< css::uno::Reference< css::text::XFlatParagraph > > m_aFlatParaList; 142 143 SwDoc* mpDoc; 144 const sal_Int32 mnType; 145 const sal_Bool mbAutomatic; 146 147 sal_uLong mnCurrentNode; // used for non-automatic mode 148 sal_uLong mnStartNode; // used for non-automatic mode 149 sal_uLong mnEndNode; // used for non-automatic mode 150 sal_Bool mbWrapped; // used for non-automatic mode 151 }; 152 153 #endif 154