[Libreoffice-commits] core.git: 3 commits - oox/source sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jul 6 00:17:01 PDT 2015
oox/source/export/preset-definitions-to-shape-types.pl | 2 -
sw/qa/extras/rtfimport/data/tdf92481.rtf | 6 ++++
sw/qa/extras/rtfimport/rtfimport.cxx | 6 ++++
sw/source/filter/ww8/docxsdrexport.cxx | 24 ++++++++--------
writerfilter/source/dmapper/SettingsTable.cxx | 25 +++++++++++++++--
writerfilter/source/ooxml/model.xml | 4 ++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 3 ++
7 files changed, 55 insertions(+), 15 deletions(-)
New commits:
commit 0afd9dbc08ee2e55e0845dd33ece10ff9375bfa7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jul 6 09:15:22 2015 +0200
sw: fix newly introduced style inconsistencies in docxsdrexport
Change-Id: I9b9f198aa6da2f6734194207b4c4bdec3ee1d4c0
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index b59de52..8244171 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1473,14 +1473,14 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
//first, loop through ALL of the chained textboxes to identify a unique ID for each chain, and sequence number for each textbox in that chain.
std::map<OUString, MSWordExportBase::LinkedTextboxInfo>::iterator linkedTextboxesIter;
- if( !m_pImpl->m_rExport.m_bLinkedTextboxesHelperInitialized )
+ if (!m_pImpl->m_rExport.m_bLinkedTextboxesHelperInitialized)
{
sal_Int32 nSeq=0;
linkedTextboxesIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.begin();
- while ( linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end() )
+ while (linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end())
{
//find the start of a textbox chain: has no PREVIOUS link, but does have NEXT link
- if ( linkedTextboxesIter->second.sPrevChain.isEmpty() && !linkedTextboxesIter->second.sNextChain.isEmpty() )
+ if (linkedTextboxesIter->second.sPrevChain.isEmpty() && !linkedTextboxesIter->second.sNextChain.isEmpty())
{
//assign this chain a unique ID and start a new sequence
nSeq = 0;
@@ -1492,18 +1492,18 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
//follow the chain and assign the same id, and incremental sequence numbers.
std::map<OUString, MSWordExportBase::LinkedTextboxInfo>::iterator followChainIter;
followChainIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find(linkedTextboxesIter->second.sNextChain);
- while ( followChainIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end() )
+ while (followChainIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end())
{
//verify that the NEXT textbox also points to me as the PREVIOUS.
// A broken link indicates a leftover remnant that can be ignored.
- if( followChainIter->second.sPrevChain != sCheckForBrokenChains )
+ if (followChainIter->second.sPrevChain != sCheckForBrokenChains)
break;
followChainIter->second.nId = m_pImpl->m_rExport.m_nLinkedTextboxesChainId;
followChainIter->second.nSeq = ++nSeq;
//empty next chain indicates the end of the linked chain.
- if ( followChainIter->second.sNextChain.isEmpty() )
+ if (followChainIter->second.sNextChain.isEmpty())
break;
sCheckForBrokenChains = followChainIter->first;
@@ -1520,19 +1520,19 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
bool isTxbxLinked = false ;
OUString sLinkChainName;
- if ( xPropSetInfo.is() )
+ if (xPropSetInfo.is())
{
- if ( xPropSetInfo->hasPropertyByName("LinkDisplayName") )
+ if (xPropSetInfo->hasPropertyByName("LinkDisplayName"))
xPropertySet->getPropertyValue("LinkDisplayName") >>= sLinkChainName;
- else if ( xPropSetInfo->hasPropertyByName("ChainName") )
+ else if (xPropSetInfo->hasPropertyByName("ChainName"))
xPropertySet->getPropertyValue("ChainName") >>= sLinkChainName;
}
// second, check if THIS textbox is linked and then decide whether to write the tag txbx or linkedTxbx
linkedTextboxesIter = m_pImpl->m_rExport.m_aLinkedTextboxesHelper.find(sLinkChainName);
- if ( linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end() )
+ if (linkedTextboxesIter != m_pImpl->m_rExport.m_aLinkedTextboxesHelper.end())
{
- if( (linkedTextboxesIter->second.nId !=0) && (linkedTextboxesIter->second.nSeq != 0) )
+ if ((linkedTextboxesIter->second.nId !=0) && (linkedTextboxesIter->second.nSeq != 0))
{
//not the first in the chain, so write the tag as linkedTxbx
pFS->singleElementNS(XML_wps, XML_linkedTxbx,
@@ -1545,7 +1545,7 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
*/
skipTxBxContent = true ;
}
- else if( (linkedTextboxesIter->second.nId != 0) && (linkedTextboxesIter->second.nSeq == 0) )
+ else if ((linkedTextboxesIter->second.nId != 0) && (linkedTextboxesIter->second.nSeq == 0))
{
/* this is the first textbox in the chaining, we add the text content
to this block*/
commit f2904c5cad7756268a5671eedd6a86286dfeed98
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jul 6 09:12:13 2015 +0200
oox: sort output in generated oox-drawingml-adj-names
So generated data don't unnecessarily differ after each build.
Change-Id: I143fa189a653266fadf9dd34ce2ed42b9b9b1548
diff --git a/oox/source/export/preset-definitions-to-shape-types.pl b/oox/source/export/preset-definitions-to-shape-types.pl
index cd324d1..907ae05 100644
--- a/oox/source/export/preset-definitions-to-shape-types.pl
+++ b/oox/source/export/preset-definitions-to-shape-types.pl
@@ -1197,7 +1197,7 @@ if ( !defined( $result_shapes{'textBox'} ) ) {
# Generate the data
if ($drawingml_adj_names_data eq 1) {
- foreach my $adj_name (keys %adj_names)
+ foreach my $adj_name (sort(keys %adj_names))
{
foreach my $adj (@{$adj_names{$adj_name}})
{
commit ffc7b671e213d366e59d39ddbbef66544ebf01e5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jul 6 09:09:41 2015 +0200
tdf#92481 RTF import: handle \widowctrl
Change-Id: I1af1d6bc150c16a2c6b0fe788a41c8c18caee6c6
diff --git a/sw/qa/extras/rtfimport/data/tdf92481.rtf b/sw/qa/extras/rtfimport/data/tdf92481.rtf
new file mode 100644
index 0000000..09a6c5e
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf92481.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+\widowctrl
+\pard\plain
+Hello.
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 24116ef..7ec1931 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2313,6 +2313,12 @@ DECLARE_RTFIMPORT_TEST(testTdf92061, "tdf92061.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString());
}
+DECLARE_RTFIMPORT_TEST(testTdf92481, "tdf92481.rtf")
+{
+ // This was 0, RTF_WIDOWCTRL was not imported.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int8>(2), getProperty<sal_Int8>(getParagraph(1), "ParaWidows"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index ef4ed92..dbb2da1 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -79,6 +79,7 @@ struct SettingsTable_Impl
bool m_bDoNotUseHTMLParagraphAutoSpacing;
bool m_bNoColumnBalance;
bool m_bAutoHyphenation;
+ bool m_bWidowControl;
bool m_bSplitPgBreakAndParaMark;
bool m_bMirrorMargin;
uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
@@ -111,6 +112,7 @@ struct SettingsTable_Impl
, m_bDoNotUseHTMLParagraphAutoSpacing(false)
, m_bNoColumnBalance(false)
, m_bAutoHyphenation(false)
+ , m_bWidowControl(false)
, m_bSplitPgBreakAndParaMark(false)
, m_bMirrorMargin(false)
, m_pThemeFontLangProps(3)
@@ -288,6 +290,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
case NS_ooxml::LN_CT_Settings_autoHyphenation:
m_pImpl->m_bAutoHyphenation = nIntValue;
break;
+ case NS_ooxml::LN_CT_Settings_widowControl:
+ m_pImpl->m_bWidowControl = nIntValue;
+ break;
default:
{
#ifdef DEBUG_WRITERFILTER
@@ -373,6 +378,11 @@ uno::Sequence<beans::PropertyValue> SettingsTable::GetCompatSettings() const
return comphelper::containerToSequence(m_pImpl->m_aCompatSettings);
}
+static bool lcl_isDefault(const uno::Reference<beans::XPropertyState>& xPropertyState, const OUString& rPropertyName)
+{
+ return xPropertyState->getPropertyState(rPropertyName) == beans::PropertyState_DEFAULT_VALUE;
+}
+
void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& xDoc)
{
uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
@@ -382,18 +392,29 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x
xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
// Auto hyphenation: turns on hyphenation by default, <w:suppressAutoHyphens/> may still disable it at a paragraph level.
- if (m_pImpl->m_bAutoHyphenation)
+ // Situation is similar for RTF_WIDOWCTRL, which turns on widow / orphan control by default.
+ if (m_pImpl->m_bAutoHyphenation || m_pImpl->m_bWidowControl)
{
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY);
+ if (!xStyleFamiliesSupplier.is())
+ return;
+
uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameContainer> xParagraphStyles = xStyleFamilies->getByName("ParagraphStyles").get< uno::Reference<container::XNameContainer> >();
uno::Reference<style::XStyle> xDefault = xParagraphStyles->getByName("Standard").get< uno::Reference<style::XStyle> >();
uno::Reference<beans::XPropertyState> xPropertyState(xDefault, uno::UNO_QUERY);
- if (xPropertyState->getPropertyState("ParaIsHyphenation") == beans::PropertyState_DEFAULT_VALUE)
+ if (m_pImpl->m_bAutoHyphenation && lcl_isDefault(xPropertyState, "ParaIsHyphenation"))
{
uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
xPropertySet->setPropertyValue("ParaIsHyphenation", uno::makeAny(true));
}
+ if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, "ParaWidows") && lcl_isDefault(xPropertyState, "ParaOrphans"))
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
+ uno::Any aAny = uno::makeAny(static_cast<sal_Int8>(2));
+ xPropertySet->setPropertyValue("ParaWidows", aAny);
+ xPropertySet->setPropertyValue("ParaOrphans", aAny);
+ }
}
}
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index df0ae0e..9a8c4d0 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -60,6 +60,10 @@
<token tokenid="ooxml:footerl"/>
<token tokenid="ooxml:footerr"/>
<token tokenid="ooxml:footerf"/>
+
+ <!-- Present in RTF, but not in OOXML. -->
+ <token tokenid="ooxml:CT_Settings_widowControl"/>
+
<namespace name="dml-stylesheet">
<start name="theme"/>
<start name="themeOverride"/>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7fe58a7..43c73c2 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3514,6 +3514,9 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_SAUTOUPD:
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_autoRedefine, std::make_shared<RTFValue>(1));
break;
+ case RTF_WIDOWCTRL:
+ m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_widowControl, std::make_shared<RTFValue>(1));
+ break;
default:
{
SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
More information about the Libreoffice-commits
mailing list