20#include <com/sun/star/text/HoriOrientation.hpp>
21#include <com/sun/star/text/VertOrientation.hpp>
32#include <osl/diagnose.h>
58 OUString aStyle, aLang, aDir;
63 bool bHeader=
false, bFooter=
false;
65 for (
size_t i = rHTMLOptions.size();
i; )
70 case HtmlOptionId::ID:
73 case HtmlOptionId::ALIGN:
74 if( HtmlTokenId::DIVISION_ON==
nToken )
77 case HtmlOptionId::STYLE:
80 case HtmlOptionId::CLASS:
83 case HtmlOptionId::LANG:
86 case HtmlOptionId::DIR:
89 case HtmlOptionId::HREF:
92 case HtmlOptionId::TITLE:
94 const OUString& rType = rOption.
GetString();
95 if( rType.equalsIgnoreAsciiCase(
"header") )
97 else if( rType.equalsIgnoreAsciiCase(
"footer") )
105 bool bAppended =
false;
115 bool bStyleParsed =
false, bPositioned =
false;
121 aItemSet, aPropInfo, &aLang, &aDir );
130 bPositioned = HtmlTokenId::DIVISION_ON ==
nToken && !aClass.isEmpty() &&
137 const std::unique_ptr<HTMLAttrContext>& pParent
139 if (!pParent->IsVisible())
145 bPositioned =
DoPositioning(aItemSet, aPropInfo, xCntxt.get());
153 xCntxt->SetHeaderOrFooter(
true);
201 SwPaM aDelPam( aSttIdx );
209 if (
SwSection* pOldContent =
m_xDoc->InsertSwSection(aDelPam, aSection,
nullptr,
nullptr,
false))
210 pOldContent->SetHidden(
true);
213 for(
size_t i=0;
i <
m_xDoc->GetPageDescCnt();
i++ )
217 m_xDoc->ChgPageDesc(
i, *pPageDesc );
226 else if( !bPositioned && aId.getLength() > 9 &&
227 (aId[0] ==
's' || aId[0] ==
'S' ) &&
228 (aId[1] ==
'd' || aId[1] ==
'D' ) )
230 bool bEndNote =
false, bFootNote =
false;
235 if( bFootNote || bEndNote )
243 SwPosition aNewPos( aTmpSwNodeIndex, pCNd, 0 );
246 aPropInfo.
m_aId.clear();
252 if( (!aId.isEmpty() && !bPositioned) || !aHRef.isEmpty() )
269 std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ?
nullptr :
new std::deque<std::unique_ptr<HTMLAttr>>);
270 SetAttr(
true,
true, pPostIts.get() );
273 const OUString
aName(
m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId :
nullptr ) );
275 if( !aHRef.isEmpty() )
279 sal_Int32 nPos2 = -1;
284 std::swap(
nPos, nPos2 );
303 + rtl::Uri::decode( aHRef.copy( nPos2+1 ),
304 rtl_UriDecodeWithCharset,
305 RTL_TEXTENCODING_ISO_8859_1 );
313 if( !aHRef.isEmpty() )
325 aFrameItemSet.Put( *pItem );
330 aFrameItemSet.Put( *pItem );
334 m_xDoc->InsertSwSection( *
m_pPam, aSection,
nullptr, &aFrameItemSet,
false );
361 xCntxt->SetSpansSection(
true );
365 aPropInfo.
m_aId.clear();
372 if( SvxAdjust::End != eAdjust )
379 InsertAttrs( aItemSet, aPropInfo, xCntxt.get(),
true );
389 std::unique_ptr<HTMLAttrContext> xCntxt;
395 case HtmlTokenId::CENTER_ON:
396 case HtmlTokenId::DIVISION_ON:
409 if (xCntxt->IsHeaderOrFooter())
423 OSL_ENSURE( pHdFtFormat,
"No header or footer" );
438 sal_uInt16 nSpace = 0;
466 nPrvNxtIdx = rContentStIdx.
GetIndex() + 1;
469 pTextNode =
m_xDoc->GetNodes()[nPrvNxtIdx]
515 OSL_ENSURE(
false,
"Wrong PaM position at end of section" );
522 bool bSectionClosed =
false;
529 bSectionClosed =
true;
535 return bSectionClosed;
541 OUString aStyle, aClass, aLang, aDir;
543 sal_uInt16 nCols = columnsFromCss, nGutter = 10;
544 bool bPercentWidth =
true;
547 for (
size_t i = rHTMLOptions.size();
i; )
552 case HtmlOptionId::ID:
555 case HtmlOptionId::STYLE:
558 case HtmlOptionId::CLASS:
561 case HtmlOptionId::LANG:
564 case HtmlOptionId::DIR:
567 case HtmlOptionId::COLS:
568 nCols = o3tl::narrowing<sal_uInt16>(rOption.
GetNumber());
570 case HtmlOptionId::WIDTH:
572 bPercentWidth = (rOption.
GetString().indexOf(
'%') != -1);
573 if( bPercentWidth && nWidth>100 )
576 case HtmlOptionId::GUTTER:
577 nGutter = o3tl::narrowing<sal_uInt16>(rOption.
GetNumber());
583 std::unique_ptr<HTMLAttrContext> xCntxt(
new HTMLAttrContext(HtmlTokenId::MULTICOL_ON));
587 bool bInCntnr =
false;
590 bInCntnr =
nullptr !=
m_aContexts[--
i]->GetFrameItemSet();
593 bool bStyleParsed =
false;
598 aItemSet, aPropInfo, &aLang, &aDir );
607 MapMode(MapUnit::MapTwip) ).Width();
610 if( !nPercentWidth && nTwipWidth <
MINFLY )
614 bool bPositioned =
false;
626 SetVarSize( aPropInfo, aFrameItemSet, nTwipWidth, nPercentWidth );
628 SetSpace(
Size(0,0), aItemSet, aPropInfo, aFrameItemSet );
643 aPropInfo.
m_aId.clear();
648 xCntxt->SetPopStack(
true );
652 bool bAppended =
false;
681 std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ?
nullptr :
new std::deque<std::unique_ptr<HTMLAttr>>);
682 SetAttr(
true,
true, pPostIts.get() );
685 OUString
aName(
m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId :
nullptr ) );
695 ->PixelToLogic(
Size(nGutter, 0),
701 aFormatCol.
Init( nCols, nGutter, USHRT_MAX );
702 aFrameItemSet.Put( aFormatCol );
706 aFrameItemSet.Put( *pItem );
711 aFrameItemSet.Put( *pItem );
714 m_xDoc->InsertSwSection( *
m_pPam, aSection,
nullptr, &aFrameItemSet,
false );
741 xCntxt->SetSpansSection(
true );
745 aPropInfo.
m_aId.clear();
750 InsertAttrs( aItemSet, aPropInfo, xCntxt.get(),
true );
757 const OUString& rName )
765 if( !rName.isEmpty() )
783 m_xDoc->GetNodes()[nDestIdx]->GetContentNode();
785 OSL_ENSURE( pDestContentNd,
"Why is the target not a Content-Node?" );
793 if( pFormatPageDesc && pFormatPageDesc->
GetPageDesc() )
795 pDestContentNd->
SetAttr( *pFormatPageDesc );
801 switch( pItem->GetBreak() )
803 case SvxBreak::PageBefore:
804 case SvxBreak::PageAfter:
805 case SvxBreak::PageBoth:
807 pDestContentNd->
SetAttr( *pItem );
823 pDestContentNd->
SetAttr(*pItem);
static OutputDevice * GetDefaultDevice()
bool GetSpansSection() const
void SetSpansSection(bool bSet)
HtmlOptionId GetToken() const
const OUString & GetString() const
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
sal_uInt32 GetNumber() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 m_nColumnCount
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
sal_uInt16 GetUpper() const
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
sal_uInt16 GetLower() const
static bool MayBePositioned(const SvxCSS1PropertyInfo &rPropInfo, bool bAutoWidth=false)
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
virtual bool SetAttr(const SfxPoolItem &)
made virtual
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
SwFormatColl & GetAnyFormatColl() const
Ends a section of nodes in the document model.
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
SwPageDesc * GetPageDesc()
void PushContext(std::unique_ptr< HTMLAttrContext > &rCntxt)
void NewDivision(HtmlTokenId nToken)
bool EndSection(bool bLFStripped=false)
void SetAnchorAndAdjustment(sal_Int16 eVertOri, sal_Int16 eHoriOri, const SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFrameSet)
void InsertAttrs(std::deque< std::unique_ptr< HTMLAttr > > rAttrs)
bool CreateContainer(std::u16string_view rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
HTMLAttrContexts m_aContexts
void InsertAttr(const SfxPoolItem &rItem, bool bInsAtStart)
static void SetSpace(const Size &rPixSpace, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFlyItemSet)
void NewMultiCol(sal_uInt16 columnsFromCss=0)
std::shared_ptr< HTMLAttrTable > m_xAttrTab
void SetAttr(bool bChkEnd=true, bool bBeforeTable=false, std::deque< std::unique_ptr< HTMLAttr > > *pPostIts=nullptr)
void SaveDocContext(HTMLAttrContext *pCntxt, HtmlContextFlags nFlags, const SwPosition *pNewPos)
bool DoPositioning(SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
static bool HasStyleOptions(std::u16string_view rStyle, std::u16string_view rId, std::u16string_view rClass, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
void InsertFlyFrame(const SfxItemSet &rItemSet, HTMLAttrContext *pCntxt, const OUString &rId)
rtl::Reference< SwDoc > m_xDoc
bool ParseStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
bool EndSections(bool bLFStripped)
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
bool m_bReadingHeaderOrFooter
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
void RegisterFlyFrame(SwFrameFormat *pFlyFrame)
void EndContext(HTMLAttrContext *pContext)
void MovePageDescAttrs(SwNode *pSrcNd, SwNodeOffset nDestIdx, bool bFormatBreak)
void FixHeaderFooterDistance(bool bHeader, const SwPosition *pOldPos)
static void SetFrameFormatAttrs(SfxItemSet &rItemSet, HtmlFrameFormatFlags nFlags, SfxItemSet &rFrameItemSet)
SwNodeIndex * GetFootEndNoteSection(const OUString &rName)
static void SetVarSize(SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet, SwTwips nDfltWidth=MINLAY, sal_uInt8 nDefaultPercentWidth=0)
Marks a node in the document model.
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool IsContentNode() const
bool IsSectionNode() const
const SwStartNode * StartOfSectionNode() const
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
SwTableNode * GetTableNode()
PaM is Point and Mark: a selection of the document model.
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * GetPoint() const
SwFrameFormat & GetMaster()
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
void SetLinkFileName(OUString const &rNew)
Starts a section of nodes in the document model.
const SwTable & GetTable() const
SwTableFormat * GetFrameFormat()
SwTextNode is a paragraph in the document model.
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(126)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
#define OOO_STRING_SVTOOLS_HTML_sdendnote
#define OOO_STRING_SVTOOLS_HTML_sdfootnote
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
const sal_Unicode cTokenSeparator
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
::std::vector< HTMLOption > HTMLOptions
@ RES_POOLCOLL_TEXT
Text body.
Marks a position in the document model.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
HTMLOptionEnum< SvxAdjust > const aHTMLPAlignTable[]