[Libreoffice-commits] core.git: Branch 'private/Sweetshark/killswclient' - 56 commits - compilerplugins/clang config_host/config_features.h.in config_host/config_firebird.h.in config_host/config_java.h.in config_host/config_options.h.in configure.ac connectivity/source cppu/source cui/source dbaccess/CppunitTest_dbaccess_hsqldb_test.mk dbaccess/CppunitTest_dbaccess_RowSetClones.mk dbaccess/source desktop/source desktop/unx extensions/source external/xmlsec filter/source helpcontent2 include/connectivity include/svx include/test include/vcl offapi/com sal/osl sc/qa sc/source sd/inc sd/qa sd/source sd/uiconfig sd/UIConfig_sdraw.mk sfx2/source solenv/clang-format solenv/gbuild starmath/source svx/source sw/inc sw/qa sw/source test/source unotools/source vcl/CppunitTest_vcl_apitests.mk vcl/CppunitTest_vcl_complextext.mk vcl/Executable_vcldemo.mk vcl/headless vcl/inc vcl/Module_vcl.mk vcl/qa vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win xmloff/source
Bjoern Michaelsen
bjoern.michaelsen at libreoffice.org
Sat May 12 08:25:08 UTC 2018
Rebased ref, commits from common ancestor:
commit 10e80d0ecb26394c583e581469b8119d866933b2
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date: Thu May 10 10:51:42 2018 +0200
dont use SwClient/SwModify in unocore: NumberingRules
Change-Id: I20ee1662310f33831757015659a70d3ffd855b3e
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index c12d4349173a..3dd5a1d2d9e1 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -134,7 +134,9 @@ namespace o3tl {
template<> struct typed_flags<UseOnPage> : is_typed_flags<UseOnPage, 0xffff> {};
}
-class SW_DLLPUBLIC SwPageDesc : public SwModify
+class SW_DLLPUBLIC SwPageDesc
+ : public SwModify
+ , public sw::BroadcasterMixin
{
friend class SwDoc;
friend class SwPageDescs;
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index a283a7954e7d..aaedae061d17 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -73,6 +73,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/propertyvalue.hxx>
#include <svl/itemprop.hxx>
+#include <svl/listener.hxx>
#include <paratr.hxx>
using namespace ::com::sun::star;
@@ -82,6 +83,14 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::style;
+
+namespace
+{
+ inline static SvtBroadcaster& GetPageDescNotifier(SwDoc* pDoc)
+ {
+ return pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier();
+ }
+}
// Constants for the css::text::ColumnSeparatorStyle
#define API_COL_LINE_NONE 0
#define API_COL_LINE_SOLID 1
@@ -999,15 +1008,13 @@ OSL_FAIL("not implemented");
static const char aInvalidStyle[] = "__XXX___invalid";
-class SwXNumberingRules::Impl : public SwClient
+class SwXNumberingRules::Impl
+ : public SvtListener
{
-private:
SwXNumberingRules& m_rParent;
-public:
- explicit Impl(SwXNumberingRules& rParent) : m_rParent(rParent) {}
-protected:
- //SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
+ virtual void Notify(const SfxHint&) override;
+ public:
+ explicit Impl(SwXNumberingRules& rParent) : m_rParent(rParent) {}
};
bool SwXNumberingRules::isInvalidStyle(const OUString &rName)
@@ -1074,7 +1081,7 @@ SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) :
}
}
if(pDoc)
- pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl);
+ m_pImpl->StartListening(GetPageDescNotifier(pDoc));
for(sal_uInt16 i = 0; i < MAXLEVEL; ++i)
{
m_sNewCharStyleNames[i] = aInvalidStyle;
@@ -1090,7 +1097,7 @@ SwXNumberingRules::SwXNumberingRules(SwDocShell& rDocSh) :
m_pPropertySet(GetNumberingRulesSet()),
bOwnNumRuleCreated(false)
{
- pDocShell->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl);
+ m_pImpl->StartListening(GetPageDescNotifier(pDocShell->GetDoc()));
}
SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) :
@@ -1101,7 +1108,7 @@ SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) :
m_pPropertySet(GetNumberingRulesSet()),
bOwnNumRuleCreated(false)
{
- rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl);
+ m_pImpl->StartListening(GetPageDescNotifier(&rDoc));
m_sCreatedNumRuleName = rDoc.GetUniqueNumRuleName();
rDoc.MakeNumRule( m_sCreatedNumRuleName, nullptr, false,
// #i89178#
@@ -2234,10 +2241,9 @@ void SwXNumberingRules::setName(const OUString& /*rName*/)
throw aExcept;
}
-void SwXNumberingRules::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwXNumberingRules::Impl::Notify(const SfxHint& rHint)
{
- ClientModify(this, pOld, pNew);
- if(!GetRegisteredIn())
+ if(rHint.GetId() == SfxHintId::Dying)
{
if(m_rParent.bOwnNumRuleCreated)
delete m_rParent.pNumRule;
commit 3fe21e2ca91aeb8f257a08c2e2fd086bc0ea1b7b
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date: Thu May 10 10:51:42 2018 +0200
dont use SwClient/SwModify in unocore: HeadFootText
Change-Id: Icf0fa7ec07c8c52981c50bc03a34ae0fa9683fcf
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 595a3deab14d..8a2567f4ce50 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -83,6 +83,10 @@ namespace sw
class SW_DLLPUBLIC BroadcasterMixin {
SvtBroadcaster m_aNotifier;
public:
+ BroadcasterMixin& operator=(const BroadcasterMixin&)
+ {
+ return *this; // Listeners are never copied or moved.
+ }
SvtBroadcaster& GetNotifier() { return m_aNotifier; }
};
/// refactoring out the some of the more sane SwClient functionality
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 787988467407..a8f61f3cf17a 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -53,7 +53,9 @@ namespace sw
class SwFrameFormats;
/// Style of a layout element.
-class SW_DLLPUBLIC SwFrameFormat: public SwFormat
+class SW_DLLPUBLIC SwFrameFormat
+ : public SwFormat
+ , public sw::BroadcasterMixin
{
friend class SwDoc;
friend class SwPageDesc; ///< Is allowed to call protected CTor.
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index eb4cc6913f38..30b582b89a80 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -270,7 +270,6 @@ enum class SectionSort { Not, Pos };
class SW_DLLPUBLIC SwSectionFormat
: public SwFrameFormat
, public ::sfx2::Metadatable
- , public sw::BroadcasterMixin
{
friend class SwDoc;
diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx
index 11aa3cbf794f..439d434dade0 100644
--- a/sw/inc/unotextbodyhf.hxx
+++ b/sw/inc/unotextbodyhf.hxx
@@ -116,7 +116,6 @@ public:
static css::uno::Reference< css::text::XText >
CreateXHeadFootText(SwFrameFormat & rHeadFootFormat, const bool bIsHeader);
- static bool IsXHeadFootText(SwClient const *const pClient);
// XInterface
virtual css::uno::Any SAL_CALL queryInterface(
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index bcc42a8b06f8..7f4d27ad6e1c 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -121,7 +121,7 @@ static void lcl_DelHFFormat( SwClient *pToRemove, SwFrameFormat *pFormat )
// It's suboptimal if the format is deleted beforehand.
SwIterator<SwClient,SwFrameFormat> aIter(*pFormat);
for(SwClient* pLast = aIter.First(); bDel && pLast; pLast = aIter.Next())
- if (dynamic_cast<const SwFrame*>(pLast) == nullptr && !SwXHeadFootText::IsXHeadFootText(pLast))
+ if (dynamic_cast<const SwFrame*>(pLast) == nullptr)
bDel = false;
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 6d01370e5d19..cc238510ab99 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <svl/listener.hxx>
#include <vcl/svapp.hxx>
#include <comphelper/profilezone.hxx>
#include <comphelper/sequence.hxx>
@@ -2453,108 +2454,90 @@ SwXBodyText::hasElements()
}
class SwXHeadFootText::Impl
- : public SwClient
+ : public SvtListener
{
+ public:
+ SwFrameFormat* m_pHeadFootFormat;
+ bool m_bIsHeader;
-public:
-
- bool m_bIsHeader;
-
- Impl( SwFrameFormat & rHeadFootFormat, const bool bIsHeader)
- : SwClient(& rHeadFootFormat)
- , m_bIsHeader(bIsHeader)
- {
- }
-
- SwFrameFormat * GetHeadFootFormat() const {
- return static_cast<SwFrameFormat*>(
- const_cast<SwModify*>(GetRegisteredIn()));
- }
+ Impl(SwFrameFormat& rHeadFootFormat, const bool bIsHeader)
+ : m_pHeadFootFormat(&rHeadFootFormat)
+ , m_bIsHeader(bIsHeader)
+ {
+ if(m_pHeadFootFormat)
+ StartListening(m_pHeadFootFormat->GetNotifier());
+ }
- SwFrameFormat & GetHeadFootFormatOrThrow() {
- SwFrameFormat *const pFormat( GetHeadFootFormat() );
- if (!pFormat) {
- throw uno::RuntimeException("SwXHeadFootText: disposed or invalid", nullptr);
+ SwFrameFormat* GetHeadFootFormat() const {
+ return m_pHeadFootFormat;
}
- return *pFormat;
- }
-protected:
- // SwClient
- virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+ SwFrameFormat& GetHeadFootFormatOrThrow() {
+ if (!m_pHeadFootFormat) {
+ throw uno::RuntimeException("SwXHeadFootText: disposed or invalid", nullptr);
+ }
+ return *m_pHeadFootFormat;
+ }
+ protected:
+ virtual void Notify(const SfxHint& rHint) override
+ {
+ if(rHint.GetId() == SfxHintId::Dying)
+ m_pHeadFootFormat = nullptr;
+ }
};
-void SwXHeadFootText::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
-{
- ClientModify(this, pOld, pNew);
-}
-
-bool SwXHeadFootText::IsXHeadFootText(SwClient const *const pClient)
-{
- return dynamic_cast<SwXHeadFootText::Impl const *>(pClient) != nullptr;
-}
-
-uno::Reference< text::XText >
-SwXHeadFootText::CreateXHeadFootText(
- SwFrameFormat & rHeadFootFormat, const bool bIsHeader)
+uno::Reference<text::XText> SwXHeadFootText::CreateXHeadFootText(
+ SwFrameFormat& rHeadFootFormat,
+ const bool bIsHeader)
{
// re-use existing SwXHeadFootText
// #i105557#: do not iterate over the registered clients: race condition
- uno::Reference< text::XText > xText(rHeadFootFormat.GetXObject(),
- uno::UNO_QUERY);
- if (!xText.is())
+ uno::Reference<text::XText> xText(rHeadFootFormat.GetXObject(), uno::UNO_QUERY);
+ if(!xText.is())
{
- SwXHeadFootText *const pXHFT(
- new SwXHeadFootText(rHeadFootFormat, bIsHeader));
+ const auto pXHFT(new SwXHeadFootText(rHeadFootFormat, bIsHeader));
xText.set(pXHFT);
rHeadFootFormat.SetXObject(xText);
}
return xText;
}
-SwXHeadFootText::SwXHeadFootText(SwFrameFormat & rHeadFootFormat, const bool bIsHeader)
- : SwXText(rHeadFootFormat.GetDoc(),
+SwXHeadFootText::SwXHeadFootText(SwFrameFormat& rHeadFootFormat, const bool bIsHeader)
+ : SwXText(
+ rHeadFootFormat.GetDoc(),
bIsHeader ? CursorType::Header : CursorType::Footer)
- , m_pImpl( new SwXHeadFootText::Impl(rHeadFootFormat, bIsHeader) )
+ , m_pImpl(new SwXHeadFootText::Impl(rHeadFootFormat, bIsHeader))
{
}
SwXHeadFootText::~SwXHeadFootText()
-{
-}
+{ }
OUString SAL_CALL
SwXHeadFootText::getImplementationName()
{
- return OUString("SwXHeadFootText");
+ return "SwXHeadFootText";
}
-static char const*const g_ServicesHeadFootText[] =
-{
- "com.sun.star.text.Text",
-};
-
sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName)
{
return cppu::supportsService(this, rServiceName);
}
-uno::Sequence< OUString > SAL_CALL
+uno::Sequence<OUString> SAL_CALL
SwXHeadFootText::getSupportedServiceNames()
{
- return ::sw::GetSupportedServiceNamesImpl(
- SAL_N_ELEMENTS(g_ServicesHeadFootText),
- g_ServicesHeadFootText);
+ return {"com.sun.star.text.Text"};
}
-const SwStartNode *SwXHeadFootText::GetStartNode() const
+const SwStartNode* SwXHeadFootText::GetStartNode() const
{
- const SwStartNode *pSttNd = nullptr;
- SwFrameFormat *const pHeadFootFormat = m_pImpl->GetHeadFootFormat();
+ const SwStartNode* pSttNd = nullptr;
+ SwFrameFormat* const pHeadFootFormat = m_pImpl->GetHeadFootFormat();
if(pHeadFootFormat)
{
const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
- if( rFlyContent.GetContentIdx() )
+ if(rFlyContent.GetContentIdx())
{
pSttNd = rFlyContent.GetContentIdx()->GetNode().GetStartNode();
}
@@ -2562,43 +2545,38 @@ const SwStartNode *SwXHeadFootText::GetStartNode() const
return pSttNd;
}
-uno::Reference< text::XTextCursor >
-SwXHeadFootText::CreateCursor()
+uno::Reference<text::XTextCursor> SwXHeadFootText::CreateCursor()
{
return createTextCursor();
}
-uno::Sequence< uno::Type > SAL_CALL
-SwXHeadFootText::getTypes()
+uno::Sequence<uno::Type> SAL_CALL SwXHeadFootText::getTypes()
{
- const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes();
- const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
- return ::comphelper::concatSequences(aTypes, aTextTypes);
+ return ::comphelper::concatSequences(
+ SwXHeadFootText_Base::getTypes(),
+ SwXText::getTypes());
}
-uno::Sequence< sal_Int8 > SAL_CALL
-SwXHeadFootText::getImplementationId()
+uno::Sequence<sal_Int8> SAL_CALL SwXHeadFootText::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
-uno::Any SAL_CALL
-SwXHeadFootText::queryInterface(const uno::Type& rType)
+uno::Any SAL_CALL SwXHeadFootText::queryInterface(const uno::Type& rType)
{
const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType);
return (ret.getValueType() == cppu::UnoType<void>::get())
- ? SwXText::queryInterface(rType)
- : ret;
+ ? SwXText::queryInterface(rType)
+ : ret;
}
-uno::Reference< text::XTextCursor > SAL_CALL
+uno::Reference<text::XTextCursor> SAL_CALL
SwXHeadFootText::createTextCursor()
{
SolarMutexGuard aGuard;
SwFrameFormat & rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
- uno::Reference< text::XTextCursor > xRet;
const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
SwPosition aPos(rNode);
@@ -2624,8 +2602,7 @@ SwXHeadFootText::createTextCursor()
{
rUnoCursor.GetPoint()->nContent.Assign(pCont, 0);
}
- SwStartNode const*const pNewStartNode =
- rUnoCursor.GetNode().FindSttNodeByType(
+ SwStartNode const*const pNewStartNode = rUnoCursor.GetNode().FindSttNodeByType(
(m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
if (!pNewStartNode || (pNewStartNode != pOwnStartNode))
{
@@ -2633,69 +2610,65 @@ SwXHeadFootText::createTextCursor()
aExcept.Message = "no text available";
throw aExcept;
}
- xRet = static_cast<text::XWordCursor*>(pXCursor);
- return xRet;
+ return static_cast<text::XWordCursor*>(pXCursor);
}
-uno::Reference< text::XTextCursor > SAL_CALL
-SwXHeadFootText::createTextCursorByRange(
- const uno::Reference< text::XTextRange > & xTextPosition)
+uno::Reference<text::XTextCursor> SAL_CALL SwXHeadFootText::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& xTextPosition)
{
SolarMutexGuard aGuard;
-
- SwFrameFormat & rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
+ SwFrameFormat& rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
SwUnoInternalPaM aPam(*GetDoc());
- if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition))
+ if (!sw::XTextRangeToSwPaM(aPam, xTextPosition))
{
uno::RuntimeException aRuntime;
aRuntime.Message = cInvalidObject;
throw aRuntime;
}
- uno::Reference< text::XTextCursor > xRet;
SwNode& rNode = rHeadFootFormat.GetContent().GetContentIdx()->GetNode();
SwPosition aPos(rNode);
SwPaM aHFPam(aPos);
aHFPam.Move(fnMoveForward, GoInNode);
- SwStartNode *const pOwnStartNode = aHFPam.GetNode().FindSttNodeByType(
+ SwStartNode* const pOwnStartNode = aHFPam.GetNode().FindSttNodeByType(
(m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
- SwStartNode *const p1 = aPam.GetNode().FindSttNodeByType(
+ SwStartNode* const p1 = aPam.GetNode().FindSttNodeByType(
(m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
if (p1 == pOwnStartNode)
{
- xRet = static_cast<text::XWordCursor*>(
- new SwXTextCursor(*GetDoc(), this,
+ return static_cast<text::XWordCursor*>(
+ new SwXTextCursor(
+ *GetDoc(),
+ this,
(m_pImpl->m_bIsHeader) ? CursorType::Header : CursorType::Footer,
*aPam.GetPoint(), aPam.GetMark()));
}
- return xRet;
+ return nullptr;
}
-uno::Reference< container::XEnumeration > SAL_CALL
-SwXHeadFootText::createEnumeration()
+uno::Reference<container::XEnumeration> SAL_CALL SwXHeadFootText::createEnumeration()
{
SolarMutexGuard aGuard;
-
- SwFrameFormat & rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
+ SwFrameFormat& rHeadFootFormat(m_pImpl->GetHeadFootFormatOrThrow());
const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
SwPosition aPos(rNode);
auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
pUnoCursor->Move(fnMoveForward, GoInNode);
- return SwXParagraphEnumeration::Create(this, pUnoCursor, (m_pImpl->m_bIsHeader) ? CursorType::Header : CursorType::Footer);
+ return SwXParagraphEnumeration::Create(
+ this,
+ pUnoCursor,
+ (m_pImpl->m_bIsHeader)
+ ? CursorType::Header
+ : CursorType::Footer);
}
-uno::Type SAL_CALL
-SwXHeadFootText::getElementType()
-{
- return cppu::UnoType<text::XTextRange>::get();
-}
+uno::Type SAL_CALL SwXHeadFootText::getElementType()
+ { return cppu::UnoType<text::XTextRange>::get(); }
sal_Bool SAL_CALL SwXHeadFootText::hasElements()
-{
- return true;
-}
+ { return true; }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cc81012a92dfbca52e9a5f281c23ef33176895d2
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date: Thu May 10 10:51:42 2018 +0200
dont use SwClient/SwModify in unocore: TextMarkup
Change-Id: I160ca544122609a5c35b6bf2739581769cd46295
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 1fa043fcd44a..50cc3a75172f 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -70,7 +70,10 @@ namespace com { namespace sun { namespace star {
typedef std::set< sal_Int32 > SwSoftPageBreakList;
/// SwTextNode is a paragraph in the document model.
-class SW_DLLPUBLIC SwTextNode: public SwContentNode, public ::sfx2::Metadatable
+class SW_DLLPUBLIC SwTextNode
+ : public SwContentNode
+ , public ::sfx2::Metadatable
+ , public sw::BroadcasterMixin
{
friend class SwContentNode;
/// For creating the first TextNode.
diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx
index 094e5909613f..1cd5d76e779a 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -19,6 +19,7 @@
#include <unotextmarkup.hxx>
+#include <svl/listener.hxx>
#include <vcl/svapp.hxx>
#include <SwSmartTagMgr.hxx>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
@@ -43,20 +44,20 @@
using namespace ::com::sun::star;
struct SwXTextMarkup::Impl
- : public SwClient
+ : public SvtListener
{
SwTextNode* m_pTextNode;
ModelToViewHelper const m_ConversionMap;
- Impl(SwTextNode *const pTextNode, const ModelToViewHelper& rMap)
- : SwClient(pTextNode)
- , m_pTextNode(pTextNode)
+ Impl(SwTextNode* const pTextNode, const ModelToViewHelper& rMap)
+ : m_pTextNode(pTextNode)
, m_ConversionMap(rMap)
{
+ if(m_pTextNode)
+ StartListening(pTextNode->GetNotifier());
}
- // SwClient
- virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+ virtual void Notify(const SfxHint& rHint) override;
};
SwXTextMarkup::SwXTextMarkup(
@@ -77,6 +78,7 @@ SwTextNode* SwXTextMarkup::GetTextNode()
void SwXTextMarkup::ClearTextNode()
{
m_pImpl->m_pTextNode = nullptr;
+ m_pImpl->EndListeningAll();
}
const ModelToViewHelper& SwXTextMarkup::GetConversionMap()
@@ -474,11 +476,13 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
finishGrammarCheck(*m_pImpl->m_pTextNode);
}
-void SwXTextMarkup::Impl::Modify( const SfxPoolItem* /*pOld*/, const SfxPoolItem* /*pNew*/ )
+void SwXTextMarkup::Impl::Notify(const SfxHint& rHint)
{
DBG_TESTSOLARMUTEX();
- EndListeningAll();
- m_pTextNode = nullptr;
+ if(rHint.GetId() == SfxHintId::Dying)
+ {
+ m_pTextNode = nullptr;
+ }
}
SwXStringKeyMap::SwXStringKeyMap()
commit 74b0602a82a8599fab52d6f58d18d0f39946280d
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date: Thu May 10 10:51:42 2018 +0200
dont use SwClient/SwModify in unocore: Section
Change-Id: Ic594c5129664b309ce1b6ddd0c715a17df5a3265
Reviewed-on: https://gerrit.libreoffice.org/54091
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 9f809ea24dbd..595a3deab14d 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SW_INC_CALBCK_HXX
#include <svl/hint.hxx>
+#include <svl/broadcast.hxx>
#include <svl/poolitem.hxx>
#include "swdllapi.h"
#include "ring.hxx"
@@ -71,6 +72,19 @@ namespace sw
virtual ~ModifyChangedHint() override;
const SwModify* m_pNew;
};
+ // Observer pattern using svl implementation
+ // use this instead of SwClient/SwModify whereever possible
+ // In writer layout, this might not always be possible,
+ // but for listeners outside of it (e.g. unocore) this should be used.
+ // The only "magic" signal this class issues is a ModifyChangedHint
+ // proclaiming its death. It does NOT however provide a new SwModify for
+ // listeners to switch to like the old SwModify/SwClient did, as that leads
+ // to madness.
+ class SW_DLLPUBLIC BroadcasterMixin {
+ SvtBroadcaster m_aNotifier;
+ public:
+ SvtBroadcaster& GetNotifier() { return m_aNotifier; }
+ };
/// refactoring out the some of the more sane SwClient functionality
class SW_DLLPUBLIC WriterListener
{
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 30b582b89a80..eb4cc6913f38 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -270,6 +270,7 @@ enum class SectionSort { Not, Pos };
class SW_DLLPUBLIC SwSectionFormat
: public SwFrameFormat
, public ::sfx2::Metadatable
+ , public sw::BroadcasterMixin
{
friend class SwDoc;
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index ec5197cbbfcd..188299134f04 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -29,6 +29,7 @@
#include <cmdid.h>
#include <hintids.hxx>
#include <svl/urihelper.hxx>
+#include <svl/listener.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/xmlcnitm.hxx>
#include <sfx2/linkmgr.hxx>
@@ -100,7 +101,7 @@ struct SwTextSectionProperties_Impl
};
class SwXTextSection::Impl
- : public SwClient
+ : public SvtListener
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
@@ -114,25 +115,33 @@ public:
bool m_bIsDescriptor;
OUString m_sName;
std::unique_ptr<SwTextSectionProperties_Impl> m_pProps;
+ SwSectionFormat* m_pFormat;
- Impl( SwXTextSection & rThis,
- SwSectionFormat *const pFormat, const bool bIndexHeader)
- : SwClient(pFormat)
+ Impl( SwXTextSection& rThis,
+ SwSectionFormat* const pFormat, const bool bIndexHeader)
+ : SvtListener()
, m_rThis(rThis)
, m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION))
, m_EventListeners(m_Mutex)
, m_bIndexHeader(bIndexHeader)
, m_bIsDescriptor(nullptr == pFormat)
, m_pProps(pFormat ? nullptr : new SwTextSectionProperties_Impl())
+ , m_pFormat(pFormat)
{
+ if(m_pFormat)
+ StartListening(m_pFormat->GetNotifier());
}
- SwSectionFormat * GetSectionFormat() const
+ void Attach(SwSectionFormat* pFormat)
{
- return static_cast<SwSectionFormat*>(const_cast<SwModify*>(
- GetRegisteredIn()));
+ EndListeningAll();
+ StartListening(pFormat->GetNotifier());
+ m_pFormat = pFormat;
}
+ SwSectionFormat* GetSectionFormat() const
+ { return m_pFormat; }
+
SwSectionFormat & GetSectionFormatOrThrow() const {
SwSectionFormat *const pFormat( GetSectionFormat() );
if (!pFormat) {
@@ -155,27 +164,22 @@ public:
uno::Sequence< uno::Any >
GetPropertyValues_Impl(
const uno::Sequence< OUString >& rPropertyNames);
-protected:
- // SwClient
- virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
-
+ virtual void Notify(const SfxHint& rHint) override;
};
-void SwXTextSection::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
+void SwXTextSection::Impl::Notify(const SfxHint& rHint)
{
- ClientModify(this, pOld, pNew);
- if (GetRegisteredIn())
+ if(rHint.GetId() == SfxHintId::Dying)
{
- return; // core object still alive
- }
-
- uno::Reference<uno::XInterface> const xThis(m_wThis);
- if (!xThis.is())
- { // fdo#72695: if UNO object is already dead, don't revive it with event
- return;
+ m_pFormat = nullptr;
+ uno::Reference<uno::XInterface> const xThis(m_wThis);
+ if (!xThis.is())
+ { // fdo#72695: if UNO object is already dead, don't revive it with event
+ return;
+ }
+ lang::EventObject const ev(xThis);
+ m_EventListeners.disposeAndClear(ev);
}
- lang::EventObject const ev(xThis);
- m_EventListeners.disposeAndClear(ev);
}
SwSectionFormat * SwXTextSection::GetFormat() const
@@ -407,7 +411,7 @@ SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange)
"SwXTextSection::attach(): invalid TextRange",
static_cast< ::cppu::OWeakObject*>(this), 0);
}
- pRet->GetFormat()->Add(m_pImpl.get());
+ m_pImpl->Attach(pRet->GetFormat());
pRet->GetFormat()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
// XML import must hide sections depending on their old
commit 8484e52675052848d2d3ffe07378ce2ad29fd288
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri May 11 00:22:06 2018 +0900
tdf#117427 missing API for determining and loading linked graphic
This adds 2 properties to GraphicDescriptor:
"Linked" - to indicate if the graphic is a linked one
"OriginURL" - the URL of the location from where the graphic was
or will be loaded (and is linked to)
Additionally GraphicProvider was extended with a "LoadAsLink"
(media)property, which can be passed using queryGraphic method.
If "LoadAsLink" is set to true, then the Graphic will be created
as a linked one.
In addition the tests for this API was added to VCL (home of this
API implementors).
Change-Id: Ibdabe5e7780d1b372d1e66c3e19b18779fee2c9a
Reviewed-on: https://gerrit.libreoffice.org/54090
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/offapi/com/sun/star/graphic/GraphicDescriptor.idl b/offapi/com/sun/star/graphic/GraphicDescriptor.idl
index 183519c8a708..daf3c88f9e3e 100644
--- a/offapi/com/sun/star/graphic/GraphicDescriptor.idl
+++ b/offapi/com/sun/star/graphic/GraphicDescriptor.idl
@@ -136,6 +136,18 @@ published service GraphicDescriptor
querying for the GraphicDescriptor</p>
*/
[optional, property] boolean Animated;
+
+ /** Indicates that the graphic is an external linked graphic
+
+ @since LibreOffice 6.1
+ */
+ [optional, property] boolean Linked;
+
+ /** The URL of the location from where the graphic was loaded from
+
+ @since LibreOffice 6.1
+ */
+ [optional, property] string OriginURL;
};
} ; } ; } ; } ;
diff --git a/vcl/CppunitTest_vcl_apitests.mk b/vcl/CppunitTest_vcl_apitests.mk
new file mode 100644
index 000000000000..83c618b06184
--- /dev/null
+++ b/vcl/CppunitTest_vcl_apitests.mk
@@ -0,0 +1,64 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_apitests))
+
+$(eval $(call gb_CppunitTest_set_include,vcl_apitests,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_apitests, \
+ vcl/qa/api/XGraphicTest \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_apitests,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_apitests, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ svt \
+ test \
+ tl \
+ unotest \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_api,vcl_apitests,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_apitests))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_apitests))
+$(eval $(call gb_CppunitTest_use_configuration,vcl_apitests))
+
+$(eval $(call gb_CppunitTest_use_components,vcl_apitests,\
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ filter/source/config/cache/filterconfig1 \
+ filter/source/storagefilterdetect/storagefd \
+ i18npool/util/i18npool \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ svtools/util/svt \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
+ unotools/util/utl \
+ uui/util/uui \
+ vcl/vcl.common \
+))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 3005538a966c..a3db18b5413d 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -203,6 +203,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\
CppunitTest_vcl_pdfexport \
CppunitTest_vcl_errorhandler \
CppunitTest_vcl_bitmap_render_test \
+ CppunitTest_vcl_apitests \
))
diff --git a/vcl/qa/api/XGraphicTest.cxx b/vcl/qa/api/XGraphicTest.cxx
new file mode 100644
index 000000000000..1dc9a1c1fe65
--- /dev/null
+++ b/vcl/qa/api/XGraphicTest.cxx
@@ -0,0 +1,246 @@
+/* -*- 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/graphic/GraphicType.hpp>
+#include <com/sun/star/graphic/GraphicProvider.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/Size.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+
+#include <rtl/uri.hxx>
+
+namespace
+{
+using namespace css;
+
+class XGraphicTest : public test::BootstrapFixture
+{
+public:
+ OUString maDataUrl;
+
+ XGraphicTest()
+ : BootstrapFixture(true, false)
+ , maDataUrl("/vcl/qa/api/data/")
+ {
+ }
+
+ OUString getFullUrl(const OUString& sFileName)
+ {
+ return m_directories.getURLFromSrc(maDataUrl) + sFileName;
+ }
+
+ void testGraphic();
+ void testGraphicDescriptor();
+ void testGraphicProvider();
+
+ CPPUNIT_TEST_SUITE(XGraphicTest);
+ CPPUNIT_TEST(testGraphic);
+ CPPUNIT_TEST(testGraphicDescriptor);
+ CPPUNIT_TEST(testGraphicProvider);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+BitmapEx createBitmap()
+{
+ Bitmap aBitmap(Size(100, 50), 24);
+ aBitmap.Erase(COL_LIGHTRED);
+
+ return BitmapEx(aBitmap);
+}
+
+void XGraphicTest::testGraphic()
+{
+ Graphic aGraphic;
+ uno::Reference<graphic::XGraphic> xGraphic = aGraphic.GetXGraphic();
+}
+
+void XGraphicTest::testGraphicDescriptor()
+{
+ Graphic aGraphic(createBitmap());
+ uno::Reference<graphic::XGraphic> xGraphic = aGraphic.GetXGraphic();
+ uno::Reference<beans::XPropertySet> xGraphicDescriptor(xGraphic, uno::UNO_QUERY_THROW);
+
+ //[property] byte GraphicType;
+ sal_Int8 nType;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("GraphicType") >>= nType);
+ CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, nType);
+
+ //[property] string MimeType;
+ OUString sMimeType;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("MimeType") >>= sMimeType);
+ CPPUNIT_ASSERT_EQUAL(OUString("image/x-vclgraphic"), sMimeType);
+
+ //[optional, property] ::com::sun::star::awt::Size SizePixel;
+ awt::Size aSizePixel;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("SizePixel") >>= aSizePixel);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aSizePixel.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(50), aSizePixel.Height);
+
+ //[optional, property] ::com::sun::star::awt::Size Size100thMM;
+ awt::Size aSize100thMM;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Size100thMM") >>= aSize100thMM);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSize100thMM.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSize100thMM.Height);
+
+ //[optional, property] byte BitsPerPixel;
+ sal_Int8 nBitsPerPixel;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("BitsPerPixel") >>= nBitsPerPixel);
+ CPPUNIT_ASSERT_EQUAL(sal_Int8(24), nBitsPerPixel);
+
+ //[optional, property] boolean Transparent;
+ bool bTransparent;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Transparent") >>= bTransparent);
+ CPPUNIT_ASSERT_EQUAL(false, bTransparent);
+
+ //[optional, property] boolean Alpha;
+ bool bAlpha;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Alpha") >>= bAlpha);
+ CPPUNIT_ASSERT_EQUAL(false, bAlpha);
+
+ //[optional, property] boolean Animated;
+ bool bAnimated;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Animated") >>= bAnimated);
+ CPPUNIT_ASSERT_EQUAL(false, bAnimated);
+}
+
+void XGraphicTest::testGraphicProvider()
+{
+ OUString aGraphicURL = getFullUrl("TestGraphic.png");
+
+ { // Load lazy
+ uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ uno::Reference<graphic::XGraphicProvider> xGraphicProvider;
+ xGraphicProvider.set(graphic::GraphicProvider::create(xContext), uno::UNO_QUERY_THROW);
+
+ auto aMediaProperties(comphelper::InitPropertySequence({
+ { "URL", uno::makeAny(aGraphicURL) },
+ { "LazyRead", uno::makeAny(true) },
+ { "LoadAsLink", uno::makeAny(false) },
+ }));
+
+ uno::Reference<graphic::XGraphic> xGraphic(
+ xGraphicProvider->queryGraphic(aMediaProperties));
+ CPPUNIT_ASSERT(xGraphic.is());
+ Graphic aGraphic(xGraphic);
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+
+ uno::Reference<beans::XPropertySet> xGraphicDescriptor(xGraphic, uno::UNO_QUERY_THROW);
+
+ sal_Int8 nType;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("GraphicType") >>= nType);
+ CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, nType);
+
+ awt::Size aSizePixel;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("SizePixel") >>= aSizePixel);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Height);
+
+ bool bLinked;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Linked") >>= bLinked);
+ CPPUNIT_ASSERT_EQUAL(false, bLinked);
+
+ OUString sOriginURL;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("OriginURL") >>= sOriginURL);
+ CPPUNIT_ASSERT_EQUAL(OUString(), sOriginURL);
+
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ }
+
+ { // Load as link
+ uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ uno::Reference<graphic::XGraphicProvider> xGraphicProvider;
+ xGraphicProvider.set(graphic::GraphicProvider::create(xContext), uno::UNO_QUERY_THROW);
+
+ auto aMediaProperties(comphelper::InitPropertySequence({
+ { "URL", uno::makeAny(aGraphicURL) },
+ { "LazyRead", uno::makeAny(false) },
+ { "LoadAsLink", uno::makeAny(true) },
+ }));
+
+ uno::Reference<graphic::XGraphic> xGraphic(
+ xGraphicProvider->queryGraphic(aMediaProperties));
+ CPPUNIT_ASSERT(xGraphic.is());
+ Graphic aGraphic(xGraphic);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ uno::Reference<beans::XPropertySet> xGraphicDescriptor(xGraphic, uno::UNO_QUERY_THROW);
+
+ sal_Int8 nType;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("GraphicType") >>= nType);
+ CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, nType);
+
+ awt::Size aSizePixel;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("SizePixel") >>= aSizePixel);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Height);
+
+ bool bLinked;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Linked") >>= bLinked);
+ CPPUNIT_ASSERT_EQUAL(true, bLinked);
+
+ OUString sOriginURL;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("OriginURL") >>= sOriginURL);
+ CPPUNIT_ASSERT_EQUAL(aGraphicURL, sOriginURL);
+ }
+
+ { // Load lazy and as link
+ uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ uno::Reference<graphic::XGraphicProvider> xGraphicProvider;
+ xGraphicProvider.set(graphic::GraphicProvider::create(xContext), uno::UNO_QUERY_THROW);
+
+ auto aMediaProperties(comphelper::InitPropertySequence({
+ { "URL", uno::makeAny(aGraphicURL) },
+ { "LazyRead", uno::makeAny(true) },
+ { "LoadAsLink", uno::makeAny(true) },
+ }));
+
+ uno::Reference<graphic::XGraphic> xGraphic(
+ xGraphicProvider->queryGraphic(aMediaProperties));
+ CPPUNIT_ASSERT(xGraphic.is());
+ Graphic aGraphic(xGraphic);
+
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+
+ uno::Reference<beans::XPropertySet> xGraphicDescriptor(xGraphic, uno::UNO_QUERY_THROW);
+
+ sal_Int8 nType;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("GraphicType") >>= nType);
+ CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, nType);
+
+ awt::Size aSizePixel;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("SizePixel") >>= aSizePixel);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aSizePixel.Height);
+
+ bool bLinked;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("Linked") >>= bLinked);
+ CPPUNIT_ASSERT_EQUAL(true, bLinked);
+
+ OUString sOriginURL;
+ CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("OriginURL") >>= sOriginURL);
+ CPPUNIT_ASSERT_EQUAL(aGraphicURL, sOriginURL);
+
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ }
+}
+
+} // namespace
+
+CPPUNIT_TEST_SUITE_REGISTRATION(XGraphicTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/api/data/TestGraphic.png b/vcl/qa/api/data/TestGraphic.png
new file mode 100644
index 000000000000..fe0c3c8ae437
Binary files /dev/null and b/vcl/qa/api/data/TestGraphic.png differ
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 2b263bcab354..61e062a43467 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1535,7 +1535,10 @@ bool ImpGraphic::loadPrepared()
Graphic aGraphic;
if (mpGfxLink->LoadNative(aGraphic))
{
+ GraphicExternalLink aLink = maGraphicExternalLink;
*this = *aGraphic.ImplGetImpGraphic();
+ maGraphicExternalLink = aLink;
+
return true;
}
return false;
diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx b/vcl/source/graphic/UnoGraphicDescriptor.cxx
index 49e1c01769cd..6f4a37af2c17 100644
--- a/vcl/source/graphic/UnoGraphicDescriptor.cxx
+++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx
@@ -34,7 +34,6 @@
#include <vcl/svapp.hxx>
#include <memory>
-
enum class UnoGraphicProperty
{
GraphicType = 1
@@ -45,6 +44,8 @@ enum class UnoGraphicProperty
, Transparent = 6
, Alpha = 7
, Animated = 8
+ , Linked = 9
+ , OriginURL = 10
};
@@ -241,6 +242,9 @@ rtl::Reference<::comphelper::PropertySetInfo> GraphicDescriptor::createPropertyS
{ OUString( "Transparent" ), static_cast< sal_Int32 >( UnoGraphicProperty::Transparent ), cppu::UnoType< sal_Bool >::get(), beans::PropertyAttribute::READONLY, 0 },
{ OUString( "Alpha" ), static_cast< sal_Int32 >( UnoGraphicProperty::Alpha ), cppu::UnoType< sal_Bool >::get(), beans::PropertyAttribute::READONLY, 0 },
{ OUString( "Animated" ), static_cast< sal_Int32 >( UnoGraphicProperty::Animated ), cppu::UnoType< sal_Bool >::get(), beans::PropertyAttribute::READONLY, 0 },
+ { OUString("Linked"), sal_Int32(UnoGraphicProperty::Linked), cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::READONLY, 0 },
+ { OUString("OriginURL"), sal_Int32(UnoGraphicProperty::OriginURL), cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
+
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
@@ -327,7 +331,7 @@ void GraphicDescriptor::_getPropertyValues( const comphelper::PropertyMapEntry**
{
if( mpGraphic->GetType() == GraphicType::Bitmap )
{
- const Size aSizePix( mpGraphic->GetBitmapEx().GetSizePixel() );
+ const Size aSizePix( mpGraphic->GetSizePixel() );
aAWTSize = awt::Size( aSizePix.Width(), aSizePix.Height() );
}
}
@@ -393,6 +397,22 @@ void GraphicDescriptor::_getPropertyValues( const comphelper::PropertyMapEntry**
*pValues <<= mpGraphic && mpGraphic->IsAnimated();
}
break;
+
+ case UnoGraphicProperty::Linked:
+ {
+ *pValues <<= mpGraphic && !mpGraphic->getOriginURL().isEmpty();
+ }
+ break;
+
+ case UnoGraphicProperty::OriginURL:
+ {
+ OUString aOriginURL;
+ if (mpGraphic)
+ aOriginURL = mpGraphic->getOriginURL();
+
+ *pValues <<= aOriginURL;
+ }
+ break;
}
++ppEntries;
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx
index 7adb183f5aa8..3576213fd9b2 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -305,6 +305,8 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
uno::Sequence< ::beans::PropertyValue > aFilterData;
bool bLazyRead = false;
+ bool bLoadAsLink = false;
+
for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !pIStm && !xRet.is(); ++i )
{
const OUString aName( rMediaProperties[ i ].Name );
@@ -329,7 +331,13 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
aValue >>= aFilterData;
}
else if (aName == "LazyRead")
+ {
aValue >>= bLazyRead;
+ }
+ else if (aName == "LoadAsLink")
+ {
+ aValue >>= bLoadAsLink;
+ }
}
// Check for the goal width and height if they are defined
@@ -384,7 +392,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
::GraphicFilter& rFilter = ::GraphicFilter::GetGraphicFilter();
{
- ::Graphic aVCLGraphic;
+ Graphic aVCLGraphic;
// Define APM Header if goal height and width are defined
WmfExternal aExtHeader;
@@ -412,6 +420,9 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
if( (error == ERRCODE_NONE ) &&
( aVCLGraphic.GetType() != GraphicType::NONE ) )
{
+ if (!aPath.isEmpty() && bLoadAsLink)
+ aVCLGraphic.setOriginURL(aPath);
+
::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
pUnoGraphic->init( aVCLGraphic );
commit 3e2fdcf48055572dd0f6bb7d73b14c1832622f24
Author: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
Date: Sat May 12 02:30:33 2018 -0500
Updated core
Project: help 5f14059e0d87ac3552b02436405b129c1c3257e1
Helponline: Only add extra <p> margin for main body text
Change-Id: Ia6413bbe4e16ee39dbd01ba48fa307514f517fbe
diff --git a/helpcontent2 b/helpcontent2
index 1b94db073c7f..5f14059e0d87 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit 1b94db073c7f918ff11d005cfb150da1ddd5cf8c
+Subproject commit 5f14059e0d87ac3552b02436405b129c1c3257e1
commit 23c5125148a8110d88385b29570bf0b7d4400458
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Thu May 10 15:46:06 2018 +0200
Use HarfBuzz to get Kashida width
One less platform-specific piece of code.
Change-Id: Ib04c5f1434046e26ead2aaedace67127a5513e55
Reviewed-on: https://gerrit.libreoffice.org/54098
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 8bd6584c6154..90ed83d3ab33 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -67,6 +67,8 @@ public: // TODO: make data members private
const PhysicalFontFace* GetFontFace() const { return m_pFontFace; }
const ImplFontCache* GetFontCache() const { return mpFontCache; }
+ int GetKashidaWidth();
+
void GetScale(double* nXScale, double* nYScale);
static inline void DecodeOpenTypeTag(const uint32_t nTableTag, char* pTagName);
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 1d6969d906a0..064b2125e8be 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -90,7 +90,7 @@ class CoreTextStyle : public LogicalFontInstance
public:
~CoreTextStyle();
- void GetFontMetric( ImplFontMetricDataRef const & ) const;
+ void GetFontMetric( ImplFontMetricDataRef const & );
bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) const;
bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) const;
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 2af33b0d97a5..f3c38647c3a8 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -67,13 +67,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel)
rFMD->SetWidth(aRawFont.averageCharWidth());
- const QChar nKashidaCh[2] = { 0x06, 0x40 };
- quint32 nKashidaGid = 0;
- QPointF aPoint;
- int nNumGlyphs;
- if (aRawFont.glyphIndexesForChars(nKashidaCh, 1, &nKashidaGid, &nNumGlyphs)
- && aRawFont.advancesForGlyphIndexes(&nKashidaGid, &aPoint, 1))
- rFMD->SetMinKashida(lrint(aPoint.rx()));
+ rFMD->SetMinKashida(m_pTextStyle[nFallbackLevel]->GetKashidaWidth());
}
const FontCharMapRef Qt5Graphics::GetFontCharMap() const
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index be615a1ee377..ac20c1e9f4c5 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -104,7 +104,7 @@ CoreTextStyle::~CoreTextStyle()
CFRelease( mpStyleDict );
}
-void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric ) const
+void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric )
{
// get the matching CoreText font handle
// TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here?
@@ -133,18 +133,7 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric )
// it also makes the calculation of the stretch factor simple
rxFontMetric->SetWidth( lrint( CTFontGetSize( aCTFontRef ) * mfFontStretch) );
- UniChar nKashidaCh = 0x0640;
- CGGlyph nKashidaGid = 0;
- if (CTFontGetGlyphsForCharacters(aCTFontRef, &nKashidaCh, &nKashidaGid, 1))
- {
-SAL_WNODEPRECATED_DECLARATIONS_PUSH
- // 'kCTFontHorizontalOrientation' is deprecated: first deprecated in
- // macOS 10.11
- double nKashidaAdv = CTFontGetAdvancesForGlyphs(aCTFontRef,
- kCTFontHorizontalOrientation, &nKashidaGid, nullptr, 1);
-SAL_WNODEPRECATED_DECLARATIONS_POP
- rxFontMetric->SetMinKashida(lrint(nKashidaAdv));
- }
+ rxFontMetric->SetMinKashida(GetKashidaWidth());
}
bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect ) const
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 845eb2e9e635..6837329fbfaf 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -79,6 +79,22 @@ hb_font_t* LogicalFontInstance::InitHbFont(hb_face_t* pHbFace) const
return pHbFont;
}
+int LogicalFontInstance::GetKashidaWidth()
+{
+ hb_font_t* pHbFont = GetHbFont();
+ hb_position_t nWidth = 0;
+ hb_codepoint_t nIndex = 0;
+
+ if (hb_font_get_glyph(pHbFont, 0x0640, 0, &nIndex))
+ {
+ double nXScale = 0;
+ GetScale(&nXScale, nullptr);
+ nWidth = hb_font_get_glyph_h_advance(pHbFont, nIndex) * nXScale;
+ }
+
+ return nWidth;
+}
+
void LogicalFontInstance::GetScale(double* nXScale, double* nYScale)
{
hb_face_t* pHbFace = hb_font_get_face(GetHbFont());
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 33a3a0c83ed3..aac35c3b3f7b 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -643,11 +643,7 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
hb_font_t *pHbFont = mpFont->GetHbFont();
// Find Kashida glyph width and index.
if (hb_font_get_glyph(pHbFont, 0x0640, 0, &nKashidaIndex))
- {
- double nXScale = 0;
- mpFont->GetScale(&nXScale, nullptr);
- nKashidaWidth = hb_font_get_glyph_h_advance(pHbFont, nKashidaIndex) * nXScale;
- }
+ nKashidaWidth = mpFont->GetKashidaWidth();
bKashidaJustify = nKashidaWidth != 0;
}
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 6476950e5fe5..9bc310b67afd 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -549,16 +549,7 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const
}
// initialize kashida width
- const int nKashidaGlyphId = FT_Get_Char_Index(maFaceFT, 0x0640);
- if( nKashidaGlyphId )
- {
- if (FT_Load_Glyph(maFaceFT, nKashidaGlyphId, mnLoadFlags) == FT_Err_Ok)
- {
- int nWidth = (maFaceFT->glyph->metrics.horiAdvance + 32) >> 6;
- rxTo->SetMinKashida(nWidth);
- }
- }
-
+ rxTo->SetMinKashida(mpFontInstance->GetKashidaWidth());
}
void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 62d9f7d85dd7..e1c26ed902a2 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -997,15 +997,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
const RawFontData aHheaRawData(getHDC(), nHheaTag);
const RawFontData aOS2RawData(getHDC(), nOS2Tag);
- WCHAR nKashidaCh = 0x0640;
- WORD nKashidaGid;
- DWORD ret = GetGlyphIndicesW(getHDC(), &nKashidaCh, 1, &nKashidaGid, GGI_MARK_NONEXISTING_GLYPHS);
- if (ret != GDI_ERROR && nKashidaGid != 0xFFFF)
- {
- int nKashidaWidth = 0;
- if (GetCharWidthI(getHDC(), nKashidaGid, 1, nullptr, &nKashidaWidth))
- rxFontMetric->SetMinKashida(static_cast<int>(mfFontScale[nFallbackLevel] * nKashidaWidth));
- }
+ rxFontMetric->SetMinKashida(mpWinFontEntry[nFallbackLevel]->GetKashidaWidth());
// get the font metric
OUTLINETEXTMETRICW aOutlineMetric;
commit 1a3deaa7f7ff1d7e6ab5f5d551bcbc8c00d84052
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 11 15:35:09 2018 +0100
coverity#705646 Resource leak
Change-Id: I709b16f720cf97c05207cfb22d0c0ea15622367a
Reviewed-on: https://gerrit.libreoffice.org/54139
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index f0ea18fa3bdc..f7062a13f283 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -496,7 +496,6 @@ void SaneDlg::InitFields()
pField->SetMax( static_cast<long>(pDouble[ nValue-1 ]) );
else
pField->SetMax( static_cast<long>(pDouble[ 1 ]) );
- delete [] pDouble;
}
switch( i ) {
case 0: aMinTopLeft.setX( pField->GetMin() );break;
@@ -514,6 +513,7 @@ void SaneDlg::InitFields()
case 3: aMaxBottomRight.setY( static_cast<int>(fValue) );break;
}
}
+ delete [] pDouble;
pField->Enable();
}
else
commit 850995b2c22db7c3ddbcc8ebfad5bcbc0b01f029
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 11 13:56:03 2018 +0100
weld SdPhotoAlbumDialog
Change-Id: I46cca94bb43e1b1cd9757b22baad9bb3f61bc15d
Reviewed-on: https://gerrit.libreoffice.org/54132
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx
index babfe9d84baf..27fb17ddd9ed 100644
--- a/sd/inc/sdabstdlg.hxx
+++ b/sd/inc/sdabstdlg.hxx
@@ -206,7 +206,7 @@ public:
virtual CreateTabPage GetSdOptionsMiscTabPageCreatorFunc() = 0;
virtual CreateTabPage GetSdOptionsSnapTabPageCreatorFunc() = 0;
- virtual VclPtr<VclAbstractDialog> CreateSdPhotoAlbumDialog( vcl::Window* pWindow, SdDrawDocument* pDoc) = 0;
+ virtual VclPtr<VclAbstractDialog> CreateSdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pDoc) = 0;
protected:
~SdAbstractDialogFactory() {}
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index f926f0be7948..8a2d6603ac55 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -278,7 +278,7 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
}
case 1:
{
- // CreateBreakDlg(vcl::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override;
+ // CreateBreakDlg(weld::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override;
// this dialog requires pDrawView. It does not show much when
// there is no object selected that can be broken up. For better
// results it might be necessary to add/select an object that
@@ -397,7 +397,7 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
}
case 10:
{
- // CreateMorphDlg(vcl::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) override;
+ // CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
@@ -542,7 +542,7 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
}
case 19:
{
- // CreateSdVectorizeDlg(vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override;
+ // CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override;
// works well with empty Bitmap, but my be nicer with setting one
Bitmap aEmptyBitmap;
auto const parent = Application::GetDefDialogParent();
@@ -554,17 +554,18 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
}
case 20:
{
- // CreateSdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pDoc) override;
+ // CreateSdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pDoc) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
+ auto const parent = Application::GetDefDialogParent();
pRetval = getSdAbstractDialogFactory()->CreateSdPhotoAlbumDialog(
- Application::GetDefDialogParent(),
+ parent == nullptr ? nullptr : parent->GetFrameWeld(),
pDrawDoc);
break;
}
case 21:
{
- // CreateMasterLayoutDialog(vcl::Window* pParent, SdDrawDocument* pDoc, SdPage*) override;
+ // CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index d7af857f86d8..863121b9b201 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -39,106 +39,80 @@
namespace sd
{
-SdPhotoAlbumDialog::SdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pActDoc)
-: ModalDialog(pWindow, "PhotoAlbumCreatorDialog", "modules/simpress/ui/photoalbum.ui"),
- pDoc(pActDoc)
+SdPhotoAlbumDialog::SdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pActDoc)
+ : GenericDialogController(pWindow, "modules/simpress/ui/photoalbum.ui", "PhotoAlbumCreatorDialog")
+ , m_pDoc(pActDoc)
+ , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
+ , m_xCreateBtn(m_xBuilder->weld_button("ok"))
+ , m_xAddBtn(m_xBuilder->weld_button("add_btn"))
+ , m_xUpBtn(m_xBuilder->weld_button("up_btn"))
+ , m_xDownBtn(m_xBuilder->weld_button("down_btn"))
+ , m_xRemoveBtn(m_xBuilder->weld_button("rem_btn"))
+ , m_xImagesLst(m_xBuilder->weld_tree_view("images_tree"))
+ , m_xImg(new SvxGraphCtrl(*m_xBuilder, "preview_img"))
+ , m_xInsTypeCombo(m_xBuilder->weld_combo_box_text("opt_combo"))
+ , m_xASRCheck(m_xBuilder->weld_check_button("asr_check"))
+ , m_xASRCheckCrop(m_xBuilder->weld_check_button("asr_check_crop"))
+ , m_xCapCheck(m_xBuilder->weld_check_button("cap_check"))
+ , m_xInsertAsLinkCheck(m_xBuilder->weld_check_button("insert_as_link_check"))
{
- get(pCancelBtn, "cancel");
- get(pCreateBtn, "ok");
-
- get(pAddBtn, "add_btn");
- get(pUpBtn, "up_btn");
- get(pDownBtn, "down_btn");
- get(pRemoveBtn, "rem_btn");
-
- get(pImagesLst, "images_tree");
- get(pImg, "preview_img");
-
- get(pInsTypeCombo, "opt_combo");
- get(pASRCheck, "asr_check");
- get(pASRCheckCrop, "asr_check_crop");
- get(pCapCheck, "cap_check");
- get(pInsertAsLinkCheck, "insert_as_link_check");
-
- pCancelBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, CancelHdl));
- pCreateBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, CreateHdl));
-
- pAddBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, FileHdl));
- pUpBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, UpHdl));
- pUpBtn->Disable();
- pDownBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, DownHdl));
- pDownBtn->Disable();
- pRemoveBtn->SetClickHdl(LINK(this, SdPhotoAlbumDialog, RemoveHdl));
- pRemoveBtn->Disable();
- pImagesLst->SetSelectHdl(LINK(this, SdPhotoAlbumDialog, SelectHdl));
- pInsTypeCombo->SetSelectHdl(LINK(this, SdPhotoAlbumDialog, TypeSelectHdl));
-
- mpGraphicFilter = new GraphicFilter;
- pAddBtn->GrabFocus();
- pImagesLst->Clear();
+ m_xCancelBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, CancelHdl));
+ m_xCreateBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, CreateHdl));
+
+ m_xAddBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, FileHdl));
+ m_xUpBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, UpHdl));
+ m_xUpBtn->set_sensitive(false);
+ m_xDownBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, DownHdl));
+ m_xDownBtn->set_sensitive(false);
+ m_xRemoveBtn->connect_clicked(LINK(this, SdPhotoAlbumDialog, RemoveHdl));
+ m_xRemoveBtn->set_sensitive(false);
+ m_xImagesLst->connect_changed(LINK(this, SdPhotoAlbumDialog, SelectHdl));
+ m_xInsTypeCombo->connect_changed(LINK(this, SdPhotoAlbumDialog, TypeSelectHdl));
+
+ m_pGraphicFilter = new GraphicFilter;
+ m_xAddBtn->grab_focus();
}
SdPhotoAlbumDialog::~SdPhotoAlbumDialog()
{
- disposeOnce();
}
-void SdPhotoAlbumDialog::dispose()
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, CancelHdl, weld::Button&, void)
{
- pCancelBtn.clear();
- pCreateBtn.clear();
- pAddBtn.clear();
- pUpBtn.clear();
- pDownBtn.clear();
- pRemoveBtn.clear();
- pImagesLst.clear();
- pImg.clear();
- pInsTypeCombo.clear();
- pASRCheck.clear();
- pASRCheckCrop.clear();
- pCapCheck.clear();
- pInsertAsLinkCheck.clear();
- ModalDialog::dispose();
+ m_xDialog->response(RET_CANCEL);
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, CancelHdl, Button*, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, weld::Button&, void)
{
- Close();
-}
-
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
-{
- if (pImagesLst->GetEntryCount() == 0)
+ if (m_xImagesLst->n_children() == 0)
{
- std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok,
SdResId(STR_PHOTO_ALBUM_EMPTY_WARNING)));
xWarn->run();
}
else
{
- Reference< drawing::XDrawPagesSupplier > xDPS( pDoc->getUnoModel(), uno::UNO_QUERY );
+ Reference< drawing::XDrawPagesSupplier > xDPS( m_pDoc->getUnoModel(), uno::UNO_QUERY );
Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY );
- Reference< lang::XMultiServiceFactory > xShapeFactory( pDoc->getUnoModel(), uno::UNO_QUERY );
+ Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDoc->getUnoModel(), uno::UNO_QUERY );
Reference< XComponentContext > xContext(::comphelper::getProcessComponentContext());
Reference< graphic::XGraphicProvider> xProvider(graphic::GraphicProvider::create(xContext));
// determine if to use Captions (use TitleObject) and choose the correct AutoLayout
// from the beginning
- const bool bCreateCaptions(pCapCheck->IsChecked());
- const bool bInsertAsLink(pInsertAsLinkCheck->IsChecked());
+ const bool bCreateCaptions(m_xCapCheck->get_active());
+ const bool bInsertAsLink(m_xInsertAsLinkCheck->get_active());
const AutoLayout aAutoLayout(bCreateCaptions ? AUTOLAYOUT_TITLE_ONLY : AUTOLAYOUT_NONE);
// get the option
- const sal_Int32 nOpt = pInsTypeCombo->GetSelectedEntryPos();
- if ( nOpt == ONE_IMAGE )
+ const int nOpt = m_xInsTypeCombo->get_active();
+ if (nOpt == ONE_IMAGE)
{
- OUString sUrl;
- for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); ++i )
+ for( sal_Int32 i = 0; i < m_xImagesLst->n_children(); ++i )
{
- OUString const * pData = static_cast<OUString const *>(pImagesLst->GetEntryData(i));
- sUrl = *pData;
+ OUString sUrl = m_xImagesLst->get_id(i);
Reference< drawing::XDrawPage > xSlide = appendNewSlide(aAutoLayout, xDrawPages);
Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY );
@@ -167,12 +141,12 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked() && !pASRCheckCrop->IsChecked())
+ if (m_xASRCheck->get_active() && !m_xASRCheckCrop->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, aPageSize);
}
- else if(pASRCheckCrop->IsChecked())
+ else if (m_xASRCheckCrop->get_active())
{
aPicSize = createASRSizeCrop(aPicSize, aPageSize);
}
@@ -196,13 +170,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
}
else if( nOpt == TWO_IMAGES )
{
- OUString sUrl1("");
- OUString sUrl2("");
-
- for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=2 )
+ for( sal_Int32 i = 0; i < m_xImagesLst->n_children(); i+=2 )
{
- OUString const * pData = nullptr;
-
// create the slide
Reference< drawing::XDrawPage > xSlide = appendNewSlide(aAutoLayout, xDrawPages);
Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY );
@@ -215,13 +184,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
"Height") >>= aPageSize.Height;
// grab the left one
- void* pD1 = pImagesLst->GetEntryData(i);
- pData = static_cast<OUString const *>(pD1);
- sUrl1 = pData ? *pData : "";
+ OUString sUrl1 = m_xImagesLst->get_id(i);
// grab the right one
- void* pD2 = pImagesLst->GetEntryData(i+1);
- pData = static_cast<OUString const *>(pD2);
- sUrl2 = pData ? *pData : "";
+ OUString sUrl2 = m_xImagesLst->get_id(i+1);
if( !sUrl1.isEmpty() )
{
@@ -242,7 +207,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -286,7 +251,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -317,14 +282,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
}
else if( nOpt == FOUR_IMAGES )
{
- OUString sUrl1("");
- OUString sUrl2("");
- OUString sUrl3("");
- OUString sUrl4("");
-
- for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=4 )
+ for( sal_Int32 i = 0; i < m_xImagesLst->n_children(); i+=4 )
{
- OUString* pData = nullptr;
// create the slide
Reference< drawing::XDrawPage > xSlide = appendNewSlide(aAutoLayout, xDrawPages);
Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY );
@@ -337,24 +296,16 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
"Height") >>= aPageSize.Height;
// grab the upper left one
- void* pD1 = pImagesLst->GetEntryData(i);
- pData = static_cast<OUString*>(pD1);
- sUrl1 = pData ? *pData : "";
+ OUString sUrl1 = m_xImagesLst->get_id(i);
// grab the upper right one
- void* pD2 = pImagesLst->GetEntryData(i+1);
- pData = static_cast<OUString *>(pD2);
- sUrl2 = pData ? *pData : "";
+ OUString sUrl2 = m_xImagesLst->get_id(i+1);
// grab the lower left one
- void* pD3 = pImagesLst->GetEntryData(i+2);
- pData = static_cast<OUString*>(pD3);
- sUrl3 = pData ? *pData : "";
+ OUString sUrl3 = m_xImagesLst->get_id(i+2);
// grab the lower right one
- void* pD4 = pImagesLst->GetEntryData(i+3);
- pData = static_cast<OUString*>(pD4);
- sUrl4 = pData ? *pData : "";
+ OUString sUrl4 = m_xImagesLst->get_id(i+3);
if( !sUrl1.isEmpty() )
{
@@ -375,7 +326,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -418,7 +369,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -461,7 +412,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -504,7 +455,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
::awt::Point aPicPos;
- if(pASRCheck->IsChecked())
+ if (m_xASRCheck->get_active())
{
// Resize the image, with keeping ASR
aPicSize = createASRSize(aPicSize, ::awt::Size(aPageSize.Width/2 - 100, aPageSize.Height/2 - 100));
@@ -534,20 +485,20 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void)
}
else
{
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
"Function is not implemented!"));
xInfoBox->run();
}
- EndDialog();
+ m_xDialog->response(RET_OK);
}
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, Button*, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, weld::Button&, void)
{
::sfx2::FileDialogHelper aDlg(
css::ui::dialogs::TemplateDescription::FILEOPEN_PREVIEW,
- FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, GetFrameWeld());
+ FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get());
// Read configuration
OUString sUrl(officecfg::Office::Impress::Pictures::Path::get());
@@ -575,85 +526,71 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, Button*, void)
{
// Store full path, show filename only. Use INetURLObject to display spaces in filename correctly
INetURLObject aUrl = INetURLObject(aFilesArr[i]);
- sal_Int16 nPos = pImagesLst->InsertEntry( aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset) );
- pImagesLst->SetEntryData(nPos, new OUString(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)));
+ m_xImagesLst->append(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset), "");
}
}
}
EnableDisableButtons();
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, UpHdl, Button*, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, UpHdl, weld::Button&, void)
{
- if (pImagesLst->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND
- && pImagesLst->GetSelectedEntryPos() != 0)
+ const int nActPos = m_xImagesLst->get_selected_index();
+ if (nActPos != -1 && nActPos != 0)
{
- const sal_Int32 nActPos = pImagesLst->GetSelectedEntryPos();
- OUString sActEntry( pImagesLst->GetEntry(nActPos) );
+ OUString sActEntry(m_xImagesLst->get_text(nActPos));
// actual data
- OUString* pActData = static_cast<OUString*>(pImagesLst->GetEntryData(nActPos));
- OUString sAct(*pActData);
+ OUString sAct(m_xImagesLst->get_id(nActPos));
- OUString sUpperEntry( pImagesLst->GetEntry(nActPos - 1) );
+ OUString sUpperEntry(m_xImagesLst->get_text(nActPos - 1));
// upper data
- OUString* pUpperData = static_cast<OUString*>(pImagesLst->GetEntryData(nActPos - 1));
- OUString sUpper(*pUpperData);
-
- pImagesLst->RemoveEntry( sActEntry );
- pImagesLst->RemoveEntry( sUpperEntry );
+ OUString sUpper(m_xImagesLst->get_id(nActPos - 1));
- pImagesLst->InsertEntry( sActEntry, nActPos - 1 );
- pImagesLst->SetEntryData( nActPos - 1, new OUString(sAct));
+ m_xImagesLst->remove_text(sActEntry);
+ m_xImagesLst->remove_text(sUpperEntry);
- pImagesLst->InsertEntry( sUpperEntry, nActPos );
- pImagesLst->SetEntryData( nActPos, new OUString(sUpper));
+ m_xImagesLst->insert(nActPos - 1, sAct, sActEntry, "");
+ m_xImagesLst->insert(nActPos, sUpper, sUpperEntry, "");
- pImagesLst->SelectEntryPos(nActPos - 1);
+ m_xImagesLst->select(nActPos - 1);
}
EnableDisableButtons();
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, Button*, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, weld::Button&, void)
{
- const sal_Int32 nActPos = pImagesLst->GetSelectedEntryPos();
- if (!pImagesLst->GetEntry(nActPos + 1).isEmpty())
+ const int nActPos = m_xImagesLst->get_selected_index();
+ if (!m_xImagesLst->get_text(nActPos + 1).isEmpty())
{
- OUString sActEntry( pImagesLst->GetSelectedEntry() );
- OUString* pActData = static_cast<OUString*>(pImagesLst->GetSelectedEntryData());
- OUString sAct(*pActData);
-
- OUString sDownEntry( pImagesLst->GetEntry(nActPos + 1) );
- OUString* pDownData = static_cast<OUString*>(pImagesLst->GetEntryData(nActPos + 1));
- OUString sDown(*pDownData);
-
- pImagesLst->RemoveEntry( sActEntry );
- pImagesLst->RemoveEntry( sDownEntry );
+ OUString sActEntry(m_xImagesLst->get_selected_text());
+ OUString sAct(m_xImagesLst->get_selected_id());
- pImagesLst->InsertEntry( sDownEntry, nActPos );
- pImagesLst->SetEntryData( nActPos, new OUString(sDown));
+ OUString sDownEntry(m_xImagesLst->get_text(nActPos + 1));
+ OUString sDown(m_xImagesLst->get_id(nActPos + 1));
- pImagesLst->InsertEntry( sActEntry, nActPos + 1 );
- pImagesLst->SetEntryData( nActPos + 1, new OUString(sAct));
+ m_xImagesLst->remove_text(sActEntry);
+ m_xImagesLst->remove_text(sDownEntry);
- pImagesLst->SelectEntryPos(nActPos + 1);
+ m_xImagesLst->insert(nActPos, sDown, sDownEntry, "");
+ m_xImagesLst->insert(nActPos + 1, sAct, sActEntry, "");
+ m_xImagesLst->select(nActPos + 1);
}
EnableDisableButtons();
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, RemoveHdl, Button*, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, RemoveHdl, weld::Button&, void)
{
- pImagesLst->RemoveEntry( pImagesLst->GetSelectedEntryPos() );
- pImg->SetImage(Image());
+ m_xImagesLst->remove(m_xImagesLst->get_selected_index());
+ m_xImg->SetGraphic(Graphic());
EnableDisableButtons();
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, ListBox&, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, weld::TreeView&, void)
{
- OUString* pData = static_cast<OUString*>(pImagesLst->GetSelectedEntryData());
- OUString sImgUrl = pData ? *pData : "";
+ OUString sImgUrl = m_xImagesLst->get_selected_id();
if (sImgUrl != SdResId(STR_PHOTO_ALBUM_TEXTBOX))
{
@@ -676,14 +613,14 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, ListBox&, void)
SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( sImgUrl, StreamMode::READ );
if( pStream )
- mpGraphicFilter->ImportGraphic( aGraphic, sImgUrl, *pStream, nFilter, nullptr, nFilterImportFlags );
+ m_pGraphicFilter->ImportGraphic( aGraphic, sImgUrl, *pStream, nFilter, nullptr, nFilterImportFlags );
else
- mpGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags );
+ m_pGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags );
delete pStream;
}
else
{
- mpGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags );
+ m_pGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags );
}
Bitmap aBmp = aGraphic.GetBitmap();
@@ -698,23 +635,23 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, ListBox&, void)
aBmp.Scale( nYRatio, nYRatio );
aBmp.Convert( BmpConversion::N24Bit );
- pImg->SetImage(Image(aBmp));
+ m_xImg->SetGraphic(Graphic(aBmp));
}
else
{
- pImg->SetImage(Image());
+ m_xImg->SetGraphic(Graphic());
}
EnableDisableButtons();
}
-IMPL_LINK_NOARG(SdPhotoAlbumDialog, TypeSelectHdl, ListBox&, void)
+IMPL_LINK_NOARG(SdPhotoAlbumDialog, TypeSelectHdl, weld::ComboBoxText&, void)
{
// Enable "Fill Slide" only for one image
// If we want to have it for other images too, we need to implement the actual cropping.
- bool const bEnable = pInsTypeCombo->GetSelectedEntryPos() == ONE_IMAGE;
- pASRCheckCrop->Enable(bEnable);
+ bool const bEnable = m_xInsTypeCombo->get_active() == ONE_IMAGE;
+ m_xASRCheckCrop->set_sensitive(bEnable);
if (!bEnable)
- pASRCheckCrop->Check(false);
+ m_xASRCheckCrop->set_active(false);
}
Reference< drawing::XDrawPage > SdPhotoAlbumDialog::appendNewSlide(AutoLayout aLayout,
@@ -724,7 +661,7 @@ Reference< drawing::XDrawPage > SdPhotoAlbumDialog::appendNewSlide(AutoLayout aL
Reference< drawing::XDrawPage > xSlide; // Create the slide
Reference< container::XIndexAccess > xIndexAccess( xDrawPages, uno::UNO_QUERY );
xSlide = xDrawPages->insertNewByIndex( xIndexAccess->getCount() );
- SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PageKind::Standard)-1, PageKind::Standard);
+ SdPage* pSlide = m_pDoc->GetSdPage( m_pDoc->GetSdPageCount(PageKind::Standard)-1, PageKind::Standard);
pSlide->SetAutoLayout(aLayout, true); // Set the layout here
return xSlide;
}
@@ -799,7 +736,7 @@ void SdPhotoAlbumDialog::createCaption(const awt::Size& aPageSize )
CapSize.setHeight( aPageSize.Height/6 );
CapPos.setX( 0 );
CapPos.setY( aPageSize.Height - CapSize.Height() );
- SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PageKind::Standard)-1, PageKind::Standard );
+ SdPage* pSlide = m_pDoc->GetSdPage( m_pDoc->GetSdPageCount(PageKind::Standard)-1, PageKind::Standard );
// try to get existing PresObj
const ::tools::Rectangle rRect(CapPos,CapSize);
@@ -826,7 +763,7 @@ void SdPhotoAlbumDialog::createCaption(const awt::Size& aPageSize )
if(pSdrObj)
{
// set color, style and some transparency
- SfxItemSet aSet(pDoc->GetItemPool() );
+ SfxItemSet aSet(m_pDoc->GetItemPool() );
aSet.Put( XFillStyleItem(drawing::FillStyle_SOLID) );
aSet.Put( XFillColorItem( "", COL_BLACK ) );
@@ -849,11 +786,11 @@ Reference< graphic::XGraphic> SdPhotoAlbumDialog::createXGraphicFromUrl(const OU
void SdPhotoAlbumDialog::EnableDisableButtons()
{
- pRemoveBtn->Enable(pImagesLst->GetSelectedEntryCount() > 0);
- pUpBtn->Enable(pImagesLst->GetSelectedEntryCount() > 0 &&
- pImagesLst->GetSelectedEntryPos() != 0);
- pDownBtn->Enable(pImagesLst->GetSelectedEntryCount() > 0 &&
- pImagesLst->GetSelectedEntryPos() < pImagesLst->GetEntryCount()-1);
+ m_xRemoveBtn->set_sensitive(m_xImagesLst->count_selected_rows() > 0);
+ m_xUpBtn->set_sensitive(m_xImagesLst->count_selected_rows() > 0 &&
+ m_xImagesLst->get_selected_index() != 0);
+ m_xDownBtn->set_sensitive(m_xImagesLst->count_selected_rows() > 0 &&
+ m_xImagesLst->get_selected_index() < m_xImagesLst->n_children() - 1);
}
} // end of namespace sd
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
index 0294f05ba120..7ec396eb3fb9 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
@@ -15,12 +15,9 @@
#include <pres.hxx>
#include <drawdoc.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/button.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/field.hxx>
+#include <vcl/weld.hxx>
#include <vcl/graphicfilter.hxx>
+#include <svx/graphctl.hxx>
#include <svx/svdotext.hxx>
#include <svx/svdobj.hxx>
@@ -41,44 +38,40 @@ using namespace ::com::sun::star::presentation;
namespace sd
{
-class SdPhotoAlbumDialog : public ModalDialog
+class SdPhotoAlbumDialog : public weld::GenericDialogController
{
public:
- SdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pActDoc);
+ SdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pActDoc);
virtual ~SdPhotoAlbumDialog() override;
- virtual void dispose() override;
private:
- VclPtr<CancelButton> pCancelBtn;
- VclPtr<PushButton> pCreateBtn;
-
- VclPtr<PushButton> pAddBtn;
- VclPtr<PushButton> pUpBtn;
- VclPtr<PushButton> pDownBtn;
- VclPtr<PushButton> pRemoveBtn;
-
- VclPtr<ListBox> pImagesLst;
- VclPtr<FixedImage> pImg;
-
- VclPtr<ListBox> pInsTypeCombo;
- VclPtr<CheckBox> pASRCheck;
- VclPtr<CheckBox> pASRCheckCrop;
- VclPtr<CheckBox> pCapCheck;
- VclPtr<CheckBox> pInsertAsLinkCheck;
-
- SdDrawDocument* pDoc;
- GraphicFilter* mpGraphicFilter;
-
- DECL_LINK(CancelHdl, Button*, void);
- DECL_LINK(CreateHdl, Button*, void);
-
- DECL_LINK(FileHdl, Button*, void);
- DECL_LINK(UpHdl, Button*, void);
- DECL_LINK(DownHdl, Button*, void);
- DECL_LINK(RemoveHdl, Button*, void);
-
- DECL_LINK(SelectHdl, ListBox&, void);
- DECL_LINK(TypeSelectHdl, ListBox&, void);
+ SdDrawDocument* m_pDoc;
+ GraphicFilter* m_pGraphicFilter;
+
+ std::unique_ptr<weld::Button> m_xCancelBtn;
+ std::unique_ptr<weld::Button> m_xCreateBtn;
+ std::unique_ptr<weld::Button> m_xAddBtn;
+ std::unique_ptr<weld::Button> m_xUpBtn;
+ std::unique_ptr<weld::Button> m_xDownBtn;
+ std::unique_ptr<weld::Button> m_xRemoveBtn;
+ std::unique_ptr<weld::TreeView> m_xImagesLst;
+ std::unique_ptr<SvxGraphCtrl> m_xImg;
+ std::unique_ptr<weld::ComboBoxText> m_xInsTypeCombo;
+ std::unique_ptr<weld::CheckButton> m_xASRCheck;
+ std::unique_ptr<weld::CheckButton> m_xASRCheckCrop;
+ std::unique_ptr<weld::CheckButton> m_xCapCheck;
+ std::unique_ptr<weld::CheckButton> m_xInsertAsLinkCheck;
+
+ DECL_LINK(CancelHdl, weld::Button&, void);
+ DECL_LINK(CreateHdl, weld::Button&, void);
+
+ DECL_LINK(FileHdl, weld::Button&, void);
+ DECL_LINK(UpHdl, weld::Button&, void);
+ DECL_LINK(DownHdl, weld::Button&, void);
+ DECL_LINK(RemoveHdl, weld::Button&, void);
+
+ DECL_LINK(SelectHdl, weld::TreeView&, void);
+ DECL_LINK(TypeSelectHdl, weld::ComboBoxText&, void);
Reference< drawing::XDrawPage > appendNewSlide(AutoLayout aLayout,
const Reference< drawing::XDrawPages >& xDrawPages);
@@ -97,7 +90,6 @@ private:
TWO_IMAGES,
FOUR_IMAGES
};
-
};
} // end of namespace sd
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index c0b8d950d158..f609fca3a774 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -47,6 +47,12 @@
#include "PhotoAlbumDialog.hxx"
IMPL_ABSTDLG_BASE(SdVclAbstractDialog_Impl);
+
+short SdAbstractGenericDialog_Impl::Execute()
+{
+ return m_xDlg->run();
+}
+
IMPL_ABSTDLG_BASE(AbstractCopyDlg_Impl);
short AbstractSdCustomShowDlg_Impl::Execute()
@@ -455,9 +461,9 @@ VclPtr<AbstractHeaderFooterDialog> SdAbstractDialogFactory_Impl::CreateHeaderFoo
return VclPtr<AbstractHeaderFooterDialog_Impl>::Create( VclPtr<::sd::HeaderFooterDialog>::Create( pViewShell, pParent, pDoc, pCurrentPage ));
}
-VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateSdPhotoAlbumDialog( vcl::Window* pParent, SdDrawDocument* pDoc )
+VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateSdPhotoAlbumDialog(weld::Window* pParent, SdDrawDocument* pDoc)
{
- return VclPtr<SdVclAbstractDialog_Impl>::Create( VclPtr<::sd::SdPhotoAlbumDialog>::Create( pParent, pDoc ) );
+ return VclPtr<SdAbstractGenericDialog_Impl>::Create(new sd::SdPhotoAlbumDialog(pParent, pDoc));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 55765fb23861..a6f5319dba38 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -64,6 +64,18 @@ class SdVclAbstractDialog_Impl : public VclAbstractDialog
DECL_ABSTDLG_BASE(SdVclAbstractDialog_Impl,Dialog)
};
+class SdAbstractGenericDialog_Impl : public VclAbstractDialog
+{
+protected:
+ std::unique_ptr<weld::GenericDialogController> m_xDlg;
+public:
+ explicit SdAbstractGenericDialog_Impl(weld::GenericDialogController* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
+};
+
class AbstractMasterLayoutDialog_Impl : public VclAbstractDialog
{
private:
@@ -289,7 +301,7 @@ public:
virtual VclPtr<AbstractSdVectorizeDlg> CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override;
virtual VclPtr<AbstractSdPublishingDlg> CreateSdPublishingDlg(vcl::Window* pWindow, DocumentType eDocType) override;
- virtual VclPtr<VclAbstractDialog> CreateSdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pDoc) override;
+ virtual VclPtr<VclAbstractDialog> CreateSdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pDoc) override;
virtual VclPtr<VclAbstractDialog> CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) override;
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index c5d376270269..18b9b01b24cc 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -256,8 +256,9 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
if (pFact)
{
+ vcl::Window* pWin = mrSlideSorter.GetContentWindow();
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
- mrSlideSorter.GetContentWindow(),
+ pWin ? pWin->GetFrameWeld() : nullptr,
pDocument));
pDlg->Execute();
}
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 3f6e477e5165..5a9649b48eaf 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -3320,8 +3320,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
if (pFact)
{
+ vcl::Window* pWin = GetActiveWindow();
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
- GetActiveWindow(),
+ pWin ? pWin->GetFrameWeld() : nullptr,
GetDoc()));
pDlg->Execute();
diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx
index ec6496c446a6..d5dddac528f1 100644
--- a/sd/source/ui/view/outlnvs2.cxx
+++ b/sd/source/ui/view/outlnvs2.cxx
@@ -309,8 +309,9 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
if (pFact)
{
+ vcl::Window* pWin = GetActiveWindow();
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
- GetActiveWindow(),
+ pWin ? pWin->GetFrameWeld() : nullptr,
GetDoc()));
pDlg->Execute();
diff --git a/sd/uiconfig/simpress/ui/photoalbum.ui b/sd/uiconfig/simpress/ui/photoalbum.ui
index 2ad9d1df394b..9ef2c289d5be 100644
--- a/sd/uiconfig/simpress/ui/photoalbum.ui
+++ b/sd/uiconfig/simpress/ui/photoalbum.ui
@@ -4,32 +4,20 @@
<requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1">
<columns>
- <!-- column-name Filename -->
+ <!-- column-name text -->
<column type="gchararray"/>
- </columns>
- </object>
- <object class="GtkListStore" id="liststore2">
- <columns>
- <!-- column-name Property -->
+ <!-- column-name id -->
<column type="gchararray"/>
</columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="photoalbum|liststore2">1 Image</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="photoalbum|liststore2">2 Images</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="photoalbum|liststore2">4 Images</col>
- </row>
- </data>
</object>
<object class="GtkDialog" id="PhotoAlbumCreatorDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="photoalbum|PhotoAlbumCreatorDialog">Create Photo Album</property>
+ <property name="modal">True</property>
<property name="window_position">center</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -108,27 +96,35 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="width_request">300</property>
- <property name="height_request">200</property>
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="images_tree:border">
- <property name="width_request">300</property>
- <property name="height_request">200</property>
+ <object class="GtkTreeView" id="images_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
<property name="search_column">0</property>
- <property name="enable_grid_lines">both</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -249,15 +245,13 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkImage" id="preview_img">
+ <object class="GtkDrawingArea" id="preview_img">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="vexpand">True</property>
- <property name="yalign">0</property>
- <property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">False</property>
@@ -313,18 +307,16 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="opt_combo">
+ <object class="GtkComboBoxText" id="opt_combo">
<property name="width_request">160</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="model">liststore2</property>
<property name="active">0</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <items>
+ <item translatable="yes" context="photoalbum|liststore2">1 Image</item>
+ <item translatable="yes" context="photoalbum|liststore2">2 Images</item>
+ <item translatable="yes" context="photoalbum|liststore2">4 Images</item>
+ </items>
</object>
<packing>
<property name="expand">False</property>
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
index 5f959499f97b..e656d0e18673 100644
--- a/svx/source/dialog/graphctl.cxx
+++ b/svx/source/dialog/graphctl.cxx
@@ -788,6 +788,7 @@ IMPL_LINK(SvxGraphCtrl, DoResize, const Size&, rSize, void)
IMPL_LINK(SvxGraphCtrl, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
{
vcl::RenderContext& rRenderContext = aPayload.first;
+ rRenderContext.Erase();
const bool bGraphicValid(GraphicType::NONE != aGraphic.GetType());
// #i73381# in non-SdrMode, paint to local directly
if (bGraphicValid && aGraphSize.Width() && aGraphSize.Height())
commit 96998e0f4c35fb9c7d39e6bb3a31b194874b091c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 11 11:16:54 2018 +0100
Resolves: tdf#117475 page properties change triggers page reorder event
and page reorder remove and re-inserts the slide in the slide sorter, so the
selected page property is removed when the page doesn't really get removed. So
then there's no selection to apply the later master page property to.
Change-Id: I4a32958542da1bf2f5041dde0294a772645e30ad
Reviewed-on: https://gerrit.libreoffice.org/54126
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
index 0837c565e5a5..e5d859f743be 100644
--- a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
+++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
@@ -216,8 +216,9 @@ private:
void AdaptSize();
SdPage* GetPage (const sal_Int32 nCoreIndex) const;
- void InsertSlide (SdPage* pPage);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list