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