Kaydet (Commit) e945999b authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

TextPropertyPanel cleanup

Change-Id: If9fe62643ad33c2d832b146a5dc7248dbba32f1a
üst a1f97ed2
...@@ -132,7 +132,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( ...@@ -132,7 +132,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
if (rsResourceURL.endsWith("/TextPropertyPanel")) if (rsResourceURL.endsWith("/TextPropertyPanel"))
{ {
pControl = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings, aContext); pControl = TextPropertyPanel::Create(pParentWindow, xFrame);
} }
else if (rsResourceURL.endsWith("/StylesPropertyPanel")) else if (rsResourceURL.endsWith("/StylesPropertyPanel"))
{ {
......
...@@ -17,57 +17,32 @@ ...@@ -17,57 +17,32 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "TextPropertyPanel.hrc"
#include "TextPropertyPanel.hxx" #include "TextPropertyPanel.hxx"
#include <editeng/kernitem.hxx>
#include <editeng/udlnitem.hxx>
#include <rtl/ref.hxx>
#include <sfx2/dispatch.hxx>
#include <svtools/unitconv.hxx>
#include <vcl/toolbox.hxx> #include <vcl/toolbox.hxx>
using namespace css; using namespace css;
using namespace css::uno;
namespace svx { namespace sidebar { namespace svx { namespace sidebar {
VclPtr<vcl::Window> TextPropertyPanel::Create ( VclPtr<vcl::Window> TextPropertyPanel::Create (
vcl::Window* pParent, vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame, const css::uno::Reference<css::frame::XFrame>& rxFrame)
SfxBindings* pBindings,
const vcl::EnumContext& rContext)
{ {
if (pParent == nullptr) if (pParent == nullptr)
throw lang::IllegalArgumentException("no parent Window given to TextPropertyPanel::Create", nullptr, 0); throw lang::IllegalArgumentException("no parent Window given to TextPropertyPanel::Create", nullptr, 0);
if ( ! rxFrame.is()) if ( ! rxFrame.is())
throw lang::IllegalArgumentException("no XFrame given to TextPropertyPanel::Create", nullptr, 1); throw lang::IllegalArgumentException("no XFrame given to TextPropertyPanel::Create", nullptr, 1);
if (pBindings == nullptr)
throw lang::IllegalArgumentException("no SfxBindings given to TextPropertyPanel::Create", nullptr, 2);
return VclPtr<TextPropertyPanel>::Create(
pParent,
rxFrame,
pBindings,
rContext);
}
TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings, const vcl::EnumContext& /*rContext*/ ) return VclPtr<TextPropertyPanel>::Create(pParent, rxFrame);
: PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui", rxFrame), }
maFontSizeControl (SID_ATTR_CHAR_FONTHEIGHT, *pBindings, *this, OUString("FontHeight"), rxFrame),
maContext() TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame )
: PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui", rxFrame)
{ {
get(mpToolBoxFont, "fonteffects");
get(mpToolBoxIncDec, "fontadjust");
get(mpToolBoxSpacing, "spacingbar");
get(mpToolBoxFontColorSw, "colorbar_writer"); get(mpToolBoxFontColorSw, "colorbar_writer");
get(mpToolBoxFontColor, "colorbar_others"); get(mpToolBoxFontColor, "colorbar_others");
get(mpToolBoxBackgroundColor, "colorbar_background"); get(mpToolBoxBackgroundColor, "colorbar_background");
//init state
mpHeightItem = nullptr;
} }
TextPropertyPanel::~TextPropertyPanel() TextPropertyPanel::~TextPropertyPanel()
...@@ -77,15 +52,10 @@ TextPropertyPanel::~TextPropertyPanel() ...@@ -77,15 +52,10 @@ TextPropertyPanel::~TextPropertyPanel()
void TextPropertyPanel::dispose() void TextPropertyPanel::dispose()
{ {
mpToolBoxFont.clear();
mpToolBoxIncDec.clear();
mpToolBoxSpacing.clear();
mpToolBoxFontColorSw.clear(); mpToolBoxFontColorSw.clear();
mpToolBoxFontColor.clear(); mpToolBoxFontColor.clear();
mpToolBoxBackgroundColor.clear(); mpToolBoxBackgroundColor.clear();
maFontSizeControl.dispose();
PanelLayout::dispose(); PanelLayout::dispose();
} }
...@@ -99,19 +69,9 @@ void TextPropertyPanel::HandleContextChange ( ...@@ -99,19 +69,9 @@ void TextPropertyPanel::HandleContextChange (
bool bWriterText = false; bool bWriterText = false;
bool bDrawText = false; bool bDrawText = false;
bool bNeedTextSpacing = false;
switch (maContext.GetCombinedContext_DI()) switch (maContext.GetCombinedContext_DI())
{ {
case CombinedEnumContext(Application::Calc, Context::Cell):
case CombinedEnumContext(Application::Calc, Context::Pivot):
// bNeedTextSpacing = false;
break;
case CombinedEnumContext(Application::Calc, Context::EditCell):
bNeedTextSpacing = true;
break;
case CombinedEnumContext(Application::Calc, Context::DrawText): case CombinedEnumContext(Application::Calc, Context::DrawText):
case CombinedEnumContext(Application::WriterVariants, Context::DrawText): case CombinedEnumContext(Application::WriterVariants, Context::DrawText):
case CombinedEnumContext(Application::WriterVariants, Context::Annotation): case CombinedEnumContext(Application::WriterVariants, Context::Annotation):
...@@ -122,13 +82,11 @@ void TextPropertyPanel::HandleContextChange ( ...@@ -122,13 +82,11 @@ void TextPropertyPanel::HandleContextChange (
case CombinedEnumContext(Application::DrawImpress, Context::Draw): case CombinedEnumContext(Application::DrawImpress, Context::Draw):
case CombinedEnumContext(Application::DrawImpress, Context::TextObject): case CombinedEnumContext(Application::DrawImpress, Context::TextObject):
case CombinedEnumContext(Application::DrawImpress, Context::Graphic): case CombinedEnumContext(Application::DrawImpress, Context::Graphic):
bNeedTextSpacing = true;
bDrawText = true; bDrawText = true;
break; break;
case CombinedEnumContext(Application::WriterVariants, Context::Text): case CombinedEnumContext(Application::WriterVariants, Context::Text):
case CombinedEnumContext(Application::WriterVariants, Context::Table): case CombinedEnumContext(Application::WriterVariants, Context::Table):
bNeedTextSpacing = true;
bWriterText = true; bWriterText = true;
break; break;
...@@ -136,36 +94,11 @@ void TextPropertyPanel::HandleContextChange ( ...@@ -136,36 +94,11 @@ void TextPropertyPanel::HandleContextChange (
break; break;
} }
mpToolBoxSpacing->Enable(bNeedTextSpacing);
mpToolBoxFontColor->Show(!bWriterText); mpToolBoxFontColor->Show(!bWriterText);
mpToolBoxFontColorSw->Show(bWriterText); mpToolBoxFontColorSw->Show(bWriterText);
mpToolBoxBackgroundColor->Show(bDrawText); mpToolBoxBackgroundColor->Show(bDrawText);
} }
void TextPropertyPanel::NotifyItemUpdate (
const sal_uInt16 nSID,
const SfxItemState eState,
const SfxPoolItem* pState,
const bool bIsEnabled)
{
switch(nSID)
{
case SID_ATTR_CHAR_FONTHEIGHT:
{
if ( eState >= SfxItemState::DEFAULT && dynamic_cast<const SvxFontHeightItem*>( pState) != nullptr )
mpHeightItem = const_cast<SvxFontHeightItem*>(static_cast<const SvxFontHeightItem*>(pState));
else
mpHeightItem = nullptr;
}
break;
case SID_ATTR_CHAR_KERNING:
{
mpToolBoxSpacing->Enable(bIsEnabled);
}
break;
}
}
} } // end of namespace svx::sidebar } } // end of namespace svx::sidebar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -19,16 +19,8 @@ ...@@ -19,16 +19,8 @@
#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
#include <sfx2/sidebar/IContextChangeReceiver.hxx> #include <sfx2/sidebar/IContextChangeReceiver.hxx>
#include <vcl/EnumContext.hxx> #include <vcl/EnumContext.hxx>
#include <svtools/ctrlbox.hxx>
#include <editeng/fhgtitem.hxx>
#include <com/sun/star/ui/XSidebar.hpp>
#include <com/sun/star/frame/XToolbarController.hpp>
#include <svx/sidebar/PanelLayout.hxx> #include <svx/sidebar/PanelLayout.hxx>
class ToolBox; class ToolBox;
...@@ -37,8 +29,7 @@ namespace svx { namespace sidebar { ...@@ -37,8 +29,7 @@ namespace svx { namespace sidebar {
class TextPropertyPanel class TextPropertyPanel
: public PanelLayout, : public PanelLayout,
public ::sfx2::sidebar::IContextChangeReceiver, public ::sfx2::sidebar::IContextChangeReceiver
public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
{ {
public: public:
virtual ~TextPropertyPanel() override; virtual ~TextPropertyPanel() override;
...@@ -46,41 +37,21 @@ public: ...@@ -46,41 +37,21 @@ public:
static VclPtr<vcl::Window> Create ( static VclPtr<vcl::Window> Create (
vcl::Window* pParent, vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame, const css::uno::Reference<css::frame::XFrame>& rxFrame);
SfxBindings* pBindings,
const vcl::EnumContext& rContext);
virtual void HandleContextChange ( virtual void HandleContextChange (
const vcl::EnumContext& rContext) override; const vcl::EnumContext& rContext) override;
virtual void NotifyItemUpdate(
const sal_uInt16 nSId,
const SfxItemState eState,
const SfxPoolItem* pState,
const bool bIsEnabled) override;
TextPropertyPanel ( TextPropertyPanel (
vcl::Window* pParent, vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame, const css::uno::Reference<css::frame::XFrame>& rxFrame);
SfxBindings* pBindings,
const vcl::EnumContext& rContext);
private: private:
//ui controls
VclPtr<ToolBox> mpToolBoxFont;
VclPtr<ToolBox> mpToolBoxIncDec;
VclPtr<ToolBox> mpToolBoxSpacing; VclPtr<ToolBox> mpToolBoxSpacing;
VclPtr<ToolBox> mpToolBoxFontColorSw; VclPtr<ToolBox> mpToolBoxFontColorSw;
VclPtr<ToolBox> mpToolBoxFontColor; VclPtr<ToolBox> mpToolBoxFontColor;
VclPtr<ToolBox> mpToolBoxBackgroundColor; VclPtr<ToolBox> mpToolBoxBackgroundColor;
//control items
::sfx2::sidebar::ControllerItem maFontSizeControl;
SvxFontHeightItem* mpHeightItem;
vcl::EnumContext maContext; vcl::EnumContext maContext;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment