Branch data 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 <string.h>
21 : :
22 : : #include <com/sun/star/awt/Size.hpp>
23 : : #include <com/sun/star/container/XNamed.hpp>
24 : : #include <com/sun/star/drawing/ColorMode.hpp>
25 : : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
26 : : #include <com/sun/star/drawing/XShape.hpp>
27 : : #include <com/sun/star/graphic/XGraphic.hpp>
28 : : #include <com/sun/star/graphic/GraphicProvider.hpp>
29 : : #include <com/sun/star/graphic/XGraphicProvider.hpp>
30 : : #include <com/sun/star/io/XInputStream.hpp>
31 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 : : #include <com/sun/star/table/BorderLine2.hpp>
33 : : #include <com/sun/star/text/GraphicCrop.hpp>
34 : : #include <com/sun/star/text/HoriOrientation.hpp>
35 : : #include <com/sun/star/text/RelOrientation.hpp>
36 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
37 : : #include <com/sun/star/text/VertOrientation.hpp>
38 : : #include <com/sun/star/text/WrapTextMode.hpp>
39 : : #include <com/sun/star/text/XTextContent.hpp>
40 : : #include <com/sun/star/uno/XComponentContext.hpp>
41 : :
42 : : #include <cppuhelper/implbase1.hxx>
43 : : #include <rtl/ustrbuf.hxx>
44 : : #include <rtl/oustringostreaminserter.hxx>
45 : :
46 : : #include <dmapper/DomainMapper.hxx>
47 : : #include <doctok/resourceids.hxx>
48 : : #include <ooxml/resourceids.hxx>
49 : : #include <resourcemodel/ResourceModelHelper.hxx>
50 : :
51 : : #include "ConversionHelper.hxx"
52 : : #include "GraphicHelpers.hxx"
53 : : #include "GraphicImport.hxx"
54 : : #include "PropertyMap.hxx"
55 : : #include "WrapPolygonHandler.hxx"
56 : : #include "dmapperLoggers.hxx"
57 : :
58 : : namespace writerfilter {
59 : :
60 : : using resourcemodel::resolveSprmProps;
61 : :
62 : : namespace dmapper
63 : : {
64 : : using namespace ::std;
65 : : using namespace ::com::sun::star;
66 : :
67 : : class XInputStreamHelper : public cppu::WeakImplHelper1
68 : : < io::XInputStream >
69 : : {
70 : : const sal_uInt8* m_pBuffer;
71 : : const sal_Int32 m_nLength;
72 : : sal_Int32 m_nPosition;
73 : : bool m_bBmp;
74 : :
75 : : const sal_uInt8* m_pBMPHeader; //default BMP-header
76 : : sal_Int32 m_nHeaderLength;
77 : : public:
78 : : XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bBmp);
79 : : ~XInputStreamHelper();
80 : :
81 : : virtual ::sal_Int32 SAL_CALL readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
82 : : virtual ::sal_Int32 SAL_CALL readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
83 : : virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException);
84 : : virtual ::sal_Int32 SAL_CALL available( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException);
85 : : virtual void SAL_CALL closeInput( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException);
86 : : };
87 : :
88 : :
89 : 0 : XInputStreamHelper::XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bBmp) :
90 : : m_pBuffer( buf ),
91 : : m_nLength( len ),
92 : : m_nPosition( 0 ),
93 : 0 : m_bBmp( bBmp )
94 : : {
95 : : static const sal_uInt8 aHeader[] =
96 : : {0x42, 0x4d, 0xe6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
97 : 0 : m_pBMPHeader = aHeader;
98 [ # # ]: 0 : m_nHeaderLength = m_bBmp ? sizeof( aHeader ) / sizeof(sal_uInt8) : 0;
99 : :
100 : 0 : }
101 : :
102 : :
103 : 0 : XInputStreamHelper::~XInputStreamHelper()
104 : : {
105 [ # # ]: 0 : }
106 : :
107 : :
108 : 0 : ::sal_Int32 XInputStreamHelper::readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
109 : : throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
110 : : {
111 : 0 : return readSomeBytes( aData, nBytesToRead );
112 : : }
113 : :
114 : :
115 : 0 : ::sal_Int32 XInputStreamHelper::readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
116 : : throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
117 : : {
118 : 0 : sal_Int32 nRet = 0;
119 [ # # ]: 0 : if( nMaxBytesToRead > 0 )
120 : : {
121 [ # # ]: 0 : if( nMaxBytesToRead > (m_nLength + m_nHeaderLength) - m_nPosition )
122 : 0 : nRet = (m_nLength + m_nHeaderLength) - m_nPosition;
123 : : else
124 : 0 : nRet = nMaxBytesToRead;
125 : 0 : aData.realloc( nRet );
126 : 0 : sal_Int8* pData = aData.getArray();
127 : 0 : sal_Int32 nHeaderRead = 0;
128 [ # # ]: 0 : if( m_nPosition < m_nHeaderLength)
129 : : {
130 : : //copy header content first
131 : 0 : nHeaderRead = m_nHeaderLength - m_nPosition;
132 : 0 : memcpy( pData, m_pBMPHeader + (m_nPosition ), nHeaderRead );
133 : 0 : nRet -= nHeaderRead;
134 : 0 : m_nPosition += nHeaderRead;
135 : : }
136 [ # # ]: 0 : if( nRet )
137 : : {
138 : 0 : memcpy( pData + nHeaderRead, m_pBuffer + (m_nPosition - m_nHeaderLength), nRet );
139 : 0 : m_nPosition += nRet;
140 : : }
141 : : }
142 : 0 : return nRet;
143 : : }
144 : :
145 : :
146 : 0 : void XInputStreamHelper::skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
147 : : {
148 [ # # ][ # # ]: 0 : if( nBytesToSkip < 0 || m_nPosition + nBytesToSkip > (m_nLength + m_nHeaderLength))
149 [ # # ]: 0 : throw io::BufferSizeExceededException();
150 : 0 : m_nPosition += nBytesToSkip;
151 : 0 : }
152 : :
153 : :
154 : 0 : ::sal_Int32 XInputStreamHelper::available( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
155 : : {
156 : 0 : return ( m_nLength + m_nHeaderLength ) - m_nPosition;
157 : : }
158 : :
159 : :
160 : 0 : void XInputStreamHelper::closeInput( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
161 : : {
162 : 0 : }
163 : :
164 : :
165 : : struct GraphicBorderLine
166 : : {
167 : : sal_Int32 nLineWidth;
168 : : sal_Int32 nLineColor;
169 : : sal_Int32 nLineDistance;
170 : : bool bHasShadow;
171 : :
172 : 120 : GraphicBorderLine() :
173 : : nLineWidth(0)
174 : : ,nLineColor(0)
175 : : ,nLineDistance(0)
176 : 120 : ,bHasShadow(false)
177 : 120 : {}
178 : :
179 : : };
180 : :
181 : 30 : class GraphicImport_Impl
182 : : {
183 : : private:
184 : : sal_Int32 nXSize;
185 : : bool bXSizeValid;
186 : : sal_Int32 nYSize;
187 : : bool bYSizeValid;
188 : :
189 : : public:
190 : : GraphicImportType eGraphicImportType;
191 : : DomainMapper& rDomainMapper;
192 : :
193 : : sal_Int32 nHoriScaling;
194 : : sal_Int32 nVertScaling;
195 : : sal_Int32 nLeftPosition;
196 : : sal_Int32 nTopPosition;
197 : : sal_Int32 nRightPosition;
198 : : sal_Int32 nBottomPosition;
199 : : sal_Int32 nLeftCrop;
200 : : sal_Int32 nTopCrop;
201 : : sal_Int32 nRightCrop;
202 : : sal_Int32 nBottomCrop;
203 : :
204 : : bool bUseSimplePos;
205 : : sal_Int32 zOrder;
206 : :
207 : : sal_Int16 nHoriOrient;
208 : : sal_Int16 nHoriRelation;
209 : : bool bPageToggle;
210 : : sal_Int16 nVertOrient;
211 : : sal_Int16 nVertRelation;
212 : : sal_Int32 nWrap;
213 : : bool bOpaque;
214 : : bool bContour;
215 : : bool bContourOutside;
216 : : WrapPolygon::Pointer_t mpWrapPolygon;
217 : : bool bIgnoreWRK;
218 : :
219 : : sal_Int32 nLeftMargin;
220 : : sal_Int32 nRightMargin;
221 : : sal_Int32 nTopMargin;
222 : : sal_Int32 nBottomMargin;
223 : :
224 : : sal_Int32 nContrast;
225 : : sal_Int32 nBrightness;
226 : : double fGamma;
227 : :
228 : : sal_Int32 nFillColor;
229 : :
230 : : drawing::ColorMode eColorMode;
231 : :
232 : : GraphicBorderLine aBorders[4];
233 : : sal_Int32 nCurrentBorderLine;
234 : :
235 : : sal_Int32 nDffType;
236 : : bool bIsGraphic;
237 : : bool bIsBitmap;
238 : : bool bIsTiff;
239 : : sal_Int32 nBitsPerPixel;
240 : :
241 : : bool bHoriFlip;
242 : : bool bVertFlip;
243 : :
244 : : bool bSizeProtected;
245 : : bool bPositionProtected;
246 : :
247 : : bool bInShapeOptionMode;
248 : : sal_Int32 nShapeOptionType;
249 : :
250 : : OUString sName;
251 : : OUString sAlternativeText;
252 : : OUString title;
253 : :
254 : 30 : GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper) :
255 : : nXSize(0)
256 : : ,bXSizeValid(false)
257 : : ,nYSize(0)
258 : : ,bYSizeValid(false)
259 : : ,eGraphicImportType( eImportType )
260 : : ,rDomainMapper( rDMapper )
261 : : ,nHoriScaling(0)
262 : : ,nVertScaling(0)
263 : : ,nLeftPosition(0)
264 : : ,nTopPosition(0)
265 : : ,nRightPosition(0)
266 : : ,nBottomPosition(0)
267 : : ,nLeftCrop(0)
268 : : ,nTopCrop (0)
269 : : ,nRightCrop (0)
270 : : ,nBottomCrop(0)
271 : : ,bUseSimplePos(false)
272 : : ,zOrder(-1)
273 : : ,nHoriOrient( text::HoriOrientation::NONE )
274 : : ,nHoriRelation( text::RelOrientation::FRAME )
275 : : ,bPageToggle( false )
276 : : ,nVertOrient( text::VertOrientation::NONE )
277 : : ,nVertRelation( text::RelOrientation::FRAME )
278 : : ,nWrap(0)
279 : : ,bOpaque( true )
280 : : ,bContour(false)
281 : : ,bContourOutside(true)
282 : : ,bIgnoreWRK(true)
283 : : ,nLeftMargin(319)
284 : : ,nRightMargin(319)
285 : : ,nTopMargin(0)
286 : : ,nBottomMargin(0)
287 : : ,nContrast(0)
288 : : ,nBrightness(0)
289 : : ,fGamma( -1.0 )
290 : : ,nFillColor( 0xffffffff )
291 : : ,eColorMode( drawing::ColorMode_STANDARD )
292 : : ,nCurrentBorderLine(BORDER_TOP)
293 : : ,nDffType( 0 )
294 : : ,bIsGraphic(false)
295 : : ,bIsBitmap(false)
296 : : ,bIsTiff(false)
297 : : ,nBitsPerPixel(0)
298 : : ,bHoriFlip(false)
299 : : ,bVertFlip(false)
300 : : ,bSizeProtected(false)
301 : : ,bPositionProtected(false)
302 [ + + ]: 150 : ,bInShapeOptionMode(false)
303 : 30 : {}
304 : :
305 : 30 : void setXSize(sal_Int32 _nXSize)
306 : : {
307 : 30 : nXSize = _nXSize;
308 : 30 : bXSizeValid = true;
309 : 30 : }
310 : :
311 : 57 : sal_uInt32 getXSize() const
312 : : {
313 : 57 : return nXSize;
314 : : }
315 : :
316 : 3 : bool isXSizeValid() const
317 : : {
318 : 3 : return bXSizeValid;
319 : : }
320 : :
321 : 30 : void setYSize(sal_Int32 _nYSize)
322 : : {
323 : 30 : nYSize = _nYSize;
324 : 30 : bYSizeValid = true;
325 : 30 : }
326 : :
327 : 57 : sal_uInt32 getYSize() const
328 : : {
329 : 57 : return nYSize;
330 : : }
331 : :
332 : 3 : bool isYSizeValis () const
333 : : {
334 : 3 : return bYSizeValid;
335 : : }
336 : : };
337 : :
338 : :
339 : 30 : GraphicImport::GraphicImport(uno::Reference < uno::XComponentContext > xComponentContext,
340 : : uno::Reference< lang::XMultiServiceFactory > xTextFactory,
341 : : DomainMapper& rDMapper,
342 : : GraphicImportType eImportType )
343 : : : LoggedProperties(dmapper_logger, "GraphicImport")
344 : : , LoggedTable(dmapper_logger, "GraphicImport")
345 : : , LoggedStream(dmapper_logger, "GraphicImport")
346 [ + - ]: 30 : , m_pImpl( new GraphicImport_Impl( eImportType, rDMapper ))
347 : : , m_xComponentContext( xComponentContext )
348 [ + - ][ + - ]: 60 : , m_xTextFactory( xTextFactory)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
349 : : {
350 : 30 : }
351 : :
352 : :
353 [ + - ][ + - ]: 30 : GraphicImport::~GraphicImport()
354 : : {
355 [ + - ][ + - ]: 30 : delete m_pImpl;
356 [ - + ]: 60 : }
357 : :
358 : 12 : void GraphicImport::handleWrapTextValue(sal_uInt32 nVal)
359 : : {
360 [ + - - + : 12 : switch (nVal)
- ]
361 : : {
362 : : case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides: // 90920;
363 : 3 : m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
364 : 3 : break;
365 : : case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left: // 90921;
366 : 0 : m_pImpl->nWrap = text::WrapTextMode_LEFT;
367 : 0 : break;
368 : : case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right: // 90922;
369 : 0 : m_pImpl->nWrap = text::WrapTextMode_RIGHT;
370 : 0 : break;
371 : : case NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest: // 90923;
372 : 9 : m_pImpl->nWrap = text::WrapTextMode_DYNAMIC;
373 : 9 : break;
374 : : default:;
375 : : }
376 : 12 : }
377 : :
378 : :
379 : :
380 : 309 : void GraphicImport::lcl_attribute(Id nName, Value & val)
381 : : {
382 : 309 : sal_Int32 nIntValue = val.getInt();
383 [ - - - - : 309 : switch( nName )
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - + - -
+ + - + -
- + + + +
+ + + + -
- + + + -
+ ]
384 : : {
385 : 0 : case NS_rtf::LN_LCB: break;//byte count
386 : 0 : case NS_rtf::LN_CBHEADER: break;//ignored
387 : : case NS_rtf::LN_MFP: //MetafilePict
388 : : case NS_rtf::LN_DffRecord: //dff record - expands to an sprm which expands to ...
389 : : case NS_rtf::LN_shpopt: //shape options
390 : : case NS_rtf::LN_shpfbse: //BLIP store entry
391 : : case NS_rtf::LN_BRCTOP: //top border
392 : : case NS_rtf::LN_BRCLEFT: //left border
393 : : case NS_rtf::LN_BRCBOTTOM: //bottom border
394 : : case NS_rtf::LN_BRCRIGHT: //right border
395 : : case NS_rtf::LN_shape: //shape
396 : : case NS_rtf::LN_blip: //the binary graphic data in a shape
397 : : {
398 [ # # # # : 0 : switch(nName)
# # ]
399 : : {
400 : : case NS_rtf::LN_BRCTOP: //top border
401 : 0 : m_pImpl->nCurrentBorderLine = BORDER_TOP;
402 : 0 : break;
403 : : case NS_rtf::LN_BRCLEFT: //left border
404 : 0 : m_pImpl->nCurrentBorderLine = BORDER_LEFT;
405 : 0 : break;
406 : : case NS_rtf::LN_BRCBOTTOM: //bottom border
407 : 0 : m_pImpl->nCurrentBorderLine = BORDER_BOTTOM;
408 : 0 : break;
409 : : case NS_rtf::LN_BRCRIGHT: //right border
410 : 0 : m_pImpl->nCurrentBorderLine = BORDER_RIGHT;
411 : 0 : break;
412 : : case NS_rtf::LN_shpopt:
413 : 0 : m_pImpl->bInShapeOptionMode = true;
414 : 0 : break;
415 : : default:;
416 : : }
417 [ # # ]: 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties();
418 [ # # ]: 0 : if( pProperties.get())
419 : : {
420 [ # # ]: 0 : pProperties->resolve(*this);
421 : : }
422 [ # # ]: 0 : switch(nName)
423 : : {
424 : : case NS_rtf::LN_shpopt:
425 : 0 : m_pImpl->bInShapeOptionMode = false;
426 : 0 : break;
427 : : default:;
428 [ # # ]: 0 : }
429 : : }
430 : 0 : break;
431 : : case NS_rtf::LN_payload :
432 : : {
433 [ # # ]: 0 : writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = val.getBinary();
434 [ # # ]: 0 : if( pPictureData.get())
435 [ # # ][ # # ]: 0 : pPictureData->resolve(*this);
436 : : }
437 : 0 : break;
438 : : case NS_rtf::LN_BM_RCWINMF: //windows bitmap structure - if it's a bitmap
439 : 0 : break;
440 : : case NS_rtf::LN_DXAGOAL: //x-size in twip
441 : : case NS_rtf::LN_DYAGOAL: //y-size in twip
442 : 0 : break;
443 : : case NS_rtf::LN_MX:
444 : 0 : m_pImpl->nHoriScaling = nIntValue;
445 : 0 : break;// hori scaling in 0.001%
446 : : case NS_rtf::LN_MY:
447 : 0 : m_pImpl->nVertScaling = nIntValue;
448 : 0 : break;// vert scaling in 0.001%
449 : : case NS_rtf::LN_DXACROPLEFT:
450 : 0 : m_pImpl->nLeftCrop = ConversionHelper::convertTwipToMM100(nIntValue);
451 : 0 : break;// left crop in twips
452 : : case NS_rtf::LN_DYACROPTOP:
453 : 0 : m_pImpl->nTopCrop = ConversionHelper::convertTwipToMM100(nIntValue);
454 : 0 : break;// top crop in twips
455 : : case NS_rtf::LN_DXACROPRIGHT:
456 : 0 : m_pImpl->nRightCrop = ConversionHelper::convertTwipToMM100(nIntValue);
457 : 0 : break;// right crop in twips
458 : : case NS_rtf::LN_DYACROPBOTTOM:
459 : 0 : m_pImpl->nBottomCrop = ConversionHelper::convertTwipToMM100(nIntValue);
460 : 0 : break;// bottom crop in twips
461 : : case NS_rtf::LN_BRCL:
462 : 0 : break;//border type - legacy -
463 : : case NS_rtf::LN_FFRAMEEMPTY:
464 : 0 : break;// picture consists of a single frame
465 : : case NS_rtf::LN_FBITMAP:
466 : 0 : m_pImpl->bIsBitmap = nIntValue > 0 ? true : false;
467 : 0 : break;//1 if it's a bitmap ???
468 : : case NS_rtf::LN_FDRAWHATCH:
469 : 0 : break;//1 if it's an active OLE object
470 : : case NS_rtf::LN_FERROR:
471 : 0 : break;// 1 if picture is an error message
472 : : case NS_rtf::LN_BPP:
473 : 0 : m_pImpl->nBitsPerPixel = nIntValue;
474 : 0 : break;//bits per pixel 0 - unknown, 1- mono, 4 - VGA
475 : :
476 : : case NS_rtf::LN_DXAORIGIN: //horizontal offset of hand annotation origin
477 : : case NS_rtf::LN_DYAORIGIN: //vertical offset of hand annotation origin
478 : 0 : break;
479 : 0 : case NS_rtf::LN_CPROPS:break;// unknown - ignored
480 : : //metafilepict
481 : : case NS_rtf::LN_MM:
482 : :
483 : 0 : break; //mapmode
484 : : case NS_rtf::LN_XEXT:
485 : 15 : m_pImpl->setXSize(nIntValue);
486 : 15 : break; // x-size
487 : : case NS_rtf::LN_YEXT:
488 : 15 : m_pImpl->setYSize(nIntValue);
489 : 15 : break; // y-size
490 : 0 : case NS_rtf::LN_HMF: break; //identifier - ignored
491 : :
492 : : //sprm 0xf004 and 0xf008, 0xf00b
493 : : case NS_rtf::LN_dfftype://
494 : 0 : m_pImpl->nDffType = nIntValue;
495 : 0 : break;
496 : : case NS_rtf::LN_dffinstance:
497 : : //todo: does this still work for PICF?
498 : : //in case of LN_dfftype == 0xf01f the instance contains the bitmap type:
499 [ # # ]: 0 : if(m_pImpl->nDffType == 0xf01f)
500 [ # # # # : 0 : switch( nIntValue )
# ]
501 : : {
502 : : case 0x216 : // Metafile header then compressed WMF
503 : :
504 : : case 0x3D4 : // Metafile header then compressed EMF
505 : :
506 : : case 0x542 : // Metafile hd. then compressed PICT
507 : :
508 : : {
509 : :
510 : : }
511 : :
512 : 0 : break;
513 : :
514 : 0 : case 0x46A : break;// One byte tag then JPEG (= JFIF) data
515 : :
516 : 0 : case 0x6E0 : break;// One byte tag then PNG data
517 : :
518 : 0 : case 0x7A8 : m_pImpl->bIsBitmap = true;
519 : 0 : break;
520 : :
521 : : }
522 : 0 : break;
523 : : case NS_rtf::LN_dffversion:// ignored
524 : 0 : break;
525 : :
526 : : //sprm 0xf008
527 : : case NS_rtf::LN_shptype:
528 : 0 : break;
529 : : case NS_rtf::LN_shpid:
530 : 0 : break;
531 : : case NS_rtf::LN_shpfGroup:
532 : 0 : break;// This shape is a group shape
533 : : case NS_rtf::LN_shpfChild:
534 : 0 : break;// Not a top-level shape
535 : : case NS_rtf::LN_shpfPatriarch:
536 : 0 : break;// This is the topmost group shape. Exactly one of these per drawing.
537 : : case NS_rtf::LN_shpfDeleted:
538 : 0 : break;// The shape has been deleted
539 : : case NS_rtf::LN_shpfOleShape:
540 : 0 : break;// The shape is an OLE object
541 : : case NS_rtf::LN_shpfHaveMaster:
542 : 0 : break;// Shape has a hspMaster property
543 : : case NS_rtf::LN_shpfFlipH: // Shape is flipped horizontally
544 : 0 : m_pImpl->bHoriFlip = nIntValue ? true : false;
545 : 0 : break;
546 : : case NS_rtf::LN_shpfFlipV: // Shape is flipped vertically
547 : 0 : m_pImpl->bVertFlip = nIntValue ? true : false;
548 : 0 : break;
549 : : case NS_rtf::LN_shpfConnector:
550 : 0 : break;// Connector type of shape
551 : : case NS_rtf::LN_shpfHaveAnchor:
552 : 0 : break;// Shape has an anchor of some kind
553 : : case NS_rtf::LN_shpfBackground:
554 : 0 : break;// Background shape
555 : : case NS_rtf::LN_shpfHaveSpt:
556 : 0 : break;// Shape has a shape type property
557 : : case NS_rtf::LN_shptypename:
558 : 0 : break;// shape type name
559 : : case NS_rtf::LN_shppid:
560 : 0 : m_pImpl->nShapeOptionType = nIntValue;
561 : 0 : break; //type of shape option
562 : : case NS_rtf::LN_shpfBid:
563 : 0 : break; //ignored
564 : : case NS_rtf::LN_shpfComplex:
565 : 0 : break;
566 : : case NS_rtf::LN_shpop:
567 : : {
568 [ # # ]: 0 : if(NS_dff::LN_shpwzDescription != sal::static_int_cast<Id>(m_pImpl->nShapeOptionType) )
569 : 0 : ProcessShapeOptions( val );
570 : : }
571 : 0 : break;
572 : : case NS_rtf::LN_shpname:
573 : 0 : break;
574 : : case NS_rtf::LN_shpvalue:
575 : : {
576 [ # # ]: 0 : if( NS_dff::LN_shpwzDescription == sal::static_int_cast<Id>(m_pImpl->nShapeOptionType) )
577 : 0 : ProcessShapeOptions( val );
578 : : }
579 : 0 : break;
580 : :
581 : : //BLIP store entry
582 : : case NS_rtf::LN_shpbtWin32:
583 : 0 : break;
584 : : case NS_rtf::LN_shpbtMacOS:
585 : 0 : break;
586 : : case NS_rtf::LN_shprgbUid:
587 : 0 : break;
588 : : case NS_rtf::LN_shptag:
589 : 0 : break;
590 : : case NS_rtf::LN_shpsize:
591 : 0 : break;
592 : : case NS_rtf::LN_shpcRef:
593 : 0 : break;
594 : : case NS_rtf::LN_shpfoDelay:
595 : 0 : break;
596 : : case NS_rtf::LN_shpusage:
597 : 0 : break;
598 : : case NS_rtf::LN_shpcbName:
599 : 0 : break;
600 : : case NS_rtf::LN_shpunused2:
601 : 0 : break;
602 : : case NS_rtf::LN_shpunused3:
603 : 0 : break;
604 : :
605 : : //border properties
606 : : case NS_rtf::LN_shpblipbname :
607 : 0 : break;
608 : :
609 : : case NS_rtf::LN_DPTLINEWIDTH: // 0x1759
610 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineWidth = nIntValue;
611 : 0 : break;
612 : : case NS_rtf::LN_BRCTYPE: // 0x175a
613 : : //graphic borders don't support different line types
614 : 0 : break;
615 : : case NS_rtf::LN_ICO: // 0x175b
616 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineColor = ConversionHelper::ConvertColor( nIntValue );
617 : 0 : break;
618 : : case NS_rtf::LN_DPTSPACE: // 0x175c
619 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineDistance = nIntValue;
620 : 0 : break;
621 : : case NS_rtf::LN_FSHADOW: // 0x175d
622 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].bHasShadow = nIntValue ? true : false;
623 : 0 : break;
624 : : case NS_rtf::LN_FFRAME: // ignored
625 : : case NS_rtf::LN_UNUSED2_15: // ignored
626 : 0 : break;
627 : :
628 : : case NS_rtf::LN_SPID:
629 : 0 : break;
630 : : case NS_rtf::LN_XALEFT:
631 : 0 : m_pImpl->nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue);
632 : 0 : break; //left position
633 : : case NS_rtf::LN_YATOP:
634 : 0 : m_pImpl->nTopPosition = ConversionHelper::convertTwipToMM100(nIntValue);
635 : 0 : break; //top position
636 : : case NS_rtf::LN_XARIGHT:
637 : 0 : m_pImpl->nRightPosition = ConversionHelper::convertTwipToMM100(nIntValue);
638 : 0 : break; //right position
639 : : case NS_rtf::LN_YABOTTOM:
640 : 0 : m_pImpl->nBottomPosition = ConversionHelper::convertTwipToMM100(nIntValue);
641 : 0 : break;//bottom position
642 : : case NS_rtf::LN_FHDR:
643 : : case NS_rtf::LN_XAlign:
644 [ # # ][ # # ]: 0 : if( nIntValue < 6 && nIntValue > 0 )
645 : : {
646 : : static const sal_Int16 aHoriOrientTab[ 6 ] =
647 : : {
648 : : text::HoriOrientation::NONE,
649 : : text::HoriOrientation::LEFT,
650 : : text::HoriOrientation::CENTER,
651 : : text::HoriOrientation::RIGHT,
652 : : text::HoriOrientation::INSIDE,
653 : : text::HoriOrientation::OUTSIDE
654 : : };
655 : 0 : m_pImpl->nHoriOrient = aHoriOrientTab[nIntValue];
656 : 0 : m_pImpl->bPageToggle = nIntValue > 3;
657 : : }
658 : 0 : break;
659 : : case NS_rtf::LN_YAlign:
660 [ # # ][ # # ]: 0 : if( nIntValue < 6 && nIntValue > 0)
661 : : {
662 : : static const sal_Int16 aVertOrientTab[ 6 ] =
663 : : {
664 : : text::VertOrientation::NONE, // From Top position
665 : : text::VertOrientation::TOP, // top
666 : : text::VertOrientation::CENTER, // centered
667 : : text::VertOrientation::BOTTOM, // bottom
668 : : text::VertOrientation::LINE_TOP, // inside (obscure)
669 : : text::VertOrientation::LINE_BOTTOM // outside (obscure)
670 : : };
671 : : static const sal_Int16 aToLineVertOrientTab[ 6 ] =
672 : : {
673 : : text::VertOrientation::NONE, // below
674 : : text::VertOrientation::LINE_BOTTOM, // top
675 : : text::VertOrientation::LINE_CENTER, // centered
676 : : text::VertOrientation::LINE_TOP, // bottom
677 : : text::VertOrientation::LINE_BOTTOM, // inside (obscure)
678 : : text::VertOrientation::LINE_TOP // outside (obscure)
679 : : };
680 : : m_pImpl->nVertOrient = m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE ?
681 [ # # ]: 0 : aToLineVertOrientTab[nIntValue] : aVertOrientTab[nIntValue];
682 : : }
683 : 0 : break;
684 : 0 : case NS_rtf::LN_LayoutInTableCell: break; //currently unknown
685 : : case NS_rtf::LN_XRelTo:
686 : : case NS_rtf::LN_BX: //hori orient relation
687 [ # # # # ]: 0 : switch( nIntValue )
688 : : {
689 : 0 : case 0: m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
690 : 0 : case 1: m_pImpl->nHoriRelation = text::RelOrientation::PAGE_FRAME; break;
691 : 0 : case 2: m_pImpl->nHoriRelation = text::RelOrientation::FRAME; break;
692 : : //case :
693 : 0 : default:m_pImpl->nHoriRelation = text::RelOrientation::CHAR;
694 : : }
695 : 0 : break;
696 : : case NS_rtf::LN_YRelTo:
697 : : case NS_rtf::LN_BY: //vert orient relation
698 [ # # # # ]: 0 : switch( nIntValue )
699 : : {
700 : 0 : case 0: m_pImpl->nVertRelation = text::RelOrientation::PAGE_PRINT_AREA; break;
701 : 0 : case 1: m_pImpl->nVertRelation = text::RelOrientation::PAGE_FRAME; break;
702 : 0 : case 2: m_pImpl->nVertRelation = text::RelOrientation::FRAME; break;
703 : : //case :
704 : 0 : default:m_pImpl->nVertRelation = text::RelOrientation::TEXT_LINE;
705 : : }
706 : :
707 : 0 : break;
708 : : case NS_rtf::LN_WR: //wrapping
709 [ # # # # : 0 : switch( nIntValue )
# # # ]
710 : : {
711 : : case 0: //0 like 2, but doesn't require absolute object
712 : 0 : m_pImpl->bIgnoreWRK = false;
713 : : case 2: //2 wrap around absolute object
714 : 0 : m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
715 : 0 : break;
716 : : case 1: //1 no text next to shape
717 : 0 : m_pImpl->nWrap = text::WrapTextMode_NONE;
718 : 0 : break;
719 : : case 3: //3 wrap as if no object present
720 : 0 : m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
721 : 0 : break;
722 : : case 4: //4 wrap tightly around object
723 : 0 : m_pImpl->bIgnoreWRK = false;
724 : : case 5: //5 wrap tightly, but allow holes
725 : 0 : m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
726 : 0 : m_pImpl->bContour = true;
727 : 0 : break;
728 : : default:;
729 : : }
730 : 0 : break;
731 : : case NS_rtf::LN_WRK:
732 [ # # ]: 0 : if( !m_pImpl->bIgnoreWRK )
733 [ # # # # : 0 : switch( nIntValue )
# ]
734 : : {
735 : : case 0: //0 like 2, but doesn't require absolute object
736 : : case 2: //2 wrap around absolute object
737 : 0 : m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
738 : 0 : break;
739 : : case 1: //1 no text next to shape
740 : 0 : m_pImpl->nWrap = text::WrapTextMode_NONE;
741 : 0 : break;
742 : : case 3: //3 wrap as if no object present
743 : 0 : m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
744 : 0 : break;
745 : : case 4: //4 wrap tightly around object
746 : : case 5: //5 wrap tightly, but allow holes
747 : 0 : m_pImpl->nWrap = text::WrapTextMode_PARALLEL;
748 : 0 : m_pImpl->bContour = true;
749 : 0 : break;
750 : : default:;
751 : : }
752 : 0 : break;
753 : : case NS_rtf::LN_FRCASIMPLE:
754 : : case NS_rtf::LN_FBELOWTEXT:
755 : : case NS_rtf::LN_FANCHORLOCK:
756 : : case NS_rtf::LN_CTXBX:
757 : 0 : break;
758 : : case NS_rtf::LN_shptxt:
759 : : //todo: text content
760 : 0 : break;
761 : 0 : case NS_rtf::LN_dffheader: break;
762 : : case NS_ooxml::LN_CT_PositiveSize2D_cx:// 90407;
763 : : case NS_ooxml::LN_CT_PositiveSize2D_cy:// 90408;
764 : : {
765 : 30 : sal_Int32 nDim = ConversionHelper::convertEMUToMM100( nIntValue );
766 [ + + ]: 30 : if( nName == NS_ooxml::LN_CT_PositiveSize2D_cx )
767 : 15 : m_pImpl->setXSize(nDim);
768 : : else
769 : 15 : m_pImpl->setYSize(nDim);
770 : : }
771 : 30 : break;
772 : : case NS_ooxml::LN_CT_EffectExtent_l:// 90907;
773 : : case NS_ooxml::LN_CT_EffectExtent_t:// 90908;
774 : : case NS_ooxml::LN_CT_EffectExtent_r:// 90909;
775 : : case NS_ooxml::LN_CT_EffectExtent_b:// 90910;
776 : : //todo: extends the wrapping size of the object, e.g. if shadow is added
777 : 0 : break;
778 : : case NS_ooxml::LN_CT_NonVisualDrawingProps_id:// 90650;
779 : : //id of the object - ignored
780 : 0 : break;
781 : : case NS_ooxml::LN_CT_NonVisualDrawingProps_name:// 90651;
782 : : //name of the object
783 : 15 : m_pImpl->sName = val.getString();
784 : 15 : break;
785 : : case NS_ooxml::LN_CT_NonVisualDrawingProps_descr:// 90652;
786 : : //alternative text
787 : 12 : m_pImpl->sAlternativeText = val.getString();
788 : 12 : break;
789 : : case NS_ooxml::LN_CT_NonVisualDrawingProps_title:
790 : : //alternative text
791 : 0 : m_pImpl->title = val.getString();
792 : 0 : break;
793 : : case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
794 : : //disallow aspect ratio change - ignored
795 : 12 : break;
796 : : case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noMove:// 90645;
797 : 0 : m_pImpl->bPositionProtected = true;
798 : 0 : break;
799 : : case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noResize: // 90646;
800 : 0 : m_pImpl->bSizeProtected = true;
801 : 0 : break;
802 : : case NS_ooxml::LN_CT_Anchor_distT: // 90983;
803 : : case NS_ooxml::LN_CT_Anchor_distB: // 90984;
804 : : case NS_ooxml::LN_CT_Anchor_distL: // 90985;
805 : : case NS_ooxml::LN_CT_Anchor_distR: // 90986;
806 : : {
807 : : //redirect to shape option processing
808 [ + + + + : 48 : switch( nName )
- ]
809 : : {
810 : : case NS_ooxml::LN_CT_Anchor_distT: // 90983;
811 : 12 : m_pImpl->nShapeOptionType = NS_dff::LN_shpdyWrapDistTop;
812 : 12 : break;
813 : : case NS_ooxml::LN_CT_Anchor_distB: // 90984;
814 : 12 : m_pImpl->nShapeOptionType = NS_dff::LN_shpdyWrapDistBottom;
815 : 12 : break;
816 : : case NS_ooxml::LN_CT_Anchor_distL: // 90985;
817 : 12 : m_pImpl->nShapeOptionType = NS_dff::LN_shpdxWrapDistLeft;
818 : 12 : break;
819 : : case NS_ooxml::LN_CT_Anchor_distR: // 90986;
820 : 12 : m_pImpl->nShapeOptionType = NS_dff::LN_shpdxWrapDistRight;
821 : 12 : break;
822 : : //m_pImpl->nShapeOptionType = NS_dff::LN_shpcropFromTop
823 : : default: ;
824 : : }
825 : 48 : ProcessShapeOptions(val);
826 : : }
827 : 48 : break;
828 : : case NS_ooxml::LN_CT_Anchor_simplePos_attr: // 90987;
829 : 12 : m_pImpl->bUseSimplePos = nIntValue > 0;
830 : 12 : break;
831 : : case NS_ooxml::LN_CT_Anchor_relativeHeight: // 90988;
832 : 12 : m_pImpl->zOrder = nIntValue;
833 : 12 : break;
834 : : case NS_ooxml::LN_CT_Anchor_behindDoc: // 90989; - in background
835 [ - + ]: 12 : if( nIntValue > 0 )
836 : 0 : m_pImpl->bOpaque = false;
837 : 12 : break;
838 : : case NS_ooxml::LN_CT_Anchor_locked: // 90990; - ignored
839 : : case NS_ooxml::LN_CT_Anchor_layoutInCell: // 90991; - ignored
840 : : case NS_ooxml::LN_CT_Anchor_hidden: // 90992; - ignored
841 : 24 : break;
842 : : case NS_ooxml::LN_CT_Anchor_allowOverlap: // 90993;
843 : : //enable overlapping - ignored
844 : 12 : break;
845 : : case NS_ooxml::LN_CT_Point2D_x: // 90405;
846 : 12 : m_pImpl->nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue);
847 : 12 : m_pImpl->nHoriRelation = text::RelOrientation::PAGE_FRAME;
848 : 12 : m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
849 : 12 : break;
850 : : case NS_ooxml::LN_CT_Point2D_y: // 90406;
851 : 12 : m_pImpl->nTopPosition = ConversionHelper::convertTwipToMM100(nIntValue);
852 : 12 : m_pImpl->nVertRelation = text::RelOrientation::PAGE_FRAME;
853 : 12 : m_pImpl->nVertOrient = text::VertOrientation::NONE;
854 : 12 : break;
855 : : case NS_ooxml::LN_CT_WrapTight_wrapText: // 90934;
856 : 0 : m_pImpl->bContour = true;
857 : 0 : m_pImpl->bContourOutside = true;
858 : :
859 : 0 : handleWrapTextValue(val.getInt());
860 : :
861 : 0 : break;
862 : : case NS_ooxml::LN_CT_WrapThrough_wrapText:
863 : : /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */
864 : 0 : m_pImpl->bContour = true;
865 : 0 : m_pImpl->bContourOutside = false;
866 : :
867 : 0 : handleWrapTextValue(val.getInt());
868 : :
869 : 0 : break;
870 : : case NS_ooxml::LN_CT_WrapSquare_wrapText: //90928;
871 : : /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */
872 : :
873 : 12 : handleWrapTextValue(val.getInt());
874 : 12 : break;
875 : : case NS_ooxml::LN_shape:
876 : : {
877 : 30 : uno::Reference< drawing::XShape> xShape;
878 [ + - ][ + - ]: 30 : val.getAny( ) >>= xShape;
879 : :
880 [ + - ]: 30 : if ( xShape.is( ) )
881 : : {
882 : : // Is it a graphic image
883 : 30 : bool bUseShape = true;
884 : : try
885 : : {
886 : : uno::Reference< beans::XPropertySet > xShapeProps
887 [ + - ]: 30 : ( xShape, uno::UNO_QUERY_THROW );
888 : :
889 : 30 : OUString sUrl;
890 [ + + ][ + - ]: 30 : xShapeProps->getPropertyValue("GraphicURL") >>= sUrl;
891 : :
892 [ + - ]: 27 : ::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
893 [ + - ]: 27 : aMediaProperties[0].Name = "URL";
894 [ + - ][ + - ]: 27 : aMediaProperties[0].Value <<= sUrl;
895 : :
896 [ + - ][ + - ]: 27 : m_xGraphicObject = createGraphicObject( aMediaProperties );
897 : :
898 : 27 : bUseShape = !m_xGraphicObject.is( );
899 : :
900 [ + - ]: 27 : if ( !bUseShape )
901 : : {
902 : : // Define the object size
903 : : uno::Reference< beans::XPropertySet > xGraphProps( m_xGraphicObject,
904 [ + - ]: 27 : uno::UNO_QUERY );
905 [ + - ][ + - ]: 27 : awt::Size aSize = xShape->getSize( );
906 [ + - ]: 27 : xGraphProps->setPropertyValue("Height",
907 [ + - ][ + - ]: 27 : uno::makeAny( aSize.Height ) );
908 [ + - ]: 27 : xGraphProps->setPropertyValue("Width",
909 [ + - ][ + - ]: 27 : uno::makeAny( aSize.Width ) );
910 [ + - ][ - + ]: 30 : }
911 : : }
912 [ + - ]: 3 : catch( const beans::UnknownPropertyException & )
913 : : {
914 : : // It isn't a graphic image
915 : : }
916 : :
917 [ + + ]: 30 : if ( bUseShape )
918 [ + - ]: 3 : m_xShape = xShape;
919 : :
920 : :
921 [ + + ]: 30 : if ( m_xShape.is( ) )
922 : : {
923 : : uno::Reference< beans::XPropertySet > xShapeProps
924 [ + - ]: 3 : (m_xShape, uno::UNO_QUERY_THROW);
925 : :
926 : :
927 : : PropertyNameSupplier& rPropNameSupplier =
928 [ + - ]: 3 : PropertyNameSupplier::GetPropertyNameSupplier();
929 [ + - ]: 3 : xShapeProps->setPropertyValue
930 [ + - ]: 3 : (rPropNameSupplier.GetName(PROP_ANCHOR_TYPE),
931 : : uno::makeAny
932 [ + - ][ + - ]: 6 : (text::TextContentAnchorType_AS_CHARACTER));
933 [ + - ]: 3 : xShapeProps->setPropertyValue
934 [ + - ]: 3 : (rPropNameSupplier.GetName(PROP_TEXT_RANGE),
935 : : uno::makeAny
936 [ + - ][ + - ]: 6 : (m_pImpl->rDomainMapper.GetCurrentTextRange()));
[ + - ]
937 : :
938 [ + - ][ + - ]: 3 : awt::Size aSize(m_xShape->getSize());
939 : :
940 [ + - ]: 3 : if (m_pImpl->isXSizeValid())
941 : 3 : aSize.Width = m_pImpl->getXSize();
942 [ + - ]: 3 : if (m_pImpl->isYSizeValis())
943 : 3 : aSize.Height = m_pImpl->getYSize();
944 : :
945 [ + - ][ + - ]: 3 : m_xShape->setSize(aSize);
946 : :
947 : 3 : m_pImpl->bIsGraphic = true;
948 : : }
949 : 30 : }
950 : : }
951 : 30 : break;
952 : : case NS_ooxml::LN_CT_Inline_distT:
953 : : case NS_ooxml::LN_CT_Inline_distB:
954 : : case NS_ooxml::LN_CT_Inline_distL:
955 : : case NS_ooxml::LN_CT_Inline_distR:
956 : : //TODO: need to be handled
957 : 12 : break;
958 : : case NS_ooxml::LN_CT_GraphicalObjectData_uri:
959 : 0 : val.getString();
960 : : //TODO: does it need to be handled?
961 : 0 : break;
962 : : default:
963 : : #ifdef DEBUG_DMAPPER_GRAPHIC_IMPORT
964 : : dmapper_logger->element("unhandled");
965 : : #endif
966 : : ;
967 : : }
968 : 309 : }
969 : :
970 : 30 : uno::Reference<text::XTextContent> GraphicImport::GetGraphicObject()
971 : : {
972 : 30 : uno::Reference<text::XTextContent> xResult;
973 : :
974 [ + + ]: 30 : if (m_xGraphicObject.is())
975 [ + - ]: 27 : xResult = m_xGraphicObject;
976 [ + - ]: 3 : else if (m_xShape.is())
977 : : {
978 [ + - ]: 3 : xResult.set(m_xShape, uno::UNO_QUERY_THROW);
979 : : }
980 : :
981 : 30 : return xResult;
982 : : }
983 : :
984 : :
985 : :
986 : 48 : void GraphicImport::ProcessShapeOptions(Value& val)
987 : : {
988 : 48 : sal_Int32 nIntValue = val.getInt();
989 : 48 : sal_Int32 nTwipValue = ConversionHelper::convertTwipToMM100(nIntValue);
990 [ - - - - : 48 : switch( m_pImpl->nShapeOptionType )
- - - - -
- - - - -
- - - - -
- - - - -
+ + + + -
- ]
991 : : {
992 : : case NS_dff::LN_shpcropFromTop /*256*/ :
993 : 0 : m_pImpl->nTopCrop = nTwipValue;
994 : 0 : break;// rtf:shpcropFromTop
995 : : case NS_dff::LN_shpcropFromBottom /*257*/ :
996 : 0 : m_pImpl->nBottomCrop= nTwipValue;
997 : 0 : break;// rtf:shpcropFromBottom
998 : : case NS_dff::LN_shpcropFromLeft /*258*/ :
999 : 0 : m_pImpl->nLeftCrop = nTwipValue;
1000 : 0 : break;// rtf:shpcropFromLeft
1001 : : case NS_dff::LN_shpcropFromRight/*259*/ :
1002 : 0 : m_pImpl->nRightCrop = nTwipValue;
1003 : 0 : break;// rtf:shpcropFromRight
1004 : : case NS_dff::LN_shppib/*260*/:
1005 : 0 : break; // rtf:shppib
1006 : : case NS_dff::LN_shppibName/*261*/:
1007 : 0 : break; // rtf:shppibName
1008 : : case NS_dff::LN_shppibFlags/*262*/: // rtf:shppibFlags
1009 : 0 : break;
1010 : : case NS_dff::LN_shppictureContrast/*264*/: // rtf:shppictureContrast docu: "1<<16"
1011 : : /*
1012 : : 0x10000 is msoffice 50%
1013 : : < 0x10000 is in units of 1/50th of 0x10000 per 1%
1014 : : > 0x10000 is in units where
1015 : : a msoffice x% is stored as 50/(100-x) * 0x10000
1016 : :
1017 : : plus, a (ui) microsoft % ranges from 0 to 100, OOO
1018 : : from -100 to 100, so also normalize into that range
1019 : : */
1020 [ # # ]: 0 : if ( nIntValue > 0x10000 )
1021 : : {
1022 : 0 : double fX = nIntValue;
1023 : 0 : fX /= 0x10000;
1024 : 0 : fX /= 51; // 50 + 1 to round
1025 : 0 : fX = 1/fX;
1026 : 0 : m_pImpl->nContrast = static_cast<sal_Int32>(fX);
1027 : 0 : m_pImpl->nContrast -= 100;
1028 : 0 : m_pImpl->nContrast = -m_pImpl->nContrast;
1029 : 0 : m_pImpl->nContrast = (m_pImpl->nContrast-50)*2;
1030 : : }
1031 [ # # ]: 0 : else if ( nIntValue == 0x10000 )
1032 : 0 : m_pImpl->nContrast = 0;
1033 : : else
1034 : : {
1035 : 0 : m_pImpl->nContrast = nIntValue * 101; //100 + 1 to round
1036 : 0 : m_pImpl->nContrast /= 0x10000;
1037 : 0 : m_pImpl->nContrast -= 100;
1038 : : }
1039 : 0 : break;
1040 : : case NS_dff::LN_shppictureBrightness/*265*/: // rtf:shppictureBrightness
1041 : 0 : m_pImpl->nBrightness = ( (sal_Int32) nIntValue / 327 );
1042 : 0 : break;
1043 : : case NS_dff::LN_shppictureGamma/*266*/: // rtf:shppictureGamma
1044 : : //todo check gamma value with _real_ document
1045 : 0 : m_pImpl->fGamma = double(nIntValue/655);
1046 : 0 : break;
1047 : : case NS_dff::LN_shppictureId /*267*/:
1048 : 0 : break; // rtf:shppictureId
1049 : : case NS_dff::LN_shppictureDblCrMod /*268*/:
1050 : 0 : break; // rtf:shppictureDblCrMod
1051 : : case NS_dff::LN_shppictureFillCrMod /*269*/:
1052 : 0 : break; // rtf:shppictureFillCrMod
1053 : : case NS_dff::LN_shppictureLineCrMod /*270*/:
1054 : 0 : break; // rtf:shppictureLineCrMod
1055 : :
1056 : : case NS_dff::LN_shppictureActive/*319*/: // rtf:shppictureActive
1057 [ # # # # ]: 0 : switch( nIntValue & 0x06 )
1058 : : {
1059 : 0 : case 0 : m_pImpl->eColorMode = drawing::ColorMode_STANDARD; break;
1060 : 0 : case 4 : m_pImpl->eColorMode = drawing::ColorMode_GREYS; break;
1061 : 0 : case 6 : m_pImpl->eColorMode = drawing::ColorMode_MONO; break;
1062 : : default:;
1063 : : }
1064 : 0 : break;
1065 : : case NS_dff::LN_shpfillColor /*385*/:
1066 : 0 : m_pImpl->nFillColor = (m_pImpl->nFillColor & 0xff000000) + ConversionHelper::ConvertColor( nIntValue );
1067 : 0 : break;
1068 : : case NS_dff::LN_shpfillOpacity /*386*/:
1069 : : {
1070 : 0 : sal_Int32 nTrans = 0xff - ( nIntValue * 0xff ) / 0xffff;
1071 : 0 : m_pImpl->nFillColor = (nTrans << 0x18 ) + (m_pImpl->nFillColor & 0xffffff);
1072 : : }
1073 : 0 : break;
1074 : : case NS_dff::LN_shpfNoFillHitTest /*447*/:
1075 : 0 : break; // rtf:shpfNoFillHitTest
1076 : : case NS_dff::LN_shplineColor /*448*/:
1077 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineColor = ConversionHelper::ConvertColor( nIntValue );
1078 : 0 : break;
1079 : : case NS_dff::LN_shplineWidth /*459*/:
1080 : : //1pt == 12700 units
1081 : 0 : m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].nLineWidth = ConversionHelper::convertTwipToMM100(nIntValue / 635);
1082 : 0 : break;
1083 : : case NS_dff::LN_shplineDashing /*462*/:
1084 : : //graphic borders don't support different dashing
1085 : : /*MSOLINEDASHING
1086 : : msolineSolid, // Solid (continuous) pen
1087 : : msolineDashSys, // PS_DASH system dash style
1088 : : msolineDotSys, // PS_DOT system dash style
1089 : : msolineDashDotSys, // PS_DASHDOT system dash style
1090 : : msolineDashDotDotSys, // PS_DASHDOTDOT system dash style
1091 : : msolineDotGEL, // square dot style
1092 : : msolineDashGEL, // dash style
1093 : : msolineLongDashGEL, // long dash style
1094 : : msolineDashDotGEL, // dash short dash
1095 : : msolineLongDashDotGEL, // long dash short dash
1096 : : msolineLongDashDotDotGEL // long dash short dash short dash*/
1097 : 0 : break;
1098 : : case NS_dff::LN_shpfNoLineDrawDash /*511*/:
1099 : 0 : break; // rtf:shpfNoLineDrawDash
1100 : : case NS_dff::LN_shpwzDescription /*897*/: //alternative text
1101 : 0 : m_pImpl->sAlternativeText = val.getString();
1102 : 0 : break;
1103 : : case NS_dff::LN_shppWrapPolygonVertices/*899*/:
1104 : 0 : break; // rtf:shppWrapPolygonVertices
1105 : : case NS_dff::LN_shpdxWrapDistLeft /*900*/: // contains a twip/635 value
1106 : : //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustLRWrapForWordMargins()
1107 : 12 : m_pImpl->nLeftMargin = nIntValue / 360;
1108 : 12 : break;
1109 : : case NS_dff::LN_shpdyWrapDistTop /*901*/: // contains a twip/635 value
1110 : : //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustULWrapForWordMargins()
1111 : 12 : m_pImpl->nTopMargin = nIntValue / 360;
1112 : 12 : break;
1113 : : case NS_dff::LN_shpdxWrapDistRight /*902*/:// contains a twip/635 value
1114 : : //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustLRWrapForWordMargins()
1115 : 12 : m_pImpl->nRightMargin = nIntValue / 360;
1116 : 12 : break;
1117 : : case NS_dff::LN_shpdyWrapDistBottom /*903*/:// contains a twip/635 value
1118 : : //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustULWrapForWordMargins()
1119 : 12 : m_pImpl->nBottomMargin = nIntValue / 360;
1120 : 12 : break;
1121 : : case NS_dff::LN_shpfPrint /*959*/:
1122 : 0 : break; // rtf:shpfPrint
1123 : : default:
1124 : : OSL_FAIL( "shape option unsupported?");
1125 : : }
1126 : 48 : }
1127 : :
1128 : :
1129 : 243 : void GraphicImport::lcl_sprm(Sprm & rSprm)
1130 : : {
1131 [ + - ]: 243 : sal_uInt32 nSprmId = rSprm.getId();
1132 [ + - ][ + - ]: 243 : Value::Pointer_t pValue = rSprm.getValue();
1133 : :
1134 [ + - + + : 243 : switch(nSprmId)
- + - - +
- ]
1135 : : {
1136 : : case 0xf004: //dff record
1137 : : case 0xf00a: //part of 0xf004 - shape properties
1138 : : case 0xf00b: //part of 0xf004
1139 : : case 0xf007:
1140 : : case 0xf122: //udefprop
1141 : : case NS_ooxml::LN_CT_Inline_extent: // 90911;
1142 : : case NS_ooxml::LN_CT_Inline_effectExtent: // 90912;
1143 : : case NS_ooxml::LN_CT_Inline_docPr: // 90913;
1144 : : case NS_ooxml::LN_CT_Inline_cNvGraphicFramePr: // 90914;
1145 : : case NS_ooxml::LN_CT_NonVisualGraphicFrameProperties_graphicFrameLocks:// 90657
1146 : : case NS_ooxml::LN_CT_Inline_a_graphic:// 90915
1147 : : case NS_ooxml::LN_CT_Anchor_simplePos_elem: // 90975;
1148 : : case NS_ooxml::LN_CT_Anchor_extent: // 90978;
1149 : : case NS_ooxml::LN_CT_Anchor_effectExtent: // 90979;
1150 : : case NS_ooxml::LN_EG_WrapType_wrapSquare: // 90945;
1151 : : case NS_ooxml::LN_EG_WrapType_wrapTight: // 90946;
1152 : : case NS_ooxml::LN_EG_WrapType_wrapThrough:
1153 : : case NS_ooxml::LN_CT_Anchor_docPr: // 90980;
1154 : : case NS_ooxml::LN_CT_Anchor_cNvGraphicFramePr: // 90981;
1155 : : case NS_ooxml::LN_CT_Anchor_a_graphic: // 90982;
1156 : : case NS_ooxml::LN_CT_WrapPath_start: // 90924;
1157 : : case NS_ooxml::LN_CT_WrapPath_lineTo: // 90925;
1158 : : case NS_ooxml::LN_graphic_graphic:
1159 : : case NS_ooxml::LN_pic_pic:
1160 : : case NS_ooxml::LN_dgm_relIds:
1161 : : {
1162 [ + - ]: 186 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1163 [ + - ]: 186 : if( pProperties.get())
1164 : : {
1165 [ + - ]: 186 : pProperties->resolve(*this);
1166 [ + - ]: 186 : }
1167 : : }
1168 : 186 : break;
1169 : : case NS_ooxml::LN_CT_WrapTight_wrapPolygon:
1170 : : case NS_ooxml::LN_CT_WrapThrough_wrapPolygon:
1171 : : /* WRITERFILTERSTATUS: done: 100, planned: 4, spent: 2 */
1172 : : {
1173 [ # # ]: 0 : WrapPolygonHandler aHandler;
1174 : :
1175 [ # # ]: 0 : resolveSprmProps(aHandler, rSprm);
1176 : :
1177 [ # # ][ # # ]: 0 : m_pImpl->mpWrapPolygon = aHandler.getPolygon();
[ # # ][ # # ]
1178 : : }
1179 : 0 : break;
1180 : : case NS_ooxml::LN_CT_Anchor_positionH: // 90976;
1181 : : {
1182 : : // Use a special handler for the positionning
1183 [ + - ][ + - ]: 12 : PositionHandlerPtr pHandler( new PositionHandler( false ));
[ + - ]
1184 [ + - ]: 12 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1185 [ + - ]: 12 : if( pProperties.get( ) )
1186 : : {
1187 [ + - ]: 12 : pProperties->resolve( *pHandler );
1188 [ + - ]: 12 : if( !m_pImpl->bUseSimplePos )
1189 : : {
1190 : 12 : m_pImpl->nHoriRelation = pHandler->m_nRelation;
1191 : 12 : m_pImpl->nHoriOrient = pHandler->m_nOrient;
1192 : 12 : m_pImpl->nLeftPosition = pHandler->m_nPosition;
1193 : : }
1194 [ + - ][ + - ]: 12 : }
1195 : : }
1196 : 12 : break;
1197 : : case NS_ooxml::LN_CT_Anchor_positionV: // 90977;
1198 : : {
1199 : : // Use a special handler for the positionning
1200 [ + - ][ + - ]: 12 : PositionHandlerPtr pHandler( new PositionHandler( true ));
[ + - ]
1201 [ + - ]: 12 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1202 [ + - ]: 12 : if( pProperties.get( ) )
1203 : : {
1204 [ + - ]: 12 : pProperties->resolve( *pHandler );
1205 [ + - ]: 12 : if( !m_pImpl->bUseSimplePos )
1206 : : {
1207 : 12 : m_pImpl->nVertRelation = pHandler->m_nRelation;
1208 : 12 : m_pImpl->nVertOrient = pHandler->m_nOrient;
1209 : 12 : m_pImpl->nTopPosition = pHandler->m_nPosition;
1210 : : }
1211 [ + - ][ + - ]: 12 : }
1212 : : }
1213 : 12 : break;
1214 : : case 0x271b:
1215 : : case 0x271c:
1216 : : {
1217 [ # # ][ # # ]: 0 : if( nSprmId != 0x271c || m_pImpl->nDffType == 0xf01f || m_pImpl->nDffType == 0xf01e )
[ # # ]
1218 : : {
1219 [ # # ]: 0 : writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = rSprm.getBinary();
1220 [ # # ]: 0 : if( pPictureData.get())
1221 [ # # ][ # # ]: 0 : pPictureData->resolve(*this);
1222 : : }
1223 : : }
1224 : 0 : break;
1225 : : case NS_ooxml::LN_EG_WrapType_wrapNone: // 90944; - doesn't contain attributes
1226 : : //depending on the behindDoc attribute text wraps through behind or in fron of the object
1227 : 3 : m_pImpl->nWrap = text::WrapTextMode_THROUGHT;
1228 : 3 : break;
1229 : : case NS_ooxml::LN_EG_WrapType_wrapTopAndBottom: // 90948;
1230 : 0 : m_pImpl->nWrap = text::WrapTextMode_NONE;
1231 : 0 : break;
1232 : : case 0xf010:
1233 : : case 0xf011:
1234 : : //ignore - doesn't contain useful members
1235 : 0 : break;
1236 : : case NS_ooxml::LN_CT_GraphicalObject_graphicData:// 90660;
1237 : : {
1238 : 30 : m_pImpl->bIsGraphic = true;
1239 : :
1240 [ + - ]: 30 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1241 [ + - ]: 30 : if( pProperties.get())
1242 [ + - ][ + - ]: 30 : pProperties->resolve(*this);
1243 : : }
1244 : 30 : break;
1245 : : default:
1246 : : #if OSL_DEBUG_LEVEL > 0
1247 : : OString sMessage( "GraphicImport::sprm() - Id: ");
1248 : : sMessage += OString::valueOf( sal_Int32( nSprmId ), 10 );
1249 : : sMessage += " / 0x";
1250 : : sMessage += OString::valueOf( sal_Int32( nSprmId ), 16 );
1251 : : SAL_WARN("writerfilter", sMessage.getStr());
1252 : : #endif
1253 : : ;
1254 [ + - ]: 243 : }
1255 : 243 : }
1256 : :
1257 : :
1258 : 0 : void GraphicImport::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t /*ref*/)
1259 : : {
1260 : 0 : }
1261 : : /*-------------------------------------------------------------------------
1262 : : crop is stored as "fixed float" as 16.16 fraction value
1263 : : related to width/or height
1264 : : -----------------------------------------------------------------------*/
1265 : 48 : void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef )
1266 : : {
1267 : : nCrop = ((nCrop >> 16 ) * nRef )
1268 : 48 : + (((nCrop & 0xffff) * nRef ) >> 16);
1269 : 48 : }
1270 : :
1271 : 27 : uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties )
1272 : : {
1273 : 27 : uno::Reference< text::XTextContent > xGraphicObject;
1274 : : try
1275 : : {
1276 [ + - ]: 27 : uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(m_xComponentContext) );
1277 [ + - ][ + - ]: 27 : uno::Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aMediaProperties );
1278 : :
1279 [ + - ]: 27 : if(xGraphic.is())
1280 : : {
1281 [ + - ]: 27 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1282 : :
1283 : : uno::Reference< beans::XPropertySet > xGraphicObjectProperties(
1284 [ + - ]: 27 : m_xTextFactory->createInstance("com.sun.star.text.TextGraphicObject"),
1285 [ + - ][ + - ]: 27 : uno::UNO_QUERY_THROW);
1286 [ + - ][ + - ]: 27 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_GRAPHIC), uno::makeAny( xGraphic ));
[ + - ][ + - ]
1287 [ + - ][ + - ]: 54 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_ANCHOR_TYPE),
1288 : : uno::makeAny( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR ?
1289 : : text::TextContentAnchorType_AT_CHARACTER :
1290 [ + - ][ + + ]: 54 : text::TextContentAnchorType_AS_CHARACTER ));
[ + - ][ + - ]
1291 [ + - ][ + - ]: 27 : xGraphicObject = uno::Reference< text::XTextContent >( xGraphicObjectProperties, uno::UNO_QUERY_THROW );
1292 : :
1293 : : //shapes have only one border, PICF might have four
1294 : 27 : table::BorderLine2 aBorderLine;
1295 [ + + ]: 135 : for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
1296 : : {
1297 [ + - ][ + + ]: 108 : if( m_pImpl->eGraphicImportType == IMPORT_AS_GRAPHIC || !nBorder )
1298 : : {
1299 [ + - ]: 27 : aBorderLine.Color = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor;
1300 : 27 : aBorderLine.InnerLineWidth = 0;
1301 [ + - ]: 27 : aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth;
1302 : 27 : aBorderLine.LineDistance = 0;
1303 : : }
1304 : : PropertyIds aBorderProps[4] =
1305 : : {
1306 : : PROP_LEFT_BORDER,
1307 : : PROP_RIGHT_BORDER,
1308 : : PROP_TOP_BORDER,
1309 : : PROP_BOTTOM_BORDER
1310 : 108 : };
1311 [ + - ][ + - ]: 108 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( aBorderProps[nBorder]), uno::makeAny(aBorderLine));
[ + - ][ + - ]
1312 : : }
1313 : :
1314 : : // setting properties for all types
1315 [ + - ][ + - ]: 54 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_DESCRIPTION ),
1316 [ + - ][ + - ]: 54 : uno::makeAny( m_pImpl->sAlternativeText ));
1317 [ + - ][ + - ]: 54 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ),
1318 [ + - ][ + - ]: 54 : uno::makeAny( m_pImpl->title ));
1319 [ - + ]: 27 : if( m_pImpl->bPositionProtected )
1320 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_POSITION_PROTECTED ),
1321 [ # # ][ # # ]: 0 : uno::makeAny(true));
1322 [ - + ]: 27 : if( m_pImpl->bSizeProtected )
1323 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SIZE_PROTECTED ),
1324 [ # # ][ # # ]: 0 : uno::makeAny(true));
1325 : :
1326 [ + - ][ + + ]: 27 : if( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR )
1327 : : {
1328 : 15 : sal_Int32 nWidth = m_pImpl->nRightPosition - m_pImpl->nLeftPosition;
1329 [ - + ]: 15 : if( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE )
1330 : : {
1331 : 0 : sal_Int32 nHeight = m_pImpl->nBottomPosition - m_pImpl->nTopPosition;
1332 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
1333 [ # # ][ # # ]: 0 : uno::makeAny( awt::Size( nWidth, nHeight )));
1334 : : }
1335 : : //adjust margins
1336 [ - + ][ # # ]: 15 : if( (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT &&
[ # # ][ - + ]
[ # # ]
1337 : : (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
1338 : : m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
1339 : : (m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
1340 : : m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
1341 : 0 : m_pImpl->nLeftMargin = 0;
1342 [ - + ][ # # ]: 15 : if((m_pImpl->nHoriOrient == text::HoriOrientation::RIGHT &&
[ # # ][ - + ]
[ # # ]
1343 : : (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
1344 : : m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
1345 : : (m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
1346 : : m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
1347 : 0 : m_pImpl->nRightMargin = 0;
1348 : : // adjust top/bottom margins
1349 [ - + ][ # # ]: 15 : if( m_pImpl->nVertOrient == text::VertOrientation::TOP &&
[ # # ]
1350 : : ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
1351 : : m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
1352 : 0 : m_pImpl->nTopMargin = 0;
1353 [ - + ][ # # ]: 15 : if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
[ # # ]
1354 : : ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
1355 : : m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
1356 : 0 : m_pImpl->nBottomMargin = 0;
1357 [ - + ][ # # ]: 15 : if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
1358 : : m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA )
1359 : 0 : m_pImpl->nBottomMargin = 0;
1360 : :
1361 : : //adjust alignment
1362 [ - + ][ # # ]: 15 : if( m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
1363 : : m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
1364 : : {
1365 : : // convert 'left to page' to 'from left -<width> to page text area'
1366 : 0 : m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
1367 : 0 : m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA;
1368 : 0 : m_pImpl->nLeftPosition = - nWidth;
1369 : : }
1370 [ - + ][ # # ]: 15 : else if( m_pImpl->nHoriOrient == text::HoriOrientation::OUTSIDE &&
1371 : : m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
1372 : : {
1373 : : // convert 'right to page' to 'from left 0 to right page border'
1374 : 0 : m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
1375 : 0 : m_pImpl->nHoriRelation = text::RelOrientation::PAGE_RIGHT;
1376 : 0 : m_pImpl->nLeftPosition = 0;
1377 : : }
1378 : :
1379 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT ),
1380 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nHoriOrient));
1381 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_POSITION),
1382 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nLeftPosition));
1383 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_ORIENT_RELATION ),
1384 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nHoriRelation));
1385 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_TOGGLE ),
1386 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->bPageToggle));
1387 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT ),
1388 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nVertOrient));
1389 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_POSITION),
1390 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nTopPosition));
1391 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_ORIENT_RELATION ),
1392 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nVertRelation));
1393 : :
1394 [ + - ][ + - ]: 15 : bool bOpaque = m_pImpl->bOpaque && !m_pImpl->rDomainMapper.IsInHeaderFooter( );
[ + - ]
1395 [ - + ]: 15 : if( !bOpaque )
1396 : : {
1397 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_OPAQUE ),
1398 [ # # ][ # # ]: 0 : uno::makeAny(bOpaque));
1399 : : }
1400 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ),
1401 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nWrap));
1402 : :
1403 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ),
1404 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->bContour));
1405 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_OUTSIDE ),
1406 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->bContourOutside));
1407 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_LEFT_MARGIN ),
1408 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nLeftMargin));
1409 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_RIGHT_MARGIN ),
1410 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nRightMargin));
1411 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TOP_MARGIN ),
1412 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nTopMargin));
1413 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BOTTOM_MARGIN ),
1414 [ + - ][ + - ]: 30 : uno::makeAny(m_pImpl->nBottomMargin));
1415 : :
1416 [ - + ][ # # ]: 15 : if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
[ + - ]
1417 : : m_pImpl->nContrast == -70 &&
1418 : : m_pImpl->nBrightness == 70 )
1419 : : {
1420 : : // strange definition of WATERMARK!
1421 : 0 : m_pImpl->nContrast = 0;
1422 : 0 : m_pImpl->nBrightness = 0;
1423 : 0 : m_pImpl->eColorMode = drawing::ColorMode_WATERMARK;
1424 : : }
1425 : :
1426 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_CONTRAST ),
1427 [ + - ][ + - ]: 30 : uno::makeAny((sal_Int16)m_pImpl->nContrast));
1428 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_LUMINANCE ),
1429 [ + - ][ + - ]: 30 : uno::makeAny((sal_Int16)m_pImpl->nBrightness));
1430 [ - + ]: 15 : if(m_pImpl->eColorMode != drawing::ColorMode_STANDARD)
1431 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_COLOR_MODE ),
1432 [ # # ][ # # ]: 0 : uno::makeAny(m_pImpl->eColorMode));
1433 [ - + ]: 15 : if(m_pImpl->fGamma > 0. )
1434 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GAMMA ),
1435 [ # # ][ # # ]: 0 : uno::makeAny(m_pImpl->fGamma ));
1436 [ - + ]: 15 : if(m_pImpl->bHoriFlip)
1437 : : {
1438 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_EVEN_PAGES ),
1439 [ # # ][ # # ]: 0 : uno::makeAny( m_pImpl->bHoriFlip ));
1440 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_HORI_MIRRORED_ON_ODD_PAGES ),
1441 [ # # ][ # # ]: 0 : uno::makeAny( m_pImpl->bHoriFlip ));
1442 : : }
1443 : :
1444 [ - + ]: 15 : if( m_pImpl->bVertFlip )
1445 [ # # ][ # # ]: 0 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_VERT_MIRRORED ),
1446 [ # # ][ # # ]: 0 : uno::makeAny( m_pImpl->bVertFlip ));
1447 [ + - ][ + - ]: 30 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BACK_COLOR ),
1448 [ + - ][ + - ]: 30 : uno::makeAny( m_pImpl->nFillColor ));
1449 : :
1450 [ + + ]: 15 : if( m_pImpl->zOrder >= 0 )
1451 : : {
1452 [ + - ]: 12 : GraphicZOrderHelper* zOrderHelper = m_pImpl->rDomainMapper.graphicZOrderHelper();
1453 [ + - ][ + - ]: 24 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_Z_ORDER ),
1454 [ + - ][ + - ]: 24 : uno::makeAny( zOrderHelper->findZOrder( m_pImpl->zOrder )));
[ + - ]
1455 [ + - ]: 12 : zOrderHelper->addItem( xGraphicObjectProperties, m_pImpl->zOrder );
1456 : : }
1457 : :
1458 : : //there seems to be no way to detect the original size via _real_ API
1459 [ + - ]: 15 : uno::Reference< beans::XPropertySet > xGraphicProperties( xGraphic, uno::UNO_QUERY_THROW );
1460 : 15 : awt::Size aGraphicSize, aGraphicSizePixel;
1461 [ + - ][ + - ]: 15 : xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE100th_M_M )) >>= aGraphicSize;
[ + - ][ + - ]
1462 [ + - ][ + - ]: 15 : xGraphicProperties->getPropertyValue(rPropNameSupplier.GetName( PROP_SIZE_PIXEL )) >>= aGraphicSizePixel;
[ + - ][ + - ]
1463 : :
1464 : 15 : uno::Any aContourPolyPolygon;
1465 [ + - - + ]: 27 : if( aGraphicSize.Width && aGraphicSize.Height &&
[ - + ][ + + ]
1466 : 12 : m_pImpl->mpWrapPolygon.get() != NULL)
1467 : : {
1468 : 0 : awt::Size aDstSize(m_pImpl->getXSize(), m_pImpl->getYSize());
1469 [ # # ]: 0 : WrapPolygon::Pointer_t pCorrected = m_pImpl->mpWrapPolygon->correctWordWrapPolygon(aGraphicSize, aDstSize);
1470 [ # # ][ # # ]: 0 : aContourPolyPolygon <<= pCorrected->getPointSequenceSequence();
[ # # ][ # # ]
1471 : : }
1472 : :
1473 [ + - ][ + - ]: 15 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_POLY_POLYGON),
1474 [ + - ]: 15 : aContourPolyPolygon);
1475 : :
1476 [ + + ][ + - ]: 15 : if( aGraphicSize.Width && aGraphicSize.Height )
1477 : : {
1478 : : //todo: i71651 graphic size is not provided by the GraphicDescriptor
1479 : 12 : lcl_CalcCrop( m_pImpl->nTopCrop, aGraphicSize.Height );
1480 : 12 : lcl_CalcCrop( m_pImpl->nBottomCrop, aGraphicSize.Height );
1481 : 12 : lcl_CalcCrop( m_pImpl->nLeftCrop, aGraphicSize.Width );
1482 : 12 : lcl_CalcCrop( m_pImpl->nRightCrop, aGraphicSize.Width );
1483 : :
1484 : :
1485 : : // We need a separate try-catch here, otherwise a bad crop setting will also nuke the size settings as well.
1486 : : try
1487 : : {
1488 [ + - ][ + - ]: 24 : xGraphicProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_GRAPHIC_CROP ),
1489 [ + - ][ - + ]: 24 : uno::makeAny(text::GraphicCrop(m_pImpl->nTopCrop, m_pImpl->nBottomCrop, m_pImpl->nLeftCrop, m_pImpl->nRightCrop)));
[ - + ]
1490 : : }
1491 [ + - ]: 12 : catch (const uno::Exception& e)
1492 : : {
1493 : : SAL_WARN("writerfilter", "failed. Message :" << e.Message);
1494 : : }
1495 : 15 : }
1496 : :
1497 : : }
1498 : :
1499 [ + + ][ + - ]: 27 : if(m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_INLINE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
1500 : : {
1501 [ + - ][ + - ]: 27 : if( m_pImpl->getXSize() && m_pImpl->getYSize() )
[ + - ]
1502 [ + - ][ + - ]: 54 : xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SIZE),
1503 [ + - ][ + - ]: 54 : uno::makeAny( awt::Size( m_pImpl->getXSize(), m_pImpl->getYSize() )));
1504 : : try
1505 : : {
1506 [ + + ]: 27 : if( !m_pImpl->sName.isEmpty() )
1507 : : {
1508 [ + - ]: 12 : uno::Reference< container::XNamed > xNamed( xGraphicObjectProperties, uno::UNO_QUERY_THROW );
1509 [ + - ][ + - ]: 12 : xNamed->setName( m_pImpl->sName );
[ # # ]
1510 : : }
1511 : : }
1512 [ # # ]: 0 : catch( const uno::Exception& e )
1513 : : {
1514 : : SAL_WARN("writerfilter", "failed. Message :" << e.Message);
1515 : : }
1516 : 27 : }
1517 [ # # ]: 27 : }
1518 : : }
1519 [ # # ]: 0 : catch( const uno::Exception& e )
1520 : : {
1521 : : SAL_WARN("writerfilter", "failed. Message :" << e.Message);
1522 : : }
1523 : 27 : return xGraphicObject;
1524 : : }
1525 : :
1526 : :
1527 : :
1528 : 0 : void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t /*ref*/)
1529 : : {
1530 [ # # ]: 0 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1531 : :
1532 [ # # ]: 0 : ::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
1533 [ # # ][ # # ]: 0 : aMediaProperties[0].Name = rPropNameSupplier.GetName(PROP_INPUT_STREAM);
1534 : :
1535 [ # # ][ # # ]: 0 : uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap );
[ # # ]
1536 [ # # ][ # # ]: 0 : aMediaProperties[0].Value <<= xIStream;
1537 : :
1538 [ # # ][ # # ]: 0 : m_xGraphicObject = createGraphicObject( aMediaProperties );
[ # # ]
1539 : 0 : }
1540 : :
1541 : :
1542 : 0 : void GraphicImport::lcl_startSectionGroup()
1543 : : {
1544 : 0 : }
1545 : :
1546 : :
1547 : 0 : void GraphicImport::lcl_endSectionGroup()
1548 : : {
1549 : 0 : }
1550 : :
1551 : :
1552 : 0 : void GraphicImport::lcl_startParagraphGroup()
1553 : : {
1554 : 0 : }
1555 : :
1556 : :
1557 : 0 : void GraphicImport::lcl_endParagraphGroup()
1558 : : {
1559 : 0 : }
1560 : :
1561 : :
1562 : 0 : void GraphicImport::lcl_startCharacterGroup()
1563 : : {
1564 : 0 : }
1565 : :
1566 : :
1567 : 0 : void GraphicImport::lcl_endCharacterGroup()
1568 : : {
1569 : 0 : }
1570 : :
1571 : :
1572 : 0 : void GraphicImport::lcl_text(const sal_uInt8 * /*_data*/, size_t /*len*/)
1573 : : {
1574 : 0 : }
1575 : :
1576 : :
1577 : 0 : void GraphicImport::lcl_utext(const sal_uInt8 * /*_data*/, size_t /*len*/)
1578 : : {
1579 : 0 : }
1580 : :
1581 : :
1582 : 0 : void GraphicImport::lcl_props(writerfilter::Reference<Properties>::Pointer_t /*ref*/)
1583 : : {
1584 : 0 : }
1585 : :
1586 : :
1587 : 0 : void GraphicImport::lcl_table(Id /*name*/, writerfilter::Reference<Table>::Pointer_t /*ref*/)
1588 : : {
1589 : 0 : }
1590 : :
1591 : :
1592 : 0 : void GraphicImport::lcl_substream(Id /*name*/, ::writerfilter::Reference<Stream>::Pointer_t /*ref*/)
1593 : : {
1594 : 0 : }
1595 : :
1596 : :
1597 : 0 : void GraphicImport::lcl_info(const string & /*info*/)
1598 : : {
1599 : 0 : }
1600 : :
1601 : 0 : void GraphicImport::lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
1602 : : {
1603 : 0 : }
1604 : :
1605 : 0 : void GraphicImport::lcl_endShape( )
1606 : : {
1607 : 0 : }
1608 : :
1609 : :
1610 : :
1611 : 30 : bool GraphicImport::IsGraphic() const
1612 : : {
1613 : 30 : return m_pImpl->bIsGraphic;
1614 : : }
1615 : :
1616 : : }
1617 [ + - ][ + - ]: 60 : }
1618 : :
1619 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|