Changed the source code location for Inspector

The Inspector has been instead of defining in svx
now defined such that the main implementation is
in sw folder whereas there is a common interface in
svx.

This change has been done as a progressive step towards
cleaner code.

Change-Id: I49af862f87b4315385c2e275b1079394c326b119
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95657
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.hxx b/include/svx/sidebar/InspectorTextPanel.hxx
similarity index 78%
rename from svx/source/sidebar/inspector/InspectorTextPanel.hxx
rename to include/svx/sidebar/InspectorTextPanel.hxx
index 0d6160d..74c0b90 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.hxx
+++ b/include/svx/sidebar/InspectorTextPanel.hxx
@@ -18,16 +18,14 @@
 */
#pragma once

#include <sfx2/sidebar/IContextChangeReceiver.hxx>
#include <sfx2/weldutils.hxx>
#include <vcl/EnumContext.hxx>
#include <sfx2/sidebar/PanelLayout.hxx>
#include <svx/svxdllapi.h>

namespace svx
{
namespace sidebar
{
class InspectorTextPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver
class SVX_DLLPUBLIC InspectorTextPanel : public PanelLayout
{
public:
    virtual ~InspectorTextPanel() override;
@@ -36,15 +34,12 @@ public:
    static VclPtr<vcl::Window> Create(vcl::Window* pParent,
                                      const css::uno::Reference<css::frame::XFrame>& rxFrame);

    virtual void HandleContextChange(const vcl::EnumContext& rContext) override;

    InspectorTextPanel(vcl::Window* pParent,
                       const css::uno::Reference<css::frame::XFrame>& rxFrame);
    virtual void updateEntries(std::vector<OUString> store);

private:
    std::unique_ptr<weld::TreeView> mxListBoxStyles; // To dump all the properties

    vcl::EnumContext maContext;
    std::unique_ptr<weld::TreeView> mxListBoxStyles;
};
}
} // end of namespace svx::sidebar
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
index fae9930..5e31fd7 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
@@ -411,7 +411,7 @@
          </value>
        </prop>
        <prop oor:name="ImplementationURL" oor:type="xs:string">
          <value>private:resource/toolpanel/SvxPanelFactory/InspectorTextPanel</value>
          <value>private:resource/toolpanel/SwPanelFactory/WriterInspectorTextPanel</value>
        </prop>
        <prop oor:name="OrderIndex" oor:type="xs:int">
          <value>120</value>
diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx
index 6b8ed65..e37648b3 100644
--- a/svx/source/sidebar/PanelFactory.cxx
+++ b/svx/source/sidebar/PanelFactory.cxx
@@ -20,7 +20,6 @@
#include <config_features.h>

#include "text/TextPropertyPanel.hxx"
#include "inspector/InspectorTextPanel.hxx"
#include "styles/StylesPropertyPanel.hxx"
#include "paragraph/ParaPropertyPanel.hxx"
#include "lists/ListsPropertyPanel.hxx"
@@ -125,10 +124,6 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
    {
        pControl = TextPropertyPanel::Create(pParentWindow, xFrame);
    }
    else if (rsResourceURL.endsWith("/InspectorTextPanel"))
    {
        pControl = InspectorTextPanel::Create(pParentWindow, xFrame);
    }
    else if (rsResourceURL.endsWith("/StylesPropertyPanel"))
    {
        pControl = StylesPropertyPanel::Create(pParentWindow, xFrame);
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.cxx b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
index 6eaa6f9..68ac911 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.cxx
+++ b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
@@ -17,11 +17,9 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include "InspectorTextPanel.hxx"
#include <svx/sidebar/InspectorTextPanel.hxx>

#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <comphelper/lok.hxx>
#include <sfx2/lokhelper.hxx>

using namespace css;

@@ -44,11 +42,17 @@ InspectorTextPanel::Create(vcl::Window* pParent,
InspectorTextPanel::InspectorTextPanel(vcl::Window* pParent,
                                       const css::uno::Reference<css::frame::XFrame>& rxFrame)
    : PanelLayout(pParent, "InspectorTextPanel", "svx/ui/inspectortextpanel.ui", rxFrame)
    , mxListBoxStyles(m_xBuilder->weld_tree_view("liststore"))
    , mxListBoxStyles(m_xBuilder->weld_tree_view("listbox_fonts"))
{
    mxListBoxStyles->set_size_request(-1, mxListBoxStyles->get_height_rows(10));
}

void InspectorTextPanel::updateEntries(std::vector<OUString> store)
{
    for (OUString& str : store)
        mxListBoxStyles->append_text(str);
}

InspectorTextPanel::~InspectorTextPanel() { disposeOnce(); }

void InspectorTextPanel::dispose()
@@ -58,14 +62,6 @@ void InspectorTextPanel::dispose()
    PanelLayout::dispose();
}

void InspectorTextPanel::HandleContextChange(const vcl::EnumContext& rContext)
{
    if (maContext == rContext)
        return;

    maContext = rContext;
}

} // end of namespace svx::sidebar

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/uiconfig/ui/inspectortextpanel.ui b/svx/uiconfig/ui/inspectortextpanel.ui
index 1ebd984..726a3d8 100644
--- a/svx/uiconfig/ui/inspectortextpanel.ui
+++ b/svx/uiconfig/ui/inspectortextpanel.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
<interface domain="svx">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkTreeStore" id="liststore">
    <columns>
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index fcb8786..0707fb9 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -707,6 +707,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
    sw/source/uibase/sidebar/TableEditPanel \
    sw/source/uibase/sidebar/ThemePanel \
    sw/source/uibase/sidebar/SwPanelFactory \
    sw/source/uibase/sidebar/WriterInspectorTextPanel \
    sw/source/uibase/table/chartins \
    sw/source/uibase/table/swtablerep \
    sw/source/uibase/table/tablemgr \
diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx
index 37b6694..b073b28 100644
--- a/sw/source/uibase/sidebar/SwPanelFactory.cxx
+++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx
@@ -26,6 +26,7 @@
#include "PageHeaderPanel.hxx"
#include "PageFooterPanel.hxx"
#include "WrapPropertyPanel.hxx"
#include "WriterInspectorTextPanel.hxx"
#include "TableEditPanel.hxx"
#include <navipi.hxx>
#include <redlndlg.hxx>
@@ -169,6 +170,15 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
            pPanel,
            ui::LayoutSize(-1,-1,-1));
    }
    else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
    {
        VclPtr<vcl::Window> pPanel = sw::sidebar::WriterInspectorTextPanel::Create( pParentWindow, xFrame);
        xElement = sfx2::sidebar::SidebarPanelBase::Create(
            rsResourceURL,
            xFrame,
            pPanel,
            ui::LayoutSize(-1,-1,-1));
    }
    else if (rsResourceURL.endsWith("/StylePresetsPanel"))
    {
        VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame);
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
new file mode 100644
index 0000000..c0fc42b
--- /dev/null
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -0,0 +1,51 @@
/* -*- 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 "WriterInspectorTextPanel.hxx"

#include <com/sun/star/lang/IllegalArgumentException.hpp>

using namespace css;

namespace sw::sidebar
{
VclPtr<vcl::Window>
WriterInspectorTextPanel::Create(vcl::Window* pParent,
                                 const css::uno::Reference<css::frame::XFrame>& rxFrame)
{
    if (pParent == nullptr)
        throw lang::IllegalArgumentException(
            "no parent Window given to WriterInspectorTextPanel::Create", nullptr, 0);
    if (!rxFrame.is())
        throw lang::IllegalArgumentException("no XFrame given to WriterInspectorTextPanel::Create",
                                             nullptr, 1);

    return VclPtr<WriterInspectorTextPanel>::Create(pParent, rxFrame);
}
WriterInspectorTextPanel::WriterInspectorTextPanel(
    vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame)
    : InspectorTextPanel(pParent, rxFrame)
{
    std::vector<OUString> store;
    InspectorTextPanel::updateEntries(store);
}

} // end of namespace svx::sidebar

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.hxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
similarity index 65%
copy from svx/source/sidebar/inspector/InspectorTextPanel.hxx
copy to sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
index 0d6160d..85b8dc7 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.hxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
@@ -18,33 +18,23 @@
 */
#pragma once

#include <sfx2/sidebar/IContextChangeReceiver.hxx>
#include <sfx2/weldutils.hxx>
#include <vcl/EnumContext.hxx>
#include <sfx2/sidebar/PanelLayout.hxx>
#include <svx/sidebar/InspectorTextPanel.hxx>

namespace svx
namespace sw
{
namespace sidebar
{
class InspectorTextPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver
class WriterInspectorTextPanel final : public svx::sidebar::InspectorTextPanel
{
public:
    virtual ~InspectorTextPanel() override;
    virtual void dispose() override;

    static VclPtr<vcl::Window> Create(vcl::Window* pParent,
                                      const css::uno::Reference<css::frame::XFrame>& rxFrame);

    virtual void HandleContextChange(const vcl::EnumContext& rContext) override;
    WriterInspectorTextPanel(vcl::Window* pParent,
                             const css::uno::Reference<css::frame::XFrame>& rxFrame);

    InspectorTextPanel(vcl::Window* pParent,
                       const css::uno::Reference<css::frame::XFrame>& rxFrame);

private:
    std::unique_ptr<weld::TreeView> mxListBoxStyles; // To dump all the properties

    vcl::EnumContext maContext;
    // virtual ~WriterInspectorTextPanel();
};
}
} // end of namespace svx::sidebar