xref: /AOO41X/main/sw/inc/unocrsrhelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _UNOCRSRHELPER_HXX
28*cdf0e10cSrcweir #define _UNOCRSRHELPER_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <map>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <swtypes.hxx>
36*cdf0e10cSrcweir #include <pam.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir class String;
40*cdf0e10cSrcweir class SfxItemSet;
41*cdf0e10cSrcweir class SfxItemPropertySet;
42*cdf0e10cSrcweir struct SfxItemPropertySimpleEntry;
43*cdf0e10cSrcweir class SwTxtNode;
44*cdf0e10cSrcweir class SwPaM;
45*cdf0e10cSrcweir class SwCursor;
46*cdf0e10cSrcweir class SwUnoCrsr;
47*cdf0e10cSrcweir class SwFmtColl;
48*cdf0e10cSrcweir struct SwSortOptions;
49*cdf0e10cSrcweir class SwDoc;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace com{ namespace sun{ namespace star{
52*cdf0e10cSrcweir 	namespace uno{
53*cdf0e10cSrcweir 		class Any;
54*cdf0e10cSrcweir 	}
55*cdf0e10cSrcweir     namespace beans{
56*cdf0e10cSrcweir         struct PropertyValue;
57*cdf0e10cSrcweir     }
58*cdf0e10cSrcweir     namespace text {
59*cdf0e10cSrcweir         class XTextContent;
60*cdf0e10cSrcweir     }
61*cdf0e10cSrcweir }}}
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir /* -----------------03.12.98 12:16-------------------
64*cdf0e10cSrcweir  *
65*cdf0e10cSrcweir  * --------------------------------------------------*/
66*cdf0e10cSrcweir enum SwGetPropertyStatesCaller
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_DEFAULT,
69*cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
70*cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
71*cdf0e10cSrcweir     SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
72*cdf0e10cSrcweir };
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir /* -----------------------------14.12.00 15:06--------------------------------
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
77*cdf0e10cSrcweir namespace SwUnoCursorHelper
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     //  keep Any's mapped by (WhichId << 16 ) + (MemberId)
80*cdf0e10cSrcweir     typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t;
81*cdf0e10cSrcweir     class SwAnyMapHelper : public AnyMapHelper_t
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir         public:
84*cdf0e10cSrcweir             ~SwAnyMapHelper();
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             void    SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny );
87*cdf0e10cSrcweir             bool    FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny );
88*cdf0e10cSrcweir     };
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
91*cdf0e10cSrcweir         GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
92*cdf0e10cSrcweir             bool const bParent);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     sal_Bool                    getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
95*cdf0e10cSrcweir 										, SwPaM& rPam
96*cdf0e10cSrcweir 										, com::sun::star::uno::Any *pAny
97*cdf0e10cSrcweir                                         , com::sun::star::beans::PropertyState& eState
98*cdf0e10cSrcweir                                         , const SwTxtNode* pNode = 0 );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	void 						GetCurPageStyle(SwPaM& rPaM, String &rString);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	inline sal_Bool 			IsStartOfPara(SwPaM& rUnoCrsr)
103*cdf0e10cSrcweir 										{ return rUnoCrsr.GetPoint()->nContent == 0;}
104*cdf0e10cSrcweir 	inline sal_Bool 			IsEndOfPara(SwPaM& rUnoCrsr)
105*cdf0e10cSrcweir 										{ return rUnoCrsr.GetCntntNode() &&
106*cdf0e10cSrcweir 											rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();}
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     void                        resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam);
109*cdf0e10cSrcweir 	void 						InsertFile(SwUnoCrsr* pUnoCrsr,
110*cdf0e10cSrcweir                                     const String& rURL,
111*cdf0e10cSrcweir                                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions
112*cdf0e10cSrcweir                                     ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	void 						getNumberingProperty(
115*cdf0e10cSrcweir 									SwPaM& rPam,
116*cdf0e10cSrcweir 									com::sun::star::beans::PropertyState& eState,
117*cdf0e10cSrcweir 									com::sun::star::uno::Any *pAny );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	void 						setNumberingProperty(
120*cdf0e10cSrcweir 									const com::sun::star::uno::Any& rValue,
121*cdf0e10cSrcweir 									SwPaM& rPam);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	sal_Int16 					IsNodeNumStart(
124*cdf0e10cSrcweir 									SwPaM& rPam,
125*cdf0e10cSrcweir 									com::sun::star::beans::PropertyState& eState);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     sal_Bool    DocInsertStringSplitCR(  SwDoc &rDoc,
128*cdf0e10cSrcweir                     const SwPaM &rNewCursor, const String &rText,
129*cdf0e10cSrcweir                     const bool bForceExpandHints );
130*cdf0e10cSrcweir     void    makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType,
131*cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
132*cdf0e10cSrcweir                 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     /// @param bTableMode: attributes should be applied to a table selection
136*cdf0e10cSrcweir     void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
137*cdf0e10cSrcweir                      const SetAttrMode nAttrMode,
138*cdf0e10cSrcweir                      const bool bTableMode = false);
139*cdf0e10cSrcweir     void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet,
140*cdf0e10cSrcweir                      const bool bOnlyTxtAttr = false,
141*cdf0e10cSrcweir                      const bool bGetFromChrFmt = true);
142*cdf0e10cSrcweir     void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer);
143*cdf0e10cSrcweir     SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     void SelectPam(SwPaM & rPam, const bool bExpand);
146*cdf0e10cSrcweir     void SetString(SwCursor & rCursor, const ::rtl::OUString & rString);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
149*cdf0e10cSrcweir            CreateSortDescriptor(const bool bFromTable);
150*cdf0e10cSrcweir     sal_Bool ConvertSortProperties(
151*cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
152*cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyValue >& rDescriptor,
153*cdf0e10cSrcweir             SwSortOptions & rSortOpt);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     /// @param bTableMode: attributes should be applied to a table selection
156*cdf0e10cSrcweir     void SetPropertyValue(
157*cdf0e10cSrcweir             SwPaM& rPaM,
158*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
159*cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName,
160*cdf0e10cSrcweir             const ::com::sun::star::uno::Any & rValue,
161*cdf0e10cSrcweir             const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT,
162*cdf0e10cSrcweir             const bool bTableMode = false)
163*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
164*cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyVetoException,
165*cdf0e10cSrcweir                 ::com::sun::star::lang::IllegalArgumentException,
166*cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
167*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
168*cdf0e10cSrcweir     ::com::sun::star::uno::Any  GetPropertyValue(
169*cdf0e10cSrcweir             SwPaM& rPaM,
170*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
171*cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
172*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
173*cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
174*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
175*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<
176*cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyState > GetPropertyStates(
177*cdf0e10cSrcweir             SwPaM & rPaM,
178*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
179*cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
180*cdf0e10cSrcweir                 rPropertyNames,
181*cdf0e10cSrcweir             const SwGetPropertyStatesCaller eCaller =
182*cdf0e10cSrcweir                 SW_PROPERTY_STATE_CALLER_DEFAULT)
183*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
184*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
185*cdf0e10cSrcweir     ::com::sun::star::beans::PropertyState GetPropertyState(
186*cdf0e10cSrcweir             SwPaM & rPaM,
187*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
188*cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
189*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
190*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
191*cdf0e10cSrcweir     void SetPropertyToDefault(
192*cdf0e10cSrcweir             SwPaM & rPaM,
193*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
194*cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
195*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
196*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
197*cdf0e10cSrcweir     ::com::sun::star::uno::Any  GetPropertyDefault(
198*cdf0e10cSrcweir             SwPaM & rPaM,
199*cdf0e10cSrcweir             const SfxItemPropertySet & rPropSet,
200*cdf0e10cSrcweir             const ::rtl::OUString & rPropertyName)
201*cdf0e10cSrcweir         throw (::com::sun::star::beans::UnknownPropertyException,
202*cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
203*cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException);
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     bool SetPageDesc(
206*cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rValue,
207*cdf0e10cSrcweir             SwDoc & rDoc, SfxItemSet & rSet);
208*cdf0e10cSrcweir     void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM)
209*cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException);
210*cdf0e10cSrcweir     bool SetCursorPropertyValue(
211*cdf0e10cSrcweir             SfxItemPropertySimpleEntry const& rEntry,
212*cdf0e10cSrcweir             ::com::sun::star::uno::Any const& rValue,
213*cdf0e10cSrcweir             SwPaM & rPam, SfxItemSet & rItemSet)
214*cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException);
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir } // namespace SwUnoCursorHelper
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir #endif
219