[Libreoffice-commits] core.git: solenv/clang-format writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 15 13:27:43 UTC 2019


 solenv/clang-format/blacklist             |    2 
 writerfilter/source/dmapper/SdtHelper.cxx |   75 ++++++++++++++++--------------
 writerfilter/source/dmapper/SdtHelper.hxx |   40 ++++------------
 3 files changed, 52 insertions(+), 65 deletions(-)

New commits:
commit 6dc2e26e0103137863f4e2d8c1f0c6511b164b66
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jul 15 11:49:15 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jul 15 15:26:36 2019 +0200

    writerfilter: turn on clang-format for SdtHelper
    
    This had manual consistent formatting. Recently it was broken, so bring
    back consistency by using clang-format.
    
    Change-Id: I1e4c127b20a2755cda72a35110b6ef8413bac548
    Reviewed-on: https://gerrit.libreoffice.org/75621
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 148665c29dfc..a069e3b1208f 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -18449,8 +18449,6 @@ writerfilter/source/dmapper/PropertyMap.cxx
 writerfilter/source/dmapper/PropertyMap.hxx
 writerfilter/source/dmapper/PropertyMapHelper.cxx
 writerfilter/source/dmapper/PropertyMapHelper.hxx
-writerfilter/source/dmapper/SdtHelper.cxx
-writerfilter/source/dmapper/SdtHelper.hxx
 writerfilter/source/dmapper/SectionColumnHandler.cxx
 writerfilter/source/dmapper/SectionColumnHandler.hxx
 writerfilter/source/dmapper/SettingsTable.cxx
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index 46b8911a0ac0..772f4b9b9504 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -30,11 +30,11 @@ namespace writerfilter
 {
 namespace dmapper
 {
-
 using namespace ::com::sun::star;
 
 /// w:sdt's w:dropDownList doesn't have width, so guess the size based on the longest string.
-static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUString const& rDefault, std::vector<OUString>& rItems)
+static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet,
+                                     OUString const& rDefault, std::vector<OUString>& rItems)
 {
     OUString aLongest = rDefault;
     sal_Int32 nHeight = 0;
@@ -48,10 +48,12 @@ static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUSt
 
     PropertyMapPtr pDefaultCharProps = pStyleSheet->GetDefaultCharProps();
     vcl::Font aFont(pOut->GetFont());
-    boost::optional<PropertyMap::Property> aFontName = pDefaultCharProps->getProperty(PROP_CHAR_FONT_NAME);
+    boost::optional<PropertyMap::Property> aFontName
+        = pDefaultCharProps->getProperty(PROP_CHAR_FONT_NAME);
     if (aFontName)
         aFont.SetFamilyName(aFontName->second.get<OUString>());
-    boost::optional<PropertyMap::Property> aHeight = pDefaultCharProps->getProperty(PROP_CHAR_HEIGHT);
+    boost::optional<PropertyMap::Property> aHeight
+        = pDefaultCharProps->getProperty(PROP_CHAR_HEIGHT);
     if (aHeight)
     {
         nHeight = aHeight->second.get<double>() * 35; // points -> mm100
@@ -68,7 +70,7 @@ static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet, OUSt
     sal_Int32 nBorder = nHeight / 2;
 
     // Width: space for the text + the square having the dropdown arrow.
-    return {nWidth + nBorder + nHeight, nHeight + nBorder};
+    return { nWidth + nBorder + nHeight, nHeight + nBorder };
 }
 
 SdtHelper::SdtHelper(DomainMapper_Impl& rDM_Impl)
@@ -83,14 +85,18 @@ SdtHelper::~SdtHelper() = default;
 void SdtHelper::createDropDownControl()
 {
     OUString aDefaultText = m_aSdtTexts.makeStringAndClear();
-    uno::Reference<awt::XControlModel> xControlModel(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.form.component.ComboBox"), uno::UNO_QUERY);
+    uno::Reference<awt::XControlModel> xControlModel(
+        m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.form.component.ComboBox"),
+        uno::UNO_QUERY);
     uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY);
     xPropertySet->setPropertyValue("DefaultText", uno::makeAny(aDefaultText));
     xPropertySet->setPropertyValue("Dropdown", uno::makeAny(true));
-    xPropertySet->setPropertyValue("StringItemList", uno::makeAny(comphelper::containerToSequence(m_aDropDownItems)));
+    xPropertySet->setPropertyValue("StringItemList",
+                                   uno::makeAny(comphelper::containerToSequence(m_aDropDownItems)));
 
-    createControlShape(lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), aDefaultText, m_aDropDownItems),
-                       xControlModel, uno::Sequence<beans::PropertyValue>());
+    createControlShape(
+        lcl_getOptimalWidth(m_rDM_Impl.GetStyleSheetTable(), aDefaultText, m_aDropDownItems),
+        xControlModel, uno::Sequence<beans::PropertyValue>());
     m_aDropDownItems.clear();
 }
 
@@ -101,11 +107,11 @@ bool SdtHelper::validateDateFormat()
 
 void SdtHelper::createDateContentControl(bool bInsideTable)
 {
-    if(!m_xDateFieldStartRange.is())
+    if (!m_xDateFieldStartRange.is())
         return;
 
     uno::Reference<text::XTextCursor> xCrsr;
-    if(m_rDM_Impl.HasTopText())
+    if (m_rDM_Impl.HasTopText())
     {
         uno::Reference<text::XTextAppend> xTextAppend = m_rDM_Impl.GetTopTextAppend();
         if (xTextAppend.is())
@@ -118,37 +124,40 @@ void SdtHelper::createDateContentControl(bool bInsideTable)
         try
         {
             xCrsr->gotoRange(m_xDateFieldStartRange, false);
-            if(bInsideTable)
+            if (bInsideTable)
                 xCrsr->goRight(1, false);
             xCrsr->gotoEnd(true);
         }
-        catch (uno::Exception&) {
+        catch (uno::Exception&)
+        {
             OSL_ENSURE(false, "Cannot get the right text range for date field");
             return;
         }
 
-        uno::Reference< uno::XInterface > xFieldInterface;
-        xFieldInterface = m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.text.Fieldmark");
-        uno::Reference< text::XFormField > xFormField( xFieldInterface, uno::UNO_QUERY );
-        uno::Reference< text::XTextContent > xToInsert(xFormField, uno::UNO_QUERY);
-        if ( xFormField.is() && xToInsert.is() )
+        uno::Reference<uno::XInterface> xFieldInterface;
+        xFieldInterface
+            = m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.text.Fieldmark");
+        uno::Reference<text::XFormField> xFormField(xFieldInterface, uno::UNO_QUERY);
+        uno::Reference<text::XTextContent> xToInsert(xFormField, uno::UNO_QUERY);
+        if (xFormField.is() && xToInsert.is())
         {
-            xToInsert->attach( uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ));
+            xToInsert->attach(uno::Reference<text::XTextRange>(xCrsr, uno::UNO_QUERY_THROW));
             xFormField->setFieldType(ODF_FORMDATE);
             uno::Reference<container::XNameContainer> xNameCont = xFormField->getParameters();
-            if(xNameCont.is())
+            if (xNameCont.is())
             {
                 OUString sDateFormat = m_sDateFormat.makeStringAndClear();
                 // Replace quotation mark used for marking static strings in date format
                 sDateFormat = sDateFormat.replaceAll("'", "\"");
                 xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT, uno::makeAny(sDateFormat));
-                xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT_LANGUAGE, uno::makeAny(m_sLocale.makeStringAndClear()));
+                xNameCont->insertByName(ODF_FORMDATE_DATEFORMAT_LANGUAGE,
+                                        uno::makeAny(m_sLocale.makeStringAndClear()));
             }
             OUString sFullDate = m_sDate.makeStringAndClear();
-            if(!sFullDate.isEmpty())
+            if (!sFullDate.isEmpty())
             {
                 sal_Int32 nTimeSep = sFullDate.indexOf("T");
-                if(nTimeSep != -1)
+                if (nTimeSep != -1)
                     sFullDate = sFullDate.copy(0, nTimeSep);
                 xNameCont->insertByName(ODF_FORMDATE_CURRENTDATE, uno::makeAny(sFullDate));
             }
@@ -156,9 +165,13 @@ void SdtHelper::createDateContentControl(bool bInsideTable)
     }
 }
 
-void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControlModel> const& xControlModel, const uno::Sequence<beans::PropertyValue>& rGrabBag)
+void SdtHelper::createControlShape(awt::Size aSize,
+                                   uno::Reference<awt::XControlModel> const& xControlModel,
+                                   const uno::Sequence<beans::PropertyValue>& rGrabBag)
 {
-    uno::Reference<drawing::XControlShape> xControlShape(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY);
+    uno::Reference<drawing::XControlShape> xControlShape(
+        m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.drawing.ControlShape"),
+        uno::UNO_QUERY);
     xControlShape->setSize(aSize);
     xControlShape->setControl(xControlModel);
 
@@ -169,7 +182,7 @@ void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControl
         xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG, uno::makeAny(rGrabBag));
 
     uno::Reference<text::XTextContent> xTextContent(xControlShape, uno::UNO_QUERY);
-    m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence< beans::PropertyValue >());
+    m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence<beans::PropertyValue>());
     m_bHasElements = true;
 }
 
@@ -185,15 +198,9 @@ uno::Sequence<beans::PropertyValue> SdtHelper::getInteropGrabBagAndClear()
     return aRet;
 }
 
-bool SdtHelper::isInteropGrabBagEmpty()
-{
-    return m_aGrabBag.empty();
-}
+bool SdtHelper::isInteropGrabBagEmpty() { return m_aGrabBag.empty(); }
 
-sal_Int32 SdtHelper::getInteropGrabBagSize()
-{
-    return m_aGrabBag.size();
-}
+sal_Int32 SdtHelper::getInteropGrabBagSize() { return m_aGrabBag.size(); }
 
 bool SdtHelper::containedInInteropGrabBag(const OUString& rValueName)
 {
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx
index 5efb397edd8a..ac12d70ea86d 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -69,29 +69,20 @@ class SdtHelper final : public virtual SvRefBase
     bool m_bOutsideAParagraph;
 
     /// Create and append the drawing::XControlShape, containing the various models.
-    void createControlShape(css::awt::Size aSize, css::uno::Reference<css::awt::XControlModel> const& xControlModel, const css::uno::Sequence<css::beans::PropertyValue>& rGrabBag);
+    void createControlShape(css::awt::Size aSize,
+                            css::uno::Reference<css::awt::XControlModel> const& xControlModel,
+                            const css::uno::Sequence<css::beans::PropertyValue>& rGrabBag);
+
 public:
     explicit SdtHelper(DomainMapper_Impl& rDM_Impl);
     ~SdtHelper() override;
 
-    std::vector<OUString>& getDropDownItems()
-    {
-        return m_aDropDownItems;
-    }
-    OUStringBuffer& getSdtTexts()
-    {
-        return m_aSdtTexts;
-    }
+    std::vector<OUString>& getDropDownItems() { return m_aDropDownItems; }
+    OUStringBuffer& getSdtTexts() { return m_aSdtTexts; }
 
-    OUStringBuffer& getDate()
-    {
-        return m_sDate;
-    }
+    OUStringBuffer& getDate() { return m_sDate; }
 
-    OUStringBuffer& getDateFormat()
-    {
-        return m_sDateFormat;
-    }
+    OUStringBuffer& getDateFormat() { return m_sDateFormat; }
 
     void setDateFieldStartRange(const css::uno::Reference<css::text::XTextRange>& xStartRange)
     {
@@ -101,25 +92,16 @@ public:
     /// Decides if we have enough information to create a date control.
     bool validateDateFormat();
 
-    OUStringBuffer& getLocale()
-    {
-        return m_sLocale;
-    }
+    OUStringBuffer& getLocale() { return m_sLocale; }
     /// If createControlShape() was ever called.
-    bool hasElements()
-    {
-        return m_bHasElements;
-    }
+    bool hasElements() { return m_bHasElements; }
 
     void setOutsideAParagraph(bool bOutsideAParagraph)
     {
         m_bOutsideAParagraph = bOutsideAParagraph;
     }
 
-    bool isOutsideAParagraph()
-    {
-        return m_bOutsideAParagraph;
-    }
+    bool isOutsideAParagraph() { return m_bOutsideAParagraph; }
 
     /// Create drop-down control from w:sdt's w:dropDownList.
     void createDropDownControl();


More information about the Libreoffice-commits mailing list