LibreOffice Module lotuswordpro (master) 1
lwpgrfobj.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 *
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
38 *
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
56
61#include <memory>
62#include <string_view>
63
64#include <lwpfilehdr.hxx>
65#include "lwpgrfobj.hxx"
66#include "lwpsdwfileloader.hxx"
67#include "bento.hxx"
68
69#include <lwpglobalmgr.hxx>
70#include <o3tl/numeric.hxx>
71#include <o3tl/sprintf.hxx>
72#include <rtl/string.hxx>
73#include "lwpframelayout.hxx"
74
75#include <xfilter/xfframe.hxx>
76#include <xfilter/xfimage.hxx>
81
82//For chart
83#include <string.h>
84
85#include <osl/thread.h>
86#include <sal/log.hxx>
87
88#define EF_NONE 0x0000
89#define EF_ODMA 0x0002
90
92 : LwpGraphicOleObject(objHdr, pStrm)
93 , m_nCachedBaseLine(0)
94 , m_bIsLinked(0)
95 , m_bCompressed(0)
96{
97}
98
100{
101}
102
104{
106 m_pObjStrm->QuickReaduInt16(); //disksize
107 sal_uInt16 strsize = m_pObjStrm->QuickReaduInt16();
108 if (strsize<AFID_MAX_FILE_FORMAT_SIZE)
109 {
110 m_pObjStrm->QuickRead(m_sDataFormat,strsize);
111 m_sDataFormat[strsize] = '\0';
112 }
113 sal_uInt32 nServerContextSize = m_pObjStrm->QuickReaduInt32();
114 if (nServerContextSize > 0)
115 {
116 sal_uInt16 nMaxPossibleSize = m_pObjStrm->remainingSize();
117
118 if (nServerContextSize > nMaxPossibleSize)
119 {
120 SAL_WARN("lwp", "stream too short for claimed no of records");
121 nServerContextSize = nMaxPossibleSize;
122 }
123
124 std::vector<unsigned char> aServerContext(nServerContextSize);
125 m_pObjStrm->QuickRead(aServerContext.data(), static_cast<sal_uInt16>(nServerContextSize));
126 if (nServerContextSize > 44)
127 {
128 m_aIPData.nBrightness = aServerContext[14];
129 m_aIPData.nContrast = aServerContext[19];
130 m_aIPData.nEdgeEnhancement = aServerContext[24];
131 m_aIPData.nSmoothing = aServerContext[29];
132 m_aIPData.bInvertImage = (aServerContext[34] == 0x01);
133 m_aIPData.bAutoContrast = (aServerContext[44] == 0x00);
134 }
135 }
136 m_pObjStrm->QuickReaduInt16(); //disksize
137 strsize = m_pObjStrm->QuickReaduInt16();
138 if (strsize<AFID_MAX_FILE_FORMAT_SIZE)
139 {
140 m_pObjStrm->QuickRead(m_sServerContextFormat,strsize);
141 m_sServerContextFormat[strsize] = '\0';
142 }
143 if (nServerContextSize == 0)
144 {
145 if (strcmp(reinterpret_cast<char *>(m_sServerContextFormat), ".cht") == 0 &&
146 strcmp(reinterpret_cast<char *>(m_sDataFormat), ".sdw") == 0)
147 {
148 strcpy(reinterpret_cast<char *>(m_sServerContextFormat), ".lch");
149 strcpy(reinterpret_cast<char *>(m_sDataFormat), ".lch");
150 }
151 }
152 m_nCachedBaseLine = m_pObjStrm->QuickReadInt32();
153 m_bIsLinked = m_pObjStrm->QuickReadInt16();
154
155 if (m_bIsLinked)
156 {
157 m_LinkedFilePath = m_pObjStrm->QuickReadStringPtr();
158
159 sal_uInt32 nFilterContextSize = m_pObjStrm->QuickReaduInt32();
160 if (nFilterContextSize > 0)
161 {
162 sal_uInt16 nMaxPossibleSize = m_pObjStrm->remainingSize();
163
164 if (nFilterContextSize > nMaxPossibleSize)
165 {
166 SAL_WARN("lwp", "stream too short for claimed no of records");
167 nFilterContextSize = nMaxPossibleSize;
168 }
169
170 std::vector<unsigned char> aFilterContext(nFilterContextSize);
171 m_pObjStrm->QuickRead(aFilterContext.data(), static_cast<sal_uInt16>(nFilterContextSize));
172 }
173 if (LwpFileHeader::m_nFileRevision >= 0x000b)
174 {
175
176 // read external file object stuff
177 sal_uInt16 type = m_pObjStrm->QuickReaduInt16();
178 if ((EF_ODMA != type) && (EF_NONE != type)) // don't know about this
179 {
180 sal_uInt32 size = m_pObjStrm->QuickReaduInt32();
181 m_pObjStrm->SeekRel(static_cast<sal_uInt16>(size));
182 }
183 // else no external file object
184 }
185 }
186
187 if (LwpFileHeader::m_nFileRevision >= 0x000b)
188 {
189 m_bCompressed = m_pObjStrm->QuickReadInt16();
190 m_Cache.LinkedFileSize = m_pObjStrm->QuickReaduInt32();
191 m_Cache.LinkedFileTime = m_pObjStrm->QuickReaduInt32();
192 m_Cache.Width = m_pObjStrm->QuickReadInt32();
193 m_Cache.Height = m_pObjStrm->QuickReadInt32();
194 }
195
197 {
198 m_WatermarkName = m_pObjStrm->QuickReadStringPtr();
199 }
200}
201
203{
205 {
206 for (auto const& vXFDrawObject : m_vXFDrawObjects)
207 {
208 pCont->Add(vXFDrawObject.get());
209 }
210 }
211 else if (IsGrafFormatValid() && !m_vXFDrawObjects.empty())
212 {
213 XFImage* pImage = static_cast<XFImage*>(m_vXFDrawObjects.front().get());
214
215 if (m_bIsLinked)
216 {
217 OUString fileURL = LwpTools::convertToFileUrl(OUStringToOString(m_LinkedFilePath, osl_getThreadTextEncoding()));
218 pImage->SetFileURL(fileURL);
219 }
220 else
221 {
222 std::vector<sal_uInt8> aGrafData = GetRawGrafData();
223 pImage->SetImageData(aGrafData.data(), aGrafData.size());
224 }
225
226 pCont->Add(pImage);
227 }
229 {
230 XFConvertEquation(pCont);
231 }
232}
233
240{
241 return (m_sServerContextFormat[1]=='b'&& m_sServerContextFormat[2]=='m' && m_sServerContextFormat[3]=='p')
248}
249
254{
256 {
258 }
259 // test codes for importing pictures
260 else if(IsGrafFormatValid())
261 {
263 }
264
266 {
268 if (xMyLayout.is() && xMyLayout->IsFrame())
269 {
270 std::unique_ptr<XFFrameStyle> pXFFrameStyle(new XFFrameStyle());
271 pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
272 pXFFrameStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelPara);
274 m_strStyleName = pXFStyleManager->AddStyle(std::move(pXFFrameStyle)).m_pStyle->GetStyleName();
275 }
276 }
277
278}
279
284{
285 // if small file, use the compressed stream for BENTO
287
288 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
289 sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
290 if (ulRet != OpenStormBento::BenErr_OK)
291 return;
292
293 // get graphic object's bento object name
294 LwpObjectID& rMyID = GetObjectID();
295 std::string aGrfObjName;
296 GetBentoNamebyID(rMyID, aGrfObjName);
297
298 // get bento stream by the name
299 std::vector<sal_uInt8> aData = pBentoContainer->GetGraphicData(aGrfObjName.c_str());
300 if (!aData.empty())
301 {
302 SvMemoryStream aDrawObjStream(aData.data(), aData.size(), StreamMode::READ);
303
304 LwpSdwFileLoader fileLoader(&aDrawObjStream, this);
306 }
307}
308
312void LwpGraphicObject::GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName)
313{
314 sal_uInt16 nHigh = rMyID.GetHigh();
315 sal_uInt32 nLow = rMyID.GetLow();
316 char pTempStr[32];
317 rName = std::string("Gr");
318 o3tl::sprintf(pTempStr, "%X,%" SAL_PRIXUINT32, nHigh, nLow);
319 rName.append(pTempStr);
320}
321
326std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData()
327{
328 std::vector<sal_uInt8> aGrafData;
329
330 // create graphic object
331 // if small file, use the compressed stream for BENTO
333
334 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
335 {
336 sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
337 if (ulRet != OpenStormBento::BenErr_OK)
338 return aGrafData;
339 }
340
341 // get graphic object's bento object name
342 LwpObjectID& rMyID = GetObjectID();
343 std::string aGrfObjName;
344 GetBentoNamebyID(rMyID, aGrfObjName);
345
346 // get bento stream by the name and read image data
347 return pBentoContainer->GetGraphicData(aGrfObjName.c_str());
348}
349
355sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData)
356{
357 // create graphic object
358 // if small file, use the compressed stream for BENTO
360
361 std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
362 sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
363 if (ulRet != OpenStormBento::BenErr_OK)
364 return 0;
365
366 SvStream* pGrafStream = nullptr;
367
368 // get graphic object's bento object name
369 LwpObjectID& rMyID = GetObjectID();
370 std::string aGrfObjName;
371 GetBentoNamebyID(rMyID, aGrfObjName);
372
373 OString sDName=OString::Concat(std::string_view(aGrfObjName)) + "-D";
374
375 // get bento stream by the name
376 pGrafStream = pBentoContainer->FindValueStreamWithPropertyName(sDName.getStr());
377
378 std::unique_ptr<SvMemoryStream> pMemGrafStream(static_cast<SvMemoryStream*>(pGrafStream));
379
380 if (pMemGrafStream)
381 {
382 // read image data
383 sal_uInt32 nDataLen = pGrafStream->TellEnd();
384
385 pGrafData.reset(new sal_uInt8 [nDataLen]);
386 pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen);
387
388 return nDataLen;
389 }
390
391 return 0;
392}
393
398{
399 rtl::Reference<XFImage> pImage = new XFImage();
400
401 // set image processing styles
402 std::unique_ptr<XFImageStyle> xImageStyle(new XFImageStyle);
404 {
405 if (m_aIPData.nBrightness != 50)
406 {
407 sal_Int32 nSODCBrightness = static_cast<sal_Int32>(m_aIPData.nBrightness)*2 - 100;
408 xImageStyle->SetBrightness(nSODCBrightness);
409 }
410 if (m_aIPData.nContrast != 50)
411 {
412 sal_Int32 nSODCContrast = static_cast<sal_Int32>(80 - static_cast<double>(m_aIPData.nContrast)*1.6);
413 xImageStyle->SetContrast(nSODCContrast);
414 }
415 }
416
417 // set scale and crop styles
418 LwpAssociatedLayouts& rLayoutWithMe = GetLayoutsWithMe();
419 LwpFrameLayout* pMyFrameLayout =
420 static_cast<LwpFrameLayout*>(rLayoutWithMe.GetOnlyLayout().obj(VO_FRAMELAYOUT).get());
421 if (pMyFrameLayout)
422 {
423 LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
424 LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
425
426 // original image size
427 double fOrgGrafWidth = static_cast<double>(m_Cache.Width)/TWIPS_PER_CM;
428 double fOrgGrafHeight = static_cast<double>(m_Cache.Height)/TWIPS_PER_CM;
429
430 // get margin values
431 double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
432 double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT);
433 double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
434 double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
435
436 if (pMyScale && pFrameGeo)
437 {
438 if (fOrgGrafHeight == 0.0 || fOrgGrafWidth == 0.0)
439 throw o3tl::divide_by_zero();
440
441 // frame size
442 double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
443 double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
444
445 // calculate the displayed size of the frame
446 double fDisFrameWidth = fFrameWidth - (fLeftMargin+fRightMargin);
447 double fDisFrameHeight = fFrameHeight - (fTopMargin+fBottomMargin);
448
449 // scaled image size
450 double fSclGrafWidth = fOrgGrafWidth;
451 double fSclGrafHeight = fOrgGrafHeight;
452
453 // get scale mode
454 sal_uInt16 nScalemode = pMyScale->GetScaleMode();
455 if (nScalemode & LwpLayoutScale::CUSTOM)
456 {
457 fSclGrafWidth = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
458 fSclGrafHeight = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
459 }
460 else if (nScalemode & LwpLayoutScale::PERCENTAGE)
461 {
462 double fScalePercentage = static_cast<double>(pMyScale->GetScalePercentage()) / 1000;
463 fSclGrafWidth = fScalePercentage * fOrgGrafWidth;
464 fSclGrafHeight = fScalePercentage * fOrgGrafHeight;
465 }
466 else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
467 {
468 if (pMyFrameLayout->IsFitGraphic())
469 {
470 fSclGrafWidth = fOrgGrafWidth;
471 fSclGrafHeight = fOrgGrafHeight;
472 }
473 else if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
474 {
475 if (fDisFrameHeight == 0.0)
476 throw o3tl::divide_by_zero();
477 if (fOrgGrafWidth/fOrgGrafHeight >= fDisFrameWidth/fDisFrameHeight)
478 {
479 fSclGrafWidth = fDisFrameWidth;
480 fSclGrafHeight = (fDisFrameWidth/fOrgGrafWidth) * fOrgGrafHeight;
481 }
482 else
483 {
484 fSclGrafHeight = fDisFrameHeight;
485 fSclGrafWidth = (fDisFrameHeight/fOrgGrafHeight) * fOrgGrafWidth;
486 }
487 }
488 else
489 {
490 fSclGrafWidth = fDisFrameWidth;
491 fSclGrafHeight = fDisFrameHeight;
492 }
493 }
494
495 // scaled ratio
496 double fXRatio = fSclGrafWidth / fOrgGrafWidth;
497 double fYRatio = fSclGrafHeight / fOrgGrafHeight;
498
499 // set image to scaled size.
500 pImage->SetWidth(fSclGrafWidth);
501 pImage->SetHeight(fSclGrafHeight);
502
503 // placement:centered or tiled. tiled style is not supported so it's processed together with centered.
504 if (pMyFrameLayout->GetScaleCenter() || pMyFrameLayout->GetScaleTile())
505 {
506 // set center alignment
507 xImageStyle->SetXPosType(enumXFFrameXPosCenter, enumXFFrameXRelFrame);
508 xImageStyle->SetYPosType(enumXFFrameYPosMiddle, enumXFFrameYRelFrame);
509
510 // need horizontal crop?
511 double fClipWidth = 0;
512 double fClipHeight = 0;
513 bool sal_bCropped = false;
514 if (fSclGrafWidth > fDisFrameWidth)
515 {
516 if (fXRatio == 0.0)
517 throw o3tl::divide_by_zero();
518 fClipWidth = (fSclGrafWidth-fDisFrameWidth ) / 2 / fXRatio;
519 sal_bCropped = true;
520 }
521
522 // need vertical crop?
523 if (fSclGrafHeight > fDisFrameHeight)
524 {
525 if (fYRatio == 0.0)
526 throw o3tl::divide_by_zero();
527 fClipHeight = (fSclGrafHeight-fDisFrameHeight ) / 2 / fYRatio;
528 sal_bCropped = true;
529 }
530
531 if (sal_bCropped)
532 {
533 xImageStyle->SetClip(fClipWidth, fClipWidth, fClipHeight, fClipHeight);
534 pImage->SetWidth(fDisFrameWidth);
535 pImage->SetHeight(fDisFrameHeight);
536 }
537 }
538 // placement:automatic
539 else
540 {
541 // set left-top alignment
542 xImageStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelFrame);
543 xImageStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
544
545 // get image position offset
546 LwpPoint& rOffset = pMyScale->GetOffset();
547 double fOffsetX = LwpTools::ConvertFromUnitsToMetric(rOffset.GetX());
548 double fOffsetY = LwpTools::ConvertFromUnitsToMetric(rOffset.GetY());
549
550 struct LwpRect
551 {
552 double fLeft;
553 double fRight;
554 double fTop;
555 double fBottom;
556
557 LwpRect()
558 {
559 fLeft = 0.00;
560 fRight = 0.00;
561 fTop = 0.00;
562 fBottom = 0.00;
563 }
564 LwpRect(double fL, double fR, double fT, double fB)
565 {
566 fLeft = fL;
567 fRight = fR;
568 fTop = fT;
569 fBottom = fB;
570 }
571 };
572 LwpRect aFrameRect(-fOffsetX, (fDisFrameWidth-fOffsetX), (-fOffsetY), (fDisFrameHeight-fOffsetY));
573 LwpRect aImageRect(0, fSclGrafWidth, 0, fSclGrafHeight);
574
575 if (aFrameRect.fRight <= aImageRect.fLeft || aFrameRect.fLeft >= aImageRect.fRight
576 ||aFrameRect.fBottom <= aImageRect.fTop|| aFrameRect.fTop >= aImageRect.fBottom)
577 {
578 // display blank
579 }
580 else// need cropped
581 {
582 // horizontal crop
583 LwpRect aCropRect;
584 if (aFrameRect.fLeft > aImageRect.fLeft)
585 {
586 aCropRect.fLeft = (aFrameRect.fLeft - aImageRect.fLeft) / fXRatio;
587 }
588
589 if (aFrameRect.fRight < aImageRect.fRight)
590 {
591 aCropRect.fRight = (aImageRect.fRight - aFrameRect.fRight) / fXRatio;
592 }
593
594 // vertical crop
595 if (aFrameRect.fTop > aImageRect.fTop)
596 {
597 aCropRect.fTop = (aFrameRect.fTop - aImageRect.fTop) / fYRatio;
598 }
599 if (aFrameRect.fBottom < aImageRect.fBottom)
600 {
601 aCropRect.fBottom = (aImageRect.fBottom - aFrameRect.fBottom) / fYRatio;
602 }
603
604 xImageStyle->SetClip(aCropRect.fLeft, aCropRect.fRight, aCropRect.fTop, aCropRect.fBottom);
605 double fPicWidth = fSclGrafWidth - (aCropRect.fLeft+aCropRect.fRight)*fXRatio;
606 double fPicHeight = fSclGrafHeight- (aCropRect.fTop+aCropRect.fBottom)*fYRatio;
607 double fX = fOffsetX > 0 ? fOffsetX : 0.00;
608 double fY = fOffsetY > 0 ? fOffsetY : 0.00;
609 pImage->SetPosition((fX+fLeftMargin), (fY+fTopMargin), fPicWidth, fPicHeight);
610 }
611 }
612 }
613 }
614
615 // set style for the image
617 pImage->SetStyleName(pXFStyleManager->AddStyle(std::move(xImageStyle)).m_pStyle->GetStyleName());
618
619 // set anchor to frame
620 pImage->SetAnchorType(enumXFAnchorFrame);
621
622 // set object name
623 LwpAtomHolder& rHolder = GetName();
624 if ( !rHolder.str().isEmpty() )
625 {
626 pImage->SetName(rHolder.str());
627 }
628
629 // insert image object into array
630 m_vXFDrawObjects.emplace_back(pImage.get());
631
632}
633
638{
639 std::unique_ptr<sal_uInt8[]> pGrafData;
640 sal_uInt32 nDataLen = GetGrafData(pGrafData);
641 if(!pGrafData)
642 return;
643
644 //convert equation
645 XFParagraph* pXFPara = new XFParagraph;
646 pXFPara->Add("Formula:");
647 //add notes
648 XFAnnotation* pXFNote = new XFAnnotation;
649 //add equation to comment notes
650 XFParagraph* pXFNotePara = new XFParagraph;
651 //equation header text: Times New Roman,
652 // 18,12,0,0,0,0,0.
653 // .TCIformat{2}
654 //total head length = 45
655 bool bOk = true;
656 sal_uInt32 nBegin = 45;
657 sal_uInt32 nEnd = 0;
658 if (nDataLen >= 1)
659 nEnd = nDataLen - 1;
660 else
661 bOk = false;
662
663 if (bOk && pGrafData[nEnd] == '$' && nEnd > 0 && pGrafData[nEnd-1] != '\\')
664 {
665 //equation body is contained by '$';
666 nBegin++;
667 nEnd--;
668 }
669
670 bOk &= nEnd >= nBegin;
671 if (bOk)
672 {
673 std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
674 for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
675 {
676 pEquData[nIndex] = pGrafData[nBegin + nIndex];
677 }
678 pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
679 }
680 pXFNote->Add(pXFNotePara);
681
682 pXFPara->Add(pXFNote);
683 pCont->Add(pXFPara);
684}
685
686void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight)
687{
688 // original image size
689 rWidth = static_cast<double>(m_Cache.Width)/TWIPS_PER_CM;
690 rHeight = static_cast<double>(m_Cache.Height)/TWIPS_PER_CM;
691}
692
693/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString GetStyleName()=0
@descr: return the style name.
LwpObjectID & GetOnlyLayout()
Definition: lwplayout.hxx:300
AtomHolder class of Word Pro to hold a string.
const OUString & str() const
LwpAssociatedLayouts & GetLayoutsWithMe()
Definition: lwpcontent.hxx:117
rtl::Reference< LwpVirtualLayout > GetLayout(LwpVirtualLayout const *pStartLayout)
Definition: lwpcontent.cxx:124
LwpAtomHolder & GetName()
Definition: lwpdlvlist.hxx:108
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
VO_FRAMELAYOUT object.
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
AFID_CACHE m_Cache
Definition: lwpgrfobj.hxx:100
void CreateGrafObject()
@descr create xf-image object and save it in the container: m_vXFDrawObjects.
Definition: lwpgrfobj.cxx:397
sal_Int16 m_bIsLinked
Definition: lwpgrfobj.hxx:99
ImageProcessingData m_aIPData
Definition: lwpgrfobj.hxx:105
void XFConvertEquation(XFContentContainer *pCont)
@descr Reserve the equation text in a note in the context.
Definition: lwpgrfobj.cxx:637
OUString m_LinkedFilePath
Definition: lwpgrfobj.hxx:103
virtual void XFConvert(XFContentContainer *pCont) override
@descr default XFConvert function pCont is the XFContentContainer for the object conversion
Definition: lwpgrfobj.cxx:202
unsigned char m_sServerContextFormat[AFID_MAX_CONTEXT_FORMAT_SIZE]
Definition: lwpgrfobj.hxx:97
std::vector< rtl::Reference< XFFrame > > m_vXFDrawObjects
Definition: lwpgrfobj.hxx:110
OUString m_WatermarkName
Definition: lwpgrfobj.hxx:102
LwpGraphicObject(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpgrfobj.cxx:91
void RegisterStyle() override
@descr create drawing object and image object.
Definition: lwpgrfobj.cxx:253
sal_Int16 m_bCompressed
Definition: lwpgrfobj.hxx:101
sal_Int32 m_nCachedBaseLine
Definition: lwpgrfobj.hxx:98
static void GetBentoNamebyID(LwpObjectID const &rMyID, std::string &rName)
@descr create drawing object.
Definition: lwpgrfobj.cxx:312
void Read() override
@descr: Read GraphicOleObject part
Definition: lwpgrfobj.cxx:103
void GetGrafOrgSize(tools::Long &rWidth, tools::Long &rHeight)
Definition: lwpgrfobj.hxx:122
virtual ~LwpGraphicObject() override
Definition: lwpgrfobj.cxx:99
void CreateDrawObjects()
@descr create drawing object.
Definition: lwpgrfobj.cxx:283
std::vector< sal_uInt8 > GetRawGrafData()
@descr get the image data read from bento stream according to the VO_GRAPHIC ID.
Definition: lwpgrfobj.cxx:326
bool IsGrafFormatValid() const
@descr judge if the graphic format is what we can support: bmp, jpg, wmf, gif, tgf(tif).
Definition: lwpgrfobj.cxx:239
sal_uInt32 GetGrafData(std::unique_ptr< sal_uInt8[]> &pGrafData)
@descr get the image data (only -D data) read from bento stream according to the VO_GRAPHIC ID.
Definition: lwpgrfobj.cxx:355
unsigned char m_sDataFormat[AFID_MAX_FILE_FORMAT_SIZE]
Definition: lwpgrfobj.hxx:96
@descr super class of LwpOleObject and LwpGraphicObject
virtual void Read() override
@descr: Read GraphicOleObject part
sal_Int32 GetHeight() const
Definition: lwplaypiece.hxx:86
sal_Int32 GetWidth() const
Definition: lwplaypiece.hxx:85
sal_uInt32 GetScalePercentage() const
LwpPoint & GetOffset()
sal_uInt16 GetScaleMode() const
sal_Int32 GetScaleWidth() const
sal_Int32 GetScaleHeight() const
sal_uInt16 GetScaleCenter()
Definition: lwplayout.cxx:958
LwpLayoutScale * GetLayoutScale()
Definition: lwplayout.hxx:366
sal_uInt16 GetScaleTile()
Definition: lwplayout.cxx:947
LwpLayoutGeometry * GetGeometry()
@descr: Get the geometry of current layout
Definition: lwplayout.cxx:634
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
object id class
Definition: lwpobjid.hxx:79
sal_uInt16 GetHigh() const
Definition: lwpobjid.hxx:130
rtl::Reference< LwpObject > obj(VO_TYPE tag=VO_INVALID) const
@descr get object from object factory per the object id
Definition: lwpobjid.cxx:183
sal_uInt32 GetLow() const
Definition: lwpobjid.hxx:125
LwpSvStream * m_pStrm
Definition: lwpobj.hxx:92
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
LwpObjectID & GetObjectID()
Definition: lwpobj.hxx:138
point class
sal_Int32 GetY() const
sal_Int32 GetX() const
void CreateDrawObjects(std::vector< rtl::Reference< XFFrame > > *pDrawObjVector)
@descr entry of lwp-drawing objects.
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
LwpSvStream * GetCompressedStream()
Definition: lwpsvstream.hxx:86
static double ConvertFromUnitsToMetric(sal_Int32 nUnits)
Definition: lwptools.hxx:117
static OUString convertToFileUrl(const OString &fileName)
Definition: lwptools.cxx:204
bool IsFitGraphic()
@descr: Whether the size of layout is fit the graphic
Definition: lwplayout.cxx:401
double GetMarginsValue(sal_uInt8 nWhichSide)
Definition: lwplayout.hxx:153
virtual sal_uInt64 TellEnd()
A container for content.
virtual void Add(XFContent *pContent)
@descr Add content.
Style for all frame objects.
Image object.
Definition: xfimage.hxx:71
void SetFileURL(const OUString &url)
@descr Use file link source.a
Definition: xfimage.cxx:71
void SetImageData(sal_uInt8 const *buf, int len)
@descr Use base64 stream.
Definition: xfimage.cxx:77
Paragraph object for SODC.
Definition: xfparagraph.hxx:73
Style manager for the filter.
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
sal_Int32 nIndex
#define SAL_WARN(area, stream)
@ VO_FRAMELAYOUT
Definition: lwpdefs.hxx:84
#define EF_ODMA
Definition: lwpgrfobj.cxx:89
#define EF_NONE
Definition: lwpgrfobj.cxx:88
const sal_uInt8 MARGIN_BOTTOM
Definition: lwpmargins.hxx:66
const sal_uInt8 MARGIN_RIGHT
Definition: lwpmargins.hxx:64
const sal_uInt8 MARGIN_TOP
Definition: lwpmargins.hxx:65
const sal_uInt8 MARGIN_LEFT
Definition: lwpmargins.hxx:63
#define AFID_MAX_FILE_FORMAT_SIZE
const double TWIPS_PER_CM
Definition: lwptools.hxx:82
sal_uLong BenOpenContainer(LwpSvStream *pStream, std::unique_ptr< LtcBenContainer > *ppContainer)
New bento container from file stream.
Definition: bencont.cxx:74
constexpr OUStringLiteral aData
size
int sprintf(char(&s)[N], char const *format, T &&... arguments)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
sal_uIntPtr sal_uLong
IXFStyle * m_pStyle
Definition: xfstylecont.hxx:71
sal_uInt8 nContrast
Definition: lwpgrfobj.hxx:72
sal_uInt8 nBrightness
Definition: lwpgrfobj.hxx:71
sal_uInt8 nSmoothing
Definition: lwpgrfobj.hxx:74
sal_uInt8 nEdgeEnhancement
Definition: lwpgrfobj.hxx:73
tools::Long Height
tools::Long Width
unsigned long LinkedFileSize
unsigned long LinkedFileTime
unsigned char sal_uInt8
ResultType type
@ enumXFFrameYPosFromTop
Definition: xfdefs.hxx:333
@ enumXFFrameYPosMiddle
Definition: xfdefs.hxx:331
@ enumXFFrameYRelFrame
Definition: xfdefs.hxx:318
@ enumXFFrameYRelPara
Definition: xfdefs.hxx:323
@ enumXFFrameXPosCenter
Definition: xfdefs.hxx:310
@ enumXFFrameXPosFromLeft
Definition: xfdefs.hxx:311
@ enumXFAnchorFrame
Definition: xfdefs.hxx:262
@ enumXFFrameXRelFrame
Definition: xfdefs.hxx:300