xref: /aoo41x/main/sw/inc/unocrsrhelper.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _UNOCRSRHELPER_HXX
24cdf0e10cSrcweir #define _UNOCRSRHELPER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <map>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <swtypes.hxx>
32cdf0e10cSrcweir #include <pam.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir class String;
36cdf0e10cSrcweir class SfxItemSet;
37cdf0e10cSrcweir class SfxItemPropertySet;
38cdf0e10cSrcweir struct SfxItemPropertySimpleEntry;
39cdf0e10cSrcweir class SwTxtNode;
40cdf0e10cSrcweir class SwPaM;
41cdf0e10cSrcweir class SwCursor;
42cdf0e10cSrcweir class SwUnoCrsr;
43cdf0e10cSrcweir class SwFmtColl;
44cdf0e10cSrcweir struct SwSortOptions;
45cdf0e10cSrcweir class SwDoc;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace com{ namespace sun{ namespace star{
48cdf0e10cSrcweir 	namespace uno{
49cdf0e10cSrcweir 		class Any;
50cdf0e10cSrcweir 	}
51cdf0e10cSrcweir     namespace beans{
52cdf0e10cSrcweir         struct PropertyValue;
53cdf0e10cSrcweir     }
54cdf0e10cSrcweir     namespace text {
55cdf0e10cSrcweir         class XTextContent;
56cdf0e10cSrcweir     }
57cdf0e10cSrcweir }}}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /* -----------------03.12.98 12:16-------------------
60cdf0e10cSrcweir  *
61cdf0e10cSrcweir  * --------------------------------------------------*/
62cdf0e10cSrcweir enum SwGetPropertyStatesCaller
63cdf0e10cSrcweir {
64cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_DEFAULT,
65cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
66cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
67cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir /* -----------------------------14.12.00 15:06--------------------------------
71cdf0e10cSrcweir 
72cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
73cdf0e10cSrcweir namespace SwUnoCursorHelper
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     //  keep Any's mapped by (WhichId << 16 ) + (MemberId)
76cdf0e10cSrcweir     typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t;
77cdf0e10cSrcweir     class SwAnyMapHelper : public AnyMapHelper_t
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         public:
80cdf0e10cSrcweir             ~SwAnyMapHelper();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir             void    SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny );
83cdf0e10cSrcweir             bool    FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny );
84cdf0e10cSrcweir     };
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
87cdf0e10cSrcweir         GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
88cdf0e10cSrcweir             bool const bParent);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     sal_Bool                    getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
91cdf0e10cSrcweir 										, SwPaM& rPam
92cdf0e10cSrcweir 										, com::sun::star::uno::Any *pAny
93cdf0e10cSrcweir                                         , com::sun::star::beans::PropertyState& eState
94cdf0e10cSrcweir                                         , const SwTxtNode* pNode = 0 );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	void 						GetCurPageStyle(SwPaM& rPaM, String &rString);
97cdf0e10cSrcweir 
IsStartOfPara(SwPaM & rUnoCrsr)98cdf0e10cSrcweir 	inline sal_Bool 			IsStartOfPara(SwPaM& rUnoCrsr)
99cdf0e10cSrcweir 										{ return rUnoCrsr.GetPoint()->nContent == 0;}
IsEndOfPara(SwPaM & rUnoCrsr)100cdf0e10cSrcweir 	inline sal_Bool 			IsEndOfPara(SwPaM& rUnoCrsr)
101cdf0e10cSrcweir 										{ return rUnoCrsr.GetCntntNode() &&
102cdf0e10cSrcweir 											rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     void                        resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam);
105cdf0e10cSrcweir 	void 						InsertFile(SwUnoCrsr* pUnoCrsr,
106cdf0e10cSrcweir                                     const String& rURL,
107cdf0e10cSrcweir                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions
108cdf0e10cSrcweir                                     ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	void 						getNumberingProperty(
111cdf0e10cSrcweir 									SwPaM& rPam,
112cdf0e10cSrcweir 									com::sun::star::beans::PropertyState& eState,
113cdf0e10cSrcweir 									com::sun::star::uno::Any *pAny );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	void 						setNumberingProperty(
116cdf0e10cSrcweir 									const com::sun::star::uno::Any& rValue,
117cdf0e10cSrcweir 									SwPaM& rPam);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	sal_Int16 					IsNodeNumStart(
120cdf0e10cSrcweir 									SwPaM& rPam,
121cdf0e10cSrcweir 									com::sun::star::beans::PropertyState& eState);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     sal_Bool    DocInsertStringSplitCR(  SwDoc &rDoc,
124cdf0e10cSrcweir                     const SwPaM &rNewCursor, const String &rText,
125cdf0e10cSrcweir                     const bool bForceExpandHints );
126cdf0e10cSrcweir     void    makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType,
127cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
128cdf0e10cSrcweir                 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     /// @param bTableMode: attributes should be applied to a table selection
132cdf0e10cSrcweir     void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
133cdf0e10cSrcweir                      const SetAttrMode nAttrMode,
134cdf0e10cSrcweir                      const bool bTableMode = false);
135cdf0e10cSrcweir     void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet,
136cdf0e10cSrcweir                      const bool bOnlyTxtAttr = false,
137cdf0e10cSrcweir                      const bool bGetFromChrFmt = true);
138cdf0e10cSrcweir     void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer);
139cdf0e10cSrcweir     SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     void SelectPam(SwPaM & rPam, const bool bExpand);
142cdf0e10cSrcweir     void SetString(SwCursor & rCursor, const ::rtl::OUString & rString);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
145cdf0e10cSrcweir            CreateSortDescriptor(const bool bFromTable);
146cdf0e10cSrcweir     sal_Bool ConvertSortProperties(
147cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
148cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyValue >& rDescriptor,
149cdf0e10cSrcweir             SwSortOptions & rSortOpt);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     /// @param bTableMode: attributes should be applied to a table selection
152cdf0e10cSrcweir     void SetPropertyValue(
153cdf0e10cSrcweir             SwPaM& rPaM,
154cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
155cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName,
156cdf0e10cSrcweir             const ::com::sun::star::uno::Any & rValue,
157cdf0e10cSrcweir             const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT,
158cdf0e10cSrcweir             const bool bTableMode = false)
159cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
160cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyVetoException,
161cdf0e10cSrcweir                 ::com::sun::star::lang::IllegalArgumentException,
162cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
163cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir     ::com::sun::star::uno::Any  GetPropertyValue(
165cdf0e10cSrcweir             SwPaM& rPaM,
166cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
167cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
168cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
169cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
170cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<
172cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyState > GetPropertyStates(
173cdf0e10cSrcweir             SwPaM & rPaM,
174cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
175cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
176cdf0e10cSrcweir                 rPropertyNames,
177cdf0e10cSrcweir             const SwGetPropertyStatesCaller eCaller =
178cdf0e10cSrcweir                 SW_PROPERTY_STATE_CALLER_DEFAULT)
179cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
180cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
181cdf0e10cSrcweir     ::com::sun::star::beans::PropertyState GetPropertyState(
182cdf0e10cSrcweir             SwPaM & rPaM,
183cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
184cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
185cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
186cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir     void SetPropertyToDefault(
188cdf0e10cSrcweir             SwPaM & rPaM,
189cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
190cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
191cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
192cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
193cdf0e10cSrcweir     ::com::sun::star::uno::Any  GetPropertyDefault(
194cdf0e10cSrcweir             SwPaM & rPaM,
195cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
196cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
197cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
198cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
199cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     bool SetPageDesc(
202cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rValue,
203cdf0e10cSrcweir             SwDoc & rDoc, SfxItemSet & rSet);
204cdf0e10cSrcweir     void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM)
205cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException);
206cdf0e10cSrcweir     bool SetCursorPropertyValue(
207cdf0e10cSrcweir             SfxItemPropertySimpleEntry const& rEntry,
208cdf0e10cSrcweir             ::com::sun::star::uno::Any const& rValue,
209cdf0e10cSrcweir             SwPaM & rPam, SfxItemSet & rItemSet)
210cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir } // namespace SwUnoCursorHelper
213cdf0e10cSrcweir 
214cdf0e10cSrcweir #endif
215