LibreOffice Module sw (master) 1
htmlctxt.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/text/HoriOrientation.hpp>
21#include <com/sun/star/text/VertOrientation.hpp>
22
23#include <hintids.hxx>
24#include <svl/itemiter.hxx>
25#include <editeng/lrspitem.hxx>
26#include <editeng/ulspitem.hxx>
27#include <editeng/brushitem.hxx>
28#include <editeng/fhgtitem.hxx>
29#include <svtools/htmltokn.h>
30#include <editeng/boxitem.hxx>
31#include <osl/diagnose.h>
32#include <o3tl/string_view.hxx>
33
34#include <doc.hxx>
35#include <pam.hxx>
36#include <shellio.hxx>
37#include <paratr.hxx>
38#include "htmlnum.hxx"
39#include "swcss1.hxx"
40#include "swhtml.hxx"
41
42#include <memory>
43#include <utility>
44
45using namespace ::com::sun::star;
46
48{
49 SwHTMLNumRuleInfo m_aNumRuleInfo; // Numbering for this environment
50 std::unique_ptr<SwPosition>
51 m_pPos; // Jump back to here when leaving context
52 std::shared_ptr<HTMLAttrTable>
53 m_xAttrTab; // Valid attributes for the environment,
54 // if attributes shouldn't be preserved
55
56 size_t m_nContextStMin; // Stack lower bound for the environment
57 // if stack needs to be protected
58 size_t m_nContextStAttrMin; // Stack lower bound for the environment
59 // if the attributes shouldn't be preserved
64
65public:
66
68 m_nContextStMin( SIZE_MAX ), m_nContextStAttrMin( SIZE_MAX ),
69 m_bStripTrailingPara( false ), m_bKeepNumRules( false ),
70 m_bFixHeaderDist( false ), m_bFixFooterDist( false )
71 {}
72
73 // The position is ours, so we need to create and delete it
74 void SetPos( const SwPosition& rPos ) { m_pPos.reset( new SwPosition(rPos) ); }
75 const SwPosition *GetPos() const { return m_pPos.get(); }
76
77 // The index isn't ours. So no creation or deletion
78 void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { m_aNumRuleInfo.Set(rInf); }
79 const SwHTMLNumRuleInfo& GetNumInfo() const { return m_aNumRuleInfo; }
80
81 std::shared_ptr<HTMLAttrTable> const & GetAttrTab(bool bCreate = false);
82
83 void SetContextStMin( size_t nMin ) { m_nContextStMin = nMin; }
84 size_t GetContextStMin() const { return m_nContextStMin; }
85
86 void SetContextStAttrMin( size_t nMin ) { m_nContextStAttrMin = nMin; }
87 size_t GetContextStAttrMin() const { return m_nContextStAttrMin; }
88
89 void SetStripTrailingPara( bool bSet ) { m_bStripTrailingPara = bSet; }
91
92 void SetKeepNumRules( bool bSet ) { m_bKeepNumRules = bSet; }
93 bool GetKeepNumRules() const { return m_bKeepNumRules; }
94
95 void SetFixHeaderDist( bool bSet ) { m_bFixHeaderDist = bSet; }
96 bool GetFixHeaderDist() const { return m_bFixHeaderDist; }
97
98 void SetFixFooterDist( bool bSet ) { m_bFixFooterDist = bSet; }
99 bool GetFixFooterDist() const { return m_bFixFooterDist; }
100};
101
102std::shared_ptr<HTMLAttrTable> const & HTMLAttrContext_SaveDoc::GetAttrTab( bool bCreate )
103{
104 if (!m_xAttrTab && bCreate)
105 {
106 m_xAttrTab = std::make_shared<HTMLAttrTable>();
107 memset(m_xAttrTab.get(), 0, sizeof(HTMLAttrTable));
108 }
109 return m_xAttrTab;
110}
111
113{
114 if( !m_pSaveDocContext && bCreate )
116
117 return m_pSaveDocContext.get();
118}
119
120HTMLAttrContext::HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, OUString aClass,
121 bool bDfltColl ) :
122 m_aClass(std::move( aClass )),
123 m_nToken( nTokn ),
124 m_nTextFormatColl( nPoolId ),
125 m_nLeftMargin( 0 ),
126 m_nRightMargin( 0 ),
127 m_nFirstLineIndent( 0 ),
128 m_nUpperSpace( 0 ),
129 m_nLowerSpace( 0 ),
130 m_eAppend( AM_NONE ),
131 m_bLRSpaceChanged( false ),
132 m_bULSpaceChanged( false ),
133 m_bDefaultTextFormatColl( bDfltColl ),
134 m_bSpansSection( false ),
135 m_bPopStack( false ),
136 m_bFinishPREListingXMP( false ),
137 m_bRestartPRE( false ),
138 m_bRestartXMP( false ),
139 m_bRestartListing( false ),
140 m_bHeaderOrFooter( false )
141{}
142
144 m_nToken( nTokn ),
145 m_nTextFormatColl( 0 ),
146 m_nLeftMargin( 0 ),
147 m_nRightMargin( 0 ),
148 m_nFirstLineIndent( 0 ),
149 m_nUpperSpace( 0 ),
150 m_nLowerSpace( 0 ),
151 m_eAppend( AM_NONE ),
152 m_bLRSpaceChanged( false ),
153 m_bULSpaceChanged( false ),
154 m_bDefaultTextFormatColl( false ),
155 m_bSpansSection( false ),
156 m_bPopStack( false ),
157 m_bFinishPREListingXMP( false ),
158 m_bRestartPRE( false ),
159 m_bRestartXMP( false ),
160 m_bRestartListing( false ),
161 m_bHeaderOrFooter( false )
162{}
163
165{
166 m_pSaveDocContext.reset();
167}
168
170{
171 m_pSaveDocContext.reset();
172}
173
175{
176 // preliminary paragraph attributes are not allowed here, they could
177 // be set here and then the pointers become invalid!
178 OSL_ENSURE(m_aParaAttrs.empty(),
179 "Danger: there are non-final paragraph attributes");
180 m_aParaAttrs.clear();
181
182 const SwPosition* pOldEndPara = m_pPam->GetPoint();
183#ifndef NDEBUG
184 auto const nOld(pOldEndPara->GetNodeIndex());
185#endif
186 sal_Int32 nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
187
188 const SwPosition& rNewSttPara = rNewPos;
189 sal_Int32 nNewSttCnt = rNewPos.GetContentIndex();
190
191 bool bMoveBack = false;
192
193 // close all open attributes and re-open them after the table
194 HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
195 for (auto nCnt = sizeof(HTMLAttrTable) / sizeof(HTMLAttr*); nCnt--; ++pHTMLAttributes)
196 {
197 HTMLAttr *pAttr = *pHTMLAttributes;
198 while( pAttr )
199 {
200 HTMLAttr *pNext = pAttr->GetNext();
201 HTMLAttr *pPrev = pAttr->GetPrev();
202
203 sal_uInt16 nWhich = pAttr->m_pItem->Which();
204 if( !nOldEndCnt && RES_PARATR_BEGIN <= nWhich &&
205 pAttr->GetStartParagraphIdx() < pOldEndPara->GetNodeIndex() )
206 {
207 // The attribute needs to be closed one content position beforehand
208 if( !bMoveBack )
209 {
210 bMoveBack = m_pPam->Move( fnMoveBackward );
211 nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
212 }
213 }
214 else if( bMoveBack )
215 {
217 nOldEndCnt = m_pPam->GetPoint()->GetContentIndex();
218 bMoveBack = false;
219 }
220
221 if( (RES_PARATR_BEGIN <= nWhich && bMoveBack) ||
222 pAttr->GetStartParagraphIdx() < pOldEndPara->GetNodeIndex() ||
223 (pAttr->GetStartParagraph() == pOldEndPara->GetNode() &&
224 pAttr->GetStartContent() != nOldEndCnt) )
225 {
226 // The attribute needs to be set. Because we still need the original, since
227 // pointers to the attribute still exists in the contexts, we need to clone it.
228 // The next-list gets lost but the previous-list is preserved
229 HTMLAttr *pSetAttr = pAttr->Clone( pOldEndPara->GetNode(), nOldEndCnt );
230
231 if( pNext )
232 pNext->InsertPrev( pSetAttr );
233 else
234 {
235 if (pSetAttr->m_bInsAtStart)
236 m_aSetAttrTab.push_front( pSetAttr );
237 else
238 m_aSetAttrTab.push_back( pSetAttr );
239 }
240 }
241 else if( pPrev )
242 {
243 // The previous attributes still need to be set, even if the current attribute
244 // doesn't need to be set before the table
245 if( pNext )
246 pNext->InsertPrev( pPrev );
247 else
248 {
249 if (pPrev->m_bInsAtStart)
250 m_aSetAttrTab.push_front( pPrev );
251 else
252 m_aSetAttrTab.push_back( pPrev );
253 }
254 }
255
256 // Set the start of the attribute
257 pAttr->m_nStartPara = rNewSttPara.GetNode();
258 pAttr->m_nEndPara = rNewSttPara.GetNode();
259 pAttr->m_nStartContent = nNewSttCnt;
260 pAttr->m_nEndContent = nNewSttCnt;
261 pAttr->m_pPrev = nullptr;
262
263 pAttr = pNext;
264 }
265 }
266
267 if( bMoveBack )
269
270 assert(m_pPam->GetPoint()->GetNodeIndex() == nOld);
271}
272
274 HtmlContextFlags nFlags,
275 const SwPosition *pNewPos )
276{
277 HTMLAttrContext_SaveDoc *pSave = pCntxt->GetSaveDocContext( true );
278 pSave->SetStripTrailingPara( bool(HtmlContextFlags::StripPara & nFlags) );
279 pSave->SetKeepNumRules( bool(HtmlContextFlags::KeepNumrule & nFlags) );
280 pSave->SetFixHeaderDist( bool(HtmlContextFlags::HeaderDist & nFlags) );
281 pSave->SetFixFooterDist( bool(HtmlContextFlags::FooterDist & nFlags) );
282
283 if( pNewPos )
284 {
285 // If the PaM needs to be set to a different position, we need to preserve numbering
286 if( !pSave->GetKeepNumRules() )
287 {
288 // Numbering shall not be preserved. So we need to preserve the current state
289 // and turn off numbering afterwards
290 pSave->SetNumInfo( GetNumInfo() );
291 GetNumInfo().Clear();
292 }
293
294 if( HtmlContextFlags::KeepAttrs & nFlags )
295 {
296 // Close attribute on current position and start on new one
297 SplitAttrTab( *pNewPos );
298 }
299 else
300 {
301 std::shared_ptr<HTMLAttrTable> xSaveAttrTab = pSave->GetAttrTab(true);
302 SaveAttrTab(xSaveAttrTab);
303 }
304
305 pSave->SetPos( *m_pPam->GetPoint() );
306 *m_pPam->GetPoint() = *pNewPos;
307 }
308
309 // Settings nContextStMin automatically means, that no
310 // currently open lists (DL/OL/UL) can be closed
311 if( HtmlContextFlags::ProtectStack & nFlags )
312 {
315
316 if( HtmlContextFlags::KeepAttrs & nFlags )
317 {
320 }
321 }
322}
323
325{
327 if( !pSave )
328 return;
329
330 if( pSave->GetStripTrailingPara() )
332
333 if( pSave->GetPos() )
334 {
335 if( pSave->GetFixHeaderDist() || pSave->GetFixFooterDist() )
337 pSave->GetPos() );
338
339 std::shared_ptr<HTMLAttrTable> xSaveAttrTab = pSave->GetAttrTab();
340 if (!xSaveAttrTab)
341 {
342 // Close attribute on current position and start on the old one
343 SplitAttrTab( *pSave->GetPos() );
344 }
345 else
346 {
347 RestoreAttrTab(xSaveAttrTab);
348 }
349
350 *m_pPam->GetPoint() = *pSave->GetPos();
351
352 // We can already set the attributes so far
353 SetAttr();
354 }
355
356 if( SIZE_MAX != pSave->GetContextStMin() )
357 {
359 if( SIZE_MAX != pSave->GetContextStAttrMin() )
361 }
362
363 if( !pSave->GetKeepNumRules() )
364 {
365 // Set the preserved numbering back
366 GetNumInfo().Set( pSave->GetNumInfo() );
367 }
368
369 pCntxt->ClearSaveDocContext();
370}
371
373{
374 if( pContext->GetPopStack() )
375 {
376 // Close all still open contexts. Our own context needs to be deleted already!
377 while( m_aContexts.size() > m_nContextStMin )
378 {
379 std::unique_ptr<HTMLAttrContext> xCntxt(PopContext());
380 OSL_ENSURE(xCntxt.get() != pContext,
381 "Context still on the stack" );
382 if (xCntxt.get() == pContext)
383 break;
384
385 EndContext(xCntxt.get());
386 }
387 }
388
389 // Close all still open attributes
390 if( pContext->HasAttrs() )
391 EndContextAttrs( pContext );
392
393 // If a section has been opened, end it. Since sections can be part of absolute-positioned
394 // objects, this needs to be done before restoring document context
395 if( pContext->GetSpansSection() )
396 EndSection();
397
398 // Leave borders and other special sections
399 if( pContext->HasSaveDocContext() )
400 RestoreDocContext( pContext );
401
402 // Add a paragraph break if needed
403 if( AM_NONE != pContext->GetAppendMode() &&
405 AppendTextNode( pContext->GetAppendMode() );
406
407 // Restart PRE, LISTING and XMP environments
408 if( pContext->IsFinishPREListingXMP() )
409 FinishPREListingXMP();
410
411 if( pContext->IsRestartPRE() )
412 StartPRE();
413
414 if( pContext->IsRestartXMP() )
415 StartXMP();
416
417 if( pContext->IsRestartListing() )
418 StartListing();
419}
420
422{
423 HTMLAttrs &rAttrs = pContext->GetAttrs();
424 for( auto pAttr : rAttrs )
425 {
426 // Simple deletion doesn't to the job, since the attribute
427 // needs to be deregistered with its list.
428 // In theory, you could delete the list and its attributes separately
429 // but if you get that wrong, quite a lot is messed up
430 DeleteAttr( pAttr );
431 }
432 rAttrs.clear();
433
434 OSL_ENSURE( !pContext->GetSpansSection(),
435 "Area can no longer be exited" );
436
437 OSL_ENSURE( !pContext->HasSaveDocContext(),
438 "Frame can no longer be exited" );
439
440 // like RestoreDocContext reset enough of this to not catastrophically
441 // fail if we still have a SaveDocContext here
442 if (HTMLAttrContext_SaveDoc *pSave = pContext->GetSaveDocContext())
443 {
444 if (SIZE_MAX != pSave->GetContextStMin())
445 {
446 m_nContextStMin = pSave->GetContextStMin();
447 if (SIZE_MAX != pSave->GetContextStAttrMin())
448 m_nContextStAttrMin = pSave->GetContextStAttrMin();
449 }
450
451 pContext->ClearSaveDocContext();
452 }
453
454 // Restart PRE/LISTING/XMP environments
455 if( pContext->IsFinishPREListingXMP() )
456 FinishPREListingXMP();
457
458 if( pContext->IsRestartPRE() )
459 StartPRE();
460
461 if( pContext->IsRestartXMP() )
462 StartXMP();
463
464 if( pContext->IsRestartListing() )
465 StartListing();
466}
467
469 SvxCSS1PropertyInfo &rPropInfo,
470 HTMLAttrContext *pContext )
471{
472 bool bRet = false;
473
474 // A border is opened on the following conditions
475 // - the tag is absolute-positioned AND left/top are both known AND don't contain a % property
476 // OR
477 // - the tag should be floating AND
478 // - there's a given width
479 if( SwCSS1Parser::MayBePositioned( rPropInfo ) )
480 {
481 SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameItemSet( m_xDoc->GetAttrPool() );
482 if( !IsNewDoc() )
483 Reader::ResetFrameFormatAttrs(aFrameItemSet );
484
486 aFrameItemSet );
487
488 SetVarSize( rPropInfo, aFrameItemSet );
489
490 SetSpace( Size(0,0), rItemSet, rPropInfo, aFrameItemSet );
491
492 SetFrameFormatAttrs( rItemSet,
494 aFrameItemSet );
495
496 InsertFlyFrame(aFrameItemSet, pContext, rPropInfo.m_aId);
497 pContext->SetPopStack( true );
498 rPropInfo.m_aId.clear();
499 bRet = true;
500 }
501
502 return bRet;
503}
504
505bool SwHTMLParser::CreateContainer( std::u16string_view rClass,
506 SfxItemSet &rItemSet,
507 SvxCSS1PropertyInfo &rPropInfo,
508 HTMLAttrContext *pContext )
509{
510 bool bRet = false;
511 if( o3tl::equalsIgnoreAsciiCase( rClass, u"sd-abs-pos" ) &&
512 SwCSS1Parser::MayBePositioned( rPropInfo ) )
513 {
514 // Container class
515 SfxItemSet *pFrameItemSet = pContext->GetFrameItemSet( m_xDoc.get() );
516 if( !IsNewDoc() )
517 Reader::ResetFrameFormatAttrs( *pFrameItemSet );
518
520 rPropInfo, *pFrameItemSet );
521 Size aDummy(0,0);
522 SetFixSize( aDummy, aDummy, false, false, rPropInfo, *pFrameItemSet );
523 SetSpace( aDummy, rItemSet, rPropInfo, *pFrameItemSet );
525 *pFrameItemSet );
526
527 bRet = true;
528 }
529
530 return bRet;
531}
532
534 SvxCSS1PropertyInfo const &rPropInfo,
535 HTMLAttrContext *pContext,
536 bool bCharLvl )
537{
538 // Put together a DropCap attribute, if a "float:left" is before the first character
539 if( bCharLvl && !m_pPam->GetPoint()->GetContentIndex() &&
540 SvxAdjust::Left == rPropInfo.m_eFloat )
541 {
542 SwFormatDrop aDrop;
543 aDrop.GetChars() = 1;
544
545 m_pCSS1Parser->FillDropCap( aDrop, rItemSet );
546
547 // We only set the DropCap attribute if the initial spans multiple lines
548 if( aDrop.GetLines() > 1 )
549 {
550 NewAttr(m_xAttrTab, &m_xAttrTab->pDropCap, aDrop);
551
552 HTMLAttrs &rAttrs = pContext->GetAttrs();
553 rAttrs.push_back( m_xAttrTab->pDropCap );
554
555 return;
556 }
557 }
558
559 if( !bCharLvl )
560 m_pCSS1Parser->SetFormatBreak( rItemSet, rPropInfo );
561
562 OSL_ENSURE(m_aContexts.size() <= m_nContextStAttrMin ||
563 m_aContexts.back().get() != pContext,
564 "SwHTMLParser::InsertAttrs: Context already on the Stack");
565
566 SfxItemIter aIter( rItemSet );
567
568 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
569 {
570 HTMLAttr **ppAttr = nullptr;
571
572 switch( pItem->Which() )
573 {
574 case RES_LR_SPACE:
575 {
576 // Paragraph indents need to be added and are generated for each paragraphs
577 // (here for the first paragraph only, all the following in SetTextCollAttrs)
578 const SvxLRSpaceItem *pLRItem =
579 static_cast<const SvxLRSpaceItem *>(pItem);
580
581 // Get old paragraph indents without the top context (that's the one we're editing)
582 sal_uInt16 nOldLeft = 0, nOldRight = 0;
583 short nOldIndent = 0;
584 bool bIgnoreTop = m_aContexts.size() > m_nContextStMin &&
585 m_aContexts.back().get() == pContext;
586 GetMarginsFromContext( nOldLeft, nOldRight, nOldIndent,
587 bIgnoreTop );
588
589 // ... and the currently valid ones
590 sal_uInt16 nLeft = nOldLeft, nRight = nOldRight;
591 short nIndent = nOldIndent;
592 pContext->GetMargins( nLeft, nRight, nIndent );
593
594 // ... and add the new indents to the old ones
595 // Here, we don't get the ones from the item but the separately remembered ones,
596 // since they could be negative. Accessing those via the item still works, since
597 // the item (with value 0) will be added
598 if( rPropInfo.m_bLeftMargin )
599 {
600 OSL_ENSURE( rPropInfo.m_nLeftMargin < 0 ||
601 rPropInfo.m_nLeftMargin == pLRItem->GetTextLeft(),
602 "left margin does not match with item" );
603 if( rPropInfo.m_nLeftMargin < 0 &&
604 -rPropInfo.m_nLeftMargin > nOldLeft )
605 nLeft = 0;
606 else
607 nLeft = nOldLeft + static_cast< sal_uInt16 >(rPropInfo.m_nLeftMargin);
608 }
609 if( rPropInfo.m_bRightMargin )
610 {
611 OSL_ENSURE( rPropInfo.m_nRightMargin < 0 ||
612 rPropInfo.m_nRightMargin == pLRItem->GetRight(),
613 "right margin does not match with item" );
614 if( rPropInfo.m_nRightMargin < 0 &&
615 -rPropInfo.m_nRightMargin > nOldRight )
616 nRight = 0;
617 else
618 nRight = nOldRight + static_cast< sal_uInt16 >(rPropInfo.m_nRightMargin);
619 }
620 if( rPropInfo.m_bTextIndent )
621 nIndent = pLRItem->GetTextFirstLineOffset();
622
623 // Remember the value for the following paragraphs
624 pContext->SetMargins( nLeft, nRight, nIndent );
625
626 // Set the attribute on the current paragraph
627 SvxLRSpaceItem aLRItem( *pLRItem );
628 aLRItem.SetTextFirstLineOffset( nIndent );
629 aLRItem.SetTextLeft( nLeft );
630 aLRItem.SetRight( nRight );
631 NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem);
632 EndAttr( m_xAttrTab->pLRSpace, false );
633 }
634 break;
635
636 case RES_UL_SPACE:
637 if( !rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin )
638 {
639 sal_uInt16 nUpper = 0, nLower = 0;
640 GetULSpaceFromContext( nUpper, nLower );
641 SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem *>(pItem) );
642 if( !rPropInfo.m_bTopMargin )
643 aULSpace.SetUpper( nUpper );
644 if( !rPropInfo.m_bBottomMargin )
645 aULSpace.SetLower( nLower );
646
647 NewAttr(m_xAttrTab, &m_xAttrTab->pULSpace, aULSpace);
648
649 // save context information
650 HTMLAttrs &rAttrs = pContext->GetAttrs();
651 rAttrs.push_back( m_xAttrTab->pULSpace );
652
653 pContext->SetULSpace( aULSpace.GetUpper(), aULSpace.GetLower() );
654 }
655 else
656 {
657 ppAttr = &m_xAttrTab->pULSpace;
658 }
659 break;
661 // don't set attributes with a % property
662 if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 )
663 ppAttr = &m_xAttrTab->pFontHeight;
664 break;
666 // don't set attributes with a % property
667 if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 )
668 ppAttr = &m_xAttrTab->pFontHeightCJK;
669 break;
671 // don't set attributes with a % property
672 if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 )
673 ppAttr = &m_xAttrTab->pFontHeightCTL;
674 break;
675
676 case RES_BACKGROUND:
677 if( bCharLvl )
678 {
679 // Convert the Frame attribute to a Char attribute (if needed)
680 SvxBrushItem aBrushItem( *static_cast<const SvxBrushItem *>(pItem) );
681 aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
682
683 // Set the attribute
684 NewAttr(m_xAttrTab, &m_xAttrTab->pCharBrush, aBrushItem);
685
686 // and save context information
687 HTMLAttrs &rAttrs = pContext->GetAttrs();
688 rAttrs.push_back( m_xAttrTab->pCharBrush );
689 }
690 else if( pContext->GetToken() != HtmlTokenId::TABLEHEADER_ON &&
691 pContext->GetToken() != HtmlTokenId::TABLEDATA_ON )
692 {
693 ppAttr = &m_xAttrTab->pBrush;
694 }
695 break;
696
697 case RES_BOX:
698 if( bCharLvl )
699 {
700 SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem *>(pItem) );
701 aBoxItem.SetWhich( RES_CHRATR_BOX );
702
703 NewAttr(m_xAttrTab, &m_xAttrTab->pCharBox, aBoxItem);
704
705 HTMLAttrs &rAttrs = pContext->GetAttrs();
706 rAttrs.push_back( m_xAttrTab->pCharBox );
707 }
708 else
709 {
710 ppAttr = &m_xAttrTab->pBox;
711 }
712 break;
713
714 default:
715 ppAttr = GetAttrTabEntry( pItem->Which() );
716 break;
717 }
718
719 if( ppAttr )
720 {
721 // Set the attribute
722 NewAttr(m_xAttrTab, ppAttr, *pItem);
723
724 // and save context information
725 HTMLAttrs &rAttrs = pContext->GetAttrs();
726 rAttrs.push_back( *ppAttr );
727 }
728 }
729
730 if( !rPropInfo.m_aId.isEmpty() )
731 InsertBookmark( rPropInfo.m_aId );
732}
733
734void SwHTMLParser::InsertAttr( HTMLAttr **ppAttr, const SfxPoolItem & rItem,
735 HTMLAttrContext *pCntxt )
736{
737 if( !ppAttr )
738 {
739 ppAttr = GetAttrTabEntry( rItem.Which() );
740 if( !ppAttr )
741 return;
742 }
743
744 // Set the attribute
745 NewAttr(m_xAttrTab, ppAttr, rItem);
746
747 // save context information
748 HTMLAttrs &rAttrs = pCntxt->GetAttrs();
749 rAttrs.push_back( *ppAttr );
750}
751
753{
754 // PRE/Listing/XMP need to be finished when finishing context
755 pCntxt->SetFinishPREListingXMP( true );
756
757 // And set all now valid flags
758 if( IsReadPRE() )
759 pCntxt->SetRestartPRE( true );
760 if( IsReadXMP() )
761 pCntxt->SetRestartXMP( true );
762 if( IsReadListing() )
763 pCntxt->SetRestartListing( true );
764
765 FinishPREListingXMP();
766}
767
769{
770 if( !m_pFrameItemSet && pCreateDoc )
772 ( pCreateDoc->GetAttrPool() );
773 return m_pFrameItemSet.get();
774}
775
776/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetContextStMin(size_t nMin)
Definition: htmlctxt.cxx:83
std::shared_ptr< HTMLAttrTable > m_xAttrTab
Definition: htmlctxt.cxx:53
bool GetStripTrailingPara() const
Definition: htmlctxt.cxx:90
void SetContextStAttrMin(size_t nMin)
Definition: htmlctxt.cxx:86
SwHTMLNumRuleInfo m_aNumRuleInfo
Definition: htmlctxt.cxx:49
size_t GetContextStMin() const
Definition: htmlctxt.cxx:84
void SetKeepNumRules(bool bSet)
Definition: htmlctxt.cxx:92
void SetPos(const SwPosition &rPos)
Definition: htmlctxt.cxx:74
const SwPosition * GetPos() const
Definition: htmlctxt.cxx:75
void SetFixFooterDist(bool bSet)
Definition: htmlctxt.cxx:98
bool GetFixHeaderDist() const
Definition: htmlctxt.cxx:96
void SetFixHeaderDist(bool bSet)
Definition: htmlctxt.cxx:95
std::shared_ptr< HTMLAttrTable > const & GetAttrTab(bool bCreate=false)
Definition: htmlctxt.cxx:102
void SetNumInfo(const SwHTMLNumRuleInfo &rInf)
Definition: htmlctxt.cxx:78
const SwHTMLNumRuleInfo & GetNumInfo() const
Definition: htmlctxt.cxx:79
void SetStripTrailingPara(bool bSet)
Definition: htmlctxt.cxx:89
size_t GetContextStAttrMin() const
Definition: htmlctxt.cxx:87
std::unique_ptr< SwPosition > m_pPos
Definition: htmlctxt.cxx:51
bool GetFixFooterDist() const
Definition: htmlctxt.cxx:99
bool GetKeepNumRules() const
Definition: htmlctxt.cxx:93
void ClearSaveDocContext()
Definition: htmlctxt.cxx:169
void SetULSpace(sal_uInt16 nUpper, sal_uInt16 nLower)
Definition: swhtml.hxx:1001
HTMLAttrContext_SaveDoc * GetSaveDocContext(bool bCreate=false)
Definition: htmlctxt.cxx:112
bool GetSpansSection() const
Definition: swhtml.hxx:271
void SetPopStack(bool bSet)
Definition: swhtml.hxx:273
const HTMLAttrs & GetAttrs() const
Definition: swhtml.hxx:267
SwHTMLAppendMode GetAppendMode() const
Definition: swhtml.hxx:298
bool IsRestartXMP() const
Definition: swhtml.hxx:289
void SetRestartXMP(bool bSet)
Definition: swhtml.hxx:288
void SetMargins(sal_uInt16 nLeft, sal_uInt16 nRight, short nIndent)
Definition: swhtml.hxx:980
void SetRestartPRE(bool bSet)
Definition: swhtml.hxx:285
bool GetPopStack() const
Definition: swhtml.hxx:274
HtmlTokenId GetToken() const
Definition: swhtml.hxx:249
std::unique_ptr< HTMLAttrContext_SaveDoc > m_pSaveDocContext
Definition: swhtml.hxx:212
bool IsFinishPREListingXMP() const
Definition: swhtml.hxx:283
bool IsRestartPRE() const
Definition: swhtml.hxx:286
void SetRestartListing(bool bSet)
Definition: swhtml.hxx:291
const SfxItemSet * GetFrameItemSet() const
Definition: swhtml.hxx:279
void SetFinishPREListingXMP(bool bSet)
Definition: swhtml.hxx:282
bool IsRestartListing() const
Definition: swhtml.hxx:292
HTMLAttrContext(HtmlTokenId nTokn, sal_uInt16 nPoolId, OUString aClass, bool bDfltColl=false)
Definition: htmlctxt.cxx:120
bool HasAttrs() const
Definition: swhtml.hxx:266
bool HasSaveDocContext() const
Definition: swhtml.hxx:276
std::unique_ptr< SfxItemSet > m_pFrameItemSet
Definition: swhtml.hxx:213
void GetMargins(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent) const
Definition: swhtml.hxx:989
sal_Int32 m_nStartContent
Definition: swhtml.hxx:134
HTMLAttr * GetPrev() const
Definition: swhtml.hxx:179
sal_Int32 m_nEndContent
Definition: swhtml.hxx:135
SwNodeIndex m_nEndPara
Definition: swhtml.hxx:133
HTMLAttr * GetNext() const
Definition: swhtml.hxx:176
SwNodeOffset GetStartParagraphIdx() const
Definition: swhtml.hxx:161
HTMLAttr * m_pPrev
Definition: swhtml.hxx:143
bool m_bInsAtStart
Definition: swhtml.hxx:136
std::unique_ptr< SfxPoolItem > m_pItem
Definition: swhtml.hxx:140
const SwNodeIndex & GetStartParagraph() const
Definition: swhtml.hxx:164
void InsertPrev(HTMLAttr *pPrv)
Definition: swhtml.cxx:5514
sal_Int32 GetStartContent() const
Definition: swhtml.hxx:167
SwNodeIndex m_nStartPara
Definition: swhtml.hxx:132
HTMLAttr * Clone(const SwNode &rEndPara, sal_Int32 nEndCnt) const
Definition: swhtml.cxx:5487
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
Definition: shellio.cxx:621
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 Which() const
tools::Long m_nRightMargin
Definition: svxcss1.hxx:135
SvxAdjust m_eFloat
Definition: svxcss1.hxx:119
tools::Long m_nLeftMargin
Definition: svxcss1.hxx:135
short GetTextFirstLineOffset() const
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
tools::Long GetRight() const
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
tools::Long GetTextLeft() const
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
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)
Definition: htmlcss1.cxx:1409
Definition: doc.hxx:194
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1326
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps.
Definition: paratr.hxx:63
sal_uInt8 GetLines() const
Definition: paratr.hxx:101
sal_uInt8 GetChars() const
Definition: paratr.hxx:104
void Set(const SwHTMLNumRuleInfo &rInf)
Definition: htmlnum.hxx:93
HTMLAttrs m_aSetAttrTab
Definition: swhtml.hxx:377
bool EndSection(bool bLFStripped=false)
Definition: htmlsect.cxx:502
size_t m_nContextStAttrMin
Definition: swhtml.hxx:420
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2100
void SetAnchorAndAdjustment(sal_Int16 eVertOri, sal_Int16 eHoriOri, const SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFrameSet)
Definition: htmlgrin.cxx:151
void InsertAttrs(std::deque< std::unique_ptr< HTMLAttr > > rAttrs)
Definition: swhtml.cxx:3482
void InsertBookmark(const OUString &rName)
Definition: htmlgrin.cxx:1393
bool CreateContainer(std::u16string_view rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:505
HTMLAttrContexts m_aContexts
Definition: swhtml.hxx:380
void InsertAttr(const SfxPoolItem &rItem, bool bInsAtStart)
Definition: swhtml.cxx:3473
static void SetSpace(const Size &rPixSpace, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFlyItemSet)
Definition: htmlplug.cxx:243
void SaveAttrTab(std::shared_ptr< HTMLAttrTable > const &rNewAttrTab)
Definition: swhtml.cxx:3318
std::shared_ptr< HTMLAttrTable > m_xAttrTab
Definition: swhtml.hxx:379
void SetAttr(bool bChkEnd=true, bool bBeforeTable=false, std::deque< std::unique_ptr< HTMLAttr > > *pPostIts=nullptr)
Definition: swhtml.hxx:512
void ClearContext(HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:421
void SaveDocContext(HTMLAttrContext *pCntxt, HtmlContextFlags nFlags, const SwPosition *pNewPos)
Definition: htmlctxt.cxx:273
void EndContextAttrs(HTMLAttrContext *pContext)
Definition: htmlcss1.cxx:2214
void StripTrailingPara()
Definition: htmlgrin.cxx:1448
bool DoPositioning(SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:468
void DeleteAttr(HTMLAttr *pAttr)
Definition: swhtml.cxx:3260
void InsertFlyFrame(const SfxItemSet &rItemSet, HTMLAttrContext *pCntxt, const OUString &rId)
Definition: htmlsect.cxx:755
HTMLAttrs m_aParaAttrs
Definition: swhtml.hxx:378
HTMLAttr ** GetAttrTabEntry(sal_uInt16 nWhich)
Definition: htmlcss1.cxx:1524
SwPaM * m_pPam
Definition: swhtml.hxx:394
SwHTMLNumRuleInfo & GetNumInfo()
Definition: swhtml.hxx:562
static void SetFixSize(const Size &rPixSize, const Size &rTwipDfltSize, bool bPercentWidth, bool bPercentHeight, SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet)
Definition: htmlplug.cxx:165
void NewAttr(const std::shared_ptr< HTMLAttrTable > &rAttrTab, HTMLAttr **ppAttr, const SfxPoolItem &rItem)
Definition: swhtml.cxx:3082
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:393
void RestoreDocContext(HTMLAttrContext *pCntxt)
Definition: htmlctxt.cxx:324
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:389
void SplitPREListingXMP(HTMLAttrContext *pCntxt)
Definition: htmlctxt.cxx:752
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
Definition: swhtml.cxx:2192
void GetMarginsFromContext(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent, bool bIgnoreCurrent=false) const
Definition: htmlcss1.cxx:2140
void EndContext(HTMLAttrContext *pContext)
Definition: htmlctxt.cxx:372
void FixHeaderFooterDistance(bool bHeader, const SwPosition *pOldPos)
Definition: htmlsect.cxx:414
void SplitAttrTab(const SwPosition &rNewPos)
Definition: htmlctxt.cxx:174
static void SetFrameFormatAttrs(SfxItemSet &rItemSet, HtmlFrameFormatFlags nFlags, SfxItemSet &rFrameItemSet)
Definition: htmlcss1.cxx:2061
bool EndAttr(HTMLAttr *pAttr, bool bChkEmpty=true)
Definition: swhtml.cxx:3098
size_t m_nContextStMin
Definition: swhtml.hxx:419
void GetULSpaceFromContext(sal_uInt16 &rUpper, sal_uInt16 &rLower) const
Definition: htmlcss1.cxx:2181
static void SetVarSize(SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet, SwTwips nDfltWidth=MINLAY, sal_uInt8 nDefaultPercentWidth=0)
Definition: htmlcss1.cxx:2022
void RestoreAttrTab(std::shared_ptr< HTMLAttrTable > const &rNewAttrTab)
Definition: swhtml.cxx:3443
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:668
const SwPosition * GetPoint() const
Definition: pam.hxx:261
float u
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr sal_uInt16 RES_FRMATR_END(133)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_BACKGROUND(21)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SvxBoxItem > RES_CHRATR_BOX(40)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
HtmlTokenId
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
@ AM_NONE
Definition: swhtml.hxx:203
std::deque< HTMLAttr * > HTMLAttrs
Definition: swhtml.hxx:75
HtmlContextFlags
Definition: swhtml.hxx:312