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 : #ifndef SW_UNOCRSRHELPER_HXX
20 : #define SW_UNOCRSRHELPER_HXX
21 :
22 : #include <map>
23 :
24 : #include <com/sun/star/beans/XPropertyState.hpp>
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 :
27 : #include <swtypes.hxx>
28 : #include <flyenum.hxx>
29 : #include <pam.hxx>
30 :
31 :
32 : class String;
33 : class SfxItemSet;
34 : class SfxItemPropertySet;
35 : struct SfxItemPropertySimpleEntry;
36 : class SdrObject;
37 : class SwTxtNode;
38 : class SwCursor;
39 : class SwUnoCrsr;
40 : class SwUnoTableCrsr;
41 : class SwFmtColl;
42 : struct SwSortOptions;
43 : class SwDoc;
44 :
45 : namespace sw { namespace mark { class IMark; } }
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 : class XFlatParagraphIterator;
57 : }
58 : }}}
59 :
60 : enum SwGetPropertyStatesCaller
61 : {
62 : SW_PROPERTY_STATE_CALLER_DEFAULT,
63 : SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION,
64 : SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY,
65 : SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
66 : };
67 :
68 : namespace SwUnoCursorHelper
69 : {
70 : // keep Any's mapped by (WhichId << 16 ) + (MemberId)
71 : typedef std::map< sal_uInt32, com::sun::star::uno::Any *> AnyMapHelper_t;
72 363 : class SwAnyMapHelper : public AnyMapHelper_t
73 : {
74 : public:
75 : ~SwAnyMapHelper();
76 :
77 : void SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any& rAny );
78 : bool FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const com::sun::star::uno::Any*& pAny );
79 : };
80 :
81 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
82 : GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
83 : bool const bParent);
84 :
85 : bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
86 : , SwPaM& rPam
87 : , com::sun::star::uno::Any *pAny
88 : , com::sun::star::beans::PropertyState& eState
89 : , const SwTxtNode* pNode = 0 );
90 :
91 : void GetCurPageStyle(SwPaM& rPaM, String &rString);
92 :
93 228 : inline sal_Bool IsStartOfPara(SwPaM& rUnoCrsr)
94 228 : { return rUnoCrsr.GetPoint()->nContent == 0;}
95 283 : inline sal_Bool IsEndOfPara(SwPaM& rUnoCrsr)
96 566 : { return rUnoCrsr.GetCntntNode() &&
97 566 : rUnoCrsr.GetPoint()->nContent == rUnoCrsr.GetCntntNode()->Len();}
98 :
99 : void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam);
100 : void InsertFile(SwUnoCrsr* pUnoCrsr,
101 : const String& rURL,
102 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rOptions
103 : ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException );
104 :
105 : void getNumberingProperty(
106 : SwPaM& rPam,
107 : com::sun::star::beans::PropertyState& eState,
108 : com::sun::star::uno::Any *pAny );
109 :
110 : void setNumberingProperty(
111 : const com::sun::star::uno::Any& rValue,
112 : SwPaM& rPam);
113 :
114 : sal_Int16 IsNodeNumStart(
115 : SwPaM& rPam,
116 : com::sun::star::beans::PropertyState& eState);
117 :
118 : bool DocInsertStringSplitCR( SwDoc &rDoc,
119 : const SwPaM &rNewCursor, const String &rText,
120 : const bool bForceExpandHints );
121 : void makeRedline( SwPaM& rPaM, const OUString& RedlineType,
122 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties )
123 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
124 :
125 :
126 : /// @param bTableMode: attributes should be applied to a table selection
127 : void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
128 : const SetAttrMode nAttrMode,
129 : const bool bTableMode = false);
130 : void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet,
131 : const bool bOnlyTxtAttr = false,
132 : const bool bGetFromChrFmt = true);
133 : void GetTextFromPam(SwPaM & rPam, OUString & rBuffer);
134 : SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional);
135 :
136 : void SelectPam(SwPaM & rPam, const bool bExpand);
137 : void SetString(SwCursor & rCursor, const OUString & rString);
138 :
139 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
140 : CreateSortDescriptor(const bool bFromTable);
141 : sal_Bool ConvertSortProperties(
142 : const ::com::sun::star::uno::Sequence<
143 : ::com::sun::star::beans::PropertyValue >& rDescriptor,
144 : SwSortOptions & rSortOpt);
145 :
146 : /// @param bTableMode: attributes should be applied to a table selection
147 : void SetPropertyValue(
148 : SwPaM& rPaM,
149 : const SfxItemPropertySet & rPropSet,
150 : const OUString & rPropertyName,
151 : const ::com::sun::star::uno::Any & rValue,
152 : const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT,
153 : const bool bTableMode = false)
154 : throw (::com::sun::star::beans::UnknownPropertyException,
155 : ::com::sun::star::beans::PropertyVetoException,
156 : ::com::sun::star::lang::IllegalArgumentException,
157 : ::com::sun::star::lang::WrappedTargetException,
158 : ::com::sun::star::uno::RuntimeException);
159 : /// @param bTableMode: attributes should be applied to a table selection
160 : void SetPropertyValues(
161 : SwPaM& rPaM,
162 : const SfxItemPropertySet & rPropSet,
163 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > &
164 : rPropertyValues,
165 : const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT,
166 : const bool bTableMode = false)
167 : throw (::com::sun::star::beans::UnknownPropertyException,
168 : ::com::sun::star::beans::PropertyVetoException,
169 : ::com::sun::star::lang::IllegalArgumentException,
170 : ::com::sun::star::lang::WrappedTargetException,
171 : ::com::sun::star::uno::RuntimeException);
172 : ::com::sun::star::uno::Any GetPropertyValue(
173 : SwPaM& rPaM,
174 : const SfxItemPropertySet & rPropSet,
175 : const OUString & rPropertyName)
176 : throw (::com::sun::star::beans::UnknownPropertyException,
177 : ::com::sun::star::lang::WrappedTargetException,
178 : ::com::sun::star::uno::RuntimeException);
179 : ::com::sun::star::uno::Sequence<
180 : ::com::sun::star::beans::PropertyState > GetPropertyStates(
181 : SwPaM & rPaM,
182 : const SfxItemPropertySet & rPropSet,
183 : const ::com::sun::star::uno::Sequence< OUString >&
184 : rPropertyNames,
185 : const SwGetPropertyStatesCaller eCaller =
186 : SW_PROPERTY_STATE_CALLER_DEFAULT)
187 : throw (::com::sun::star::beans::UnknownPropertyException,
188 : ::com::sun::star::uno::RuntimeException);
189 : ::com::sun::star::beans::PropertyState GetPropertyState(
190 : SwPaM & rPaM,
191 : const SfxItemPropertySet & rPropSet,
192 : const OUString & rPropertyName)
193 : throw (::com::sun::star::beans::UnknownPropertyException,
194 : ::com::sun::star::uno::RuntimeException);
195 : void SetPropertyToDefault(
196 : SwPaM & rPaM,
197 : const SfxItemPropertySet & rPropSet,
198 : const OUString & rPropertyName)
199 : throw (::com::sun::star::beans::UnknownPropertyException,
200 : ::com::sun::star::uno::RuntimeException);
201 : ::com::sun::star::uno::Any GetPropertyDefault(
202 : SwPaM & rPaM,
203 : const SfxItemPropertySet & rPropSet,
204 : const OUString & rPropertyName)
205 : throw (::com::sun::star::beans::UnknownPropertyException,
206 : ::com::sun::star::lang::WrappedTargetException,
207 : ::com::sun::star::uno::RuntimeException);
208 :
209 : bool SetPageDesc(
210 : const ::com::sun::star::uno::Any& rValue,
211 : SwDoc & rDoc, SfxItemSet & rSet);
212 : void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM)
213 : throw (::com::sun::star::lang::IllegalArgumentException);
214 : bool SetCursorPropertyValue(
215 : SfxItemPropertySimpleEntry const& rEntry,
216 : ::com::sun::star::uno::Any const& rValue,
217 : SwPaM & rPam, SfxItemSet & rItemSet)
218 : throw (::com::sun::star::lang::IllegalArgumentException);
219 :
220 : /// try to get something that can be selected out of the XInterface
221 : /// at most one of the out parameters gets assigned a non-null value
222 : /// o_rpPaM is newly allocated and must be deleted; other parameters not
223 : SW_DLLPUBLIC void GetSelectableFromAny(
224 : ::com::sun::star::uno::Reference<
225 : ::com::sun::star::uno::XInterface> const& xIfc,
226 : SwDoc & rTargetDoc,
227 : SwPaM *& o_rpPaM, std::pair<OUString, FlyCntType> & o_rFrame,
228 : OUString & o_rTableName, SwUnoTableCrsr const*& o_rpTableCursor,
229 : ::sw::mark::IMark const*& o_rpMark,
230 : std::vector<SdrObject *> & o_rSdrObjects);
231 :
232 : ::com::sun::star::uno::Reference<
233 : ::com::sun::star::text::XFlatParagraphIterator>
234 : CreateFlatParagraphIterator(SwDoc &, sal_Int32, bool);
235 :
236 : } // namespace SwUnoCursorHelper
237 :
238 : #endif
239 :
240 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|