20 #include <config_features.h>
25 #include <com/sun/star/embed/Aspects.hpp>
26 #include <com/sun/star/embed/ElementModes.hpp>
27 #include <com/sun/star/frame/XModel.hpp>
28 #include <com/sun/star/packages/XPackageEncryption.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <rtl/random.h>
37 #include <rtl/ustring.hxx>
38 #include <rtl/ustrbuf.hxx>
59 #include <editeng/editeng.hxx>
90 #include <section.hxx>
97 #include <../../core/inc/DocumentRedlineManager.hxx>
100 #include <viewsh.hxx>
112 #include <editeng/editids.hrc>
118 #include <com/sun/star/beans/PropertyAttribute.hpp>
119 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
120 #include <com/sun/star/document/XViewDataSupplier.hpp>
121 #include <com/sun/star/document/IndexedPropertyValues.hpp>
131 #include <osl/file.hxx>
135 #if OSL_DEBUG_LEVEL > 1
144 #include <unordered_set>
152 #include <com/sun/star/i18n/XBreakIterator.hpp>
153 #include <com/sun/star/i18n/ScriptType.hpp>
155 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
157 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
170 for( sal_uInt16
i = 0;
i < nCount;
i++ )
173 if( pData && pData->
GetInventor() == SdrInventor::ScOrSwDraw
189 OUStringBuffer aTmpStr;
192 aTmpStr.append(
"../");
195 if (!aTmpStr.isEmpty())
196 aTmpStr.append(rPath);
200 if (!aTmpStr.isEmpty())
202 bool bWasAbs =
false;
210 void lclIgnoreUString32(
SvStream& rStrm)
212 sal_uInt32 nChars(0);
223 constexpr sal_uInt32 WW8_HLINK_BODY = 0x00000001;
224 constexpr sal_uInt32 WW8_HLINK_ABS = 0x00000002;
225 constexpr sal_uInt32 WW8_HLINK_DESCR = 0x00000014;
226 constexpr sal_uInt32 WW8_HLINK_MARK = 0x00000008;
227 constexpr sal_uInt32 WW8_HLINK_FRAME = 0x00000080;
228 constexpr sal_uInt32 WW8_HLINK_UNC = 0x00000100;
233 sal_uInt8 const aGuidUrlMoniker[ 16 ] = {
234 0xE0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
236 sal_uInt8 const aGuidFileMoniker[ 16 ] = {
237 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 };
240 sal_uInt32 nFlags(0);
246 std::unique_ptr< OUString > xLongName;
247 std::unique_ptr< OUString > xShortName;
248 std::unique_ptr< OUString > xTextMark;
251 if( ::
get_flag( nFlags, WW8_HLINK_DESCR ) )
252 lclIgnoreUString32( rStrm );
255 if( ::
get_flag( nFlags, WW8_HLINK_FRAME ) )
261 if( ::
get_flag( nFlags, WW8_HLINK_UNC ) )
265 sal_uInt32 nStrLen(0);
275 else if( ::
get_flag( nFlags, WW8_HLINK_BODY ) )
279 if( memcmp(aGuid, aGuidFileMoniker, 16) == 0 )
281 sal_uInt16 nLevel = 0;
285 sal_uInt32 nUnits = 0;
291 xShortName.reset(
new OUString(sStr.getStr(), sStr.getLength(), GetCharSetFromLanguage()));
295 sal_uInt32 nStrLen(0);
310 else if( memcmp(aGuid, aGuidUrlMoniker, 16) == 0 )
316 sal_uInt32 nStrLen(0);
324 if( !::
get_flag( nFlags, WW8_HLINK_ABS ) )
329 SAL_INFO(
"sw.ww8",
"WW8Hyperlink::ReadEmbeddedData - unknown content GUID");
334 if( ::
get_flag( nFlags, WW8_HLINK_MARK ) )
339 if (!xLongName && xShortName)
341 xLongName.reset(
new OUString );
342 *xLongName += *xShortName;
344 else if (!xLongName && xTextMark)
345 xLongName.reset(
new OUString );
351 if (xLongName->isEmpty())
352 *xTextMark = xTextMark->replace(
'!',
'.');
353 *xLongName +=
"#" + *xTextMark;
361 class BasicProjImportHelper
364 uno::Reference< uno::XComponentContext >
mxCtx;
366 explicit BasicProjImportHelper(
SwDocShell& rShell ) : mrDocShell( rShell ),
370 bool import(
const uno::Reference< io::XInputStream >& rxIn );
371 OUString getProjectName()
const;
376 bool BasicProjImportHelper::import(
const uno::Reference< io::XInputStream >& rxIn )
389 catch(
const uno::Exception& )
396 OUString BasicProjImportHelper::getProjectName()
const
398 OUString sProjName(
"Standard" );
399 uno::Reference< beans::XPropertySet > xProps( mrDocShell.GetModel(), uno::UNO_QUERY );
404 uno::Reference< script::vba::XVBACompatibility > xVBA( xProps->getPropertyValue(
"BasicLibraries" ), uno::UNO_QUERY_THROW );
405 sProjName = xVBA->getProjectName();
408 catch(
const uno::Exception& )
417 class Sttb :
public TBBase
423 SBBItem() : cchData(0){}
429 std::vector< SBBItem > dataItems;
431 Sttb(Sttb
const&) =
delete;
432 Sttb& operator=(Sttb
const&) =
delete;
438 OUString getStringAtIndex( sal_uInt32 );
458 const size_t nMaxPossibleRecords = rS.
remainingSize() /
sizeof(sal_uInt16);
459 if (cData > nMaxPossibleRecords)
461 for ( sal_Int32 index = 0;
index < cData; ++
index )
466 dataItems.push_back( aItem );
473 Sttb::getStringAtIndex( sal_uInt32 index )
476 if ( index < dataItems.size() )
477 aRet = dataItems[ index ].data;
483 :
SvxMSDffManager(*rRdr.m_pTableStream, rRdr.GetBaseURL(), rRdr.m_xWwFib->m_fcDggInfo,
484 rRdr.m_pDataStream, nullptr, 0,
COL_WHITE, rRdr.m_pStrm, bSkipImages),
485 rReader(rRdr), pFallbackStream(nullptr)
493 sal_uInt32 nFlags(0);
516 const int _nCalledByGroup )
const
521 if ( _nCalledByGroup > 0 )
527 OUString sStorageName;
529 uno::Reference < embed::XStorage > xDstStg;
534 css::uno::Reference< css::drawing::XShape > xShape;
554 css::embed::Aspects::MSOLE_CONTENT,
564 "if you're recursive, you're broken");
614 pImpRec->nShapeId = rObjData.
nShapeId;
623 pImpRec->pClientAnchorBuffer, pImpRec->nClientAnchorLen );
631 pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );
635 pImpRec->nLayoutInTableCell = 0xFFFFFFFF;
644 if (nBytesLeft > nAvailableBytes)
646 SAL_WARN(
"sw.ww8",
"Document claimed to have shape record of " << nBytesLeft <<
" bytes, but only " << nAvailableBytes <<
" available");
647 nBytesLeft = nAvailableBytes;
649 while( 5 < nBytesLeft )
653 sal_uInt32 nUDData(0);
659 case 0x038F: pImpRec->nXAlign = nUDData;
break;
661 pImpRec->nXRelTo = nUDData;
663 case 0x0391: pImpRec->nYAlign = nUDData;
break;
665 pImpRec->nYRelTo = nUDData;
667 case 0x03BF: pImpRec->nLayoutInTableCell = nUDData;
break;
672 pImpRec->relativeHorizontalWidth = nUDData;
678 pImpRec->isHorizontalRule =
true;
695 bool bIsSimpleDrawingTextBox = (pImpRec->eShapeType ==
mso_sptTextBox);
696 if (!bIsSimpleDrawingTextBox)
701 bIsSimpleDrawingTextBox =
723 bool bVerticalText =
false;
731 nTextRotationAngle = 9000_deg100;
735 nTextRotationAngle = 27000_deg100;
738 bVerticalText =
true;
741 bVerticalText =
true;
742 nTextRotationAngle = 9000_deg100;
750 if (nTextRotationAngle)
752 if (nTextRotationAngle == 9000_deg100)
758 sal_Int32 nOldTextLeft = nTextLeft;
759 sal_Int32 nOldTextRight = nTextRight;
760 sal_Int32 nOldTextTop = nTextTop;
761 sal_Int32 nOldTextBottom = nTextBottom;
763 nTextLeft = nOldTextBottom;
764 nTextRight = nOldTextTop;
765 nTextTop = nOldTextLeft;
766 nTextBottom = nOldTextRight;
768 else if (nTextRotationAngle == 27000_deg100)
774 sal_Int32 nOldTextLeft = nTextLeft;
775 sal_Int32 nOldTextRight = nTextRight;
776 sal_Int32 nOldTextTop = nTextTop;
777 sal_Int32 nOldTextBottom = nTextBottom;
779 nTextLeft = nOldTextTop;
780 nTextRight = nOldTextBottom;
781 nTextTop = nOldTextRight;
782 nTextBottom = nOldTextLeft;
786 if (bIsSimpleDrawingTextBox)
803 if( bIsSimpleDrawingTextBox )
805 std::shared_ptr<SvxMSDffShapeInfo>
const xTmpRec =
806 std::make_shared<SvxMSDffShapeInfo>(0, pImpRec->nShapeId);
808 SvxMSDffShapeInfos_ById::const_iterator
const it =
837 pImpRec->bAutoWidth =
true;
851 pImpRec->nDxTextLeft = nTextLeft;
852 pImpRec->nDyTextTop = nTextTop;
853 pImpRec->nDxTextRight = nTextRight;
854 pImpRec->nDyTextBottom = nTextBottom;
857 sal_uInt32 eTextAnchor =
867 switch( eTextAnchor )
923 if ( bIsSimpleDrawingTextBox )
925 if ( nTextRotationAngle )
931 aPivot.AdjustX(nMinWH );
932 aPivot.AdjustY(nMinWH );
933 pObj->
NbcRotate(aPivot, nTextRotationAngle);
937 if ( ( ( rObjData.
nSpFlags & ShapeFlag::FlipV ) ||
mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) )
942 double fExtraTextRotation = 0.0;
947 if ( rObjData.
nSpFlags & ShapeFlag::FlipV )
949 fExtraTextRotation += 18000.0;
951 fExtraTextRotation += nTextRotationAngle.
get();
954 fExtraTextRotation /= 100.0;
956 css::beans::PropertyValue aPropVal;
957 aPropVal.Name =
"TextRotateAngle";
958 aPropVal.Value <<= fExtraTextRotation;
959 aGeometryItem.SetPropertyValue( aPropVal );
986 if( SfxItemState::DEFAULT == eState )
993 pImpRec->bDrawHell =
true;
995 pImpRec->bDrawHell =
false;
997 pImpRec->bHidden =
true;
1002 pImpRec->aTextId.nTxBxS =
static_cast<sal_uInt16
>( nTextId >> 16 );
1003 pImpRec->aTextId.nSequence =
static_cast<sal_uInt16
>(nTextId);
1018 pImpRec->pWrapPolygon.reset();
1020 sal_uInt16 nNumElemVert(0), nNumElemMemVert(0), nElemSizeVert(0);
1023 if (nNumElemVert && ((nElemSizeVert == 8) || (nElemSizeVert == 4)))
1032 for (sal_uInt16
i = 0;
i < nNumElemVert; ++
i)
1034 sal_Int32 nX(0), nY(0);
1035 if (nElemSizeVert == 8)
1039 sal_Int16 nSmallX(0), nSmallY(0);
1044 (*(pImpRec->pWrapPolygon))[
i].setX( nX );
1045 (*(pImpRec->pWrapPolygon))[
i].setY( nY );
1064 nLineFlags &= ~0x08;
1067 pImpRec->eLineStyle = (nLineFlags & 8)
1075 pImpRec->nFlags = rObjData.
nSpFlags;
1077 if( pImpRec->nShapeId )
1079 auto nShapeId = pImpRec->nShapeId;
1080 auto nShapeOrder = (
static_cast<sal_uLong>(pImpRec->aTextId.nTxBxS) << 16)
1081 + pImpRec->aTextId.nSequence;
1083 pImpRec->pObj = pObj;
1084 rImportData.
insert(std::move(pImpRec));
1090 ( (rObjData.
nSpFlags & ShapeFlag::Group)
1109 std::vector< sal_uInt8 >
aBuffer( nBufferSize );
1110 if (rSt.
ReadBytes(aBuffer.data(), nBufferSize) == nBufferSize)
1112 aMemStream.
WriteBytes(aBuffer.data(), nBufferSize);
1115 bool bRet = 4 <= nStreamSize;
1116 sal_uInt16 nRawRecId,nRawRecSize;
1136 if (!aNameStr.isEmpty())
1155 sal_uInt16 nColl = 0;
1159 nColl = SVBT16ToUInt16(pData);
1181 "fields into the control stack");
1183 "input fields into the control stack");
1185 "annotations into the control stack");
1187 "redlines into the control stack");
1200 size_t nCnt =
size();
1201 for (
size_t i=0;
i < nCnt; ++
i)
1204 if (nAttrId == rEntry.
pAttr->Which())
1219 "<GetListFirstLineIndent> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
1223 if (eAdj == SvxAdjust::Right)
1225 else if (eAdj == SvxAdjust::Center)
1229 return nReverseListIndented;
1236 "<lcl_GetTrueMargin> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
1240 rFirstLinePos = nBodyIndent + nFirstLineDiff;
1242 const auto nPseudoListBodyIndent = rFormat.
GetAbsLSpace();
1244 tools::Long nExtraListIndent = nPseudoListBodyIndent + nReverseListIndented;
1246 return std::max<tools::Long>(nExtraListIndent, 0);
1253 const bool bFirstLineOfstSet,
1254 const bool bLeftIndentSet )
1260 rLR.
SetTextLeft(nWantedFirstLinePos - nExtraListIndent);
1265 if ( !bFirstLineOfstSet && bLeftIndentSet &&
1270 else if ( bFirstLineOfstSet && !bLeftIndentSet &&
1275 else if (!bFirstLineOfstSet && !bLeftIndentSet )
1298 OUString
sName(static_cast<const SfxStringItem*>(pItem)->
GetValue());
1337 switch( rEntry.
pAttr->Which() )
1343 bool bInsertBookmarkIntoDoc =
true;
1346 if ( pFltBookmark !=
nullptr && pFltBookmark->
IsTOCBookmark() )
1348 const OUString& rName = pFltBookmark->
GetName();
1352 bInsertBookmarkIntoDoc =
false;
1355 if ( bInsertBookmarkIntoDoc )
1371 switch (rEntry.
pAttr->Which())
1382 SwPaM aRegion(rTmpPos);
1388 for(; nStart <= nEnd; ++nStart)
1409 const bool bFirstLineIndentSet =
1413 const bool bLeftIndentSet =
1417 bFirstLineIndentSet,
1421 if (aNewLR == aOldLR)
1432 OSL_ENSURE(
false,
"What is a field doing in the control stack,"
1433 "probably should have been in the endstack");
1437 OSL_ENSURE(
false,
"What is an annotation doing in the control stack,"
1438 "probably should have been in the endstack");
1442 OSL_ENSURE(
false,
"What is an input field doing in the control stack,"
1443 "probably should have been in the endstack");
1448 SwPaM aRegion(rTmpPos);
1456 if (
nullptr != pFrame)
1459 rEntry.
pAttr.get());
1517 pItem = &pNd->
GetAttr(nWhich);
1528 size_t nSize =
size();
1532 if (rEntry.
pAttr->Which() == nWhich)
1534 if ( (rEntry.
bOpen) ||
1547 return rEntry.
pAttr.get();
1559 sal_uInt16 nSubType;
1562 && !
static_cast<const SwGetRefField*
>(pField)->GetSetRefName().isEmpty())
1566 pMarkAccess->
findMark( static_cast<const SwGetRefField*>(pField)->GetSetRefName() );
1580 switch (rEntry.
pAttr->Which())
1613 sal_uInt16 nRefNo =
static_cast<SwTextFootnote*
>(pFootnote)->GetSeqRefNo();
1633 OSL_ENSURE(
false,
"EndStck used with non field, not what we want");
1657 sal_uInt8 nDel = (nLen > 0) ? pData[0] : 0;
1660 sal_uInt8 nIns = (nLen > nDel*2+1) ? pData[nDel*2+1] : 0;
1661 const sal_uInt8* pIns = pData + 2*nDel + 2;
1663 short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
1664 if (nRequiredLength > nLen)
1672 WW8_TBD const * pTyp =
reinterpret_cast<WW8_TBD const *
>(pData + 2*nDel + 2*nIns + 2);
1674 std::shared_ptr<SvxTabStopItem> aAttr(std::make_shared<SvxTabStopItem>(0, 0, SvxTabAdjust::Default,
RES_PARATR_TABSTOP));
1677 sal_uInt16 nTabBase;
1681 if (nTabBase <
m_vColl.size())
1682 pSty =
m_vColl[nTabBase].m_pFormat;
1692 bool bFound =
false;
1693 std::unordered_set<size_t> aLoopWatch;
1694 while (pSty && !bFound)
1698 &pTabs) == SfxItemState::SET;
1701 aAttr.reset(static_cast<SvxTabStopItem*>(pTabs->
Clone()));
1705 sal_uInt16 nOldTabBase = nTabBase;
1707 if (nTabBase <
m_vColl.size())
1708 nTabBase =
m_vColl[nTabBase].m_nBase;
1712 nOldTabBase != nTabBase &&
1718 aLoopWatch.insert(reinterpret_cast<size_t>(pSty));
1719 if (nTabBase <
m_vColl.size())
1720 pSty =
m_vColl[nTabBase].m_pFormat;
1723 if (aLoopWatch.find(reinterpret_cast<size_t>(pSty)) !=
1733 for (
short i=0;
i < nDel; ++
i)
1735 sal_uInt16
nPos = aAttr->GetPos(SVBT16ToUInt16(pDel +
i*2));
1737 aAttr->Remove( nPos );
1740 for (
short i=0;
i < nIns; ++
i)
1742 short nPos = SVBT16ToUInt16(pIns +
i*2);
1744 switch( pTyp[
i].aBits1 & 0x7 )
1762 switch( pTyp[
i].aBits1 >> 3 & 0x7 )
1779 sal_uInt16 nPos2 = aAttr->GetPos( nPos );
1781 aAttr->Remove(nPos2);
1782 aAttr->Insert(aTabStop);
1812 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1814 uno::Reference<document::XDocumentProperties> xDocuProps(
1815 xDPS->getDocumentProperties());
1816 OSL_ENSURE(xDocuProps.is(),
"DocumentProperties is null");
1817 if (xDocuProps.is())
1822 xDocuProps->setPrintDate(uDT);
1853 if( nDefTabSiz < 56 )
1858 const_cast<SvxTabStop&
>(aNewTab[0]).GetAdjustment() = SvxTabAdjust::Default;
1866 sal_Int16 nZoomType;
1868 case 1: nZoomType = sal_Int16(SvxZoomType::WHOLEPAGE);
break;
1869 case 2: nZoomType = sal_Int16(SvxZoomType::PAGEWIDTH);
break;
1870 case 3: nZoomType = sal_Int16(SvxZoomType::OPTIMAL);
break;
1871 default: nZoomType = sal_Int16(SvxZoomType::PERCENT);
break;
1875 {
"VisibleBottom",
uno::Any(sal_Int32(0)) },
1876 {
"ZoomType",
uno::Any(nZoomType) }
1880 uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(xComponentContext);
1881 xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps));
1882 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(
m_pDocShell->
GetModel(), uno::UNO_QUERY);
1883 xViewDataSupplier->setViewData(xBox);
1936 uno::Reference<beans::XPropertySetInfo> xInfo = xDocProps->getPropertySetInfo();
1939 if (xInfo->hasPropertyByName(
"ApplyFormDesignMode"))
1940 xDocProps->setPropertyValue(
"ApplyFormDesignMode", css::uno::makeAny(
false));
1950 else if ( xDocProps.is() )
1953 aGrabBag[
"FormPasswordHash"] <<=
m_xWDop->lKeyProtDoc;
1954 xDocProps->setPropertyValue(
"InteropGrabBag",
uno::Any(aGrabBag.getAsConstPropertyValueList()));
1968 i18n::ForbiddenCharacters aForbidden(OUString(+rTypo.
m_rgxchFPunct),
2007 maTmpPos(*pRdr->m_pPaM->GetPoint()),
2008 mxOldStck(
std::move(pRdr->m_xCtrlStck)),
2009 mxOldAnchorStck(
std::move(pRdr->m_xAnchorStck)),
2010 mxOldRedlines(
std::move(pRdr->m_xRedlineStack)),
2011 mxOldPlcxMan(pRdr->m_xPlcxMan),
2012 mpWFlyPara(
std::move(pRdr->m_xWFlyPara)),
2013 mpSFlyPara(
std::move(pRdr->m_xSFlyPara)),
2014 mpPreviousNumPaM(pRdr->m_pPreviousNumPaM),
2015 mpPrevNumRule(pRdr->m_pPrevNumRule),
2016 mxTableDesc(
std::move(pRdr->m_xTableDesc)),
2017 mnInTable(pRdr->m_nInTable),
2018 mnCurrentColl(pRdr->m_nCurrentColl),
2019 mcSymbol(pRdr->m_cSymbol),
2020 mbIgnoreText(pRdr->m_bIgnoreText),
2021 mbSymbol(pRdr->m_bSymbol),
2022 mbHdFtFootnoteEdn(pRdr->m_bHdFtFootnoteEdn),
2023 mbTxbxFlySection(pRdr->m_bTxbxFlySection),
2024 mbAnl(pRdr->m_bAnl),
2025 mbInHyperlink(pRdr->m_bInHyperlink),
2026 mbPgSecBreak(pRdr->m_bPgSecBreak),
2027 mbWasParaEnd(pRdr->m_bWasParaEnd),
2028 mbHasBorder(pRdr->m_bHasBorder),
2029 mbFirstPara(pRdr->m_bFirstPara)
2109 if (nStartCp < 0 || nLen < 0)
2148 sAuthor = OUString(pDescri->
xstUsrInitl + 1, nLen, RTL_TEXTENCODING_MS_1252);
2155 const sal_uInt16 nLen = std::min<sal_uInt16>(SVBT16ToUInt16(pDescri->
xstUsrInitl[0]),
2157 OUStringBuffer
aBuf;
2158 aBuf.setLength(nLen);
2159 for(sal_uInt16 nIdx = 1; nIdx <= nLen; ++nIdx)
2160 aBuf[nIdx-1] = SVBT16ToUInt16(pDescri->
xstUsrInitl[nIdx]);
2161 sInitials = aBuf.makeStringAndClear();
2167 sAuthor = sInitials;
2170 sal_uInt32 nDateTime = 0;
2175 if (
m_xWwFib->m_lcbAtrdExtra/18 > nIndex)
2176 nDateTime = SVBT32ToUInt32(*reinterpret_cast<SVBT32*>(pExtended+(nIndex*18)));
2188 sText, sInitials, OUString(), aDate );
2205 OSL_ENSURE(pSttIdx,
"impossible");
2222 aAnch.
SetType( RndStdIds::FLY_AT_PARA );
2235 OSL_ENSURE( pFrameObj,
2236 "<SwWW8ImplReader::Read_HdFtTextAsHackedFrame(..)> - missing SdrObject instance" );
2266 return (nHeaderCP < m_xWwFib->m_ccpHdr && nHeaderCP >= 0);
2277 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2279 if (nI & nWhichItems)
2283 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
2286 m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2313 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2319 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
2322 m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2334 bool bDisabledFirst = bUseFirst && !rSection.
HasTitlePage();
2375 bool bHackRequired =
false;
2377 bHackRequired =
true;
2379 bHackRequired =
true;
2409 OSL_ENSURE(rSection.
mpPage,
"makes no sense to call with a main page");
2429 if (pText !=
nullptr)
2433 pRule && !
m_xWDop->fDontUseHTMLAutoSpacing &&
2502 if(pULSpaceItem !=
nullptr)
2507 aUL.
SetUpper( static_cast< sal_uInt16 >(nSpace) );
2509 aUL.
SetLower( static_cast< sal_uInt16 >(nSpace) );
2579 bool bResult =
true;
2582 if (
nullptr != aRes.
pSprm)
2594 const int nMagicNumber = 469;
2599 if ((nTableWidth + nMagicNumber) < nTextAreaWidth)
2620 sal_uInt16 nUChar = 0;
2654 bool bTableRowEnd = (
m_xPlcxMan->HasParaSprm(
m_bVer67 ? 25 : 0x2417).pSprm !=
nullptr);
2685 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(24).pSprm);
2688 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x2416).pSprm);
2690 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x244B).pSprm);
2702 WW8_CP nMyStartCp=nStartCp;
2706 nCellLevel = *aLevel.
pSprm;
2733 bStopTab = bStartTab =
true;
2736 if(
m_bAnl && !bTableRowEnd )
2745 || bStopTab || bStartTab )
2805 return bTableRowEnd;
2853 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2863 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2879 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2887 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2923 char const *pIn, std::size_t nInLen,
sal_Unicode *pOut, std::size_t nOutLen)
2925 const sal_uInt32 nFlags =
2926 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2927 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2928 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2929 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2931 const sal_uInt32 nFlags2 =
2932 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
2933 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE |
2934 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2935 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2937 std::size_t nDestChars=0;
2938 std::size_t nConverted=0;
2942 sal_uInt32 nInfo = 0;
2943 sal_Size nThisConverted=0;
2945 nDestChars += rtl_convertTextToUnicode(hConverter,
nullptr,
2946 pIn+nConverted, nInLen-nConverted,
2947 pOut+nDestChars, nOutLen-nDestChars,
2948 nFlags, &nInfo, &nThisConverted);
2950 OSL_ENSURE(nInfo == 0,
"A character conversion failed!");
2952 nConverted += nThisConverted;
2955 nInfo & RTL_TEXTTOUNICODE_INFO_UNDEFINED ||
2956 nInfo & RTL_TEXTTOUNICODE_INFO_MBUNDEFINED
2959 sal_Size nOtherConverted;
2960 rtl_TextToUnicodeConverter hCP1252Converter =
2961 rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252);
2962 nDestChars += rtl_convertTextToUnicode(hCP1252Converter,
nullptr,
2964 pOut+nDestChars, nOutLen-nDestChars,
2965 nFlags2, &nInfo, &nOtherConverted);
2966 rtl_destroyTextToUnicodeConverter(hCP1252Converter);
2969 }
while (nConverted < nInLen);
2976 bool bResult =
false;
2978 switch (static_cast<sal_uInt16>(nLang))
3007 if (nChar >= 0x0030 && nChar <= 0x0039)
3008 return nChar + 0x0630;
3015 OUString makeOUString(rtl_uString *pStr, sal_Int32 nAllocLen)
3018 if (nAllocLen < pStr->length + 256)
3019 return OUString(pStr, SAL_NO_ACQUIRE);
3021 OUString sRet(pStr->buffer, pStr->length);
3022 rtl_uString_release(pStr);
3032 sal_Int32 nRequestedStrLen = nEnd - rPos;
3034 OSL_ENSURE(nRequestedStrLen,
"String is 0");
3035 if (nRequestedStrLen <= 0)
3040 OSL_ENSURE(bValidPos,
"Document claimed to have more text than available");
3044 rPos+=nRequestedStrLen;
3049 OSL_ENSURE(nAvailableStrLen,
"Document claimed to have more text than available");
3050 if (!nAvailableStrLen)
3053 rPos+=nRequestedStrLen;
3057 sal_Int32 nValidStrLen = std::min<std::size_t>(nRequestedStrLen, nAvailableStrLen);
3062 const sal_Int32 nStrLen = std::min(nValidStrLen,
SAL_MAX_INT32-1);
3065 RTL_TEXTENCODING_MS_1252;
3066 if (
m_bVer67 && eSrcCharSet == RTL_TEXTENCODING_MS_932)
3105 SAL_WARN(
"sw.ww8",
"discarding word95 RTL_TEXTENCODING_MS_932 encoding");
3110 RTL_TEXTENCODING_MS_1252;
3113 auto l = [](rtl_uString*
p){rtl_uString_release(
p);};
3114 std::unique_ptr<rtl_uString, decltype(l)> xStr(rtl_uString_alloc(nStrLen), l);
3118 std::unique_ptr<char[]> p8Bits;
3120 rtl_TextToUnicodeConverter hConverter =
nullptr;
3122 hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
3125 p8Bits.reset(
new char[nStrLen] );
3133 if (pItem !=
nullptr)
3137 for (nL2 = 0; nL2 < nStrLen; ++nL2)
3153 if ((32 > nUCode) || (0xa0 == nUCode))
3165 if (nUCode >= 0x3000)
3168 aTest[0] =
static_cast< char >((nUCode & 0xFF00) >> 8);
3169 aTest[1] =
static_cast< char >(nUCode & 0x00FF);
3170 OUString aTemp(aTest, 2, eSrcCJKCharSet);
3171 OSL_ENSURE(aTemp.getLength() == 1,
"so much for that theory");
3172 *pWork++ = aTemp[0];
3176 char cTest =
static_cast< char >(nUCode & 0x00FF);
3182 p8Bits[nL2] = nBCode;
3193 for (sal_Int32 nI = 0; nI < nEndUsed; ++nI, ++pBuffer)
3197 xStr->buffer[nEndUsed] = 0;
3198 xStr->length = nEndUsed;
3207 rtl_destroyTextToUnicodeConverter(hConverter);
3208 return nL2 >= nStrLen;
3211 #define MSASCII SAL_MAX_INT16
3216 sal_Int16 lcl_getScriptType(
3217 const uno::Reference<i18n::XBreakIterator>& rBI,
3218 const OUString &rString, sal_Int32
nPos)
3220 sal_Int16 nScript = rBI->getScriptType(rString, nPos);
3221 if (nScript == i18n::ScriptType::WEAK && rString[nPos] >= 0x0020 && rString[nPos] <= 0x007F)
3228 sal_Int32 lcl_endOfScript(
3229 const uno::Reference<i18n::XBreakIterator>& rBI,
3230 const OUString &rString, sal_Int32 nPos, sal_Int16 nScript)
3232 while (nPos < rString.getLength())
3234 sal_Int16 nNewScript = lcl_getScriptType(rBI, rString, nPos);
3235 if (nScript != nNewScript)
3242 sal_Int32 lcl_getWriterScriptType(
3243 const uno::Reference<i18n::XBreakIterator>& rBI,
3244 const OUString &rString, sal_Int32 nPos)
3246 sal_Int16 nScript = i18n::ScriptType::WEAK;
3248 if (rString.isEmpty())
3253 nScript = rBI->getScriptType(rString, nPos);
3254 if (nScript != i18n::ScriptType::WEAK)
3302 if (rAddString.isEmpty())
3308 sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
3309 sal_Int32 nLen = rAddString.getLength();
3311 OUString sParagraphText;
3315 sParagraphText = pNd->
GetText();
3316 sal_Int32 nParaOffset = sParagraphText.getLength();
3317 sParagraphText = sParagraphText + rAddString;
3322 sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString, nPos, nScript);
3326 OUString sChunk(rAddString.copy(nPos, nEnd-nPos));
3328 const SvxFontItem *pOverriddenItems[] = {
nullptr,
nullptr,
nullptr};
3329 bool aForced[] = {
false,
false,
false};
3331 int nLclIdctHint = 0xFF;
3332 if (nScript == i18n::ScriptType::WEAK)
3335 nLclIdctHint = pIdctHint->
GetValue();
3340 sal_uInt16 nForceFromFontId = 0;
3341 if (nLclIdctHint != 0xFF)
3343 switch (nLclIdctHint)
3359 if (nForceFromFontId != 0)
3364 sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
3365 nPos + nParaOffset);
3367 bool bWriterWillUseSameFontAsWordAutomatically =
false;
3369 if (nWriterScript != i18n::ScriptType::WEAK)
3373 (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId ==
RES_CHRATR_CTL_FONT) ||
3374 (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId ==
RES_CHRATR_FONT)
3377 bWriterWillUseSameFontAsWordAutomatically =
true;
3382 sal_uInt16 nDestId = aIds[nWriterScript-1];
3384 bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
3389 if (!bWriterWillUseSameFontAsWordAutomatically)
3396 aForced[i] = aIds[i] != nForceFromFontId && *pSourceFont != *pDestFont;
3399 pOverriddenItems[i] =
3403 aForceFont.SetWhich(aIds[i]);
3417 if (pOverriddenItems[i])
3424 nScript = lcl_getScriptType(xBI, rAddString, nPos);
3432 OUStringBuffer buf(rString.getLength());
3433 for (sal_Int32
i = 0;
i < rString.getLength(); ++
i)
3442 SAL_INFO(
"sw.ww8",
"filtering control character");
3445 return buf.makeStringAndClear();
3454 if (addString.isEmpty())
3457 #if OSL_DEBUG_LEVEL > 1
3458 SAL_INFO(
"sw.ww8",
"<addTextToParagraph>" << addString <<
"</addTextToParagraph>");
3464 OSL_ENSURE(pNd,
"What the hell, where's my text node");
3472 if (addString.getLength() <= nCharsLeft)
3498 tools::Long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
3502 WW8_CP nRequested = nEnd - rPos;
3508 SAL_WARN(
"sw.ww8",
"document claims to have more characters, " << nRequested <<
" than remaining, " << nMaxPossible);
3509 nRequested = nMaxPossible;
3515 for (
WW8_CP nCh = 0; nCh < nRequested; ++nCh)
3534 bool bStartLine =
ReadChar(rPos, nCpOfs);
3545 bool bParaEndAdded =
false;
3552 if (pTemp && pTemp->
GetText().isEmpty()
3569 bParaEndAdded =
true;
3580 return bParaEndAdded;
3585 bool bNewParaEnd =
false;
3593 sal_uInt16 nWCharVal(0);
3599 m_pStrm -> ReadUChar( nBCode );
3604 bool bParaMark =
false;
3606 if ( 0xc != nWCharVal )
3628 if (pCntNd!=
nullptr && pCntNd->
Len()>0)
3655 cInsert =
u'\x00a4';
3659 cInsert =
u'\x00b5';
3666 cp_set::iterator aItr =
m_aTOXEndCps.find(static_cast<WW8_CP>(nPosCp));
3668 cInsert =
u'\x00a7';
3706 sal_uInt16 nWordCode(0);
3714 nWordCode = nByteCode;
3716 if( nWordCode == 0x1 )
3733 "WW8: Please report this document, it may have a "
3750 bNewParaEnd = bParaMark =
true;
3763 pTest->
Where() == nPosCp+1+nCpOfs)
3767 sal_uInt32 nData = pTest->
Get(nPos, pData) ? SVBT32ToUInt32(*static_cast<SVBT32*>(pData))
3795 SAL_INFO(
"sw.ww8.level2",
"<unknownValue val=\"" << nWCharVal <<
"\">" );
3799 if(
'\x0' != cInsert )
3801 OUString sInsert(cInsert);
3810 bool* pStartAttr,
bool bCallProcessSpecial)
3828 if (nOldColl >=
m_vColl.size())
3831 bool bTabRowEnd =
false;
3846 m_vColl[m_nCurrentColl].m_n81BiDiFlags);
3877 rbStartLine =
false;
3895 else if( aRes.
nSprmId < 0x800 )
3905 WW8_CP nMaxLegalSkip = nTextEnd - rTextPos;
3907 rTextPos += std::min<WW8_CP>(nSkipChars, nMaxLegalSkip);
3908 nSkipPos = rTextPos-1;
3918 SAL_WARN_IF(!bValidPos,
"sw.ww8",
"Document claimed to have text at an invalid position, skip attributes for region");
3926 bool bDoPlcxManPlusPLus =
true;
3930 if( bDoPlcxManPlusPLus )
3932 nNext = bValidPos ?
m_xPlcxMan->Where() : nTextEnd;
3940 if( (0 <= nNext) && (nSkipPos >= nNext) )
3942 if (nDepthGuard >= 1024)
3944 SAL_WARN(
"sw.ww8",
"ReadTextAttr hit recursion limit");
3948 nNext =
ReadTextAttr(rTextPos, nTextEnd, rbStartLine, nDepthGuard + 1);
3949 bDoPlcxManPlusPLus =
false;
3959 while( nSkipPos >= nNext );
3975 if (nStart == -1 || nEnd == -1 || nEnd < nStart )
3979 [=](
const WW8_CP& rPos) {
3983 return (bSdOD && ((nStart < rPos && nEnd > rPos) || (nStart == nEnd && rPos == nStart))) ||
3984 (!bSdOD && (nStart < rPos && nEnd >= rPos));
3999 if( rTextPos >= rNext )
4005 if (rTextPos == rNext && rTextPos >= nTextEnd)
4008 while( rTextPos >= rNext );
4011 else if ( rbStartLine )
4021 rbStartLine =
false;
4034 std::stack<sal_uInt16> aStack;
4037 while (!aStack.empty())
4039 sal_uInt16 nSprmId = aStack.top();
4040 if ((0 < nSprmId) && ((
eFTN > nSprmId) || (0x0800 <= nSprmId)))
4052 bool bStartLine =
true;
4054 short nDistance = 0;
4078 if (nTextLen > nMaxPossible)
4080 SAL_WARN_IF(nTextLen > nMaxPossible,
"sw.ww8",
"TextLen too long");
4081 nTextLen = nMaxPossible;
4083 WW8_CP nTextEnd = nStartCp+nTextLen;
4084 while (l < nTextEnd)
4086 ReadAttrs( l, nNext, nTextEnd, bStartLine );
4095 bStartLine =
ReadChars(l, nNext, nTextEnd, nCpOfs);
4130 SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
4147 else if(pNewSwCharFormat)
4162 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(46);
4164 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(0x442C);
4167 nDropLines = (*aDCS.
pSprm) >> 3;
4173 nDistance = SVBT16ToUInt16(aDistance.
pSprm);
4182 if (pSwFormatCharFormat)
4185 if (m_xCurrentItemSet && !pFormat)
4193 m_xCurrentItemSet.reset();
4200 if ((nCrCount++ & 0x40) == 0 && nType ==
MAN_MAINTEXT && l <= nTextLen)
4203 m_nProgress =
static_cast<sal_uInt16
>(l * 100 / nTextLen);
4205 m_nProgress =
static_cast<sal_uInt16
>(l / nTextLen * 100);
4257 : m_pDocShell(rD.GetDocShell())
4260 , m_pTableStream(nullptr)
4261 , m_pDataStream(nullptr)
4264 , m_aSectionManager(*this)
4265 , m_aExtraneousParas(rD)
4266 , m_aInsertedTables(rD)
4267 , m_aSectionNameGenerator(rD,
"WW")
4268 , m_aGrfNameGenerator(bNewDoc, OUString(
'G'))
4269 , m_aParaStyleMapper(rD)
4270 , m_aCharStyleMapper(rD)
4271 , m_pFlyFormatOfJustInsertedGraphic(nullptr)
4272 , m_pPreviousNumPaM(nullptr)
4273 , m_pPrevNumRule(nullptr)
4274 , m_aTextNodesHavingFirstLineOfstSet()
4275 , m_aTextNodesHavingLeftIndentSet()
4276 , m_pCurrentColl(nullptr)
4277 , m_pDfltTextFormatColl(nullptr)
4278 , m_pStandardFormatColl(nullptr)
4279 , m_pDrawModel(nullptr)
4280 , m_pDrawPg(nullptr)
4281 , m_pNumFieldType(nullptr)
4282 , m_sBaseURL(rBaseURL)
4286 , m_bRegardHindiDigits( false )
4287 , m_bDrawCpOValid( false )
4293 , m_eTextCharSet(RTL_TEXTENCODING_ASCII_US)
4294 , m_eStructCharSet(RTL_TEXTENCODING_ASCII_US)
4295 , m_eHardCharSet(RTL_TEXTENCODING_DONTKNOW)
4306 , m_nWantedVersion(nVersionPara)
4307 , m_nSwNumLevel(0xff)
4308 , m_nWwNumType(0xff)
4310 , m_bNewDoc(bNewDoc)
4311 , m_bSkipImages(bSkipImages)
4312 , m_bReadNoTable(false)
4313 , m_bPgSecBreak(false)
4316 , m_bTxbxFlySection(false)
4317 , m_bHasBorder(false)
4319 , m_bIgnoreText(false)
4321 , m_bWasTabRowEnd(false)
4322 , m_bWasTabCellEnd(false)
4324 , m_bHdFtFootnoteEdn(false)
4325 , m_bFootnoteEdn(false)
4326 , m_bIsHeader(false)
4327 , m_bIsFooter(false)
4328 , m_bIsUnicode(false)
4329 , m_bCpxStyle(false)
4330 , m_bStyNormal(false)
4331 , m_bWWBugNormal(false)
4332 , m_bNoAttrImport(false)
4333 , m_bInHyperlink(false)
4334 , m_bWasParaEnd(false)
4339 , m_bEmbeddObj(false)
4340 , m_bCurrentAND_fNumberAcross(false)
4341 , m_bNoLnNumYet(true)
4342 , m_bFirstPara(true)
4343 , m_bFirstParaOfPage(false)
4344 , m_bParaAutoBefore(false)
4345 , m_bParaAutoAfter(false)
4349 , m_bReadTable(false)
4350 , m_bLoadingTOXCache(false)
4351 , m_nEmbeddedTOXLevel(0)
4352 , m_bLoadingTOXHyperlink(false)
4353 , m_pPreviousNode(nullptr)
4354 , m_bCareFirstParaEndInToc(false)
4355 , m_bCareLastParaEndInToc(false)
4358 , m_bOnLoadingMain(false)
4359 , m_bNotifyMacroEventRead(false)
4380 OSL_ENSURE(
false,
"WW stack already deleted" );
4404 if (aData.
begin()->get()->nFlags & ShapeFlag::Background)
4424 SetPage(rPage, rFormat, rSection, bIgnoreCols);
4446 OSL_ENSURE(rSection.
mpPage,
"Makes no sense to call me with no pages to set");
4468 OSL_ENSURE(pApply,
"impossible");
4477 SwPaM aPage(aPamStart);
4487 mySegIter const &rStart,
bool bIgnoreCols)
4500 OSL_ENSURE(rIter->mpPage,
"no page!");
4506 if (rIter != rStart)
4507 pPrevious = &(*(rIter-1));
4508 SetHdFt(*rIter, std::distance(rStart, rIter), pPrevious);
4516 rIter->mpPage->SetFollow(rIter->mpPage);
4518 if (rIter->PageRestartNo())
4529 for (
mySegIter aIter = aStart; aIter != aEnd; ++aIter)
4534 if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
4536 SwPaM start( aIter->maStart );
4542 mySegIter aPrev = (aIter == aStart) ? aIter : aIter-1;
4546 bool bThisAndPreviousAreCompatible = ((aIter->GetPageWidth() == aPrev->GetPageWidth()) &&
4547 (aIter->GetPageHeight() == aPrev->GetPageHeight()) && (aIter->IsLandScape() == aPrev->IsLandScape()));
4549 bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
4550 bool bInsertPageDesc = !bInsertSection;
4552 if( aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
4553 bInsertPageDesc =
true;
4556 if (bInsertPageDesc)
4567 bool bIgnoreCols = bInsertSection;
4568 bool bThisAndNextAreCompatible = (aNext == aEnd) ||
4569 ((aIter->GetPageWidth() == aNext->GetPageWidth()) &&
4570 (aIter->GetPageHeight() == aNext->GetPageHeight()) &&
4571 (aIter->IsLandScape() == aNext->IsLandScape()));
4573 if ((aNext != aEnd && aNext->IsContinuous() && bThisAndNextAreCompatible) || bProtected)
4576 if ((aIter->NoCols() > 1) || bProtected)
4577 bInsertSection =
true;
4589 if ( aIter->maSep.bkc == 3 || aIter->maSep.bkc == 4 )
4600 *aIter = aTmpSection;
4604 if ( aIter->maSep.bkc == 4 )
4623 aAnchor = aNext->maStart;
4626 aNext->maStart.GetNode().GetContentNode(), 0);
4650 bool bHasOwnHdFt =
false;
4657 if (!bInsertPageDesc)
4662 aIter->maSep.grpfIhdt, std::distance(aStart, aIter)
4670 bool bFailed =
true;
4676 for(; nStart <= nEnd; ++nStart)
4692 aIter->mpPage = pOrig;
4709 if (aNext == aEnd || !aNext->IsContinuous())
4728 for (
auto aI =
m_aTextNodes.rbegin(); aI != aEnd; ++aI)
4754 uno::Reference < io::XStream >
xStream =
4755 xRoot->openStreamElement(
SL::aMSMacroCmds, embed::ElementModes::READWRITE );
4759 std::unique_ptr<sal_uInt8[]> xBuffer(
new sal_uInt8[lcbCmds]);
4761 xOutStream->WriteBytes(xBuffer.get(),
m_xWwFib->m_lcbCmds);
4770 std::vector<OUString> aDocVarStrings;
4771 std::vector<ww::bytes> aDocVarStringIds;
4772 std::vector<OUString> aDocValueStrings;
4775 aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
4778 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4780 uno::Reference<document::XDocumentProperties> xDocProps(
4781 xDPS->getDocumentProperties());
4782 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4783 uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
4784 xDocProps->getUserDefinedProperties();
4785 OSL_ENSURE(xUserDefinedProps.is(),
"UserDefinedProperties is null");
4787 for(
size_t i=0;
i<aDocVarStrings.size();
i++)
4789 const OUString &rName = aDocVarStrings[
i];
4793 xUserDefinedProps->addProperty( rName,
4794 beans::PropertyAttribute::REMOVABLE,
4796 }
catch (
const uno::Exception &) {
4810 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4812 uno::Reference<document::XDocumentProperties> xDocProps(
4813 xDPS->getDocumentProperties());
4814 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4816 if (!xDocProps.is())
4827 if ( !sTemplateURL.isEmpty() )
4828 xDocProps->setTemplateURL( sTemplateURL );
4831 else if (
m_xWwFib->m_lcbSttbfAssoc)
4837 SAL_WARN(
"sw.ww8",
"** Read of SttbAssoc data failed!!!! ");
4839 OUString sPath = aSttb.getStringAtIndex( 0x1 );
4842 if ( !sPath.isEmpty() )
4843 osl::FileBase::getFileURLFromSystemPath( sPath, aURL );
4845 xDocProps->setTemplateURL( aURL );
4847 xDocProps->setTemplateURL( sPath );
4853 static void lcl_createTemplateToProjectEntry(
const uno::Reference< container::XNameContainer >& xPrjNameCache,
const OUString& sTemplatePathOrURL,
const OUString& sVBAProjName )
4855 if ( !xPrjNameCache.is() )
4859 aObj.
SetURL( sTemplatePathOrURL );
4860 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4863 aURL = sTemplatePathOrURL;
4866 osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL, aURL );
4871 OUString templateNameWithExt = aObj.
GetLastName();
4872 sal_Int32
nIndex = templateNameWithExt.lastIndexOf(
'.' );
4875 OUString templateName = templateNameWithExt.copy( 0, nIndex );
4876 xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) );
4879 catch(
const uno::Exception& )
4886 class WW8Customizations
4897 WW8Customizations::WW8Customizations(
SvStream* pTableStream,
WW8Fib const & rFib ) : mpTableStream(pTableStream), mWw8Fib( rFib )
4901 void WW8Customizations::Import(
SwDocShell* pShell )
4903 if ( mWw8Fib.m_lcbCmds == 0 || !
IsEightPlus(mWw8Fib.GetFIBVersion()) )
4909 if (!
checkSeek(*mpTableStream, mWw8Fib.m_fcCmds))
4911 SAL_WARN(
"sw.ww8",
"** Seek to Customization data failed!!!! ");
4914 bool bReadResult = aTCG.
Read( *mpTableStream );
4915 mpTableStream->Seek( nCur );
4918 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! ");
4925 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! epically");
4936 uno::Sequence< OUString > sGlobalTemplates;
4941 if( xSFA->isFolder( aAddinPath ) )
4942 sGlobalTemplates = xSFA->getFolderContents( aAddinPath,
false );
4944 for (
const auto& rGlobalTemplate : std::as_const(sGlobalTemplates) )
4947 aObj.
SetURL( rGlobalTemplate );
4948 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4951 aURL = rGlobalTemplate;
4953 osl::FileBase::getFileURLFromSystemPath( rGlobalTemplate, aURL );
4954 if ( !aURL.endsWithIgnoreAsciiCase(
".dot" ) || ( !sCreatedFrom.empty() && sCreatedFrom == aURL ) )
4959 BasicProjImportHelper aBasicImporter( *
m_pDocShell );
4965 refMainStream->SetEndian(SvStreamEndian::LITTLE);
4966 WW8Fib aWwFib( *refMainStream, 8 );
4970 if (xTableStream.
is() &&
ERRCODE_NONE == xTableStream->GetError())
4972 xTableStream->SetEndian(SvStreamEndian::LITTLE);
4973 WW8Customizations aGblCustomisations( xTableStream.
get(), aWwFib );
4988 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(
xModel, uno::UNO_QUERY_THROW);
4992 uno::Reference<task::XInteractionHandler> xHandler;
4993 xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
4995 catch (
const uno::Exception&)
5002 auto pFibData = std::make_shared<::ww8::WW8FibData>();
5004 if (
m_xWwFib->m_fReadOnlyRecommended)
5005 pFibData->setReadOnlyRecommended(
true);
5007 pFibData->setReadOnlyRecommended(
false);
5010 pFibData->setWriteReservation(
true);
5012 pFibData->setWriteReservation(
false);