tdf#60242 remember horizontal/vertical choice in split cells dialog

Change-Id: I25f6b7c8ff6aa678b597bbede0dd1492468f2f62
Reviewed-on: https://gerrit.libreoffice.org/65606
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/cui/source/dialogs/splitcelldlg.cxx b/cui/source/dialogs/splitcelldlg.cxx
index 903c998..6c9a744 100644
--- a/cui/source/dialogs/splitcelldlg.cxx
+++ b/cui/source/dialogs/splitcelldlg.cxx
@@ -83,4 +83,10 @@ short SvxSplitTableDlg::Execute()
    return run();
}

void SvxSplitTableDlg::SetSplitVerticalByDefault()
{
    if( mnMaxVertical >= 2 )
        m_xVertBox->set_active(true); // tdf#60242
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/splitcelldlg.hxx b/cui/source/inc/splitcelldlg.hxx
index 9b4c1f34..b0c2fdd 100644
--- a/cui/source/inc/splitcelldlg.hxx
+++ b/cui/source/inc/splitcelldlg.hxx
@@ -43,6 +43,7 @@ public:
    virtual long GetCount() const override;

    virtual short Execute() override;
    virtual void SetSplitVerticalByDefault() override;
};

#endif
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 8547dc3..2a50a9c 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -295,6 +295,7 @@ public:
    virtual bool IsHorizontal() const = 0;
    virtual bool IsProportional() const = 0;
    virtual long GetCount() const = 0;
    virtual void SetSplitVerticalByDefault() = 0;
};

class SvxAbstractNewTableDialog : public VclAbstractDialog
diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index d18a546..3b147dc 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -2308,6 +2308,13 @@
          </info>
          <value>true</value>
        </prop>
        <prop oor:name="SplitVerticalByDefault" oor:type="xs:boolean" oor:nillable="false">
          <info>
            <desc>Specifies whether cells should be split vertically by default.</desc>
            <label>Split vertically by default</label>
          </info>
          <value>false</value>
        </prop>
      </group>
    </group>
    <group oor:name="Cursor">
diff --git a/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs b/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs
index cd65511..9177514 100644
--- a/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs
@@ -869,6 +869,13 @@
          </info>
          <value>false</value>
        </prop>
        <prop oor:name="SplitVerticalByDefault" oor:type="xs:boolean" oor:nillable="false">
          <info>
            <desc>Specifies whether cells should be split vertically by default.</desc>
            <label>Split vertically by default</label>
          </info>
          <value>false</value>
        </prop>
      </group>
    </group>
    <group oor:name="Insert">
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 3ebbec5..9bba13e 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1197,6 +1197,8 @@ public:
    bool IsInsTableFormatNum() const;
    bool IsInsTableChangeNumFormat() const;
    bool IsInsTableAlignNum() const;
    bool IsSplitVerticalByDefault() const;
    void SetSplitVerticalByDefault(bool value);

    // From FEShell (for Undo and BModified).
    static void GetTabCols( SwTabCols &rFill, const SwCellFrame* pBoxFrame );
diff --git a/sw/inc/modcfg.hxx b/sw/inc/modcfg.hxx
index 550cb1c..795d1f3 100644
--- a/sw/inc/modcfg.hxx
+++ b/sw/inc/modcfg.hxx
@@ -155,6 +155,7 @@ class SwTableConfig : public utl::ConfigItem
    bool    m_bInsTableFormatNum;       // Table/Input/NumberRecognition        // Automatic recognition of numbers.
    bool    m_bInsTableChangeNumFormat; // Table/Input/NumberFormatRecognition  // Automatic recognition of number formats.
    bool    m_bInsTableAlignNum;        // Table/Input/Alignment                // Align numbers.
    bool    m_bSplitVerticalByDefault;  // Table/Input/SplitVerticalByDefault   // Split vertical by default.

    static const css::uno::Sequence<OUString>& GetPropertyNames();

@@ -303,6 +304,13 @@ public:
                    config.m_aInsTableOpts = rOpts;
                    config.SetModified();}

    bool        IsSplitVerticalByDefault(bool bHTML) const
                    { return bHTML ? m_aWebTableConfig.m_bSplitVerticalByDefault : m_aTableConfig.m_bSplitVerticalByDefault; }
    void        SetSplitVerticalByDefault(bool bHTML, bool b)
                    { auto & config = bHTML ? m_aWebTableConfig : m_aTableConfig;
                      config.m_bSplitVerticalByDefault = b;
                      config.SetModified();}

    const InsCaptionOpt* GetCapOption(bool bHTML, const SwCapObjType eType, const SvGlobalName *pOleId);
    bool        SetCapOption(bool bHTML, const InsCaptionOpt* pOpt);

diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index eec00ab..4e4577f3 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -191,6 +191,8 @@ public:
    bool            IsInsTableFormatNum(bool bHTML) const;
    bool            IsInsTableChangeNumFormat(bool bHTML) const;
    bool            IsInsTableAlignNum(bool bHTML) const;
    bool            IsSplitVerticalByDefault(bool bHTML) const;
    void            SetSplitVerticalByDefault(bool bHTML, bool value);

    // Redlining.
    std::size_t         GetRedlineAuthor();
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index fb544a7..d25cf80 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1706,6 +1706,16 @@ bool SwDoc::IsInsTableAlignNum() const
    return SW_MOD()->IsInsTableAlignNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
}

bool SwDoc::IsSplitVerticalByDefault() const
{
    return SW_MOD()->IsSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
}

void SwDoc::SetSplitVerticalByDefault(bool value)
{
    SW_MOD()->SetSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE), value);
}

/// Set up the InsertDB as Undo table
void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable )
{
diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx
index a76477b..1d9c83a 100644
--- a/sw/source/uibase/app/swmodul1.cxx
+++ b/sw/source/uibase/app/swmodul1.cxx
@@ -572,6 +572,16 @@ bool SwModule::IsInsTableAlignNum(bool bHTML) const
    return m_pModuleConfig->IsInsTableAlignNum(bHTML);
}

bool SwModule::IsSplitVerticalByDefault(bool bHTML) const
{
    return m_pModuleConfig->IsSplitVerticalByDefault(bHTML);
}

void SwModule::SetSplitVerticalByDefault(bool bHTML, bool value)
{
    m_pModuleConfig->SetSplitVerticalByDefault(bHTML, value);
}

const Color &SwModule::GetRedlineMarkColor()
{
    return m_pModuleConfig->GetMarkAlignColor();
diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx
index ea2d83b..7c9a027 100644
--- a/sw/source/uibase/config/modcfg.cxx
+++ b/sw/source/uibase/config/modcfg.cxx
@@ -1075,7 +1075,8 @@ const Sequence<OUString>& SwTableConfig::GetPropertyNames()
        "Change/Effect",                //  4
        "Input/NumberRecognition",      //  5
        "Input/NumberFormatRecognition",//  6
        "Input/Alignment"               //  7
        "Input/Alignment",              //  7
        "Input/SplitVerticalByDefault"  //  8
    };
    return aNames;
}
@@ -1091,6 +1092,7 @@ SwTableConfig::SwTableConfig(bool bWeb)
    , m_bInsTableFormatNum(false)
    , m_bInsTableChangeNumFormat(false)
    , m_bInsTableAlignNum(false)
    , m_bSplitVerticalByDefault(false)
{
    Load();
}
@@ -1119,6 +1121,7 @@ void SwTableConfig::ImplCommit()
            case 5 : pValues[nProp] <<= m_bInsTableFormatNum; break;  //"Input/NumberRecognition",
            case 6 : pValues[nProp] <<= m_bInsTableChangeNumFormat; break;  //"Input/NumberFormatRecognition",
            case 7 : pValues[nProp] <<= m_bInsTableAlignNum; break;  //"Input/Alignment"
            case 8 : pValues[nProp] <<= m_bSplitVerticalByDefault; break;  //"Input/SplitVerticalByDefault"
        }
    }
    PutProperties(aNames, aValues);
@@ -1145,6 +1148,7 @@ void SwTableConfig::Load()
                case 5 : m_bInsTableFormatNum = *o3tl::doAccess<bool>(pValues[nProp]);  break;  //"Input/NumberRecognition",
                case 6 : m_bInsTableChangeNumFormat = *o3tl::doAccess<bool>(pValues[nProp]); break;  //"Input/NumberFormatRecognition",
                case 7 : m_bInsTableAlignNum = *o3tl::doAccess<bool>(pValues[nProp]); break;  //"Input/Alignment"
                case 8 : m_bSplitVerticalByDefault = *o3tl::doAccess<bool>(pValues[nProp]); break;  //"Input/SplitVerticalByDefault"
            }
        }
    }
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 0a9ee03..7d01662 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -115,6 +115,9 @@ public:
    void EndDrag      (const Point* pPt, bool bProp) { (this->*m_fnEndDrag)(pPt, bProp); }
    long KillSelection(const Point* pPt, bool bProp) { return (this->*m_fnKillSel)(pPt, bProp); }

    bool IsSplitVerticalByDefault() const;
    void SetSplitVerticalByDefault(bool value);

    // reset all selections
    long ResetSelect( const Point *, bool );

diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 54f6b9d..4333c01 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -985,6 +985,8 @@ void SwTableShell::Execute(SfxRequest &rReq)
                SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                const long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
                ScopedVclPtr<SvxAbstractSplitTableDialog> pDlg(pFact->CreateSvxSplitTableDialog(GetView().GetFrameWeld(), rSh.IsTableVertical(), nMaxVert));
                if(rSh.IsSplitVerticalByDefault())
                    pDlg->SetSplitVerticalByDefault();
                if( pDlg->Execute() == RET_OK )
                {
                    nCount = pDlg->GetCount();
@@ -993,6 +995,10 @@ void SwTableShell::Execute(SfxRequest &rReq)
                    rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
                    rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
                    rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );

                    // tdf#60242: remember choice for next time
                    bool bVerticalWasChecked = !pDlg->IsHorizontal();
                    rSh.SetSplitVerticalByDefault(bVerticalWasChecked);
                }
            }

diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index e2739a2..88db013 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -364,6 +364,16 @@ long SwWrtShell::ResetSelect(const Point *,bool)
    return 1;
}

bool SwWrtShell::IsSplitVerticalByDefault() const
{
    return GetDoc()->IsSplitVerticalByDefault();
}

void SwWrtShell::SetSplitVerticalByDefault(bool value)
{
    GetDoc()->SetSplitVerticalByDefault(value);
}

// Do nothing

long SwWrtShell::Ignore(const Point *, bool ) {