1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_UNOCRSRHELPER_HXX
20 #define INCLUDED_SW_INC_UNOCRSRHELPER_HXX
22 #include "swtypes.hxx"
23 #include "flyenum.hxx"
29 class SfxItemPropertySet
;
30 struct SfxItemPropertySimpleEntry
;
35 class SwUnoTableCursor
;
41 namespace sw
{ namespace mark
{ class IMark
; } }
43 namespace com
{ namespace sun
{ namespace star
{
46 enum class PropertyState
;
50 class XFlatParagraphIterator
;
54 enum SwGetPropertyStatesCaller
56 SW_PROPERTY_STATE_CALLER_DEFAULT
,
57 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION
,
58 SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY
,
59 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
62 namespace SwUnoCursorHelper
67 // keep Any's mapped by (WhichId << 16 ) + (MemberId)
68 std::map
<sal_uInt32
, css::uno::Any
> m_Map
;
71 void SetValue( sal_uInt16 nWhichId
, sal_uInt16 nMemberId
, const css::uno::Any
& rAny
);
72 bool FillValue( sal_uInt16 nWhichId
, sal_uInt16 nMemberId
, const css::uno::Any
*& pAny
);
75 css::uno::Reference
< css::text::XTextContent
>
76 GetNestedTextContent(SwTextNode
const & rTextNode
, sal_Int32
const nIndex
,
79 bool getCursorPropertyValue(const SfxItemPropertySimpleEntry
& rEntry
82 , css::beans::PropertyState
& eState
83 , const SwTextNode
* pNode
= nullptr );
85 void GetCurPageStyle(SwPaM
const & rPaM
, OUString
&rString
);
87 inline bool IsStartOfPara(SwPaM
& rUnoCursor
)
88 { return rUnoCursor
.GetPoint()->nContent
== 0;}
89 inline bool IsEndOfPara(SwPaM
& rUnoCursor
)
90 { return rUnoCursor
.GetContentNode() &&
91 rUnoCursor
.GetPoint()->nContent
== rUnoCursor
.GetContentNode()->Len();}
93 void resetCursorPropertyValue(const SfxItemPropertySimpleEntry
& rEntry
, SwPaM
& rPam
);
94 /// @throws css::lang::IllegalArgumentException
95 /// @throws css::io::IOException
96 /// @throws css::uno::RuntimeException
97 void InsertFile(SwUnoCursor
* pUnoCursor
,
99 const css::uno::Sequence
< css::beans::PropertyValue
>& rOptions
);
101 void getNumberingProperty(
103 css::beans::PropertyState
& eState
,
104 css::uno::Any
*pAny
);
106 void setNumberingProperty(
107 const css::uno::Any
& rValue
,
110 sal_Int16
IsNodeNumStart(
112 css::beans::PropertyState
& eState
);
114 bool DocInsertStringSplitCR( SwDoc
&rDoc
,
115 const SwPaM
&rNewCursor
, const OUString
&rText
,
116 const bool bForceExpandHints
);
117 /// @throws css::lang::IllegalArgumentException
118 /// @throws css::uno::RuntimeException
119 void makeRedline( SwPaM
const & rPaM
, const OUString
& RedlineType
,
120 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
);
122 /// @throws css::lang::IllegalArgumentException
123 /// @throws css::uno::RuntimeException
124 void makeTableRowRedline( SwTableLine
& rTableLine
, const OUString
& RedlineType
,
125 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
);
127 /// @throws css::lang::IllegalArgumentException
128 /// @throws css::uno::RuntimeException
129 SW_DLLPUBLIC
void makeTableCellRedline( SwTableBox
& rTableBox
, const OUString
& RedlineType
,
130 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
);
132 /// @param bTableMode: attributes should be applied to a table selection
133 void SetCursorAttr(SwPaM
& rPam
, const SfxItemSet
& rSet
,
134 const SetAttrMode nAttrMode
,
135 const bool bTableMode
= false);
136 void GetCursorAttr(SwPaM
& rPam
, SfxItemSet
& rSet
,
137 const bool bOnlyTextAttr
= false,
138 const bool bGetFromChrFormat
= true);
139 void GetTextFromPam(SwPaM
& rPam
, OUString
& rBuffer
, SwRootFrame
const* pLayout
= nullptr);
140 SwFormatColl
* GetCurTextFormatColl(SwPaM
& rPam
, const bool bConditional
);
142 void SelectPam(SwPaM
& rPam
, const bool bExpand
);
143 void SetString(SwCursor
& rCursor
, const OUString
& rString
);
145 css::uno::Sequence
< css::beans::PropertyValue
>
146 CreateSortDescriptor(const bool bFromTable
);
147 bool ConvertSortProperties(
148 const css::uno::Sequence
< css::beans::PropertyValue
>& rDescriptor
,
149 SwSortOptions
& rSortOpt
);
151 /// @throws css::beans::UnknownPropertyException
152 /// @throws css::beans::PropertyVetoException
153 /// @throws css::lang::IllegalArgumentException
154 /// @throws css::lang::WrappedTargetException
155 /// @throws css::uno::RuntimeException
156 void SetPropertyValue(
158 const SfxItemPropertySet
& rPropSet
,
159 const OUString
& rPropertyName
,
160 const css::uno::Any
& rValue
,
161 const SetAttrMode nAttrMode
= SetAttrMode::DEFAULT
);
162 /// @throws css::beans::UnknownPropertyException
163 /// @throws css::beans::PropertyVetoException
164 /// @throws css::lang::IllegalArgumentException
165 /// @throws css::lang::WrappedTargetException
166 /// @throws css::uno::RuntimeException
167 void SetPropertyValues(
169 const SfxItemPropertySet
& rPropSet
,
170 const css::uno::Sequence
< css::beans::PropertyValue
> &
172 const SetAttrMode nAttrMode
= SetAttrMode::DEFAULT
);
173 /// @throws css::beans::UnknownPropertyException
174 /// @throws css::lang::WrappedTargetException
175 /// @throws css::uno::RuntimeException
176 css::uno::Any
GetPropertyValue(
178 const SfxItemPropertySet
& rPropSet
,
179 const OUString
& rPropertyName
);
180 /// @throws css::beans::UnknownPropertyException
181 /// @throws css::uno::RuntimeException
182 css::uno::Sequence
< css::beans::PropertyState
> GetPropertyStates(
184 const SfxItemPropertySet
& rPropSet
,
185 const css::uno::Sequence
< OUString
>&
187 const SwGetPropertyStatesCaller eCaller
=
188 SW_PROPERTY_STATE_CALLER_DEFAULT
);
189 /// @throws css::beans::UnknownPropertyException
190 /// @throws css::uno::RuntimeException
191 css::beans::PropertyState
GetPropertyState(
193 const SfxItemPropertySet
& rPropSet
,
194 const OUString
& rPropertyName
);
195 /// @throws css::beans::UnknownPropertyException
196 /// @throws css::uno::RuntimeException
197 void SetPropertyToDefault(
199 const SfxItemPropertySet
& rPropSet
,
200 const OUString
& rPropertyName
);
201 /// @throws css::beans::UnknownPropertyException
202 /// @throws css::lang::WrappedTargetException
203 /// @throws css::uno::RuntimeException
204 css::uno::Any
GetPropertyDefault(
206 const SfxItemPropertySet
& rPropSet
,
207 const OUString
& rPropertyName
);
210 const css::uno::Any
& rValue
,
211 SwDoc
& rDoc
, SfxItemSet
& rSet
);
212 /// @throws css::lang::IllegalArgumentException
213 /// @throws css::uno::RuntimeException
214 void SetTextFormatColl(const css::uno::Any
& rAny
, SwPaM
& rPaM
);
215 /// @throws css::lang::IllegalArgumentException
216 /// @throws css::uno::RuntimeException
217 /// @throws css::uno::DeploymentException
218 bool SetCursorPropertyValue(
219 SfxItemPropertySimpleEntry
const& rEntry
,
220 css::uno::Any
const& rValue
,
221 SwPaM
& rPam
, SfxItemSet
& rItemSet
);
223 /// try to get something that can be selected out of the XInterface
224 /// at most one of the out parameters gets assigned a non-null value
225 /// o_rpPaM is newly allocated and must be deleted; other parameters not
226 SW_DLLPUBLIC
void GetSelectableFromAny(
227 css::uno::Reference
<css::uno::XInterface
> const& xIfc
,
229 SwPaM
*& o_rpPaM
, std::pair
<OUString
, FlyCntType
> & o_rFrame
,
230 OUString
& o_rTableName
, SwUnoTableCursor
const*& o_rpTableCursor
,
231 ::sw::mark::IMark
const*& o_rpMark
,
232 std::vector
<SdrObject
*> & o_rSdrObjects
);
234 css::uno::Reference
<css::text::XFlatParagraphIterator
>
235 CreateFlatParagraphIterator(SwDoc
&, sal_Int32
, bool);
237 } // namespace SwUnoCursorHelper
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */