1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/dispatch.hxx>
21 #include <svl/intitem.hxx>
22 #include <svl/eitem.hxx>
23 #include "dialmgr.hxx"
24 #include "splitcelldlg.hxx"
28 class NoApplyDialog
: public SvxStandardDialog
31 NoApplyDialog(vcl::Window
*pParent
, const OUString
&rId
, const OUString
&rXML
) :
32 SvxStandardDialog(pParent
, rId
, rXML
) { }
34 virtual void Apply() SAL_OVERRIDE
{}
38 SvxSplitTableDlg::SvxSplitTableDlg( vcl::Window
*pParent
, bool bIsTableVertical
,
39 long nMaxVertical
, long nMaxHorizontal
)
40 : m_pDialog(VclPtr
<NoApplyDialog
>::Create(pParent
, "SplitCellsDialog", "cui/ui/splitcellsdialog.ui"))
41 , mnMaxVertical(nMaxVertical
)
42 , mnMaxHorizontal(nMaxHorizontal
)
44 m_pDialog
->get(m_pCountEdit
, "countnf");
45 m_pDialog
->get(m_pHorzBox
, "hori");
46 m_pDialog
->get(m_pVertBox
, "vert");
47 m_pDialog
->get(m_pPropCB
, "prop");
48 m_pHorzBox
->SetClickHdl( LINK( this, SvxSplitTableDlg
, ClickHdl
));
49 m_pPropCB
->SetClickHdl( LINK( this, SvxSplitTableDlg
, ClickHdl
));
50 m_pVertBox
->SetClickHdl( LINK( this, SvxSplitTableDlg
, ClickHdl
));
52 if( mnMaxVertical
< 2 )
53 m_pVertBox
->Enable(false);
55 //exchange the meaning of horizontal and vertical for vertical text
58 Image
aTmpImg(m_pHorzBox
->GetModeRadioImage());
59 OUString
sTmp(m_pHorzBox
->GetText());
60 m_pHorzBox
->SetText(m_pVertBox
->GetText());
61 m_pHorzBox
->SetModeRadioImage(m_pVertBox
->GetModeRadioImage());
62 m_pVertBox
->SetText(sTmp
);
63 m_pVertBox
->SetModeRadioImage(aTmpImg
);
67 SvxSplitTableDlg::~SvxSplitTableDlg()
73 m_pDialog
.disposeAndClear();
76 IMPL_LINK( SvxSplitTableDlg
, ClickHdl
, Button
*, pButton
)
78 const bool bIsVert
= pButton
== m_pVertBox
;
79 long nMax
= bIsVert
? mnMaxVertical
: mnMaxHorizontal
;
80 m_pPropCB
->Enable(!bIsVert
);
81 m_pCountEdit
->SetMax( nMax
);
85 bool SvxSplitTableDlg::IsHorizontal() const
87 return m_pHorzBox
->IsChecked();
90 bool SvxSplitTableDlg::IsProportional() const
92 return m_pPropCB
->IsChecked() && m_pHorzBox
->IsChecked();
95 long SvxSplitTableDlg::GetCount() const
97 return sal::static_int_cast
<long>( m_pCountEdit
->GetValue() );
100 short SvxSplitTableDlg::Execute()
102 return m_pDialog
->Execute();
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */