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 :
20 : #include <com/sun/star/text/RelOrientation.hpp>
21 : #include <com/sun/star/text/VertOrientation.hpp>
22 : #include <com/sun/star/text/HorizontalAdjust.hpp>
23 : #include <com/sun/star/text/DocumentStatistic.hpp>
24 : #include <com/sun/star/text/HoriOrientation.hpp>
25 : #include <com/sun/star/text/HoriOrientationFormat.hpp>
26 : #include <com/sun/star/text/NotePrintMode.hpp>
27 : #include <com/sun/star/text/SizeType.hpp>
28 : #include <com/sun/star/text/VertOrientationFormat.hpp>
29 : #include <com/sun/star/text/WrapTextMode.hpp>
30 : #include <com/sun/star/text/GraphicCrop.hpp>
31 : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
32 : #include <com/sun/star/drawing/ColorMode.hpp>
33 : #include <svtools/grfmgr.hxx>
34 : #include <swtypes.hxx>
35 : #include <grfatr.hxx>
36 : #include <swunohelper.hxx>
37 :
38 : #include <cmdid.h>
39 : #include <unomid.h>
40 :
41 : using namespace ::com::sun::star;
42 :
43 336 : TYPEINIT1_AUTOFACTORY(SwCropGrf, SfxPoolItem)
44 388 : TYPEINIT1_AUTOFACTORY(SwGammaGrf, SfxPoolItem)
45 :
46 : /******************************************************************************
47 : * Implementierung class SwMirrorGrf
48 : ******************************************************************************/
49 :
50 0 : SfxPoolItem* SwMirrorGrf::Clone( SfxItemPool* ) const
51 : {
52 0 : return new SwMirrorGrf( *this );
53 : }
54 :
55 0 : sal_uInt16 SwMirrorGrf::GetValueCount() const
56 : {
57 0 : return RES_MIRROR_GRAPH_END - RES_MIRROR_GRAPH_BEGIN;
58 : }
59 :
60 0 : int SwMirrorGrf::operator==( const SfxPoolItem& rItem) const
61 : {
62 0 : return SfxEnumItem::operator==(rItem) &&
63 0 : ((SwMirrorGrf&)rItem).IsGrfToggle() == IsGrfToggle();
64 : }
65 :
66 0 : static sal_Bool lcl_IsHoriOnEvenPages(int nEnum, sal_Bool bToggle)
67 : {
68 : sal_Bool bEnum = nEnum == RES_MIRROR_GRAPH_VERT ||
69 0 : nEnum == RES_MIRROR_GRAPH_BOTH;
70 0 : return bEnum != bToggle;
71 : }
72 0 : static sal_Bool lcl_IsHoriOnOddPages(int nEnum)
73 : {
74 : sal_Bool bEnum = nEnum == RES_MIRROR_GRAPH_VERT ||
75 0 : nEnum == RES_MIRROR_GRAPH_BOTH;
76 0 : return bEnum;
77 : }
78 0 : bool SwMirrorGrf::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
79 : {
80 0 : bool bRet = true;
81 : sal_Bool bVal;
82 : // Vertikal und Horizontal sind mal getauscht worden!
83 0 : nMemberId &= ~CONVERT_TWIPS;
84 0 : switch ( nMemberId )
85 : {
86 : case MID_MIRROR_HORZ_EVEN_PAGES:
87 0 : bVal = lcl_IsHoriOnEvenPages(GetValue(), IsGrfToggle());
88 0 : break;
89 : case MID_MIRROR_HORZ_ODD_PAGES:
90 0 : bVal = lcl_IsHoriOnOddPages(GetValue());
91 0 : break;
92 : case MID_MIRROR_VERT:
93 0 : bVal = GetValue() == RES_MIRROR_GRAPH_HOR ||
94 0 : GetValue() == RES_MIRROR_GRAPH_BOTH;
95 0 : break;
96 : default:
97 : OSL_ENSURE( !this, "unknown MemberId" );
98 0 : bRet = false;
99 : }
100 0 : rVal.setValue( &bVal, ::getBooleanCppuType() );
101 0 : return bRet;
102 : }
103 :
104 0 : bool SwMirrorGrf::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
105 : {
106 0 : bool bRet = true;
107 0 : sal_Bool bVal = *(sal_Bool*)rVal.getValue();
108 : // Vertikal und Horizontal sind mal getauscht worden!
109 0 : nMemberId &= ~CONVERT_TWIPS;
110 0 : switch ( nMemberId )
111 : {
112 : case MID_MIRROR_HORZ_EVEN_PAGES:
113 : case MID_MIRROR_HORZ_ODD_PAGES:
114 : {
115 0 : sal_Bool bIsVert = GetValue() == RES_MIRROR_GRAPH_HOR ||
116 0 : GetValue() == RES_MIRROR_GRAPH_BOTH;
117 : sal_Bool bOnOddPages = nMemberId == MID_MIRROR_HORZ_EVEN_PAGES ?
118 0 : lcl_IsHoriOnOddPages(GetValue()) : bVal;
119 : sal_Bool bOnEvenPages = nMemberId == MID_MIRROR_HORZ_ODD_PAGES ?
120 0 : lcl_IsHoriOnEvenPages(GetValue(), IsGrfToggle()) : bVal;
121 : MirrorGraph nEnum = bOnOddPages ?
122 : bIsVert ? RES_MIRROR_GRAPH_BOTH : RES_MIRROR_GRAPH_VERT :
123 0 : bIsVert ? RES_MIRROR_GRAPH_HOR : RES_MIRROR_GRAPH_DONT;
124 0 : sal_Bool bToggle = bOnOddPages != bOnEvenPages;
125 0 : SetValue(static_cast<sal_uInt16>(nEnum));
126 0 : SetGrfToggle( bToggle );
127 : }
128 0 : break;
129 : case MID_MIRROR_VERT:
130 0 : if ( bVal )
131 : {
132 0 : if ( GetValue() == RES_MIRROR_GRAPH_VERT )
133 0 : SetValue( RES_MIRROR_GRAPH_BOTH );
134 0 : else if ( GetValue() != RES_MIRROR_GRAPH_BOTH )
135 0 : SetValue( RES_MIRROR_GRAPH_HOR );
136 : }
137 : else
138 : {
139 0 : if ( GetValue() == RES_MIRROR_GRAPH_BOTH )
140 0 : SetValue( RES_MIRROR_GRAPH_VERT );
141 0 : else if ( GetValue() == RES_MIRROR_GRAPH_HOR )
142 0 : SetValue( RES_MIRROR_GRAPH_DONT );
143 : }
144 0 : break;
145 : default:
146 : OSL_ENSURE( !this, "unknown MemberId" );
147 0 : bRet = false;
148 : }
149 0 : return bRet;
150 : }
151 :
152 :
153 : /******************************************************************************
154 : * Implementierung class SwCropGrf
155 : ******************************************************************************/
156 :
157 10 : SwCropGrf::SwCropGrf()
158 10 : : SvxGrfCrop( RES_GRFATR_CROPGRF )
159 10 : {}
160 :
161 0 : SwCropGrf::SwCropGrf(sal_Int32 nL, sal_Int32 nR, sal_Int32 nT, sal_Int32 nB )
162 0 : : SvxGrfCrop( nL, nR, nT, nB, RES_GRFATR_CROPGRF )
163 0 : {}
164 :
165 0 : SfxPoolItem* SwCropGrf::Clone( SfxItemPool* ) const
166 : {
167 0 : return new SwCropGrf( *this );
168 : }
169 :
170 : // ------------------------------------------------------------------
171 :
172 0 : SfxPoolItem* SwRotationGrf::Clone( SfxItemPool * ) const
173 : {
174 0 : return new SwRotationGrf( GetValue(), aUnrotatedSize );
175 : }
176 :
177 :
178 0 : int SwRotationGrf::operator==( const SfxPoolItem& rCmp ) const
179 : {
180 0 : return SfxUInt16Item::operator==( rCmp ) &&
181 0 : GetUnrotatedSize() == ((SwRotationGrf&)rCmp).GetUnrotatedSize();
182 : }
183 :
184 :
185 0 : bool SwRotationGrf::QueryValue( uno::Any& rVal, sal_uInt8 ) const
186 : {
187 : // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
188 : // where we still want this to be a sal_Int16
189 0 : rVal <<= (sal_Int16)GetValue();
190 0 : return true;
191 : }
192 :
193 0 : bool SwRotationGrf::PutValue( const uno::Any& rVal, sal_uInt8 )
194 : {
195 : // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
196 : // where we still want this to be a sal_Int16
197 0 : sal_Int16 nValue = 0;
198 0 : if (rVal >>= nValue)
199 : {
200 : // sal_uInt16 argument needed
201 0 : SetValue( (sal_uInt16) nValue );
202 0 : return true;
203 : }
204 :
205 : OSL_FAIL( "SwRotationGrf::PutValue - Wrong type!" );
206 0 : return false;
207 : }
208 :
209 : // ------------------------------------------------------------------
210 :
211 17 : SfxPoolItem* SwLuminanceGrf::Clone( SfxItemPool * ) const
212 : {
213 17 : return new SwLuminanceGrf( *this );
214 : }
215 :
216 : // ------------------------------------------------------------------
217 :
218 17 : SfxPoolItem* SwContrastGrf::Clone( SfxItemPool * ) const
219 : {
220 17 : return new SwContrastGrf( *this );
221 : }
222 :
223 : // ------------------------------------------------------------------
224 :
225 0 : SfxPoolItem* SwChannelRGrf::Clone( SfxItemPool * ) const
226 : {
227 0 : return new SwChannelRGrf( *this );
228 : }
229 :
230 : // ------------------------------------------------------------------
231 :
232 0 : SfxPoolItem* SwChannelGGrf::Clone( SfxItemPool * ) const
233 : {
234 0 : return new SwChannelGGrf( *this );
235 : }
236 :
237 : // ------------------------------------------------------------------
238 :
239 0 : SfxPoolItem* SwChannelBGrf::Clone( SfxItemPool * ) const
240 : {
241 0 : return new SwChannelBGrf( *this );
242 : }
243 :
244 : // ------------------------------------------------------------------
245 :
246 10 : SfxPoolItem* SwGammaGrf::Clone( SfxItemPool * ) const
247 : {
248 10 : return new SwGammaGrf( *this );
249 : }
250 :
251 26 : int SwGammaGrf::operator==( const SfxPoolItem& rCmp ) const
252 : {
253 26 : return SfxPoolItem::operator==( rCmp ) &&
254 26 : nValue == ((SwGammaGrf&)rCmp).GetValue();
255 : }
256 :
257 0 : bool SwGammaGrf::QueryValue( uno::Any& rVal, sal_uInt8 ) const
258 : {
259 0 : rVal <<= nValue;
260 0 : return true;
261 : }
262 :
263 0 : bool SwGammaGrf::PutValue( const uno::Any& rVal, sal_uInt8 )
264 : {
265 0 : return rVal >>= nValue;
266 : }
267 :
268 : // ------------------------------------------------------------------
269 :
270 0 : SfxPoolItem* SwInvertGrf::Clone( SfxItemPool * ) const
271 : {
272 0 : return new SwInvertGrf( *this );
273 : }
274 :
275 : // ------------------------------------------------------------------
276 :
277 0 : SfxPoolItem* SwTransparencyGrf::Clone( SfxItemPool * ) const
278 : {
279 0 : return new SwTransparencyGrf( *this );
280 : }
281 : // ------------------------------------------------------------------
282 0 : bool SwTransparencyGrf::QueryValue( uno::Any& rVal,
283 : sal_uInt8 ) const
284 : {
285 : OSL_ENSURE(ISA(SfxByteItem),"Put/QueryValue should be removed!");
286 0 : sal_Int16 nRet = GetValue();
287 : OSL_ENSURE( 0 <= nRet && nRet <= 100, "value out of range" );
288 0 : rVal <<= nRet;
289 0 : return true;
290 : }
291 : // ------------------------------------------------------------------
292 0 : bool SwTransparencyGrf::PutValue( const uno::Any& rVal,
293 : sal_uInt8 )
294 : {
295 : //temporary conversion until this is a SfxInt16Item!
296 : OSL_ENSURE(ISA(SfxByteItem),"Put/QueryValue should be removed!");
297 0 : sal_Int16 nVal = 0;
298 0 : if(!(rVal >>= nVal) || nVal < -100 || nVal > 100)
299 0 : return false;
300 0 : if(nVal < 0)
301 : {
302 : // for compatibility with old documents
303 : // introduce rounding as for SO 6.0 PP2
304 0 : nVal = ( ( nVal * 128 ) - (99/2) ) / 100;
305 0 : nVal += 128;
306 : }
307 : OSL_ENSURE( 0 <= nVal && nVal <= 100, "value out of range" );
308 0 : SetValue(static_cast<sal_uInt8>(nVal));
309 0 : return true;
310 : }
311 :
312 : // ------------------------------------------------------------------
313 :
314 0 : SfxPoolItem* SwDrawModeGrf::Clone( SfxItemPool * ) const
315 : {
316 0 : return new SwDrawModeGrf( *this );
317 : }
318 :
319 0 : sal_uInt16 SwDrawModeGrf::GetValueCount() const
320 : {
321 0 : return GRAPHICDRAWMODE_WATERMARK + 1;
322 : }
323 :
324 0 : bool SwDrawModeGrf::QueryValue( uno::Any& rVal,
325 : sal_uInt8 ) const
326 : {
327 0 : drawing::ColorMode eRet = (drawing::ColorMode)GetEnumValue();
328 0 : rVal <<= eRet;
329 0 : return true;
330 : }
331 :
332 0 : bool SwDrawModeGrf::PutValue( const uno::Any& rVal,
333 : sal_uInt8 )
334 : {
335 0 : sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal );
336 0 : if(eVal >= 0 && eVal <= GRAPHICDRAWMODE_WATERMARK)
337 : {
338 0 : SetEnumValue((sal_uInt16)eVal);
339 0 : return true;
340 : }
341 0 : return false;
342 : }
343 :
344 :
345 :
346 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|