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