Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/embed/Aspects.hpp>
30 : :
31 : : #include <hintids.hxx>
32 : :
33 : : #include <vcl/cvtgrf.hxx>
34 : : #include <vcl/virdev.hxx>
35 : : #include <com/sun/star/drawing/XShape.hpp>
36 : : #include <vcl/svapp.hxx>
37 : : #include <sot/storage.hxx>
38 : : #include <svtools/filter.hxx>
39 : : #include <svl/itemiter.hxx>
40 : : #include <svx/svdobj.hxx>
41 : : #include <svx/svdotext.hxx>
42 : : #include <svx/svdmodel.hxx>
43 : : #include <svx/svdpage.hxx>
44 : : #include <editeng/outlobj.hxx>
45 : : #include <editeng/editobj.hxx>
46 : : #include <svx/unoshape.hxx>
47 : : #include <editeng/brshitem.hxx>
48 : : #include <editeng/boxitem.hxx>
49 : : #include <editeng/lrspitem.hxx>
50 : : #include <editeng/ulspitem.hxx>
51 : : #include <editeng/fontitem.hxx>
52 : : #include <editeng/frmdiritem.hxx>
53 : : #include <svx/svdoole2.hxx>
54 : : #include <editeng/editeng.hxx>
55 : : #include <editeng/flditem.hxx>
56 : : #include <comphelper/seqstream.hxx>
57 : : #include <unotools/ucbstreamhelper.hxx>
58 : : #include <svx/fmglob.hxx>
59 : : #include <svx/svdouno.hxx>
60 : : #include <svx/unoapi.hxx>
61 : :
62 : : // #i71538#
63 : : #include <svx/svdview.hxx>
64 : : #include <fmtcnct.hxx>
65 : : #include <fmtanchr.hxx>
66 : : #include <fmtsrnd.hxx>
67 : : #include <fmtornt.hxx>
68 : : #include <fmtfsize.hxx>
69 : : #include <fmtfollowtextflow.hxx> // #i30669#
70 : : #include <dcontact.hxx>
71 : : #include <frmfmt.hxx>
72 : : #include <flyfrm.hxx>
73 : : #include <pagefrm.hxx>
74 : : #include <frmatr.hxx>
75 : : #include <fmtcntnt.hxx>
76 : : #include <ndindex.hxx>
77 : : #include <doc.hxx>
78 : : #include <docary.hxx>
79 : : #include <pam.hxx>
80 : : #include <swrect.hxx>
81 : : #include <ndgrf.hxx>
82 : : #include <grfatr.hxx>
83 : : #include <ndole.hxx>
84 : : #include <unodraw.hxx>
85 : : #include <pagedesc.hxx>
86 : : #include <ww8par.hxx>
87 : : #include <breakit.hxx>
88 : : #include <com/sun/star/i18n/ScriptType.hpp>
89 : : #include "ww8attributeoutput.hxx"
90 : : #include "writerhelper.hxx"
91 : : #include "writerwordglue.hxx"
92 : : #include "wrtww8.hxx"
93 : : #include "escher.hxx"
94 : : #include <ndtxt.hxx>
95 : : #include "WW8FFData.hxx"
96 : : #include <com/sun/star/beans/XPropertyContainer.hpp>
97 : : #include <com/sun/star/beans/XPropertySet.hpp>
98 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
99 : : #include <com/sun/star/form/XFormComponent.hpp>
100 : : #include <comphelper/processfactory.hxx>
101 : : #include "docsh.hxx"
102 : : #include <oox/ole/olehelper.hxx>
103 : : #include <comphelper/componentcontext.hxx>
104 : : #include <fstream>
105 : : #include <unotools/streamwrap.hxx>
106 : :
107 : :
108 : : using ::editeng::SvxBorderLine;
109 : : using namespace com::sun::star;
110 : : using namespace sw::util;
111 : : using namespace sw::types;
112 : : using namespace nsFieldFlags;
113 : :
114 : : namespace
115 : : {
116 : : /// Get the Z ordering number for a DrawObj in a WW8Export.
117 : : /// @param rWrt The containing WW8Export.
118 : : /// @param pObj pointer to the drawing object.
119 : : /// @returns The ordering number.
120 : 0 : static sal_uLong lcl_getSdrOrderNumber(const WW8Export& rWrt, DrawObj *pObj)
121 : : {
122 : 0 : return rWrt.GetSdrOrdNum(pObj->maCntnt.GetFrmFmt());
123 : : };
124 : :
125 : : /// A function object to act as a predicate comparing the ordering numbers
126 : : /// of two drawing obejcts in a WW8Export.
127 : : class CompareDrawObjs
128 : : {
129 : : private:
130 : : const WW8Export& wrt;
131 : :
132 : : public:
133 : 9 : CompareDrawObjs(const WW8Export& rWrt) : wrt(rWrt) {};
134 : 0 : bool operator()(DrawObj *a, DrawObj *b) const
135 : : {
136 : 0 : sal_uLong aSort = ::lcl_getSdrOrderNumber(wrt, a);
137 : 0 : sal_uLong bSort = ::lcl_getSdrOrderNumber(wrt, b);
138 : 0 : return aSort < bSort;
139 : : }
140 : : };
141 : :
142 : : /// Make a z-order sorted copy of a collection of DrawObj objects.
143 : : /// @param rWrt The containing WW8Export.
144 : : /// @param rSrcArr The source array.
145 : : /// @param rDstArr The destination array.
146 : 9 : static void lcl_makeZOrderArray(const WW8Export& rWrt,
147 : : std::vector<DrawObj> &rSrcArr,
148 : : std::vector<DrawObj*> &rDstArr)
149 : : {
150 : 9 : rDstArr.clear();
151 : 9 : rDstArr.reserve(rSrcArr.size());
152 [ + + ]: 15 : for(size_t i = 0; i < rSrcArr.size(); ++i)
153 : : {
154 [ + - ]: 6 : rDstArr.push_back( &rSrcArr[i] );
155 : : }
156 [ + - ]: 9 : std::sort(rDstArr.begin(), rDstArr.end(), ::CompareDrawObjs(rWrt));
157 : 9 : }
158 : :
159 : : }
160 : :
161 : : // get a part fix for this type of element
162 : 0 : bool WW8Export::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt)
163 : : {
164 : : OSL_ENSURE(bWrtWW8, "Not allowed");
165 [ # # ]: 0 : if (!bWrtWW8)
166 : 0 : return false;
167 : 0 : bool bHack = false;
168 : 0 : const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
169 [ # # ][ # # ]: 0 : if (pObject && pObject->GetObjInventor() == FmFormInventor)
[ # # ]
170 : : {
171 [ # # ][ # # ]: 0 : if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
[ # # ]
172 : : {
173 : : uno::Reference< awt::XControlModel > xControlModel =
174 [ # # ]: 0 : pFormObj->GetUnoControlModel();
175 : : uno::Reference< lang::XServiceInfo > xInfo(xControlModel,
176 [ # # ]: 0 : uno::UNO_QUERY);
177 [ # # ]: 0 : uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
178 [ # # ][ # # ]: 0 : if (xInfo->supportsService(C2U("com.sun.star.form.component.ComboBox")))
[ # # ][ # # ]
179 : : {
180 [ # # ]: 0 : DoComboBox(xPropSet);
181 : 0 : bHack = true;
182 : : }
183 [ # # ][ # # ]: 0 : else if (xInfo->supportsService(C2U("com.sun.star.form.component.CheckBox")))
[ # # ][ # # ]
184 : : {
185 [ # # ]: 0 : DoCheckBox(xPropSet);
186 : 0 : bHack = true;
187 : 0 : }
188 : : }
189 : : }
190 : 0 : return bHack;
191 : : }
192 : :
193 : :
194 : 0 : void WW8Export::DoComboBox(uno::Reference<beans::XPropertySet> xPropSet)
195 : : {
196 : 0 : rtl::OUString sSelected;
197 [ # # ]: 0 : uno::Sequence<rtl::OUString> aListItems;
198 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(C2U("StringItemList")) >>= aListItems;
[ # # ][ # # ]
199 : 0 : sal_Int32 nNoStrings = aListItems.getLength();
200 [ # # ]: 0 : if (nNoStrings)
201 : : {
202 [ # # ][ # # ]: 0 : uno::Any aTmp = xPropSet->getPropertyValue(C2U("DefaultText"));
[ # # ]
203 : 0 : const rtl::OUString *pStr = (const rtl::OUString *)aTmp.getValue();
204 [ # # ]: 0 : if (pStr)
205 : 0 : sSelected = *pStr;
206 : : }
207 : :
208 : 0 : rtl::OUString sName;
209 : : {
210 [ # # ][ # # ]: 0 : uno::Any aTmp = xPropSet->getPropertyValue(C2U("Name"));
[ # # ]
211 : 0 : const rtl::OUString *pStr = (const rtl::OUString *)aTmp.getValue();
212 [ # # ]: 0 : if (pStr)
213 : 0 : sName = *pStr;
214 : : }
215 : :
216 : :
217 : 0 : rtl::OUString sHelp;
218 : : {
219 : : // property "Help" does not exist and due to the no-existence an exception is thrown.
220 : : try
221 : : {
222 [ # # ][ # # ]: 0 : uno::Any aTmp = xPropSet->getPropertyValue(C2U("HelpText"));
[ # # ][ # # ]
223 : 0 : const rtl::OUString *pStr = (const rtl::OUString *)aTmp.getValue();
224 [ # # ]: 0 : if (pStr)
225 : 0 : sHelp = *pStr;
226 : : }
227 [ # # ]: 0 : catch( const uno::Exception& )
228 : : {}
229 : : }
230 : :
231 : 0 : rtl::OUString sToolTip;
232 : : {
233 [ # # ][ # # ]: 0 : uno::Any aTmp = xPropSet->getPropertyValue(C2U("Name"));
[ # # ]
234 : 0 : const rtl::OUString *pStr = (const rtl::OUString *)aTmp.getValue();
235 [ # # ]: 0 : if (pStr)
236 : 0 : sToolTip = *pStr;
237 : : }
238 : :
239 [ # # ][ # # ]: 0 : DoComboBox(sName, sHelp, sToolTip, sSelected, aListItems);
240 : 0 : }
241 : :
242 : 0 : void WW8Export::DoComboBox(const rtl::OUString &rName,
243 : : const rtl::OUString &rHelp,
244 : : const rtl::OUString &rToolTip,
245 : : const rtl::OUString &rSelected,
246 : : uno::Sequence<rtl::OUString> &rListItems)
247 : : {
248 : : OSL_ENSURE(bWrtWW8, "Not allowed");
249 [ # # ]: 0 : if (!bWrtWW8)
250 : 0 : return;
251 : : OutputField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
252 [ # # ][ # # ]: 0 : WRITEFIELD_START | WRITEFIELD_CMD_START);
[ # # ]
253 : : // write the refence to the "picture" structure
254 : 0 : sal_uLong nDataStt = pDataStrm->Tell();
255 [ # # ][ # # ]: 0 : pChpPlc->AppendFkpEntry( Strm().Tell() );
256 : :
257 [ # # ]: 0 : WriteChar( 0x01 );
258 : :
259 : : static sal_uInt8 aArr1[] =
260 : : {
261 : : 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
262 : : 0x06, 0x08, 0x01, // sprmCFData
263 : : 0x55, 0x08, 0x01, // sprmCFSpec
264 : : 0x02, 0x08, 0x01 // sprmCFFldVanish
265 : : };
266 : 0 : sal_uInt8* pDataAdr = aArr1 + 2;
267 : 0 : Set_UInt32( pDataAdr, nDataStt );
268 : :
269 [ # # ][ # # ]: 0 : pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof(aArr1), aArr1);
270 : :
271 : : OutputField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
272 [ # # ][ # # ]: 0 : WRITEFIELD_CLOSE);
[ # # ]
273 : :
274 [ # # ]: 0 : ::sw::WW8FFData aFFData;
275 : :
276 : 0 : aFFData.setType(2);
277 : 0 : aFFData.setName(rName);
278 [ # # ]: 0 : aFFData.setHelp(rHelp);
279 [ # # ]: 0 : aFFData.setStatus(rToolTip);
280 : :
281 : 0 : sal_uInt32 nListItems = rListItems.getLength();
282 : :
283 [ # # ]: 0 : for (sal_uInt32 i = 0; i < nListItems; i++)
284 : : {
285 [ # # ][ # # ]: 0 : if (i < 0x20 && rSelected == rListItems[i])
[ # # ][ # # ]
286 : 0 : aFFData.setResult(::sal::static_int_cast<sal_uInt8>(i));
287 [ # # ][ # # ]: 0 : aFFData.addListboxEntry(rListItems[i]);
288 : : }
289 : :
290 [ # # ][ # # ]: 0 : aFFData.Write(pDataStrm);
291 : : }
292 : :
293 : 0 : void WW8Export::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet)
294 : : {
295 : : uno::Reference<beans::XPropertySetInfo> xPropSetInfo =
296 [ # # ][ # # ]: 0 : xPropSet->getPropertySetInfo();
297 : :
298 : : OutputField(0, ww::eFORMCHECKBOX, FieldString(ww::eFORMCHECKBOX),
299 [ # # ][ # # ]: 0 : WRITEFIELD_START | WRITEFIELD_CMD_START);
[ # # ]
300 : : // write the refence to the "picture" structure
301 : 0 : sal_uLong nDataStt = pDataStrm->Tell();
302 [ # # ][ # # ]: 0 : pChpPlc->AppendFkpEntry( Strm().Tell() );
303 : :
304 [ # # ]: 0 : WriteChar( 0x01 );
305 : : static sal_uInt8 aArr1[] = {
306 : : 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
307 : :
308 : : 0x06, 0x08, 0x01, // sprmCFData
309 : : 0x55, 0x08, 0x01, // sprmCFSpec
310 : : 0x02, 0x08, 0x01 // sprmCFFldVanish
311 : : };
312 : 0 : sal_uInt8* pDataAdr = aArr1 + 2;
313 : 0 : Set_UInt32( pDataAdr, nDataStt );
314 : :
315 [ # # ]: 0 : pChpPlc->AppendFkpEntry(Strm().Tell(),
316 [ # # ]: 0 : sizeof( aArr1 ), aArr1 );
317 : :
318 [ # # ]: 0 : ::sw::WW8FFData aFFData;
319 : :
320 : 0 : aFFData.setType(1);
321 : 0 : aFFData.setCheckboxHeight(0x14);
322 : :
323 : 0 : sal_Int16 nTemp = 0;
324 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(C2U("DefaultState")) >>= nTemp;
[ # # ]
325 : 0 : aFFData.setDefaultResult(nTemp);
326 : :
327 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(C2U("State")) >>= nTemp;
[ # # ]
328 : 0 : aFFData.setResult(nTemp);
329 : :
330 : 0 : ::rtl::OUString aStr;
331 [ # # ][ # # ]: 0 : static ::rtl::OUString sName(C2U("Name"));
[ # # ][ # # ]
332 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sName))
[ # # ]
333 : : {
334 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sName) >>= aStr;
335 : 0 : aFFData.setName(aStr);
336 : : }
337 : :
338 [ # # ][ # # ]: 0 : static ::rtl::OUString sHelpText(C2U("HelpText"));
[ # # ][ # # ]
339 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sHelpText))
[ # # ]
340 : : {
341 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sHelpText) >>= aStr;
342 [ # # ]: 0 : aFFData.setHelp(aStr);
343 : : }
344 [ # # ][ # # ]: 0 : static ::rtl::OUString sHelpF1Text(C2U("HelpF1Text"));
[ # # ][ # # ]
345 [ # # ][ # # ]: 0 : if (xPropSetInfo->hasPropertyByName(sHelpF1Text))
[ # # ]
346 : : {
347 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(sHelpF1Text) >>= aStr;
348 [ # # ]: 0 : aFFData.setStatus(aStr);
349 : : }
350 : :
351 [ # # ]: 0 : aFFData.Write(pDataStrm);
352 : :
353 [ # # ][ # # ]: 0 : OutputField(0, ww::eFORMCHECKBOX, aEmptyStr, WRITEFIELD_CLOSE);
354 : 0 : }
355 : :
356 : 0 : void WW8Export::DoFormText(const SwInputField * pFld)
357 : : {
358 : : OutputField(0, ww::eFORMTEXT, FieldString(ww::eFORMTEXT),
359 [ # # ][ # # ]: 0 : WRITEFIELD_START | WRITEFIELD_CMD_START);
[ # # ]
360 : : // write the refence to the "picture" structure
361 : 0 : sal_uLong nDataStt = pDataStrm->Tell();
362 [ # # ][ # # ]: 0 : pChpPlc->AppendFkpEntry( Strm().Tell() );
363 : :
364 [ # # ]: 0 : WriteChar( 0x01 );
365 : : static sal_uInt8 aArr1[] = {
366 : : 0x02, 0x08, 0x81, // sprmCFFldVanish
367 : : 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
368 : :
369 : : 0x06, 0x08, 0x01, // sprmCFData
370 : : 0x55, 0x08, 0x01 // sprmCFSpec
371 : : };
372 : 0 : sal_uInt8* pDataAdr = aArr1 + 5;
373 : 0 : Set_UInt32( pDataAdr, nDataStt );
374 : :
375 [ # # ]: 0 : pChpPlc->AppendFkpEntry(Strm().Tell(),
376 [ # # ]: 0 : sizeof( aArr1 ), aArr1 );
377 : :
378 [ # # ]: 0 : ::sw::WW8FFData aFFData;
379 : :
380 : 0 : aFFData.setType(0);
381 [ # # ]: 0 : aFFData.setName(pFld->GetPar2());
382 [ # # ][ # # ]: 0 : aFFData.setHelp(pFld->GetHelp());
[ # # ][ # # ]
383 [ # # ][ # # ]: 0 : aFFData.setStatus(pFld->GetToolTip());
[ # # ][ # # ]
384 [ # # ]: 0 : aFFData.Write(pDataStrm);
385 : :
386 [ # # ]: 0 : OutputField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CMD_END);
387 : :
388 [ # # ]: 0 : String const fieldStr( pFld->ExpandField(true) );
389 [ # # ][ # # ]: 0 : SwWW8Writer::WriteString16(Strm(), fieldStr, false);
390 : :
391 : : static sal_uInt8 aArr2[] = {
392 : : 0x03, 0x6a, 0x00, 0x00, 0x00, 0x00, // sprmCPicLocation
393 : : 0x55, 0x08, 0x01, // sprmCFSpec
394 : : 0x75, 0x08, 0x01 // ???
395 : : };
396 : :
397 : 0 : pDataAdr = aArr2 + 2;
398 : 0 : Set_UInt32( pDataAdr, nDataStt );
399 [ # # ]: 0 : pChpPlc->AppendFkpEntry(Strm().Tell(),
400 [ # # ]: 0 : sizeof( aArr2 ), aArr2 );
401 : :
402 [ # # ][ # # ]: 0 : OutputField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CLOSE);
[ # # ]
403 : 0 : }
404 : :
405 : 18 : PlcDrawObj::~PlcDrawObj()
406 : : {
407 [ - + ]: 18 : }
408 : :
409 : : //Its irritating to have to change the RTL frames position into LTR ones
410 : : //so that word will have to place them in the right place. Doubly so that
411 : : //the SO drawings and writer frames have different ideas themselves as to
412 : : //how to be positioned when in RTL mode!
413 : 0 : bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
414 : : sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
415 : : SwTwips nPageRight, SwTwips nPageSize)
416 : : {
417 : 0 : bool bRet = false;
418 [ # # ]: 0 : if (eHoriOri == text::HoriOrientation::NONE)
419 : : {
420 [ # # ]: 0 : if (eHoriRel == text::RelOrientation::PAGE_FRAME)
421 : : {
422 : 0 : rLeft = nPageSize - rLeft;
423 : 0 : bRet = true;
424 : : }
425 [ # # ][ # # ]: 0 : else if (
[ # # ]
426 : : (eHoriRel == text::RelOrientation::PAGE_PRINT_AREA) ||
427 : : (eHoriRel == text::RelOrientation::FRAME) ||
428 : : (eHoriRel == text::RelOrientation::PRINT_AREA)
429 : : )
430 : : {
431 : 0 : rLeft = nPageSize - nPageLeft - nPageRight - rLeft;
432 : 0 : bRet = true;
433 : : }
434 : : }
435 [ # # ]: 0 : if (bRet)
436 : 0 : rLeft -= nWidth;
437 : 0 : return bRet;
438 : : }
439 : :
440 : 0 : bool RTLDrawingsHack(long &rLeft, long /*nWidth*/,
441 : : sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
442 : : SwTwips nPageRight, SwTwips nPageSize)
443 : : {
444 : 0 : bool bRet = false;
445 [ # # ]: 0 : if (eHoriOri == text::HoriOrientation::NONE)
446 : : {
447 [ # # ]: 0 : if (eHoriRel == text::RelOrientation::PAGE_FRAME)
448 : : {
449 : 0 : rLeft = nPageSize + rLeft;
450 : 0 : bRet = true;
451 : : }
452 [ # # ][ # # ]: 0 : else if (
[ # # ]
453 : : (eHoriRel == text::RelOrientation::PAGE_PRINT_AREA) ||
454 : : (eHoriRel == text::RelOrientation::FRAME) ||
455 : : (eHoriRel == text::RelOrientation::PRINT_AREA)
456 : : )
457 : : {
458 : 0 : rLeft = nPageSize - nPageLeft - nPageRight + rLeft;
459 : 0 : bRet = true;
460 : : }
461 : : }
462 : 0 : return bRet;
463 : : }
464 : :
465 : 6 : bool WW8Export::MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight,
466 : : const sw::Frame &rFrmFmt)
467 : : {
468 : : //Require nasty bidi swap
469 [ + - ][ + - ]: 6 : if (FRMDIR_HORI_RIGHT_TOP != pDoc->GetTextDirection(rFrmFmt.GetPosition()))
470 : 6 : return false;
471 : :
472 : 0 : SwTwips nWidth = rRight - rLeft;
473 : : SwTwips nPageLeft, nPageRight;
474 [ # # ]: 0 : SwTwips nPageSize = CurrentPageWidth(nPageLeft, nPageRight);
475 : :
476 [ # # ]: 0 : const SwFmtHoriOrient& rHOr = rFrmFmt.GetFrmFmt().GetHoriOrient();
477 : :
478 : 0 : bool bRet = false;
479 : 0 : sw::Frame::WriterSource eSource = rFrmFmt.GetWriterType();
480 [ # # ][ # # ]: 0 : if (eSource == sw::Frame::eDrawing || eSource == sw::Frame::eFormControl)
481 : : {
482 [ # # ]: 0 : if (RTLDrawingsHack(rLeft, nWidth, rHOr.GetHoriOrient(),
483 : 0 : rHOr.GetRelationOrient(), nPageLeft, nPageRight, nPageSize))
484 : : {
485 : 0 : bRet = true;
486 : : }
487 : : }
488 : : else
489 : : {
490 [ # # ]: 0 : if (RTLGraphicsHack(rLeft, nWidth, rHOr.GetHoriOrient(),
491 : 0 : rHOr.GetRelationOrient(), nPageLeft, nPageRight, nPageSize))
492 : : {
493 : 0 : bRet = true;
494 : : }
495 : : }
496 [ # # ]: 0 : if (bRet)
497 : 0 : rRight = rLeft + nWidth;
498 : 6 : return bRet;
499 : : }
500 : :
501 : 18 : void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
502 : : {
503 [ - + ]: 18 : if (8 > rWrt.pFib->nVersion) // Cannot export drawobject in vers 7-
504 : 18 : return;
505 : :
506 : 18 : sal_uInt32 nFcStart = rWrt.pTableStrm->Tell();
507 : :
508 [ + + ]: 18 : if (!maDrawObjs.empty())
509 : : {
510 : : // write CPs
511 : 6 : WW8Fib& rFib = *rWrt.pFib;
512 [ + - ]: 6 : WW8_CP nCpOffs = GetCpOffset(rFib);
513 : :
514 : 6 : cDrawObjIter aEnd = maDrawObjs.end();
515 : 6 : cDrawObjIter aIter;
516 : :
517 [ + - ][ + + ]: 12 : for (aIter = maDrawObjs.begin(); aIter < aEnd; ++aIter)
518 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm, aIter->mnCp - nCpOffs);
519 : :
520 : : SwWW8Writer::WriteLong(*rWrt.pTableStrm, rFib.ccpText + rFib.ccpFtn +
521 [ + - ]: 6 : rFib.ccpHdr + rFib.ccpEdn + rFib.ccpTxbx + rFib.ccpHdrTxbx + 1);
522 : :
523 [ + - ][ + + ]: 12 : for (aIter = maDrawObjs.begin(); aIter < aEnd; ++aIter)
524 : : {
525 : : // write the fspa-struct
526 : 6 : const sw::Frame &rFrmFmt = aIter->maCntnt;
527 : 6 : const SwFrmFmt &rFmt = rFrmFmt.GetFrmFmt();
528 [ + - ]: 6 : const SdrObject* pObj = rFmt.FindRealSdrObject();
529 : :
530 [ + - ]: 6 : Rectangle aRect;
531 [ + - ][ + - ]: 6 : SwFmtVertOrient rVOr = rFmt.GetVertOrient();
532 [ + - ][ + - ]: 6 : SwFmtHoriOrient rHOr = rFmt.GetHoriOrient();
533 : : // #i30669# - convert the positioning attributes.
534 : : // Most positions are converted, if layout information exists.
535 : : const bool bPosConverted =
536 [ + - ]: 6 : WinwordAnchoring::ConvertPosition( rHOr, rVOr, rFmt );
537 : :
538 : 6 : Point aObjPos;
539 [ + + ]: 6 : if (RES_FLYFRMFMT == rFmt.Which())
540 : : {
541 [ + - ]: 3 : SwRect aLayRect(rFmt.FindLayoutRect(false, &aObjPos));
542 : : // the Object is not visible - so get the values from
543 : : // the format. The Position may not be correct.
544 [ - + ]: 3 : if( aLayRect.IsEmpty() )
545 [ # # ][ # # ]: 0 : aRect.SetSize( rFmt.GetFrmSize().GetSize() );
546 : : else
547 : : {
548 : : // #i56090# Do not only consider the first client
549 : : // Note that we actually would have to find the maximum size of the
550 : : // frame format clients. However, this already should work in most cases.
551 [ + - ]: 3 : const SwRect aSizeRect(rFmt.FindLayoutRect());
552 [ - + ]: 3 : if ( aSizeRect.Width() > aLayRect.Width() )
553 : 0 : aLayRect.Width( aSizeRect.Width() );
554 : :
555 [ + - ]: 3 : aRect = aLayRect.SVRect();
556 : : }
557 : : }
558 : : else
559 : : {
560 : : OSL_ENSURE(pObj, "wo ist das SDR-Object?");
561 [ + - ]: 3 : if (pObj)
562 : : {
563 [ + - ]: 3 : aRect = pObj->GetSnapRect();
564 : : }
565 : : }
566 : :
567 : : // #i30669# - use converted position, if conversion is performed.
568 : : // Unify position determination of Writer fly frames
569 : : // and drawing objects.
570 [ - + ]: 6 : if ( bPosConverted )
571 : : {
572 : 0 : aRect.SetPos( Point( rHOr.GetPos(), rVOr.GetPos() ) );
573 : : }
574 : : else
575 : : {
576 [ + - ]: 6 : aRect -= aIter->maParentPos;
577 : 6 : aObjPos = aRect.TopLeft();
578 [ + - ]: 6 : if (text::VertOrientation::NONE == rVOr.GetVertOrient())
579 : : {
580 : : // #i22673#
581 : 6 : sal_Int16 eOri = rVOr.GetRelationOrient();
582 [ - + ][ + - ]: 6 : if (eOri == text::RelOrientation::CHAR || eOri == text::RelOrientation::TEXT_LINE)
583 : 0 : aObjPos.Y() = -rVOr.GetPos();
584 : : else
585 : 6 : aObjPos.Y() = rVOr.GetPos();
586 : : }
587 [ + - ]: 6 : if (text::HoriOrientation::NONE == rHOr.GetHoriOrient())
588 : 6 : aObjPos.X() = rHOr.GetPos();
589 : 6 : aRect.SetPos( aObjPos );
590 : : }
591 : :
592 : 6 : sal_Int32 nThick = aIter->mnThick;
593 : :
594 : : //If we are being exported as an inline hack, set
595 : : //corner to 0 and forget about border thickness for positioning
596 [ - + ][ + - ]: 6 : if (rFrmFmt.IsInline())
597 : : {
598 : 0 : aRect.SetPos(Point(0,0));
599 : 0 : nThick = 0;
600 : : }
601 : :
602 : : // spid
603 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm, aIter->mnShapeId);
604 : :
605 : 6 : SwTwips nLeft = aRect.Left() + nThick;
606 : 6 : SwTwips nRight = aRect.Right() - nThick;
607 : :
608 : : //Nasty swap for bidi if neccessary
609 [ + - ]: 6 : rWrt.MiserableRTLFrmFmtHack(nLeft, nRight, rFrmFmt);
610 : :
611 : : //xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
612 : : //(most of) the border is outside the graphic is word, so
613 : : //change dimensions to fit
614 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm, nLeft);
615 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm,aRect.Top() + nThick);
616 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm, nRight);
617 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm,aRect.Bottom() - nThick);
618 : :
619 : : //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
620 : 6 : sal_uInt16 nFlags=0;
621 : : //If nFlags isn't 0x14 its overridden by the escher properties
622 [ + - ][ - + ]: 6 : if (FLY_AT_PAGE == rFmt.GetAnchor().GetAnchorId())
623 : 0 : nFlags = 0x0000;
624 : : else
625 : 6 : nFlags = 0x0014; // x-rel to text, y-rel to text
626 : :
627 [ + - ]: 6 : const SwFmtSurround& rSurr = rFmt.GetSurround();
628 [ - + ]: 6 : sal_uInt16 nContour = rSurr.IsContour() ? 0x0080 : 0x0040;
629 : 6 : SwSurround eSurround = rSurr.GetSurround();
630 : :
631 : : /*
632 : : #i3958#
633 : : The inline elements being export as anchored to character inside
634 : : the shape field hack are required to be wrap through so as to flow
635 : : over the following dummy 0x01 graphic
636 : : */
637 [ - + ][ + - ]: 6 : if (rFrmFmt.IsInline())
638 : 0 : eSurround = SURROUND_THROUGHT;
639 : :
640 [ - + - - : 6 : switch (eSurround)
- - - ]
641 : : {
642 : : case SURROUND_NONE:
643 : 0 : nFlags |= 0x0020;
644 : 0 : break;
645 : : case SURROUND_THROUGHT:
646 : 6 : nFlags |= 0x0060;
647 : 6 : break;
648 : : case SURROUND_PARALLEL:
649 : 0 : nFlags |= 0x0000 | nContour;
650 : 0 : break;
651 : : case SURROUND_IDEAL:
652 : 0 : nFlags |= 0x0600 | nContour;
653 : 0 : break;
654 : : case SURROUND_LEFT:
655 : 0 : nFlags |= 0x0200 | nContour;
656 : 0 : break;
657 : : case SURROUND_RIGHT:
658 : 0 : nFlags |= 0x0400 | nContour;
659 : 0 : break;
660 : : default:
661 : : OSL_ENSURE(!this, "Unsupported surround type for export");
662 : 0 : break;
663 : : }
664 [ + - ][ + - ]: 9 : if (pObj && (pObj->GetLayer() == rWrt.pDoc->GetHellId() ||
[ + - ][ + + ]
[ - + ][ + + ]
665 [ + - ][ + - ]: 3 : pObj->GetLayer() == rWrt.pDoc->GetInvisibleHellId()))
666 : : {
667 : 3 : nFlags |= 0x4000;
668 : : }
669 : :
670 : : /*
671 : : #i3958# Required to make this inline stuff work in WordXP, not
672 : : needed for 2003 interestingly
673 : : */
674 [ + - ][ - + ]: 6 : if (rFrmFmt.IsInline())
675 : 0 : nFlags |= 0x8000;
676 : :
677 [ + - ]: 6 : SwWW8Writer::WriteShort(*rWrt.pTableStrm, nFlags);
678 : :
679 : : // cTxbx
680 [ + - ]: 6 : SwWW8Writer::WriteLong(*rWrt.pTableStrm, 0);
681 [ + - ][ + - ]: 6 : }
682 : :
683 [ + - ]: 6 : RegisterWithFib(rFib, nFcStart, rWrt.pTableStrm->Tell() - nFcStart);
684 : : }
685 : : }
686 : :
687 : 3 : void MainTxtPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
688 : : sal_uInt32 nLen) const
689 : : {
690 : 3 : rFib.fcPlcfspaMom = nStart;
691 : 3 : rFib.lcbPlcfspaMom = nLen;
692 : 3 : }
693 : :
694 : 3 : WW8_CP MainTxtPlcDrawObj::GetCpOffset(const WW8Fib &) const
695 : : {
696 : 3 : return 0;
697 : : }
698 : :
699 : 3 : void HdFtPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
700 : : sal_uInt32 nLen) const
701 : : {
702 : 3 : rFib.fcPlcfspaHdr = nStart;
703 : 3 : rFib.lcbPlcfspaHdr = nLen;
704 : 3 : }
705 : :
706 : 3 : WW8_CP HdFtPlcDrawObj::GetCpOffset(const WW8Fib &rFib) const
707 : : {
708 : 3 : return rFib.ccpText + rFib.ccpFtn;
709 : : }
710 : :
711 : 0 : DrawObj& DrawObj::operator=(const DrawObj& rOther)
712 : : {
713 : 0 : mnCp = rOther.mnCp;
714 : 0 : mnShapeId = rOther.mnShapeId;
715 : 0 : maCntnt = rOther.maCntnt;
716 : 0 : maParentPos = rOther.maParentPos;
717 : 0 : mnThick = rOther.mnThick;
718 : 0 : mnDirection = rOther.mnDirection;
719 : 0 : mnHdFtIndex = rOther.mnHdFtIndex;
720 : 0 : return *this;
721 : : }
722 : :
723 : 6 : bool PlcDrawObj::Append( WW8Export& rWrt, WW8_CP nCp, const sw::Frame& rFmt,
724 : : const Point& rNdTopLeft )
725 : : {
726 : 6 : bool bRet = false;
727 : 6 : const SwFrmFmt &rFormat = rFmt.GetFrmFmt();
728 [ + - ][ + + ]: 6 : if (TXT_HDFT == rWrt.nTxtTyp || TXT_MAINTEXT == rWrt.nTxtTyp)
729 : : {
730 [ + + ]: 6 : if (RES_FLYFRMFMT == rFormat.Which())
731 : : {
732 : : // check for textflyframe and if it is the first in a Chain
733 [ + - ]: 3 : if (rFormat.GetCntnt().GetCntntIdx())
734 : 3 : bRet = true;
735 : : }
736 : : else
737 : 3 : bRet = true;
738 : : }
739 : :
740 [ + - ]: 6 : if (bRet)
741 : : {
742 [ + - ]: 6 : DrawObj aObj(rFmt, nCp, rNdTopLeft, rWrt.TrueFrameDirection(rFormat),
743 [ + - ]: 12 : rWrt.GetHdFtIndex());
744 [ + - ][ + - ]: 6 : maDrawObjs.push_back(aObj);
745 : : }
746 : 6 : return bRet;
747 : : }
748 : :
749 : 6 : void DrawObj::SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick)
750 : : {
751 : 6 : mnShapeId = nId;
752 : 6 : mnThick = nThick;
753 : 6 : }
754 : :
755 : 18 : bool WW8_WrPlcTxtBoxes::WriteTxt( WW8Export& rWrt )
756 : : {
757 : 18 : bool bRet = false;
758 : 18 : rWrt.bInWriteEscher = true;
759 [ + + ]: 18 : WW8_CP& rccp=TXT_TXTBOX == nTyp ? rWrt.pFib->ccpTxbx : rWrt.pFib->ccpHdrTxbx;
760 : :
761 : 18 : bRet = WriteGenericTxt( rWrt, nTyp, rccp );
762 : :
763 : 18 : WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
764 : 18 : WW8Fib& rFib = *rWrt.pFib;
765 : : WW8_CP nMyOffset = rFib.ccpText + rFib.ccpFtn + rFib.ccpHdr + rFib.ccpAtn
766 : 18 : + rFib.ccpEdn;
767 [ + + ]: 18 : if( TXT_TXTBOX == nTyp )
768 : 9 : rWrt.pFldTxtBxs->Finish( nCP, nMyOffset );
769 : : else
770 : 9 : rWrt.pFldHFTxtBxs->Finish( nCP, nMyOffset + rFib.ccpTxbx );
771 : 18 : rWrt.bInWriteEscher = false;
772 : 18 : return bRet;
773 : : }
774 : :
775 : 3 : void WW8_WrPlcTxtBoxes::Append( const SdrObject& rObj, sal_uInt32 nShapeId )
776 : : {
777 [ + - ]: 3 : aCntnt.push_back( &rObj );
778 : 3 : aShapeIds.push_back( nShapeId );
779 : 3 : }
780 : :
781 : 3 : const std::vector<sal_uInt32>* WW8_WrPlcTxtBoxes::GetShapeIdArr() const
782 : : {
783 : 3 : return &aShapeIds;
784 : : }
785 : :
786 : :
787 : 0 : sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrmFmt& rFmt ) const
788 : : {
789 : : sal_uInt32 nOrdNum;
790 : 0 : const SdrObject* pObj = rFmt.FindRealSdrObject();
791 [ # # ]: 0 : if( pObj )
792 : 0 : nOrdNum = pObj->GetOrdNum();
793 : : else
794 : : {
795 : : // no Layout for this format, then recalc the ordnum
796 : 0 : SwFrmFmt* pFmt = (SwFrmFmt*)&rFmt;
797 : 0 : nOrdNum = pDoc->GetSpzFrmFmts()->GetPos( pFmt );
798 : :
799 : 0 : const SdrModel* pModel = pDoc->GetDrawModel();
800 [ # # ]: 0 : if( pModel )
801 : 0 : nOrdNum += pModel->GetPage( 0 )->GetObjCount();
802 : : }
803 : 0 : return nOrdNum;
804 : : }
805 : :
806 : 6 : void WW8Export::AppendFlyInFlys(const sw::Frame& rFrmFmt,
807 : : const Point& rNdTopLeft)
808 : : {
809 : : OSL_ENSURE(bWrtWW8, "this has gone horribly wrong");
810 : : OSL_ENSURE(!pEscher, "der EscherStream wurde schon geschrieben!");
811 [ - + ]: 6 : if (pEscher)
812 : 6 : return ;
813 : : PlcDrawObj *pDrwO;
814 [ + + ]: 6 : if (TXT_HDFT == nTxtTyp)
815 : 3 : pDrwO = pHFSdrObjs;
816 : : else
817 : 3 : pDrwO = pSdrObjs;
818 : :
819 [ - + ]: 6 : if (rFrmFmt.IsInline())
820 : : {
821 : : OutputField(0, ww::eSHAPE, FieldString(ww::eSHAPE),
822 [ # # ]: 0 : WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
823 : : }
824 : :
825 : 6 : WW8_CP nCP = Fc2Cp(Strm().Tell());
826 : 6 : bool bSuccess = pDrwO->Append(*this, nCP, rFrmFmt, rNdTopLeft);
827 : : OSL_ENSURE(bSuccess, "Couldn't export a graphical element!");
828 : :
829 [ + - ]: 6 : if (bSuccess)
830 : : {
831 : : static const sal_uInt8 aSpec8[] =
832 : : {
833 : : 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
834 : : 0x55, 0x08, 1 // sprmCFSpec
835 : : };
836 : : // fSpec-Attribut true
837 : : // Fuer DrawObjets muss ein Spezial-Zeichen
838 : : // in den Text und darum ein fSpec-Attribut
839 : 6 : pChpPlc->AppendFkpEntry( Strm().Tell() );
840 : 6 : WriteChar( 0x8 );
841 : 6 : pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 );
842 : :
843 : : //Need dummy picture frame
844 [ - + ]: 6 : if (rFrmFmt.IsInline())
845 : 0 : OutGrf(rFrmFmt);
846 : : }
847 : :
848 [ - + ]: 6 : if (rFrmFmt.IsInline())
849 : 0 : OutputField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE);
850 : : }
851 : :
852 : 3 : MSWord_SdrAttrIter::MSWord_SdrAttrIter( MSWordExportBase& rWr,
853 : : const EditTextObject& rEditObj, sal_uInt8 nTyp )
854 [ + - ][ + - ]: 3 : : MSWordAttrIter( rWr ), pEditObj(&rEditObj), pEditPool(0), mnTyp(nTyp)
[ + - ]
855 : : {
856 [ + - ]: 3 : NextPara( 0 );
857 : 3 : }
858 : :
859 : 3 : void MSWord_SdrAttrIter::NextPara( sal_uInt16 nPar )
860 : : {
861 : 3 : nPara = nPar;
862 : : // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen
863 : : // wird, dass am Absatzanfang sowieso die Attribute neu ausgegeben
864 : : // werden.
865 : 3 : aChrTxtAtrArr.clear();
866 : 3 : aChrSetArr.clear();
867 : 3 : nAktSwPos = nTmpSwPos = 0;
868 : :
869 [ + - ]: 3 : SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
870 : 3 : pEditPool = aSet.GetPool();
871 [ + - ]: 3 : eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet();
872 : :
873 [ + - ][ + - ]: 3 : if( pBreakIt->GetBreakIter().is() )
874 [ + - ][ + - ]: 3 : nScript = pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0);
[ + - ][ + - ]
[ + - ][ + - ]
875 : : else
876 : 0 : nScript = i18n::ScriptType::LATIN;
877 : :
878 [ + - ]: 3 : pEditObj->GetCharAttribs( nPara, aTxtAtrArr );
879 [ + - ][ + - ]: 3 : nAktSwPos = SearchNext( 1 );
880 : 3 : }
881 : :
882 : 3 : rtl_TextEncoding MSWord_SdrAttrIter::GetNextCharSet() const
883 : : {
884 [ - + ]: 3 : if( !aChrSetArr.empty() )
885 : 0 : return aChrSetArr.back();
886 : 3 : return eNdChrSet;
887 : : }
888 : :
889 : : // der erste Parameter in SearchNext() liefert zurueck, ob es ein TxtAtr ist.
890 : 3 : xub_StrLen MSWord_SdrAttrIter::SearchNext( xub_StrLen nStartPos )
891 : : {
892 : 3 : sal_uInt16 nMinPos = STRING_MAXLEN;
893 [ + - ][ + - ]: 3 : for(std::vector<EECharAttrib>::const_iterator i = aTxtAtrArr.begin(); i < aTxtAtrArr.end(); ++i)
[ - + ]
894 : : {
895 : 0 : sal_uInt16 nPos = i->nStart; // gibt erstes Attr-Zeichen
896 [ # # ][ # # ]: 0 : if( nPos >= nStartPos && nPos <= nMinPos )
897 : : {
898 : 0 : nMinPos = nPos;
899 [ # # ]: 0 : SetCharSet(*i, true);
900 : : }
901 : :
902 : 0 : nPos = i->nEnd; // gibt letztes Attr-Zeichen + 1
903 [ # # ][ # # ]: 0 : if( nPos >= nStartPos && nPos < nMinPos )
904 : : {
905 : 0 : nMinPos = nPos;
906 [ # # ]: 0 : SetCharSet(*i, false);
907 : : }
908 : : }
909 : 3 : return nMinPos;
910 : : }
911 : :
912 : 0 : void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
913 : : {
914 : 0 : const SfxPoolItem& rItem = *rAttr.pAttr;
915 [ # # ]: 0 : if( rItem.Which() != EE_CHAR_FONTINFO )
916 : : {
917 : 0 : return;
918 : : }
919 : :
920 [ # # ]: 0 : if( bStart )
921 : : {
922 : 0 : rtl_TextEncoding eChrSet = ((SvxFontItem&)rItem).GetCharSet();
923 [ # # ]: 0 : aChrSetArr.push_back( eChrSet );
924 [ # # ]: 0 : aChrTxtAtrArr.push_back( &rAttr );
925 : : }
926 : : else
927 : : {
928 : : std::vector<const EECharAttrib*>::iterator it =
929 [ # # ]: 0 : std::find( aChrTxtAtrArr.begin(), aChrTxtAtrArr.end(), &rAttr );
930 [ # # ][ # # ]: 0 : if ( it != aChrTxtAtrArr.end() )
931 : : {
932 [ # # ]: 0 : aChrTxtAtrArr.erase( it );
933 [ # # ][ # # ]: 0 : aChrSetArr.erase( aChrSetArr.begin() + (it - aChrTxtAtrArr.begin()) );
[ # # ]
934 : : }
935 : : }
936 : : }
937 : :
938 : 0 : void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt)
939 : : {
940 : 0 : const SvxFieldItem &rField = (const SvxFieldItem &)rHt;
941 : 0 : const SvxFieldData *pFld = rField.GetField();
942 [ # # ][ # # ]: 0 : if (pFld && pFld->ISA(SvxURLField))
[ # # ]
943 : : {
944 : 0 : sal_uInt8 nOldTxtTyp = m_rExport.nTxtTyp;
945 : 0 : m_rExport.nTxtTyp = mnTyp;
946 : 0 : const SvxURLField *pURL = (const SvxURLField *)pFld;
947 [ # # ][ # # ]: 0 : m_rExport.AttrOutput().StartURL( pURL->GetURL(), pURL->GetTargetFrame() );
[ # # ]
948 : :
949 : 0 : const String &rStr = pURL->GetRepresentation();
950 [ # # ][ # # ]: 0 : m_rExport.AttrOutput().RawText( rStr, true, GetNodeCharSet() ); // FIXME kendy: is the 'true' actually correct here? It was here before, but... ;-)
951 : :
952 [ # # ][ # # ]: 0 : m_rExport.AttrOutput().EndURL();
953 : 0 : m_rExport.nTxtTyp = nOldTxtTyp;
954 : : }
955 : 0 : }
956 : :
957 : 3 : void MSWord_SdrAttrIter::OutAttr( xub_StrLen nSwPos )
958 : : {
959 : 3 : OutParaAttr(true);
960 : :
961 [ - + ]: 3 : if(!aTxtAtrArr.empty())
962 : : {
963 : 0 : const SwModify* pOldMod = m_rExport.pOutFmtNode;
964 : 0 : m_rExport.pOutFmtNode = 0;
965 : :
966 : 0 : const SfxItemPool* pSrcPool = pEditPool;
967 : 0 : const SfxItemPool& rDstPool = m_rExport.pDoc->GetAttrPool();
968 : :
969 : 0 : nTmpSwPos = nSwPos;
970 : : sal_uInt16 nWhich, nSlotId;
971 [ # # ][ # # ]: 0 : for(std::vector<EECharAttrib>::const_iterator i = aTxtAtrArr.begin(); i < aTxtAtrArr.end(); ++i)
[ # # ]
972 : : {
973 [ # # ][ # # ]: 0 : if (nSwPos >= i->nStart && nSwPos < i->nEnd)
[ # # ]
974 : : {
975 : 0 : nWhich = i->pAttr->Which();
976 [ # # ]: 0 : if (nWhich == EE_FEATURE_FIELD)
977 : : {
978 [ # # ]: 0 : OutEEField(*(i->pAttr));
979 : 0 : continue;
980 : : }
981 [ # # ]: 0 : else if (nWhich == EE_FEATURE_TAB)
982 : : {
983 [ # # ]: 0 : m_rExport.WriteChar(0x9);
984 : 0 : continue;
985 : : }
986 [ # # ]: 0 : nSlotId = pSrcPool->GetSlotId(nWhich);
987 : :
988 [ # # ][ # # ]: 0 : if (nSlotId && nWhich != nSlotId)
989 : : {
990 [ # # ]: 0 : nWhich = rDstPool.GetWhich(nSlotId);
991 [ # # ][ # # ]: 0 : if (nWhich && nWhich != nSlotId &&
[ # # ][ # # ]
[ # # ]
992 : : nWhich < RES_UNKNOWNATR_BEGIN &&
993 [ # # ]: 0 : m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
994 : : {
995 : : // use always the SW-Which Id !
996 [ # # ]: 0 : SfxPoolItem* pI = i->pAttr->Clone();
997 : 0 : pI->SetWhich( nWhich );
998 [ # # ][ # # ]: 0 : m_rExport.AttrOutput().OutputItem( *pI );
999 [ # # ][ # # ]: 0 : delete pI;
1000 : : }
1001 : : }
1002 : : }
1003 : :
1004 [ # # ]: 0 : if( nSwPos < i->nStart )
1005 : 0 : break;
1006 : : }
1007 : :
1008 : 0 : nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt
1009 : 0 : m_rExport.pOutFmtNode = pOldMod;
1010 : : }
1011 : 3 : }
1012 : :
1013 : 3 : bool MSWord_SdrAttrIter::IsTxtAttr(xub_StrLen nSwPos)
1014 : : {
1015 [ + - ][ + - ]: 3 : for (std::vector<EECharAttrib>::const_iterator i = aTxtAtrArr.begin(); i < aTxtAtrArr.end(); ++i)
[ - + ]
1016 : : {
1017 [ # # ][ # # ]: 0 : if (nSwPos >= i->nStart && nSwPos < i->nEnd)
[ # # ]
1018 : : {
1019 [ # # # # ]: 0 : if (i->pAttr->Which() == EE_FEATURE_FIELD ||
[ # # ]
1020 : 0 : i->pAttr->Which() == EE_FEATURE_TAB)
1021 : 0 : return true;
1022 : : }
1023 : : }
1024 : 3 : return false;
1025 : : }
1026 : :
1027 : : // HasItem ist fuer die Zusammenfassung des Doppel-Attributes Underline
1028 : : // und WordLineMode als TextItems. OutAttr() ruft die Ausgabefunktion,
1029 : : // die dann ueber HasItem() nach anderen Items an der
1030 : : // Attribut-Anfangposition fragen kann.
1031 : : // Es koennen nur Attribute mit Ende abgefragt werden.
1032 : : // Es wird mit bDeep gesucht
1033 : 0 : const SfxPoolItem* MSWord_SdrAttrIter::HasTextItem(sal_uInt16 nWhich) const
1034 : : {
1035 : : nWhich = sw::hack::TransformWhichBetweenPools(*pEditPool,
1036 : 0 : m_rExport.pDoc->GetAttrPool(), nWhich);
1037 [ # # ]: 0 : if (nWhich)
1038 : : {
1039 [ # # ][ # # ]: 0 : for (std::vector<EECharAttrib>::const_iterator i = aTxtAtrArr.begin(); i < aTxtAtrArr.end(); ++i)
1040 : : {
1041 [ # # ][ # # ]: 0 : if (nWhich == i->pAttr->Which() && nTmpSwPos >= i->nStart && nTmpSwPos < i->nEnd)
[ # # ][ # # ]
1042 : 0 : return i->pAttr; // Found
1043 [ # # ]: 0 : else if (nTmpSwPos < i->nStart)
1044 : 0 : return NULL; // dann kommt da nichts mehr
1045 : : }
1046 : : }
1047 : 0 : return NULL;
1048 : : }
1049 : :
1050 : 0 : const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const
1051 : : {
1052 : : using sw::hack::GetSetWhichFromSwDocWhich;
1053 : 0 : const SfxPoolItem* pRet = HasTextItem(nWhich);
1054 [ # # ]: 0 : if (!pRet)
1055 : : {
1056 [ # # ]: 0 : SfxItemSet aSet(pEditObj->GetParaAttribs(nPara));
1057 [ # # ]: 0 : nWhich = GetSetWhichFromSwDocWhich(aSet, *m_rExport.pDoc, nWhich);
1058 : : OSL_ENSURE(nWhich, "Impossible, catastrophic failure imminent");
1059 [ # # ][ # # ]: 0 : pRet = &aSet.Get(nWhich);
1060 : : }
1061 : 0 : return *pRet;
1062 : : }
1063 : :
1064 : 3 : void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr)
1065 : : {
1066 [ + - ]: 3 : SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
1067 [ + - ]: 3 : if( aSet.Count() )
1068 : : {
1069 : 3 : const SfxItemSet* pOldSet = m_rExport.GetCurItemSet();
1070 : 3 : m_rExport.SetCurItemSet( &aSet );
1071 : :
1072 [ + - ]: 3 : SfxItemIter aIter( aSet );
1073 : 3 : const SfxPoolItem* pItem = aIter.GetCurItem();
1074 : :
1075 : 3 : const SfxItemPool* pSrcPool = pEditPool,
1076 : 3 : * pDstPool = &m_rExport.pDoc->GetAttrPool();
1077 : :
1078 [ # # ][ # # ]: 3 : do {
[ - + ][ - + ]
1079 : 3 : sal_uInt16 nWhich = pItem->Which(),
1080 [ + - ]: 3 : nSlotId = pSrcPool->GetSlotId( nWhich );
1081 : :
1082 [ + - ][ + - ]: 3 : if ( nSlotId && nWhich != nSlotId &&
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ # # ][ # # ]
[ - + ]
1083 : 3 : 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
1084 : : nWhich != nSlotId &&
1085 : : ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END )
1086 : : : ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
1087 : : {
1088 : : // use always the SW-Which Id !
1089 [ # # ]: 0 : SfxPoolItem* pI = pItem->Clone();
1090 : 0 : pI->SetWhich( nWhich );
1091 [ # # ][ # # ]: 0 : if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
1092 [ # # ][ # # ]: 0 : m_rExport.AttrOutput().OutputItem( *pI );
1093 [ # # ][ # # ]: 0 : delete pI;
1094 : : }
1095 : 3 : } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
1096 [ + - ]: 3 : m_rExport.SetCurItemSet( pOldSet );
1097 [ + - ]: 3 : }
1098 : 3 : }
1099 : :
1100 : 0 : void WW8Export::WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp)
1101 : : {
1102 [ # # ][ # # ]: 0 : const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, &rObj);
1103 : : OSL_ENSURE(pTxtObj, "That is no SdrTextObj!");
1104 [ # # ]: 0 : if (!pTxtObj)
1105 : 0 : return;
1106 : :
1107 : 0 : const OutlinerParaObject* pParaObj = 0;
1108 : 0 : bool bOwnParaObj = false;
1109 : :
1110 : : /*
1111 : : #i13885#
1112 : : When the object is actively being edited, that text is not set into
1113 : : the objects normal text object, but lives in a seperate object.
1114 : : */
1115 [ # # ]: 0 : if (pTxtObj->IsTextEditActive())
1116 : : {
1117 : 0 : pParaObj = pTxtObj->GetEditOutlinerParaObject();
1118 : 0 : bOwnParaObj = true;
1119 : : }
1120 : : else
1121 : : {
1122 : 0 : pParaObj = pTxtObj->GetOutlinerParaObject();
1123 : : }
1124 : :
1125 [ # # ]: 0 : if( pParaObj )
1126 : : {
1127 : 0 : WriteOutliner(*pParaObj, nTyp);
1128 [ # # ]: 0 : if( bOwnParaObj )
1129 [ # # ]: 0 : delete pParaObj;
1130 : : }
1131 : : }
1132 : :
1133 : 0 : void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp)
1134 : : {
1135 : 0 : bool bAnyWrite = false;
1136 [ # # ]: 0 : const EditTextObject& rEditObj = rParaObj.GetTextObject();
1137 [ # # ]: 0 : MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
1138 : :
1139 [ # # ]: 0 : sal_uInt16 nPara = rEditObj.GetParagraphCount();
1140 : 0 : sal_uInt8 bNul = 0;
1141 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nPara; ++n )
1142 : : {
1143 [ # # ]: 0 : if( n )
1144 [ # # ]: 0 : aAttrIter.NextPara( n );
1145 : :
1146 : 0 : rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
1147 : :
1148 : : OSL_ENSURE( pO->empty(), " pO ist am Zeilenanfang nicht leer" );
1149 : :
1150 [ # # ]: 0 : String aStr( rEditObj.GetText( n ));
1151 : 0 : xub_StrLen nAktPos = 0;
1152 : 0 : xub_StrLen nEnd = aStr.Len();
1153 [ # # ]: 0 : do {
1154 : 0 : xub_StrLen nNextAttr = aAttrIter.WhereNext();
1155 [ # # ]: 0 : rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
1156 : :
1157 [ # # ]: 0 : if( nNextAttr > nEnd )
1158 : 0 : nNextAttr = nEnd;
1159 : :
1160 [ # # ]: 0 : bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
1161 [ # # ]: 0 : if( !bTxtAtr )
1162 : : OutSwString( aStr, nAktPos, nNextAttr - nAktPos,
1163 [ # # ]: 0 : true, eChrSet );
1164 : :
1165 : : // Am Zeilenende werden die Attribute bis ueber das CR
1166 : : // aufgezogen. Ausnahme: Fussnoten am Zeilenende
1167 [ # # ][ # # ]: 0 : if( nNextAttr == nEnd && !bTxtAtr )
1168 [ # # ][ # # ]: 0 : WriteCR(); // CR danach
[ # # ]
1169 : :
1170 : : // Ausgabe der Zeichenattribute
1171 [ # # ]: 0 : aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ??
1172 [ # # ]: 0 : pChpPlc->AppendFkpEntry( Strm().Tell(),
1173 [ # # ][ # # ]: 0 : pO->size(), pO->data() );
1174 : 0 : pO->clear();
1175 : :
1176 : : // Ausnahme: Fussnoten am Zeilenende
1177 [ # # ][ # # ]: 0 : if( nNextAttr == nEnd && bTxtAtr )
1178 [ # # ][ # # ]: 0 : WriteCR(); // CR danach
[ # # ]
1179 : 0 : nAktPos = nNextAttr;
1180 : 0 : eChrSet = eNextChrSet;
1181 [ # # ]: 0 : aAttrIter.NextPos();
1182 : : }
1183 : : while( nAktPos < nEnd );
1184 : :
1185 : : OSL_ENSURE( pO->empty(), " pO ist am ZeilenEnde nicht leer" );
1186 : :
1187 [ # # ]: 0 : pO->push_back( bNul ); // Style # as short
1188 [ # # ]: 0 : pO->push_back( bNul );
1189 : :
1190 [ # # ]: 0 : aAttrIter.OutParaAttr(false);
1191 : :
1192 [ # # ]: 0 : sal_uLong nPos = Strm().Tell();
1193 [ # # ]: 0 : pPapPlc->AppendFkpEntry( Strm().Tell(),
1194 [ # # ][ # # ]: 0 : pO->size(), pO->data() );
1195 : 0 : pO->clear();
1196 [ # # ]: 0 : pChpPlc->AppendFkpEntry( nPos );
1197 [ # # ]: 0 : }
1198 : :
1199 : 0 : bAnyWrite = 0 != nPara;
1200 [ # # ]: 0 : if( !bAnyWrite )
1201 [ # # ][ # # ]: 0 : WriteStringAsPara( aEmptyStr );
1202 : 0 : }
1203 : :
1204 : 6 : void WinwordAnchoring::WriteData( EscherEx& rEx ) const
1205 : : {
1206 : : //Toplevel groups get their winword extra data attached, and sub elements
1207 : : //use the defaults
1208 [ + - ]: 6 : if (rEx.GetGroupLevel() <= 1)
1209 : : {
1210 : 6 : SvStream& rSt = rEx.GetStream();
1211 : : //The last argument denotes the number of sub properties in this atom
1212 [ - + ]: 6 : if (mbInline)
1213 : : {
1214 : 0 : rEx.AddAtom(18, DFF_msofbtUDefProp, 3, 3); //Prop id is 0xF122
1215 : 0 : rSt << (sal_uInt16)0x0390 << sal_uInt32(3);
1216 : 0 : rSt << (sal_uInt16)0x0392 << sal_uInt32(3);
1217 : : //This sub property is required to be in the dummy inline frame as
1218 : : //well
1219 : 0 : rSt << (sal_uInt16)0x053F << nInlineHack;
1220 : : }
1221 : : else
1222 : : {
1223 : 6 : rEx.AddAtom(24, DFF_msofbtUDefProp, 3, 4 ); //Prop id is 0xF122
1224 : 6 : rSt << (sal_uInt16)0x038F << mnXAlign;
1225 : 6 : rSt << (sal_uInt16)0x0390 << mnXRelTo;
1226 : 6 : rSt << (sal_uInt16)0x0391 << mnYAlign;
1227 : 6 : rSt << (sal_uInt16)0x0392 << mnYRelTo;
1228 : : }
1229 : : }
1230 : 6 : }
1231 : :
1232 : :
1233 : 9 : void WW8Export::CreateEscher()
1234 : : {
1235 : 9 : SfxItemState eBackSet = pDoc->GetPageDesc(0).GetMaster().
1236 : 9 : GetItemState(RES_BACKGROUND);
1237 [ + + ][ - + ]: 9 : if (pHFSdrObjs->size() || pSdrObjs->size() || SFX_ITEM_SET == eBackSet)
[ + + ][ + + ]
1238 : : {
1239 : : OSL_ENSURE( !pEscher, "wer hat den Pointer nicht geloescht?" );
1240 [ + - ]: 6 : SvMemoryStream* pEscherStrm = new SvMemoryStream;
1241 : 6 : pEscherStrm->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
1242 [ + - ]: 6 : pEscher = new SwEscherEx(pEscherStrm, *this);
1243 : : }
1244 : 9 : }
1245 : :
1246 : 9 : void WW8Export::WriteEscher()
1247 : : {
1248 [ + + ]: 9 : if (pEscher)
1249 : : {
1250 : 6 : sal_uLong nStart = pTableStrm->Tell();
1251 : :
1252 : 6 : pEscher->WritePictures();
1253 : 6 : pEscher->FinishEscher();
1254 : :
1255 : 6 : pFib->fcDggInfo = nStart;
1256 : 6 : pFib->lcbDggInfo = pTableStrm->Tell() - nStart;
1257 [ + - ]: 6 : delete pEscher, pEscher = 0;
1258 : : }
1259 : 9 : }
1260 : :
1261 : 6 : void SwEscherEx::WritePictures()
1262 : : {
1263 [ + - ]: 6 : if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
1264 : : {
1265 : : // set the blip - entries to the correct stream pos
1266 : 6 : sal_Int32 nEndPos = rWrt.Strm().Tell();
1267 : 6 : mxGlobal->SetNewBlipStreamOffset( nEndPos );
1268 : :
1269 : 6 : pPicStrm->Seek( 0 );
1270 : 6 : rWrt.Strm() << *pPicStrm;
1271 : : }
1272 : 6 : Flush();
1273 : 6 : }
1274 : :
1275 : :
1276 : : // Output- Routines for Escher Export
1277 : :
1278 [ + - ]: 6 : SwEscherExGlobal::SwEscherExGlobal()
1279 : : {
1280 : 6 : }
1281 : :
1282 [ + - ]: 6 : SwEscherExGlobal::~SwEscherExGlobal()
1283 : : {
1284 [ - + ]: 12 : }
1285 : :
1286 : 6 : SvStream* SwEscherExGlobal::ImplQueryPictureStream()
1287 : : {
1288 : : // this function will be called exactly once
1289 [ + - ]: 6 : mxPicStrm.reset( new SvMemoryStream );
1290 : 6 : mxPicStrm->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
1291 : 6 : return mxPicStrm.get();
1292 : : }
1293 : :
1294 : 6 : SwBasicEscherEx::SwBasicEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
1295 [ + - ][ + - ]: 6 : : EscherEx( EscherExGlobalRef( new SwEscherExGlobal ), pStrm), rWrt(rWW8Wrt), pEscherStrm(pStrm)
1296 : : {
1297 [ + - ]: 6 : Init();
1298 : 6 : }
1299 : :
1300 : 6 : SwBasicEscherEx::~SwBasicEscherEx()
1301 : : {
1302 [ - + ]: 6 : }
1303 : :
1304 : 0 : void SwBasicEscherEx::WriteFrmExtraData(const SwFrmFmt&)
1305 : : {
1306 : 0 : AddAtom(4, ESCHER_ClientAnchor);
1307 : 0 : GetStream() << (sal_uInt32)0x80000000;
1308 : 0 : }
1309 : :
1310 : 0 : void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId)
1311 : : {
1312 : 0 : OpenContainer(ESCHER_SpContainer);
1313 : 0 : AddShape(ESCHER_ShpInst_PictureFrame, 0xa00, nShapeId);
1314 : : // store anchor attribute
1315 : 0 : WriteFrmExtraData(rFmt);
1316 : :
1317 : 0 : AddAtom(6, DFF_msofbtUDefProp, 3, 1); //Prop id is 0xF122
1318 : 0 : GetStream() << (sal_uInt16)0x053F << nInlineHack;
1319 : :
1320 : 0 : CloseContainer(); // ESCHER_SpContainer
1321 : 0 : }
1322 : :
1323 : 3 : sal_uInt32 AddMirrorFlags(sal_uInt32 nFlags, const SwMirrorGrf &rMirror)
1324 : : {
1325 [ + - - - ]: 3 : switch (rMirror.GetValue())
1326 : : {
1327 : : default:
1328 : : case RES_MIRROR_GRAPH_DONT:
1329 : 3 : break;
1330 : : case RES_MIRROR_GRAPH_VERT:
1331 : 0 : nFlags |= SHAPEFLAG_FLIPH;
1332 : 0 : break;
1333 : : case RES_MIRROR_GRAPH_HOR:
1334 : 0 : nFlags |= SHAPEFLAG_FLIPV;
1335 : 0 : break;
1336 : : case RES_MIRROR_GRAPH_BOTH:
1337 : 0 : nFlags |= SHAPEFLAG_FLIPH;
1338 : 0 : nFlags |= SHAPEFLAG_FLIPV;
1339 : 0 : break;
1340 : :
1341 : : }
1342 : 3 : return nFlags;
1343 : : }
1344 : :
1345 : 3 : sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId)
1346 : : {
1347 : 3 : sal_Int32 nBorderThick=0;
1348 [ + - ]: 3 : SwNoTxtNode *pNd = GetNoTxtNodeFromSwFrmFmt(rFmt);
1349 [ + - ]: 3 : SwGrfNode *pGrfNd = pNd ? pNd->GetGrfNode() : 0;
1350 : : OSL_ENSURE(pGrfNd, "No SwGrfNode ?, suspicious");
1351 [ - + ]: 3 : if (!pGrfNd)
1352 : 0 : return nBorderThick;
1353 : :
1354 [ + - ]: 3 : OpenContainer( ESCHER_SpContainer );
1355 : :
1356 [ + - ][ + - ]: 3 : const SwMirrorGrf &rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
1357 : : AddShape(ESCHER_ShpInst_PictureFrame, AddMirrorFlags(0xa00, rMirror),
1358 [ + - ]: 3 : nShapeId);
1359 : :
1360 [ + - ]: 3 : EscherPropertyContainer aPropOpt;
1361 : :
1362 : 3 : sal_uInt32 nFlags = ESCHER_BlipFlagDefault;
1363 : :
1364 [ - + ]: 3 : if (pGrfNd->IsLinkedFile())
1365 : : {
1366 [ # # ]: 0 : String sURL;
1367 [ # # ]: 0 : pGrfNd->GetFileFilterNms( &sURL, 0 );
1368 : :
1369 [ # # ]: 0 : ww::bytes aBuf;
1370 [ # # ]: 0 : SwWW8Writer::InsAsString16( aBuf, sURL );
1371 [ # # ]: 0 : SwWW8Writer::InsUInt16( aBuf, 0 );
1372 : :
1373 : 0 : sal_uInt16 nArrLen = aBuf.size();
1374 [ # # ]: 0 : sal_uInt8* pArr = new sal_uInt8[ nArrLen ];
1375 [ # # ]: 0 : std::copy( aBuf.begin(), aBuf.end(), pArr);
1376 : :
1377 [ # # ]: 0 : aPropOpt.AddOpt(ESCHER_Prop_pibName, true, nArrLen, pArr, nArrLen);
1378 : : nFlags = ESCHER_BlipFlagLinkToFile | ESCHER_BlipFlagURL |
1379 [ # # ]: 0 : ESCHER_BlipFlagDoNotSave;
1380 : : }
1381 : : else
1382 : : {
1383 [ + - ]: 3 : pGrfNd->SwapIn(true);
1384 : :
1385 [ + - ][ + - ]: 3 : Graphic aGraphic(pGrfNd->GetGrf());
1386 [ + - ]: 3 : GraphicObject aGraphicObject( aGraphic );
1387 [ + - ]: 3 : rtl::OString aUniqueId = aGraphicObject.GetUniqueID();
1388 : :
1389 [ + - ]: 3 : if (!aUniqueId.isEmpty())
1390 : : {
1391 [ + - ]: 3 : const MapMode aMap100mm( MAP_100TH_MM );
1392 [ + - ]: 3 : Size aSize( aGraphic.GetPrefSize() );
1393 : :
1394 [ + - ][ + - ]: 3 : if ( MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit() )
[ + - ]
1395 : : {
1396 : : aSize = Application::GetDefaultDevice()->PixelToLogic(
1397 [ + - ][ + - ]: 3 : aSize, aMap100mm );
1398 : : }
1399 : : else
1400 : : {
1401 : : aSize = OutputDevice::LogicToLogic( aSize,
1402 [ # # ][ # # ]: 0 : aGraphic.GetPrefMapMode(), aMap100mm );
[ # # ]
1403 : : }
1404 : :
1405 : 3 : Point aEmptyPoint = Point();
1406 [ + - ]: 3 : Rectangle aRect( aEmptyPoint, aSize );
1407 : :
1408 [ + - ]: 3 : sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(),
1409 [ + - ]: 3 : aUniqueId, aRect, NULL, 0 );
1410 [ + - ]: 3 : if (nBlibId)
1411 [ + - ][ + - ]: 3 : aPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, sal_True);
1412 [ + - ][ + - ]: 3 : }
1413 : : }
1414 : :
1415 [ + - ]: 3 : aPropOpt.AddOpt( ESCHER_Prop_pibFlags, nFlags );
1416 [ + - ]: 3 : nBorderThick = WriteFlyFrameAttr(rFmt,mso_sptPictureFrame,aPropOpt);
1417 [ + - ]: 3 : WriteGrfAttr(*pGrfNd, aPropOpt);
1418 : :
1419 [ + - ]: 3 : aPropOpt.Commit( GetStream() );
1420 : :
1421 : : // store anchor attribute
1422 [ + - ]: 3 : WriteFrmExtraData( rFmt );
1423 : :
1424 [ + - ]: 3 : CloseContainer(); // ESCHER_SpContainer
1425 [ + - ]: 3 : return nBorderThick;
1426 : : }
1427 : :
1428 : 3 : void SwBasicEscherEx::WriteGrfAttr(const SwNoTxtNode& rNd,
1429 : : EscherPropertyContainer& rPropOpt)
1430 : : {
1431 : : const SfxPoolItem* pItem;
1432 : 3 : sal_uInt32 nMode = GRAPHICDRAWMODE_STANDARD;
1433 : 3 : sal_Int32 nContrast = 0;
1434 : 3 : sal_Int16 nBrightness = 0;
1435 : :
1436 [ + - ][ - + ]: 6 : if (SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CONTRAST,
1437 [ + - ]: 3 : true, &pItem))
1438 : : {
1439 : 0 : nContrast = ((SfxInt16Item*)pItem)->GetValue();
1440 : : }
1441 : :
1442 [ + - ][ - + ]: 6 : if (SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_LUMINANCE,
1443 [ + - ]: 3 : true, &pItem))
1444 : : {
1445 : 0 : nBrightness = ((SfxInt16Item*)pItem)->GetValue();
1446 : : }
1447 : :
1448 : :
1449 [ + - ][ - + ]: 6 : if (SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE,
1450 [ + - ]: 3 : true, &pItem))
1451 : : {
1452 : 0 : nMode = ((SfxEnumItem*)pItem)->GetValue();
1453 [ # # ]: 0 : if (nMode == GRAPHICDRAWMODE_WATERMARK)
1454 : : {
1455 : : /*
1456 : : There is no real watermark mode in word, we must use standard
1457 : : mode and modify our ones by 70% extra brightness and 70% less
1458 : : contrast. This means that unmodified default OOo watermark
1459 : : will turn back into watermark, and modified OOo watermark will
1460 : : change into a close visual representation in standardmode
1461 : : */
1462 : 0 : nBrightness += 70;
1463 [ # # ]: 0 : if (nBrightness > 100)
1464 : 0 : nBrightness = 100;
1465 : 0 : nContrast -= 70;
1466 [ # # ]: 0 : if (nContrast < -100)
1467 : 0 : nContrast = -100;
1468 : 0 : nMode = GRAPHICDRAWMODE_STANDARD;
1469 : : }
1470 : : }
1471 : :
1472 [ - + ]: 3 : if (nMode == GRAPHICDRAWMODE_GREYS)
1473 : 0 : nMode = 0x40004;
1474 [ - + ]: 3 : else if (nMode == GRAPHICDRAWMODE_MONO)
1475 : 0 : nMode = 0x60006;
1476 : : else
1477 : 3 : nMode = 0;
1478 [ + - ]: 3 : rPropOpt.AddOpt( ESCHER_Prop_pictureActive, nMode );
1479 : :
1480 [ - + ]: 3 : if (nContrast != 0)
1481 : : {
1482 : 0 : nContrast+=100;
1483 [ # # ]: 0 : if (nContrast == 100)
1484 : 0 : nContrast = 0x10000;
1485 [ # # ]: 0 : else if (nContrast < 100)
1486 : : {
1487 : 0 : nContrast *= 0x10000;
1488 : 0 : nContrast /= 100;
1489 : : }
1490 [ # # ]: 0 : else if (nContrast < 200)
1491 : 0 : nContrast = (100 * 0x10000) / (200-nContrast);
1492 : : else
1493 : 0 : nContrast = 0x7fffffff;
1494 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_pictureContrast, nContrast);
1495 : : }
1496 : :
1497 [ - + ]: 3 : if (nBrightness != 0)
1498 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_pictureBrightness, nBrightness * 327 );
1499 : :
1500 [ + - ][ - + ]: 6 : if (SFX_ITEM_SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CROPGRF,
1501 [ + - ]: 3 : true, &pItem))
1502 : : {
1503 [ # # ]: 0 : const Size aSz( rNd.GetTwipSize() );
1504 : : sal_Int32 nVal;
1505 [ # # ]: 0 : if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetLeft() ) )
1506 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_cropFromLeft, ToFract16( nVal, aSz.Width()) );
1507 [ # # ]: 0 : if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetRight() ) )
1508 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_cropFromRight, ToFract16( nVal, aSz.Width()));
1509 [ # # ]: 0 : if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetTop() ) )
1510 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_cropFromTop, ToFract16( nVal, aSz.Height()));
1511 [ # # ]: 0 : if( 0 != ( nVal = ((SwCropGrf*)pItem )->GetBottom() ) )
1512 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_cropFromBottom, ToFract16( nVal, aSz.Height()));
1513 : : }
1514 : 3 : }
1515 : :
1516 : 0 : void SwBasicEscherEx::SetPicId(const SdrObject &, sal_uInt32,
1517 : : EscherPropertyContainer &)
1518 : : {
1519 : 0 : }
1520 : :
1521 : 3 : void SwEscherEx::SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId,
1522 : : EscherPropertyContainer &rPropOpt)
1523 : : {
1524 : 3 : pTxtBxs->Append(rSdrObj, nShapeId);
1525 : 3 : sal_uInt32 nPicId = pTxtBxs->Count();
1526 : 3 : nPicId *= 0x10000;
1527 : 3 : rPropOpt.AddOpt( ESCHER_Prop_pictureId, nPicId );
1528 : 3 : }
1529 : :
1530 : 0 : sal_Int32 SwBasicEscherEx::WriteOLEFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId)
1531 : : {
1532 : 0 : sal_Int32 nBorderThick = 0;
1533 [ # # ]: 0 : if (const SdrObject* pSdrObj = rFmt.FindRealSdrObject())
1534 : : {
1535 [ # # ][ # # ]: 0 : SwNodeIndex aIdx(*rFmt.GetCntnt().GetCntntIdx(), 1);
1536 : 0 : SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
1537 [ # # ]: 0 : sal_Int64 nAspect = rOLENd.GetAspect();
1538 : :
1539 [ # # ]: 0 : uno::Reference < embed::XEmbeddedObject > xObj(rOLENd.GetOLEObj().GetOleRef());
1540 : :
1541 : : // the rectangle is used to transport the size of the object
1542 : : // the left, top corner is set to ( 0, 0 ) by default constructor,
1543 : : // if the width and height are set correctly bRectIsSet should be set to true
1544 : 0 : awt::Rectangle aRect;
1545 : 0 : sal_Bool bRectIsSet = sal_False;
1546 : :
1547 : :
1548 : : // TODO/LATER: should the icon size be stored in case of iconified object?
1549 [ # # ][ # # ]: 0 : if ( xObj.is() && nAspect != embed::Aspects::MSOLE_ICON )
[ # # ]
1550 : : {
1551 : : try
1552 : : {
1553 [ # # ][ # # ]: 0 : awt::Size aSize = xObj->getVisualAreaSize( nAspect );
1554 : 0 : aRect.Width = aSize.Width;
1555 : 0 : aRect.Height = aSize.Height;
1556 : 0 : bRectIsSet = sal_True;
1557 : : }
1558 [ # # ]: 0 : catch( const uno::Exception& )
1559 : : {}
1560 : : }
1561 : :
1562 : : /*
1563 : : #i5970#
1564 : : Export floating ole2 .doc ver 8+ wmf ole2 previews as emf previews
1565 : : instead ==> allows unicode text to be preserved
1566 : : */
1567 : : #ifdef OLE_PREVIEW_AS_EMF
1568 [ # # ]: 0 : Graphic* pGraphic = rOLENd.GetGraphic();
1569 : : #endif
1570 [ # # ]: 0 : OpenContainer(ESCHER_SpContainer);
1571 : :
1572 [ # # ]: 0 : EscherPropertyContainer aPropOpt;
1573 [ # # ][ # # ]: 0 : const SwMirrorGrf &rMirror = rOLENd.GetSwAttrSet().GetMirrorGrf();
1574 : : WriteOLEPicture(aPropOpt, AddMirrorFlags(0xa00 | SHAPEFLAG_OLESHAPE,
1575 [ # # ][ # # ]: 0 : rMirror), pGraphic ? *pGraphic : Graphic(), *pSdrObj, nShapeId, bRectIsSet ? &aRect : NULL );
[ # # ][ # # ]
[ # # ][ # # ]
1576 : :
1577 [ # # ]: 0 : nBorderThick = WriteFlyFrameAttr(rFmt, mso_sptPictureFrame, aPropOpt);
1578 [ # # ]: 0 : WriteGrfAttr(rOLENd, aPropOpt);
1579 [ # # ]: 0 : aPropOpt.Commit(GetStream());
1580 : :
1581 : : // store anchor attribute
1582 [ # # ]: 0 : WriteFrmExtraData( rFmt );
1583 : :
1584 [ # # ][ # # ]: 0 : CloseContainer(); // ESCHER_SpContainer
[ # # ]
1585 : : }
1586 [ # # ]: 0 : return nBorderThick;
1587 : : }
1588 : :
1589 : 6 : void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush,
1590 : : EscherPropertyContainer& rPropOpt)
1591 : : {
1592 : 6 : bool bSetOpacity = false;
1593 : 6 : sal_uInt32 nOpaque = 0;
1594 [ - + ]: 6 : if (const GraphicObject *pGraphicObject = rBrush.GetGraphicObject())
1595 : : {
1596 [ # # ]: 0 : rtl::OString aUniqueId = pGraphicObject->GetUniqueID();
1597 [ # # ]: 0 : if (!aUniqueId.isEmpty())
1598 : : {
1599 [ # # ]: 0 : const Graphic &rGraphic = pGraphicObject->GetGraphic();
1600 [ # # ]: 0 : Size aSize(rGraphic.GetPrefSize());
1601 [ # # ]: 0 : const MapMode aMap100mm(MAP_100TH_MM);
1602 [ # # ][ # # ]: 0 : if (MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit())
[ # # ]
1603 : : {
1604 : : aSize = Application::GetDefaultDevice()->PixelToLogic(
1605 [ # # ][ # # ]: 0 : aSize, aMap100mm);
1606 : : }
1607 : : else
1608 : : {
1609 : : aSize = OutputDevice::LogicToLogic(aSize,
1610 [ # # ][ # # ]: 0 : rGraphic.GetPrefMapMode(), aMap100mm);
[ # # ]
1611 : : }
1612 : :
1613 : 0 : Point aEmptyPoint = Point();
1614 [ # # ]: 0 : Rectangle aRect(aEmptyPoint, aSize);
1615 : :
1616 [ # # ]: 0 : sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(),
1617 [ # # ]: 0 : aUniqueId, aRect, NULL, 0);
1618 [ # # ]: 0 : if (nBlibId)
1619 [ # # ][ # # ]: 0 : rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,sal_True);
1620 : : }
1621 : :
1622 [ # # ]: 0 : if (0 != (nOpaque = pGraphicObject->GetAttr().GetTransparency()))
1623 : 0 : bSetOpacity = true;
1624 : :
1625 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture );
1626 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
1627 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
1628 : : }
1629 : : else
1630 : : {
1631 : 6 : sal_uInt32 nFillColor = GetColor(rBrush.GetColor(), false);
1632 : 6 : rPropOpt.AddOpt( ESCHER_Prop_fillColor, nFillColor );
1633 : 6 : rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff );
1634 : 6 : rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
1635 : :
1636 [ + + ]: 6 : if (0 != (nOpaque = rBrush.GetColor().GetTransparency()))
1637 : 3 : bSetOpacity = true;
1638 : : }
1639 : :
1640 [ + + ]: 6 : if (bSetOpacity)
1641 : : {
1642 : 3 : nOpaque = (nOpaque * 100) / 0xFE;
1643 : 3 : nOpaque = ((100 - nOpaque) << 16) / 100;
1644 : 3 : rPropOpt.AddOpt(ESCHER_Prop_fillOpacity, nOpaque);
1645 : : }
1646 : 6 : }
1647 : :
1648 : 6 : bool lcl_isInHeader(const SwFrmFmt& rFmt)
1649 : : {
1650 [ - + ]: 6 : const SwFlyFrmFmt* pFlyFrmFmt = dynamic_cast<const SwFlyFrmFmt*>(&rFmt);
1651 [ + + ]: 6 : if (!pFlyFrmFmt)
1652 : 3 : return false;
1653 : 3 : SwFlyFrm* pFlyFrm = const_cast<SwFlyFrm*>(pFlyFrmFmt->GetFrm());
1654 : 3 : SwPageFrm* pPageFrm = pFlyFrm->FindPageFrmOfAnchor();
1655 : 3 : SwFrm* pHeader = pPageFrm->Lower();
1656 [ + - ]: 3 : if (pHeader->GetType() == FRM_HEADER)
1657 : : {
1658 : 3 : const SwFrm* pFrm = pFlyFrm->GetAnchorFrm();
1659 [ + - ]: 6 : while (pFrm)
1660 : : {
1661 [ + + ]: 6 : if (pFrm == pHeader)
1662 : 3 : return true;
1663 : 3 : pFrm = pFrm->GetUpper();
1664 : : }
1665 : : }
1666 : 6 : return false;
1667 : : }
1668 : :
1669 : 6 : sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrmFmt& rFmt,
1670 : : MSO_SPT eShapeType, EscherPropertyContainer& rPropOpt)
1671 : : {
1672 : 6 : sal_Int32 nLineWidth=0;
1673 : : const SfxPoolItem* pItem;
1674 : 6 : bool bFirstLine = true;
1675 [ + - ][ + + ]: 6 : if (SFX_ITEM_SET == rFmt.GetItemState(RES_BOX, true, &pItem))
1676 : : {
1677 : : static const sal_uInt16 aExhperProp[4] =
1678 : : {
1679 : : ESCHER_Prop_dyTextTop, ESCHER_Prop_dyTextBottom,
1680 : : ESCHER_Prop_dxTextLeft, ESCHER_Prop_dxTextRight
1681 : : };
1682 : : const SvxBorderLine* pLine;
1683 : :
1684 [ + + ]: 15 : for( sal_uInt16 n = 0; n < 4; ++n )
1685 [ + - ][ - + ]: 12 : if( 0 != ( pLine = ((SvxBoxItem*)pItem)->GetLine( n )) )
1686 : : {
1687 [ # # ]: 0 : if( bFirstLine )
1688 : : {
1689 [ # # ]: 0 : sal_uInt32 nLineColor = GetColor(pLine->GetColor(), false);
1690 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_lineColor, nLineColor );
1691 : : rPropOpt.AddOpt( ESCHER_Prop_lineBackColor,
1692 [ # # ]: 0 : nLineColor ^ 0xffffff );
1693 : :
1694 : : MSO_LineStyle eStyle;
1695 [ # # ]: 0 : if( pLine->isDouble() )
1696 : : {
1697 : : // double line
1698 : 0 : nLineWidth = pLine->GetWidth();
1699 [ # # ][ # # ]: 0 : if( pLine->GetInWidth() == pLine->GetOutWidth() )
[ # # ]
1700 : 0 : eStyle = mso_lineDouble;
1701 [ # # ][ # # ]: 0 : else if( pLine->GetInWidth() < pLine->GetOutWidth() )
[ # # ]
1702 : 0 : eStyle = mso_lineThickThin;
1703 : : else
1704 : 0 : eStyle = mso_lineThinThick;
1705 : : }
1706 : : else
1707 : : {
1708 : : // simple line
1709 : 0 : eStyle = mso_lineSimple;
1710 : 0 : nLineWidth = pLine->GetWidth();
1711 : : }
1712 : :
1713 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_lineStyle, eStyle );
1714 : : rPropOpt.AddOpt( ESCHER_Prop_lineWidth,
1715 [ # # ][ # # ]: 0 : DrawModelToEmu( nLineWidth ));
1716 : :
1717 : 0 : MSO_LineDashing eDashing = mso_lineSolid;
1718 [ # # # ]: 0 : switch (pLine->GetBorderLineStyle())
1719 : : {
1720 : : case table::BorderLineStyle::DASHED:
1721 : 0 : eDashing = mso_lineDashGEL;
1722 : 0 : break;
1723 : : case table::BorderLineStyle::DOTTED:
1724 : 0 : eDashing = mso_lineDotGEL;
1725 : 0 : break;
1726 : : case table::BorderLineStyle::SOLID:
1727 : : default:
1728 : 0 : break;
1729 : : }
1730 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_lineDashing, eDashing );
1731 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x8000E );
1732 : :
1733 : : //Use import logic to determine how much of border will go
1734 : : //outside graphic
1735 : : nLineWidth = SwMSDffManager::GetEscherLineMatch(
1736 [ # # ]: 0 : eStyle,eShapeType,nLineWidth);
1737 : 0 : bFirstLine = false;
1738 : : }
1739 : 0 : rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(
1740 [ # # ][ # # ]: 0 : ((SvxBoxItem*)pItem)->GetDistance( n ) ));
[ # # ]
1741 : : }
1742 : : else
1743 : : // MM If there is no line the distance should be set to 0
1744 [ + - ][ + - ]: 12 : rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(0));
1745 : : }
1746 [ + - ]: 6 : if( bFirstLine ) // no valid line found
1747 : : {
1748 [ + - ]: 6 : rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1749 [ + - ]: 6 : rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
1750 [ + - ]: 6 : rPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
1751 [ + - ]: 6 : rPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
1752 [ + - ]: 6 : rPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
1753 : : }
1754 : :
1755 : : // SwWW8ImplReader::Read_GrafLayer() imports these as opaque
1756 : : // unconditionally, so if both are true, don't export the property.
1757 [ + - ]: 6 : bool bIsInHeader = lcl_isInHeader(rFmt);
1758 [ + - ]: 6 : bool bIsThrought = rFmt.GetSurround().GetValue() == SURROUND_THROUGHT;
1759 : :
1760 [ + + ]: 6 : if (bIsInHeader)
1761 : : {
1762 [ + - ]: 3 : const SvxBrushItem& rBrush(rFmt.GetBackground());
1763 [ + - ]: 3 : WriteBrushAttr(rBrush, rPropOpt);
1764 : : }
1765 : : else
1766 : : {
1767 [ + - ]: 3 : SvxBrushItem aBrush(rWrt.TrueFrameBgBrush(rFmt));
1768 [ + - ][ + - ]: 3 : WriteBrushAttr(aBrush, rPropOpt);
1769 : : }
1770 : :
1771 [ + - ]: 6 : const SdrObject* pObj = rFmt.FindRealSdrObject();
1772 : :
1773 [ + - ][ + - ]: 12 : if( pObj && (pObj->GetLayer() == GetHellLayerId() ||
[ + + ][ - + ]
[ + - ][ - + ]
1774 [ + - ][ + - ]: 6 : pObj->GetLayer() == GetInvisibleHellId() ) && !(bIsInHeader && bIsThrought))
[ - + ]
1775 : : {
1776 [ # # ]: 0 : rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
1777 : : }
1778 : :
1779 : 6 : return nLineWidth;
1780 : : }
1781 : :
1782 : 6 : sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrmFmt& rFmt, MSO_SPT eShapeType,
1783 : : EscherPropertyContainer& rPropOpt)
1784 : : {
1785 : : sal_Int32 nLineWidth = SwBasicEscherEx::WriteFlyFrameAttr(rFmt, eShapeType,
1786 [ + - ]: 6 : rPropOpt);
1787 : :
1788 : : /*
1789 : : These are not in SwBasicEscherEx::WriteFlyFrameAttr because inline objs
1790 : : can't do it in word and it hacks it in by stretching the graphic that
1791 : : way, perhaps we should actually draw in this space into the graphic we
1792 : : are exporting!
1793 : : */
1794 : : const SfxPoolItem* pItem;
1795 [ + - ][ + + ]: 6 : if (SFX_ITEM_SET == rFmt.GetItemState(RES_LR_SPACE, true, &pItem))
1796 : : {
1797 : : rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft,
1798 [ + - ][ + - ]: 3 : DrawModelToEmu( ((SvxLRSpaceItem*)pItem)->GetLeft() ) );
1799 : : rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight,
1800 [ + - ][ + - ]: 3 : DrawModelToEmu( ((SvxLRSpaceItem*)pItem)->GetRight() ) );
1801 : : }
1802 : : else
1803 : : {
1804 [ + - ]: 3 : rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft, 0 );
1805 [ + - ]: 3 : rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, 0 );
1806 : : }
1807 : :
1808 [ + - ][ - + ]: 6 : if (SFX_ITEM_SET == rFmt.GetItemState(RES_UL_SPACE, true, &pItem))
1809 : : {
1810 : : rPropOpt.AddOpt( ESCHER_Prop_dyWrapDistTop,
1811 [ # # ][ # # ]: 0 : DrawModelToEmu( ((SvxULSpaceItem*)pItem)->GetUpper() ) );
1812 : : rPropOpt.AddOpt( ESCHER_Prop_dyWrapDistBottom,
1813 [ # # ][ # # ]: 0 : DrawModelToEmu( ((SvxULSpaceItem*)pItem)->GetLower() ) );
1814 : : }
1815 : :
1816 [ + - ][ - + ]: 6 : if (rFmt.GetSurround().IsContour())
1817 : : {
1818 [ # # ][ # # ]: 0 : if (const SwNoTxtNode *pNd = GetNoTxtNodeFromSwFrmFmt(rFmt))
1819 : : {
1820 [ # # ]: 0 : const PolyPolygon *pPolyPoly = pNd->HasContour();
1821 [ # # ][ # # ]: 0 : if (pPolyPoly && pPolyPoly->Count())
[ # # ][ # # ]
1822 : : {
1823 [ # # ]: 0 : Polygon aPoly(PolygonFromPolyPolygon(*pPolyPoly));
1824 [ # # ][ # # ]: 0 : const Size &rOrigSize = pNd->GetGraphic().GetPrefSize();
[ # # ]
1825 [ # # ]: 0 : Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width());
1826 [ # # ]: 0 : Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height());
1827 [ # # ][ # # ]: 0 : aPoly.Scale(aMapPolyX, aMapPolyY);
[ # # ]
1828 : :
1829 : : /*
1830 : : a) stretch right bound by 15twips
1831 : : b) shrink bottom bound to where it would have been in word
1832 : : c) Move it to the left by 15twips
1833 : :
1834 : : See the import for details
1835 : : */
1836 [ # # ]: 0 : const Size &rSize = pNd->GetTwipSize();
1837 [ # # ]: 0 : Fraction aMoveHack(ww::nWrap100Percent, rSize.Width());
1838 [ # # ][ # # ]: 0 : aMoveHack *= Fraction(15, 1);
1839 [ # # ]: 0 : long nMove(aMoveHack);
1840 : :
1841 : : Fraction aHackX(ww::nWrap100Percent + nMove,
1842 [ # # ]: 0 : ww::nWrap100Percent);
1843 : : Fraction aHackY(ww::nWrap100Percent - nMove,
1844 [ # # ]: 0 : ww::nWrap100Percent);
1845 [ # # ][ # # ]: 0 : aPoly.Scale(aHackX, aHackY);
[ # # ]
1846 : :
1847 [ # # ]: 0 : aPoly.Move(-nMove, 0);
1848 : :
1849 [ # # ]: 0 : SvMemoryStream aPolyDump;
1850 [ # # ]: 0 : aPolyDump.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
1851 : :
1852 [ # # ]: 0 : sal_uInt16 nLen = aPoly.GetSize();
1853 [ # # ]: 0 : aPolyDump << nLen;
1854 [ # # ]: 0 : aPolyDump << nLen;
1855 [ # # ]: 0 : aPolyDump << sal_uInt16(8);
1856 [ # # ]: 0 : for (sal_uInt16 nI = 0; nI < nLen; ++nI)
1857 : : {
1858 [ # # ][ # # ]: 0 : aPolyDump << sal_uInt32(aPoly[nI].X());
1859 [ # # ][ # # ]: 0 : aPolyDump << sal_uInt32(aPoly[nI].Y());
1860 : : }
1861 : :
1862 [ # # ]: 0 : sal_uInt16 nArrLen = msword_cast<sal_uInt16>(aPolyDump.Tell());
1863 [ # # ]: 0 : void *pArr = const_cast<void *>(aPolyDump.GetData());
1864 : : //PropOpt wants to own the buffer
1865 : 0 : aPolyDump.ObjectOwnsMemory(false);
1866 : : rPropOpt.AddOpt(DFF_Prop_pWrapPolygonVertices, false,
1867 [ # # ][ # # ]: 0 : nArrLen, static_cast<sal_uInt8 *>(pArr), nArrLen);
[ # # ]
1868 : : }
1869 : : }
1870 : : }
1871 : :
1872 : 6 : return nLineWidth;
1873 : : }
1874 : :
1875 : 6 : void SwBasicEscherEx::Init()
1876 : : {
1877 : 6 : MapUnit eMap = MAP_TWIP;
1878 [ + - ][ + - ]: 6 : if (SdrModel *pModel = rWrt.pDoc->GetDrawModel())
1879 : : {
1880 : : // PPT arbeitet nur mit Einheiten zu 576DPI
1881 : : // WW hingegen verwendet twips, dh. 1440DPI.
1882 : 6 : eMap = pModel->GetScaleUnit();
1883 : : }
1884 : :
1885 : : // MS-DFF-Properties sind grossteils in EMU (English Metric Units) angegeben
1886 : : // 1mm=36000emu, 1twip=635emu
1887 [ + - ]: 6 : Fraction aFact(360, 1);
1888 [ + - ][ + - ]: 6 : aFact /= GetMapFactor(MAP_100TH_MM, eMap).X();
1889 : : // create little values
1890 [ + - ][ + - ]: 6 : aFact = Fraction(aFact.GetNumerator(), aFact.GetDenominator());
1891 : 6 : mnEmuMul = aFact.GetNumerator();
1892 : 6 : mnEmuDiv = aFact.GetDenominator();
1893 : :
1894 [ + - ]: 6 : SetHellLayerId(rWrt.pDoc->GetHellId());
1895 : 6 : }
1896 : :
1897 : 0 : sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax) const
1898 : : {
1899 [ # # ]: 0 : if (nMax)
1900 : : {
1901 : 0 : sal_Int32 nMSVal = (nVal / 65536) * nMax;
1902 : 0 : nMSVal += (nVal * 65536 ) / nMax;
1903 : 0 : return nMSVal;
1904 : : }
1905 : 0 : return 0;
1906 : : }
1907 : :
1908 : 3 : SdrLayerID SwBasicEscherEx::GetInvisibleHellId() const
1909 : : {
1910 : 3 : return rWrt.pDoc->GetInvisibleHellId();
1911 : : }
1912 : :
1913 : 0 : void SwBasicEscherEx::WritePictures()
1914 : : {
1915 [ # # ]: 0 : if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
1916 : : {
1917 : : // set the blip - entries to the correct stream pos
1918 : 0 : sal_Int32 nEndPos = pPicStrm->Tell();
1919 : 0 : mxGlobal->WriteBlibStoreEntry(*pEscherStrm, 1, sal_True, nEndPos);
1920 : :
1921 : 0 : pPicStrm->Seek(0);
1922 : 0 : *pEscherStrm << *pPicStrm;
1923 : : }
1924 : 0 : }
1925 : :
1926 : 6 : SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt)
1927 : : : SwBasicEscherEx(pStrm, rWW8Wrt),
1928 [ + - ][ + - ]: 6 : pTxtBxs(0)
1929 : : {
1930 : 6 : aHostData.SetClientData(&aWinwordAnchoring);
1931 [ + - ]: 6 : OpenContainer( ESCHER_DggContainer );
1932 : :
1933 : 6 : sal_uInt16 nColorCount = 4;
1934 [ + - ]: 6 : *pStrm << (sal_uInt16)( nColorCount << 4 ) // instance
1935 [ + - ]: 6 : << (sal_uInt16)ESCHER_SplitMenuColors // record type
1936 [ + - ]: 6 : << (sal_uInt32)( nColorCount * 4 ) // size
1937 [ + - ]: 6 : << (sal_uInt32)0x08000004
1938 [ + - ]: 6 : << (sal_uInt32)0x08000001
1939 [ + - ]: 6 : << (sal_uInt32)0x08000002
1940 [ + - ]: 6 : << (sal_uInt32)0x100000f7;
1941 : :
1942 [ + - ]: 6 : CloseContainer(); // ESCHER_DggContainer
1943 : :
1944 : 6 : sal_uInt8 i = 2; // for header/footer and the other
1945 : 6 : PlcDrawObj *pSdrObjs = rWrt.pHFSdrObjs;
1946 : 6 : pTxtBxs = rWrt.pHFTxtBxs;
1947 : :
1948 : : // if no header/footer -> skip over
1949 [ + + ]: 6 : if (!pSdrObjs->size())
1950 : : {
1951 : 3 : --i;
1952 : 3 : pSdrObjs = rWrt.pSdrObjs;
1953 : 3 : pTxtBxs = rWrt.pTxtBxs;
1954 : : }
1955 : :
1956 [ + + ]: 15 : for( ; i--; pSdrObjs = rWrt.pSdrObjs, pTxtBxs = rWrt.pTxtBxs )
1957 : : {
1958 : : // "dummy char" (or any Count ?) - why? This knows only M$
1959 [ + - ]: 9 : GetStream() << (sal_Char)i;
1960 : :
1961 [ + - ]: 9 : OpenContainer( ESCHER_DgContainer );
1962 : :
1963 [ + - ]: 9 : EnterGroup( 0 );
1964 : :
1965 [ + + ][ + - ]: 9 : sal_uLong nSecondShapeId = pSdrObjs == rWrt.pSdrObjs ? GenerateShapeId() : 0;
1966 : :
1967 : : // write now all Writer-/DrawObjects
1968 [ + - ]: 9 : DrawObjPointerVector aSorted;
1969 [ + - ]: 9 : MakeZOrderArrAndFollowIds(pSdrObjs->GetObjArr(), aSorted);
1970 : :
1971 : 9 : sal_uInt32 nShapeId=0;
1972 : 9 : DrawObjPointerIter aEnd = aSorted.end();
1973 [ + - ][ + + ]: 15 : for (DrawObjPointerIter aIter = aSorted.begin(); aIter != aEnd; ++aIter)
1974 : : {
1975 : 6 : sal_Int32 nBorderThick=0;
1976 : 6 : DrawObj *pObj = (*aIter);
1977 : : OSL_ENSURE(pObj, "impossible");
1978 [ - + ]: 6 : if (!pObj)
1979 : 0 : continue;
1980 : 6 : const sw::Frame &rFrame = pObj->maCntnt;
1981 : 6 : const SwFrmFmt& rFmt = rFrame.GetFrmFmt();
1982 : :
1983 [ + + - - ]: 6 : switch (rFrame.GetWriterType())
1984 : : {
1985 : : case sw::Frame::eTxtBox:
1986 : : case sw::Frame::eOle:
1987 : : case sw::Frame::eGraphic:
1988 [ + - ]: 3 : nBorderThick = WriteFlyFrm(*pObj, nShapeId, aSorted);
1989 : 3 : break;
1990 : : case sw::Frame::eFormControl:
1991 [ + - ][ + - ]: 3 : WriteOCXControl(rFmt, nShapeId = GenerateShapeId());
1992 : 3 : break;
1993 : : case sw::Frame::eDrawing:
1994 [ # # ]: 0 : aWinwordAnchoring.SetAnchoring(rFmt);
1995 [ # # ]: 0 : const SdrObject* pSdrObj = rFmt.FindRealSdrObject();
1996 [ # # ]: 0 : if (pSdrObj)
1997 : : {
1998 : 0 : bool bSwapInPage = false;
1999 [ # # ][ # # ]: 0 : if (!pSdrObj->GetPage())
2000 : : {
2001 [ # # ][ # # ]: 0 : if (SdrModel* pModel = rWrt.pDoc->GetDrawModel())
2002 : : {
2003 [ # # ][ # # ]: 0 : if (SdrPage *pPage = pModel->GetPage(0))
2004 : : {
2005 : 0 : bSwapInPage = true;
2006 [ # # ]: 0 : (const_cast<SdrObject*>(pSdrObj))->SetPage(pPage);
2007 : : }
2008 : : }
2009 : : }
2010 : :
2011 [ # # ]: 0 : nShapeId = AddSdrObject(*pSdrObj);
2012 : :
2013 [ # # ]: 0 : if (bSwapInPage)
2014 [ # # ]: 0 : (const_cast<SdrObject*>(pSdrObj))->SetPage(0);
2015 : : }
2016 : : #if OSL_DEBUG_LEVEL > 0
2017 : : else
2018 : : OSL_ENSURE( !this, "Where is the SDR-Object?" );
2019 : : #endif
2020 : : }
2021 : :
2022 [ - + ]: 6 : if( !nShapeId )
2023 : : {
2024 [ # # ]: 0 : nShapeId = AddDummyShape();
2025 : : }
2026 : :
2027 : 6 : pObj->SetShapeDetails(nShapeId, nBorderThick);
2028 : : }
2029 : :
2030 [ + - ]: 9 : EndSdrObjectPage(); // ???? Bugfix for 74724
2031 : :
2032 [ + + ]: 9 : if( nSecondShapeId )
2033 : : {
2034 [ + - ]: 6 : OpenContainer( ESCHER_SpContainer );
2035 : :
2036 [ + - ]: 6 : AddShape( ESCHER_ShpInst_Rectangle, 0xe00, nSecondShapeId );
2037 : :
2038 [ + - ]: 6 : EscherPropertyContainer aPropOpt;
2039 [ + - ]: 6 : const SwFrmFmt &rFmt = rWrt.pDoc->GetPageDesc(0).GetMaster();
2040 : 6 : const SfxPoolItem* pItem = 0;
2041 : : SfxItemState eState = rFmt.GetItemState(RES_BACKGROUND, true,
2042 [ + - ]: 6 : &pItem);
2043 [ - + ][ # # ]: 6 : if (SFX_ITEM_SET == eState && pItem)
2044 : : {
2045 : 0 : const SvxBrushItem* pBrush = (const SvxBrushItem*)pItem;
2046 [ # # ]: 0 : WriteBrushAttr(*pBrush, aPropOpt);
2047 : : }
2048 [ + - ]: 6 : aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
2049 [ + - ]: 6 : aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
2050 [ + - ]: 6 : aPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
2051 [ + - ]: 6 : aPropOpt.AddOpt( ESCHER_Prop_lineWidth, 0 );
2052 : :
2053 [ + - ]: 6 : aPropOpt.Commit( *pStrm );
2054 : :
2055 [ + - ]: 6 : AddAtom( 4, ESCHER_ClientData );
2056 [ + - ]: 6 : GetStream() << static_cast<sal_Int32>(1);
2057 : :
2058 [ + - ][ + - ]: 6 : CloseContainer(); // ESCHER_SpContainer
2059 : : }
2060 [ + - ]: 9 : CloseContainer(); // ESCHER_DgContainer
2061 : 9 : }
2062 : 6 : }
2063 : :
2064 [ + - ]: 6 : SwEscherEx::~SwEscherEx()
2065 : : {
2066 [ - + ]: 12 : }
2067 : :
2068 : 6 : void SwEscherEx::FinishEscher()
2069 : : {
2070 : 6 : pEscherStrm->Seek(0);
2071 : 6 : *rWrt.pTableStrm << *pEscherStrm;
2072 [ + - ]: 6 : delete pEscherStrm, pEscherStrm = 0;
2073 : 6 : }
2074 : :
2075 : : /** method to perform conversion of positioning attributes with the help
2076 : : of corresponding layout information
2077 : :
2078 : : #i30669#
2079 : : Because most of the Writer object positions doesn't correspond to the
2080 : : object positions in WW8, this method converts the positioning
2081 : : attributes. For this conversion the corresponding layout information
2082 : : is needed. If no layout information exists - e.g. no layout exists - no
2083 : : conversion is performed.
2084 : : No conversion is performed for as-character anchored objects. Whose
2085 : : object positions are already treated special in method <WriteData(..)>.
2086 : :
2087 : : @param _iorHoriOri
2088 : : input/output parameter - containing the current horizontal position
2089 : : attributes, which are converted by this method.
2090 : :
2091 : : @param _iorVertOri
2092 : : input/output parameter - containing the current vertical position
2093 : : attributes, which are converted by this method.
2094 : :
2095 : : @param _rFrmFmt
2096 : : input parameter - frame format of the anchored object
2097 : :
2098 : : @return boolean, indicating, if a conversion has been performed.
2099 : : */
2100 : 12 : bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri,
2101 : : SwFmtVertOrient& _iorVertOri,
2102 : : const SwFrmFmt& _rFrmFmt )
2103 : : {
2104 : 12 : const RndStdIds eAnchor = _rFrmFmt.GetAnchor().GetAnchorId();
2105 : :
2106 [ - + ][ + - ]: 12 : if ( (FLY_AS_CHAR == eAnchor) || (FLY_AT_FLY == eAnchor) )
2107 : : {
2108 : : // no conversion for as-character or at frame anchored objects
2109 : 0 : return false;
2110 : : }
2111 : :
2112 : : // determine anchored object
2113 : 12 : SwAnchoredObject* pAnchoredObj( 0L );
2114 : : {
2115 : 12 : const SwContact* pContact = _rFrmFmt.FindContactObj();
2116 [ + - ]: 12 : if ( pContact )
2117 : : {
2118 [ + - ]: 12 : std::list<SwAnchoredObject*> aAnchoredObjs;
2119 [ + - ]: 12 : pContact->GetAnchoredObjs( aAnchoredObjs );
2120 [ + - ]: 12 : if ( !aAnchoredObjs.empty() )
2121 : : {
2122 [ + - ]: 12 : pAnchoredObj = aAnchoredObjs.front();
2123 : 12 : }
2124 : : }
2125 : : }
2126 [ - + ]: 12 : if ( !pAnchoredObj )
2127 : : {
2128 : : // no anchored object found. Thus, the needed layout information can't
2129 : : // be determined. --> no conversion
2130 : 0 : return false;
2131 : : }
2132 : : // no conversion for anchored drawing object, which aren't attached to an
2133 : : // anchor frame.
2134 : : // This is the case for drawing objects, which are anchored inside a page
2135 : : // header/footer of an *unused* page style.
2136 [ + - ][ - + ]: 24 : if ( dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) &&
[ - + ]
2137 [ + + ]: 12 : !pAnchoredObj->GetAnchorFrm() )
2138 : : {
2139 : 0 : return false;
2140 : : }
2141 : :
2142 : 12 : bool bConverted( false );
2143 : :
2144 : : // determine value of attribute 'Follow text flow', because positions aligned
2145 : : // at page areas have to be converted, if it's set.
2146 : 12 : const bool bFollowTextFlow = _rFrmFmt.GetFollowTextFlow().GetValue();
2147 : :
2148 : : // check, if horizontal and vertical position have to be converted due to
2149 : : // the fact, that the object is anchored at a paragraph, which has a "column
2150 : : // break before" attribute
2151 : 12 : bool bConvDueToAnchoredAtColBreakPara( false );
2152 [ + - + - : 36 : if ( ( (eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR) ) &&
+ - ][ + - ]
[ + + ]
2153 : 12 : _rFrmFmt.GetAnchor().GetCntntAnchor() &&
2154 : 12 : _rFrmFmt.GetAnchor().GetCntntAnchor()->nNode.GetNode().IsTxtNode() )
2155 : : {
2156 : : SwTxtNode& rAnchorTxtNode =
2157 [ + - ]: 12 : dynamic_cast<SwTxtNode&>(_rFrmFmt.GetAnchor().GetCntntAnchor()->nNode.GetNode());
2158 : 12 : const SvxFmtBreakItem* pBreak = &(ItemGet<SvxFmtBreakItem>(rAnchorTxtNode, RES_BREAK));
2159 [ - + ]: 24 : if ( pBreak &&
[ + - - + ]
2160 : 12 : pBreak->GetBreak() == SVX_BREAK_COLUMN_BEFORE )
2161 : : {
2162 : 0 : bConvDueToAnchoredAtColBreakPara = true;
2163 : : }
2164 : : }
2165 : :
2166 : : // convert horizontal position, if needed
2167 : : {
2168 : : enum HoriConv { NO_CONV, CONV2PG, CONV2COL, CONV2CHAR };
2169 : 12 : HoriConv eHoriConv( NO_CONV );
2170 : :
2171 : : // determine, if conversion has to be performed due to the position orientation
2172 : 12 : bool bConvDueToOrientation( false );
2173 : : {
2174 : 12 : const sal_Int16 eHOri = _iorHoriOri.GetHoriOrient();
2175 : : bConvDueToOrientation = eHOri == text::HoriOrientation::LEFT || eHOri == text::HoriOrientation::RIGHT ||
2176 : : eHOri == text::HoriOrientation::INSIDE || eHOri == text::HoriOrientation::OUTSIDE ||
2177 [ + - ][ + - ]: 12 : ( eHOri != text::HoriOrientation::CENTER && _iorHoriOri.IsPosToggle() );
[ + - ][ + - ]
[ - + ][ + - ]
2178 : : }
2179 : :
2180 : : // determine conversion type due to the position relation
2181 [ - + ]: 12 : if ( bConvDueToAnchoredAtColBreakPara )
2182 : : {
2183 : 0 : eHoriConv = CONV2PG;
2184 : : }
2185 : : else
2186 : : {
2187 [ - - + - : 12 : switch ( _iorHoriOri.GetRelationOrient() )
- - ]
2188 : : {
2189 : : case text::RelOrientation::PAGE_FRAME:
2190 : : case text::RelOrientation::PAGE_PRINT_AREA:
2191 : : {
2192 [ # # ][ # # ]: 0 : if ( bConvDueToOrientation || bFollowTextFlow )
2193 : 0 : eHoriConv = CONV2PG;
2194 : : }
2195 : 0 : break;
2196 : : case text::RelOrientation::PAGE_LEFT:
2197 : : case text::RelOrientation::PAGE_RIGHT:
2198 : : {
2199 : : // relation not supported by WW8. Thus, conversion always needed.
2200 : 0 : eHoriConv = CONV2PG;
2201 : : }
2202 : 0 : break;
2203 : : case text::RelOrientation::FRAME:
2204 : : {
2205 [ - + ]: 12 : if ( bConvDueToOrientation )
2206 : 0 : eHoriConv = CONV2COL;
2207 : : }
2208 : 12 : break;
2209 : : case text::RelOrientation::PRINT_AREA:
2210 : : case text::RelOrientation::FRAME_LEFT:
2211 : : case text::RelOrientation::FRAME_RIGHT:
2212 : : {
2213 : : // relation not supported by WW8. Thus, conversion always needed.
2214 : 0 : eHoriConv = CONV2COL;
2215 : : }
2216 : 0 : break;
2217 : : case text::RelOrientation::CHAR:
2218 : : {
2219 [ # # ]: 0 : if ( bConvDueToOrientation )
2220 : 0 : eHoriConv = CONV2CHAR;
2221 : : }
2222 : 0 : break;
2223 : : default:
2224 : : OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" );
2225 : : }
2226 : : }
2227 [ - + ]: 12 : if ( eHoriConv != NO_CONV )
2228 : : {
2229 : 0 : _iorHoriOri.SetHoriOrient( text::HoriOrientation::NONE );
2230 : 0 : SwTwips nPosX( 0L );
2231 : : {
2232 : 0 : Point aPos;
2233 [ # # ]: 0 : if ( eHoriConv == CONV2PG )
2234 : : {
2235 : 0 : _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
2236 : : // #i33818#
2237 : 0 : bool bRelToTableCell( false );
2238 : : aPos = pAnchoredObj->GetRelPosToPageFrm( bFollowTextFlow,
2239 [ # # ]: 0 : bRelToTableCell );
2240 [ # # ]: 0 : if ( bRelToTableCell )
2241 : : {
2242 : 0 : _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
2243 : : }
2244 : : }
2245 [ # # ]: 0 : else if ( eHoriConv == CONV2COL )
2246 : : {
2247 : 0 : _iorHoriOri.SetRelationOrient( text::RelOrientation::FRAME );
2248 [ # # ]: 0 : aPos = pAnchoredObj->GetRelPosToAnchorFrm();
2249 : : }
2250 [ # # ]: 0 : else if ( eHoriConv == CONV2CHAR )
2251 : : {
2252 : 0 : _iorHoriOri.SetRelationOrient( text::RelOrientation::CHAR );
2253 [ # # ]: 0 : aPos = pAnchoredObj->GetRelPosToChar();
2254 : : }
2255 : : // No distinction between layout directions, because of missing
2256 : : // information about WW8 in vertical layout.
2257 : 0 : nPosX = aPos.X();
2258 : : }
2259 : 0 : _iorHoriOri.SetPos( nPosX );
2260 : 0 : bConverted = true;
2261 : : }
2262 : : }
2263 : :
2264 : : // convert vertical position, if needed
2265 : : {
2266 : : enum VertConv { NO_CONV, CONV2PG, CONV2PARA, CONV2LINE };
2267 : 12 : VertConv eVertConv( NO_CONV );
2268 : :
2269 : : // determine, if conversion has to be performed due to the position orientation
2270 : 12 : bool bConvDueToOrientation( false );
2271 : : {
2272 : 12 : const sal_Int16 eVOri = _iorVertOri.GetVertOrient();
2273 : : bConvDueToOrientation = ( eVOri == text::VertOrientation::TOP ||
2274 : : eVOri == text::VertOrientation::BOTTOM ||
2275 : : eVOri == text::VertOrientation::CHAR_TOP ||
2276 : : eVOri == text::VertOrientation::CHAR_BOTTOM ||
2277 : : eVOri == text::VertOrientation::CHAR_CENTER ||
2278 : : eVOri == text::VertOrientation::LINE_TOP ||
2279 : : eVOri == text::VertOrientation::LINE_BOTTOM ||
2280 [ + - ][ + - ]: 12 : eVOri == text::VertOrientation::LINE_CENTER );
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
2281 : : }
2282 : :
2283 : : // determine conversion type due to the position relation
2284 [ - + ]: 12 : if ( bConvDueToAnchoredAtColBreakPara )
2285 : : {
2286 : 0 : eVertConv = CONV2PG;
2287 : : }
2288 : : else
2289 : : {
2290 [ - + - - : 12 : switch ( _iorVertOri.GetRelationOrient() )
- - ]
2291 : : {
2292 : : case text::RelOrientation::PAGE_FRAME:
2293 : : case text::RelOrientation::PAGE_PRINT_AREA:
2294 : : {
2295 [ # # ][ # # ]: 0 : if ( bConvDueToOrientation || bFollowTextFlow )
2296 : 0 : eVertConv = CONV2PG;
2297 : : }
2298 : 0 : break;
2299 : : case text::RelOrientation::FRAME:
2300 : : {
2301 [ + - - + ]: 24 : if ( bConvDueToOrientation ||
[ - + ]
2302 : 12 : _iorVertOri.GetVertOrient() == text::VertOrientation::CENTER )
2303 : : {
2304 : 0 : eVertConv = CONV2PARA;
2305 : : }
2306 : : }
2307 : 12 : break;
2308 : : case text::RelOrientation::PRINT_AREA:
2309 : : {
2310 : : // relation not supported by WW8. Thus, conversion always needed.
2311 : 0 : eVertConv = CONV2PARA;
2312 : : }
2313 : 0 : break;
2314 : : case text::RelOrientation::CHAR:
2315 : : {
2316 : : // relation not supported by WW8. Thus, conversion always needed.
2317 : 0 : eVertConv = CONV2PARA;
2318 : : }
2319 : 0 : break;
2320 : : case text::RelOrientation::TEXT_LINE:
2321 : : {
2322 [ # # # # ]: 0 : if ( bConvDueToOrientation ||
[ # # ]
2323 : 0 : _iorVertOri.GetVertOrient() == text::VertOrientation::NONE )
2324 : : {
2325 : 0 : eVertConv = CONV2LINE;
2326 : : }
2327 : : }
2328 : 0 : break;
2329 : : case text::RelOrientation::PAGE_LEFT:
2330 : : case text::RelOrientation::PAGE_RIGHT:
2331 : : case text::RelOrientation::FRAME_LEFT:
2332 : : case text::RelOrientation::FRAME_RIGHT:
2333 : : default:
2334 : : OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown vertical relation" );
2335 : : }
2336 : : }
2337 : :
2338 [ - + ]: 12 : if ( eVertConv != NO_CONV )
2339 : : {
2340 : 0 : _iorVertOri.SetVertOrient( text::VertOrientation::NONE );
2341 : 0 : SwTwips nPosY( 0L );
2342 : : {
2343 : 0 : Point aPos;
2344 [ # # ]: 0 : if ( eVertConv == CONV2PG )
2345 : : {
2346 : 0 : _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
2347 : : // #i33818#
2348 : 0 : bool bRelToTableCell( false );
2349 : : aPos = pAnchoredObj->GetRelPosToPageFrm( bFollowTextFlow,
2350 [ # # ]: 0 : bRelToTableCell );
2351 [ # # ]: 0 : if ( bRelToTableCell )
2352 : : {
2353 : 0 : _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
2354 : : }
2355 : : }
2356 [ # # ]: 0 : else if ( eVertConv == CONV2PARA )
2357 : : {
2358 : 0 : _iorVertOri.SetRelationOrient( text::RelOrientation::FRAME );
2359 [ # # ]: 0 : aPos = pAnchoredObj->GetRelPosToAnchorFrm();
2360 : : }
2361 [ # # ]: 0 : else if ( eVertConv == CONV2LINE )
2362 : : {
2363 : 0 : _iorVertOri.SetRelationOrient( text::RelOrientation::TEXT_LINE );
2364 [ # # ]: 0 : aPos = pAnchoredObj->GetRelPosToLine();
2365 : : }
2366 : : // No distinction between layout directions, because of missing
2367 : : // information about WW8 in vertical layout.
2368 : 0 : nPosY = aPos.Y();
2369 : : }
2370 : 0 : _iorVertOri.SetPos( nPosY );
2371 : 0 : bConverted = true;
2372 : : }
2373 : : }
2374 : :
2375 : 12 : return bConverted;
2376 : : }
2377 : :
2378 : 6 : void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt)
2379 : : {
2380 [ + - ]: 6 : const RndStdIds eAnchor = rFmt.GetAnchor().GetAnchorId();
2381 : 6 : mbInline = (eAnchor == FLY_AS_CHAR);
2382 : :
2383 [ + - ][ + - ]: 6 : SwFmtHoriOrient rHoriOri = rFmt.GetHoriOrient();
2384 [ + - ][ + - ]: 6 : SwFmtVertOrient rVertOri = rFmt.GetVertOrient();
2385 : :
2386 : : // #i30669# - convert the positioning attributes.
2387 : : // Most positions are converted, if layout information exists.
2388 [ + - ]: 6 : const bool bPosConverted = ConvertPosition( rHoriOri, rVertOri, rFmt );
2389 : :
2390 : 6 : const sal_Int16 eHOri = rHoriOri.GetHoriOrient();
2391 : 6 : const sal_Int16 eVOri = rVertOri.GetVertOrient(); // #i22673#
2392 : :
2393 : 6 : const sal_Int16 eHRel = rHoriOri.GetRelationOrient();
2394 : 6 : const sal_Int16 eVRel = rVertOri.GetRelationOrient();
2395 : :
2396 : : // horizontal Adjustment
2397 [ + - - - : 6 : switch (eHOri)
- - ]
2398 : : {
2399 : : default:
2400 : : case text::HoriOrientation::NONE:
2401 : 6 : mnXAlign = 0;
2402 : 6 : break;
2403 : : case text::HoriOrientation::LEFT:
2404 : 0 : mnXAlign = 1;
2405 : 0 : break;
2406 : : case text::HoriOrientation::CENTER:
2407 : 0 : mnXAlign = 2;
2408 : 0 : break;
2409 : : case text::HoriOrientation::RIGHT:
2410 : 0 : mnXAlign = 3;
2411 : 0 : break;
2412 : : case text::HoriOrientation::INSIDE:
2413 : 0 : mnXAlign = 4;
2414 : 0 : break;
2415 : : case text::HoriOrientation::OUTSIDE:
2416 : 0 : mnXAlign = 5;
2417 : 0 : break;
2418 : : }
2419 : :
2420 : : // vertical Adjustment
2421 : : // #i22673#
2422 : : // When adjustment is vertically relative to line or to char
2423 : : // bottom becomes top and vice versa
2424 : 6 : const bool bVertSwap = !bPosConverted &&
2425 : : ( (eVRel == text::RelOrientation::CHAR) ||
2426 [ + - ][ + - ]: 6 : (eVRel == text::RelOrientation::TEXT_LINE) );
[ - + ]
2427 [ + - - - ]: 6 : switch (eVOri)
2428 : : {
2429 : : default:
2430 : : case text::VertOrientation::NONE:
2431 : 6 : mnYAlign = 0;
2432 : 6 : break;
2433 : : case text::VertOrientation::TOP:
2434 : : case text::VertOrientation::LINE_TOP:
2435 : : case text::VertOrientation::CHAR_TOP:
2436 [ # # ]: 0 : mnYAlign = bVertSwap ? 3 : 1;
2437 : 0 : break;
2438 : : case text::VertOrientation::CENTER:
2439 : : case text::VertOrientation::LINE_CENTER:
2440 : 0 : mnYAlign = 2;
2441 : 0 : break;
2442 : : case text::VertOrientation::BOTTOM:
2443 : : case text::VertOrientation::LINE_BOTTOM:
2444 : : case text::VertOrientation::CHAR_BOTTOM:
2445 [ # # ]: 0 : mnYAlign = bVertSwap ? 1 : 3;
2446 : 0 : break;
2447 : : }
2448 : :
2449 : : // Adjustment is horizontally relative to...
2450 [ - - + - : 6 : switch (eHRel)
- - - ]
2451 : : {
2452 : : case text::RelOrientation::PAGE_PRINT_AREA:
2453 : 0 : mnXRelTo = 0;
2454 : 0 : break;
2455 : : case text::RelOrientation::PAGE_FRAME:
2456 : : case text::RelOrientation::PAGE_LEFT: //:-(
2457 : : case text::RelOrientation::PAGE_RIGHT: //:-(
2458 : 0 : mnXRelTo = 1;
2459 : 0 : break;
2460 : : case text::RelOrientation::FRAME:
2461 : : case text::RelOrientation::FRAME_LEFT: //:-(
2462 : : case text::RelOrientation::FRAME_RIGHT: //:-(
2463 [ - + ]: 6 : if (eAnchor == FLY_AT_PAGE)
2464 : 0 : mnXRelTo = 1;
2465 : : else
2466 : 6 : mnXRelTo = 2;
2467 : 6 : break;
2468 : : case text::RelOrientation::PRINT_AREA:
2469 [ # # ]: 0 : if (eAnchor == FLY_AT_PAGE)
2470 : 0 : mnXRelTo = 0;
2471 : : else
2472 : 0 : mnXRelTo = 2;
2473 : 0 : break;
2474 : : case text::RelOrientation::CHAR:
2475 : 0 : mnXRelTo = 3;
2476 : 0 : break;
2477 : : case text::RelOrientation::TEXT_LINE:
2478 : 0 : break;
2479 : : }
2480 : :
2481 : : // Adjustment is vertically relative to...
2482 [ - - - + : 6 : switch (eVRel)
- - ]
2483 : : {
2484 : : case text::RelOrientation::PAGE_PRINT_AREA:
2485 : 0 : mnYRelTo = 0;
2486 : 0 : break;
2487 : : case text::RelOrientation::PAGE_FRAME:
2488 : 0 : mnYRelTo = 1;
2489 : 0 : break;
2490 : : case text::RelOrientation::PRINT_AREA:
2491 [ # # ]: 0 : if (eAnchor == FLY_AT_PAGE)
2492 : 0 : mnYRelTo = 0;
2493 : : else
2494 : 0 : mnYRelTo = 2;
2495 : 0 : break;
2496 : : case text::RelOrientation::FRAME:
2497 [ - + ]: 6 : if (eAnchor == FLY_AT_PAGE)
2498 : 0 : mnYRelTo = 1;
2499 : : else
2500 : 6 : mnYRelTo = 2;
2501 : 6 : break;
2502 : : case text::RelOrientation::CHAR:
2503 : : case text::RelOrientation::TEXT_LINE: // #i22673# - vertical alignment at top of line
2504 : : case text::RelOrientation::PAGE_LEFT: //nonsense
2505 : : case text::RelOrientation::PAGE_RIGHT: //nonsense
2506 : : case text::RelOrientation::FRAME_LEFT: //nonsense
2507 : : case text::RelOrientation::FRAME_RIGHT: //nonsense
2508 : 0 : mnYRelTo = 3;
2509 : 0 : break;
2510 [ + - ][ + - ]: 6 : }
2511 : 6 : }
2512 : :
2513 : 6 : void SwEscherEx::WriteFrmExtraData( const SwFrmFmt& rFmt )
2514 : : {
2515 : 6 : aWinwordAnchoring.SetAnchoring(rFmt);
2516 : 6 : aWinwordAnchoring.WriteData(*this);
2517 : :
2518 : 6 : AddAtom(4, ESCHER_ClientAnchor);
2519 : 6 : GetStream() << static_cast<sal_Int32>(0);
2520 : :
2521 : 6 : AddAtom(4, ESCHER_ClientData);
2522 : 6 : GetStream() << static_cast<sal_Int32>(1);
2523 : 6 : }
2524 : :
2525 : 3 : sal_Int32 SwEscherEx::WriteFlyFrm(const DrawObj &rObj, sal_uInt32 &rShapeId,
2526 : : DrawObjPointerVector &rPVec)
2527 : : {
2528 : 3 : const SwFrmFmt &rFmt = rObj.maCntnt.GetFrmFmt();
2529 : :
2530 : : // check for textflyframe and if it is the first in a Chain
2531 : 3 : sal_Int32 nBorderThick = 0;
2532 : 3 : const SwNodeIndex* pNdIdx = rFmt.GetCntnt().GetCntntIdx();
2533 [ + - ]: 3 : if( pNdIdx )
2534 : : {
2535 [ + - ]: 3 : SwNodeIndex aIdx( *pNdIdx, 1 );
2536 [ + - - ]: 3 : switch( aIdx.GetNode().GetNodeType() )
2537 : : {
2538 : : case ND_GRFNODE:
2539 [ + - ][ + - ]: 3 : nBorderThick = WriteGrfFlyFrame( rFmt, rShapeId = GenerateShapeId() );
2540 : 3 : break;
2541 : : case ND_OLENODE:
2542 [ # # ][ # # ]: 0 : nBorderThick = WriteOLEFlyFrame( rFmt, rShapeId = GenerateShapeId() );
2543 : 0 : break;
2544 : : default:
2545 [ # # ][ # # ]: 0 : if (const SdrObject* pObj = rFmt.FindRealSdrObject())
2546 : : {
2547 : : // check for the first in a Chain
2548 : : sal_uInt32 nTxtId;
2549 : 0 : sal_uInt16 nOff = 0;
2550 : 0 : const SwFrmFmt* pFmt = &rFmt, *pPrev;
2551 [ # # ][ # # ]: 0 : while( 0 != ( pPrev = pFmt->GetChain().GetPrev() ))
2552 : : {
2553 : 0 : ++nOff;
2554 : 0 : pFmt = pPrev;
2555 : : }
2556 : :
2557 [ # # ]: 0 : rShapeId = GetFlyShapeId(rFmt, rObj.mnHdFtIndex, rPVec);
2558 [ # # ]: 0 : if( !nOff )
2559 : : {
2560 [ # # ]: 0 : nTxtId = pTxtBxs->GetPos( pObj );
2561 [ # # ]: 0 : if( USHRT_MAX == nTxtId )
2562 : : {
2563 [ # # ]: 0 : pTxtBxs->Append( *pObj, rShapeId );
2564 : 0 : nTxtId = pTxtBxs->Count();
2565 : : }
2566 : : else
2567 : 0 : ++nTxtId;
2568 : : }
2569 : : else
2570 : : {
2571 [ # # ]: 0 : const SdrObject* pPrevObj = pFmt->FindRealSdrObject();
2572 [ # # ]: 0 : nTxtId = pTxtBxs->GetPos( pPrevObj );
2573 [ # # ]: 0 : if( USHRT_MAX == nTxtId )
2574 : : {
2575 : : sal_uInt32 nPrevShapeId =
2576 [ # # ]: 0 : GetFlyShapeId(*pFmt, rObj.mnHdFtIndex, rPVec);
2577 [ # # ]: 0 : pTxtBxs->Append( *pPrevObj, nPrevShapeId );
2578 : 0 : nTxtId = pTxtBxs->Count();
2579 : : }
2580 : : else
2581 : 0 : ++nTxtId;
2582 : : }
2583 : 0 : nTxtId *= 0x10000;
2584 : 0 : nTxtId += nOff;
2585 : :
2586 [ # # ]: 0 : nBorderThick = WriteTxtFlyFrame(rObj, rShapeId, nTxtId, rPVec);
2587 : : }
2588 [ + - ]: 3 : }
2589 : : }
2590 : 3 : return nBorderThick;
2591 : : }
2592 : :
2593 : 0 : sal_uInt16 FindPos(const SwFrmFmt &rFmt, unsigned int nHdFtIndex,
2594 : : DrawObjPointerVector &rPVec)
2595 : : {
2596 : 0 : DrawObjPointerIter aEnd = rPVec.end();
2597 [ # # ][ # # ]: 0 : for (DrawObjPointerIter aIter = rPVec.begin(); aIter != aEnd; ++aIter)
2598 : : {
2599 : 0 : const DrawObj *pObj = (*aIter);
2600 : : OSL_ENSURE(pObj, "Impossible");
2601 [ # # ]: 0 : if (!pObj)
2602 : 0 : continue;
2603 [ # # # # ]: 0 : if (
[ # # ]
2604 : : nHdFtIndex == pObj->mnHdFtIndex &&
2605 : 0 : &rFmt == (&pObj->maCntnt.GetFrmFmt())
2606 : : )
2607 : : {
2608 [ # # ]: 0 : return static_cast< sal_uInt16 >(aIter - rPVec.begin());
2609 : : }
2610 : : }
2611 : 0 : return USHRT_MAX;
2612 : : }
2613 : :
2614 : 0 : sal_Int32 SwEscherEx::WriteTxtFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId,
2615 : : sal_uInt32 nTxtBox, DrawObjPointerVector &rPVec)
2616 : : {
2617 : 0 : const SwFrmFmt &rFmt = rObj.maCntnt.GetFrmFmt();
2618 : 0 : short nDirection = rObj.mnDirection;
2619 : :
2620 : 0 : sal_Int32 nBorderThick=0;
2621 [ # # ]: 0 : OpenContainer( ESCHER_SpContainer );
2622 : :
2623 [ # # ]: 0 : AddShape( ESCHER_ShpInst_TextBox, 0xa00, nShapeId );
2624 [ # # ]: 0 : EscherPropertyContainer aPropOpt;
2625 [ # # ]: 0 : aPropOpt.AddOpt(ESCHER_Prop_lTxid, nTxtBox);
2626 [ # # ][ # # ]: 0 : if (const SwFrmFmt *pNext = rFmt.GetChain().GetNext())
2627 : : {
2628 [ # # ]: 0 : sal_uInt16 nPos = FindPos(*pNext, rObj.mnHdFtIndex, rPVec);
2629 [ # # ][ # # ]: 0 : if (USHRT_MAX != nPos && aFollowShpIds[nPos])
[ # # ][ # # ]
2630 [ # # ][ # # ]: 0 : aPropOpt.AddOpt(ESCHER_Prop_hspNext, aFollowShpIds[nPos]);
2631 : : }
2632 [ # # ]: 0 : nBorderThick = WriteFlyFrameAttr( rFmt, mso_sptTextBox, aPropOpt );
2633 : :
2634 : : MSO_TextFlow nFlow;
2635 : :
2636 [ # # # ]: 0 : switch (nDirection)
2637 : : {
2638 : : default:
2639 : : OSL_ENSURE(!this, "unknown direction type");
2640 : : case FRMDIR_HORI_LEFT_TOP:
2641 : 0 : nFlow=mso_txflHorzN;
2642 : 0 : break;
2643 : : case FRMDIR_HORI_RIGHT_TOP:
2644 : 0 : nFlow=mso_txflHorzN;
2645 : 0 : break;
2646 : : case FRMDIR_VERT_TOP_LEFT: //not really possible in word
2647 : : case FRMDIR_VERT_TOP_RIGHT:
2648 : 0 : nFlow=mso_txflTtoBA;
2649 : 0 : break;
2650 : : }
2651 [ # # ]: 0 : aPropOpt.AddOpt( ESCHER_Prop_txflTextFlow, nFlow );
2652 : :
2653 [ # # ]: 0 : aPropOpt.Commit( GetStream() );
2654 : :
2655 : : // store anchor attribute
2656 [ # # ]: 0 : WriteFrmExtraData( rFmt );
2657 : :
2658 [ # # ][ # # ]: 0 : AddAtom( 4, ESCHER_ClientTextbox ); GetStream() << nTxtBox;
2659 : :
2660 [ # # ]: 0 : CloseContainer(); // ESCHER_SpContainer
2661 [ # # ]: 0 : return nBorderThick;
2662 : : }
2663 : :
2664 : 3 : void SwBasicEscherEx::WriteOLEPicture(EscherPropertyContainer &rPropOpt,
2665 : : sal_uInt32 nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj,
2666 : : sal_uInt32 nShapeId, const awt::Rectangle* pVisArea )
2667 : : {
2668 : : //nShapeFlags == 0xA00 + flips and ole active
2669 [ + - ]: 3 : AddShape(ESCHER_ShpInst_PictureFrame, nShapeFlags, nShapeId);
2670 : :
2671 [ + - ]: 3 : GraphicObject aGraphicObject(rGraphic);
2672 [ + - ]: 3 : rtl::OString aId = aGraphicObject.GetUniqueID();
2673 [ + - ]: 3 : if (!aId.isEmpty())
2674 : : {
2675 [ + - ]: 3 : Rectangle aRect = rObj.GetLogicRect();
2676 : 3 : aRect.SetPos(Point(0,0));
2677 [ + - ]: 3 : aRect.Right() = DrawModelToEmu(aRect.Right());
2678 [ + - ]: 3 : aRect.Bottom() = DrawModelToEmu(aRect.Bottom());
2679 [ + - ]: 3 : sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(),
2680 [ + - ]: 3 : aId, aRect, pVisArea, 0); // SJ: the fourth parameter (VisArea) should be set..
2681 [ + - ]: 3 : if (nBlibId)
2682 [ + - ]: 3 : rPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, sal_True);
2683 : : }
2684 : :
2685 [ + - ]: 3 : SetPicId(rObj, nShapeId, rPropOpt);
2686 [ + - ][ + - ]: 3 : rPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0x10000 );
2687 : 3 : }
2688 : :
2689 : 3 : void SwEscherEx::WriteOCXControl( const SwFrmFmt& rFmt, sal_uInt32 nShapeId )
2690 : : {
2691 [ + - ]: 3 : if (const SdrObject* pSdrObj = rFmt.FindRealSdrObject())
2692 : : {
2693 [ + - ]: 3 : OpenContainer( ESCHER_SpContainer );
2694 : :
2695 [ + - ]: 3 : SdrModel *pModel = rWrt.pDoc->GetDrawModel();
2696 [ + - ]: 3 : OutputDevice *pDevice = Application::GetDefaultDevice();
2697 : : OSL_ENSURE(pModel && pDevice, "no model or device");
2698 : :
2699 : : // #i71538# use complete SdrViews
2700 : : // SdrExchangeView aExchange(pModel, pDevice);
2701 [ + - ]: 3 : SdrView aExchange(pModel, pDevice);
2702 : :
2703 [ + - ]: 3 : Graphic aGraphic(aExchange.GetObjGraphic(pModel, pSdrObj));
2704 : :
2705 [ + - ]: 3 : EscherPropertyContainer aPropOpt;
2706 : : WriteOLEPicture(aPropOpt, 0xa00 | SHAPEFLAG_OLESHAPE, aGraphic,
2707 [ + - ]: 3 : *pSdrObj, nShapeId, NULL );
2708 : :
2709 [ + - ]: 3 : WriteFlyFrameAttr( rFmt, mso_sptPictureFrame , aPropOpt );
2710 [ + - ]: 3 : aPropOpt.Commit( GetStream() );
2711 : :
2712 : : // store anchor attribute
2713 [ + - ]: 3 : WriteFrmExtraData( rFmt );
2714 : :
2715 [ + - ][ + - ]: 3 : CloseContainer(); // ESCHER_SpContainer
[ + - ][ + - ]
2716 : : }
2717 : 3 : }
2718 : :
2719 : 9 : void SwEscherEx::MakeZOrderArrAndFollowIds(
2720 : : std::vector<DrawObj>& rSrcArr, std::vector<DrawObj*>&rDstArr)
2721 : : {
2722 : 9 : ::lcl_makeZOrderArray(rWrt, rSrcArr, rDstArr);
2723 : :
2724 : : //Now set up the follow IDs
2725 : 9 : aFollowShpIds.clear();
2726 : :
2727 [ + + ]: 15 : for (size_t n = 0; n < rDstArr.size(); ++n)
2728 : : {
2729 : 6 : const SwFrmFmt &rFmt = rDstArr[n]->maCntnt.GetFrmFmt();
2730 : 6 : bool bNeedsShapeId = false;
2731 : :
2732 [ + + ]: 6 : if (RES_FLYFRMFMT == rFmt.Which())
2733 : : {
2734 [ + - ]: 3 : const SwFmtChain &rChain = rFmt.GetChain();
2735 [ + - ][ - + ]: 3 : if (rChain.GetPrev() || rChain.GetNext())
[ - + ]
2736 : 0 : bNeedsShapeId = true;
2737 : : }
2738 : :
2739 [ - + ][ # # ]: 6 : sal_uLong nShapeId = bNeedsShapeId ? GenerateShapeId() : 0;
2740 : :
2741 [ + - ]: 6 : aFollowShpIds.push_back(nShapeId);
2742 : : }
2743 : 9 : }
2744 : :
2745 : 0 : sal_uInt32 SwEscherEx::GetFlyShapeId(const SwFrmFmt& rFmt,
2746 : : unsigned int nHdFtIndex, DrawObjPointerVector &rpVec)
2747 : : {
2748 : 0 : sal_uInt16 nPos = FindPos(rFmt, nHdFtIndex, rpVec);
2749 : : sal_uInt32 nShapeId;
2750 [ # # ]: 0 : if (USHRT_MAX != nPos)
2751 : : {
2752 [ # # ]: 0 : if (0 == (nShapeId = aFollowShpIds[nPos]))
2753 : : {
2754 : 0 : nShapeId = GenerateShapeId();
2755 : 0 : aFollowShpIds[ nPos ] = nShapeId;
2756 : : }
2757 : : }
2758 : : else
2759 : 0 : nShapeId = GenerateShapeId();
2760 : 0 : return nShapeId;
2761 : : }
2762 : :
2763 : 0 : sal_uInt32 SwEscherEx::QueryTextID(
2764 : : const uno::Reference< drawing::XShape>& xXShapeRef, sal_uInt32 nShapeId )
2765 : : {
2766 : 0 : sal_uInt32 nId = 0;
2767 [ # # ]: 0 : if (SdrObject* pObj = GetSdrObjectFromXShape(xXShapeRef))
2768 : : {
2769 : 0 : pTxtBxs->Append( *pObj, nShapeId );
2770 : 0 : nId = pTxtBxs->Count();
2771 : 0 : nId *= 0x10000;
2772 : : }
2773 : 0 : return nId;
2774 : : }
2775 : :
2776 : : uno::Reference< uno::XComponentContext >
2777 : 0 : lcl_getUnoCtx()
2778 : : {
2779 [ # # ][ # # ]: 0 : comphelper::ComponentContext aCtx( ::comphelper::getProcessServiceFactory() );
2780 [ # # ][ # # ]: 0 : return aCtx.getUNOContext();
2781 : : }
2782 : :
2783 : :
2784 : 186 : SwMSConvertControls::SwMSConvertControls( SfxObjectShell *pDSh,SwPaM *pP ) : oox
2785 [ + - ][ + - ]: 186 : ::ole::MSConvertOCXControls( pDSh ? pDSh->GetModel() : NULL ), pPaM( pP )
2786 : : {
2787 : 186 : }
2788 : :
2789 : : // in transitioning away old filter for ole/ocx controls, ReadOCXStream has been made pure virtual in
2790 : : // filter/source/msocximex.cxx, so.. we need an implementation here
2791 : 3 : sal_Bool SwMSConvertControls::ReadOCXStream( SotStorageRef& rSrc1,
2792 : : com::sun::star::uno::Reference< com::sun::star::drawing::XShape > *pShapeRef,
2793 : : sal_Bool bFloatingCtrl )
2794 : : {
2795 : 3 : uno::Reference< form::XFormComponent > xFComp;
2796 [ + - ]: 3 : sal_Bool bRes = oox::ole::MSConvertOCXControls::ReadOCXStorage( rSrc1, xFComp );
2797 [ + - ][ + - ]: 3 : if ( bRes && xFComp.is() )
[ + - ]
2798 : : {
2799 : 3 : com::sun::star::awt::Size aSz; // not used in import
2800 [ + - ]: 3 : bRes = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
2801 : : }
2802 : 3 : return bRes;
2803 : : }
2804 : :
2805 : 3 : bool SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrObject *pObj)
2806 : : {
2807 [ - + ]: 3 : if (!rWW8Wrt.bWrtWW8)
2808 : 0 : return false;
2809 : :
2810 [ + - ][ + - ]: 3 : SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObj);
[ + - ][ + - ]
2811 : : uno::Reference< awt::XControlModel > xControlModel =
2812 [ + - ]: 3 : pFormObj->GetUnoControlModel();
2813 : :
2814 : : //Why oh lord do we use so many different units ?
2815 : : //I think I painted myself into a little bit of a
2816 : : //corner by trying to use the uno interface for
2817 : : //controls export
2818 [ + - ]: 3 : Rectangle aRect = pFormObj->GetLogicRect();
2819 : 3 : aRect.SetPos(Point(0,0));
2820 : 3 : awt::Size aSize;
2821 : 3 : aSize.Width = TWIPS_TO_MM(aRect.Right());
2822 : 3 : aSize.Height = TWIPS_TO_MM(aRect.Bottom());
2823 : :
2824 : : //Open the ObjectPool
2825 : 3 : SvStorageRef xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(
2826 : : rtl::OUString(SL::aObjectPool), STREAM_READWRITE |
2827 [ + - ]: 6 : STREAM_SHARE_DENYALL);
[ + - + - ]
2828 : :
2829 : : //Create a destination storage for the microsoft control
2830 : 3 : rtl::OUStringBuffer sStorageName;
2831 [ + - ][ + - ]: 3 : sStorageName.append('_').append(reinterpret_cast<sal_Int64>(pObj));
2832 : : SvStorageRef xOleStg = xObjPool->OpenSotStorage(sStorageName.makeStringAndClear(),
2833 [ + - ][ + - ]: 3 : STREAM_READWRITE|STREAM_SHARE_DENYALL);
[ + - ][ + - ]
2834 : :
2835 [ - + ]: 3 : if (!xOleStg.Is())
2836 : 0 : return false;
2837 : :
2838 : :
2839 : 3 : rtl::OUString sUName;
2840 [ - + ][ + - ]: 3 : if (!WriteOCXStream( mxModel, xOleStg,xControlModel,aSize,sUName))
2841 : 0 : return false;
2842 : :
2843 [ + - ]: 3 : String sName = sUName;
2844 : :
2845 : : sal_uInt8 aSpecOLE[] =
2846 : : {
2847 : : 0x03, 0x6a, 0xFF, 0xFF, 0xFF, 0xFF, // sprmCPicLocation
2848 : : 0x0a, 0x08, 1, // sprmCFOLE2
2849 : : 0x55, 0x08, 1, // sprmCFSpec
2850 : : 0x56, 0x08, 1 // sprmCFObj
2851 : 3 : };
2852 : : //Set the obj id into the sprmCPicLocation
2853 : 3 : sal_uInt8 *pData = aSpecOLE+2;
2854 : 3 : Set_UInt32(pData,(sal_uInt32)(sal_uIntPtr)pObj);
2855 : :
2856 [ + - ]: 3 : String sFld(FieldString(ww::eCONTROL));
2857 [ + - ]: 3 : sFld.APPEND_CONST_ASC("Forms.");
2858 [ + - ]: 3 : sFld += sName;
2859 [ + - ]: 3 : sFld.APPEND_CONST_ASC(".1 \\s ");
2860 : :
2861 : : rWW8Wrt.OutputField(0, ww::eCONTROL, sFld,
2862 [ + - ]: 3 : WRITEFIELD_START|WRITEFIELD_CMD_START|WRITEFIELD_CMD_END);
2863 : :
2864 [ + - ]: 3 : rWW8Wrt.pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(),sizeof(aSpecOLE),
2865 [ + - ]: 3 : aSpecOLE);
2866 [ + - ]: 3 : rWW8Wrt.WriteChar( 0x1 );
2867 [ + - ]: 3 : rWW8Wrt.OutputField(0, ww::eCONTROL, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE);
2868 [ + - ][ + - ]: 3 : return true;
[ + - ][ + - ]
2869 [ + - ][ + - ]: 54 : }
2870 : :
2871 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|