[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source xmloff/source

2018-02-19 Thread Armin Le Grand
 sw/inc/grfatr.hxx  |   10 +++---
 sw/source/core/graphic/grfatr.cxx  |   28 +++-
 xmloff/source/text/XMLTextFrameContext.cxx |8 
 xmloff/source/text/txtparae.cxx|   11 +++
 4 files changed, 53 insertions(+), 4 deletions(-)

New commits:
commit 58607318bf39053d2f20d47ae8e3e69e6b3eeb04
Author: Armin Le Grand 
Date:   Thu Feb 15 15:41:50 2018 +0100

tdf#115519: Handle rotation for WriterFlyFrames correctly

Adapted due to no transformation is written here, but still
controlling the values of persistent data is a good thing.

Change-Id: I5f29b3640eaf24d63c64edfecd6732f336582640
Reviewed-on: https://gerrit.libreoffice.org/49826
Tested-by: Jenkins 
Reviewed-by: Armin Le Grand 
Reviewed-on: https://gerrit.libreoffice.org/49897
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/inc/grfatr.hxx b/sw/inc/grfatr.hxx
index d4aa180dcddc..9d3d52f57985 100644
--- a/sw/inc/grfatr.hxx
+++ b/sw/inc/grfatr.hxx
@@ -92,14 +92,18 @@ public:
 
 class SwRotationGrf : public SfxUInt16Item
 {
+private:
 Size aUnrotatedSize;
+
+// tdf#15529 check and evtl. correct value, it is in 10th
+// degrees and *has* to be in the range [0 .. 3600[
+sal_Int16 checkAndCorrectValue(sal_Int16 nValue);
+
 public:
 SwRotationGrf( sal_Int16 nVal = 0 )
 : SfxUInt16Item( RES_GRFATR_ROTATION, nVal )
 {}
-SwRotationGrf( sal_Int16 nVal, const Size& rSz )
-: SfxUInt16Item( RES_GRFATR_ROTATION, nVal ), aUnrotatedSize( rSz )
-{}
+SwRotationGrf( sal_Int16 nVal, const Size& rSz );
 
 // pure virtual methods from SfxInt16Item
 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/sw/source/core/graphic/grfatr.cxx 
b/sw/source/core/graphic/grfatr.cxx
index 71cf98283d6b..163a5bcb600f 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -158,6 +158,31 @@ SfxPoolItem* SwCropGrf::Clone( SfxItemPool* ) const
 return new SwCropGrf( *this );
 }
 
+sal_Int16 SwRotationGrf::checkAndCorrectValue(sal_Int16 nValue)
+{
+if(nValue < 0)
+{
+// smaller zero, modulo (will keep negative) and add one range
+DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to 
be in [0 .. 3600[ (!)");
+return 3600 + (nValue % 3600);
+}
+else if (nValue > 3600)
+{
+// bigger range, use modulo
+DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to 
be in [0 .. 3600[ (!)");
+return nValue % 3600;
+}
+
+return nValue;
+}
+
+SwRotationGrf::SwRotationGrf( sal_Int16 nVal, const Size& rSz )
+// tdf#15529 check and evtl. correct value
+:   SfxUInt16Item( RES_GRFATR_ROTATION, checkAndCorrectValue(nVal) ),
+aUnrotatedSize( rSz )
+{
+}
+
 SfxPoolItem* SwRotationGrf::Clone( SfxItemPool * ) const
 {
 return new SwRotationGrf( GetValue(), aUnrotatedSize );
@@ -185,7 +210,8 @@ bool SwRotationGrf::PutValue( const uno::Any& rVal, 
sal_uInt8 )
 if (rVal >>= nValue)
 {
 // sal_uInt16 argument needed
-SetValue( (sal_uInt16) nValue );
+// tdf#15529 check and evtl. correct value
+SetValue(static_cast(checkAndCorrectValue(nValue)));
 return true;
 }
 
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx 
b/xmloff/source/text/XMLTextFrameContext.cxx
index e7f81a6e6d27..2e0a50bb3f6b 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1058,6 +1058,14 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
 {
 // RotGrfFlyFrame: is in 10th degrees
 nRotation = (sal_Int16)(nVal % 3600 );
+
+// tdf#115519 may be negative, with the above modulo 
maximal -3599, so
+// no loop needed here. nRotation is used in 
setPropertyValue("GraphicRotation")
+// and *has* to be in the range [0 .. 3600[
+if(nRotation < 0)
+{
+nRotation += 3600;
+}
 }
 }
 }
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 41bd0d503898..763058f270b7 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3092,6 +3092,17 @@ void XMLTextParagraphExport::_exportTextGraphic(
 rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal;
 if( nVal != 0 )
 {
+// tdf#115519 may be bigger 3600 or negative,
+// correct to range [0 .. 3600[
+if(nVal > 0)
+{
+nVal %= 3600;
+}
+else if(nVal < 0)
+{
+ 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source sw/uiconfig xmloff/source

2018-01-10 Thread Bernhard Widl
Rebased ref, commits from common ancestor:
commit 93949cb1a1f8d7273cbc7e956a1b6309ddf88d92
Author: Bernhard Widl 
Date:   Wed Nov 15 19:30:28 2017 +0100

tdf#101856 create bookmarks w/ new hidden/cond attrs, save as odt

Change-Id: Ibf067f7862d9d70d00d2e45ab0fcf74ec2fe1175

diff --git a/sw/inc/IMark.hxx b/sw/inc/IMark.hxx
index a132b6a3c0a4..aa9854c41475 100644
--- a/sw/inc/IMark.hxx
+++ b/sw/inc/IMark.hxx
@@ -86,6 +86,10 @@ namespace sw { namespace mark
 virtual const vcl::KeyCode& GetKeyCode() const =0;
 virtual void SetShortName(const OUString&) =0;
 virtual void SetKeyCode(const vcl::KeyCode&) =0;
+virtual bool IsHidden() const =0;
+virtual const OUString& GetHideCondition() const =0;
+virtual void Hide(bool hide) =0;
+virtual void SetHideCondition(const OUString&) =0;
 private:
 IBookmark(IBookmark&) = delete;
 IBookmark  =(IBookmark const&) = delete;
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 09cd1f48513c..36a93cef8ba7 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -814,6 +814,8 @@
 #define FN_PARAM_PAM(FN_PARAM2+27) /* Point and Mark */
 #define FN_TEXT_BOX (FN_PARAM2+28) /* TextBox Property*/
 #define FN_PARAM_IGNORE_PROTECTED   (FN_PARAM2+29) /* Ignore protected 
areas */
+#define FN_BOOKMARK_HIDDEN  (FN_PARAM2+30) /* Hidden Property of 
bookmarks*/
+#define FN_BOOKMARK_CONDITION   (FN_PARAM2+31) /* Condition Property 
of bookmarks*/
 
 // Status: not more than 19!
 #define FN_STAT_PAGE(FN_STAT + 1)
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 89c90a965cfd..8195259686eb 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -549,6 +549,11 @@ public:
 const OUString& rName,
 const OUString& rShortName,
 IDocumentMarkAccess::MarkType eMark = 
IDocumentMarkAccess::MarkType::BOOKMARK);
+::sw::mark::IMark* SetBookmark(
+const vcl::KeyCode&,
+const OUString& rName,
+bool rHide,
+const OUString& rCondition);
 bool GotoMark( const ::sw::mark::IMark* const pMark );// sets 
CurrentCursor.SPoint
 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
 bool GoNextBookmark(); // true, if there was one
diff --git a/sw/inc/globals.hrc b/sw/inc/globals.hrc
index 1959e52720cb..7d7f9909bed2 100644
--- a/sw/inc/globals.hrc
+++ b/sw/inc/globals.hrc
@@ -210,6 +210,8 @@
 #define SID_FAX_LIST(RC_GLOBALS_BEGIN +  116)
 #define SID_WRT_SHELL   (RC_GLOBALS_BEGIN +  117)
 
+#define STR_BOOKMARK_HIDDEN (RC_GLOBALS_BEGIN + 118)
+#define STR_BOOKMARK_CONDITION  (RC_GLOBALS_BEGIN + 119)
 
 #endif
 
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 63589f273ce5..c700ee3bb468 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -331,6 +331,8 @@
 #define UNO_NAME_IS_GLOBAL_DOCUMENT_SECTION "IsGlobalDocumentSection"
 #define UNO_NAME_TEXT_FIELD "TextField"
 #define UNO_NAME_BOOKMARK "Bookmark"
+#define UNO_NAME_BOOKMARK_HIDDEN "BookmarkHidden"
+#define UNO_NAME_BOOKMARK_CONDITION "BookmarkCondition"
 #define UNO_NAME_TEXT_TABLE "TextTable"
 #define UNO_NAME_CELL "Cell"
 #define UNO_NAME_TEXT_FRAME "TextFrame"
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 08594bc3d0e8..cd74c7adf102 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -286,6 +286,7 @@ namespace sw { namespace mark
 , ::sfx2::Metadatable()
 , m_aCode(rCode)
 , m_sShortName(rShortName)
+, m_bHidden(false)
 {
 m_aName = rName;
 }
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 946af35c5cae..d95eb1174d65 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -99,6 +99,31 @@ namespace
 }
 // set CurrentCursor.SPoint
 
+// at CurrentCursor.SPoint
+::sw::mark::IMark* SwCursorShell::SetBookmark(
+const vcl::KeyCode& rCode,
+const OUString& rName,
+bool rHide,
+const OUString& rCondition)
+{
+StartAction();
+::sw::mark::IMark* pMark = getIDocumentMarkAccess()->makeMark(
+*GetCursor(),
+rName,
+IDocumentMarkAccess::MarkType::BOOKMARK);
+::sw::mark::IBookmark* pBookmark = dynamic_cast< ::sw::mark::IBookmark* 
>(pMark);
+if (pBookmark)
+{
+pBookmark->SetKeyCode(rCode);
+pBookmark->SetShortName(OUString());
+pBookmark->Hide(rHide);
+pBookmark->SetHideCondition(rCondition);
+}
+EndAction();
+return pMark;
+}
+// set CurrentCursor.SPoint
+
 bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark, bool 
bAtStart)
 {
 // watch Cursor-Moves
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index ac5fae6a37db..cdb4a8422419 100644
--- a/sw/source/core/inc/bookmrk.hxx

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source xmloff/source

2018-01-09 Thread Bernhard Widl
 sw/inc/cmdid.h |2 +
 sw/inc/crsrsh.hxx  |5 ++
 sw/inc/unoprnms.hxx|2 +
 sw/source/core/crsr/crbm.cxx   |   25 
 sw/source/core/unocore/unobkm.cxx  |   74 -
 sw/source/core/unocore/unomap1.cxx |2 +
 sw/source/ui/misc/bookmark.cxx |2 -
 xmloff/source/text/txtparae.cxx|   24 
 8 files changed, 133 insertions(+), 3 deletions(-)

New commits:
commit b3226f8133ef28a0cc7328e419e0bf54abd3fda1
Author: Bernhard Widl 
Date:   Fri Dec 22 17:39:15 2017 +0100

tdf#101856 create bookmarks w/ new hidden/condition attrs, and save as odt

Change-Id: Ib1df7a4c1477693aa2d0ec067635cdcbd393cebd
Reviewed-on: https://gerrit.libreoffice.org/47598
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 09cd1f48513c..36a93cef8ba7 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -814,6 +814,8 @@
 #define FN_PARAM_PAM(FN_PARAM2+27) /* Point and Mark */
 #define FN_TEXT_BOX (FN_PARAM2+28) /* TextBox Property*/
 #define FN_PARAM_IGNORE_PROTECTED   (FN_PARAM2+29) /* Ignore protected 
areas */
+#define FN_BOOKMARK_HIDDEN  (FN_PARAM2+30) /* Hidden Property of 
bookmarks*/
+#define FN_BOOKMARK_CONDITION   (FN_PARAM2+31) /* Condition Property 
of bookmarks*/
 
 // Status: not more than 19!
 #define FN_STAT_PAGE(FN_STAT + 1)
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 89c90a965cfd..8195259686eb 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -549,6 +549,11 @@ public:
 const OUString& rName,
 const OUString& rShortName,
 IDocumentMarkAccess::MarkType eMark = 
IDocumentMarkAccess::MarkType::BOOKMARK);
+::sw::mark::IMark* SetBookmark(
+const vcl::KeyCode&,
+const OUString& rName,
+bool rHide,
+const OUString& rCondition);
 bool GotoMark( const ::sw::mark::IMark* const pMark );// sets 
CurrentCursor.SPoint
 bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
 bool GoNextBookmark(); // true, if there was one
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 63589f273ce5..c700ee3bb468 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -331,6 +331,8 @@
 #define UNO_NAME_IS_GLOBAL_DOCUMENT_SECTION "IsGlobalDocumentSection"
 #define UNO_NAME_TEXT_FIELD "TextField"
 #define UNO_NAME_BOOKMARK "Bookmark"
+#define UNO_NAME_BOOKMARK_HIDDEN "BookmarkHidden"
+#define UNO_NAME_BOOKMARK_CONDITION "BookmarkCondition"
 #define UNO_NAME_TEXT_TABLE "TextTable"
 #define UNO_NAME_CELL "Cell"
 #define UNO_NAME_TEXT_FRAME "TextFrame"
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 946af35c5cae..eff58b1f8ad6 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -99,6 +99,31 @@ namespace
 }
 // set CurrentCursor.SPoint
 
+// at CurrentCursor.SPoint
+::sw::mark::IMark* SwCursorShell::SetBookmark(
+const vcl::KeyCode& rCode,
+const OUString& rName,
+bool rHide,
+const OUString& rCondition)
+{
+StartAction();
+::sw::mark::IMark* pMark = getIDocumentMarkAccess()->makeMark(
+*GetCursor(),
+rName,
+IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New);
+::sw::mark::IBookmark* pBookmark = dynamic_cast< ::sw::mark::IBookmark* 
>(pMark);
+if (pBookmark)
+{
+pBookmark->SetKeyCode(rCode);
+pBookmark->SetShortName(OUString());
+pBookmark->Hide(rHide);
+pBookmark->SetHideCondition(rCondition);
+}
+EndAction();
+return pMark;
+}
+// set CurrentCursor.SPoint
+
 bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark, bool 
bAtStart)
 {
 // watch Cursor-Moves
diff --git a/sw/source/core/unocore/unobkm.cxx 
b/sw/source/core/unocore/unobkm.cxx
index feca7d3cdee8..bfd4bedc3975 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -52,13 +52,16 @@ public:
 ::comphelper::OInterfaceContainerHelper2  m_EventListeners;
 SwDoc * m_pDoc;
 ::sw::mark::IMark * m_pRegisteredBookmark;
-OUString m_sMarkName;
+OUStringm_sMarkName;
+boolm_bHidden;
+OUStringm_HideCondition;
 
 Impl(   SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/)
 : SwClient()
 , m_EventListeners(m_Mutex)
 , m_pDoc(pDoc)
 , m_pRegisteredBookmark(nullptr)
+, m_bHidden(false)
 {
 // DO NOT registerInMark here! (because SetXBookmark would delete 
rThis)
 }
@@ -106,6 +109,14 @@ void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis,
 else if (m_pRegisteredBookmark)
 {
 m_sMarkName = 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source

2017-12-12 Thread Jan-Marek Glogowski
 sw/inc/textboxhelper.hxx |   13 
 sw/source/core/doc/textboxhelper.cxx |   97 ---
 2 files changed, 110 deletions(-)

New commits:
commit 9e190bbb5d79805159d53a433826181df7f11982
Author: Jan-Marek Glogowski 
Date:   Fri Jul 22 18:00:59 2016 +0200

Remove now unused SwTextBoxHelper functions

(Manually cherry picked from commit 
f7f5d27066b696ac4e33246d3794bde8058e8622)

Change-Id: I39500424c79040b1887ea74081fdf0ea0bc5f009
Reviewed-on: https://gerrit.libreoffice.org/46331
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 98983bad9f42..32fc2167c72a 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -73,8 +73,6 @@ public:
 static SwFrameFormat* getOtherTextBoxFormat(const SwFrameFormat* pFormat, 
sal_uInt16 nType);
 /// If we have an associated TextFrame, then return that.
 static SwFrameFormat* 
getOtherTextBoxFormat(css::uno::Reference xShape);
-static SwFrameFormat* findTextBox(const SwFrameFormat* pShape);
-static SwFrameFormat* findTextBox(const 
css::uno::Reference& xShape);
 /// Return the textbox rectangle of a draw shape (in twips).
 static Rectangle getTextRectangle(SwFrameFormat* pShape, bool bAbsolute = 
true);
 
@@ -91,17 +89,6 @@ public:
 /// Is pObject a textbox of a drawinglayer shape?
 static bool isTextBox(const SdrObject* pObject);
 
-/// Look up TextFrames in a document, which are in fact TextBoxes.
-static std::set findTextBoxes(const SwDoc* pDoc);
-/**
- * Look up TextFrames in a document, which are in fact TextBoxes.
- *
- * If rNode has a matching SwContentFrame, then only TextBoxes of rNode are
- * returned.
- */
-static std::set findTextBoxes(const SwNode& rNode);
-/// Build a textbox -> shape format map.
-static std::map findShapes(const SwDoc* 
pDoc);
 /// Count number of shapes in the document, excluding TextBoxes.
 static sal_Int32 getCount(const SwDoc* pDoc);
 /// Count number of shapes on the page, excluding TextBoxes.
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 12464e37e4b6..23033eaeea38 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -126,27 +126,6 @@ void SwTextBoxHelper::destroy(SwFrameFormat* pShape)
 }
 }
 
-std::set SwTextBoxHelper::findTextBoxes(const SwDoc* 
pDoc)
-{
-std::set aTextBoxes;
-
-const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats();
-for (SwFrameFormats::const_iterator it = rSpzFrameFormats.begin(); it != 
rSpzFrameFormats.end(); ++it)
-{
-const SwFrameFormat* pFormat = *it;
-
-// A TextBox in the context of this class is a fly frame that has a
-// matching (same RES_CNTNT) draw frame.
-if (!pFormat->GetAttrSet().HasItem(RES_CNTNT) || 
!pFormat->GetContent().GetContentIdx())
-continue;
-
-if (pFormat->Which() == RES_FLYFRMFMT && nullptr != 
pFormat->GetOtherTextBoxFormat())
-aTextBoxes.insert(pFormat);
-}
-
-return aTextBoxes;
-}
-
 bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pShape, sal_uInt16 nType)
 {
assert(nType == RES_FLYFRMFMT || nType == RES_DRAWFRMFMT);
@@ -169,49 +148,6 @@ bool SwTextBoxHelper::isTextBox(const SwFrameFormat* 
pShape, sal_uInt16 nType)
return true;
 }
 
-std::set SwTextBoxHelper::findTextBoxes(const SwNode& 
rNode)
-{
-const SwDoc* pDoc = rNode.GetDoc();
-const SwContentNode* pContentNode = nullptr;
-const SwContentFrame* pContentFrame = nullptr;
-bool bHaveViewShell = 
pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
-if (bHaveViewShell && (pContentNode = rNode.GetContentNode()) && 
(pContentFrame = 
pContentNode->getLayoutFrame(pDoc->getIDocumentLayoutAccess().GetCurrentLayout(
-{
-// We can use the layout information to iterate over only the frames 
which are anchored to us.
-std::set aRet;
-const SwSortedObjs* pSortedObjs = pContentFrame->GetDrawObjs();
-if (pSortedObjs)
-{
-for (SwAnchoredObject* pAnchoredObject : *pSortedObjs)
-{
-SwFrameFormat* pTextBox = 
getOtherTextBoxFormat(>GetFrameFormat(), RES_DRAWFRMFMT);
-if (pTextBox)
-aRet.insert(pTextBox);
-}
-}
-return aRet;
-}
-else
-// If necessary, here we could manually limit the returned set to the
-// ones which are anchored to rNode, but currently no need to do so.
-return findTextBoxes(pDoc);
-}
-
-std::map SwTextBoxHelper::findShapes(const 
SwDoc* pDoc)
-{
-std::map aRet;
-
-const SwFrameFormats& 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source

2017-12-12 Thread Jan-Marek Glogowski
 sw/inc/frmfmt.hxx|6 ++
 sw/source/core/doc/DocumentLayoutManager.cxx |4 
 sw/source/core/doc/textboxhelper.cxx |   13 +
 sw/source/core/layout/atrfrm.cxx |   27 +--
 4 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 75bd6c311f518853fc31affe04fff717d741d575
Author: Jan-Marek Glogowski 
Date:   Fri Jul 22 17:23:40 2016 +0200

Link DRAW and FLY format for faster textbox lookup

Currently we have to rebuild the list of text boxes for every
lookup. Instead of a managed set, or a per-document list etc.,
this introduces direct pointers between the corresponding
SwDrawFramFormat and SwFlyFrameFormat of a text box.

(Manually cherry picked from commit 
5bed080c77f99f22fd52ad6cf2d6274e7c1e12a8)

Change-Id: Iefba2d153d9d8b3f1185aa305e9f463a50e78f89
Reviewed-on: https://gerrit.libreoffice.org/46305
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 4291ced05f6e..c2a19706160c 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -41,12 +41,15 @@ class SW_DLLPUBLIC SwFrameFormat: public SwFormat
 friend class SwDoc;
 friend class SwPageDesc;///< Is allowed to call protected CTor.
 friend class ::sw::DocumentLayoutManager; ///< Is allowed to call 
protected CTor.
+friend class SwTextBoxHelper;
 
 css::uno::WeakReference m_wXObject;
 
 // DrawingLayer FillAttributes in a preprocessed form for primitive 
usage
 drawinglayer::attribute::SdrAllFillAttributesHelperPtr  maFillAttributes;
 
+SwFrameFormat *m_pOtherTextBoxFormat;
+
 protected:
 SwFrameFormat(
 SwAttrPool& rPool,
@@ -64,6 +67,9 @@ protected:
 
 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue 
) override;
 
+SwFrameFormat* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; }
+void SetOtherTextBoxFormat( SwFrameFormat *pFormat );
+
 public:
 virtual ~SwFrameFormat();
 
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index c5380df0b3de..5fc0d4cc7483 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -510,6 +510,10 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
 SwFormatContent 
aContent(pDestTextBox->GetContent().GetContentIdx()->GetNode().GetStartNode());
 aSet.Put(aContent);
 pDest->SetFormatAttr(aSet);
+
+// Link FLY and DRAW formats, so it becomes a text box
+pDest->SetOtherTextBoxFormat(pDestTextBox);
+pDestTextBox->SetOtherTextBoxFormat(pDest);
 }
 
 return pDest;
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 61402fe02c94..c75908384ebf 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -55,6 +56,18 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape)
 uno::Reference 
xTextContentAppend(xTextDocument->getText(), uno::UNO_QUERY);
 xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence());
 
+// Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
+uno::Reference xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
+SwXTextFrame* pTextFrame = dynamic_cast(xRealTextFrame.get());
+assert(nullptr != pTextFrame);
+SwFrameFormat* pFormat = pTextFrame->GetFrameFormat();
+
+assert(nullptr != dynamic_cast(pShape));
+assert(nullptr != dynamic_cast(pFormat));
+
+pShape->SetOtherTextBoxFormat(pFormat);
+pFormat->SetOtherTextBoxFormat(pShape);
+
 // Initialize properties.
 uno::Reference xPropertySet(xTextFrame, 
uno::UNO_QUERY);
 uno::Any aEmptyBorder = uno::makeAny(table::BorderLine2());
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 849af3b88ed0..4a67225681e4 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2502,7 +2502,8 @@ SwFrameFormat::SwFrameFormat(
 const sal_uInt16* pWhichRange)
 :   SwFormat(rPool, pFormatNm, (pWhichRange ? pWhichRange : 
aFrameFormatSetRange), pDrvdFrame, nFormatWhich),
 m_wXObject(),
-maFillAttributes()
+maFillAttributes(),
+m_pOtherTextBoxFormat(nullptr)
 {
 }
 
@@ -2514,7 +2515,8 @@ SwFrameFormat::SwFrameFormat(
 const sal_uInt16* pWhichRange)
 :   SwFormat(rPool, rFormatNm, (pWhichRange ? pWhichRange : 
aFrameFormatSetRange), pDrvdFrame, nFormatWhich),
 m_wXObject(),
-maFillAttributes()
+maFillAttributes(),
+m_pOtherTextBoxFormat(nullptr)
 {
 }
 
@@ -2528,6 +2530,27 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source

2017-10-06 Thread Jan-Marek Glogowski
Rebased ref, commits from common ancestor:
commit c8377d3cada65d20786f52db0a14b7e7de6d8324
Author: Jan-Marek Glogowski 
Date:   Fri Oct 6 11:00:19 2017 +0200

Don't schedule the Idle job for busy documents

This refactors DocumentTimerManager to export the busy status
independent of the Idle function. This way it can be ignored in
the Scheduler while the document is busy,

Reviewed-on: https://gerrit.libreoffice.org/43197
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 
(cherry picked from commit 53da556c600fa82ba84bc7fdce6a594b43f2b097)

Conflicts:
sw/inc/doc.hxx
sw/source/core/doc/DocumentTimerManager.cxx
sw/source/core/inc/DocumentTimerManager.hxx

Change-Id: Icec2075d3338ad8dd4440678eb0570d7fe887778

diff --git a/sw/inc/IDocumentTimerAccess.hxx b/sw/inc/IDocumentTimerAccess.hxx
index 2cdb33e5ab7d..94947b35ac30 100644
--- a/sw/inc/IDocumentTimerAccess.hxx
+++ b/sw/inc/IDocumentTimerAccess.hxx
@@ -55,6 +55,11 @@ public:
 */
 virtual void StartBackgroundJobs() = 0;
 
+/**
+ * Is the document ready to be processed?
+ */
+virtual bool IsDocIdle() const = 0;
+
 protected:
 virtual ~IDocumentTimerAccess() {};
 };
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index f154c4379021..9ce4526fcd80 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -238,9 +238,6 @@ typedef std::vector 
SwPageDescs;
 
 void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem );
 
-// global function to start grammar checking in the document
-void StartGrammarChecking( SwDoc  );
-
 // Represents the model of a Writer document.
 class SW_DLLPUBLIC SwDoc :
 public IInterface
@@ -1651,6 +1648,12 @@ public:
 std::swap(mvUnoCursorTable, unoCursorTable);
 }
 
+/**
+ * @param bSkipStart don't actually start the jobs, just check
+ * @returns true if new background checking jobs were started
+ */
+bool StartGrammarChecking( bool bSkipStart = false );
+
 private:
 // Copies master header to left / first one, if necessary - used by 
ChgPageDesc().
 void CopyMasterHeader(const SwPageDesc , const SwFormatHeader 
, SwPageDesc , bool bLeft, bool bFirst);
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx 
b/sw/source/core/doc/DocumentTimerManager.cxx
index f3d71cd48a47..66018bcefca1 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -80,27 +80,16 @@ void DocumentTimerManager::StartBackgroundJobs()
 maDocIdle.Start();
 }
 
-IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
+DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
 {
-#ifdef TIMELOG
-static ::rtl::Logfile* pModLogFile = 0;
-if( !pModLogFile )
-pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
-#endif
-
 SwRootFrame* pTmpRoot = 
m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
 if( pTmpRoot &&
 !SfxProgress::GetActiveProgress( m_rDoc.GetDocShell() ) )
 {
 SwViewShell* 
pShell(m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell());
 for(SwViewShell& rSh : pShell->GetRingContainer())
-{
 if( rSh.ActionPend() )
-{
-pIdle->Start();
-return;
-}
-}
+return IdleJob::Busy;
 
 if( pTmpRoot->IsNeedGrammarCheck() )
 {
@@ -109,59 +98,93 @@ IMPL_LINK_TYPED( DocumentTimerManager, DoIdleJobs, Timer*, 
pIdle, void )
 SvtLinguConfig().GetProperty( OUString(
 UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
 
-if (bIsOnlineSpell && bIsAutoGrammar)
-StartGrammarChecking( m_rDoc );
+if( bIsOnlineSpell && bIsAutoGrammar && 
m_rDoc.StartGrammarChecking( true ) )
+return IdleJob::Grammar;
 }
-std::set aAllLayouts = m_rDoc.GetAllLayouts();
-std::set::iterator pLayIter = aAllLayouts.begin();
-for ( ;pLayIter != aAllLayouts.end();++pLayIter )
+
+for ( auto pLayout : m_rDoc.GetAllLayouts() )
 {
-if ((*pLayIter)->IsIdleFormat())
-{
-(*pLayIter)->GetCurrShell()->LayoutIdle();
-// Defer the remaining work.
-pIdle->Start();
-return;
-}
+if( pLayout->IsIdleFormat() )
+return IdleJob::Layout;
 }
 
 SwFieldUpdateFlags nFieldUpdFlag = 
m_rDoc.GetDocumentSettingManager().getFieldUpdateFlags(true);
 if( ( AUTOUPD_FIELD_ONLY == nFieldUpdFlag
-|| AUTOUPD_FIELD_AND_CHARTS == nFieldUpdFlag ) &&
-
m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().IsFieldsDirty()
-// If we switch the field name the Fields are not updated.
-