summaryrefslogtreecommitdiff
path: root/sw/source/uibase/cctrl
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-05-26 17:43:14 +0200
committerMichael Stahl <mstahl@redhat.com>2014-05-27 11:13:02 +0200
commit35029b250318b3a4f02cef5194abdd3f68311c43 (patch)
tree5026ab2dab620dcdcae84e574483ce3c325e5a78 /sw/source/uibase/cctrl
parentf8d26c68e48e52265d4f20a1527bf52828c046ad (diff)
sw: move sw/source/core/uibase to sw/source/uibase
It's too confusing to have UI code inside of core; the important part is that it's separated from the optional UI code in swui library. Change-Id: I640a52723d5802faf08f3b8eaa03cd937fd93449
Diffstat (limited to 'sw/source/uibase/cctrl')
-rw-r--r--sw/source/uibase/cctrl/actctrl.cxx125
-rw-r--r--sw/source/uibase/cctrl/popbox.cxx63
-rw-r--r--sw/source/uibase/cctrl/swlbox.cxx137
3 files changed, 325 insertions, 0 deletions
diff --git a/sw/source/uibase/cctrl/actctrl.cxx b/sw/source/uibase/cctrl/actctrl.cxx
new file mode 100644
index 000000000000..eb5fe931fae6
--- /dev/null
+++ b/sw/source/uibase/cctrl/actctrl.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/string.hxx>
+#include <vcl/builder.hxx>
+#include "actctrl.hxx"
+
+void NumEditAction::Action()
+{
+ aActionLink.Call( this );
+}
+
+bool NumEditAction::Notify( NotifyEvent& rNEvt )
+{
+ bool nHandled = false;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode aKeyCode = pKEvt->GetKeyCode();
+ const sal_uInt16 nModifier = aKeyCode.GetModifier();
+ if( aKeyCode.GetCode() == KEY_RETURN &&
+ !nModifier)
+ {
+ Action();
+ nHandled = true;
+ }
+
+ }
+ if(!nHandled)
+ NumericField::Notify( rNEvt );
+ return nHandled;
+}
+
+NoSpaceEdit::NoSpaceEdit(Window* pParent)
+ : Edit(pParent, WB_BORDER|WB_TABSTOP)
+ , sForbiddenChars(OUString(" "))
+{
+}
+
+NoSpaceEdit::~NoSpaceEdit()
+{
+}
+
+void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
+{
+ bool bCallParent = true;
+ if(rEvt.GetCharCode())
+ {
+ OUString sKey(rEvt.GetCharCode());
+ if( -1 != sForbiddenChars.indexOf(sKey))
+ bCallParent = false;
+ }
+ if(bCallParent)
+ Edit::KeyInput(rEvt);
+}
+
+void NoSpaceEdit::Modify()
+{
+ Selection aSel = GetSelection();
+ OUString sTemp = GetText();
+ for(sal_uInt16 i = 0; i < sForbiddenChars.getLength(); i++)
+ {
+ sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
+ }
+ sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
+ if(nDiff)
+ {
+ aSel.setMin(aSel.getMin() - nDiff);
+ aSel.setMax(aSel.getMin());
+ SetText(sTemp);
+ SetSelection(aSel);
+ }
+ Edit::Modify();
+}
+
+void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
+{
+ const KeyCode aKeyCode = rEvt.GetKeyCode();
+ const sal_uInt16 nModifier = aKeyCode.GetModifier();
+ if( aKeyCode.GetCode() == KEY_RETURN &&
+ !nModifier)
+ {
+ if(aReturnActionLink.IsSet())
+ aReturnActionLink.Call(this);
+ }
+ else
+ Edit::KeyInput(rEvt);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new TableNameEdit(pParent);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNoSpaceEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new NoSpaceEdit(pParent);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReturnActionEdit(Window *pParent, VclBuilder::stringmap &rMap)
+{
+ VclBuilder::ensureDefaultWidthChars(rMap);
+ return new ReturnActionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/cctrl/popbox.cxx b/sw/source/uibase/cctrl/popbox.cxx
new file mode 100644
index 000000000000..4ebf98d738df
--- /dev/null
+++ b/sw/source/uibase/cctrl/popbox.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cmdid.h>
+#include <swtypes.hxx>
+#include <popbox.hxx>
+#include <navipi.hxx>
+
+SwHelpToolBox::SwHelpToolBox( SwNavigationPI* pParent, const ResId& rResId )
+ : ToolBox( pParent, rResId ),
+ DropTargetHelper( this )
+{
+}
+
+void SwHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
+{
+ // If doubleclick is detected use doubleclick handler
+ if(rEvt.GetButtons() == MOUSE_RIGHT &&
+ 0 == GetItemId(rEvt.GetPosPixel()))
+ {
+ aRightClickLink.Call((MouseEvent *)&rEvt);
+ }
+ else
+ ToolBox::MouseButtonDown(rEvt);
+}
+
+long SwHelpToolBox::DoubleClick( ToolBox* pCaller )
+{
+ // No doubleclick on button
+ if( 0 == pCaller->GetCurItemId() && aDoubleClickLink.Call(0) )
+ return sal_True;
+ return sal_False;
+}
+
+SwHelpToolBox::~SwHelpToolBox() {}
+
+sal_Int8 SwHelpToolBox::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ return ((SwNavigationPI*)GetParent())->AcceptDrop( rEvt );
+}
+
+sal_Int8 SwHelpToolBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ return ((SwNavigationPI*)GetParent())->ExecuteDrop( rEvt );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/cctrl/swlbox.cxx b/sw/source/uibase/cctrl/swlbox.cxx
new file mode 100644
index 000000000000..bdd3f15869ad
--- /dev/null
+++ b/sw/source/uibase/cctrl/swlbox.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+#include <unotools/charclass.hxx>
+#include <swtypes.hxx>
+#include <swlbox.hxx>
+
+// Description: ListboxElement
+SwBoxEntry::SwBoxEntry() :
+ bModified(false),
+ bNew(false),
+ nId(COMBOBOX_APPEND)
+{
+}
+
+SwBoxEntry::SwBoxEntry(const OUString& aNam, sal_Int32 nIdx) :
+ bModified(false),
+ bNew(false),
+ aName(aNam),
+ nId(nIdx)
+{
+}
+
+SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
+ bModified(rOld.bModified),
+ bNew(rOld.bNew),
+ aName(rOld.aName),
+ nId(rOld.nId)
+{
+}
+
+SwComboBox::SwComboBox(Window* pParent, WinBits nStyle)
+ : ComboBox(pParent, nStyle)
+{
+ Init();
+}
+
+void SwComboBox::Init()
+{
+ // create administration for the resource's Stringlist
+ sal_Int32 nSize = GetEntryCount();
+ for( sal_Int32 i=0; i < nSize; ++i )
+ {
+ SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
+ aEntryLst.push_back(pTmp);
+ }
+}
+
+// Basic class Dtor
+SwComboBox::~SwComboBox()
+{
+}
+
+void SwComboBox::InsertSwEntry(const SwBoxEntry& rEntry)
+{
+ InsertSorted(new SwBoxEntry(rEntry));
+}
+
+sal_Int32 SwComboBox::InsertEntry(const OUString& rStr, sal_Int32)
+{
+ InsertSwEntry(SwBoxEntry(rStr));
+ return 0;
+}
+
+void SwComboBox::RemoveEntryAt(sal_Int32 const nPos)
+{
+ if(nPos < 0 || static_cast<size_t>(nPos) >= aEntryLst.size())
+ return;
+
+ // Remove old element
+ SwBoxEntry* pEntry = &aEntryLst[nPos];
+ ComboBox::RemoveEntryAt(nPos);
+
+ // Don't add new entries to the list
+ if(pEntry->bNew)
+ {
+ aEntryLst.erase(aEntryLst.begin() + nPos);
+ }
+ else
+ {
+ // add to DelEntryLst
+ aDelEntryLst.transfer(aDelEntryLst.end(),
+ aEntryLst.begin() + nPos, aEntryLst);
+ }
+}
+
+sal_Int32 SwComboBox::GetSwEntryPos(const SwBoxEntry& rEntry) const
+{
+ return ComboBox::GetEntryPos(rEntry.aName);
+}
+
+const SwBoxEntry& SwComboBox::GetSwEntry(sal_Int32 const nPos) const
+{
+ if(0 <= nPos && static_cast<size_t>(nPos) < aEntryLst.size())
+ return aEntryLst[nPos];
+
+ return aDefault;
+}
+
+sal_Int32 SwComboBox::GetRemovedCount() const
+{
+ return static_cast<sal_Int32>(aDelEntryLst.size());
+}
+
+const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_Int32 nPos) const
+{
+ if(0 <= nPos && static_cast<size_t>(nPos) < aDelEntryLst.size())
+ return aDelEntryLst[nPos];
+
+ return aDefault;
+}
+
+void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
+{
+ ComboBox::InsertEntry(pEntry->aName);
+ sal_Int32 nPos = ComboBox::GetEntryPos(pEntry->aName);
+ aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */