[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Mon Jun 12 09:56:25 UTC 2017


 sw/inc/crstate.hxx                          |    6 +++--
 sw/source/core/crsr/crstrvl.cxx             |   16 +++++++++++---
 sw/source/core/text/frmcrsr.cxx             |   16 ++++++++++++++
 sw/source/ui/config/optpage.cxx             |    7 ++++++
 sw/source/ui/dbui/mmlayoutpage.cxx          |    2 -
 sw/source/uibase/inc/optpage.hxx            |    1 
 sw/uiconfig/swriter/ui/optformataidspage.ui |   30 +++++++++++++++++++++-------
 7 files changed, 63 insertions(+), 15 deletions(-)

New commits:
commit 23cf6dbe4d35d0d9beeaa2193247c6f67a869c66
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Mon Jun 12 09:31:03 2017 +0200

    tdf#108427 Direct cursor: Add option to insert only spaces
    
    Change-Id: I1136688ec8af44c533f4dd40a9a4b24ea59992ef
    Reviewed-on: https://gerrit.libreoffice.org/38685
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx
index 8c361dee61fc..71a3a7868dcb 100644
--- a/sw/inc/crstate.hxx
+++ b/sw/inc/crstate.hxx
@@ -27,7 +27,8 @@
 enum SwFillMode
 {
     FILL_TAB,       ///< default, fill with tabs
-    FILL_SPACE,     ///< fill with spaces and tabs
+    FILL_TAB_SPACE, ///< fill with spaces and tabs
+    FILL_SPACE,     ///< fill with spaces
     FILL_MARGIN,    ///< only align left, center, right
     FILL_INDENT     ///< by left paragraph indention
 };
@@ -38,11 +39,12 @@ struct SwFillCursorPos
     sal_uInt16 nParaCnt;        ///< number of paragraphs to insert
     sal_uInt16 nTabCnt;         ///< number of tabs respectively size of indentation
     sal_uInt16 nSpaceCnt;       ///< number of spaces to insert
+    sal_uInt16 nSpaceOnlyCnt;   ///< number of spaces to insert ("only spaces, no tabs" mode)
     sal_uInt16 nColumnCnt;      ///< number of necessary column breaks
     sal_Int16  eOrient;      ///< paragraph alignment
     SwFillMode eMode;       ///< desired fill-up rule
     SwFillCursorPos( SwFillMode eMd ) :
-        nParaCnt( 0 ), nTabCnt( 0 ), nSpaceCnt( 0 ), nColumnCnt( 0 ),
+        nParaCnt( 0 ), nTabCnt( 0 ), nSpaceCnt( 0 ), nSpaceOnlyCnt(0), nColumnCnt( 0 ),
         eOrient( css::text::HoriOrientation::NONE ), eMode( eMd )
     {}
 };
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 0dd9819023a5..ccd662d67f13 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1950,13 +1950,21 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
                 break;
 
             case FILL_TAB:
+            case FILL_TAB_SPACE:
             case FILL_SPACE:
                 {
                     OUStringBuffer sInsert;
-                    if (aFPos.nTabCnt)
-                        comphelper::string::padToLength(sInsert, aFPos.nTabCnt, '\t');
-                    if (aFPos.nSpaceCnt)
-                        comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
+                    if (aFPos.eMode == FILL_SPACE)
+                    {
+                        comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceOnlyCnt, ' ');
+                    }
+                    else
+                    {
+                        if (aFPos.nTabCnt)
+                            comphelper::string::padToLength(sInsert, aFPos.nTabCnt, '\t');
+                        if (aFPos.nSpaceCnt)
+                            comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
+                    }
                     if (!sInsert.isEmpty())
                         GetDoc()->getIDocumentContentOperations().InsertString( *m_pCurrentCursor, sInsert.makeStringAndClear());
                 }
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 4481a5cb129b..dd448aab7b9f 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -538,6 +538,7 @@ struct SwFillData
     SwFillCursorPos &Fill() const { return *pCMS->m_pFill; }
     void SetTab( sal_uInt16 nNew ) { pCMS->m_pFill->nTabCnt = nNew; }
     void SetSpace( sal_uInt16 nNew ) { pCMS->m_pFill->nSpaceCnt = nNew; }
+    void SetSpaceOnly( sal_uInt16 nNew ) { pCMS->m_pFill->nSpaceOnlyCnt = nNew; }
     void SetOrient( const sal_Int16 eNew ){ pCMS->m_pFill->eOrient = eNew; }
 };
 
@@ -1508,6 +1509,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                     SwTwips nLeftTab;
                     SwTwips nRightTab = nLeft;
                     sal_uInt16 nSpaceCnt = 0;
+                    sal_uInt16 nSpaceOnlyCnt = 0;
                     sal_uInt16 nTabCnt = 0;
                     sal_uInt16 nIdx = 0;
                     do
@@ -1551,7 +1553,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                     }
                     while( rFill.X() > nRightTab );
                     --nTabCnt;
-                    if( FILL_TAB != rFill.Mode() )
+                    if( FILL_TAB_SPACE == rFill.Mode() )
                     {
                         if( nSpace > 0 )
                         {
@@ -1602,6 +1604,16 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                             }
                         }
                     }
+                    else if( FILL_SPACE == rFill.Mode() )
+                    {
+                        SwTwips nLeftSpace = nLeft;
+                        while( nLeftSpace < rFill.X() )
+                        {
+                            nLeftSpace += nSpace;
+                            ++nSpaceOnlyCnt;
+                        }
+                        rRect.Left( nLeftSpace );
+                    }
                     else
                     {
                         if( rFill.X() - nLeftTab < nRightTab - rFill.X() )
@@ -1624,6 +1636,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                     }
                     rFill.SetTab( nTabCnt );
                     rFill.SetSpace( nSpaceCnt );
+                    rFill.SetSpaceOnly( nSpaceOnlyCnt );
                     if( bFill )
                     {
                         if( std::abs( rFill.X() - nCenter ) <=
@@ -1632,6 +1645,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                             rFill.SetOrient( text::HoriOrientation::CENTER );
                             rFill.SetTab( 0 );
                             rFill.SetSpace( 0 );
+                            rFill.SetSpaceOnly( 0 );
                             rRect.Left( nCenter );
                         }
                         if( !rFill.bEmpty )
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index b78e70fc5936..8c6306eb839b 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1327,6 +1327,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage( vcl::Window* pParent,
     get(m_pFillMarginRB, "fillmargin");
     get(m_pFillIndentRB, "fillindent");
     get(m_pFillTabRB, "filltab");
+    get(m_pFillTabAndSpaceRB, "filltabandspace");
     get(m_pFillSpaceRB, "fillspace");
 
     get(m_pCursorProtFrame, "crsrprotframe");
@@ -1346,6 +1347,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage( vcl::Window* pParent,
     m_pFillMarginRB->Check( FILL_MARGIN == eMode );
     m_pFillTabRB->Check( FILL_TAB == eMode );
     m_pFillSpaceRB->Check( FILL_SPACE == eMode );
+    m_pFillTabAndSpaceRB->Check( FILL_TAB_SPACE == eMode );
 
     if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem )
         && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
@@ -1361,6 +1363,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage( vcl::Window* pParent,
         m_pFillIndentRB->Hide();
         m_pFillTabRB->Hide();
         m_pFillSpaceRB->Hide();
+        m_pFillTabAndSpaceRB->Hide();
 
         m_pCursorProtFrame->Hide();
         m_pCursorInProtCB->Hide();
@@ -1389,6 +1392,7 @@ void SwShdwCursorOptionsTabPage::dispose()
     m_pFillIndentRB.clear();
     m_pFillTabRB.clear();
     m_pFillSpaceRB.clear();
+    m_pFillTabAndSpaceRB.clear();
     m_pCursorProtFrame.clear();
     m_pCursorInProtCB.clear();
     m_pMathBaselineAlignmentCB.clear();
@@ -1419,6 +1423,8 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
         eMode = FILL_MARGIN;
     else if( m_pFillTabRB->IsChecked() )
         eMode = FILL_TAB;
+    else if ( m_pFillTabAndSpaceRB->IsChecked() )
+        eMode = FILL_TAB_SPACE;
     else
         eMode = FILL_SPACE;
     aOpt.SetMode( eMode );
@@ -1482,6 +1488,7 @@ void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
     m_pFillMarginRB->Check( FILL_MARGIN == eMode );
     m_pFillTabRB->Check( FILL_TAB == eMode );
     m_pFillSpaceRB->Check( FILL_SPACE == eMode );
+    m_pFillTabAndSpaceRB->Check( FILL_TAB_SPACE == eMode );
 
     if (m_pWrtShell) {
        m_pMathBaselineAlignmentCB->Check( m_pWrtShell->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ) );
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 721a51b883be..6392e8418a72 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -423,7 +423,7 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
     const SwRect& rPageRect = rShell.GetAnyCurRect(CurRectType::Page);
     const Point aGreetingPos( DEFAULT_LEFT_DISTANCE + rPageRect.Left(), GREETING_TOP_DISTANCE );
 
-    const bool bRet = rShell.SetShadowCursorPos( aGreetingPos, FILL_SPACE );
+    const bool bRet = rShell.SetShadowCursorPos( aGreetingPos, FILL_TAB_SPACE );
 
     if(!bRet)
     {
diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx
index 71c2330cf2f2..c770edf18bb2 100644
--- a/sw/source/uibase/inc/optpage.hxx
+++ b/sw/source/uibase/inc/optpage.hxx
@@ -251,6 +251,7 @@ class SwShdwCursorOptionsTabPage : public SfxTabPage
     VclPtr<RadioButton> m_pFillMarginRB;
     VclPtr<RadioButton> m_pFillIndentRB;
     VclPtr<RadioButton> m_pFillTabRB;
+    VclPtr<RadioButton> m_pFillTabAndSpaceRB;
     VclPtr<RadioButton> m_pFillSpaceRB;
 
     VclPtr<VclFrame> m_pCursorProtFrame;
diff --git a/sw/uiconfig/swriter/ui/optformataidspage.ui b/sw/uiconfig/swriter/ui/optformataidspage.ui
index 0af1f6edbf94..84bba183cc1c 100644
--- a/sw/uiconfig/swriter/ui/optformataidspage.ui
+++ b/sw/uiconfig/swriter/ui/optformataidspage.ui
@@ -177,7 +177,7 @@
                           <object class="GtkLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label" translatable="no">¶</property>
+                            <property name="label">¶</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -188,7 +188,7 @@
                           <object class="GtkLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label" translatable="no">-</property>
+                            <property name="label">-</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -199,7 +199,7 @@
                           <object class="GtkLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label" translatable="no">·</property>
+                            <property name="label">·</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -210,7 +210,7 @@
                           <object class="GtkLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label" translatable="no">→</property>
+                            <property name="label">→</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -221,7 +221,7 @@
                           <object class="GtkLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label" translatable="no">↵</property>
+                            <property name="label">↵</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -422,7 +422,7 @@
                                     <property name="use_underline">True</property>
                                     <property name="xalign">0</property>
                                     <property name="draw_indicator">True</property>
-                                    <property name="group">fillspace</property>
+                                    <property name="group">filltabandspace</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">0</property>
@@ -430,7 +430,7 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkRadioButton" id="fillspace">
+                                  <object class="GtkRadioButton" id="filltabandspace">
                                     <property name="label" translatable="yes">Tabs a_nd spaces</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
@@ -445,6 +445,22 @@
                                     <property name="top_attach">3</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <object class="GtkRadioButton" id="fillspace">
+                                    <property name="label" translatable="yes">_Spaces</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="draw_indicator">True</property>
+                                    <property name="group">fillmargin</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">0</property>
+                                    <property name="top_attach">4</property>
+                                  </packing>
+                                </child>
                               </object>
                             </child>
                           </object>


More information about the Libreoffice-commits mailing list