sw/source/filter/html/htmlctxt.cxx | 176 +++++++++++++++---------------------- 1 file changed, 73 insertions(+), 103 deletions(-)
New commits: commit 71160b4cd3ee9f8b127ed687d9e0d0a8067bfd64 Author: Lukas Röllin <lukas.roel...@bluewin.ch> Date: Mon Feb 6 11:23:53 2017 +0000 Translate German comments Change-Id: Iafca03642f7053cb9c5009163cb80528d88bca47 Reviewed-on: https://gerrit.libreoffice.org/33960 Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx index 11ae0fe..f86cafdc 100644 --- a/sw/source/filter/html/htmlctxt.cxx +++ b/sw/source/filter/html/htmlctxt.cxx @@ -40,22 +40,17 @@ using namespace ::com::sun::star; class HTMLAttrContext_SaveDoc { - SwHTMLNumRuleInfo aNumRuleInfo; // In Umgebung gueltige Numerierung - SwPosition *pPos; // hierhin beim verlassen den - // Kontexts zurueckgesprungen - HTMLAttrTable *pAttrTab; // In Umgebung gueltige Attribute, - // wenn Attributierung nicht - // beibehalten werden soll. - - size_t nContextStMin; // In Umgebung gueltige Stack- - // Untergrenze, wenn der Stack - // geschuetzt werden soll. - size_t nContextStAttrMin; // In Umgebung gueltige Stack- - // Untergrenze, wenn die Attribute - // nicht beibehalten werden sollen. - - bool bStripTrailingPara : 1; // letzen Absatz entfernen? - bool bKeepNumRules : 1; // Numerierung beibehalten? + SwHTMLNumRuleInfo aNumRuleInfo; // Numbering for this environment + SwPosition *pPos; // Jump back to here when leaving context + HTMLAttrTable *pAttrTab; // Valid attributes for the envionment, + // if attributes shouldn't be preserved + + size_t nContextStMin; // Stack lower bound for the environment + // if stack needs to be protected + size_t nContextStAttrMin; // Stack lower bound for the environment + // if the attribues shouldn't be preserved + bool bStripTrailingPara : 1; + bool bKeepNumRules : 1; bool bFixHeaderDist : 1; bool bFixFooterDist : 1; @@ -70,11 +65,11 @@ public: ~HTMLAttrContext_SaveDoc() { delete pPos; delete pAttrTab; } - // Die Position gehoert uns, muss also angelegt und zerstoert werden + // The position is ours, so we need to create and delete it void SetPos( const SwPosition& rPos ) { pPos = new SwPosition(rPos); } const SwPosition *GetPos() const { return pPos; } - // Der Index gehoert uns nicht. Kein Anlgen und Zerstoeren. + // The index isn't ours. So no creation or deletion void SetNumInfo( const SwHTMLNumRuleInfo& rInf ) { aNumRuleInfo.Set(rInf); } const SwHTMLNumRuleInfo& GetNumInfo() const { return aNumRuleInfo; } @@ -140,8 +135,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos ) bool bMoveBack = false; - // alle noch offenen Attribute beenden und hinter der Tabelle - // neu aufspannen + // close all open attributes and re-open them after the table HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(&m_aAttrTab); for (auto nCnt = sizeof(HTMLAttrTable) / sizeof(HTMLAttr*); nCnt--; ++pHTMLAttributes) { @@ -155,8 +149,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos ) if( !nOldEndCnt && RES_PARATR_BEGIN <= nWhich && pAttr->GetSttParaIdx() < pOldEndPara->GetIndex() ) { - // Das Attribut muss eine Content-Position weiter vorne - // beendet werden + // The attribute needs to be closed one content position beforehand if( !bMoveBack ) { bMoveBack = m_pPam->Move( fnMoveBackward ); @@ -174,11 +167,9 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos ) (pAttr->GetSttPara() == *pOldEndPara && pAttr->GetSttCnt() != nOldEndCnt) ) { - // Das Attribut muss gesetzt werden. Da wir - // das Original noch brauchen, weil Zeiger auf das Attribut - // noch in den Kontexten existieren, muessen wir es clonen. - // Die Next-Liste geht dabei verloren, aber die - // Previous-Liste bleibt erhalten + // The attribute needs to be set. Because we still need the original, since + // pointers to the attribute still exists in the contexts, we need to clone it. + // The next-list gets lost but the previous-list is preserved HTMLAttr *pSetAttr = pAttr->Clone( *pOldEndPara, nOldEndCnt ); if( pNext ) @@ -193,9 +184,8 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos ) } else if( pPrev ) { - // Wenn das Attribut nicht gesetzt vor der Tabelle - // gesetzt werden muss, muessen der Previous-Attribute - // trotzdem gesetzt werden. + // The previous attributes still need to be set, even if the current attribute + // doesn't need to be set before the table if( pNext ) pNext->InsertPrev( pPrev ); else @@ -207,7 +197,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos ) } } - // den Start des Attributs neu setzen + // Set the start of the attribute pAttr->nSttPara = rNewSttPara; pAttr->nEndPara = rNewSttPara; pAttr->nSttContent = nNewSttCnt; @@ -235,20 +225,18 @@ void SwHTMLParser::SaveDocContext( HTMLAttrContext *pCntxt, if( pNewPos ) { - // Wenn der PaM an eine andere Position gesetzt wird, muss - // die Numerierung gerettet werden.. + // If the PaM needs to be set to a different position, we need to preserve numbering if( !pSave->GetKeepNumRules() ) { - // Die Numerierung soll nicht beibehalten werden. Also muss - // der aktuelle Zustand gerettet und die Numerierung - // anschliessend ausgeschaltet werden. + // Numbering shall not be preserved. So we need to preserve the current state + // and turn off numbering afterwards pSave->SetNumInfo( GetNumInfo() ); GetNumInfo().Clear(); } if( HtmlContextFlags::KeepAttrs & nFlags ) { - // Attribute an aktueller Position beenden und an neuer neu anfangen + // Close attribute on current position and start on new one SplitAttrTab( *pNewPos ); } else @@ -261,8 +249,8 @@ void SwHTMLParser::SaveDocContext( HTMLAttrContext *pCntxt, *m_pPam->GetPoint() = *pNewPos; } - // Mit dem Setzen von nContextStMin koennen automatisch auch - // keine gerade offenen Listen (DL/OL/UL) mehr beendet werden. + // Settings nContextStMin automatically means, that no + // currently open lists (DL/OL/UL) can be closed if( HtmlContextFlags::ProtectStack & nFlags ) { pSave->SetContextStMin( m_nContextStMin ); @@ -294,8 +282,7 @@ void SwHTMLParser::RestoreDocContext( HTMLAttrContext *pCntxt ) HTMLAttrTable *pSaveAttrTab = pSave->GetAttrTab(); if( !pSaveAttrTab ) { - // Attribute an aktueller Position beenden und an alter neu - // anfangen. + // Close attribute on current position and start on the old one SplitAttrTab( *pSave->GetPos() ); } else @@ -305,7 +292,7 @@ void SwHTMLParser::RestoreDocContext( HTMLAttrContext *pCntxt ) *m_pPam->GetPoint() = *pSave->GetPos(); - // Die bisherigen Attribute koennen wir schonmal setzen. + // We can already set the attributes so far SetAttr(); } @@ -318,7 +305,7 @@ void SwHTMLParser::RestoreDocContext( HTMLAttrContext *pCntxt ) if( !pSave->GetKeepNumRules() ) { - // Die bisherige gemerkte Numerierung wieder setzen + // Set the preserved numbering back GetNumInfo().Set( pSave->GetNumInfo() ); } @@ -329,8 +316,7 @@ void SwHTMLParser::EndContext( HTMLAttrContext *pContext ) { if( pContext->GetPopStack() ) { - // Alle noch offenen Kontexte beenden. Der eigene - // Kontext muss bereits geloscht sein! + // Close all still open contexts. Our own context needs to be deleted already! while( m_aContexts.size() > m_nContextStMin ) { HTMLAttrContext *pCntxt = PopContext(); @@ -344,26 +330,25 @@ void SwHTMLParser::EndContext( HTMLAttrContext *pContext ) } } - // Alle noch offenen Attribute beenden + // Close all still open attributes if( pContext->HasAttrs() ) EndContextAttrs( pContext ); - // Falls ein Bereich geoeffnet wurde, den verlassen. Da Bereiche - // auch innerhalb von absolut positionierten Objekten angelegt werden, - // muss das passieren, bever ein alter Dokument-Kontext restauriert wird. + // If a section has been opened, end it. Since sections can be part of absolute-positioned + // objects, this needs to be done before restoring document context if( pContext->GetSpansSection() ) EndSection(); - // Rahmen und sonstige Sonderbereiche verlassen. + // Leave borders and other special sections if( pContext->HasSaveDocContext() ) RestoreDocContext( pContext ); - // Ggf. noch einen Ansatz-Umbruch einfuegen + // Add a paragraph break if needed if( AM_NONE != pContext->GetAppendMode() && m_pPam->GetPoint()->nContent.GetIndex() ) AppendTextNode( pContext->GetAppendMode() ); - // PRE-/LISTING- und XMP-Umgebungen wieder starten + // Restart PRE, LISTING and XMP environments if( pContext->IsFinishPREListingXMP() ) FinishPREListingXMP(); @@ -382,11 +367,10 @@ void SwHTMLParser::ClearContext( HTMLAttrContext *pContext ) HTMLAttrs &rAttrs = pContext->GetAttrs(); for( auto pAttr : rAttrs ) { - // einfaches Loeschen reicht hier nicht, weil das - // Attribut auch aus seiner Liste ausgetragen werden - // muss. Theoretisch koennt man natuerlich auch die Liste - // und die Attribute getrennt loeschen, aber wenn man - // dann was falsch gemacht hat, sieht es uebel aus. + // Simple deletion doesn't to the job, since the attribute + // needs to be deregistered with its list. + // In theory, you could delete the list and its attributes separately + // but if you get that wrong, quite a lot is messed up DeleteAttr( pAttr ); } @@ -396,7 +380,7 @@ void SwHTMLParser::ClearContext( HTMLAttrContext *pContext ) OSL_ENSURE( !pContext->HasSaveDocContext(), "Rahmen kann nicht mehr verlassen werden" ); - // PRE-/LISTING- und XMP-Umgebungen wieder starten + // Restart PRE/LISTING/XMP environments if( pContext->IsFinishPREListingXMP() ) FinishPREListingXMP(); @@ -416,11 +400,11 @@ bool SwHTMLParser::DoPositioning( SfxItemSet &rItemSet, { bool bRet = false; - // Unter folgenden Umstaenden wird jetzt ein Rahmen aufgemacht: - // - das Tag wird absolut positioniert und left/top sind beide - // gegeben und enthalten auch keine %-Angabe, oder - // - das Tag soll fliessen, und - // - es wurde eine Breite angegeben (in beiden Faellen noetig) + // A border is opened on the following conditions + // - the tag is absolute-positoned AND left/top are both known AND don't contain a % property + // OR + // - the tag should be floating AND + // - there's a given width if( SwCSS1Parser::MayBePositioned( rPropInfo ) ) { SfxItemSet aFrameItemSet( m_xDoc->GetAttrPool(), @@ -428,17 +412,13 @@ bool SwHTMLParser::DoPositioning( SfxItemSet &rItemSet, if( !IsNewDoc() ) Reader::ResetFrameFormatAttrs(aFrameItemSet ); - // Ausrichtung setzen SetAnchorAndAdjustment( text::VertOrientation::NONE, text::HoriOrientation::NONE, rItemSet, rPropInfo, aFrameItemSet ); - // Groesse setzen SetVarSize( rItemSet, rPropInfo, aFrameItemSet ); - // Abstaende setzen SetSpace( Size(0,0), rItemSet, rPropInfo, aFrameItemSet ); - // Sonstige CSS1-Attribute Setzen SetFrameFormatAttrs( rItemSet, rPropInfo, HtmlFrameFormatFlags::Box|HtmlFrameFormatFlags::Padding|HtmlFrameFormatFlags::Background|HtmlFrameFormatFlags::Direction, aFrameItemSet ); @@ -461,7 +441,7 @@ bool SwHTMLParser::CreateContainer( const OUString& rClass, if( rClass.equalsIgnoreAsciiCase( "sd-abs-pos" ) && SwCSS1Parser::MayBePositioned( rPropInfo ) ) { - // Container-Klasse + // Container class SfxItemSet *pFrameItemSet = pContext->GetFrameItemSet( m_xDoc.get() ); if( !IsNewDoc() ) Reader::ResetFrameFormatAttrs( *pFrameItemSet ); @@ -486,8 +466,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, HTMLAttrContext *pContext, bool bCharLvl ) { - // Ein DropCap-Attribut basteln, wenn auf Zeichen-Ebene vor dem - // ersten Zeichen ein float: left vorkommt + // Put together a DropCap attribute, if a "float:left" is before the first character if( bCharLvl && !m_pPam->GetPoint()->nContent.GetIndex() && SVX_ADJUST_LEFT == rPropInfo.m_eFloat ) { @@ -496,8 +475,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, m_pCSS1Parser->FillDropCap( aDrop, rItemSet ); - // Nur wenn das Initial auch ueber mehrere Zeilen geht, wird das - // DropCap-Attribut gesetzt. Sonst setzten wir die Attribute hart. + // We only set the DropCap attribute if the initial spans multiple lines if( aDrop.GetLines() > 1 ) { NewAttr( &m_aAttrTab.pDropCap, aDrop ); @@ -527,15 +505,12 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, { case RES_LR_SPACE: { - // Absatz-Einzuege muessen addiert werden und werden immer - // nur absatzweise gesetzt (fuer den ersten Absatz hier, - // fuer alle folgenden in SetTextCollAttrs) - + // Paragraph indents need to be added and are generated for each paragraphs + // (here for the first paragraph only, all the following in SetTextCollAttrs) const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem); - // die bisherigen Absatz-Abstaende holen (ohne die vom - // obersten Kontext, denn den veraendern wir ja gerade) ... + // Get old paragraph indents without the top context (that's the one we're editing) sal_uInt16 nOldLeft = 0, nOldRight = 0; short nOldIndent = 0; bool bIgnoreTop = m_aContexts.size() > m_nContextStMin && @@ -543,17 +518,15 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, GetMarginsFromContext( nOldLeft, nOldRight, nOldIndent, bIgnoreTop ); - // und noch die aktuell gueltigen + // ... and the currently valid ones sal_uInt16 nLeft = nOldLeft, nRight = nOldRight; short nIndent = nOldIndent; pContext->GetMargins( nLeft, nRight, nIndent ); - // ... und die neuen Abstaende zu den alten addieren - // Hier werden nicht die aus dem Item genommen, sondern die - // extra gemerkten, weil die auch negativ sein koennen. Die - // Abfrage ueber das Item funktioniert aber trotzdem, denn - // fuer negative Werte wird das Item (mit Wert 0) auch - // eingefuegt. + // ... and add the new indents to the old ones + // Here, we don't get the ones from the item but the separately remembered ones, + // since they could be negative. Accessing those via the item still works, since + // the item (with value 0) will be added if( rPropInfo.m_bLeftMargin ) { OSL_ENSURE( rPropInfo.m_nLeftMargin < 0 || @@ -579,10 +552,10 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, if( rPropInfo.m_bTextIndent ) nIndent = pLRItem->GetTextFirstLineOfst(); - // und die Werte fuer nachfolgende Absaetze merken + // Remember the value for the following paragraphs pContext->SetMargins( nLeft, nRight, nIndent ); - // das Attribut noch am aktuellen Absatz setzen + // Set the attribute on the current paragraph SvxLRSpaceItem aLRItem( *pLRItem ); aLRItem.SetTextFirstLineOfst( nIndent ); aLRItem.SetTextLeft( nLeft ); @@ -605,7 +578,7 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, NewAttr( &m_aAttrTab.pULSpace, aULSpace ); - // ... und noch die Kontext-Information speichern + // save context information HTMLAttrs &rAttrs = pContext->GetAttrs(); rAttrs.push_back( m_aAttrTab.pULSpace ); @@ -617,17 +590,17 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, } break; case RES_CHRATR_FONTSIZE: - // es werden keine Attribute mit %-Angaben gesetzt + // don't set attributes with a % property if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 ) ppAttr = &m_aAttrTab.pFontHeight; break; case RES_CHRATR_CJK_FONTSIZE: - // es werden keine Attribute mit %-Angaben gesetzt + // don't set attributes with a % property if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 ) ppAttr = &m_aAttrTab.pFontHeightCJK; break; case RES_CHRATR_CTL_FONTSIZE: - // es werden keine Attribute mit %-Angaben gesetzt + // don't set attributes with a % property if( static_cast<const SvxFontHeightItem *>(pItem)->GetProp() == 100 ) ppAttr = &m_aAttrTab.pFontHeightCTL; break; @@ -635,14 +608,14 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, case RES_BACKGROUND: if( bCharLvl ) { - // das Frame-Attr ggf. in ein Char-Attr umwandeln + // Convert the Frame attribute to a Char attribute (if needed) SvxBrushItem aBrushItem( *static_cast<const SvxBrushItem *>(pItem) ); aBrushItem.SetWhich( RES_CHRATR_BACKGROUND ); - // Das Attribut setzen ... + // Set the attribute NewAttr( &m_aAttrTab.pCharBrush, aBrushItem ); - // ... und noch die Kontext-Information speichern + // and save context information HTMLAttrs &rAttrs = pContext->GetAttrs(); rAttrs.push_back( m_aAttrTab.pCharBrush ); } @@ -671,22 +644,20 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, break; default: - // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ... ppAttr = GetAttrTabEntry( pItem->Which() ); break; } if( ppAttr ) { - // Das Attribut setzen ... + // Set the attribute NewAttr( ppAttr, *pItem ); - // ... und noch die Kontext-Information speichern + // and save context information HTMLAttrs &rAttrs = pContext->GetAttrs(); rAttrs.push_back( *ppAttr ); } - // auf zum naechsten Item pItem = aIter.NextItem(); } @@ -704,20 +675,20 @@ void SwHTMLParser::InsertAttr( HTMLAttr **ppAttr, const SfxPoolItem & rItem, return; } - // das Attribut setzen + // Set the attribute NewAttr( ppAttr, rItem ); - // und im Kontext merken + // save context information HTMLAttrs &rAttrs = pCntxt->GetAttrs(); rAttrs.push_back( *ppAttr ); } void SwHTMLParser::SplitPREListingXMP( HTMLAttrContext *pCntxt ) { - // PRE/Listing/XMP soll beim beenden des Kontexts beendet werden. + // PRE/Listing/XMP need to be finished when finishing context pCntxt->SetFinishPREListingXMP( true ); - // Und die jetzt gueltigen Flags sollen wieder gesetzt werden. + // And set all now valid flags if( IsReadPRE() ) pCntxt->SetRestartPRE( true ); if( IsReadXMP() ) @@ -725,7 +696,6 @@ void SwHTMLParser::SplitPREListingXMP( HTMLAttrContext *pCntxt ) if( IsReadListing() ) pCntxt->SetRestartListing( true ); - // PRE/Listing/XMP wird auuserdem sofort beendet FinishPREListingXMP(); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits