convert annotation page break menu to .ui

Change-Id: I822029c8fe2dc8ae0a0f52091375d79c0784b7ce
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 41fed85..81d0736 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -211,6 +211,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
	sw/uiconfig/swriter/ui/notebookbar \
	sw/uiconfig/swriter/ui/notebookbar_groups \
	sw/uiconfig/swriter/ui/notebookbar_single \
	sw/uiconfig/swriter/ui/pagebreakmenu \
	sw/uiconfig/swriter/ui/pagecolumncontrol \
	sw/uiconfig/swriter/ui/pagemargincontrol \
	sw/uiconfig/swriter/ui/pageorientationcontrol \
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 74ac12b..9e718b8 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -715,9 +715,6 @@
#define FN_HEADERFOOTER_DELETE      (FN_HEADERFOOTER+2)
#define FN_HEADERFOOTER_BORDERBACK  (FN_HEADERFOOTER+3)

#define FN_PAGEBREAK_EDIT           (FN_PAGEBREAK+1)
#define FN_PAGEBREAK_DELETE         (FN_PAGEBREAK+2)

// Region: Parameter
#define FN_PARAM_MOVE_COUNT         (FN_PARAM+2)
#define FN_PARAM_MOVE_SELECTION     (FN_PARAM+3)
diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h
index fdcff07..d1ad3e7 100644
--- a/sw/inc/swcommands.h
+++ b/sw/inc/swcommands.h
@@ -35,8 +35,6 @@
#define CMD_FN_HEADERFOOTER_EDIT                    ".uno:HeaderFooterEdit"
#define CMD_FN_HEADERFOOTER_DELETE                  ".uno:HeaderFooterDelete"
#define CMD_FN_HEADERFOOTER_BORDERBACK              ".uno:HeaderFooterBorderBackground"
#define CMD_FN_PAGEBREAK_EDIT                       ".uno:PageBreakEdit"
#define CMD_FN_PAGEBREAK_DELETE                     ".uno:PageBreakDelete"

#endif

diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index d6dac73..fe71b4d 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -112,23 +112,4 @@ Menu MN_HEADERFOOTER_BUTTON
    };
};

Menu MN_PAGEBREAK_BUTTON
{
    ItemList =
    {
        MenuItem
        {
            Identifier = FN_PAGEBREAK_EDIT ;
            HelpID = CMD_FN_PAGEBREAK_EDIT ;
            Text [ en-US ] = "Edit Page Break..." ;
        };
        MenuItem
        {
            Identifier = FN_PAGEBREAK_DELETE ;
            HelpID = CMD_FN_PAGEBREAK_DELETE ;
            Text [ en-US ] = "Delete Page Break" ;
        };
    };
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx
index dcf4b08..10b9171 100644
--- a/sw/source/uibase/docvw/PageBreakWin.cxx
+++ b/sw/source/uibase/docvw/PageBreakWin.cxx
@@ -93,7 +93,8 @@ namespace

SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwFrame *pFrame ) :
    SwFrameMenuButtonBase( pEditWin, pFrame ),
    m_pPopupMenu( nullptr ),
    m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/pagebreakmenu.ui", ""),
    m_pPopupMenu(m_aBuilder.get_menu("menu")),
    m_pLine( nullptr ),
    m_bIsAppearing( false ),
    m_nFadeRate( 100 ),
@@ -107,10 +108,9 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwFrame *pFrame ) :
    // Create the line control
    m_pLine = VclPtr<SwBreakDashedLine>::Create( GetEditWin(), &SwViewOption::GetPageBreakColor, this );

    // Create the popup menu
    m_pPopupMenu = VclPtr<PopupMenu>::Create( SW_RES( MN_PAGEBREAK_BUTTON ) );
    // Set the popup menu
    m_pPopupMenu->SetDeactivateHdl( LINK( this, SwPageBreakWin, HideHandler ) );
    SetPopupMenu( m_pPopupMenu );
    SetPopupMenu(m_pPopupMenu);

    m_aFadeTimer.SetTimeout( 50 );
    m_aFadeTimer.SetInvokeHandler( LINK( this, SwPageBreakWin, FadeHandler ) );
@@ -127,7 +127,9 @@ void SwPageBreakWin::dispose()
    m_aFadeTimer.Stop();

    m_pLine.disposeAndClear();
    m_pPopupMenu.disposeAndClear();
    m_pPopupMenu.clear();
    m_aBuilder.disposeBuilder();

    delete m_pMousePt;
    m_pMousePt = nullptr;

@@ -214,88 +216,84 @@ void SwPageBreakWin::Paint(vcl::RenderContext& rRenderContext, const ::tools::Re
    pProcessor->process(aGhostedSeq);
}

void SwPageBreakWin::Select( )
void SwPageBreakWin::Select()
{
    SwFrameControlPtr pThis = GetEditWin()->GetFrameControlsManager( ).GetControl( PageBreak, GetFrame() );

    switch( GetCurItemId( ) )
    OString sIdent = GetCurItemIdent();
    if (sIdent == "edit")
    {
        case FN_PAGEBREAK_EDIT:
        const SwLayoutFrame* pBodyFrame = static_cast< const SwLayoutFrame* >( GetPageFrame()->Lower() );
        while ( pBodyFrame && !pBodyFrame->IsBodyFrame() )
            pBodyFrame = static_cast< const SwLayoutFrame* >( pBodyFrame->GetNext() );

        SwEditWin* pEditWin = GetEditWin();

        if ( pBodyFrame )
        {
            SwWrtShell& rSh = pEditWin->GetView().GetWrtShell();
            bool bOldLock = rSh.IsViewLocked();
            rSh.LockView( true );

            if ( pBodyFrame->Lower()->IsTabFrame() )
            {
                const SwLayoutFrame* pBodyFrame = static_cast< const SwLayoutFrame* >( GetPageFrame()->Lower() );
                while ( pBodyFrame && !pBodyFrame->IsBodyFrame() )
                    pBodyFrame = static_cast< const SwLayoutFrame* >( pBodyFrame->GetNext() );
                rSh.Push( );
                rSh.ClearMark();

                SwEditWin* pEditWin = GetEditWin();
                SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
                SwContentNode* pNd = pCnt->GetNode();
                rSh.SetSelection( *pNd );

                if ( pBodyFrame )
                {
                    SwWrtShell& rSh = pEditWin->GetView().GetWrtShell();
                    bool bOldLock = rSh.IsViewLocked();
                    rSh.LockView( true );
                SfxStringItem aItem(pEditWin->GetView().GetPool().GetWhich(FN_FORMAT_TABLE_DLG), "textflow");
                pEditWin->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
                        FN_FORMAT_TABLE_DLG,
                        SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
                        { &aItem });

                    if ( pBodyFrame->Lower()->IsTabFrame() )
                    {
                        rSh.Push( );
                        rSh.ClearMark();

                        SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
                        SwContentNode* pNd = pCnt->GetNode();
                        rSh.SetSelection( *pNd );

                        SfxStringItem aItem(pEditWin->GetView().GetPool().GetWhich(FN_FORMAT_TABLE_DLG), "textflow");
                        pEditWin->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
                                FN_FORMAT_TABLE_DLG,
                                SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
                                { &aItem });

                        rSh.Pop( false );
                    }
                    else
                    {
                        SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
                        SwContentNode* pNd = pCnt->GetNode();

                        SwPaM aPaM( *pNd );
                        SwPaMItem aPaMItem( pEditWin->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM );
                        SfxStringItem aItem( pEditWin->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), "textflow" );
                        pEditWin->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
                                SID_PARA_DLG,
                                SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
                                { &aItem, &aPaMItem });
                    }
                    rSh.LockView( bOldLock );
                    pEditWin->GrabFocus( );
                }
                rSh.Pop( false );
            }
            break;
        case FN_PAGEBREAK_DELETE:
            else
            {
                const SwLayoutFrame* pBodyFrame = static_cast< const SwLayoutFrame* >( GetPageFrame()->Lower() );
                while ( pBodyFrame && !pBodyFrame->IsBodyFrame() )
                    pBodyFrame = static_cast< const SwLayoutFrame* >( pBodyFrame->GetNext() );
                SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
                SwContentNode* pNd = pCnt->GetNode();

                if ( pBodyFrame )
                {
                    SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
                    SwContentNode* pNd = pCnt->GetNode();

                    pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( SwUndoId::UI_DELETE_PAGE_BREAK, nullptr );

                    SfxItemSet aSet( GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
                            RES_PAGEDESC, RES_PAGEDESC,
                            RES_BREAK, RES_BREAK,
                            nullptr );
                    aSet.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) );
                    aSet.Put( SwFormatPageDesc( nullptr ) );

                    SwPaM aPaM( *pNd );
                    pNd->GetDoc()->getIDocumentContentOperations().InsertItemSet( aPaM, aSet );

                    pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( SwUndoId::UI_DELETE_PAGE_BREAK, nullptr );
                }
                SwPaM aPaM( *pNd );
                SwPaMItem aPaMItem( pEditWin->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM );
                SfxStringItem aItem( pEditWin->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), "textflow" );
                pEditWin->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
                        SID_PARA_DLG,
                        SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
                        { &aItem, &aPaMItem });
            }
            break;
            rSh.LockView( bOldLock );
            pEditWin->GrabFocus( );
        }
    }
    else if (sIdent == "delete")
    {
        const SwLayoutFrame* pBodyFrame = static_cast< const SwLayoutFrame* >( GetPageFrame()->Lower() );
        while ( pBodyFrame && !pBodyFrame->IsBodyFrame() )
            pBodyFrame = static_cast< const SwLayoutFrame* >( pBodyFrame->GetNext() );

        if ( pBodyFrame )
        {
            SwContentFrame *pCnt = const_cast< SwContentFrame* >( pBodyFrame->ContainsContent() );
            SwContentNode* pNd = pCnt->GetNode();

            pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( SwUndoId::UI_DELETE_PAGE_BREAK, nullptr );

            SfxItemSet aSet( GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
                    RES_PAGEDESC, RES_PAGEDESC,
                    RES_BREAK, RES_BREAK,
                    nullptr );
            aSet.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) );
            aSet.Put( SwFormatPageDesc( nullptr ) );

            SwPaM aPaM( *pNd );
            pNd->GetDoc()->getIDocumentContentOperations().InsertItemSet( aPaM, aSet );

            pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( SwUndoId::UI_DELETE_PAGE_BREAK, nullptr );
        }
    }

    // Only fade if there is more than this temporary shared pointer:
diff --git a/sw/source/uibase/inc/PageBreakWin.hxx b/sw/source/uibase/inc/PageBreakWin.hxx
index 21e0bbc..995154c 100644
--- a/sw/source/uibase/inc/PageBreakWin.hxx
+++ b/sw/source/uibase/inc/PageBreakWin.hxx
@@ -10,7 +10,7 @@
#define INCLUDED_SW_SOURCE_UIBASE_INC_PAGEBREAKWIN_HXX

#include <FrameControl.hxx>

#include <vcl/builder.hxx>
#include <vcl/menubtn.hxx>

class SwPageFrame;
@@ -22,6 +22,7 @@ class SwPageFrame;
  */
class SwPageBreakWin : public SwFrameMenuButtonBase
{
    VclBuilder            m_aBuilder;
    VclPtr<PopupMenu>     m_pPopupMenu;
    VclPtr<vcl::Window>   m_pLine;
    bool                  m_bIsAppearing;
diff --git a/sw/source/uibase/inc/popup.hrc b/sw/source/uibase/inc/popup.hrc
index a34fb0c..9f12daf 100644
--- a/sw/source/uibase/inc/popup.hrc
+++ b/sw/source/uibase/inc/popup.hrc
@@ -24,9 +24,8 @@

#define MN_ANNOTATION_BUTTON        (RC_POPUPS_BEGIN + 0)
#define MN_HEADERFOOTER_BUTTON      (RC_POPUPS_BEGIN + 1)
#define MN_PAGEBREAK_BUTTON         (RC_POPUPS_BEGIN + 2)

#if MN_PAGEBREAK_BUTTON > RC_POPUPS_END
#if MN_HEADERFOOTER_BUTTON > RC_POPUPS_END

#error Resource-Id Ueberlauf in #file, #line
#endif
diff --git a/sw/uiconfig/swriter/ui/pagebreakmenu.ui b/sw/uiconfig/swriter/ui/pagebreakmenu.ui
new file mode 100644
index 0000000..b528891
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/pagebreakmenu.ui
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
  <requires lib="gtk+" version="3.10"/>
  <object class="GtkMenu" id="menu">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <child>
      <object class="GtkMenuItem" id="edit">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">Edit Page Break...</property>
        <property name="use_underline">True</property>
      </object>
    </child>
    <child>
      <object class="GtkMenuItem" id="delete">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes">Delete Page Break</property>
        <property name="use_underline">True</property>
      </object>
    </child>
  </object>
</interface>