xref: /trunk/main/sw/inc/unocrsrhelper.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 #ifndef _UNOCRSRHELPER_HXX
24 #define _UNOCRSRHELPER_HXX
25 
26 #include <map>
27 
28 #include <com/sun/star/beans/XPropertyState.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 
31 #include <swtypes.hxx>
32 #include <pam.hxx>
33 
34 
35 class String;
36 class SfxItemSet;
37 class SfxItemPropertySet;
38 struct SfxItemPropertySimpleEntry;
39 class SwTxtNode;
40 class SwPaM;
41 class SwCursor;
42 class SwUnoCrsr;
43 class SwFmtColl;
44 struct SwSortOptions;
45 class SwDoc;
46 
47 namespace com{ namespace sun{ namespace star{
48 	namespace uno{
49 		class Any;
50 	}
51     namespace beans{
52         struct PropertyValue;
53     }
54     namespace text {
55         class XTextContent;
56     }
57 }}}
58 
59 /* -----------------03.12.98 12:16-------------------
60  *
61  * --------------------------------------------------*/
62 enum SwGetPropertyStatesCaller
63 {
64     SW_PROPERTY_STATE_CALLER_DEFAULT,
65     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
66     SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
67     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
68 };
69 
70 /* -----------------------------14.12.00 15:06--------------------------------
71 
72  ---------------------------------------------------------------------------*/
73 namespace SwUnoCursorHelper
74 {
75     //  keep Any's mapped by (WhichId << 16 ) + (MemberId)
76     typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t;
77     class SwAnyMapHelper : public AnyMapHelper_t
78     {
79         public:
80             ~SwAnyMapHelper();
81 
82             void    SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny );
83             bool    FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny );
84     };
85 
86     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
87         GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
88             bool const bParent);
89 
90     sal_Bool                    getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
91 										, SwPaM& rPam
92 										, com::sun::star::uno::Any *pAny
93                                         , com::sun::star::beans::PropertyState& eState
94                                         , const SwTxtNode* pNode = 0 );
95 
96 	void 						GetCurPageStyle(SwPaM& rPaM, String &rString);
97 
IsStartOfPara(SwPaM & rUnoCrsr)98 	inline sal_Bool 			IsStartOfPara(SwPaM& rUnoCrsr)
99 										{ return rUnoCrsr.GetPoint()->nContent == 0;}
IsEndOfPara(SwPaM & rUnoCrsr)100 	inline sal_Bool 			IsEndOfPara(SwPaM& rUnoCrsr)
101 										{ return rUnoCrsr.GetCntntNode() &&
102 											rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();}
103 
104     void                        resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam);
105 	void 						InsertFile(SwUnoCrsr* pUnoCrsr,
106                                     const String& rURL,
107                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions
108                                     ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException );
109 
110 	void 						getNumberingProperty(
111 									SwPaM& rPam,
112 									com::sun::star::beans::PropertyState& eState,
113 									com::sun::star::uno::Any *pAny );
114 
115 	void 						setNumberingProperty(
116 									const com::sun::star::uno::Any& rValue,
117 									SwPaM& rPam);
118 
119 	sal_Int16 					IsNodeNumStart(
120 									SwPaM& rPam,
121 									com::sun::star::beans::PropertyState& eState);
122 
123     sal_Bool    DocInsertStringSplitCR(  SwDoc &rDoc,
124                     const SwPaM &rNewCursor, const String &rText,
125                     const bool bForceExpandHints );
126     void    makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType,
127             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
128                 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
129 
130 
131     /// @param bTableMode: attributes should be applied to a table selection
132     void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
133                      const SetAttrMode nAttrMode,
134                      const bool bTableMode = false);
135     void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet,
136                      const bool bOnlyTxtAttr = false,
137                      const bool bGetFromChrFmt = true);
138     void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer);
139     SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional);
140 
141     void SelectPam(SwPaM & rPam, const bool bExpand);
142     void SetString(SwCursor & rCursor, const ::rtl::OUString & rString);
143 
144     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
145            CreateSortDescriptor(const bool bFromTable);
146     sal_Bool ConvertSortProperties(
147             const ::com::sun::star::uno::Sequence<
148                 ::com::sun::star::beans::PropertyValue >& rDescriptor,
149             SwSortOptions & rSortOpt);
150 
151     /// @param bTableMode: attributes should be applied to a table selection
152     void SetPropertyValue(
153             SwPaM& rPaM,
154             const SfxItemPropertySet & rPropSet,
155             const ::rtl::OUString & rPropertyName,
156             const ::com::sun::star::uno::Any & rValue,
157             const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT,
158             const bool bTableMode = false)
159         throw (::com::sun::star::beans::UnknownPropertyException,
160                 ::com::sun::star::beans::PropertyVetoException,
161                 ::com::sun::star::lang::IllegalArgumentException,
162                 ::com::sun::star::lang::WrappedTargetException,
163                 ::com::sun::star::uno::RuntimeException);
164     ::com::sun::star::uno::Any  GetPropertyValue(
165             SwPaM& rPaM,
166             const SfxItemPropertySet & rPropSet,
167             const ::rtl::OUString & rPropertyName)
168         throw (::com::sun::star::beans::UnknownPropertyException,
169                 ::com::sun::star::lang::WrappedTargetException,
170                 ::com::sun::star::uno::RuntimeException);
171     ::com::sun::star::uno::Sequence<
172                 ::com::sun::star::beans::PropertyState > GetPropertyStates(
173             SwPaM & rPaM,
174             const SfxItemPropertySet & rPropSet,
175             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
176                 rPropertyNames,
177             const SwGetPropertyStatesCaller eCaller =
178                 SW_PROPERTY_STATE_CALLER_DEFAULT)
179         throw (::com::sun::star::beans::UnknownPropertyException,
180                 ::com::sun::star::uno::RuntimeException);
181     ::com::sun::star::beans::PropertyState GetPropertyState(
182             SwPaM & rPaM,
183             const SfxItemPropertySet & rPropSet,
184             const ::rtl::OUString & rPropertyName)
185         throw (::com::sun::star::beans::UnknownPropertyException,
186                 ::com::sun::star::uno::RuntimeException);
187     void SetPropertyToDefault(
188             SwPaM & rPaM,
189             const SfxItemPropertySet & rPropSet,
190             const ::rtl::OUString & rPropertyName)
191         throw (::com::sun::star::beans::UnknownPropertyException,
192                 ::com::sun::star::uno::RuntimeException);
193     ::com::sun::star::uno::Any  GetPropertyDefault(
194             SwPaM & rPaM,
195             const SfxItemPropertySet & rPropSet,
196             const ::rtl::OUString & rPropertyName)
197         throw (::com::sun::star::beans::UnknownPropertyException,
198                 ::com::sun::star::lang::WrappedTargetException,
199                 ::com::sun::star::uno::RuntimeException);
200 
201     bool SetPageDesc(
202             const ::com::sun::star::uno::Any& rValue,
203             SwDoc & rDoc, SfxItemSet & rSet);
204     void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM)
205         throw (::com::sun::star::lang::IllegalArgumentException);
206     bool SetCursorPropertyValue(
207             SfxItemPropertySimpleEntry const& rEntry,
208             ::com::sun::star::uno::Any const& rValue,
209             SwPaM & rPam, SfxItemSet & rItemSet)
210         throw (::com::sun::star::lang::IllegalArgumentException);
211 
212 } // namespace SwUnoCursorHelper
213 
214 #endif
215